@mittwald/flow-react-components 0.2.0-alpha.674 → 0.2.0-alpha.675
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/assets/doc-properties.json +122 -122
- package/dist/css/all.css +1 -1
- package/dist/js/components/src/components/CartesianChart/CartesianChart.mjs +36 -188
- package/dist/js/components/src/components/CartesianChart/CartesianChart.mjs.map +1 -1
- package/dist/js/components/src/components/CartesianChart/CartesianChart.module.scss.mjs +4 -2
- package/dist/js/components/src/components/CartesianChart/CartesianChart.module.scss.mjs.map +1 -1
- package/dist/js/components/src/components/CartesianChart/hooks/useChartClipRect.mjs +71 -0
- package/dist/js/components/src/components/CartesianChart/hooks/useChartClipRect.mjs.map +1 -0
- package/dist/js/flr-universal.mjs +2 -0
- package/dist/js/flr-universal.mjs.map +1 -1
- package/dist/types/components/CartesianChart/CartesianChart.d.ts +6 -5
- package/dist/types/components/CartesianChart/CartesianChart.d.ts.map +1 -1
- package/dist/types/components/CartesianChart/hooks/useChartClipRect.d.ts +2 -0
- package/dist/types/components/CartesianChart/hooks/useChartClipRect.d.ts.map +1 -0
- package/package.json +4 -4
|
@@ -1,204 +1,52 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
3
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
4
|
+
import { ResponsiveContainer, ComposedChart } from 'recharts';
|
|
5
|
+
import { useMemo, isValidElement } from 'react';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
7
|
import styles from './CartesianChart.module.scss.mjs';
|
|
8
|
+
import { useChartClipRect } from './hooks/useChartClipRect.mjs';
|
|
9
|
+
import DivView from '../../views/DivView.mjs';
|
|
8
10
|
import { Wrap } from '../Wrap/Wrap.mjs';
|
|
9
|
-
import '../AccentBox/AccentBox.mjs';
|
|
10
|
-
import '../../lib/propsContext/propsContext.mjs';
|
|
11
|
-
import '../../lib/propsContext/components/PropsContextProvider.mjs';
|
|
12
|
-
import '../Button/Button.mjs';
|
|
13
|
-
import '@tabler/icons-react';
|
|
14
|
-
import '../Icon/Icon.mjs';
|
|
15
|
-
import '../../views/IconView.mjs';
|
|
16
|
-
import '@mittwald/react-tunnel';
|
|
17
|
-
import '../Activity/Activity.mjs';
|
|
18
|
-
import '../Action/Action.mjs';
|
|
19
|
-
import 'react-aria';
|
|
20
|
-
import '@react-aria/live-announcer';
|
|
21
|
-
import '../ActionGroup/ActionGroup.mjs';
|
|
22
|
-
import '../Alert/Alert.mjs';
|
|
23
|
-
import '../AlertBadge/AlertBadge.mjs';
|
|
24
|
-
import '../AlertText/AlertText.mjs';
|
|
25
|
-
import '../Align/Align.mjs';
|
|
26
|
-
import '../Autocomplete/Autocomplete.mjs';
|
|
27
|
-
import '../Avatar/Avatar.mjs';
|
|
28
|
-
import '../Badge/Badge.mjs';
|
|
29
|
-
import 'react-aria-components';
|
|
30
|
-
import 'mobx';
|
|
31
|
-
import '../../lib/controller/overlay/context.mjs';
|
|
32
|
-
import 'remeda';
|
|
33
|
-
import '@react-aria/utils';
|
|
34
|
-
import 'dot-prop';
|
|
35
|
-
import '../../lib/tokens/CategoricalColors.mjs';
|
|
36
|
-
import '../Text/Text.mjs';
|
|
37
|
-
import '@mittwald/react-use-promise';
|
|
38
|
-
import '../Heading/Heading.mjs';
|
|
39
|
-
import '../../views/SkeletonTextView.mjs';
|
|
40
|
-
import '../../views/LoadingSpinnerView.mjs';
|
|
41
|
-
import { CartesianGrid } from './components/CartesianGrid/CartesianGrid.mjs';
|
|
42
|
-
import '../Checkbox/Checkbox.mjs';
|
|
43
|
-
import '../CheckboxButton/CheckboxButton.mjs';
|
|
44
|
-
import '../CheckboxGroup/CheckboxGroup.mjs';
|
|
45
|
-
import 'react-syntax-highlighter';
|
|
46
|
-
import '../CopyButton/CopyButton.mjs';
|
|
47
|
-
import '../ColumnLayout/ColumnLayout.mjs';
|
|
48
|
-
import '../ComboBox/ComboBox.mjs';
|
|
49
|
-
import '../../lib/propsContext/components/ComponentPropsContextProvider.mjs';
|
|
50
|
-
import '../Content/Content.mjs';
|
|
51
|
-
import '../ContextMenu/ContextMenu.mjs';
|
|
52
|
-
import '../MenuItem/MenuItem.mjs';
|
|
53
|
-
import '../ContextMenu/components/ContextMenuTrigger/ContextMenuTrigger.mjs';
|
|
54
|
-
import '../ContextMenu/components/ContextMenuSection/ContextMenuSection.mjs';
|
|
55
|
-
import '../ContextualHelp/ContextualHelp.mjs';
|
|
56
|
-
import '../ContextualHelp/components/ContextualHelpTrigger/ContextualHelpTrigger.mjs';
|
|
57
|
-
import '../CounterBadge/CounterBadge.mjs';
|
|
58
|
-
import '../CountryOptions/CountryOptions.mjs';
|
|
59
|
-
import '../DatePicker/DatePicker.mjs';
|
|
60
|
-
import '../DateRangePicker/DateRangePicker.mjs';
|
|
61
|
-
import '../FieldDescription/FieldDescription.mjs';
|
|
62
|
-
import '../FieldError/FieldError.mjs';
|
|
63
|
-
import '../FileCard/FileCard.mjs';
|
|
64
|
-
import '../FileCardList/FileCardList.mjs';
|
|
65
|
-
import '../FileDropZone/FileDropZone.mjs';
|
|
66
|
-
import '../FileField/FileField.mjs';
|
|
67
|
-
import '../Header/Header.mjs';
|
|
68
|
-
import '../IllustratedMessage/IllustratedMessage.mjs';
|
|
69
|
-
import '../Image/Image.mjs';
|
|
70
|
-
import '../Initials/Initials.mjs';
|
|
71
|
-
import '../Label/Label.mjs';
|
|
72
|
-
import '../LayoutCard/LayoutCard.mjs';
|
|
73
|
-
import '../OverlayTrigger/components/MenuTrigger/MenuTrigger.mjs';
|
|
74
|
-
import '../../views/DialogTriggerView.mjs';
|
|
75
|
-
import '../LightBox/LightBox.mjs';
|
|
76
|
-
import '../Link/Link.mjs';
|
|
77
|
-
import 'invariant';
|
|
78
|
-
import '../../views/ListItemViewContentView.mjs';
|
|
79
|
-
import '../../views/ButtonView.mjs';
|
|
80
|
-
import '../../views/ContextMenuTriggerView.mjs';
|
|
81
|
-
import '../List/components/ListSummary/ListSummary.mjs';
|
|
82
|
-
import '../List/listContext.mjs';
|
|
83
|
-
import '../List/List.mjs';
|
|
84
|
-
import 'react-markdown';
|
|
85
|
-
import 'remark-gfm';
|
|
86
|
-
import '../MarkdownEditor/MarkdownEditor.mjs';
|
|
87
|
-
import '../Message/Message.mjs';
|
|
88
|
-
import '../MessageThread/MessageThread.mjs';
|
|
89
|
-
import '../Modal/Modal.mjs';
|
|
90
|
-
import '../Navigation/Navigation.mjs';
|
|
91
|
-
import '../Navigation/components/NavigationGroup/NavigationGroup.mjs';
|
|
92
|
-
import '../NotificationProvider/NotificationProvider.mjs';
|
|
93
|
-
import 'luxon';
|
|
94
|
-
import '../NumberField/NumberField.mjs';
|
|
95
|
-
import '../Option/Option.mjs';
|
|
96
|
-
import '../../views/OverlayContentView.mjs';
|
|
97
|
-
import '../PasswordCreationField/PasswordCreationField.mjs';
|
|
98
|
-
import '../Popover/components/PopoverTrigger/PopoverTrigger.mjs';
|
|
99
|
-
import '../Popover/Popover.mjs';
|
|
100
|
-
import '../ProgressBar/ProgressBar.mjs';
|
|
101
|
-
import '../RadioGroup/RadioGroup.mjs';
|
|
102
|
-
import '../RadioGroup/components/Radio/Radio.mjs';
|
|
103
|
-
import '../RadioGroup/components/RadioButton/RadioButton.mjs';
|
|
104
|
-
import '../Rating/Rating.mjs';
|
|
105
|
-
import '../SearchField/SearchField.mjs';
|
|
106
|
-
import '../Section/Section.mjs';
|
|
107
|
-
import '../SegmentedControl/SegmentedControl.mjs';
|
|
108
|
-
import '../SegmentedControl/components/Segment/Segment.mjs';
|
|
109
|
-
import '../Select/Select.mjs';
|
|
110
|
-
import '../SettingsProvider/SettingsProvider.mjs';
|
|
111
|
-
import '../Slider/Slider.mjs';
|
|
112
|
-
import '../SuspenseTrigger/SuspenseTrigger.mjs';
|
|
113
|
-
import '../Switch/Switch.mjs';
|
|
114
|
-
import '../Tabs/Tabs.mjs';
|
|
115
|
-
import '../Tabs/components/Tab/context.mjs';
|
|
116
|
-
import '../TextArea/TextArea.mjs';
|
|
117
|
-
import '../TextField/TextField.mjs';
|
|
118
|
-
import '../TimeField/TimeField.mjs';
|
|
119
|
-
import '../TranslationProvider/TranslationProvider.mjs';
|
|
120
|
-
import 'react-truncate-inside';
|
|
121
11
|
|
|
122
12
|
const CartesianChart = (props) => {
|
|
123
|
-
const {
|
|
124
|
-
|
|
125
|
-
|
|
13
|
+
const { children, data, className, height, flexGrow, emptyView, ...rest } = props;
|
|
14
|
+
const { viewDimensions, ref: containerRef } = useChartClipRect();
|
|
15
|
+
const showEmptyView = !!((!data || data.length === 0) && emptyView);
|
|
16
|
+
const rootClassName = clsx(
|
|
17
|
+
styles.cartesianChart,
|
|
126
18
|
className,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const rootClassName = clsx(styles.cartesianChart, className);
|
|
133
|
-
const otherChildren = [];
|
|
134
|
-
const gridChildren = [];
|
|
135
|
-
Children.forEach(children, (child) => {
|
|
136
|
-
if (!child) return;
|
|
137
|
-
const element = child;
|
|
138
|
-
if (element.type === CartesianGrid) {
|
|
139
|
-
gridChildren.push(element);
|
|
140
|
-
} else {
|
|
141
|
-
otherChildren.push(element);
|
|
19
|
+
showEmptyView && styles.emptyView
|
|
20
|
+
);
|
|
21
|
+
const emptyElement = useMemo(() => {
|
|
22
|
+
if (isValidElement(emptyView)) {
|
|
23
|
+
return emptyView;
|
|
142
24
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const chartContainerRef = useRef(null);
|
|
146
|
-
const [viewDimensions, setViewDimensions] = useState(null);
|
|
147
|
-
useEffect(() => {
|
|
148
|
-
if (showEmptyView) {
|
|
149
|
-
const updateDimensions = () => {
|
|
150
|
-
const svg = chartContainerRef.current?.querySelector(
|
|
151
|
-
"svg"
|
|
152
|
-
);
|
|
153
|
-
if (!svg) return;
|
|
154
|
-
const clip = svg.querySelector("clipPath rect");
|
|
155
|
-
if (clip) {
|
|
156
|
-
const x = parseFloat(clip.getAttribute("x") ?? "0");
|
|
157
|
-
const y = parseFloat(clip.getAttribute("y") ?? "0");
|
|
158
|
-
const width = parseFloat(clip.getAttribute("width") ?? "0");
|
|
159
|
-
const height2 = parseFloat(clip.getAttribute("height") ?? "0");
|
|
160
|
-
setViewDimensions({ x, y, width, height: height2 });
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
updateDimensions();
|
|
164
|
-
const container = chartContainerRef.current;
|
|
165
|
-
const observer = new ResizeObserver(updateDimensions);
|
|
166
|
-
if (container) observer.observe(container);
|
|
167
|
-
return () => {
|
|
168
|
-
observer.disconnect();
|
|
169
|
-
};
|
|
25
|
+
if (!emptyView) {
|
|
26
|
+
return;
|
|
170
27
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
28
|
+
console.warn(
|
|
29
|
+
"CartesianChart: emptyView as a non-element is deprecated and will be removed in a future release. Please provide an element as emptyView."
|
|
30
|
+
);
|
|
31
|
+
return null;
|
|
32
|
+
}, [emptyView]);
|
|
33
|
+
return /* @__PURE__ */ jsx(Wrap, { if: height, children: /* @__PURE__ */ jsx("div", { style: { height, flex: flexGrow ? 1 : void 0 }, children: /* @__PURE__ */ jsx(
|
|
34
|
+
ResponsiveContainer,
|
|
174
35
|
{
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
{
|
|
188
|
-
data,
|
|
189
|
-
className: rootClassName,
|
|
190
|
-
...rest,
|
|
191
|
-
children: [
|
|
192
|
-
!showEmptyView && gridChildren,
|
|
193
|
-
otherChildren,
|
|
194
|
-
showEmptyView && viewDimensions && /* @__PURE__ */ jsx("foreignObject", { ...viewDimensions, children: /* @__PURE__ */ jsx("div", { className: styles.emptyViewContainer, children: /* @__PURE__ */ jsx(EmptyView, { data }) }) })
|
|
195
|
-
]
|
|
196
|
-
}
|
|
197
|
-
)
|
|
198
|
-
}
|
|
199
|
-
)
|
|
36
|
+
initialDimension: {
|
|
37
|
+
// fix warning on initial render
|
|
38
|
+
width: 1,
|
|
39
|
+
height: 1
|
|
40
|
+
},
|
|
41
|
+
width: height ? void 0 : "100%",
|
|
42
|
+
aspect: height ? void 0 : 3,
|
|
43
|
+
ref: containerRef,
|
|
44
|
+
children: /* @__PURE__ */ jsxs(ComposedChart, { data, className: rootClassName, ...rest, children: [
|
|
45
|
+
children,
|
|
46
|
+
showEmptyView && viewDimensions && /* @__PURE__ */ jsx("foreignObject", { ...viewDimensions, children: /* @__PURE__ */ jsx(DivView, { className: styles.emptyViewContainer, children: emptyElement }) })
|
|
47
|
+
] })
|
|
200
48
|
}
|
|
201
|
-
) });
|
|
49
|
+
) }) });
|
|
202
50
|
};
|
|
203
51
|
|
|
204
52
|
export { CartesianChart };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CartesianChart.mjs","sources":["../../../../../../src/components/CartesianChart/CartesianChart.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"CartesianChart.mjs","sources":["../../../../../../src/components/CartesianChart/CartesianChart.tsx"],"sourcesContent":["import { ComposedChart, ResponsiveContainer } from \"recharts\";\nimport React, {\n type ComponentProps,\n type FC,\n isValidElement,\n type PropsWithChildren,\n type ReactNode,\n useMemo,\n} from \"react\";\nimport clsx from \"clsx\";\nimport styles from \"./CartesianChart.module.scss\";\nimport { useChartClipRect } from \"@/components/CartesianChart/hooks/useChartClipRect\";\nimport DivView from \"@/views/DivView\";\nimport Wrap from \"@/components/Wrap\";\n\n/** @deprecated Use a ReactNode instead */\nexport interface CartesianChartEmptyViewProps {\n data?: ComponentProps<typeof ComposedChart>[\"data\"];\n}\n\nexport interface CartesianChartProps\n extends\n Pick<\n ComponentProps<typeof ComposedChart>,\n \"data\" | \"className\" | \"syncId\" | \"syncMethod\"\n >,\n PropsWithChildren {\n height?: string;\n\n /** View that is provided when data is empty/undefined */\n emptyView?: ReactNode;\n\n /**\n * Allow the height controlling container to set flex-grow: 1. Can only be\n * used in combination with `height`\n */\n flexGrow?: boolean;\n}\n\n/** @flr-generate all */\nexport const CartesianChart: FC<CartesianChartProps> = (props) => {\n const { children, data, className, height, flexGrow, emptyView, ...rest } =\n props;\n\n const { viewDimensions, ref: containerRef } = useChartClipRect();\n\n const showEmptyView = !!((!data || data.length === 0) && emptyView);\n const rootClassName = clsx(\n styles.cartesianChart,\n className,\n showEmptyView && styles.emptyView,\n );\n\n const emptyElement = useMemo(() => {\n if (isValidElement(emptyView)) {\n return emptyView;\n }\n\n if (!emptyView) {\n return;\n }\n\n console.warn(\n \"CartesianChart: emptyView as a non-element is deprecated and will be removed in a future release. Please provide an element as emptyView.\",\n );\n return null;\n }, [emptyView]);\n\n return (\n <Wrap if={height}>\n <div style={{ height, flex: flexGrow ? 1 : undefined }}>\n <ResponsiveContainer\n initialDimension={{\n // fix warning on initial render\n width: 1,\n height: 1,\n }}\n width={height ? undefined : \"100%\"}\n aspect={height ? undefined : 3}\n ref={containerRef}\n >\n <ComposedChart data={data} className={rootClassName} {...rest}>\n {children}\n {showEmptyView && viewDimensions && (\n <foreignObject {...viewDimensions}>\n <DivView className={styles.emptyViewContainer}>\n {emptyElement}\n </DivView>\n </foreignObject>\n )}\n </ComposedChart>\n </ResponsiveContainer>\n </div>\n </Wrap>\n );\n};\n\nexport default CartesianChart;\n"],"names":[],"mappings":";;;;;;;;;AAwCO,MAAM,cAAA,GAA0C,CAAC,KAAA,KAAU;AAChE,EAAA,MAAM,EAAE,UAAU,IAAA,EAAM,SAAA,EAAW,QAAQ,QAAA,EAAU,SAAA,EAAW,GAAG,IAAA,EAAK,GACtE,KAAA;AAEF,EAAA,MAAM,EAAE,cAAA,EAAgB,GAAA,EAAK,YAAA,KAAiB,gBAAA,EAAiB;AAE/D,EAAA,MAAM,gBAAgB,CA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AQ,SAAA,EAAW,MAAA,CAAO,kBAAA,EACxB,QAAA,EAAA,YAAA,EACH,CAAA,EACF;AAAA,OAAA,EAEJ;AAAA;AAAA,KAEJ,CAAA,EACF,CAAA;AAEJ;;;;"}
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
/* */
|
|
3
3
|
const cartesianChart = "flow--cartesian-chart";
|
|
4
4
|
const emptyViewContainer = "flow--cartesian-chart--empty-view-container";
|
|
5
|
+
const emptyView = "flow--cartesian-chart--empty-view";
|
|
5
6
|
const styles = {
|
|
6
7
|
cartesianChart: cartesianChart,
|
|
7
|
-
emptyViewContainer: emptyViewContainer
|
|
8
|
+
emptyViewContainer: emptyViewContainer,
|
|
9
|
+
emptyView: emptyView
|
|
8
10
|
};
|
|
9
11
|
|
|
10
|
-
export { cartesianChart, styles as default, emptyViewContainer };
|
|
12
|
+
export { cartesianChart, styles as default, emptyView, emptyViewContainer };
|
|
11
13
|
//# sourceMappingURL=CartesianChart.module.scss.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CartesianChart.module.scss.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CartesianChart.module.scss.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
import { useRef, useState, useEffect } from 'react';
|
|
4
|
+
import { useCallbackRef } from 'use-callback-ref';
|
|
5
|
+
|
|
6
|
+
const useChartClipRect = () => {
|
|
7
|
+
const observerRef = useRef(null);
|
|
8
|
+
const svgRef = useRef(null);
|
|
9
|
+
const [viewDimensions, setViewDimensions] = useState(null);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
return () => {
|
|
12
|
+
if (observerRef.current) {
|
|
13
|
+
observerRef.current.disconnect();
|
|
14
|
+
observerRef.current = null;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}, []);
|
|
18
|
+
const attachContainerRef = useCallbackRef(
|
|
19
|
+
null,
|
|
20
|
+
(div) => {
|
|
21
|
+
if (observerRef.current) {
|
|
22
|
+
observerRef.current.disconnect();
|
|
23
|
+
observerRef.current = null;
|
|
24
|
+
}
|
|
25
|
+
const svg = div?.querySelector("svg") ?? null;
|
|
26
|
+
svgRef.current = svg;
|
|
27
|
+
if (!svg) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const clipRect = svg.querySelector(
|
|
31
|
+
"clipPath rect"
|
|
32
|
+
);
|
|
33
|
+
if (!clipRect) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const observer = new MutationObserver((mutations) => {
|
|
37
|
+
const newViewDimensions = mutations.reduce(
|
|
38
|
+
(acc, mutation) => {
|
|
39
|
+
if (mutation.type !== "attributes" || !mutation.attributeName) {
|
|
40
|
+
return acc;
|
|
41
|
+
}
|
|
42
|
+
const target = mutation.target;
|
|
43
|
+
const attr = mutation.attributeName;
|
|
44
|
+
const value = target.getAttribute(attr);
|
|
45
|
+
if (value) {
|
|
46
|
+
acc = {
|
|
47
|
+
...acc,
|
|
48
|
+
[attr]: value
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return acc;
|
|
52
|
+
},
|
|
53
|
+
viewDimensions ?? { x: "0", y: "0", width: "0", height: "0" }
|
|
54
|
+
);
|
|
55
|
+
setViewDimensions(newViewDimensions);
|
|
56
|
+
});
|
|
57
|
+
observer.observe(clipRect, {
|
|
58
|
+
attributes: true,
|
|
59
|
+
attributeFilter: ["x", "y", "width", "height"],
|
|
60
|
+
attributeOldValue: false,
|
|
61
|
+
childList: false,
|
|
62
|
+
subtree: false
|
|
63
|
+
});
|
|
64
|
+
observerRef.current = observer;
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
return { viewDimensions, ref: attachContainerRef };
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export { useChartClipRect };
|
|
71
|
+
//# sourceMappingURL=useChartClipRect.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChartClipRect.mjs","sources":["../../../../../../../src/components/CartesianChart/hooks/useChartClipRect.ts"],"sourcesContent":["import { type SVGProps, useEffect, useRef, useState } from \"react\";\nimport { useCallbackRef } from \"use-callback-ref\";\n\n/** @internal * */\nexport type ViewDimensions = Pick<\n SVGProps<SVGForeignObjectElement>,\n \"x\" | \"y\" | \"width\" | \"height\"\n> | null;\n\n/** @internal * */\nexport const useChartClipRect = () => {\n const observerRef = useRef<MutationObserver>(null);\n const svgRef = useRef<SVGSVGElement>(null);\n\n const [viewDimensions, setViewDimensions] = useState<ViewDimensions>(null);\n\n useEffect(() => {\n return () => {\n if (observerRef.current) {\n observerRef.current.disconnect();\n observerRef.current = null;\n }\n };\n }, []);\n\n const attachContainerRef = useCallbackRef(\n null,\n (div: HTMLDivElement | null) => {\n if (observerRef.current) {\n observerRef.current.disconnect();\n observerRef.current = null;\n }\n\n const svg = div?.querySelector(\"svg\") ?? null;\n svgRef.current = svg;\n\n if (!svg) {\n return;\n }\n\n const clipRect = svg.querySelector(\n \"clipPath rect\",\n ) as SVGRectElement | null;\n if (!clipRect) {\n return;\n }\n\n const observer = new MutationObserver((mutations) => {\n const newViewDimensions: ViewDimensions = mutations.reduce(\n (acc, mutation) => {\n if (mutation.type !== \"attributes\" || !mutation.attributeName) {\n return acc;\n }\n\n const target = mutation.target as SVGRectElement;\n const attr = mutation.attributeName as keyof ViewDimensions;\n const value = target.getAttribute(attr);\n\n if (value) {\n acc = {\n ...acc,\n [attr]: value,\n };\n }\n\n return acc;\n },\n viewDimensions ?? { x: \"0\", y: \"0\", width: \"0\", height: \"0\" },\n );\n\n setViewDimensions(newViewDimensions);\n });\n\n observer.observe(clipRect, {\n attributes: true,\n attributeFilter: [\"x\", \"y\", \"width\", \"height\"],\n attributeOldValue: false,\n childList: false,\n subtree: false,\n });\n\n observerRef.current = observer;\n },\n );\n\n return { view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EAAe;AAC7D,cAAA,OAAO,GAAA;AAAA,YACT;AAEA,YAAA,MAAM,SAAS,QAAA,CAAS,MAAA;AACxB,YAAA,MAAM,OAAO,QAAA,CAAS,aAAA;AACtB,YAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,YAAA,CAAa,IAAI,CAAA;AAEtC,YAAA,IAAI,KAAA,EAAO;AACT,cAAA,GAAA,GAAM;AAAA,gBACJ,GAAG,GAAA;AAAA,gBACH,CAAC,IAAI,GAAG;AAAA,eACV;AAAA,YACF;AAEA,YAAA,OAAO,GAAA;AAAA,UACT,CAAA;AAAA,UACA,cAAA,IAAkB,EAAE,CAAA,EAAG,GAAA,EAAK,GAAG,GAAA,EAAK,KAAA,EAAO,GAAA,EAAK,MAAA,EAAQ,GAAA;AAAI,SAC9D;AAEA,QAAA,iBAAA,CAAkB,iBAAiB,CAAA;AAAA,MACrC,CAAC,CAAA;AAED,MAAA,QAAA,CAAS,QAAQ,QAAA,EAAU;AAAA,QACzB,UAAA,EAAY,IAAA;AAAA,QACZ,eAAA,EAAiB,CAAC,GAAA,EAAK,GAAA,EAAK,SAAS,QAAQ,CAAA;AAAA,QAC7C,iBAAA,EAAmB,KAAA;AAAA,QACnB,SAAA,EAAW,KAAA;AAAA,QACX,OAAA,EAAS;AAAA,OACV,CAAA;AAED,MAAA,WAAA,CAAY,OAAA,GAAU,QAAA;AAAA,IACxB;AAAA,GACF;AAEA,EAAA,OAAO,EAAE,cAAA,EAAgB,GAAA,EAAK,kBAAA,EAAmB;AACnD;;;;"}
|
|
@@ -145,6 +145,8 @@ import './components/src/components/Badge/Badge.mjs';
|
|
|
145
145
|
import 'react-aria-components';
|
|
146
146
|
export { BrowserOnly } from './components/src/components/BrowserOnly/BrowserOnly.mjs';
|
|
147
147
|
import 'recharts';
|
|
148
|
+
import 'use-callback-ref';
|
|
149
|
+
import './components/src/views/DivView.mjs';
|
|
148
150
|
import './components/src/lib/tokens/CategoricalColors.mjs';
|
|
149
151
|
import './components/src/components/Text/Text.mjs';
|
|
150
152
|
import '@mittwald/react-use-promise';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flr-universal.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"flr-universal.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { ComposedChart } from 'recharts';
|
|
2
|
+
import { ComponentProps, FC, PropsWithChildren, ReactNode } from 'react';
|
|
3
|
+
/** @deprecated Use a ReactNode instead */
|
|
3
4
|
export interface CartesianChartEmptyViewProps {
|
|
4
|
-
data?: ComponentProps<typeof
|
|
5
|
+
data?: ComponentProps<typeof ComposedChart>["data"];
|
|
5
6
|
}
|
|
6
|
-
export interface CartesianChartProps extends Pick<ComponentProps<typeof
|
|
7
|
+
export interface CartesianChartProps extends Pick<ComponentProps<typeof ComposedChart>, "data" | "className" | "syncId" | "syncMethod">, PropsWithChildren {
|
|
7
8
|
height?: string;
|
|
8
9
|
/** View that is provided when data is empty/undefined */
|
|
9
|
-
emptyView?:
|
|
10
|
+
emptyView?: ReactNode;
|
|
10
11
|
/**
|
|
11
12
|
* Allow the height controlling container to set flex-grow: 1. Can only be
|
|
12
13
|
* used in combination with `height`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CartesianChart.d.ts","sourceRoot":"","sources":["../../../../src/components/CartesianChart/CartesianChart.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"CartesianChart.d.ts","sourceRoot":"","sources":["../../../../src/components/CartesianChart/CartesianChart.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAuB,MAAM,UAAU,CAAC;AAC9D,OAAc,EACZ,KAAK,cAAc,EACnB,KAAK,EAAE,EAEP,KAAK,iBAAiB,EACtB,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AAOf,0CAA0C;AAC1C,MAAM,WAAW,4BAA4B;IAC3C,IAAI,CAAC,EAAE,cAAc,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,mBACf,SACE,IAAI,CACF,cAAc,CAAC,OAAO,aAAa,CAAC,EACpC,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,YAAY,CAC/C,EACD,iBAAiB;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,yDAAyD;IACzD,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAwB;AACxB,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CAuDlD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChartClipRect.d.ts","sourceRoot":"","sources":["../../../../../src/components/CartesianChart/hooks/useChartClipRect.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/flow-react-components",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.675",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A React implementation of Flow, mittwald’s design system",
|
|
6
6
|
"homepage": "https://mittwald.github.io/flow",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@internationalized/string-compiler": "^3.2.6",
|
|
60
60
|
"@mittwald/password-tools-js": "3.0.0-alpha.18",
|
|
61
|
-
"@mittwald/react-tunnel": "0.2.0-alpha.
|
|
61
|
+
"@mittwald/react-tunnel": "0.2.0-alpha.675",
|
|
62
62
|
"@mittwald/react-use-promise": "^4.2.2",
|
|
63
63
|
"@react-aria/form": "^3.1.3",
|
|
64
64
|
"@react-aria/live-announcer": "^3.4.4",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"@faker-js/faker": "^10.2.0",
|
|
105
105
|
"@internationalized/date": "^3.10.1",
|
|
106
106
|
"@mittwald/flow-core": "",
|
|
107
|
-
"@mittwald/flow-design-tokens": "0.2.0-alpha.
|
|
107
|
+
"@mittwald/flow-design-tokens": "0.2.0-alpha.675",
|
|
108
108
|
"@mittwald/react-use-promise": "^4.2.2",
|
|
109
109
|
"@mittwald/remote-dom-react": "1.2.2-mittwald.10",
|
|
110
110
|
"@mittwald/typescript-config": "",
|
|
@@ -172,5 +172,5 @@
|
|
|
172
172
|
"optional": true
|
|
173
173
|
}
|
|
174
174
|
},
|
|
175
|
-
"gitHead": "
|
|
175
|
+
"gitHead": "3d05327f32a6ca087b3755132f13e13c589bf74c"
|
|
176
176
|
}
|