@unovis/react 1.6.7 → 1.7.0-mcp.2
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/README.md +4 -0
- package/components/annotations/index.d.ts +12 -11
- package/components/annotations/index.js +30 -27
- package/components/annotations/index.js.map +1 -1
- package/components/area/index.d.ts +13 -12
- package/components/area/index.js +31 -29
- package/components/area/index.js.map +1 -1
- package/components/axis/index.d.ts +13 -12
- package/components/axis/index.js +31 -29
- package/components/axis/index.js.map +1 -1
- package/components/boxplot/index.d.ts +13 -0
- package/components/boxplot/index.js +33 -0
- package/components/boxplot/index.js.map +1 -0
- package/components/brush/index.d.ts +13 -12
- package/components/brush/index.js +31 -29
- package/components/brush/index.js.map +1 -1
- package/components/chord-diagram/index.d.ts +17 -16
- package/components/chord-diagram/index.js +31 -29
- package/components/chord-diagram/index.js.map +1 -1
- package/components/crosshair/index.d.ts +13 -12
- package/components/crosshair/index.js +31 -29
- package/components/crosshair/index.js.map +1 -1
- package/components/donut/index.d.ts +13 -12
- package/components/donut/index.js +31 -29
- package/components/donut/index.js.map +1 -1
- package/components/free-brush/index.d.ts +13 -12
- package/components/free-brush/index.js +31 -29
- package/components/free-brush/index.js.map +1 -1
- package/components/graph/index.d.ts +39 -38
- package/components/graph/index.js +31 -29
- package/components/graph/index.js.map +1 -1
- package/components/grouped-bar/index.d.ts +13 -12
- package/components/grouped-bar/index.js +31 -29
- package/components/grouped-bar/index.js.map +1 -1
- package/components/heatmap/index.d.ts +13 -0
- package/components/heatmap/index.js +33 -0
- package/components/heatmap/index.js.map +1 -0
- package/components/line/index.d.ts +13 -12
- package/components/line/index.js +31 -29
- package/components/line/index.js.map +1 -1
- package/components/nested-donut/index.d.ts +13 -12
- package/components/nested-donut/index.js +31 -29
- package/components/nested-donut/index.js.map +1 -1
- package/components/plotband/index.d.ts +12 -11
- package/components/plotband/index.js +30 -27
- package/components/plotband/index.js.map +1 -1
- package/components/plotline/index.d.ts +12 -11
- package/components/plotline/index.js +30 -27
- package/components/plotline/index.js.map +1 -1
- package/components/radial-bar/index.d.ts +13 -0
- package/components/radial-bar/index.js +33 -0
- package/components/radial-bar/index.js.map +1 -0
- package/components/sankey/index.d.ts +17 -16
- package/components/sankey/index.js +31 -29
- package/components/sankey/index.js.map +1 -1
- package/components/scatter/index.d.ts +13 -12
- package/components/scatter/index.js +31 -29
- package/components/scatter/index.js.map +1 -1
- package/components/stacked-bar/index.d.ts +13 -12
- package/components/stacked-bar/index.js +31 -29
- package/components/stacked-bar/index.js.map +1 -1
- package/components/timeline/index.d.ts +13 -12
- package/components/timeline/index.js +31 -29
- package/components/timeline/index.js.map +1 -1
- package/components/tooltip/index.d.ts +12 -11
- package/components/tooltip/index.js +30 -27
- package/components/tooltip/index.js.map +1 -1
- package/components/topojson-map/index.d.ts +17 -16
- package/components/topojson-map/index.js +31 -29
- package/components/topojson-map/index.js.map +1 -1
- package/components/treemap/index.d.ts +13 -12
- package/components/treemap/index.js +31 -29
- package/components/treemap/index.js.map +1 -1
- package/components/xy-labels/index.d.ts +13 -12
- package/components/xy-labels/index.js +31 -29
- package/components/xy-labels/index.js.map +1 -1
- package/components.d.ts +30 -27
- package/composites/time-series/index.d.ts +55 -54
- package/composites/time-series/index.js +65 -61
- package/composites/time-series/index.js.map +1 -1
- package/composites/time-series/style.module.css.js +14 -7
- package/composites/time-series/style.module.css.js.map +1 -1
- package/composites.d.ts +1 -1
- package/containers/single-container/index.d.ts +9 -8
- package/containers/single-container/index.js +50 -49
- package/containers/single-container/index.js.map +1 -1
- package/containers/xy-container/index.d.ts +10 -9
- package/containers/xy-container/index.js +54 -59
- package/containers/xy-container/index.js.map +1 -1
- package/containers.d.ts +2 -2
- package/html-components/bullet-legend/index.d.ts +13 -12
- package/html-components/bullet-legend/index.js +30 -27
- package/html-components/bullet-legend/index.js.map +1 -1
- package/html-components/flow-legend/index.d.ts +13 -12
- package/html-components/flow-legend/index.js +30 -27
- package/html-components/flow-legend/index.js.map +1 -1
- package/html-components/leaflet-flow-map/index.d.ts +18 -17
- package/html-components/leaflet-flow-map/index.js +31 -29
- package/html-components/leaflet-flow-map/index.js.map +1 -1
- package/html-components/leaflet-map/index.d.ts +15 -14
- package/html-components/leaflet-map/index.js +31 -29
- package/html-components/leaflet-map/index.js.map +1 -1
- package/html-components/rolling-pin-legend/index.d.ts +13 -12
- package/html-components/rolling-pin-legend/index.js +30 -27
- package/html-components/rolling-pin-legend/index.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.js +111 -30
- package/index.js.map +1 -1
- package/package.json +15 -16
- package/types/dom.d.ts +3 -3
- package/utils/react.d.ts +5 -4
- package/utils/react.js +22 -29
- package/utils/react.js.map +1 -1
- package/external/.pnpm/style-inject@0.3.0/external/style-inject/dist/style-inject.es.js +0 -29
- package/external/.pnpm/style-inject@0.3.0/external/style-inject/dist/style-inject.es.js.map +0 -1
|
@@ -1,63 +1,67 @@
|
|
|
1
|
-
import React, { useState, useMemo } from
|
|
2
|
-
import { TextAlign } from
|
|
3
|
-
import { Scale } from
|
|
4
|
-
import { VisXYContainer } from
|
|
5
|
-
import { VisArea } from
|
|
6
|
-
import { VisAxis } from
|
|
7
|
-
import { VisCrosshair } from
|
|
8
|
-
import { VisTooltip } from
|
|
9
|
-
import { VisBrush } from
|
|
10
|
-
import s from
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
1
|
+
import React, { useState, useMemo } from "react";
|
|
2
|
+
import { TextAlign } from "@unovis/ts/types/text";
|
|
3
|
+
import { Scale } from "@unovis/ts/types/scale";
|
|
4
|
+
import { VisXYContainer } from "../../containers/xy-container/index.js";
|
|
5
|
+
import { VisArea } from "../../components/area/index.js";
|
|
6
|
+
import { VisAxis } from "../../components/axis/index.js";
|
|
7
|
+
import { VisCrosshair } from "../../components/crosshair/index.js";
|
|
8
|
+
import { VisTooltip } from "../../components/tooltip/index.js";
|
|
9
|
+
import { VisBrush } from "../../components/brush/index.js";
|
|
10
|
+
import s from "./style.module.css.js";
|
|
11
|
+
function VisTimeSeries(props) {
|
|
12
|
+
const [selectedRange, setSelectedRange] = useState(void 0);
|
|
13
|
+
const [animationDuration, setAnimationDuration] = useState(0);
|
|
14
|
+
const xScale = useMemo(() => Scale.scaleTime(), []);
|
|
15
|
+
const xScaleNav = useMemo(() => Scale.scaleTime(), []);
|
|
16
|
+
const onBrushStart = useMemo(() => (selection, e, userDriven) => {
|
|
17
|
+
if (userDriven) setAnimationDuration(0);
|
|
18
|
+
props.onBrushStart?.(selection, e, userDriven);
|
|
19
|
+
}, []);
|
|
20
|
+
const onBrushMove = useMemo(() => (selection, e, userDriven) => {
|
|
21
|
+
if (userDriven && selectedRange?.[0] !== selection[0] && selectedRange?.[1] !== selection[1]) setSelectedRange(selection);
|
|
22
|
+
props.onBrushMove?.(selection, e, userDriven);
|
|
23
|
+
}, []);
|
|
24
|
+
const onBrushEnd = useMemo(() => (selection, e, userDriven) => {
|
|
25
|
+
if (userDriven && selectedRange?.[0] !== selection[0] && selectedRange?.[1] !== selection[1]) setSelectedRange(selection);
|
|
26
|
+
setAnimationDuration(void 0);
|
|
27
|
+
props.onBrushEnd?.(selection, e, userDriven);
|
|
28
|
+
}, []);
|
|
29
|
+
return /* @__PURE__ */ React.createElement("div", { className: `${s.timeSeriesContainer}${props.className ? `.${props.className}` : ""}`, style: { height: props.height } }, /* @__PURE__ */ React.createElement(
|
|
30
|
+
VisXYContainer,
|
|
31
|
+
{
|
|
32
|
+
className: s.timeSeriesModule,
|
|
33
|
+
data: props.data,
|
|
34
|
+
xScale,
|
|
35
|
+
xDomain: selectedRange,
|
|
36
|
+
duration: animationDuration,
|
|
37
|
+
scaleByDomain: true
|
|
38
|
+
},
|
|
39
|
+
/* @__PURE__ */ React.createElement(
|
|
40
|
+
VisArea,
|
|
41
|
+
{
|
|
42
|
+
x: props.x,
|
|
43
|
+
y: props.y,
|
|
44
|
+
color: props.color
|
|
45
|
+
}
|
|
46
|
+
),
|
|
47
|
+
/* @__PURE__ */ React.createElement(VisAxis, { type: "x", numTicks: 5, tickFormat: props.formatXTicks, tickTextAlign: TextAlign.Center }),
|
|
48
|
+
/* @__PURE__ */ React.createElement(VisAxis, { type: "y", tickFormat: props.formatYTicks, label: props.yLabel }),
|
|
49
|
+
/* @__PURE__ */ React.createElement(VisTooltip, null),
|
|
50
|
+
/* @__PURE__ */ React.createElement(VisCrosshair, { template: props.crosshairTemplate })
|
|
51
|
+
), /* @__PURE__ */ React.createElement(VisXYContainer, { className: s.navigationModule, duration: 0, xScale: xScaleNav, data: props.data }, /* @__PURE__ */ React.createElement(VisArea, { x: props.x, y: props.y }), /* @__PURE__ */ React.createElement(VisBrush, { draggable: true, onBrushStart, onBrushMove, onBrushEnd }), /* @__PURE__ */ React.createElement(VisAxis, { type: "x", numTicks: 5, tickFormat: props.formatXTicks ?? props.formatNavXTicks, tickTextAlign: TextAlign.Right, label: props.xLabel }), /* @__PURE__ */ React.createElement(VisAxis, { type: "y", tickFormat: props.formatYTicks, minMaxTicksOnly: true, label: props.yLabel ? " " : void 0 })));
|
|
52
|
+
}
|
|
53
|
+
VisTimeSeries.defaultProps = {
|
|
54
|
+
margin: { top: 10, bottom: 10, left: 10, right: 10 },
|
|
55
|
+
autoMargin: true,
|
|
56
|
+
padding: {},
|
|
57
|
+
x: (d) => d.timestamp,
|
|
58
|
+
y: (d) => d.value,
|
|
59
|
+
id: (d) => d.id,
|
|
60
|
+
color: (d) => null,
|
|
61
|
+
formatYTicks: (d) => d.toFixed(1),
|
|
62
|
+
crosshairTemplate: (d) => `<div>Date: ${new Date(d.timestamp).toLocaleDateString()}</div><div>Value: ${d.value?.toFixed(1)}</div>`
|
|
63
|
+
};
|
|
64
|
+
export {
|
|
65
|
+
VisTimeSeries
|
|
60
66
|
};
|
|
61
|
-
|
|
62
|
-
export { VisTimeSeries };
|
|
63
67
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/composites/time-series/index.tsx"],"sourcesContent":["import React, { useState, useMemo } from 'react'\nimport { Spacing } from '@unovis/ts/types/spacing'\nimport { TextAlign } from '@unovis/ts/types/text'\nimport { Scale } from '@unovis/ts/types/scale'\nimport { VisXYContainer } from '@unovis/react/containers/xy-container'\nimport { VisArea } from '@unovis/react/components/area'\nimport { VisAxis } from '@unovis/react/components/axis'\nimport { VisCrosshair } from '@unovis/react/components/crosshair'\nimport { VisTooltip } from '@unovis/react/components/tooltip'\nimport { VisBrush } from '@unovis/react/components/brush'\n\nimport s from './style.module.css'\n\nexport type VisTimeSeriesDatum = {\n timestamp: number;\n value: number;\n id?: string;\n color?: string;\n}\n\nexport type VisTimeSeriesProps<Datum> = {\n data: Datum[];\n margin: Spacing;\n autoMargin: boolean;\n\n x: (d: Datum, i: number) => number;\n y: (d: Datum, i: number) => number;\n id: (d: Datum, i: number) => string;\n color: (d: Datum[], i: number) => string | null;\n cursor: string | ((d: Datum, i: number) => string);\n formatXTicks?: (timestamp: number) => string;\n formatYTicks?: (timestamp: number) => string;\n\n selectionMinLength: number;\n onBrushStart?: (selection: [number, number], e?: { sourceEvent: MouseEvent }, userDriven?: boolean) => void;\n onBrushMove?: (selection: [number, number], e?: { sourceEvent: MouseEvent }, userDriven?: boolean) => void;\n onBrushEnd?: (selection: [number, number], e?: { sourceEvent: MouseEvent }, userDriven?: boolean) => void;\n formatNavXTicks?: (timestamp: number) => string;\n\n xLabel?: string;\n yLabel?: string;\n\n crosshairTemplate?: (d: Datum) => string | HTMLElement;\n\n className?: string;\n height?: string;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function VisTimeSeries<Datum> (props: VisTimeSeriesProps<Datum>): JSX.Element {\n const [selectedRange, setSelectedRange] = useState<[number, number] | undefined>(undefined)\n const [animationDuration, setAnimationDuration] = useState<number | undefined>(0)\n const xScale = useMemo(() => Scale.scaleTime(), [])\n const xScaleNav = useMemo(() => Scale.scaleTime(), [])\n\n // On Mount\n // useEffect(() => {}, [])\n\n // On Props Update\n // useEffect(() => {})\n\n // Brush callbacks\n const onBrushStart = useMemo(() => (selection: [number, number], e?: { sourceEvent: MouseEvent }, userDriven?: boolean): void => {\n if (userDriven) setAnimationDuration(0)\n props.onBrushStart?.(selection, e, userDriven)\n }, [])\n\n const onBrushMove = useMemo(() => (selection: [number, number], e?: { sourceEvent: MouseEvent }, userDriven?: boolean): void => {\n if (userDriven && selectedRange?.[0] !== selection[0] && selectedRange?.[1] !== selection[1]) setSelectedRange(selection)\n props.onBrushMove?.(selection, e, userDriven)\n }, [])\n\n const onBrushEnd = useMemo(() => (selection: [number, number], e?: { sourceEvent: MouseEvent }, userDriven?: boolean): void => {\n if (userDriven && selectedRange?.[0] !== selection[0] && selectedRange?.[1] !== selection[1]) setSelectedRange(selection)\n setAnimationDuration(undefined)\n props.onBrushEnd?.(selection, e, userDriven)\n }, [])\n\n return (\n <div className={`${s.timeSeriesContainer}${props.className ? `.${props.className}` : ''}`} style={{ height: props.height }}>\n <VisXYContainer\n className={s.timeSeriesModule}\n data={props.data}\n xScale={xScale}\n xDomain={selectedRange}\n duration={animationDuration}\n scaleByDomain={true}\n >\n <VisArea\n x={props.x}\n y={props.y}\n color={props.color}\n />\n <VisAxis type='x' numTicks={5} tickFormat={props.formatXTicks} tickTextAlign={TextAlign.Center}/>\n <VisAxis type='y' tickFormat={props.formatYTicks} label={props.yLabel}/>\n <VisTooltip />\n <VisCrosshair template={props.crosshairTemplate}/>\n </VisXYContainer>\n <VisXYContainer className={s.navigationModule} duration={0} xScale={xScaleNav} data={props.data}>\n <VisArea x={props.x} y={props.y} />\n <VisBrush draggable={true} onBrushStart={onBrushStart} onBrushMove={onBrushMove} onBrushEnd={onBrushEnd} />\n <VisAxis type='x' numTicks={5} tickFormat={props.formatXTicks ?? props.formatNavXTicks} tickTextAlign={TextAlign.Right} label={props.xLabel}/>\n <VisAxis type='y' tickFormat={props.formatYTicks} minMaxTicksOnly={true} label={props.yLabel ? ' ' : undefined}/>\n </VisXYContainer>\n </div>\n )\n}\n\nVisTimeSeries.defaultProps = {\n margin: { top: 10, bottom: 10, left: 10, right: 10 },\n autoMargin: true,\n padding: {},\n\n x: (d: VisTimeSeriesDatum) => d.timestamp,\n y: (d: VisTimeSeriesDatum) => d.value,\n id: (d: VisTimeSeriesDatum) => d.id,\n color: (d: VisTimeSeriesDatum[]) => null,\n\n formatYTicks: (d: number) => d.toFixed(1),\n\n crosshairTemplate: (d: VisTimeSeriesDatum) =>\n `<div>Date: ${new Date(d.timestamp).toLocaleDateString()}</div><div>Value: ${d.value?.toFixed(1)}</div>`,\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/composites/time-series/index.tsx"],"sourcesContent":["import React, { useState, useMemo } from 'react'\nimport { Spacing } from '@unovis/ts/types/spacing'\nimport { TextAlign } from '@unovis/ts/types/text'\nimport { Scale } from '@unovis/ts/types/scale'\nimport { VisXYContainer } from '@unovis/react/containers/xy-container'\nimport { VisArea } from '@unovis/react/components/area'\nimport { VisAxis } from '@unovis/react/components/axis'\nimport { VisCrosshair } from '@unovis/react/components/crosshair'\nimport { VisTooltip } from '@unovis/react/components/tooltip'\nimport { VisBrush } from '@unovis/react/components/brush'\n\nimport s from './style.module.css'\n\nexport type VisTimeSeriesDatum = {\n timestamp: number;\n value: number;\n id?: string;\n color?: string;\n}\n\nexport type VisTimeSeriesProps<Datum> = {\n data: Datum[];\n margin: Spacing;\n autoMargin: boolean;\n\n x: (d: Datum, i: number) => number;\n y: (d: Datum, i: number) => number;\n id: (d: Datum, i: number) => string;\n color: (d: Datum[], i: number) => string | null;\n cursor: string | ((d: Datum, i: number) => string);\n formatXTicks?: (timestamp: number) => string;\n formatYTicks?: (timestamp: number) => string;\n\n selectionMinLength: number;\n onBrushStart?: (selection: [number, number], e?: { sourceEvent: MouseEvent }, userDriven?: boolean) => void;\n onBrushMove?: (selection: [number, number], e?: { sourceEvent: MouseEvent }, userDriven?: boolean) => void;\n onBrushEnd?: (selection: [number, number], e?: { sourceEvent: MouseEvent }, userDriven?: boolean) => void;\n formatNavXTicks?: (timestamp: number) => string;\n\n xLabel?: string;\n yLabel?: string;\n\n crosshairTemplate?: (d: Datum) => string | HTMLElement;\n\n className?: string;\n height?: string;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function VisTimeSeries<Datum> (props: VisTimeSeriesProps<Datum>): JSX.Element {\n const [selectedRange, setSelectedRange] = useState<[number, number] | undefined>(undefined)\n const [animationDuration, setAnimationDuration] = useState<number | undefined>(0)\n const xScale = useMemo(() => Scale.scaleTime(), [])\n const xScaleNav = useMemo(() => Scale.scaleTime(), [])\n\n // On Mount\n // useEffect(() => {}, [])\n\n // On Props Update\n // useEffect(() => {})\n\n // Brush callbacks\n const onBrushStart = useMemo(() => (selection: [number, number], e?: { sourceEvent: MouseEvent }, userDriven?: boolean): void => {\n if (userDriven) setAnimationDuration(0)\n props.onBrushStart?.(selection, e, userDriven)\n }, [])\n\n const onBrushMove = useMemo(() => (selection: [number, number], e?: { sourceEvent: MouseEvent }, userDriven?: boolean): void => {\n if (userDriven && selectedRange?.[0] !== selection[0] && selectedRange?.[1] !== selection[1]) setSelectedRange(selection)\n props.onBrushMove?.(selection, e, userDriven)\n }, [])\n\n const onBrushEnd = useMemo(() => (selection: [number, number], e?: { sourceEvent: MouseEvent }, userDriven?: boolean): void => {\n if (userDriven && selectedRange?.[0] !== selection[0] && selectedRange?.[1] !== selection[1]) setSelectedRange(selection)\n setAnimationDuration(undefined)\n props.onBrushEnd?.(selection, e, userDriven)\n }, [])\n\n return (\n <div className={`${s.timeSeriesContainer}${props.className ? `.${props.className}` : ''}`} style={{ height: props.height }}>\n <VisXYContainer\n className={s.timeSeriesModule}\n data={props.data}\n xScale={xScale}\n xDomain={selectedRange}\n duration={animationDuration}\n scaleByDomain={true}\n >\n <VisArea\n x={props.x}\n y={props.y}\n color={props.color}\n />\n <VisAxis type='x' numTicks={5} tickFormat={props.formatXTicks} tickTextAlign={TextAlign.Center}/>\n <VisAxis type='y' tickFormat={props.formatYTicks} label={props.yLabel}/>\n <VisTooltip />\n <VisCrosshair template={props.crosshairTemplate}/>\n </VisXYContainer>\n <VisXYContainer className={s.navigationModule} duration={0} xScale={xScaleNav} data={props.data}>\n <VisArea x={props.x} y={props.y} />\n <VisBrush draggable={true} onBrushStart={onBrushStart} onBrushMove={onBrushMove} onBrushEnd={onBrushEnd} />\n <VisAxis type='x' numTicks={5} tickFormat={props.formatXTicks ?? props.formatNavXTicks} tickTextAlign={TextAlign.Right} label={props.xLabel}/>\n <VisAxis type='y' tickFormat={props.formatYTicks} minMaxTicksOnly={true} label={props.yLabel ? ' ' : undefined}/>\n </VisXYContainer>\n </div>\n )\n}\n\nVisTimeSeries.defaultProps = {\n margin: { top: 10, bottom: 10, left: 10, right: 10 },\n autoMargin: true,\n padding: {},\n\n x: (d: VisTimeSeriesDatum) => d.timestamp,\n y: (d: VisTimeSeriesDatum) => d.value,\n id: (d: VisTimeSeriesDatum) => d.id,\n color: (d: VisTimeSeriesDatum[]) => null,\n\n formatYTicks: (d: number) => d.toFixed(1),\n\n crosshairTemplate: (d: VisTimeSeriesDatum) =>\n `<div>Date: ${new Date(d.timestamp).toLocaleDateString()}</div><div>Value: ${d.value?.toFixed(1)}</div>`,\n}\n"],"names":[],"mappings":"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"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
const timeSeriesContainer = "_timeSeriesContainer_1ayv5_1";
|
|
2
|
+
const timeSeriesModule = "_timeSeriesModule_1ayv5_8";
|
|
3
|
+
const navigationModule = "_navigationModule_1ayv5_14";
|
|
4
|
+
const s = {
|
|
5
|
+
timeSeriesContainer,
|
|
6
|
+
timeSeriesModule,
|
|
7
|
+
navigationModule
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
s as default,
|
|
11
|
+
navigationModule,
|
|
12
|
+
timeSeriesContainer,
|
|
13
|
+
timeSeriesModule
|
|
14
|
+
};
|
|
8
15
|
//# sourceMappingURL=style.module.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":
|
|
1
|
+
{"version":3,"file":"style.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
package/composites.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './composites/time-series';
|
|
1
|
+
export * from './composites/time-series';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React,
|
|
2
|
-
import { SingleContainerConfigInterface } from '@unovis/ts/containers/single-container/config';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
1
|
+
import { default as React, PropsWithChildren } from 'react';
|
|
2
|
+
import { SingleContainerConfigInterface } from '@unovis/ts/containers/single-container/config';
|
|
3
|
+
|
|
4
|
+
export type VisSingleContainerProps<Data> = SingleContainerConfigInterface<Data> & {
|
|
5
|
+
data?: Data;
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: React.CSSProperties | Record<`--${string}`, string | number>;
|
|
8
|
+
};
|
|
9
|
+
export declare const VisSingleContainer: (<Data>(props: PropsWithChildren<VisSingleContainerProps<Data>>) => JSX.Element | null);
|
|
@@ -1,51 +1,52 @@
|
|
|
1
|
-
import React, { useRef, useEffect } from
|
|
2
|
-
import { SingleContainer } from
|
|
3
|
-
import { arePropsEqual } from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
1
|
+
import React, { useRef, useEffect } from "react";
|
|
2
|
+
import { SingleContainer } from "@unovis/ts/containers/single-container";
|
|
3
|
+
import { arePropsEqual } from "../../utils/react.js";
|
|
4
|
+
function VisSingleContainerFC(props) {
|
|
5
|
+
const container = useRef(null);
|
|
6
|
+
const prevPropsRef = useRef({});
|
|
7
|
+
const chartRef = useRef(void 0);
|
|
8
|
+
const dataRef = useRef(void 0);
|
|
9
|
+
const animationFrameRef = useRef(null);
|
|
10
|
+
const getConfig = () => ({
|
|
11
|
+
...props,
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
13
|
+
component: container.current?.querySelector("vis-component")?.__component__,
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
15
|
+
tooltip: container.current?.querySelector("vis-tooltip")?.__component__,
|
|
16
|
+
annotations: container.current?.querySelector("vis-annotations")?.__component__
|
|
17
|
+
});
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const c = new SingleContainer(container.current, getConfig(), props.data);
|
|
20
|
+
chartRef.current = c;
|
|
21
|
+
prevPropsRef.current = props;
|
|
22
|
+
dataRef.current = props.data;
|
|
23
|
+
return () => {
|
|
24
|
+
if (animationFrameRef.current) {
|
|
25
|
+
cancelAnimationFrame(animationFrameRef.current);
|
|
26
|
+
animationFrameRef.current = null;
|
|
27
|
+
prevPropsRef.current = {};
|
|
28
|
+
}
|
|
29
|
+
c.destroy();
|
|
30
|
+
};
|
|
31
|
+
}, []);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const preventRender = true;
|
|
34
|
+
if (props.data && props.data !== dataRef.current) {
|
|
35
|
+
chartRef.current?.setData(props.data, preventRender);
|
|
36
|
+
dataRef.current = props.data;
|
|
37
|
+
}
|
|
38
|
+
if (!arePropsEqual(prevPropsRef.current, props)) {
|
|
39
|
+
prevPropsRef.current = props;
|
|
40
|
+
if (animationFrameRef.current) cancelAnimationFrame(animationFrameRef.current);
|
|
41
|
+
animationFrameRef.current = requestAnimationFrame(() => {
|
|
42
|
+
chartRef.current?.updateContainer(getConfig());
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return /* @__PURE__ */ React.createElement("div", { ref: container, className: props.className, style: props.style }, props.children);
|
|
47
|
+
}
|
|
48
48
|
const VisSingleContainer = React.memo(VisSingleContainerFC, arePropsEqual);
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
export {
|
|
50
|
+
VisSingleContainer
|
|
51
|
+
};
|
|
51
52
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/containers/single-container/index.tsx"],"sourcesContent":["// eslint-disable-next-line no-use-before-define\nimport React, { ReactNode, useEffect, useRef, useState, PropsWithChildren } from 'react'\nimport { SingleContainer } from '@unovis/ts/containers/single-container'\nimport { SingleContainerConfigInterface } from '@unovis/ts/containers/single-container/config'\nimport { ComponentCore } from '@unovis/ts/core/component'\nimport { Tooltip } from '@unovis/ts/components/tooltip'\nimport { Annotations } from '@unovis/ts/components/annotations'\n\n// Utils\nimport { arePropsEqual } from 'src/utils/react'\n\n// Types\nimport { VisComponentElement } from 'src/types/dom'\n\nexport type VisSingleContainerProps<Data> = SingleContainerConfigInterface<Data> & {\n data?: Data;\n className?: string;\n style?: React.CSSProperties | Record<`--${string}`, string | number>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction VisSingleContainerFC<Data> (props: PropsWithChildren<VisSingleContainerProps<Data>>): JSX.Element {\n const container = useRef<HTMLDivElement>(null)\n const prevPropsRef = useRef<PropsWithChildren<VisSingleContainerProps<Data>>>({})\n const chartRef = useRef<SingleContainer<Data> | undefined>(undefined)\n const dataRef = useRef<Data | undefined>(undefined)\n const animationFrameRef = useRef<number | null>(null)\n\n const getConfig = (): SingleContainerConfigInterface<Data> => ({\n ...props,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n component: container.current?.querySelector<VisComponentElement<ComponentCore<Data>>>('vis-component')?.__component__,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n tooltip: container.current?.querySelector<VisComponentElement<Tooltip>>('vis-tooltip')?.__component__,\n annotations: container.current?.querySelector<VisComponentElement<Annotations>>('vis-annotations')?.__component__,\n })\n\n // On Mount\n useEffect(() => {\n const c = new SingleContainer<Data>(container.current as HTMLDivElement, getConfig(), props.data)\n chartRef.current = c\n prevPropsRef.current = props\n dataRef.current = props.data\n\n return () => {\n if (animationFrameRef.current) {\n cancelAnimationFrame(animationFrameRef.current)\n animationFrameRef.current = null\n prevPropsRef.current = {}\n }\n c.destroy()\n }\n }, [])\n\n // On Props Update\n useEffect(() => {\n const preventRender = true\n\n // Set new Data without re-render\n if (props.data && (props.data !== dataRef.current)) {\n chartRef.current?.setData(props.data, preventRender)\n dataRef.current = props.data\n }\n\n // Update and render\n // ! Experimental: we use `requestAnimationFrame` to make the wrapper compatible with React 18 Strict Mode.\n // React 18 in Strict Mode renders components twice. At the same time, this container will get updated only after\n // the first render of its children (VisSankey, VisGraph, ...) meaning that their wrong instances (the ones\n // that will be destroyed soon) are stored in the `__component__` property of their elements at that moment.\n // So we delay the container update with `requestAnimationFrame` to wait till the new instances of children\n // components are available at `__component__`.\n if (!arePropsEqual(prevPropsRef.current, props)) { // Checking whether the props have changed do avoid multiple renders\n prevPropsRef.current = props\n if (animationFrameRef.current) cancelAnimationFrame(animationFrameRef.current)\n animationFrameRef.current = requestAnimationFrame(() => {\n chartRef.current?.updateContainer(getConfig())\n })\n }\n })\n\n return (\n <div ref={container} className={props.className} style={props.style}>\n {props.children}\n </div>\n )\n}\n\n// We export a memoized component to avoid unnecessary re-renders\n// and define its type explicitly to help react-docgen-typescript to extract information about props\nexport const VisSingleContainer: (<Data>(props: PropsWithChildren<VisSingleContainerProps<Data>>) => JSX.Element | null) =\n React.memo(VisSingleContainerFC, arePropsEqual)\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/containers/single-container/index.tsx"],"sourcesContent":["// eslint-disable-next-line no-use-before-define\nimport React, { ReactNode, useEffect, useRef, useState, PropsWithChildren } from 'react'\nimport { SingleContainer } from '@unovis/ts/containers/single-container'\nimport { SingleContainerConfigInterface } from '@unovis/ts/containers/single-container/config'\nimport { ComponentCore } from '@unovis/ts/core/component'\nimport { Tooltip } from '@unovis/ts/components/tooltip'\nimport { Annotations } from '@unovis/ts/components/annotations'\n\n// Utils\nimport { arePropsEqual } from 'src/utils/react'\n\n// Types\nimport { VisComponentElement } from 'src/types/dom'\n\nexport type VisSingleContainerProps<Data> = SingleContainerConfigInterface<Data> & {\n data?: Data;\n className?: string;\n style?: React.CSSProperties | Record<`--${string}`, string | number>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction VisSingleContainerFC<Data> (props: PropsWithChildren<VisSingleContainerProps<Data>>): JSX.Element {\n const container = useRef<HTMLDivElement>(null)\n const prevPropsRef = useRef<PropsWithChildren<VisSingleContainerProps<Data>>>({})\n const chartRef = useRef<SingleContainer<Data> | undefined>(undefined)\n const dataRef = useRef<Data | undefined>(undefined)\n const animationFrameRef = useRef<number | null>(null)\n\n const getConfig = (): SingleContainerConfigInterface<Data> => ({\n ...props,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n component: container.current?.querySelector<VisComponentElement<ComponentCore<Data>>>('vis-component')?.__component__,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n tooltip: container.current?.querySelector<VisComponentElement<Tooltip>>('vis-tooltip')?.__component__,\n annotations: container.current?.querySelector<VisComponentElement<Annotations>>('vis-annotations')?.__component__,\n })\n\n // On Mount\n useEffect(() => {\n const c = new SingleContainer<Data>(container.current as HTMLDivElement, getConfig(), props.data)\n chartRef.current = c\n prevPropsRef.current = props\n dataRef.current = props.data\n\n return () => {\n if (animationFrameRef.current) {\n cancelAnimationFrame(animationFrameRef.current)\n animationFrameRef.current = null\n prevPropsRef.current = {}\n }\n c.destroy()\n }\n }, [])\n\n // On Props Update\n useEffect(() => {\n const preventRender = true\n\n // Set new Data without re-render\n if (props.data && (props.data !== dataRef.current)) {\n chartRef.current?.setData(props.data, preventRender)\n dataRef.current = props.data\n }\n\n // Update and render\n // ! Experimental: we use `requestAnimationFrame` to make the wrapper compatible with React 18 Strict Mode.\n // React 18 in Strict Mode renders components twice. At the same time, this container will get updated only after\n // the first render of its children (VisSankey, VisGraph, ...) meaning that their wrong instances (the ones\n // that will be destroyed soon) are stored in the `__component__` property of their elements at that moment.\n // So we delay the container update with `requestAnimationFrame` to wait till the new instances of children\n // components are available at `__component__`.\n if (!arePropsEqual(prevPropsRef.current, props)) { // Checking whether the props have changed do avoid multiple renders\n prevPropsRef.current = props\n if (animationFrameRef.current) cancelAnimationFrame(animationFrameRef.current)\n animationFrameRef.current = requestAnimationFrame(() => {\n chartRef.current?.updateContainer(getConfig())\n })\n }\n })\n\n return (\n <div ref={container} className={props.className} style={props.style}>\n {props.children}\n </div>\n )\n}\n\n// We export a memoized component to avoid unnecessary re-renders\n// and define its type explicitly to help react-docgen-typescript to extract information about props\nexport const VisSingleContainer: (<Data>(props: PropsWithChildren<VisSingleContainerProps<Data>>) => JSX.Element | null) =\n React.memo(VisSingleContainerFC, arePropsEqual)\n"],"names":[],"mappings":";;;AAqBA,SAAS,qBAA4B,OAAsE;AACzG,QAAM,YAAY,OAAuB,IAAI;AAC7C,QAAM,eAAe,OAAyD,EAAE;AAChF,QAAM,WAAW,OAA0C,MAAS;AACpE,QAAM,UAAU,OAAyB,MAAS;AAClD,QAAM,oBAAoB,OAAsB,IAAI;AAEpD,QAAM,YAAY,OAA6C;AAAA,IAC7D,GAAG;AAAA;AAAA,IAEH,WAAW,UAAU,SAAS,cAAwD,eAAe,GAAG;AAAA;AAAA,IAExG,SAAS,UAAU,SAAS,cAA4C,aAAa,GAAG;AAAA,IACxF,aAAa,UAAU,SAAS,cAAgD,iBAAiB,GAAG;AAAA,EAAA;AAItG,YAAU,MAAM;AACd,UAAM,IAAI,IAAI,gBAAsB,UAAU,SAA2B,UAAA,GAAa,MAAM,IAAI;AAChG,aAAS,UAAU;AACnB,iBAAa,UAAU;AACvB,YAAQ,UAAU,MAAM;AAExB,WAAO,MAAM;AACX,UAAI,kBAAkB,SAAS;AAC7B,6BAAqB,kBAAkB,OAAO;AAC9C,0BAAkB,UAAU;AAC5B,qBAAa,UAAU,CAAA;AAAA,MACzB;AACA,QAAE,QAAA;AAAA,IACJ;AAAA,EACF,GAAG,CAAA,CAAE;AAGL,YAAU,MAAM;AACd,UAAM,gBAAgB;AAGtB,QAAI,MAAM,QAAS,MAAM,SAAS,QAAQ,SAAU;AAClD,eAAS,SAAS,QAAQ,MAAM,MAAM,aAAa;AACnD,cAAQ,UAAU,MAAM;AAAA,IAC1B;AASA,QAAI,CAAC,cAAc,aAAa,SAAS,KAAK,GAAG;AAC/C,mBAAa,UAAU;AACvB,UAAI,kBAAkB,QAAS,sBAAqB,kBAAkB,OAAO;AAC7E,wBAAkB,UAAU,sBAAsB,MAAM;AACtD,iBAAS,SAAS,gBAAgB,WAAW;AAAA,MAC/C,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,SACE,sBAAA,cAAC,OAAA,EAAI,KAAK,WAAW,WAAW,MAAM,WAAW,OAAO,MAAM,MAAA,GAC3D,MAAM,QACT;AAEJ;AAIO,MAAM,qBACX,MAAM,KAAK,sBAAsB,aAAa;"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import React,
|
|
2
|
-
import { XYContainerConfigInterface } from '@unovis/ts/containers/xy-container/config';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export declare
|
|
1
|
+
import { default as React, PropsWithChildren } from 'react';
|
|
2
|
+
import { XYContainerConfigInterface } from '@unovis/ts/containers/xy-container/config';
|
|
3
|
+
|
|
4
|
+
export type VisXYContainerProps<Datum> = XYContainerConfigInterface<Datum> & {
|
|
5
|
+
data?: Datum[];
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: React.CSSProperties | Record<`--${string}`, string | number>;
|
|
8
|
+
};
|
|
9
|
+
export declare function VisXYContainerFC<Datum>(props: PropsWithChildren<VisXYContainerProps<Datum>>): JSX.Element;
|
|
10
|
+
export declare const VisXYContainer: (<Datum>(props: PropsWithChildren<VisXYContainerProps<Datum>>) => JSX.Element | null);
|
|
@@ -1,61 +1,56 @@
|
|
|
1
|
-
import React, { useRef, useEffect } from
|
|
2
|
-
import { XYContainer } from
|
|
3
|
-
import { AxisType } from
|
|
4
|
-
import { arePropsEqual } from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
var _a;
|
|
52
|
-
(_a = chartRef.current) === null || _a === void 0 ? void 0 : _a.updateContainer(getConfig());
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
return (React.createElement("div", { ref: container, className: props.className, style: props.style }, props.children));
|
|
57
|
-
}
|
|
1
|
+
import React, { useRef, useEffect } from "react";
|
|
2
|
+
import { XYContainer } from "@unovis/ts/containers/xy-container";
|
|
3
|
+
import { AxisType } from "@unovis/ts/components/axis/types";
|
|
4
|
+
import { arePropsEqual } from "../../utils/react.js";
|
|
5
|
+
function VisXYContainerFC(props) {
|
|
6
|
+
const container = useRef(null);
|
|
7
|
+
const prevPropsRef = useRef({});
|
|
8
|
+
const chartRef = useRef(void 0);
|
|
9
|
+
const dataRef = useRef(void 0);
|
|
10
|
+
const animationFrameRef = useRef(null);
|
|
11
|
+
const getConfig = () => ({
|
|
12
|
+
components: Array.from(container.current?.querySelectorAll("vis-component") ?? []).map((c) => c.__component__).filter(Boolean),
|
|
13
|
+
tooltip: container.current?.querySelector("vis-tooltip")?.__component__,
|
|
14
|
+
crosshair: container.current?.querySelector("vis-crosshair")?.__component__,
|
|
15
|
+
annotations: container.current?.querySelector("vis-annotations")?.__component__,
|
|
16
|
+
xAxis: Array.from(container.current?.querySelectorAll("vis-axis") ?? []).map((c) => c.__component__).find((c) => c.config.type === AxisType.X),
|
|
17
|
+
yAxis: Array.from(container.current?.querySelectorAll("vis-axis") ?? []).map((c) => c.__component__).find((c) => c.config.type === AxisType.Y),
|
|
18
|
+
margin: { top: 5, left: 5, right: 5, bottom: 5 },
|
|
19
|
+
...props
|
|
20
|
+
});
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const c = new XYContainer(container.current, getConfig(), props.data);
|
|
23
|
+
chartRef.current = c;
|
|
24
|
+
prevPropsRef.current = props;
|
|
25
|
+
dataRef.current = props.data;
|
|
26
|
+
return () => {
|
|
27
|
+
if (animationFrameRef.current) {
|
|
28
|
+
cancelAnimationFrame(animationFrameRef.current);
|
|
29
|
+
animationFrameRef.current = null;
|
|
30
|
+
prevPropsRef.current = {};
|
|
31
|
+
}
|
|
32
|
+
c.destroy();
|
|
33
|
+
};
|
|
34
|
+
}, []);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const preventRender = true;
|
|
37
|
+
if (props.data && props.data !== dataRef.current) {
|
|
38
|
+
chartRef.current?.setData(props.data, preventRender);
|
|
39
|
+
dataRef.current = props.data;
|
|
40
|
+
}
|
|
41
|
+
if (!arePropsEqual(prevPropsRef.current, props)) {
|
|
42
|
+
prevPropsRef.current = props;
|
|
43
|
+
if (animationFrameRef.current) cancelAnimationFrame(animationFrameRef.current);
|
|
44
|
+
animationFrameRef.current = requestAnimationFrame(() => {
|
|
45
|
+
chartRef.current?.updateContainer(getConfig());
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return /* @__PURE__ */ React.createElement("div", { ref: container, className: props.className, style: props.style }, props.children);
|
|
50
|
+
}
|
|
58
51
|
const VisXYContainer = React.memo(VisXYContainerFC, arePropsEqual);
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
export {
|
|
53
|
+
VisXYContainer,
|
|
54
|
+
VisXYContainerFC
|
|
55
|
+
};
|
|
61
56
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/containers/xy-container/index.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport React, { ReactNode, useEffect, useRef, useState, PropsWithChildren } from 'react'\nimport { XYContainer } from '@unovis/ts/containers/xy-container'\nimport { XYContainerConfigInterface } from '@unovis/ts/containers/xy-container/config'\nimport { XYComponentCore } from '@unovis/ts/core/xy-component'\nimport { Tooltip } from '@unovis/ts/components/tooltip'\nimport { Crosshair } from '@unovis/ts/components/crosshair'\nimport { Axis } from '@unovis/ts/components/axis'\nimport { AxisType } from '@unovis/ts/components/axis/types'\nimport { Annotations } from '@unovis/ts/components/annotations'\n\n// Utils\nimport { arePropsEqual } from 'src/utils/react'\n\n// Types\nimport { VisComponentElement } from 'src/types/dom'\n\nexport type VisXYContainerProps<Datum> = XYContainerConfigInterface<Datum> & {\n data?: Datum[];\n className?: string;\n style?: React.CSSProperties | Record<`--${string}`, string | number>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function VisXYContainerFC<Datum> (props: PropsWithChildren<VisXYContainerProps<Datum>>): JSX.Element {\n const container = useRef<HTMLDivElement>(null)\n const prevPropsRef = useRef<PropsWithChildren<VisXYContainerProps<Datum>>>({})\n const chartRef = useRef<XYContainer<Datum> | undefined>(undefined)\n const dataRef = useRef<Datum[] | undefined>(undefined)\n const animationFrameRef = useRef<number | null>(null)\n\n const getConfig = (): XYContainerConfigInterface<Datum> => ({\n components: Array\n .from(container.current?.querySelectorAll<VisComponentElement<XYComponentCore<Datum>>>('vis-component') ?? [])\n .map(c => c.__component__)\n .filter(Boolean) as XYComponentCore<Datum>[],\n tooltip: container.current?.querySelector<VisComponentElement<Tooltip>>('vis-tooltip')?.__component__,\n crosshair: container.current?.querySelector<VisComponentElement<Crosshair<Datum>>>('vis-crosshair')?.__component__,\n annotations: container.current?.querySelector<VisComponentElement<Annotations>>('vis-annotations')?.__component__,\n xAxis: Array\n .from(container.current?.querySelectorAll<VisComponentElement<Axis<Datum>>>('vis-axis') ?? [])\n .map(c => c.__component__)\n .find(c => c.config.type === AxisType.X),\n yAxis: Array\n .from(container.current?.querySelectorAll<VisComponentElement<Axis<Datum>>>('vis-axis') ?? [])\n .map(c => c.__component__)\n .find(c => c.config.type === AxisType.Y),\n margin: { top: 5, left: 5, right: 5, bottom: 5 },\n ...props,\n })\n\n // On Mount\n useEffect(() => {\n const c = new XYContainer<Datum>(container.current as HTMLDivElement, getConfig(), props.data)\n chartRef.current = c\n prevPropsRef.current = props\n dataRef.current = props.data\n\n return () => {\n if (animationFrameRef.current) {\n cancelAnimationFrame(animationFrameRef.current)\n animationFrameRef.current = null\n prevPropsRef.current = {}\n }\n c.destroy()\n }\n }, [])\n\n // On Props Update\n useEffect(() => {\n const preventRender = true\n\n // Set new Data without re-render\n if (props.data && (props.data !== dataRef.current)) {\n chartRef.current?.setData(props.data, preventRender)\n dataRef.current = props.data\n }\n\n // Update and render\n // ! Experimental: we use `requestAnimationFrame` to make the wrapper compatible with React 18 Strict Mode.\n // React 18 in Strict Mode renders components twice. At the same time, this container will get updated only after\n // the first render of its children (VisLine, VisArea, ...) meaning that their wrong instances (the ones\n // that will be destroyed soon) are stored in the `__component__` property of their elements at that moment.\n // So we delay the container update with `requestAnimationFrame` to wait till the new instances of children\n // components are available at `__component__`.\n if (!arePropsEqual(prevPropsRef.current, props)) { // Checking whether the props have changed do avoid multiple renders\n prevPropsRef.current = props\n if (animationFrameRef.current) cancelAnimationFrame(animationFrameRef.current)\n animationFrameRef.current = requestAnimationFrame(() => {\n chartRef.current?.updateContainer(getConfig())\n })\n }\n })\n\n return (\n <div ref={container} className={props.className} style={props.style}>\n {props.children}\n </div>\n )\n}\n\n// We export a memoized component to avoid unnecessary re-renders\n// and define its type explicitly to help react-docgen-typescript to extract information about props\nexport const VisXYContainer: (<Datum>(props: PropsWithChildren<VisXYContainerProps<Datum>>) => JSX.Element | null) =\n React.memo(VisXYContainerFC, arePropsEqual)\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/containers/xy-container/index.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport React, { ReactNode, useEffect, useRef, useState, PropsWithChildren } from 'react'\nimport { XYContainer } from '@unovis/ts/containers/xy-container'\nimport { XYContainerConfigInterface } from '@unovis/ts/containers/xy-container/config'\nimport { XYComponentCore } from '@unovis/ts/core/xy-component'\nimport { Tooltip } from '@unovis/ts/components/tooltip'\nimport { Crosshair } from '@unovis/ts/components/crosshair'\nimport { Axis } from '@unovis/ts/components/axis'\nimport { AxisType } from '@unovis/ts/components/axis/types'\nimport { Annotations } from '@unovis/ts/components/annotations'\n\n// Utils\nimport { arePropsEqual } from 'src/utils/react'\n\n// Types\nimport { VisComponentElement } from 'src/types/dom'\n\nexport type VisXYContainerProps<Datum> = XYContainerConfigInterface<Datum> & {\n data?: Datum[];\n className?: string;\n style?: React.CSSProperties | Record<`--${string}`, string | number>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function VisXYContainerFC<Datum> (props: PropsWithChildren<VisXYContainerProps<Datum>>): JSX.Element {\n const container = useRef<HTMLDivElement>(null)\n const prevPropsRef = useRef<PropsWithChildren<VisXYContainerProps<Datum>>>({})\n const chartRef = useRef<XYContainer<Datum> | undefined>(undefined)\n const dataRef = useRef<Datum[] | undefined>(undefined)\n const animationFrameRef = useRef<number | null>(null)\n\n const getConfig = (): XYContainerConfigInterface<Datum> => ({\n components: Array\n .from(container.current?.querySelectorAll<VisComponentElement<XYComponentCore<Datum>>>('vis-component') ?? [])\n .map(c => c.__component__)\n .filter(Boolean) as XYComponentCore<Datum>[],\n tooltip: container.current?.querySelector<VisComponentElement<Tooltip>>('vis-tooltip')?.__component__,\n crosshair: container.current?.querySelector<VisComponentElement<Crosshair<Datum>>>('vis-crosshair')?.__component__,\n annotations: container.current?.querySelector<VisComponentElement<Annotations>>('vis-annotations')?.__component__,\n xAxis: Array\n .from(container.current?.querySelectorAll<VisComponentElement<Axis<Datum>>>('vis-axis') ?? [])\n .map(c => c.__component__)\n .find(c => c.config.type === AxisType.X),\n yAxis: Array\n .from(container.current?.querySelectorAll<VisComponentElement<Axis<Datum>>>('vis-axis') ?? [])\n .map(c => c.__component__)\n .find(c => c.config.type === AxisType.Y),\n margin: { top: 5, left: 5, right: 5, bottom: 5 },\n ...props,\n })\n\n // On Mount\n useEffect(() => {\n const c = new XYContainer<Datum>(container.current as HTMLDivElement, getConfig(), props.data)\n chartRef.current = c\n prevPropsRef.current = props\n dataRef.current = props.data\n\n return () => {\n if (animationFrameRef.current) {\n cancelAnimationFrame(animationFrameRef.current)\n animationFrameRef.current = null\n prevPropsRef.current = {}\n }\n c.destroy()\n }\n }, [])\n\n // On Props Update\n useEffect(() => {\n const preventRender = true\n\n // Set new Data without re-render\n if (props.data && (props.data !== dataRef.current)) {\n chartRef.current?.setData(props.data, preventRender)\n dataRef.current = props.data\n }\n\n // Update and render\n // ! Experimental: we use `requestAnimationFrame` to make the wrapper compatible with React 18 Strict Mode.\n // React 18 in Strict Mode renders components twice. At the same time, this container will get updated only after\n // the first render of its children (VisLine, VisArea, ...) meaning that their wrong instances (the ones\n // that will be destroyed soon) are stored in the `__component__` property of their elements at that moment.\n // So we delay the container update with `requestAnimationFrame` to wait till the new instances of children\n // components are available at `__component__`.\n if (!arePropsEqual(prevPropsRef.current, props)) { // Checking whether the props have changed do avoid multiple renders\n prevPropsRef.current = props\n if (animationFrameRef.current) cancelAnimationFrame(animationFrameRef.current)\n animationFrameRef.current = requestAnimationFrame(() => {\n chartRef.current?.updateContainer(getConfig())\n })\n }\n })\n\n return (\n <div ref={container} className={props.className} style={props.style}>\n {props.children}\n </div>\n )\n}\n\n// We export a memoized component to avoid unnecessary re-renders\n// and define its type explicitly to help react-docgen-typescript to extract information about props\nexport const VisXYContainer: (<Datum>(props: PropsWithChildren<VisXYContainerProps<Datum>>) => JSX.Element | null) =\n React.memo(VisXYContainerFC, arePropsEqual)\n"],"names":[],"mappings":";;;;AAwBO,SAAS,iBAAyB,OAAmE;AAC1G,QAAM,YAAY,OAAuB,IAAI;AAC7C,QAAM,eAAe,OAAsD,EAAE;AAC7E,QAAM,WAAW,OAAuC,MAAS;AACjE,QAAM,UAAU,OAA4B,MAAS;AACrD,QAAM,oBAAoB,OAAsB,IAAI;AAEpD,QAAM,YAAY,OAA0C;AAAA,IAC1D,YAAY,MACT,KAAK,UAAU,SAAS,iBAA8D,eAAe,KAAK,CAAA,CAAE,EAC5G,IAAI,CAAA,MAAK,EAAE,aAAa,EACxB,OAAO,OAAO;AAAA,IACjB,SAAS,UAAU,SAAS,cAA4C,aAAa,GAAG;AAAA,IACxF,WAAW,UAAU,SAAS,cAAqD,eAAe,GAAG;AAAA,IACrG,aAAa,UAAU,SAAS,cAAgD,iBAAiB,GAAG;AAAA,IACpG,OAAO,MACJ,KAAK,UAAU,SAAS,iBAAmD,UAAU,KAAK,EAAE,EAC5F,IAAI,CAAA,MAAK,EAAE,aAAa,EACxB,KAAK,OAAK,EAAE,OAAO,SAAS,SAAS,CAAC;AAAA,IACzC,OAAO,MACJ,KAAK,UAAU,SAAS,iBAAmD,UAAU,KAAK,EAAE,EAC5F,IAAI,CAAA,MAAK,EAAE,aAAa,EACxB,KAAK,OAAK,EAAE,OAAO,SAAS,SAAS,CAAC;AAAA,IACzC,QAAQ,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,EAAA;AAAA,IAC7C,GAAG;AAAA,EAAA;AAIL,YAAU,MAAM;AACd,UAAM,IAAI,IAAI,YAAmB,UAAU,SAA2B,UAAA,GAAa,MAAM,IAAI;AAC7F,aAAS,UAAU;AACnB,iBAAa,UAAU;AACvB,YAAQ,UAAU,MAAM;AAExB,WAAO,MAAM;AACX,UAAI,kBAAkB,SAAS;AAC7B,6BAAqB,kBAAkB,OAAO;AAC9C,0BAAkB,UAAU;AAC5B,qBAAa,UAAU,CAAA;AAAA,MACzB;AACA,QAAE,QAAA;AAAA,IACJ;AAAA,EACF,GAAG,CAAA,CAAE;AAGL,YAAU,MAAM;AACd,UAAM,gBAAgB;AAGtB,QAAI,MAAM,QAAS,MAAM,SAAS,QAAQ,SAAU;AAClD,eAAS,SAAS,QAAQ,MAAM,MAAM,aAAa;AACnD,cAAQ,UAAU,MAAM;AAAA,IAC1B;AASA,QAAI,CAAC,cAAc,aAAa,SAAS,KAAK,GAAG;AAC/C,mBAAa,UAAU;AACvB,UAAI,kBAAkB,QAAS,sBAAqB,kBAAkB,OAAO;AAC7E,wBAAkB,UAAU,sBAAsB,MAAM;AACtD,iBAAS,SAAS,gBAAgB,WAAW;AAAA,MAC/C,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,SACE,sBAAA,cAAC,OAAA,EAAI,KAAK,WAAW,WAAW,MAAM,WAAW,OAAO,MAAM,MAAA,GAC3D,MAAM,QACT;AAEJ;AAIO,MAAM,iBACX,MAAM,KAAK,kBAAkB,aAAa;"}
|
package/containers.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './containers/xy-container';
|
|
2
|
-
export * from './containers/single-container';
|
|
1
|
+
export * from './containers/xy-container';
|
|
2
|
+
export * from './containers/single-container';
|