@elliemae/ds-dataviz 3.80.0-next.72 → 3.80.0-next.76
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/dist/cjs/graphs/Chart/Chart.js +1 -0
- package/dist/cjs/graphs/Chart/Chart.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scroller/Controllers.js +1 -1
- package/dist/cjs/graphs/Chart/parts/Scroller/Controllers.js.map +2 -2
- package/dist/esm/graphs/Chart/Chart.js +1 -0
- package/dist/esm/graphs/Chart/Chart.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scroller/Controllers.js +1 -1
- package/dist/esm/graphs/Chart/parts/Scroller/Controllers.js.map +2 -2
- package/package.json +8 -8
|
@@ -43,6 +43,7 @@ const Chart = (props) => {
|
|
|
43
43
|
const ctx = (0, import_useChart.useChart)(props);
|
|
44
44
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ChartContext.ChartContext.Provider, { value: ctx, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ChartContainer.ChartContainer, {}) });
|
|
45
45
|
};
|
|
46
|
+
Chart.displayName = "Chart";
|
|
46
47
|
const ChartWithSchema = (0, import_ds_props_helpers.describe)(Chart);
|
|
47
48
|
ChartWithSchema.propTypes = import_react_desc_prop_types.DSChartPropTypesSchema;
|
|
48
49
|
//# sourceMappingURL=Chart.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/graphs/Chart/Chart.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { ChartContainer } from './parts/ChartContainer.js';\nimport { ChartContext } from './ChartContext.js';\nimport { useChart } from './config/useChart.js';\nimport { DSChartPropTypesSchema, type DSChartT } from '../../react-desc-prop-types.js';\nconst Chart: React.ComponentType<DSChartT.Props> = (props) => {\n const ctx = useChart(props);\n return (\n <ChartContext.Provider value={ctx}>\n <ChartContainer />\n </ChartContext.Provider>\n );\n};\n\nconst ChartWithSchema = describe(Chart);\nChartWithSchema.propTypes = DSChartPropTypesSchema;\n\nexport { Chart, ChartWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADUjB;AATN,8BAAyB;AACzB,4BAA+B;AAC/B,0BAA6B;AAC7B,sBAAyB;AACzB,mCAAsD;AACtD,MAAM,QAA6C,CAAC,UAAU;AAC5D,QAAM,UAAM,0BAAS,KAAK;AAC1B,SACE,4CAAC,iCAAa,UAAb,EAAsB,OAAO,KAC5B,sDAAC,wCAAe,GAClB;AAEJ;
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { ChartContainer } from './parts/ChartContainer.js';\nimport { ChartContext } from './ChartContext.js';\nimport { useChart } from './config/useChart.js';\nimport { DSChartPropTypesSchema, type DSChartT } from '../../react-desc-prop-types.js';\nconst Chart: React.ComponentType<DSChartT.Props> = (props) => {\n const ctx = useChart(props);\n return (\n <ChartContext.Provider value={ctx}>\n <ChartContainer />\n </ChartContext.Provider>\n );\n};\n\n// PUI-19397: the props table heading is the component's displayName, or its function name when it has none, and a\n// minified build renames the function. 'Chart' is not DSDatavizName: that name is the slot namespace, not the heading.\nChart.displayName = 'Chart';\nconst ChartWithSchema = describe(Chart);\nChartWithSchema.propTypes = DSChartPropTypesSchema;\n\nexport { Chart, ChartWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADUjB;AATN,8BAAyB;AACzB,4BAA+B;AAC/B,0BAA6B;AAC7B,sBAAyB;AACzB,mCAAsD;AACtD,MAAM,QAA6C,CAAC,UAAU;AAC5D,QAAM,UAAM,0BAAS,KAAK;AAC1B,SACE,4CAAC,iCAAa,UAAb,EAAsB,OAAO,KAC5B,sDAAC,wCAAe,GAClB;AAEJ;AAIA,MAAM,cAAc;AACpB,MAAM,sBAAkB,kCAAS,KAAK;AACtC,gBAAgB,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -86,7 +86,7 @@ const ToolbarButton = ({
|
|
|
86
86
|
isDisabled,
|
|
87
87
|
role: "button",
|
|
88
88
|
"aria-label": label,
|
|
89
|
-
"aria-disabled": isDisabled,
|
|
89
|
+
"aria-disabled": isDisabled ? true : void 0,
|
|
90
90
|
tabIndex: isDisabled ? -1 : 0,
|
|
91
91
|
getOwnerProps,
|
|
92
92
|
getOwnerPropsArguments: () => ({ isDisabled }),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/graphs/Chart/parts/Scroller/Controllers.tsx", "../../../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useContext, useCallback, useMemo } from 'react';\nimport { ThemeContext } from '@elliemae/ds-system';\nimport { ChartContext } from '../../ChartContext.js';\nimport { TOOLBAR } from '../../../constants.js';\nimport { StyledResetter, StyledZoomInButton, StyledZoomOutButton } from '../../styles.js';\n\n// each zoom step doubles or halves the zoom, around the center of the view\nconst ZOOM_STEP = 2;\n// zooming in stops when about this many points of the longest series are in view\nconst MIN_POINTS_IN_VIEW = 8;\n// the room between two buttons of the toolbar\nconst BUTTON_GAP = 4;\n\nconst BUTTON_SIZE = TOOLBAR.RESET.WIDTH - 4;\nconst ICON_PROPS = {\n fill: 'none',\n strokeLinecap: 'round',\n strokeLinejoin: 'round',\n strokeWidth: '1.25',\n} as const;\n\ntype ToolbarButtonComponent = typeof StyledResetter | typeof StyledZoomInButton | typeof StyledZoomOutButton;\n\ninterface ToolbarButtonProps {\n Component: ToolbarButtonComponent;\n label: string;\n isDisabled: boolean;\n // the first button the keyboard reaches: Shift + Tab goes back to the chart from it\n isFirstFocusable: boolean;\n x: number;\n // with the keyboard or with the pointer\n onActivate: (withKeyboard: boolean) => void;\n children: React.ReactNode;\n}\n\n// A button of the zoom toolbar. A disabled one leaves the tab order, says it is disabled, and does nothing.\nconst ToolbarButton = ({\n Component,\n label,\n isDisabled,\n isFirstFocusable,\n x,\n onActivate,\n children,\n}: ToolbarButtonProps) => {\n const { containerRef, getOwnerProps } = useContext(ChartContext);\n const theme = useContext(ThemeContext);\n\n const handleOnClick = useCallback(() => {\n if (!isDisabled) onActivate(false);\n }, [isDisabled, onActivate]);\n\n const handleOnKeyDown: React.KeyboardEventHandler = useCallback(\n (e) => {\n e.stopPropagation();\n if (['Space', 'Enter'].includes(e.code)) {\n e.preventDefault();\n if (!isDisabled) onActivate(true);\n }\n if (isFirstFocusable && e.code === 'Tab' && e.shiftKey) {\n e.preventDefault();\n containerRef?.focus();\n }\n },\n [containerRef, isDisabled, isFirstFocusable, onActivate],\n );\n\n return (\n <Component\n onClick={handleOnClick}\n onKeyDown={handleOnKeyDown}\n transform={`translate(${x},0)`}\n strokeLinecap=\"round\"\n isDisabled={isDisabled}\n role=\"button\"\n aria-label={label}\n aria-disabled={isDisabled}\n tabIndex={isDisabled ? -1 : 0}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={() => ({ isDisabled })}\n >\n {/* a rounded 17px button, the same box for the three of them */}\n <rect\n width={BUTTON_SIZE}\n height={BUTTON_SIZE}\n rx={3}\n fill={theme?.colors?.neutral?.['000'] ?? '#FFFFFF'}\n stroke={theme?.colors?.neutral?.['300'] ?? '#B0B9C8'}\n strokeWidth=\"1\"\n />\n <g stroke={theme?.colors?.neutral?.['700'] ?? '#353C46'}>{children}</g>\n </Component>\n );\n};\n\n// The zoom toolbar of a horizontally scrollable chart with a linear or time axis: zoom in and zoom out, a step at a\n// time around the center of the view, and reset, back to the whole range. Dragging across the plot and Shift with the\n// arrows zoom as well (see ScrollableContainerX and useKeyboardNavigation).\nexport const Controllers = () => {\n const {\n props: { xScroll },\n width,\n innerWidth,\n internalMargin,\n xScale,\n yScale,\n containerRef,\n containerRatio,\n setContainerRatio,\n lastScrollbarPosition,\n setToolbarRef,\n setXScrollbarPosition,\n interactionStore,\n currentData,\n } = useContext(ChartContext);\n\n const maxRatio = useMemo(\n () => Math.max(ZOOM_STEP, Math.max(0, ...currentData.map((serie) => serie.data.length)) / MIN_POINTS_IN_VIEW),\n [currentData],\n );\n\n // the zoom at `ratio`, with the center of the view where it was, as a share of the plot\n const zoomTo = useCallback(\n (ratio: number) => {\n const nextRatio = Math.min(maxRatio, Math.max(1, ratio));\n const { xScrollbarPosition } = interactionStore.getState();\n const center = (xScrollbarPosition * containerRatio + innerWidth / 2) / (innerWidth * containerRatio);\n const lastPosition = innerWidth - innerWidth / nextRatio;\n const position = Math.min(lastPosition, Math.max(0, center * innerWidth - innerWidth / (2 * nextRatio)));\n setContainerRatio(nextRatio);\n setXScrollbarPosition(position);\n lastScrollbarPosition.current = position;\n },\n [\n containerRatio,\n innerWidth,\n interactionStore,\n lastScrollbarPosition,\n maxRatio,\n setContainerRatio,\n setXScrollbarPosition,\n ],\n );\n\n const zoomIn = useCallback(() => zoomTo(containerRatio * ZOOM_STEP), [containerRatio, zoomTo]);\n const zoomOut = useCallback(() => zoomTo(containerRatio / ZOOM_STEP), [containerRatio, zoomTo]);\n // reset disables itself and zoom out: with the keyboard, the focus goes back to the chart (with the pointer it stays\n // put, as focusing the chart activates its first point and opens its tooltip)\n const reset = useCallback(\n (withKeyboard: boolean) => {\n zoomTo(1);\n if (withKeyboard) containerRef?.focus();\n },\n [containerRef, zoomTo],\n );\n\n const isZoomedOut = containerRatio <= 1;\n const isZoomedIn = containerRatio >= maxRatio;\n\n // a band axis does not zoom\n if (xScale?.type === 'BAND' || yScale?.type === 'BAND') return null;\n if (!xScroll) return null;\n\n const step = TOOLBAR.RESET.WIDTH + BUTTON_GAP;\n // right-aligned, where the reset button used to be alone, and centered in the top margin\n const toolbarX = width - TOOLBAR.RESET.WIDTH * 2 - step * 2;\n const toolbarY = internalMargin.top / 2 - TOOLBAR.RESET.HEIGHT / 2;\n return (\n <g ref={setToolbarRef} transform={`translate(${toolbarX},${toolbarY})`}>\n <ToolbarButton\n Component={StyledZoomInButton}\n label=\"Zoom in chart\"\n isDisabled={isZoomedIn}\n isFirstFocusable={!isZoomedIn}\n x={0}\n onActivate={zoomIn}\n >\n <path d=\"M 5 8.5 H 12 M 8.5 5 V 12\" {...ICON_PROPS} />\n </ToolbarButton>\n <ToolbarButton\n Component={StyledZoomOutButton}\n label=\"Zoom out chart\"\n isDisabled={isZoomedOut}\n isFirstFocusable={isZoomedIn && !isZoomedOut}\n x={step}\n onActivate={zoomOut}\n >\n <path d=\"M 5 8.5 H 12\" {...ICON_PROPS} />\n </ToolbarButton>\n <ToolbarButton\n Component={StyledResetter}\n label=\"Reset zoom in chart\"\n isDisabled={isZoomedOut}\n isFirstFocusable={false}\n x={step * 2}\n onActivate={reset}\n >\n <path\n d=\"M 2.875 7.75 A 5.625 5.625 0 1 1 4.5225 11.7275 L 8.2725 10.7275 L 6.5225 14.9775 L 4.5225 11.7275\"\n {...ICON_PROPS}\n />\n </ToolbarButton>\n </g>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADoEnB;AApEJ,mBAAwD;AACxD,uBAA6B;AAC7B,0BAA6B;AAC7B,uBAAwB;AACxB,oBAAwE;AAGxE,MAAM,YAAY;AAElB,MAAM,qBAAqB;AAE3B,MAAM,aAAa;AAEnB,MAAM,cAAc,yBAAQ,MAAM,QAAQ;AAC1C,MAAM,aAAa;AAAA,EACjB,MAAM;AAAA,EACN,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,aAAa;AACf;AAiBA,MAAM,gBAAgB,CAAC;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA0B;AACxB,QAAM,EAAE,cAAc,cAAc,QAAI,yBAAW,gCAAY;AAC/D,QAAM,YAAQ,yBAAW,6BAAY;AAErC,QAAM,oBAAgB,0BAAY,MAAM;AACtC,QAAI,CAAC,WAAY,YAAW,KAAK;AAAA,EACnC,GAAG,CAAC,YAAY,UAAU,CAAC;AAE3B,QAAM,sBAA8C;AAAA,IAClD,CAAC,MAAM;AACL,QAAE,gBAAgB;AAClB,UAAI,CAAC,SAAS,OAAO,EAAE,SAAS,EAAE,IAAI,GAAG;AACvC,UAAE,eAAe;AACjB,YAAI,CAAC,WAAY,YAAW,IAAI;AAAA,MAClC;AACA,UAAI,oBAAoB,EAAE,SAAS,SAAS,EAAE,UAAU;AACtD,UAAE,eAAe;AACjB,sBAAc,MAAM;AAAA,MACtB;AAAA,IACF;AAAA,IACA,CAAC,cAAc,YAAY,kBAAkB,UAAU;AAAA,EACzD;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAS;AAAA,MACT,WAAW;AAAA,MACX,WAAW,aAAa,CAAC;AAAA,MACzB,eAAc;AAAA,MACd;AAAA,MACA,MAAK;AAAA,MACL,cAAY;AAAA,MACZ,iBAAe;AAAA,
|
|
4
|
+
"sourcesContent": ["import React, { useContext, useCallback, useMemo } from 'react';\nimport { ThemeContext } from '@elliemae/ds-system';\nimport { ChartContext } from '../../ChartContext.js';\nimport { TOOLBAR } from '../../../constants.js';\nimport { StyledResetter, StyledZoomInButton, StyledZoomOutButton } from '../../styles.js';\n\n// each zoom step doubles or halves the zoom, around the center of the view\nconst ZOOM_STEP = 2;\n// zooming in stops when about this many points of the longest series are in view\nconst MIN_POINTS_IN_VIEW = 8;\n// the room between two buttons of the toolbar\nconst BUTTON_GAP = 4;\n\nconst BUTTON_SIZE = TOOLBAR.RESET.WIDTH - 4;\nconst ICON_PROPS = {\n fill: 'none',\n strokeLinecap: 'round',\n strokeLinejoin: 'round',\n strokeWidth: '1.25',\n} as const;\n\ntype ToolbarButtonComponent = typeof StyledResetter | typeof StyledZoomInButton | typeof StyledZoomOutButton;\n\ninterface ToolbarButtonProps {\n Component: ToolbarButtonComponent;\n label: string;\n isDisabled: boolean;\n // the first button the keyboard reaches: Shift + Tab goes back to the chart from it\n isFirstFocusable: boolean;\n x: number;\n // with the keyboard or with the pointer\n onActivate: (withKeyboard: boolean) => void;\n children: React.ReactNode;\n}\n\n// A button of the zoom toolbar. A disabled one leaves the tab order, says it is disabled, and does nothing.\nconst ToolbarButton = ({\n Component,\n label,\n isDisabled,\n isFirstFocusable,\n x,\n onActivate,\n children,\n}: ToolbarButtonProps) => {\n const { containerRef, getOwnerProps } = useContext(ChartContext);\n const theme = useContext(ThemeContext);\n\n const handleOnClick = useCallback(() => {\n if (!isDisabled) onActivate(false);\n }, [isDisabled, onActivate]);\n\n const handleOnKeyDown: React.KeyboardEventHandler = useCallback(\n (e) => {\n e.stopPropagation();\n if (['Space', 'Enter'].includes(e.code)) {\n e.preventDefault();\n if (!isDisabled) onActivate(true);\n }\n if (isFirstFocusable && e.code === 'Tab' && e.shiftKey) {\n e.preventDefault();\n containerRef?.focus();\n }\n },\n [containerRef, isDisabled, isFirstFocusable, onActivate],\n );\n\n return (\n <Component\n onClick={handleOnClick}\n onKeyDown={handleOnKeyDown}\n transform={`translate(${x},0)`}\n strokeLinecap=\"round\"\n isDisabled={isDisabled}\n role=\"button\"\n aria-label={label}\n aria-disabled={isDisabled ? true : undefined}\n tabIndex={isDisabled ? -1 : 0}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={() => ({ isDisabled })}\n >\n {/* a rounded 17px button, the same box for the three of them */}\n <rect\n width={BUTTON_SIZE}\n height={BUTTON_SIZE}\n rx={3}\n fill={theme?.colors?.neutral?.['000'] ?? '#FFFFFF'}\n stroke={theme?.colors?.neutral?.['300'] ?? '#B0B9C8'}\n strokeWidth=\"1\"\n />\n <g stroke={theme?.colors?.neutral?.['700'] ?? '#353C46'}>{children}</g>\n </Component>\n );\n};\n\n// The zoom toolbar of a horizontally scrollable chart with a linear or time axis: zoom in and zoom out, a step at a\n// time around the center of the view, and reset, back to the whole range. Dragging across the plot and Shift with the\n// arrows zoom as well (see ScrollableContainerX and useKeyboardNavigation).\nexport const Controllers = () => {\n const {\n props: { xScroll },\n width,\n innerWidth,\n internalMargin,\n xScale,\n yScale,\n containerRef,\n containerRatio,\n setContainerRatio,\n lastScrollbarPosition,\n setToolbarRef,\n setXScrollbarPosition,\n interactionStore,\n currentData,\n } = useContext(ChartContext);\n\n const maxRatio = useMemo(\n () => Math.max(ZOOM_STEP, Math.max(0, ...currentData.map((serie) => serie.data.length)) / MIN_POINTS_IN_VIEW),\n [currentData],\n );\n\n // the zoom at `ratio`, with the center of the view where it was, as a share of the plot\n const zoomTo = useCallback(\n (ratio: number) => {\n const nextRatio = Math.min(maxRatio, Math.max(1, ratio));\n const { xScrollbarPosition } = interactionStore.getState();\n const center = (xScrollbarPosition * containerRatio + innerWidth / 2) / (innerWidth * containerRatio);\n const lastPosition = innerWidth - innerWidth / nextRatio;\n const position = Math.min(lastPosition, Math.max(0, center * innerWidth - innerWidth / (2 * nextRatio)));\n setContainerRatio(nextRatio);\n setXScrollbarPosition(position);\n lastScrollbarPosition.current = position;\n },\n [\n containerRatio,\n innerWidth,\n interactionStore,\n lastScrollbarPosition,\n maxRatio,\n setContainerRatio,\n setXScrollbarPosition,\n ],\n );\n\n const zoomIn = useCallback(() => zoomTo(containerRatio * ZOOM_STEP), [containerRatio, zoomTo]);\n const zoomOut = useCallback(() => zoomTo(containerRatio / ZOOM_STEP), [containerRatio, zoomTo]);\n // reset disables itself and zoom out: with the keyboard, the focus goes back to the chart (with the pointer it stays\n // put, as focusing the chart activates its first point and opens its tooltip)\n const reset = useCallback(\n (withKeyboard: boolean) => {\n zoomTo(1);\n if (withKeyboard) containerRef?.focus();\n },\n [containerRef, zoomTo],\n );\n\n const isZoomedOut = containerRatio <= 1;\n const isZoomedIn = containerRatio >= maxRatio;\n\n // a band axis does not zoom\n if (xScale?.type === 'BAND' || yScale?.type === 'BAND') return null;\n if (!xScroll) return null;\n\n const step = TOOLBAR.RESET.WIDTH + BUTTON_GAP;\n // right-aligned, where the reset button used to be alone, and centered in the top margin\n const toolbarX = width - TOOLBAR.RESET.WIDTH * 2 - step * 2;\n const toolbarY = internalMargin.top / 2 - TOOLBAR.RESET.HEIGHT / 2;\n return (\n <g ref={setToolbarRef} transform={`translate(${toolbarX},${toolbarY})`}>\n <ToolbarButton\n Component={StyledZoomInButton}\n label=\"Zoom in chart\"\n isDisabled={isZoomedIn}\n isFirstFocusable={!isZoomedIn}\n x={0}\n onActivate={zoomIn}\n >\n <path d=\"M 5 8.5 H 12 M 8.5 5 V 12\" {...ICON_PROPS} />\n </ToolbarButton>\n <ToolbarButton\n Component={StyledZoomOutButton}\n label=\"Zoom out chart\"\n isDisabled={isZoomedOut}\n isFirstFocusable={isZoomedIn && !isZoomedOut}\n x={step}\n onActivate={zoomOut}\n >\n <path d=\"M 5 8.5 H 12\" {...ICON_PROPS} />\n </ToolbarButton>\n <ToolbarButton\n Component={StyledResetter}\n label=\"Reset zoom in chart\"\n isDisabled={isZoomedOut}\n isFirstFocusable={false}\n x={step * 2}\n onActivate={reset}\n >\n <path\n d=\"M 2.875 7.75 A 5.625 5.625 0 1 1 4.5225 11.7275 L 8.2725 10.7275 L 6.5225 14.9775 L 4.5225 11.7275\"\n {...ICON_PROPS}\n />\n </ToolbarButton>\n </g>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADoEnB;AApEJ,mBAAwD;AACxD,uBAA6B;AAC7B,0BAA6B;AAC7B,uBAAwB;AACxB,oBAAwE;AAGx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;AAAA,YACD,GAAG;AAAA;AAAA,QACN;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -9,6 +9,7 @@ const Chart = (props) => {
|
|
|
9
9
|
const ctx = useChart(props);
|
|
10
10
|
return /* @__PURE__ */ jsx(ChartContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(ChartContainer, {}) });
|
|
11
11
|
};
|
|
12
|
+
Chart.displayName = "Chart";
|
|
12
13
|
const ChartWithSchema = describe(Chart);
|
|
13
14
|
ChartWithSchema.propTypes = DSChartPropTypesSchema;
|
|
14
15
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/graphs/Chart/Chart.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { ChartContainer } from './parts/ChartContainer.js';\nimport { ChartContext } from './ChartContext.js';\nimport { useChart } from './config/useChart.js';\nimport { DSChartPropTypesSchema, type DSChartT } from '../../react-desc-prop-types.js';\nconst Chart: React.ComponentType<DSChartT.Props> = (props) => {\n const ctx = useChart(props);\n return (\n <ChartContext.Provider value={ctx}>\n <ChartContainer />\n </ChartContext.Provider>\n );\n};\n\nconst ChartWithSchema = describe(Chart);\nChartWithSchema.propTypes = DSChartPropTypesSchema;\n\nexport { Chart, ChartWithSchema };\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACUjB;AATN,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AACzB,SAAS,8BAA6C;AACtD,MAAM,QAA6C,CAAC,UAAU;AAC5D,QAAM,MAAM,SAAS,KAAK;AAC1B,SACE,oBAAC,aAAa,UAAb,EAAsB,OAAO,KAC5B,8BAAC,kBAAe,GAClB;AAEJ;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { ChartContainer } from './parts/ChartContainer.js';\nimport { ChartContext } from './ChartContext.js';\nimport { useChart } from './config/useChart.js';\nimport { DSChartPropTypesSchema, type DSChartT } from '../../react-desc-prop-types.js';\nconst Chart: React.ComponentType<DSChartT.Props> = (props) => {\n const ctx = useChart(props);\n return (\n <ChartContext.Provider value={ctx}>\n <ChartContainer />\n </ChartContext.Provider>\n );\n};\n\n// PUI-19397: the props table heading is the component's displayName, or its function name when it has none, and a\n// minified build renames the function. 'Chart' is not DSDatavizName: that name is the slot namespace, not the heading.\nChart.displayName = 'Chart';\nconst ChartWithSchema = describe(Chart);\nChartWithSchema.propTypes = DSChartPropTypesSchema;\n\nexport { Chart, ChartWithSchema };\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACUjB;AATN,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AACzB,SAAS,8BAA6C;AACtD,MAAM,QAA6C,CAAC,UAAU;AAC5D,QAAM,MAAM,SAAS,KAAK;AAC1B,SACE,oBAAC,aAAa,UAAb,EAAsB,OAAO,KAC5B,8BAAC,kBAAe,GAClB;AAEJ;AAIA,MAAM,cAAc;AACpB,MAAM,kBAAkB,SAAS,KAAK;AACtC,gBAAgB,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -53,7 +53,7 @@ const ToolbarButton = ({
|
|
|
53
53
|
isDisabled,
|
|
54
54
|
role: "button",
|
|
55
55
|
"aria-label": label,
|
|
56
|
-
"aria-disabled": isDisabled,
|
|
56
|
+
"aria-disabled": isDisabled ? true : void 0,
|
|
57
57
|
tabIndex: isDisabled ? -1 : 0,
|
|
58
58
|
getOwnerProps,
|
|
59
59
|
getOwnerPropsArguments: () => ({ isDisabled }),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/graphs/Chart/parts/Scroller/Controllers.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useCallback, useMemo } from 'react';\nimport { ThemeContext } from '@elliemae/ds-system';\nimport { ChartContext } from '../../ChartContext.js';\nimport { TOOLBAR } from '../../../constants.js';\nimport { StyledResetter, StyledZoomInButton, StyledZoomOutButton } from '../../styles.js';\n\n// each zoom step doubles or halves the zoom, around the center of the view\nconst ZOOM_STEP = 2;\n// zooming in stops when about this many points of the longest series are in view\nconst MIN_POINTS_IN_VIEW = 8;\n// the room between two buttons of the toolbar\nconst BUTTON_GAP = 4;\n\nconst BUTTON_SIZE = TOOLBAR.RESET.WIDTH - 4;\nconst ICON_PROPS = {\n fill: 'none',\n strokeLinecap: 'round',\n strokeLinejoin: 'round',\n strokeWidth: '1.25',\n} as const;\n\ntype ToolbarButtonComponent = typeof StyledResetter | typeof StyledZoomInButton | typeof StyledZoomOutButton;\n\ninterface ToolbarButtonProps {\n Component: ToolbarButtonComponent;\n label: string;\n isDisabled: boolean;\n // the first button the keyboard reaches: Shift + Tab goes back to the chart from it\n isFirstFocusable: boolean;\n x: number;\n // with the keyboard or with the pointer\n onActivate: (withKeyboard: boolean) => void;\n children: React.ReactNode;\n}\n\n// A button of the zoom toolbar. A disabled one leaves the tab order, says it is disabled, and does nothing.\nconst ToolbarButton = ({\n Component,\n label,\n isDisabled,\n isFirstFocusable,\n x,\n onActivate,\n children,\n}: ToolbarButtonProps) => {\n const { containerRef, getOwnerProps } = useContext(ChartContext);\n const theme = useContext(ThemeContext);\n\n const handleOnClick = useCallback(() => {\n if (!isDisabled) onActivate(false);\n }, [isDisabled, onActivate]);\n\n const handleOnKeyDown: React.KeyboardEventHandler = useCallback(\n (e) => {\n e.stopPropagation();\n if (['Space', 'Enter'].includes(e.code)) {\n e.preventDefault();\n if (!isDisabled) onActivate(true);\n }\n if (isFirstFocusable && e.code === 'Tab' && e.shiftKey) {\n e.preventDefault();\n containerRef?.focus();\n }\n },\n [containerRef, isDisabled, isFirstFocusable, onActivate],\n );\n\n return (\n <Component\n onClick={handleOnClick}\n onKeyDown={handleOnKeyDown}\n transform={`translate(${x},0)`}\n strokeLinecap=\"round\"\n isDisabled={isDisabled}\n role=\"button\"\n aria-label={label}\n aria-disabled={isDisabled}\n tabIndex={isDisabled ? -1 : 0}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={() => ({ isDisabled })}\n >\n {/* a rounded 17px button, the same box for the three of them */}\n <rect\n width={BUTTON_SIZE}\n height={BUTTON_SIZE}\n rx={3}\n fill={theme?.colors?.neutral?.['000'] ?? '#FFFFFF'}\n stroke={theme?.colors?.neutral?.['300'] ?? '#B0B9C8'}\n strokeWidth=\"1\"\n />\n <g stroke={theme?.colors?.neutral?.['700'] ?? '#353C46'}>{children}</g>\n </Component>\n );\n};\n\n// The zoom toolbar of a horizontally scrollable chart with a linear or time axis: zoom in and zoom out, a step at a\n// time around the center of the view, and reset, back to the whole range. Dragging across the plot and Shift with the\n// arrows zoom as well (see ScrollableContainerX and useKeyboardNavigation).\nexport const Controllers = () => {\n const {\n props: { xScroll },\n width,\n innerWidth,\n internalMargin,\n xScale,\n yScale,\n containerRef,\n containerRatio,\n setContainerRatio,\n lastScrollbarPosition,\n setToolbarRef,\n setXScrollbarPosition,\n interactionStore,\n currentData,\n } = useContext(ChartContext);\n\n const maxRatio = useMemo(\n () => Math.max(ZOOM_STEP, Math.max(0, ...currentData.map((serie) => serie.data.length)) / MIN_POINTS_IN_VIEW),\n [currentData],\n );\n\n // the zoom at `ratio`, with the center of the view where it was, as a share of the plot\n const zoomTo = useCallback(\n (ratio: number) => {\n const nextRatio = Math.min(maxRatio, Math.max(1, ratio));\n const { xScrollbarPosition } = interactionStore.getState();\n const center = (xScrollbarPosition * containerRatio + innerWidth / 2) / (innerWidth * containerRatio);\n const lastPosition = innerWidth - innerWidth / nextRatio;\n const position = Math.min(lastPosition, Math.max(0, center * innerWidth - innerWidth / (2 * nextRatio)));\n setContainerRatio(nextRatio);\n setXScrollbarPosition(position);\n lastScrollbarPosition.current = position;\n },\n [\n containerRatio,\n innerWidth,\n interactionStore,\n lastScrollbarPosition,\n maxRatio,\n setContainerRatio,\n setXScrollbarPosition,\n ],\n );\n\n const zoomIn = useCallback(() => zoomTo(containerRatio * ZOOM_STEP), [containerRatio, zoomTo]);\n const zoomOut = useCallback(() => zoomTo(containerRatio / ZOOM_STEP), [containerRatio, zoomTo]);\n // reset disables itself and zoom out: with the keyboard, the focus goes back to the chart (with the pointer it stays\n // put, as focusing the chart activates its first point and opens its tooltip)\n const reset = useCallback(\n (withKeyboard: boolean) => {\n zoomTo(1);\n if (withKeyboard) containerRef?.focus();\n },\n [containerRef, zoomTo],\n );\n\n const isZoomedOut = containerRatio <= 1;\n const isZoomedIn = containerRatio >= maxRatio;\n\n // a band axis does not zoom\n if (xScale?.type === 'BAND' || yScale?.type === 'BAND') return null;\n if (!xScroll) return null;\n\n const step = TOOLBAR.RESET.WIDTH + BUTTON_GAP;\n // right-aligned, where the reset button used to be alone, and centered in the top margin\n const toolbarX = width - TOOLBAR.RESET.WIDTH * 2 - step * 2;\n const toolbarY = internalMargin.top / 2 - TOOLBAR.RESET.HEIGHT / 2;\n return (\n <g ref={setToolbarRef} transform={`translate(${toolbarX},${toolbarY})`}>\n <ToolbarButton\n Component={StyledZoomInButton}\n label=\"Zoom in chart\"\n isDisabled={isZoomedIn}\n isFirstFocusable={!isZoomedIn}\n x={0}\n onActivate={zoomIn}\n >\n <path d=\"M 5 8.5 H 12 M 8.5 5 V 12\" {...ICON_PROPS} />\n </ToolbarButton>\n <ToolbarButton\n Component={StyledZoomOutButton}\n label=\"Zoom out chart\"\n isDisabled={isZoomedOut}\n isFirstFocusable={isZoomedIn && !isZoomedOut}\n x={step}\n onActivate={zoomOut}\n >\n <path d=\"M 5 8.5 H 12\" {...ICON_PROPS} />\n </ToolbarButton>\n <ToolbarButton\n Component={StyledResetter}\n label=\"Reset zoom in chart\"\n isDisabled={isZoomedOut}\n isFirstFocusable={false}\n x={step * 2}\n onActivate={reset}\n >\n <path\n d=\"M 2.875 7.75 A 5.625 5.625 0 1 1 4.5225 11.7275 L 8.2725 10.7275 L 6.5225 14.9775 L 4.5225 11.7275\"\n {...ICON_PROPS}\n />\n </ToolbarButton>\n </g>\n );\n};\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACoEnB,SAcE,KAdF;AApEJ,SAAgB,YAAY,aAAa,eAAe;AACxD,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,eAAe;AACxB,SAAS,gBAAgB,oBAAoB,2BAA2B;AAGxE,MAAM,YAAY;AAElB,MAAM,qBAAqB;AAE3B,MAAM,aAAa;AAEnB,MAAM,cAAc,QAAQ,MAAM,QAAQ;AAC1C,MAAM,aAAa;AAAA,EACjB,MAAM;AAAA,EACN,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,aAAa;AACf;AAiBA,MAAM,gBAAgB,CAAC;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA0B;AACxB,QAAM,EAAE,cAAc,cAAc,IAAI,WAAW,YAAY;AAC/D,QAAM,QAAQ,WAAW,YAAY;AAErC,QAAM,gBAAgB,YAAY,MAAM;AACtC,QAAI,CAAC,WAAY,YAAW,KAAK;AAAA,EACnC,GAAG,CAAC,YAAY,UAAU,CAAC;AAE3B,QAAM,kBAA8C;AAAA,IAClD,CAAC,MAAM;AACL,QAAE,gBAAgB;AAClB,UAAI,CAAC,SAAS,OAAO,EAAE,SAAS,EAAE,IAAI,GAAG;AACvC,UAAE,eAAe;AACjB,YAAI,CAAC,WAAY,YAAW,IAAI;AAAA,MAClC;AACA,UAAI,oBAAoB,EAAE,SAAS,SAAS,EAAE,UAAU;AACtD,UAAE,eAAe;AACjB,sBAAc,MAAM;AAAA,MACtB;AAAA,IACF;AAAA,IACA,CAAC,cAAc,YAAY,kBAAkB,UAAU;AAAA,EACzD;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAS;AAAA,MACT,WAAW;AAAA,MACX,WAAW,aAAa,CAAC;AAAA,MACzB,eAAc;AAAA,MACd;AAAA,MACA,MAAK;AAAA,MACL,cAAY;AAAA,MACZ,iBAAe;AAAA,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useCallback, useMemo } from 'react';\nimport { ThemeContext } from '@elliemae/ds-system';\nimport { ChartContext } from '../../ChartContext.js';\nimport { TOOLBAR } from '../../../constants.js';\nimport { StyledResetter, StyledZoomInButton, StyledZoomOutButton } from '../../styles.js';\n\n// each zoom step doubles or halves the zoom, around the center of the view\nconst ZOOM_STEP = 2;\n// zooming in stops when about this many points of the longest series are in view\nconst MIN_POINTS_IN_VIEW = 8;\n// the room between two buttons of the toolbar\nconst BUTTON_GAP = 4;\n\nconst BUTTON_SIZE = TOOLBAR.RESET.WIDTH - 4;\nconst ICON_PROPS = {\n fill: 'none',\n strokeLinecap: 'round',\n strokeLinejoin: 'round',\n strokeWidth: '1.25',\n} as const;\n\ntype ToolbarButtonComponent = typeof StyledResetter | typeof StyledZoomInButton | typeof StyledZoomOutButton;\n\ninterface ToolbarButtonProps {\n Component: ToolbarButtonComponent;\n label: string;\n isDisabled: boolean;\n // the first button the keyboard reaches: Shift + Tab goes back to the chart from it\n isFirstFocusable: boolean;\n x: number;\n // with the keyboard or with the pointer\n onActivate: (withKeyboard: boolean) => void;\n children: React.ReactNode;\n}\n\n// A button of the zoom toolbar. A disabled one leaves the tab order, says it is disabled, and does nothing.\nconst ToolbarButton = ({\n Component,\n label,\n isDisabled,\n isFirstFocusable,\n x,\n onActivate,\n children,\n}: ToolbarButtonProps) => {\n const { containerRef, getOwnerProps } = useContext(ChartContext);\n const theme = useContext(ThemeContext);\n\n const handleOnClick = useCallback(() => {\n if (!isDisabled) onActivate(false);\n }, [isDisabled, onActivate]);\n\n const handleOnKeyDown: React.KeyboardEventHandler = useCallback(\n (e) => {\n e.stopPropagation();\n if (['Space', 'Enter'].includes(e.code)) {\n e.preventDefault();\n if (!isDisabled) onActivate(true);\n }\n if (isFirstFocusable && e.code === 'Tab' && e.shiftKey) {\n e.preventDefault();\n containerRef?.focus();\n }\n },\n [containerRef, isDisabled, isFirstFocusable, onActivate],\n );\n\n return (\n <Component\n onClick={handleOnClick}\n onKeyDown={handleOnKeyDown}\n transform={`translate(${x},0)`}\n strokeLinecap=\"round\"\n isDisabled={isDisabled}\n role=\"button\"\n aria-label={label}\n aria-disabled={isDisabled ? true : undefined}\n tabIndex={isDisabled ? -1 : 0}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={() => ({ isDisabled })}\n >\n {/* a rounded 17px button, the same box for the three of them */}\n <rect\n width={BUTTON_SIZE}\n height={BUTTON_SIZE}\n rx={3}\n fill={theme?.colors?.neutral?.['000'] ?? '#FFFFFF'}\n stroke={theme?.colors?.neutral?.['300'] ?? '#B0B9C8'}\n strokeWidth=\"1\"\n />\n <g stroke={theme?.colors?.neutral?.['700'] ?? '#353C46'}>{children}</g>\n </Component>\n );\n};\n\n// The zoom toolbar of a horizontally scrollable chart with a linear or time axis: zoom in and zoom out, a step at a\n// time around the center of the view, and reset, back to the whole range. Dragging across the plot and Shift with the\n// arrows zoom as well (see ScrollableContainerX and useKeyboardNavigation).\nexport const Controllers = () => {\n const {\n props: { xScroll },\n width,\n innerWidth,\n internalMargin,\n xScale,\n yScale,\n containerRef,\n containerRatio,\n setContainerRatio,\n lastScrollbarPosition,\n setToolbarRef,\n setXScrollbarPosition,\n interactionStore,\n currentData,\n } = useContext(ChartContext);\n\n const maxRatio = useMemo(\n () => Math.max(ZOOM_STEP, Math.max(0, ...currentData.map((serie) => serie.data.length)) / MIN_POINTS_IN_VIEW),\n [currentData],\n );\n\n // the zoom at `ratio`, with the center of the view where it was, as a share of the plot\n const zoomTo = useCallback(\n (ratio: number) => {\n const nextRatio = Math.min(maxRatio, Math.max(1, ratio));\n const { xScrollbarPosition } = interactionStore.getState();\n const center = (xScrollbarPosition * containerRatio + innerWidth / 2) / (innerWidth * containerRatio);\n const lastPosition = innerWidth - innerWidth / nextRatio;\n const position = Math.min(lastPosition, Math.max(0, center * innerWidth - innerWidth / (2 * nextRatio)));\n setContainerRatio(nextRatio);\n setXScrollbarPosition(position);\n lastScrollbarPosition.current = position;\n },\n [\n containerRatio,\n innerWidth,\n interactionStore,\n lastScrollbarPosition,\n maxRatio,\n setContainerRatio,\n setXScrollbarPosition,\n ],\n );\n\n const zoomIn = useCallback(() => zoomTo(containerRatio * ZOOM_STEP), [containerRatio, zoomTo]);\n const zoomOut = useCallback(() => zoomTo(containerRatio / ZOOM_STEP), [containerRatio, zoomTo]);\n // reset disables itself and zoom out: with the keyboard, the focus goes back to the chart (with the pointer it stays\n // put, as focusing the chart activates its first point and opens its tooltip)\n const reset = useCallback(\n (withKeyboard: boolean) => {\n zoomTo(1);\n if (withKeyboard) containerRef?.focus();\n },\n [containerRef, zoomTo],\n );\n\n const isZoomedOut = containerRatio <= 1;\n const isZoomedIn = containerRatio >= maxRatio;\n\n // a band axis does not zoom\n if (xScale?.type === 'BAND' || yScale?.type === 'BAND') return null;\n if (!xScroll) return null;\n\n const step = TOOLBAR.RESET.WIDTH + BUTTON_GAP;\n // right-aligned, where the reset button used to be alone, and centered in the top margin\n const toolbarX = width - TOOLBAR.RESET.WIDTH * 2 - step * 2;\n const toolbarY = internalMargin.top / 2 - TOOLBAR.RESET.HEIGHT / 2;\n return (\n <g ref={setToolbarRef} transform={`translate(${toolbarX},${toolbarY})`}>\n <ToolbarButton\n Component={StyledZoomInButton}\n label=\"Zoom in chart\"\n isDisabled={isZoomedIn}\n isFirstFocusable={!isZoomedIn}\n x={0}\n onActivate={zoomIn}\n >\n <path d=\"M 5 8.5 H 12 M 8.5 5 V 12\" {...ICON_PROPS} />\n </ToolbarButton>\n <ToolbarButton\n Component={StyledZoomOutButton}\n label=\"Zoom out chart\"\n isDisabled={isZoomedOut}\n isFirstFocusable={isZoomedIn && !isZoomedOut}\n x={step}\n onActivate={zoomOut}\n >\n <path d=\"M 5 8.5 H 12\" {...ICON_PROPS} />\n </ToolbarButton>\n <ToolbarButton\n Component={StyledResetter}\n label=\"Reset zoom in chart\"\n isDisabled={isZoomedOut}\n isFirstFocusable={false}\n x={step * 2}\n onActivate={reset}\n >\n <path\n d=\"M 2.875 7.75 A 5.625 5.625 0 1 1 4.5225 11.7275 L 8.2725 10.7275 L 6.5225 14.9775 L 4.5225 11.7275\"\n {...ICON_PROPS}\n />\n </ToolbarButton>\n </g>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACoEnB,SAcE,KAdF;AApEJ,SAAgB,YAAY,aAAa,eAAe;AACxD,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,eAAe;AACxB,SAAS,gBAAgB,oBAAoB,2BAA2B;AAGxE,MAAM,YAAY;AAElB,MAAM,qBAAqB;AAE3B,MAAM,aAAa;AAEnB,MAAM,cAAc,QAAQ,MAAM,QAAQ;AAC1C,MAAM,aAAa;AAAA,EACjB,MAAM;AAAA,EACN,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,aAAa;AACf;AAiBA,MAAM,gBAAgB,CAAC;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA0B;AACxB,QAAM,EAAE,cAAc,cAAc,IAAI,WAAW,YAAY;AAC/D,QAAM,QAAQ,WAAW,YAAY;AAErC,QAAM,gBAAgB,YAAY,MAAM;AACtC,QAAI,CAAC,WAAY,YAAW,KAAK;AAAA,EACnC,GAAG,CAAC,YAAY,UAAU,CAAC;AAE3B,QAAM,kBAA8C;AAAA,IAClD,CAAC,MAAM;A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C,OAAE,KAAK,eAAe,WAAW,aAAa,QAAQ,IAAI,QAAQ,KACjE;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,WAAW;AAAA,QACX,OAAM;AAAA,QACN,YAAY;AAAA,QACZ,kBAAkB,CAAC;AAAA,QACnB,GAAG;AAAA,QACH,YAAY;AAAA,QAEZ,8BAAC,UAAK,GAAE,6BAA6B,GAAG,YAAY;AAAA;AAAA,IACtD;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,WAAW;AAAA,QACX,OAAM;AAAA,QACN,YAAY;AAAA,QACZ,kBAAkB,cAAc,CAAC;AAAA,QACjC,GAAG;AAAA,QACH,YAAY;AAAA,QAEZ,8BAAC,UAAK,GAAE,gBAAgB,GAAG,YAAY;AAAA;AAAA,IACzC;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,WAAW;AAAA,QACX,OAAM;AAAA,QACN,YAAY;AAAA,QACZ,kBAAkB;AAAA,QAClB,GAAG,OAAO;AAAA,QACV,YAAY;AAAA,QAEZ;AAAA,UAAC;AAAA;AAAA,YACC,GAAE;AAAA,YACD,GAAG;AAAA;AAAA,QACN;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-dataviz",
|
|
3
|
-
"version": "3.80.0-next.
|
|
3
|
+
"version": "3.80.0-next.76",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - DataViz",
|
|
6
6
|
"files": [
|
|
@@ -36,18 +36,18 @@
|
|
|
36
36
|
"indent": 4
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@elliemae/ds-floating-context": "3.80.0-next.
|
|
40
|
-
"@elliemae/ds-grid": "3.80.0-next.
|
|
41
|
-
"@elliemae/ds-props-helpers": "3.80.0-next.
|
|
42
|
-
"@elliemae/ds-system": "3.80.0-next.
|
|
43
|
-
"@elliemae/ds-typescript-helpers": "3.80.0-next.
|
|
39
|
+
"@elliemae/ds-floating-context": "3.80.0-next.76",
|
|
40
|
+
"@elliemae/ds-grid": "3.80.0-next.76",
|
|
41
|
+
"@elliemae/ds-props-helpers": "3.80.0-next.76",
|
|
42
|
+
"@elliemae/ds-system": "3.80.0-next.76",
|
|
43
|
+
"@elliemae/ds-typescript-helpers": "3.80.0-next.76",
|
|
44
44
|
"d3": "~7.9.0",
|
|
45
45
|
"resize-observer-polyfill": "~1.5.1",
|
|
46
46
|
"uid": "^2.0.2"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@elliemae/ds-monorepo-devops": "3.80.0-next.
|
|
50
|
-
"@elliemae/ds-test-utils": "3.80.0-next.
|
|
49
|
+
"@elliemae/ds-monorepo-devops": "3.80.0-next.76",
|
|
50
|
+
"@elliemae/ds-test-utils": "3.80.0-next.76",
|
|
51
51
|
"@elliemae/pui-theme": "~2.13.0",
|
|
52
52
|
"@types/d3": "~7.4.0",
|
|
53
53
|
"jest": "^30.0.0",
|