Skip to content

Commit

Permalink
Merge pull request #506 from snehilvj/dash-3-0
Browse files Browse the repository at this point in the history
Updates for Dash 3.0
  • Loading branch information
AnnMarieW authored Feb 7, 2025
2 parents c1cce96 + 6f76bf0 commit 4bc7952
Show file tree
Hide file tree
Showing 161 changed files with 781 additions and 1,158 deletions.
8 changes: 8 additions & 0 deletions .github/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ npm install
npm run build
```

Note: the build has a warning: ! Missing proptypes.js in dash_mantine_components/__init__.py !
Do not add that yet because it doesn't handle Mantine prop types correctly.


Push updated `package-lock.json`

2. Build source distribution.
Expand Down Expand Up @@ -73,3 +77,7 @@ Anything that’s not a major should be safe to just bump. The ones to pay atten
- types/ramda - just match ramda
- style-loader and css-loader - these are used together within the webpack config. IIRC these particular upgrades don’t require any changes to the config for our normal usage, so most likely it’ll just work. If the bundle builds without errors you’re fine, otherwise need to look at the docs for these packages.
- typescript - even if it's not a major bump, sometimes they tighten up their error checking in minor releases so the bundle fails to build and something about type annotations needs to be updated

Others:
- "dash-extensions-js": "^0.0.8" is required for the `renderDashComponent` function in Dash 2. Do not upgrade unless support for dash 2 is dropped or the newer version of dash-extensions is dash 2 compatible

15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Change Log

# 1.0.0rc1

### Pre-release Highlights
- This release ensures dash-mantine-components V1 is compatible with both Dash 2 and Dash 3
- If you were using `dmc >= 0.15.0`, there are no known breaking change.
- If you were using `dmc < 0.15.0`, please follow our [migration guide]().
- ⚠️ **Important:** Apps using `dmc < 1.0.0` must pin `dash < 3` to avoid compatibility issues.

### Changed
- Updated to handle changes in Dash 3 #506 by @AnnMarieW:
- Removed `defaultProps` to be compatible with React 18.3
- Handled the removal of the `loading_state` prop
- Updated to use the new `dash_component_api`


# 0.15.3

### Added
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash_mantine_components",
"version": "0.15.3",
"version": "1.0.0rc1",
"description": "Plotly Dash Components based on Mantine",
"main": "index.ts",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion requires-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dash[ci,dev,testing]>=2.0
dash[ci,dev,testing]>=2
pyyaml>=5.0
pytest<8.1.0
wheel
Expand Down
22 changes: 15 additions & 7 deletions src/ts/components/charts/AreaChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { DashBaseProps } from "props/dash";
import { StylesApiProps } from "props/styles";
import React, { useState, useRef } from "react";
import { getClickData, isEventValid } from "../../utils/charts";
import { getLoadingState } from "../../utils/dash3";

interface Props
extends BoxProps,
Expand Down Expand Up @@ -64,8 +65,19 @@ interface Props
}

/** AreaChart */
const AreaChart = (props: Props) => {
const { setProps, loading_state, clickData, hoverData, clickSeriesName, hoverSeriesName, series, highlightHover, areaChartProps, activeDotProps, areaProps, ...others } = props;
const AreaChart = ({
setProps,
loading_state,
clickData,
hoverData,
clickSeriesName,
hoverSeriesName,
series,
highlightHover = false,
areaChartProps,
activeDotProps,
areaProps,
...others }: Props) => {

const [highlightedArea, setHighlightedArea] = useState(null);
const shouldHighlight = highlightHover && highlightedArea !== null;
Expand Down Expand Up @@ -153,7 +165,7 @@ const AreaChart = (props: Props) => {

return (
<MantineAreaChart
data-dash-is-loading={(loading_state && loading_state.is_loading) || undefined}
data-dash-is-loading={getLoadingState(loading_state) || undefined}
areaChartProps={newProps}
series={series}
activeDotProps={{
Expand All @@ -168,8 +180,4 @@ const AreaChart = (props: Props) => {
);
}

AreaChart.defaultProps = {
highlightHover: false,
};

export default AreaChart;
27 changes: 15 additions & 12 deletions src/ts/components/charts/BarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { DashBaseProps } from "props/dash";
import { StylesApiProps } from "props/styles";
import React, { useState, useRef } from "react";
import { getClickData, isEventValid } from "../../utils/charts";
import { getLoadingState } from "../../utils/dash3";

interface Props
extends BoxProps,
Expand Down Expand Up @@ -53,11 +54,20 @@ interface Props
barLabelColor?: MantineColor;
}


/** BarChart */
const BarChart = (props: Props) => {
const {
setProps, loading_state, clickData, hoverData, barChartProps, clickSeriesName, hoverSeriesName, barProps,
highlightHover, ...others } = props;
const BarChart = ({
setProps,
loading_state,
clickData,
hoverData,
barChartProps,
clickSeriesName,
hoverSeriesName,
barProps,
highlightHover = false,
...others
}: Props) => {

const [highlightedArea, setHighlightedArea] = useState(null);
const shouldHighlight = highlightHover && highlightedArea !== null;
Expand Down Expand Up @@ -129,9 +139,7 @@ const BarChart = (props: Props) => {

return (
<MantineBarChart
data-dash-is-loading={
(loading_state && loading_state.is_loading) || undefined
}
data-dash-is-loading={getLoadingState(loading_state) || undefined}
barChartProps={newProps}
barProps={barPropsFunction}
{...others}
Expand All @@ -141,11 +149,6 @@ const BarChart = (props: Props) => {
};


BarChart.defaultProps = {
withBarValueLabel: false,
highlightHover: false,
};



export default BarChart;
7 changes: 2 additions & 5 deletions src/ts/components/charts/BubbleChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { DashBaseProps } from "props/dash";
import { StylesApiProps } from "props/styles";
import React from "react";
import { getScatterClickData, isEventValid } from "../../utils/charts";
import { getLoadingState } from "../../utils/dash3";

interface Props
extends BoxProps,
Expand Down Expand Up @@ -68,15 +69,11 @@ const BubbleChart = (props: Props) => {

return (
<MantineBubbleChart
data-dash-is-loading={
(loading_state && loading_state.is_loading) || undefined
}
data-dash-is-loading={getLoadingState(loading_state) || undefined}
scatterProps={newProps}
{...others}
/>
);
};

BubbleChart.defaultProps = {};

export default BubbleChart;
29 changes: 18 additions & 11 deletions src/ts/components/charts/CompositeChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { DashBaseProps } from "props/dash";
import { StylesApiProps } from "props/styles";
import React, { useRef, useState } from "react";
import { getClickData, isEventValid } from "../../utils/charts";
import { getLoadingState } from "../../utils/dash3";

interface Props
extends BoxProps,
Expand Down Expand Up @@ -62,10 +63,23 @@ interface Props
maxBarWidth?: number;
}


/** CompositeChart */
const CompositeChart = (props: Props) => {
const { setProps, loading_state, clickData, hoverData, highlightHover, hoverSeriesName, clickSeriesName, composedChartProps, barProps, lineProps, areaProps, activeDotProps, ...others } =
props;
const CompositeChart = ({
setProps,
loading_state,
clickData,
hoverData,
highlightHover = false,
hoverSeriesName,
clickSeriesName,
composedChartProps,
barProps,
lineProps,
areaProps,
activeDotProps,
...others
}: Props) => {

const [highlightedArea, setHighlightedArea] = useState(null);
const shouldHighlight = highlightHover && highlightedArea !== null;
Expand Down Expand Up @@ -159,9 +173,7 @@ const CompositeChart = (props: Props) => {

return (
<MantineCompositeChart
data-dash-is-loading={
(loading_state && loading_state.is_loading) || undefined
}
data-dash-is-loading={getLoadingState(loading_state) || undefined}
composedChartProps={newProps}
barProps={(item) => propsFunction(item, 'bar')} // Pass the chart type as 'bar'
lineProps={(item) => propsFunction(item, 'line')} // Pass the chart type as 'line'
Expand All @@ -177,10 +189,5 @@ const CompositeChart = (props: Props) => {
);
};

CompositeChart.defaultProps = {
withPointLabels: false,
withBarValueLabel: false,
highlightHover: false
};

export default CompositeChart;
9 changes: 4 additions & 5 deletions src/ts/components/charts/DonutChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { DashBaseProps } from "props/dash";
import { StylesApiProps } from "props/styles";
import React, { useState } from "react";
import { getPieClickData, isEventValid } from "../../utils/charts";
import { getLoadingState } from "../../utils/dash3";

interface Props extends BoxProps, StylesApiProps, DashBaseProps {
/** Data used to render chart */
Expand All @@ -15,9 +16,9 @@ interface Props extends BoxProps, StylesApiProps, DashBaseProps {
/** Tooltip animation duration in ms, `0` by default */
tooltipAnimationDuration?: number;
/** Props passed down to `Tooltip` recharts component */
tooltipProps?: any;
tooltipProps?: object;
/** Props passed down to recharts `Pie` component */
pieProps?: any;
pieProps?: object;
/** Controls color of the segments stroke, by default depends on color scheme */
strokeColor?: MantineColor;
/** Controls text color of all labels, by default depends on color scheme */
Expand Down Expand Up @@ -84,9 +85,7 @@ const DonutChart = (props: Props) => {

return (
<MantineDonutChart
data-dash-is-loading={
(loading_state && loading_state.is_loading) || undefined
}
data-dash-is-loading={getLoadingState(loading_state) || undefined}
pieProps={newProps}
{...others}
/>
Expand Down
24 changes: 16 additions & 8 deletions src/ts/components/charts/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { DashBaseProps } from "props/dash";
import { StylesApiProps } from "props/styles";
import React, { useState, useRef } from "react";
import { getClickData, isEventValid } from "../../utils/charts";
import { getLoadingState } from "../../utils/dash3";


interface Props
Expand Down Expand Up @@ -61,8 +62,20 @@ interface Props
}

/** Mantine-themed line chart built on top of the Recharts library, */
const LineChart = (props: Props) => {
const { setProps, loading_state, clickData, hoverData, clickSeriesName, hoverSeriesName, series, highlightHover, lineChartProps, activeDotProps, lineProps, ...others } = props;
const LineChart = ({
setProps,
loading_state,
clickData,
hoverData,
clickSeriesName,
hoverSeriesName,
series,
highlightHover = false,
lineChartProps,
activeDotProps,
lineProps,
...others
}: Props) => {

const [highlightedArea, setHighlightedArea] = useState(null);
const shouldHighlight = highlightHover && highlightedArea !== null;
Expand Down Expand Up @@ -149,9 +162,7 @@ const LineChart = (props: Props) => {

return (
<MantineLineChart
data-dash-is-loading={
(loading_state && loading_state.is_loading) || undefined
}
data-dash-is-loading={getLoadingState(loading_state) || undefined}
lineChartProps={newProps}
series={series}
activeDotProps={{
Expand All @@ -166,8 +177,5 @@ const LineChart = (props: Props) => {
);
};

LineChart.defaultProps = {
highlightHover: false,
};

export default LineChart;
5 changes: 2 additions & 3 deletions src/ts/components/charts/PieChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { DashBaseProps } from "props/dash";
import { StylesApiProps } from "props/styles";
import React, { useState } from "react";
import { getPieClickData, isEventValid } from "../../utils/charts";
import { getLoadingState } from "../../utils/dash3";

interface Props extends BoxProps, StylesApiProps, DashBaseProps {
/** Data used to render chart */
Expand Down Expand Up @@ -84,9 +85,7 @@ const PieChart = (props: Props) => {

return (
<MantinePieChart
data-dash-is-loading={
(loading_state && loading_state.is_loading) || undefined
}
data-dash-is-loading={getLoadingState(loading_state) || undefined}
pieProps={newProps}
{...others}
/>
Expand Down
7 changes: 2 additions & 5 deletions src/ts/components/charts/RadarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { DashBaseProps } from "props/dash";
import { StylesApiProps } from "props/styles";
import React from "react";
import { getClickData, isEventValid } from "../../utils/charts";
import { getLoadingState } from "../../utils/dash3";

interface Props extends BoxProps, StylesApiProps, DashBaseProps {
/** Data used in the chart */
Expand Down Expand Up @@ -59,15 +60,11 @@ const RadarChart = (props: Props) => {

return (
<MantineRadarChart
data-dash-is-loading={
(loading_state && loading_state.is_loading) || undefined
}
data-dash-is-loading={getLoadingState(loading_state) || undefined}
radarChartProps={newProps}
{...others}
/>
);
};

RadarChart.defaultProps = {};

export default RadarChart;
6 changes: 2 additions & 4 deletions src/ts/components/charts/ScatterChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { DashBaseProps } from "props/dash";
import { StylesApiProps } from "props/styles";
import React from "react";
import { getScatterClickData, isEventValid } from "../../utils/charts";
import { getLoadingState } from "../../utils/dash3";

interface Props
extends BoxProps,
Expand Down Expand Up @@ -74,15 +75,12 @@ const ScatterChart = (props: Props) => {

return (
<MantineScatterChart
data-dash-is-loading={
(loading_state && loading_state.is_loading) || undefined
}
data-dash-is-loading={getLoadingState(loading_state) || undefined}
scatterProps={newProps}
{...others}
/>
);
};

ScatterChart.defaultProps = {};

export default ScatterChart;
Loading

0 comments on commit 4bc7952

Please sign in to comment.