@carto/ps-react-ui 4.7.0 → 4.8.0
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/category-DwaeYjpX.js +656 -0
- package/dist/category-DwaeYjpX.js.map +1 -0
- package/dist/change-column-Cidl_M-4.js +1110 -0
- package/dist/change-column-Cidl_M-4.js.map +1 -0
- package/dist/data-zoom-layout-BH0LPwSy.js +28 -0
- package/dist/data-zoom-layout-BH0LPwSy.js.map +1 -0
- package/dist/echart-CU0KmClP.js +176 -0
- package/dist/echart-CU0KmClP.js.map +1 -0
- package/dist/exports-Cx-f6m6U.js +63 -0
- package/dist/exports-Cx-f6m6U.js.map +1 -0
- package/dist/formula-DuC0NQLH.js +79 -0
- package/dist/formula-DuC0NQLH.js.map +1 -0
- package/dist/markdown-BD1jcknS.js +8326 -0
- package/dist/markdown-BD1jcknS.js.map +1 -0
- package/dist/merge-options-DCkkHZIf.js +34 -0
- package/dist/merge-options-DCkkHZIf.js.map +1 -0
- package/dist/{styles-BYTyKQFP.js → option-builders-F-c9ELi1.js} +25 -45
- package/dist/option-builders-F-c9ELi1.js.map +1 -0
- package/dist/png-item-CS4z1iSH.js +45 -0
- package/dist/png-item-CS4z1iSH.js.map +1 -0
- package/dist/range-DsqTjSpg.js +186 -0
- package/dist/range-DsqTjSpg.js.map +1 -0
- package/dist/spread-CTuIXZSM.js +67 -0
- package/dist/spread-CTuIXZSM.js.map +1 -0
- package/dist/style-DVnT6HC1.js +131 -0
- package/dist/style-DVnT6HC1.js.map +1 -0
- package/dist/styles-cohnxh9F.js +23 -0
- package/dist/styles-cohnxh9F.js.map +1 -0
- package/dist/table-HIpXuq4G.js +390 -0
- package/dist/table-HIpXuq4G.js.map +1 -0
- package/dist/transforms-Cdx4fkU5.js +106 -0
- package/dist/transforms-Cdx4fkU5.js.map +1 -0
- package/dist/types/widgets/echart/utils.test.d.ts +1 -0
- package/dist/types/widgets/formula/config.test.d.ts +1 -0
- package/dist/types/widgets/stores/widget-store-branches.test.d.ts +1 -0
- package/dist/types/widgets/table/config.test.d.ts +1 -0
- package/dist/types/widgets-v2/actions/brush-toggle/brush-toggle.d.ts +56 -0
- package/dist/types/widgets-v2/actions/brush-toggle/index.d.ts +3 -0
- package/dist/types/widgets-v2/actions/brush-toggle/labels.d.ts +5 -0
- package/dist/types/widgets-v2/actions/brush-toggle/style.d.ts +12 -0
- package/dist/types/widgets-v2/actions/brush-toggle/transforms.d.ts +11 -0
- package/dist/types/widgets-v2/actions/brush-toggle/transforms.test.d.ts +1 -0
- package/dist/types/widgets-v2/actions/change-column/change-column-icon.d.ts +2 -0
- package/dist/types/widgets-v2/actions/change-column/change-column.d.ts +29 -0
- package/dist/types/widgets-v2/actions/change-column/index.d.ts +3 -0
- package/dist/types/widgets-v2/actions/change-column/labels.d.ts +5 -0
- package/dist/types/widgets-v2/actions/change-column/sortable-column-item.d.ts +14 -0
- package/dist/types/widgets-v2/actions/change-column/style.d.ts +33 -0
- package/dist/types/widgets-v2/actions/change-column/types.d.ts +10 -0
- package/dist/types/widgets-v2/actions/download/download.d.ts +18 -0
- package/dist/types/widgets-v2/actions/download/exports.d.ts +37 -0
- package/dist/types/widgets-v2/actions/download/icons.d.ts +12 -0
- package/dist/types/widgets-v2/actions/download/index.d.ts +6 -0
- package/dist/types/widgets-v2/actions/download/labels.d.ts +11 -0
- package/dist/types/widgets-v2/actions/download/png-item.d.ts +24 -0
- package/dist/types/widgets-v2/actions/download/style.d.ts +1 -0
- package/dist/types/widgets-v2/actions/download/types.d.ts +35 -0
- package/dist/types/widgets-v2/actions/fullscreen/fullscreen.d.ts +59 -0
- package/dist/types/widgets-v2/actions/fullscreen/index.d.ts +3 -0
- package/dist/types/widgets-v2/actions/fullscreen/labels.d.ts +5 -0
- package/dist/types/widgets-v2/actions/fullscreen/style.d.ts +48 -0
- package/dist/types/widgets-v2/actions/fullscreen/types.d.ts +14 -0
- package/dist/types/widgets-v2/actions/index.d.ts +9 -0
- package/dist/types/widgets-v2/actions/lock-selection/index.d.ts +3 -0
- package/dist/types/widgets-v2/actions/lock-selection/labels.d.ts +6 -0
- package/dist/types/widgets-v2/actions/lock-selection/lock-selection.d.ts +36 -0
- package/dist/types/widgets-v2/actions/lock-selection/style.d.ts +12 -0
- package/dist/types/widgets-v2/actions/lock-selection/transforms.d.ts +6 -0
- package/dist/types/widgets-v2/actions/relative-data/index.d.ts +3 -0
- package/dist/types/widgets-v2/actions/relative-data/labels.d.ts +5 -0
- package/dist/types/widgets-v2/actions/relative-data/relative-data.d.ts +39 -0
- package/dist/types/widgets-v2/actions/relative-data/style.d.ts +12 -0
- package/dist/types/widgets-v2/actions/relative-data/transforms.d.ts +30 -0
- package/dist/types/widgets-v2/actions/relative-data/transforms.test.d.ts +1 -0
- package/dist/types/widgets-v2/actions/searcher/filter.d.ts +6 -0
- package/dist/types/widgets-v2/actions/searcher/index.d.ts +4 -0
- package/dist/types/widgets-v2/actions/searcher/labels.d.ts +7 -0
- package/dist/types/widgets-v2/actions/searcher/searcher-toggle.d.ts +23 -0
- package/dist/types/widgets-v2/actions/searcher/searcher.d.ts +11 -0
- package/dist/types/widgets-v2/actions/searcher/style.d.ts +16 -0
- package/dist/types/widgets-v2/actions/stack-toggle/index.d.ts +3 -0
- package/dist/types/widgets-v2/actions/stack-toggle/labels.d.ts +5 -0
- package/dist/types/widgets-v2/actions/stack-toggle/stack-toggle.d.ts +10 -0
- package/dist/types/widgets-v2/actions/stack-toggle/style.d.ts +12 -0
- package/dist/types/widgets-v2/actions/stack-toggle/transforms.d.ts +13 -0
- package/dist/types/widgets-v2/actions/stack-toggle/transforms.test.d.ts +1 -0
- package/dist/types/widgets-v2/actions/zoom-toggle/index.d.ts +3 -0
- package/dist/types/widgets-v2/actions/zoom-toggle/labels.d.ts +5 -0
- package/dist/types/widgets-v2/actions/zoom-toggle/style.d.ts +12 -0
- package/dist/types/widgets-v2/actions/zoom-toggle/transforms.d.ts +51 -0
- package/dist/types/widgets-v2/actions/zoom-toggle/transforms.test.d.ts +1 -0
- package/dist/types/widgets-v2/actions/zoom-toggle/zoom-toggle.d.ts +35 -0
- package/dist/types/widgets-v2/bar/download.d.ts +24 -0
- package/dist/types/widgets-v2/bar/index.d.ts +4 -0
- package/dist/types/widgets-v2/bar/options.d.ts +43 -0
- package/dist/types/widgets-v2/bar/options.test.d.ts +1 -0
- package/dist/types/widgets-v2/bar/skeleton.d.ts +6 -0
- package/dist/types/widgets-v2/bar/types.d.ts +41 -0
- package/dist/types/widgets-v2/category/category-ui.d.ts +81 -0
- package/dist/types/widgets-v2/category/category.d.ts +48 -0
- package/dist/types/widgets-v2/category/components/category-bar-stacked.d.ts +28 -0
- package/dist/types/widgets-v2/category/components/category-bar.d.ts +23 -0
- package/dist/types/widgets-v2/category/components/category-legend.d.ts +18 -0
- package/dist/types/widgets-v2/category/components/category-row-multi.d.ts +31 -0
- package/dist/types/widgets-v2/category/components/category-row-other.d.ts +13 -0
- package/dist/types/widgets-v2/category/components/category-row-single.d.ts +28 -0
- package/dist/types/widgets-v2/category/components/category-row-stacked.d.ts +38 -0
- package/dist/types/widgets-v2/category/download.d.ts +16 -0
- package/dist/types/widgets-v2/category/download.test.d.ts +1 -0
- package/dist/types/widgets-v2/category/index.d.ts +10 -0
- package/dist/types/widgets-v2/category/skeleton.d.ts +11 -0
- package/dist/types/widgets-v2/category/style.d.ts +166 -0
- package/dist/types/widgets-v2/category/types.d.ts +49 -0
- package/dist/types/widgets-v2/echart/echart-ui.d.ts +44 -0
- package/dist/types/widgets-v2/echart/echart.d.ts +75 -0
- package/dist/types/widgets-v2/echart/index.d.ts +4 -0
- package/dist/types/widgets-v2/echart/shared-resize-observer.d.ts +5 -0
- package/dist/types/widgets-v2/echart/shared-resize-observer.test.d.ts +1 -0
- package/dist/types/widgets-v2/echart/style.d.ts +6 -0
- package/dist/types/widgets-v2/echart/use-chart-selection.d.ts +51 -0
- package/dist/types/widgets-v2/formula/delta.d.ts +22 -0
- package/dist/types/widgets-v2/formula/download.d.ts +20 -0
- package/dist/types/widgets-v2/formula/formula-ui.d.ts +20 -0
- package/dist/types/widgets-v2/formula/formula.d.ts +8 -0
- package/dist/types/widgets-v2/formula/index.d.ts +11 -0
- package/dist/types/widgets-v2/formula/note.d.ts +11 -0
- package/dist/types/widgets-v2/formula/prefix.d.ts +12 -0
- package/dist/types/widgets-v2/formula/series.d.ts +16 -0
- package/dist/types/widgets-v2/formula/skeleton.d.ts +4 -0
- package/dist/types/widgets-v2/formula/style.d.ts +29 -0
- package/dist/types/widgets-v2/formula/suffix.d.ts +12 -0
- package/dist/types/widgets-v2/formula/types.d.ts +40 -0
- package/dist/types/widgets-v2/formula/value.d.ts +14 -0
- package/dist/types/widgets-v2/histogram/download.d.ts +17 -0
- package/dist/types/widgets-v2/histogram/download.test.d.ts +1 -0
- package/dist/types/widgets-v2/histogram/index.d.ts +5 -0
- package/dist/types/widgets-v2/histogram/options.d.ts +42 -0
- package/dist/types/widgets-v2/histogram/options.test.d.ts +1 -0
- package/dist/types/widgets-v2/histogram/skeleton.d.ts +9 -0
- package/dist/types/widgets-v2/histogram/transforms.d.ts +17 -0
- package/dist/types/widgets-v2/histogram/transforms.test.d.ts +1 -0
- package/dist/types/widgets-v2/histogram/types.d.ts +47 -0
- package/dist/types/widgets-v2/index.d.ts +107 -0
- package/dist/types/widgets-v2/markdown/download.d.ts +16 -0
- package/dist/types/widgets-v2/markdown/download.test.d.ts +1 -0
- package/dist/types/widgets-v2/markdown/index.d.ts +6 -0
- package/dist/types/widgets-v2/markdown/markdown-content.d.ts +34 -0
- package/dist/types/widgets-v2/markdown/markdown-ui.d.ts +12 -0
- package/dist/types/widgets-v2/markdown/markdown.d.ts +6 -0
- package/dist/types/widgets-v2/markdown/skeleton.d.ts +4 -0
- package/dist/types/widgets-v2/markdown/style.d.ts +61 -0
- package/dist/types/widgets-v2/markdown/types.d.ts +4 -0
- package/dist/types/widgets-v2/note/labels.d.ts +5 -0
- package/dist/types/widgets-v2/note/style.d.ts +26 -0
- package/dist/types/widgets-v2/note/widget-note.d.ts +46 -0
- package/dist/types/widgets-v2/pie/download.d.ts +17 -0
- package/dist/types/widgets-v2/pie/download.test.d.ts +1 -0
- package/dist/types/widgets-v2/pie/index.d.ts +4 -0
- package/dist/types/widgets-v2/pie/options.d.ts +35 -0
- package/dist/types/widgets-v2/pie/options.test.d.ts +1 -0
- package/dist/types/widgets-v2/pie/skeleton.d.ts +4 -0
- package/dist/types/widgets-v2/pie/types.d.ts +50 -0
- package/dist/types/widgets-v2/provider/widget-provider.d.ts +32 -0
- package/dist/types/widgets-v2/range/index.d.ts +4 -0
- package/dist/types/widgets-v2/range/range-ui.d.ts +19 -0
- package/dist/types/widgets-v2/range/range.d.ts +19 -0
- package/dist/types/widgets-v2/range/skeleton.d.ts +9 -0
- package/dist/types/widgets-v2/range/style.d.ts +40 -0
- package/dist/types/widgets-v2/range/types.d.ts +37 -0
- package/dist/types/widgets-v2/scatterplot/download.d.ts +16 -0
- package/dist/types/widgets-v2/scatterplot/download.test.d.ts +1 -0
- package/dist/types/widgets-v2/scatterplot/index.d.ts +5 -0
- package/dist/types/widgets-v2/scatterplot/options.d.ts +42 -0
- package/dist/types/widgets-v2/scatterplot/options.test.d.ts +1 -0
- package/dist/types/widgets-v2/scatterplot/skeleton.d.ts +12 -0
- package/dist/types/widgets-v2/scatterplot/transforms.d.ts +17 -0
- package/dist/types/widgets-v2/scatterplot/transforms.test.d.ts +1 -0
- package/dist/types/widgets-v2/scatterplot/types.d.ts +50 -0
- package/dist/types/widgets-v2/selection-summary/labels.d.ts +6 -0
- package/dist/types/widgets-v2/selection-summary/selection-summary.d.ts +22 -0
- package/dist/types/widgets-v2/selection-summary/style.d.ts +23 -0
- package/dist/types/widgets-v2/spread/download.d.ts +15 -0
- package/dist/types/widgets-v2/spread/download.test.d.ts +1 -0
- package/dist/types/widgets-v2/spread/index.d.ts +6 -0
- package/dist/types/widgets-v2/spread/separator.d.ts +7 -0
- package/dist/types/widgets-v2/spread/skeleton.d.ts +9 -0
- package/dist/types/widgets-v2/spread/spread-ui.d.ts +18 -0
- package/dist/types/widgets-v2/spread/spread.d.ts +5 -0
- package/dist/types/widgets-v2/spread/types.d.ts +25 -0
- package/dist/types/widgets-v2/state/labels.d.ts +7 -0
- package/dist/types/widgets-v2/state/labels.test.d.ts +1 -0
- package/dist/types/widgets-v2/state/style.d.ts +19 -0
- package/dist/types/widgets-v2/state/widget-state.d.ts +19 -0
- package/dist/types/widgets-v2/stores/index.d.ts +8 -0
- package/dist/types/widgets-v2/stores/pipeline-middleware.d.ts +5 -0
- package/dist/types/widgets-v2/stores/pipeline-middleware.test.d.ts +1 -0
- package/dist/types/widgets-v2/stores/transforms.d.ts +4 -0
- package/dist/types/widgets-v2/stores/transforms.test.d.ts +1 -0
- package/dist/types/widgets-v2/stores/types.d.ts +55 -0
- package/dist/types/widgets-v2/stores/use-echart-instance.d.ts +15 -0
- package/dist/types/widgets-v2/stores/use-transform-enabled.d.ts +17 -0
- package/dist/types/widgets-v2/stores/use-transform.d.ts +12 -0
- package/dist/types/widgets-v2/stores/widget-context.d.ts +2 -0
- package/dist/types/widgets-v2/stores/widget-store-registry.d.ts +74 -0
- package/dist/types/widgets-v2/stores/widget-store-registry.test.d.ts +1 -0
- package/dist/types/widgets-v2/subheader/style.d.ts +10 -0
- package/dist/types/widgets-v2/subheader/subheader.d.ts +11 -0
- package/dist/types/widgets-v2/table/download.d.ts +18 -0
- package/dist/types/widgets-v2/table/download.test.d.ts +1 -0
- package/dist/types/widgets-v2/table/helpers.d.ts +32 -0
- package/dist/types/widgets-v2/table/helpers.test.d.ts +1 -0
- package/dist/types/widgets-v2/table/index.d.ts +7 -0
- package/dist/types/widgets-v2/table/labels.d.ts +22 -0
- package/dist/types/widgets-v2/table/skeleton.d.ts +22 -0
- package/dist/types/widgets-v2/table/style.d.ts +44 -0
- package/dist/types/widgets-v2/table/table-ui.d.ts +38 -0
- package/dist/types/widgets-v2/table/table.d.ts +50 -0
- package/dist/types/widgets-v2/table/types.d.ts +37 -0
- package/dist/types/widgets-v2/test-utils.d.ts +52 -0
- package/dist/types/widgets-v2/timeseries/download.d.ts +17 -0
- package/dist/types/widgets-v2/timeseries/download.test.d.ts +1 -0
- package/dist/types/widgets-v2/timeseries/index.d.ts +4 -0
- package/dist/types/widgets-v2/timeseries/options.d.ts +39 -0
- package/dist/types/widgets-v2/timeseries/options.test.d.ts +1 -0
- package/dist/types/widgets-v2/timeseries/skeleton.d.ts +8 -0
- package/dist/types/widgets-v2/timeseries/types.d.ts +56 -0
- package/dist/types/widgets-v2/toolbox/labels.d.ts +5 -0
- package/dist/types/widgets-v2/toolbox/style.d.ts +30 -0
- package/dist/types/widgets-v2/toolbox/toolbox.d.ts +49 -0
- package/dist/types/widgets-v2/utils/data-zoom-layout.d.ts +11 -0
- package/dist/types/widgets-v2/utils/index.d.ts +2 -0
- package/dist/types/widgets-v2/utils/merge-options.d.ts +12 -0
- package/dist/types/widgets-v2/utils/merge-options.test.d.ts +1 -0
- package/dist/types/widgets-v2/wrapper/index.d.ts +4 -0
- package/dist/types/widgets-v2/wrapper/labels.d.ts +6 -0
- package/dist/types/widgets-v2/wrapper/style.d.ts +111 -0
- package/dist/types/widgets-v2/wrapper/widget-actions.d.ts +22 -0
- package/dist/types/widgets-v2/wrapper/widget-content.d.ts +12 -0
- package/dist/types/widgets-v2/wrapper/widget-wrapper.d.ts +51 -0
- package/dist/use-transform-DXPN3nY7.js +110 -0
- package/dist/use-transform-DXPN3nY7.js.map +1 -0
- package/dist/widget-context-DTGO0Yta.js +13 -0
- package/dist/widget-context-DTGO0Yta.js.map +1 -0
- package/dist/widget-store-registry-_W4Z4xp-.js +178 -0
- package/dist/widget-store-registry-_W4Z4xp-.js.map +1 -0
- package/dist/widgets/actions.js +688 -668
- package/dist/widgets/actions.js.map +1 -1
- package/dist/widgets/bar.js +14 -13
- package/dist/widgets/bar.js.map +1 -1
- package/dist/widgets/histogram.js +38 -37
- package/dist/widgets/histogram.js.map +1 -1
- package/dist/widgets/pie.js +19 -18
- package/dist/widgets/pie.js.map +1 -1
- package/dist/widgets/scatterplot.js +8 -7
- package/dist/widgets/scatterplot.js.map +1 -1
- package/dist/widgets/timeseries.js +11 -10
- package/dist/widgets/timeseries.js.map +1 -1
- package/dist/widgets/utils.js +8 -7
- package/dist/widgets/utils.js.map +1 -1
- package/dist/widgets-v2/actions.js +43 -0
- package/dist/widgets-v2/actions.js.map +1 -0
- package/dist/widgets-v2/bar.js +327 -0
- package/dist/widgets-v2/bar.js.map +1 -0
- package/dist/widgets-v2/category.js +104 -0
- package/dist/widgets-v2/category.js.map +1 -0
- package/dist/widgets-v2/echart.js +57 -0
- package/dist/widgets-v2/echart.js.map +1 -0
- package/dist/widgets-v2/formula.js +74 -0
- package/dist/widgets-v2/formula.js.map +1 -0
- package/dist/widgets-v2/histogram.js +350 -0
- package/dist/widgets-v2/histogram.js.map +1 -0
- package/dist/widgets-v2/markdown.js +68 -0
- package/dist/widgets-v2/markdown.js.map +1 -0
- package/dist/widgets-v2/pie.js +381 -0
- package/dist/widgets-v2/pie.js.map +1 -0
- package/dist/widgets-v2/range.js +52 -0
- package/dist/widgets-v2/range.js.map +1 -0
- package/dist/widgets-v2/scatterplot.js +405 -0
- package/dist/widgets-v2/scatterplot.js.map +1 -0
- package/dist/widgets-v2/spread.js +72 -0
- package/dist/widgets-v2/spread.js.map +1 -0
- package/dist/widgets-v2/stores.js +42 -0
- package/dist/widgets-v2/stores.js.map +1 -0
- package/dist/widgets-v2/table.js +78 -0
- package/dist/widgets-v2/table.js.map +1 -0
- package/dist/widgets-v2/timeseries.js +352 -0
- package/dist/widgets-v2/timeseries.js.map +1 -0
- package/dist/widgets-v2/utils.js +7 -0
- package/dist/widgets-v2/utils.js.map +1 -0
- package/dist/widgets-v2.js +953 -0
- package/dist/widgets-v2.js.map +1 -0
- package/package.json +73 -5
- package/src/components/lasso-tool/chip.test.tsx +176 -0
- package/src/components/lasso-tool/lasso-tool-inline.test.tsx +171 -0
- package/src/components/lasso-tool/lasso-tool.test.tsx +198 -0
- package/src/components/list-data/list-data.test.tsx +73 -0
- package/src/components/no-data-alert/no-data-alert.test.tsx +38 -0
- package/src/components/responsive-drawer/responsive-drawer.test.tsx +68 -0
- package/src/widgets/actions/brush-toggle/brush-overlay.test.tsx +465 -0
- package/src/widgets/actions/brush-toggle/brush-overlay.tsx +24 -2
- package/src/widgets/actions/brush-toggle/brush-toggle.test.tsx +208 -0
- package/src/widgets/actions/change-column/change-column-dnd.test.tsx +193 -0
- package/src/widgets/actions/change-column/sortable-column-item.test.tsx +124 -0
- package/src/widgets/actions/zoom-toggle/zoom-toggle.test.tsx +322 -0
- package/src/widgets/category/components/category-rows.test.tsx +213 -0
- package/src/widgets/echart/utils.test.ts +277 -0
- package/src/widgets/formula/config.test.ts +37 -0
- package/src/widgets/histogram/config.ts +1 -3
- package/src/widgets/range/components/range-item.test.tsx +243 -0
- package/src/widgets/stores/widget-store-branches.test.ts +275 -0
- package/src/widgets/table/config.test.ts +65 -0
- package/src/widgets/utils/chart-config/option-builders.test.ts +188 -0
- package/src/widgets-v2/PERFORMANCE.md +189 -0
- package/src/widgets-v2/actions/brush-toggle/brush-toggle.test.tsx +180 -0
- package/src/widgets-v2/actions/brush-toggle/brush-toggle.tsx +154 -0
- package/src/widgets-v2/actions/brush-toggle/index.ts +3 -0
- package/src/widgets-v2/actions/brush-toggle/labels.ts +9 -0
- package/src/widgets-v2/actions/brush-toggle/style.ts +11 -0
- package/src/widgets-v2/actions/brush-toggle/transforms.test.ts +47 -0
- package/src/widgets-v2/actions/brush-toggle/transforms.ts +31 -0
- package/src/widgets-v2/actions/change-column/change-column-icon.tsx +14 -0
- package/src/widgets-v2/actions/change-column/change-column.test.tsx +59 -0
- package/src/widgets-v2/actions/change-column/change-column.tsx +180 -0
- package/src/widgets-v2/actions/change-column/index.ts +7 -0
- package/src/widgets-v2/actions/change-column/labels.ts +9 -0
- package/src/widgets-v2/actions/change-column/sortable-column-item.tsx +56 -0
- package/src/widgets-v2/actions/change-column/style.ts +32 -0
- package/src/widgets-v2/actions/change-column/types.ts +11 -0
- package/src/widgets-v2/actions/download/download.test.tsx +327 -0
- package/src/widgets-v2/actions/download/download.tsx +144 -0
- package/src/widgets-v2/actions/download/exports.test.tsx +198 -0
- package/src/widgets-v2/actions/download/exports.ts +115 -0
- package/src/widgets-v2/actions/download/icons.tsx +26 -0
- package/src/widgets-v2/actions/download/index.ts +13 -0
- package/src/widgets-v2/actions/download/labels.ts +16 -0
- package/src/widgets-v2/actions/download/png-item.test.tsx +72 -0
- package/src/widgets-v2/actions/download/png-item.tsx +52 -0
- package/src/widgets-v2/actions/download/style.ts +3 -0
- package/src/widgets-v2/actions/download/types.ts +32 -0
- package/src/widgets-v2/actions/fullscreen/fullscreen.test.tsx +150 -0
- package/src/widgets-v2/actions/fullscreen/fullscreen.tsx +230 -0
- package/src/widgets-v2/actions/fullscreen/index.ts +7 -0
- package/src/widgets-v2/actions/fullscreen/labels.ts +9 -0
- package/src/widgets-v2/actions/fullscreen/style.ts +59 -0
- package/src/widgets-v2/actions/fullscreen/types.ts +15 -0
- package/src/widgets-v2/actions/index.ts +82 -0
- package/src/widgets-v2/actions/lock-selection/index.ts +10 -0
- package/src/widgets-v2/actions/lock-selection/labels.ts +11 -0
- package/src/widgets-v2/actions/lock-selection/lock-selection.test.tsx +187 -0
- package/src/widgets-v2/actions/lock-selection/lock-selection.tsx +130 -0
- package/src/widgets-v2/actions/lock-selection/style.ts +11 -0
- package/src/widgets-v2/actions/lock-selection/transforms.ts +27 -0
- package/src/widgets-v2/actions/relative-data/index.ts +3 -0
- package/src/widgets-v2/actions/relative-data/labels.ts +9 -0
- package/src/widgets-v2/actions/relative-data/relative-data.test.tsx +71 -0
- package/src/widgets-v2/actions/relative-data/relative-data.tsx +107 -0
- package/src/widgets-v2/actions/relative-data/style.ts +11 -0
- package/src/widgets-v2/actions/relative-data/transforms.test.ts +151 -0
- package/src/widgets-v2/actions/relative-data/transforms.ts +70 -0
- package/src/widgets-v2/actions/searcher/filter.ts +28 -0
- package/src/widgets-v2/actions/searcher/index.ts +8 -0
- package/src/widgets-v2/actions/searcher/labels.ts +13 -0
- package/src/widgets-v2/actions/searcher/searcher-toggle.tsx +91 -0
- package/src/widgets-v2/actions/searcher/searcher.test.tsx +92 -0
- package/src/widgets-v2/actions/searcher/searcher.tsx +112 -0
- package/src/widgets-v2/actions/searcher/style.ts +15 -0
- package/src/widgets-v2/actions/stack-toggle/index.ts +3 -0
- package/src/widgets-v2/actions/stack-toggle/labels.ts +9 -0
- package/src/widgets-v2/actions/stack-toggle/stack-toggle.test.tsx +61 -0
- package/src/widgets-v2/actions/stack-toggle/stack-toggle.tsx +54 -0
- package/src/widgets-v2/actions/stack-toggle/style.ts +11 -0
- package/src/widgets-v2/actions/stack-toggle/transforms.test.ts +43 -0
- package/src/widgets-v2/actions/stack-toggle/transforms.ts +25 -0
- package/src/widgets-v2/actions/zoom-toggle/index.ts +9 -0
- package/src/widgets-v2/actions/zoom-toggle/labels.ts +9 -0
- package/src/widgets-v2/actions/zoom-toggle/style.ts +11 -0
- package/src/widgets-v2/actions/zoom-toggle/transforms.test.ts +148 -0
- package/src/widgets-v2/actions/zoom-toggle/transforms.ts +171 -0
- package/src/widgets-v2/actions/zoom-toggle/zoom-toggle.test.tsx +107 -0
- package/src/widgets-v2/actions/zoom-toggle/zoom-toggle.tsx +106 -0
- package/src/widgets-v2/bar/download.test.tsx +91 -0
- package/src/widgets-v2/bar/download.tsx +66 -0
- package/src/widgets-v2/bar/index.ts +10 -0
- package/src/widgets-v2/bar/options.test.ts +317 -0
- package/src/widgets-v2/bar/options.ts +326 -0
- package/src/widgets-v2/bar/skeleton.test.tsx +19 -0
- package/src/widgets-v2/bar/skeleton.tsx +69 -0
- package/src/widgets-v2/bar/types.ts +46 -0
- package/src/widgets-v2/category/category-ui.test.tsx +746 -0
- package/src/widgets-v2/category/category-ui.tsx +389 -0
- package/src/widgets-v2/category/category.relative-data.test.tsx +107 -0
- package/src/widgets-v2/category/category.stack-toggle.test.tsx +85 -0
- package/src/widgets-v2/category/category.test.tsx +305 -0
- package/src/widgets-v2/category/category.tsx +121 -0
- package/src/widgets-v2/category/components/category-bar-stacked.test.tsx +121 -0
- package/src/widgets-v2/category/components/category-bar-stacked.tsx +73 -0
- package/src/widgets-v2/category/components/category-bar.test.tsx +64 -0
- package/src/widgets-v2/category/components/category-bar.tsx +49 -0
- package/src/widgets-v2/category/components/category-legend.test.tsx +51 -0
- package/src/widgets-v2/category/components/category-legend.tsx +39 -0
- package/src/widgets-v2/category/components/category-row-multi.tsx +86 -0
- package/src/widgets-v2/category/components/category-row-other.test.tsx +28 -0
- package/src/widgets-v2/category/components/category-row-other.tsx +33 -0
- package/src/widgets-v2/category/components/category-row-single.tsx +76 -0
- package/src/widgets-v2/category/components/category-row-stacked.test.tsx +244 -0
- package/src/widgets-v2/category/components/category-row-stacked.tsx +99 -0
- package/src/widgets-v2/category/download.test.ts +71 -0
- package/src/widgets-v2/category/download.ts +54 -0
- package/src/widgets-v2/category/index.ts +32 -0
- package/src/widgets-v2/category/skeleton.test.tsx +26 -0
- package/src/widgets-v2/category/skeleton.tsx +74 -0
- package/src/widgets-v2/category/style.ts +290 -0
- package/src/widgets-v2/category/types.ts +54 -0
- package/src/widgets-v2/echart/echart-ui.test.tsx +232 -0
- package/src/widgets-v2/echart/echart-ui.tsx +184 -0
- package/src/widgets-v2/echart/echart.test.tsx +229 -0
- package/src/widgets-v2/echart/echart.tsx +199 -0
- package/src/widgets-v2/echart/index.ts +22 -0
- package/src/widgets-v2/echart/shared-resize-observer.test.ts +91 -0
- package/src/widgets-v2/echart/shared-resize-observer.ts +56 -0
- package/src/widgets-v2/echart/style.ts +8 -0
- package/src/widgets-v2/echart/use-chart-selection.test.tsx +118 -0
- package/src/widgets-v2/echart/use-chart-selection.ts +115 -0
- package/src/widgets-v2/formula/delta.tsx +61 -0
- package/src/widgets-v2/formula/download.test.tsx +65 -0
- package/src/widgets-v2/formula/download.tsx +69 -0
- package/src/widgets-v2/formula/formula-ui.test.tsx +91 -0
- package/src/widgets-v2/formula/formula-ui.tsx +66 -0
- package/src/widgets-v2/formula/formula.test.tsx +50 -0
- package/src/widgets-v2/formula/formula.tsx +34 -0
- package/src/widgets-v2/formula/index.ts +17 -0
- package/src/widgets-v2/formula/note.tsx +25 -0
- package/src/widgets-v2/formula/prefix.tsx +25 -0
- package/src/widgets-v2/formula/series.tsx +67 -0
- package/src/widgets-v2/formula/skeleton.test.tsx +21 -0
- package/src/widgets-v2/formula/skeleton.tsx +27 -0
- package/src/widgets-v2/formula/style.ts +31 -0
- package/src/widgets-v2/formula/subcomponents.test.tsx +107 -0
- package/src/widgets-v2/formula/suffix.tsx +25 -0
- package/src/widgets-v2/formula/types.ts +44 -0
- package/src/widgets-v2/formula/value.tsx +31 -0
- package/src/widgets-v2/histogram/download.test.ts +94 -0
- package/src/widgets-v2/histogram/download.ts +60 -0
- package/src/widgets-v2/histogram/index.ts +10 -0
- package/src/widgets-v2/histogram/options.test.ts +304 -0
- package/src/widgets-v2/histogram/options.ts +337 -0
- package/src/widgets-v2/histogram/skeleton.test.tsx +16 -0
- package/src/widgets-v2/histogram/skeleton.tsx +70 -0
- package/src/widgets-v2/histogram/transforms.test.ts +46 -0
- package/src/widgets-v2/histogram/transforms.ts +30 -0
- package/src/widgets-v2/histogram/types.ts +51 -0
- package/src/widgets-v2/index.ts +201 -0
- package/src/widgets-v2/markdown/download.test.ts +66 -0
- package/src/widgets-v2/markdown/download.ts +53 -0
- package/src/widgets-v2/markdown/index.ts +6 -0
- package/src/widgets-v2/markdown/markdown-content.test.tsx +155 -0
- package/src/widgets-v2/markdown/markdown-content.tsx +72 -0
- package/src/widgets-v2/markdown/markdown-ui.test.tsx +75 -0
- package/src/widgets-v2/markdown/markdown-ui.tsx +55 -0
- package/src/widgets-v2/markdown/markdown.test.tsx +39 -0
- package/src/widgets-v2/markdown/markdown.tsx +17 -0
- package/src/widgets-v2/markdown/skeleton.test.tsx +15 -0
- package/src/widgets-v2/markdown/skeleton.tsx +32 -0
- package/src/widgets-v2/markdown/style.ts +53 -0
- package/src/widgets-v2/markdown/types.ts +4 -0
- package/src/widgets-v2/note/labels.ts +9 -0
- package/src/widgets-v2/note/style.ts +26 -0
- package/src/widgets-v2/note/widget-note.test.tsx +158 -0
- package/src/widgets-v2/note/widget-note.tsx +172 -0
- package/src/widgets-v2/pie/download.test.ts +78 -0
- package/src/widgets-v2/pie/download.ts +55 -0
- package/src/widgets-v2/pie/index.ts +10 -0
- package/src/widgets-v2/pie/options.test.ts +585 -0
- package/src/widgets-v2/pie/options.ts +509 -0
- package/src/widgets-v2/pie/skeleton.test.tsx +17 -0
- package/src/widgets-v2/pie/skeleton.tsx +32 -0
- package/src/widgets-v2/pie/types.ts +55 -0
- package/src/widgets-v2/provider/widget-provider.test.tsx +119 -0
- package/src/widgets-v2/provider/widget-provider.tsx +111 -0
- package/src/widgets-v2/range/index.ts +4 -0
- package/src/widgets-v2/range/range-ui.test.tsx +130 -0
- package/src/widgets-v2/range/range-ui.tsx +211 -0
- package/src/widgets-v2/range/range.test.tsx +68 -0
- package/src/widgets-v2/range/range.tsx +46 -0
- package/src/widgets-v2/range/skeleton.test.tsx +17 -0
- package/src/widgets-v2/range/skeleton.tsx +47 -0
- package/src/widgets-v2/range/style.ts +41 -0
- package/src/widgets-v2/range/types.ts +37 -0
- package/src/widgets-v2/scatterplot/download.test.ts +71 -0
- package/src/widgets-v2/scatterplot/download.ts +54 -0
- package/src/widgets-v2/scatterplot/index.ts +11 -0
- package/src/widgets-v2/scatterplot/options.test.ts +399 -0
- package/src/widgets-v2/scatterplot/options.ts +421 -0
- package/src/widgets-v2/scatterplot/skeleton.test.tsx +17 -0
- package/src/widgets-v2/scatterplot/skeleton.tsx +84 -0
- package/src/widgets-v2/scatterplot/transforms.test.ts +97 -0
- package/src/widgets-v2/scatterplot/transforms.ts +38 -0
- package/src/widgets-v2/scatterplot/types.ts +55 -0
- package/src/widgets-v2/selection-summary/labels.ts +11 -0
- package/src/widgets-v2/selection-summary/selection-summary.test.tsx +53 -0
- package/src/widgets-v2/selection-summary/selection-summary.tsx +62 -0
- package/src/widgets-v2/selection-summary/style.ts +23 -0
- package/src/widgets-v2/spread/download.test.ts +64 -0
- package/src/widgets-v2/spread/download.ts +59 -0
- package/src/widgets-v2/spread/index.ts +6 -0
- package/src/widgets-v2/spread/separator.tsx +11 -0
- package/src/widgets-v2/spread/skeleton.test.tsx +17 -0
- package/src/widgets-v2/spread/skeleton.tsx +38 -0
- package/src/widgets-v2/spread/spread-ui.test.tsx +108 -0
- package/src/widgets-v2/spread/spread-ui.tsx +52 -0
- package/src/widgets-v2/spread/spread.test.tsx +50 -0
- package/src/widgets-v2/spread/spread.tsx +31 -0
- package/src/widgets-v2/spread/types.ts +27 -0
- package/src/widgets-v2/state/labels.test.ts +33 -0
- package/src/widgets-v2/state/labels.ts +20 -0
- package/src/widgets-v2/state/style.ts +25 -0
- package/src/widgets-v2/state/widget-state.test.tsx +294 -0
- package/src/widgets-v2/state/widget-state.tsx +184 -0
- package/src/widgets-v2/stores/index.ts +49 -0
- package/src/widgets-v2/stores/pipeline-middleware.test.ts +187 -0
- package/src/widgets-v2/stores/pipeline-middleware.ts +91 -0
- package/src/widgets-v2/stores/transforms.test.ts +162 -0
- package/src/widgets-v2/stores/transforms.ts +70 -0
- package/src/widgets-v2/stores/types.ts +64 -0
- package/src/widgets-v2/stores/use-echart-instance.test.tsx +91 -0
- package/src/widgets-v2/stores/use-echart-instance.ts +29 -0
- package/src/widgets-v2/stores/use-transform-enabled.test.tsx +127 -0
- package/src/widgets-v2/stores/use-transform-enabled.ts +25 -0
- package/src/widgets-v2/stores/use-transform.test.tsx +262 -0
- package/src/widgets-v2/stores/use-transform.ts +158 -0
- package/src/widgets-v2/stores/widget-context.test.tsx +58 -0
- package/src/widgets-v2/stores/widget-context.ts +15 -0
- package/src/widgets-v2/stores/widget-store-registry.test.ts +292 -0
- package/src/widgets-v2/stores/widget-store-registry.ts +248 -0
- package/src/widgets-v2/subheader/style.ts +12 -0
- package/src/widgets-v2/subheader/subheader.test.tsx +30 -0
- package/src/widgets-v2/subheader/subheader.tsx +16 -0
- package/src/widgets-v2/table/download.test.ts +75 -0
- package/src/widgets-v2/table/download.ts +47 -0
- package/src/widgets-v2/table/helpers.test.ts +214 -0
- package/src/widgets-v2/table/helpers.ts +136 -0
- package/src/widgets-v2/table/index.ts +23 -0
- package/src/widgets-v2/table/labels.tsx +41 -0
- package/src/widgets-v2/table/skeleton.test.tsx +26 -0
- package/src/widgets-v2/table/skeleton.tsx +65 -0
- package/src/widgets-v2/table/style.ts +46 -0
- package/src/widgets-v2/table/table-ui.test.tsx +200 -0
- package/src/widgets-v2/table/table-ui.tsx +331 -0
- package/src/widgets-v2/table/table.test.tsx +119 -0
- package/src/widgets-v2/table/table.tsx +174 -0
- package/src/widgets-v2/table/types.ts +44 -0
- package/src/widgets-v2/test-utils.ts +107 -0
- package/src/widgets-v2/timeseries/download.test.ts +95 -0
- package/src/widgets-v2/timeseries/download.ts +86 -0
- package/src/widgets-v2/timeseries/index.ts +10 -0
- package/src/widgets-v2/timeseries/options.test.ts +379 -0
- package/src/widgets-v2/timeseries/options.ts +341 -0
- package/src/widgets-v2/timeseries/skeleton.test.tsx +13 -0
- package/src/widgets-v2/timeseries/skeleton.tsx +76 -0
- package/src/widgets-v2/timeseries/types.ts +61 -0
- package/src/widgets-v2/toolbox/labels.ts +9 -0
- package/src/widgets-v2/toolbox/style.ts +33 -0
- package/src/widgets-v2/toolbox/toolbox.test.tsx +200 -0
- package/src/widgets-v2/toolbox/toolbox.tsx +309 -0
- package/src/widgets-v2/utils/data-zoom-layout.ts +26 -0
- package/src/widgets-v2/utils/index.ts +2 -0
- package/src/widgets-v2/utils/merge-options.test.ts +52 -0
- package/src/widgets-v2/utils/merge-options.ts +50 -0
- package/src/widgets-v2/wrapper/index.ts +14 -0
- package/src/widgets-v2/wrapper/labels.ts +11 -0
- package/src/widgets-v2/wrapper/style.ts +134 -0
- package/src/widgets-v2/wrapper/widget-actions.test.tsx +52 -0
- package/src/widgets-v2/wrapper/widget-actions.tsx +43 -0
- package/src/widgets-v2/wrapper/widget-content.test.tsx +27 -0
- package/src/widgets-v2/wrapper/widget-content.tsx +29 -0
- package/src/widgets-v2/wrapper/widget-wrapper.test.tsx +159 -0
- package/src/widgets-v2/wrapper/widget-wrapper.tsx +178 -0
- package/dist/styles-BYTyKQFP.js.map +0 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type ComponentType } from 'react'
|
|
2
|
+
import { IconButton, type SvgIconProps } from '@mui/material'
|
|
3
|
+
import StackedBarChartIcon from '@mui/icons-material/StackedBarChart'
|
|
4
|
+
import { Tooltip } from '../../../components'
|
|
5
|
+
import { useSingleTransform, useWidgetId } from '../../stores'
|
|
6
|
+
import { addStack } from './transforms'
|
|
7
|
+
import { DEFAULT_STACK_TOGGLE_LABELS, type StackToggleLabels } from './labels'
|
|
8
|
+
import { styles } from './style'
|
|
9
|
+
|
|
10
|
+
const STACK_DESCRIPTOR = {
|
|
11
|
+
id: 'stack-toggle',
|
|
12
|
+
type: 'config' as const,
|
|
13
|
+
order: 30,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface StackToggleProps {
|
|
17
|
+
initialEnabled?: boolean
|
|
18
|
+
labels?: Partial<StackToggleLabels>
|
|
19
|
+
icon?: ComponentType<SvgIconProps>
|
|
20
|
+
iconProps?: SvgIconProps
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function StackToggle({
|
|
24
|
+
initialEnabled = false,
|
|
25
|
+
labels,
|
|
26
|
+
icon: Icon = StackedBarChartIcon,
|
|
27
|
+
iconProps,
|
|
28
|
+
}: StackToggleProps) {
|
|
29
|
+
const id = useWidgetId()
|
|
30
|
+
const _labels = { ...DEFAULT_STACK_TOGGLE_LABELS, ...labels }
|
|
31
|
+
const { enabled, toggle } = useSingleTransform(
|
|
32
|
+
id,
|
|
33
|
+
STACK_DESCRIPTOR,
|
|
34
|
+
addStack,
|
|
35
|
+
{
|
|
36
|
+
initialEnabled,
|
|
37
|
+
},
|
|
38
|
+
)
|
|
39
|
+
const tooltip = enabled ? _labels.on : _labels.off
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Tooltip title={tooltip}>
|
|
43
|
+
<IconButton
|
|
44
|
+
size='small'
|
|
45
|
+
aria-label={tooltip}
|
|
46
|
+
aria-pressed={enabled}
|
|
47
|
+
onClick={toggle}
|
|
48
|
+
sx={{ ...styles.toggle, ...(enabled && styles.toggleActive) }}
|
|
49
|
+
>
|
|
50
|
+
<Icon fontSize='small' {...iconProps} />
|
|
51
|
+
</IconButton>
|
|
52
|
+
</Tooltip>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SxProps, Theme } from '@mui/material'
|
|
2
|
+
|
|
3
|
+
export const styles = {
|
|
4
|
+
toggle: {
|
|
5
|
+
p: 0.5,
|
|
6
|
+
'& .MuiSvgIcon-root': { fontSize: 20 },
|
|
7
|
+
},
|
|
8
|
+
toggleActive: {
|
|
9
|
+
background: (theme: Theme) => theme.palette.primary.relatedLight,
|
|
10
|
+
},
|
|
11
|
+
} satisfies Record<string, SxProps<Theme>>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { addStack } from './transforms'
|
|
3
|
+
|
|
4
|
+
describe('addStack', () => {
|
|
5
|
+
it('passes through non-objects unchanged', () => {
|
|
6
|
+
expect(addStack(undefined)).toBe(undefined)
|
|
7
|
+
expect(addStack(null)).toBe(null)
|
|
8
|
+
expect(addStack(42)).toBe(42)
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('marks every existing series with stack:"total"', () => {
|
|
12
|
+
const out = addStack({
|
|
13
|
+
title: { text: 'x' },
|
|
14
|
+
series: [{ type: 'bar' }, { type: 'bar' }],
|
|
15
|
+
}) as { series: { type: string; stack: string }[]; title: { text: string } }
|
|
16
|
+
expect(out.series).toHaveLength(2)
|
|
17
|
+
expect(out.series[0]).toMatchObject({ type: 'bar', stack: 'total' })
|
|
18
|
+
expect(out.series[1]).toMatchObject({ type: 'bar', stack: 'total' })
|
|
19
|
+
expect(out.title).toEqual({ text: 'x' })
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('emits a broadcast template when there are no existing series (data-fusion widgets)', () => {
|
|
23
|
+
const out = addStack({}) as { series: { stack: string }[] }
|
|
24
|
+
expect(out.series).toEqual([{ stack: 'total' }])
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('emits a broadcast template when series is missing entirely', () => {
|
|
28
|
+
const out = addStack({ tooltip: {} }) as {
|
|
29
|
+
series: { stack: string }[]
|
|
30
|
+
tooltip: object
|
|
31
|
+
}
|
|
32
|
+
expect(out.series).toEqual([{ stack: 'total' }])
|
|
33
|
+
expect(out.tooltip).toBeDefined()
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('preserves non-object series entries (defensive)', () => {
|
|
37
|
+
const out = addStack({ series: ['weird', { type: 'bar' }] }) as {
|
|
38
|
+
series: unknown[]
|
|
39
|
+
}
|
|
40
|
+
expect(out.series[0]).toBe('weird')
|
|
41
|
+
expect(out.series[1]).toMatchObject({ type: 'bar', stack: 'total' })
|
|
42
|
+
})
|
|
43
|
+
})
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stack-mode config transform: marks every series with `stack: 'total'` so
|
|
3
|
+
* ECharts stacks them vertically (bar) or by value (line). Module-level
|
|
4
|
+
* constant so identity is stable across renders — no `useCallback` needed.
|
|
5
|
+
*
|
|
6
|
+
* Widgets that bake series into options at build time get marked in place.
|
|
7
|
+
* Widgets that build series at data-fusion time (`bar`, `histogram`,
|
|
8
|
+
* `timeseries`) have no `series` array yet at config-transform time, so we
|
|
9
|
+
* also emit a single-entry **broadcast template** (`[{ stack: 'total' }]`).
|
|
10
|
+
* Their option factories merge that template into every series they emit
|
|
11
|
+
* at fusion time, so the `stack` mark survives end-to-end.
|
|
12
|
+
*/
|
|
13
|
+
export const addStack = (option: unknown): unknown => {
|
|
14
|
+
if (option == null || typeof option !== 'object') return option
|
|
15
|
+
const cfg = option as Record<string, unknown>
|
|
16
|
+
const existing = Array.isArray(cfg.series) ? cfg.series : []
|
|
17
|
+
const series =
|
|
18
|
+
existing.length === 0
|
|
19
|
+
? [{ stack: 'total' }]
|
|
20
|
+
: existing.map((s: unknown): unknown => {
|
|
21
|
+
if (s == null || typeof s !== 'object') return s
|
|
22
|
+
return { ...s, stack: 'total' }
|
|
23
|
+
})
|
|
24
|
+
return { ...cfg, series }
|
|
25
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { ZoomToggle, type ZoomToggleProps } from './zoom-toggle'
|
|
2
|
+
export {
|
|
3
|
+
addZoom,
|
|
4
|
+
createAddZoom,
|
|
5
|
+
ZOOM_LAYOUT,
|
|
6
|
+
type ZoomAxis,
|
|
7
|
+
type CreateAddZoomOptions,
|
|
8
|
+
} from './transforms'
|
|
9
|
+
export { DEFAULT_ZOOM_TOGGLE_LABELS, type ZoomToggleLabels } from './labels'
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SxProps, Theme } from '@mui/material'
|
|
2
|
+
|
|
3
|
+
export const styles = {
|
|
4
|
+
toggle: {
|
|
5
|
+
p: 0.5,
|
|
6
|
+
'& .MuiSvgIcon-root': { fontSize: 20 },
|
|
7
|
+
},
|
|
8
|
+
toggleActive: {
|
|
9
|
+
background: (theme: Theme) => theme.palette.primary.relatedLight,
|
|
10
|
+
},
|
|
11
|
+
} satisfies Record<string, SxProps<Theme>>
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { createTheme, type Theme } from '@mui/material'
|
|
3
|
+
import { addZoom, createAddZoom, ZOOM_LAYOUT } from './transforms'
|
|
4
|
+
|
|
5
|
+
const theme = createTheme() as unknown as Theme
|
|
6
|
+
|
|
7
|
+
describe('addZoom', () => {
|
|
8
|
+
it('appends an inside + slider dataZoom pair to the option', () => {
|
|
9
|
+
const out = addZoom({ xAxis: { type: 'value' } }) as {
|
|
10
|
+
xAxis: { type: string }
|
|
11
|
+
dataZoom: { type: string }[]
|
|
12
|
+
}
|
|
13
|
+
expect(out.xAxis).toEqual({ type: 'value' })
|
|
14
|
+
expect(out.dataZoom).toHaveLength(2)
|
|
15
|
+
expect(out.dataZoom[0]?.type).toBe('inside')
|
|
16
|
+
expect(out.dataZoom[1]?.type).toBe('slider')
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('replaces an existing dataZoom array (no append/stack across runs)', () => {
|
|
20
|
+
const seeded = { dataZoom: [{ type: 'inside' }, { type: 'inside' }] }
|
|
21
|
+
const out = addZoom(seeded) as { dataZoom: { type: string }[] }
|
|
22
|
+
expect(out.dataZoom).toHaveLength(2)
|
|
23
|
+
expect(out.dataZoom.map((z) => z.type)).toEqual(['inside', 'slider'])
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('omits start/end so ECharts preserves the user-dragged range across re-runs', () => {
|
|
27
|
+
const out = addZoom({}) as {
|
|
28
|
+
dataZoom: { start?: number; end?: number }[]
|
|
29
|
+
}
|
|
30
|
+
for (const dz of out.dataZoom) {
|
|
31
|
+
expect(dz.start).toBeUndefined()
|
|
32
|
+
expect(dz.end).toBeUndefined()
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('returns the input unchanged when not an object', () => {
|
|
37
|
+
expect(addZoom(null)).toBe(null)
|
|
38
|
+
expect(addZoom(undefined)).toBe(undefined)
|
|
39
|
+
expect(addZoom('not an object')).toBe('not an object')
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
describe('createAddZoom (theme-bound, v1-styled slider)', () => {
|
|
44
|
+
it('produces an inside zoom + a styled slider with the v1 chrome', () => {
|
|
45
|
+
const transform = createAddZoom(theme)
|
|
46
|
+
const out = transform({}) as {
|
|
47
|
+
dataZoom: {
|
|
48
|
+
type: string
|
|
49
|
+
height?: number
|
|
50
|
+
handleIcon?: string
|
|
51
|
+
fillerColor?: string
|
|
52
|
+
borderColor?: string
|
|
53
|
+
dataBackground?: { areaStyle?: { color?: string } }
|
|
54
|
+
textStyle?: { fontSize?: number }
|
|
55
|
+
}[]
|
|
56
|
+
}
|
|
57
|
+
expect(out.dataZoom).toHaveLength(2)
|
|
58
|
+
expect(out.dataZoom[0]?.type).toBe('inside')
|
|
59
|
+
const slider = out.dataZoom[1]!
|
|
60
|
+
expect(slider.type).toBe('slider')
|
|
61
|
+
// v1 hallmarks the new slider must carry.
|
|
62
|
+
expect(slider.height).toBe(ZOOM_LAYOUT.sliderHeight)
|
|
63
|
+
expect(slider.handleIcon).toMatch(/^image:\/\/data:image\/svg\+xml/)
|
|
64
|
+
expect(slider.fillerColor).toBeTruthy()
|
|
65
|
+
expect(slider.borderColor).toBeTruthy()
|
|
66
|
+
expect(slider.textStyle?.fontSize).toBeGreaterThan(0)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('omits start/end so the dragged range survives re-runs', () => {
|
|
70
|
+
const transform = createAddZoom(theme)
|
|
71
|
+
const out = transform({}) as {
|
|
72
|
+
dataZoom: { start?: number; end?: number }[]
|
|
73
|
+
}
|
|
74
|
+
for (const dz of out.dataZoom) {
|
|
75
|
+
expect(dz.start).toBeUndefined()
|
|
76
|
+
expect(dz.end).toBeUndefined()
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('returns non-object input unchanged', () => {
|
|
81
|
+
const transform = createAddZoom(theme)
|
|
82
|
+
expect(transform(null)).toBe(null)
|
|
83
|
+
expect(transform(undefined)).toBe(undefined)
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it('defaults to x-axis only (matches bar/histogram/timeseries semantics)', () => {
|
|
87
|
+
const transform = createAddZoom(theme)
|
|
88
|
+
const out = transform({}) as {
|
|
89
|
+
dataZoom: { type: string; xAxisIndex?: unknown; yAxisIndex?: unknown }[]
|
|
90
|
+
}
|
|
91
|
+
expect(out.dataZoom).toHaveLength(2)
|
|
92
|
+
for (const dz of out.dataZoom) {
|
|
93
|
+
expect(dz.xAxisIndex).toEqual([0])
|
|
94
|
+
expect(dz.yAxisIndex).toBeUndefined()
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it('emits inside + slider per axis when axes=["x","y"] (2D zoom for scatter)', () => {
|
|
99
|
+
const transform = createAddZoom(theme, { axes: ['x', 'y'] })
|
|
100
|
+
const out = transform({}) as {
|
|
101
|
+
dataZoom: {
|
|
102
|
+
type: string
|
|
103
|
+
xAxisIndex?: unknown
|
|
104
|
+
yAxisIndex?: unknown
|
|
105
|
+
width?: number
|
|
106
|
+
right?: number
|
|
107
|
+
height?: number
|
|
108
|
+
bottom?: number
|
|
109
|
+
}[]
|
|
110
|
+
}
|
|
111
|
+
expect(out.dataZoom).toHaveLength(4)
|
|
112
|
+
const insides = out.dataZoom.filter((dz) => dz.type === 'inside')
|
|
113
|
+
const sliders = out.dataZoom.filter((dz) => dz.type === 'slider')
|
|
114
|
+
expect(insides).toHaveLength(2)
|
|
115
|
+
expect(sliders).toHaveLength(2)
|
|
116
|
+
// One inside per axis.
|
|
117
|
+
expect(insides.some((dz) => dz.xAxisIndex !== undefined)).toBe(true)
|
|
118
|
+
expect(insides.some((dz) => dz.yAxisIndex !== undefined)).toBe(true)
|
|
119
|
+
// X-slider: horizontal at the bottom (has height + bottom).
|
|
120
|
+
const xSlider = sliders.find((dz) => dz.xAxisIndex !== undefined)
|
|
121
|
+
expect(xSlider?.height).toBe(ZOOM_LAYOUT.sliderHeight)
|
|
122
|
+
expect(xSlider?.bottom).toBeDefined()
|
|
123
|
+
// Y-slider: vertical on the right (has width + right, no handleIcon).
|
|
124
|
+
const ySlider = sliders.find((dz) => dz.yAxisIndex !== undefined)
|
|
125
|
+
expect(ySlider?.width).toBe(ZOOM_LAYOUT.sliderHeight)
|
|
126
|
+
expect(ySlider?.right).toBeDefined()
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
it('emits y-only when axes=["y"]', () => {
|
|
130
|
+
const transform = createAddZoom(theme, { axes: ['y'] })
|
|
131
|
+
const out = transform({}) as {
|
|
132
|
+
dataZoom: { type: string; xAxisIndex?: unknown; yAxisIndex?: unknown }[]
|
|
133
|
+
}
|
|
134
|
+
expect(out.dataZoom).toHaveLength(2)
|
|
135
|
+
for (const dz of out.dataZoom) {
|
|
136
|
+
expect(dz.yAxisIndex).toEqual([0])
|
|
137
|
+
expect(dz.xAxisIndex).toBeUndefined()
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
describe('ZOOM_LAYOUT', () => {
|
|
143
|
+
it('exposes the layout constants used by data-fusion mergers', () => {
|
|
144
|
+
expect(ZOOM_LAYOUT.sliderHeight).toBe(32)
|
|
145
|
+
expect(ZOOM_LAYOUT.sliderGap).toBe(8)
|
|
146
|
+
expect(ZOOM_LAYOUT.sliderBottomWithLegend).toBe(28)
|
|
147
|
+
})
|
|
148
|
+
})
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import type { Theme } from '@mui/material'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* v1's slider handle — 9×36 SVG with a white pill body, secondary-colored
|
|
5
|
+
* stroke, and three grip lines. Inlined as a data URL so the chart can
|
|
6
|
+
* render it without a network fetch.
|
|
7
|
+
*/
|
|
8
|
+
const SLIDER_HANDLE_ICON =
|
|
9
|
+
'image://data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iOSIgaGVpZ2h0PSIzNiIgdmlld0JveD0iMCAwIDkgMzYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHg9IjAuNSIgeT0iLTAuNSIgd2lkdGg9IjgiIGhlaWdodD0iMTgiIHJ4PSI0IiB0cmFuc2Zvcm09Im1hdHJpeCgxIDAgMCAtMSAwIDI3KSIgZmlsbD0id2hpdGUiIHN0cm9rZT0iIzM1OEJFNyIvPgo8cmVjdCB3aWR0aD0iMyIgaGVpZ2h0PSIyIiByeD0iMSIgdHJhbnNmb3JtPSJtYXRyaXgoMSAwIDAgLTEgMyAyMykiIGZpbGw9IiMzNThCRTciLz4KPHJlY3Qgd2lkdGg9IjMiIGhlaWdodD0iMiIgcng9IjEiIHRyYW5zZm9ybT0ibWF0cml4KDEgMCAwIC0xIDMgMTkpIiBmaWxsPSIjMzU4QkU3Ii8+CjxyZWN0IHdpZHRoPSIzIiBoZWlnaHQ9IjIiIHJ4PSIxIiB0cmFuc2Zvcm09Im1hdHJpeCgxIDAgMCAtMSAzIDE1KSIgZmlsbD0iIzM1OEJFNyIvPgo8L3N2Zz4='
|
|
10
|
+
|
|
11
|
+
const SLIDER_HEIGHT = 32
|
|
12
|
+
const SLIDER_BOTTOM = 0
|
|
13
|
+
|
|
14
|
+
/** Which chart axis (or axes) zoom applies to. */
|
|
15
|
+
export type ZoomAxis = 'x' | 'y'
|
|
16
|
+
|
|
17
|
+
export interface CreateAddZoomOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Axes to enable zoom on. Default `['x']` (matches bar / histogram /
|
|
20
|
+
* timeseries — horizontal pan/zoom on the category axis). Pass
|
|
21
|
+
* `['x', 'y']` for a scatterplot-style 2D zoom (mouse-wheel scales both
|
|
22
|
+
* axes; a horizontal slider sits at the bottom for x-range and a
|
|
23
|
+
* vertical slider sits on the right for y-range).
|
|
24
|
+
*/
|
|
25
|
+
axes?: readonly ZoomAxis[]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Theme-bound zoom config transform: adds one inside `dataZoom`
|
|
30
|
+
* (mouse-wheel + drag) per axis plus a styled slider per axis with the
|
|
31
|
+
* v1 chrome (blue-tinted filler, secondary-color data preview, white
|
|
32
|
+
* pill handles, CARTO typography). The x-slider is horizontal at the
|
|
33
|
+
* bottom; the y-slider is vertical on the right.
|
|
34
|
+
*
|
|
35
|
+
* Returned function has stable identity for a given theme + axes
|
|
36
|
+
* combination; pair with `useMemo` at the call site.
|
|
37
|
+
*
|
|
38
|
+
* **No `start` / `end`** are emitted: ECharts defaults to `0–100` on the
|
|
39
|
+
* first `setOption` and then keeps the runtime slider state across
|
|
40
|
+
* subsequent merges (no `replaceMerge` for `dataZoom`). Re-running the
|
|
41
|
+
* transform on data/formatter/RelativeData updates therefore preserves the
|
|
42
|
+
* user's dragged range instead of snapping it back.
|
|
43
|
+
*/
|
|
44
|
+
export function createAddZoom(
|
|
45
|
+
theme: Theme,
|
|
46
|
+
options: CreateAddZoomOptions = {},
|
|
47
|
+
): (option: unknown) => unknown {
|
|
48
|
+
const axes = options.axes ?? ['x']
|
|
49
|
+
const includeX = axes.includes('x')
|
|
50
|
+
const includeY = axes.includes('y')
|
|
51
|
+
const sliderStyles = getZoomSliderStyles(theme)
|
|
52
|
+
const baseSliderProps = {
|
|
53
|
+
throttle: 0,
|
|
54
|
+
showDetail: false,
|
|
55
|
+
brushSelect: false,
|
|
56
|
+
moveHandleSize: 8,
|
|
57
|
+
handleSize: '100%',
|
|
58
|
+
...sliderStyles,
|
|
59
|
+
}
|
|
60
|
+
return (option: unknown): unknown => {
|
|
61
|
+
if (option == null || typeof option !== 'object') return option
|
|
62
|
+
const cfg = option as Record<string, unknown>
|
|
63
|
+
const dataZoom: object[] = []
|
|
64
|
+
if (includeX) {
|
|
65
|
+
dataZoom.push({ type: 'inside', xAxisIndex: [0], throttle: 0 })
|
|
66
|
+
}
|
|
67
|
+
if (includeY) {
|
|
68
|
+
dataZoom.push({ type: 'inside', yAxisIndex: [0], throttle: 0 })
|
|
69
|
+
}
|
|
70
|
+
if (includeX) {
|
|
71
|
+
dataZoom.push({
|
|
72
|
+
type: 'slider',
|
|
73
|
+
xAxisIndex: [0],
|
|
74
|
+
height: SLIDER_HEIGHT,
|
|
75
|
+
bottom: SLIDER_BOTTOM,
|
|
76
|
+
handleIcon: SLIDER_HANDLE_ICON,
|
|
77
|
+
...baseSliderProps,
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
if (includeY) {
|
|
81
|
+
// Vertical slider — `width` is its thickness, `right` pins it to
|
|
82
|
+
// the right edge. We omit `handleIcon` so ECharts renders its
|
|
83
|
+
// default vertical handle (the inline SVG is shaped for a
|
|
84
|
+
// horizontal slider and looks wrong when rotated).
|
|
85
|
+
dataZoom.push({
|
|
86
|
+
type: 'slider',
|
|
87
|
+
yAxisIndex: [0],
|
|
88
|
+
width: SLIDER_HEIGHT,
|
|
89
|
+
right: SLIDER_BOTTOM,
|
|
90
|
+
...baseSliderProps,
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
return { ...cfg, dataZoom }
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Back-compat untyped transform — produces the bare `dataZoom` config from
|
|
99
|
+
* the original v2 implementation. Use {@link createAddZoom} when a theme is
|
|
100
|
+
* available so the slider matches the v1 styling.
|
|
101
|
+
*
|
|
102
|
+
* `start` / `end` are intentionally omitted so ECharts preserves the user's
|
|
103
|
+
* runtime range across subsequent `setOption` merges (see {@link createAddZoom}).
|
|
104
|
+
*/
|
|
105
|
+
export const addZoom = (option: unknown): unknown => {
|
|
106
|
+
if (option == null || typeof option !== 'object') return option
|
|
107
|
+
const cfg = option as Record<string, unknown>
|
|
108
|
+
return {
|
|
109
|
+
...cfg,
|
|
110
|
+
dataZoom: [
|
|
111
|
+
{ type: 'inside' },
|
|
112
|
+
{
|
|
113
|
+
type: 'slider',
|
|
114
|
+
height: SLIDER_HEIGHT,
|
|
115
|
+
bottom: SLIDER_BOTTOM,
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Style block matching v1's `getEChartZoomSliderStyles`. */
|
|
122
|
+
function getZoomSliderStyles(theme: Theme) {
|
|
123
|
+
const secondary = theme.palette.secondary?.main ?? '#358BE7'
|
|
124
|
+
return {
|
|
125
|
+
fillerColor: 'rgba(53, 139, 231, 0.25)',
|
|
126
|
+
borderColor: 'rgba(53, 139, 231, 0.3)',
|
|
127
|
+
borderWidth: 0.5,
|
|
128
|
+
backgroundColor: 'transparent',
|
|
129
|
+
borderRadius: 4,
|
|
130
|
+
dataBackground: {
|
|
131
|
+
lineStyle: { opacity: 0 },
|
|
132
|
+
areaStyle: { opacity: 1, color: secondary },
|
|
133
|
+
},
|
|
134
|
+
selectedDataBackground: {
|
|
135
|
+
lineStyle: { opacity: 0 },
|
|
136
|
+
areaStyle: { opacity: 1, color: secondary },
|
|
137
|
+
},
|
|
138
|
+
handleStyle: {
|
|
139
|
+
color: theme.palette.common?.white ?? '#fff',
|
|
140
|
+
borderColor: 'rgba(3, 111, 226, 0.08)',
|
|
141
|
+
borderWidth: 1,
|
|
142
|
+
shadowBlur: 3,
|
|
143
|
+
shadowColor: 'rgba(0, 0, 0, 0.1)',
|
|
144
|
+
shadowOffsetX: 0,
|
|
145
|
+
shadowOffsetY: 1,
|
|
146
|
+
},
|
|
147
|
+
textStyle: {
|
|
148
|
+
color: theme.palette.black?.[60] ?? theme.palette.text?.primary,
|
|
149
|
+
fontSize: parseInt(
|
|
150
|
+
(theme.typography.overlineDelicate?.fontSize as string | undefined) ??
|
|
151
|
+
'11',
|
|
152
|
+
),
|
|
153
|
+
fontFamily:
|
|
154
|
+
theme.typography.overlineDelicate?.fontFamily ??
|
|
155
|
+
theme.typography.caption?.fontFamily,
|
|
156
|
+
},
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Visual layout constants used by the data-fusion mergers (bar, histogram,
|
|
162
|
+
* timeseries) when laying out the slider against the legend / grid.
|
|
163
|
+
*/
|
|
164
|
+
export const ZOOM_LAYOUT = {
|
|
165
|
+
/** Slider height in px (matches `createAddZoom` output). */
|
|
166
|
+
sliderHeight: SLIDER_HEIGHT,
|
|
167
|
+
/** Vertical gap between chart grid and the slider. */
|
|
168
|
+
sliderGap: 8,
|
|
169
|
+
/** Slider `bottom` when a legend is shown — sits above the legend row. */
|
|
170
|
+
sliderBottomWithLegend: 28,
|
|
171
|
+
} as const
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
|
|
2
|
+
import { fireEvent, render, screen } from '@testing-library/react'
|
|
3
|
+
import type { ECharts } from 'echarts'
|
|
4
|
+
import { ZoomToggle } from './zoom-toggle'
|
|
5
|
+
import { Provider } from '../../provider/widget-provider'
|
|
6
|
+
import {
|
|
7
|
+
applyTransforms,
|
|
8
|
+
clearAllWidgetStores,
|
|
9
|
+
getWidgetStore,
|
|
10
|
+
setEchartInstance,
|
|
11
|
+
} from '../../stores'
|
|
12
|
+
|
|
13
|
+
beforeEach(() => clearAllWidgetStores())
|
|
14
|
+
afterEach(() => clearAllWidgetStores())
|
|
15
|
+
|
|
16
|
+
describe('<ZoomToggle>', () => {
|
|
17
|
+
it('starts disabled by default', () => {
|
|
18
|
+
render(
|
|
19
|
+
<Provider id='zt-1' data={[]}>
|
|
20
|
+
<ZoomToggle />
|
|
21
|
+
</Provider>,
|
|
22
|
+
)
|
|
23
|
+
const trigger = screen.getByLabelText('Enable zoom')
|
|
24
|
+
expect(trigger.getAttribute('aria-pressed')).toBe('false')
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('respects initialEnabled=true', () => {
|
|
28
|
+
render(
|
|
29
|
+
<Provider id='zt-2' data={[]}>
|
|
30
|
+
<ZoomToggle initialEnabled />
|
|
31
|
+
</Provider>,
|
|
32
|
+
)
|
|
33
|
+
expect(screen.getByLabelText('Disable zoom')).toBeTruthy()
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('clicking enables the transform — dataZoom appears in the post-pipeline option', () => {
|
|
37
|
+
render(
|
|
38
|
+
<Provider id='zt-3' data={[1]}>
|
|
39
|
+
<ZoomToggle />
|
|
40
|
+
</Provider>,
|
|
41
|
+
)
|
|
42
|
+
fireEvent.click(screen.getByLabelText('Enable zoom'))
|
|
43
|
+
// configTransforms now apply inside <Widget.Echart>; replay the
|
|
44
|
+
// pipeline locally over a blank structural option.
|
|
45
|
+
const configTransforms = getWidgetStore('zt-3').getState().configTransforms
|
|
46
|
+
const opts = applyTransforms({}, configTransforms) as {
|
|
47
|
+
dataZoom?: { type: string }[]
|
|
48
|
+
}
|
|
49
|
+
expect(opts.dataZoom).toBeTruthy()
|
|
50
|
+
expect(opts.dataZoom).toHaveLength(2)
|
|
51
|
+
expect(opts.dataZoom?.[0]?.type).toBe('inside')
|
|
52
|
+
expect(opts.dataZoom?.[1]?.type).toBe('slider')
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('clicking to disable issues a one-shot setOption({}, replaceMerge: ["dataZoom"]) on the live instance', () => {
|
|
56
|
+
const setOption = vi.fn()
|
|
57
|
+
const chart = { setOption } as unknown as ECharts
|
|
58
|
+
render(
|
|
59
|
+
<Provider id='zt-4' data={[1]}>
|
|
60
|
+
<ZoomToggle initialEnabled />
|
|
61
|
+
</Provider>,
|
|
62
|
+
)
|
|
63
|
+
setEchartInstance('zt-4', chart)
|
|
64
|
+
fireEvent.click(screen.getByLabelText('Disable zoom'))
|
|
65
|
+
expect(setOption).toHaveBeenCalledTimes(1)
|
|
66
|
+
expect(setOption).toHaveBeenCalledWith({}, { replaceMerge: ['dataZoom'] })
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('clicking to enable does NOT touch the live instance (no cleanup needed)', () => {
|
|
70
|
+
const setOption = vi.fn()
|
|
71
|
+
const chart = { setOption } as unknown as ECharts
|
|
72
|
+
render(
|
|
73
|
+
<Provider id='zt-5' data={[1]}>
|
|
74
|
+
<ZoomToggle />
|
|
75
|
+
</Provider>,
|
|
76
|
+
)
|
|
77
|
+
setEchartInstance('zt-5', chart)
|
|
78
|
+
fireEvent.click(screen.getByLabelText('Enable zoom'))
|
|
79
|
+
expect(setOption).not.toHaveBeenCalled()
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
it('rehydrates enabled state from transformStates on remount', () => {
|
|
83
|
+
const { unmount } = render(
|
|
84
|
+
<Provider id='zt-6' data={[1]} keepAlive>
|
|
85
|
+
<ZoomToggle />
|
|
86
|
+
</Provider>,
|
|
87
|
+
)
|
|
88
|
+
fireEvent.click(screen.getByLabelText('Enable zoom'))
|
|
89
|
+
unmount()
|
|
90
|
+
render(
|
|
91
|
+
<Provider id='zt-6' data={[1]} keepAlive>
|
|
92
|
+
<ZoomToggle />
|
|
93
|
+
</Provider>,
|
|
94
|
+
)
|
|
95
|
+
// Re-mounted with keepAlive — enabled survived.
|
|
96
|
+
expect(screen.getByLabelText('Disable zoom')).toBeTruthy()
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('honors custom labels', () => {
|
|
100
|
+
render(
|
|
101
|
+
<Provider id='zt-7' data={[]}>
|
|
102
|
+
<ZoomToggle labels={{ off: 'Pan & zoom', on: 'Stop pan & zoom' }} />
|
|
103
|
+
</Provider>,
|
|
104
|
+
)
|
|
105
|
+
expect(screen.getByLabelText('Pan & zoom')).toBeTruthy()
|
|
106
|
+
})
|
|
107
|
+
})
|