@carto/ps-react-ui 4.7.1 → 4.9.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/{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-l4fNHLEg.js +213 -0
- package/dist/range-l4fNHLEg.js.map +1 -0
- package/dist/resolve-theme-color-BdojIw0K.js +47 -0
- package/dist/resolve-theme-color-BdojIw0K.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-CQCAnDLb.js +388 -0
- package/dist/table-CQCAnDLb.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 +46 -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 +53 -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 +43 -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 +51 -0
- package/dist/types/widgets-v2/index.d.ts +108 -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 +57 -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 +27 -0
- package/dist/types/widgets-v2/range/range.d.ts +24 -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 +54 -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 +40 -0
- package/dist/types/widgets-v2/table/table-ui.d.ts +44 -0
- package/dist/types/widgets-v2/table/table.d.ts +50 -0
- package/dist/types/widgets-v2/table/types.d.ts +48 -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 +60 -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/types.d.ts +25 -0
- package/dist/types/widgets-v2/utils/data-zoom-layout.d.ts +11 -0
- package/dist/types/widgets-v2/utils/index.d.ts +3 -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/utils/resolve-theme-color.d.ts +18 -0
- package/dist/types/widgets-v2/utils/resolve-theme-color.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/bar.js +14 -13
- package/dist/widgets/bar.js.map +1 -1
- package/dist/widgets/histogram.js +8 -7
- 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 +330 -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 +353 -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 +387 -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 +411 -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 +358 -0
- package/dist/widgets-v2/timeseries.js.map +1 -0
- package/dist/widgets-v2/utils.js +8 -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 +71 -3
- 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-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/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 +334 -0
- package/src/widgets-v2/bar/options.ts +332 -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 +51 -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 +59 -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 +48 -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 +318 -0
- package/src/widgets-v2/histogram/options.ts +338 -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 +55 -0
- package/src/widgets-v2/index.ts +204 -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 +601 -0
- package/src/widgets-v2/pie/options.ts +513 -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 +62 -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 +136 -0
- package/src/widgets-v2/range/range-ui.tsx +278 -0
- package/src/widgets-v2/range/range.test.tsx +68 -0
- package/src/widgets-v2/range/range.tsx +52 -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 +411 -0
- package/src/widgets-v2/scatterplot/options.ts +425 -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 +59 -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 +43 -0
- package/src/widgets-v2/table/table-ui.test.tsx +200 -0
- package/src/widgets-v2/table/table-ui.tsx +364 -0
- package/src/widgets-v2/table/table.test.tsx +119 -0
- package/src/widgets-v2/table/table.tsx +179 -0
- package/src/widgets-v2/table/types.ts +55 -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 +394 -0
- package/src/widgets-v2/timeseries/options.ts +348 -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 +65 -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/types.ts +25 -0
- package/src/widgets-v2/utils/data-zoom-layout.ts +26 -0
- package/src/widgets-v2/utils/index.ts +3 -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/utils/resolve-theme-color.test.ts +43 -0
- package/src/widgets-v2/utils/resolve-theme-color.ts +34 -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
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest'
|
|
2
2
|
import type { CallbackDataParams } from 'echarts/types/dist/shared'
|
|
3
|
+
import type { Theme } from '@mui/material'
|
|
3
4
|
import {
|
|
4
5
|
niceNum,
|
|
5
6
|
buildSeriesLabelConfig,
|
|
6
7
|
buildHistogramSeriesLabelConfig,
|
|
8
|
+
buildLegendConfig,
|
|
9
|
+
buildGridConfig,
|
|
10
|
+
createTooltipPositioner,
|
|
11
|
+
createAxisLabelFormatter,
|
|
12
|
+
applyXAxisFormatter,
|
|
13
|
+
applyYAxisFormatter,
|
|
14
|
+
createTooltipFormatter,
|
|
7
15
|
} from './option-builders'
|
|
8
16
|
|
|
17
|
+
const fakeTheme = {
|
|
18
|
+
spacing: (n: number) => String(n * 8),
|
|
19
|
+
} as unknown as Theme
|
|
20
|
+
|
|
9
21
|
describe('niceNum', () => {
|
|
10
22
|
it('should return 0 for 0', () => {
|
|
11
23
|
expect(niceNum(0)).toBe(0)
|
|
@@ -142,3 +154,179 @@ describe('buildHistogramSeriesLabelConfig', () => {
|
|
|
142
154
|
)
|
|
143
155
|
})
|
|
144
156
|
})
|
|
157
|
+
|
|
158
|
+
describe('buildLegendConfig', () => {
|
|
159
|
+
it('returns config with show=true when hasLegend=true', () => {
|
|
160
|
+
const cfg = buildLegendConfig({ hasLegend: true })
|
|
161
|
+
expect(cfg.show).toBe(true)
|
|
162
|
+
expect(cfg.icon).toBe('circle')
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
it('returns config with show=false when hasLegend=false', () => {
|
|
166
|
+
const cfg = buildLegendConfig({ hasLegend: false })
|
|
167
|
+
expect(cfg.show).toBe(false)
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
it('does not set formatter when no labelFormatter provided', () => {
|
|
171
|
+
const cfg = buildLegendConfig({ hasLegend: true })
|
|
172
|
+
expect(cfg.formatter).toBeUndefined()
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
it('sets a wrapper formatter when labelFormatter is provided', () => {
|
|
176
|
+
const cfg = buildLegendConfig({
|
|
177
|
+
hasLegend: true,
|
|
178
|
+
labelFormatter: (v) => `[${v}]`,
|
|
179
|
+
})
|
|
180
|
+
expect(typeof cfg.formatter).toBe('function')
|
|
181
|
+
const fmt = cfg.formatter as (name: string) => string
|
|
182
|
+
expect(fmt('hello')).toBe('[hello]')
|
|
183
|
+
})
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
describe('buildGridConfig', () => {
|
|
187
|
+
it('uses smaller bottom spacing when no legend', () => {
|
|
188
|
+
const cfg = buildGridConfig(false, fakeTheme)
|
|
189
|
+
expect(cfg.bottom).toBe(24) // 3 * 8
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
it('uses larger bottom spacing when legend present', () => {
|
|
193
|
+
const cfg = buildGridConfig(true, fakeTheme)
|
|
194
|
+
expect(cfg.bottom).toBe(56) // 7 * 8
|
|
195
|
+
})
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
describe('createTooltipPositioner', () => {
|
|
199
|
+
it('returns a positioner that places tooltip on the left when there is room', () => {
|
|
200
|
+
const positioner = createTooltipPositioner(fakeTheme)
|
|
201
|
+
const position = positioner([100, 50], null, null, null, {
|
|
202
|
+
contentSize: [50, 30],
|
|
203
|
+
viewSize: [400, 200],
|
|
204
|
+
})
|
|
205
|
+
expect(position.left).toBe(100)
|
|
206
|
+
expect(position.right).toBeUndefined()
|
|
207
|
+
expect(position.top).toBeDefined()
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
it('returns a positioner that places tooltip on the right when there is no room', () => {
|
|
211
|
+
const positioner = createTooltipPositioner(fakeTheme)
|
|
212
|
+
const position = positioner([380, 50], null, null, null, {
|
|
213
|
+
contentSize: [100, 30],
|
|
214
|
+
viewSize: [400, 200],
|
|
215
|
+
})
|
|
216
|
+
expect(position.right).toBe(20) // 400 - 380
|
|
217
|
+
expect(position.left).toBeUndefined()
|
|
218
|
+
})
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
describe('createAxisLabelFormatter', () => {
|
|
222
|
+
it('returns undefined when no formatter passed', () => {
|
|
223
|
+
expect(createAxisLabelFormatter(undefined)).toBeUndefined()
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
it('returns a wrapper function that calls the formatter', () => {
|
|
227
|
+
const fn = createAxisLabelFormatter((v) => `$${v}`)
|
|
228
|
+
expect(fn?.(5)).toBe('$5')
|
|
229
|
+
})
|
|
230
|
+
})
|
|
231
|
+
|
|
232
|
+
describe('applyXAxisFormatter', () => {
|
|
233
|
+
it('attaches a stringifying formatter when both xAxis is object and formatter provided', () => {
|
|
234
|
+
const result = applyXAxisFormatter({ type: 'value' }, (v) => Number(v) + 1)
|
|
235
|
+
const r = result as { axisLabel: { formatter: (v: unknown) => string } }
|
|
236
|
+
expect(r.axisLabel.formatter(2)).toBe('3')
|
|
237
|
+
})
|
|
238
|
+
|
|
239
|
+
it('returns undefined formatter when no formatter provided', () => {
|
|
240
|
+
const result = applyXAxisFormatter({ type: 'value' }, undefined)
|
|
241
|
+
const r = result as { axisLabel: { formatter: unknown } }
|
|
242
|
+
expect(r.axisLabel.formatter).toBeUndefined()
|
|
243
|
+
})
|
|
244
|
+
|
|
245
|
+
it('preserves existing axisLabel object keys', () => {
|
|
246
|
+
const result = applyXAxisFormatter(
|
|
247
|
+
{ type: 'value', axisLabel: { color: 'red' } },
|
|
248
|
+
undefined,
|
|
249
|
+
)
|
|
250
|
+
const r = result as { axisLabel: { color: string; formatter: unknown } }
|
|
251
|
+
expect(r.axisLabel.color).toBe('red')
|
|
252
|
+
})
|
|
253
|
+
|
|
254
|
+
it('handles xAxis being an array (skips object-only path)', () => {
|
|
255
|
+
const result = applyXAxisFormatter([{ type: 'value' }], (v) => v)
|
|
256
|
+
// formatter should not be attached when xAxis is an array
|
|
257
|
+
const r = result as { axisLabel: { formatter: unknown } }
|
|
258
|
+
expect(r.axisLabel.formatter).toBeUndefined()
|
|
259
|
+
})
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
describe('applyYAxisFormatter', () => {
|
|
263
|
+
it('applies formatter when yAxis is an object with type=value', () => {
|
|
264
|
+
const result = applyYAxisFormatter({ type: 'value' }, (v) => `$${v}`)
|
|
265
|
+
const r = result as { axisLabel: { formatter: (v: number) => string } }
|
|
266
|
+
expect(r.axisLabel.formatter(5)).toBe('$5')
|
|
267
|
+
})
|
|
268
|
+
|
|
269
|
+
it('does not apply formatter when yAxis is not type=value', () => {
|
|
270
|
+
const result = applyYAxisFormatter({ type: 'category' }, (v) => `$${v}`)
|
|
271
|
+
const r = result as { axisLabel: { formatter: unknown } }
|
|
272
|
+
expect(r.axisLabel.formatter).toBeUndefined()
|
|
273
|
+
})
|
|
274
|
+
|
|
275
|
+
it('handles yAxis being an array (skips object-only path)', () => {
|
|
276
|
+
const result = applyYAxisFormatter([{ type: 'value' }], (v) => `$${v}`)
|
|
277
|
+
const r = result as { axisLabel: { formatter: unknown } }
|
|
278
|
+
expect(r.axisLabel.formatter).toBeUndefined()
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
it('handles missing axisLabel gracefully', () => {
|
|
282
|
+
const result = applyYAxisFormatter({ type: 'value' }, undefined)
|
|
283
|
+
const r = result as { axisLabel: object }
|
|
284
|
+
expect(r.axisLabel).toBeDefined()
|
|
285
|
+
})
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
describe('createTooltipFormatter', () => {
|
|
289
|
+
it('returns html for a single-item (object) trigger', () => {
|
|
290
|
+
const fmt = createTooltipFormatter((item) => ({
|
|
291
|
+
name: 'A',
|
|
292
|
+
seriesName: 'series',
|
|
293
|
+
marker: '●',
|
|
294
|
+
value: (item.value as number) ?? 0,
|
|
295
|
+
}))
|
|
296
|
+
const params = { value: 42 } as unknown as CallbackDataParams
|
|
297
|
+
const html = fmt(params)
|
|
298
|
+
expect(html).toContain('series')
|
|
299
|
+
expect(html).toContain('42')
|
|
300
|
+
})
|
|
301
|
+
|
|
302
|
+
it('handles multi-item (array) trigger', () => {
|
|
303
|
+
const fmt = createTooltipFormatter((item) => ({
|
|
304
|
+
name: String(item.name ?? ''),
|
|
305
|
+
seriesName: String(item.seriesName ?? ''),
|
|
306
|
+
marker: '●',
|
|
307
|
+
value: (item.value as number) ?? 0,
|
|
308
|
+
}))
|
|
309
|
+
const params = [
|
|
310
|
+
{ name: 'X', seriesName: 's1', value: 1 },
|
|
311
|
+
{ name: 'X', seriesName: 's2', value: 2 },
|
|
312
|
+
] as unknown as CallbackDataParams[]
|
|
313
|
+
const html = fmt(params)
|
|
314
|
+
expect(html).toContain('s1')
|
|
315
|
+
expect(html).toContain('s2')
|
|
316
|
+
})
|
|
317
|
+
|
|
318
|
+
it('omits the header div when name is empty and there is only one item', () => {
|
|
319
|
+
const fmt = createTooltipFormatter(() => ({
|
|
320
|
+
name: '',
|
|
321
|
+
seriesName: '',
|
|
322
|
+
marker: '●',
|
|
323
|
+
value: 1,
|
|
324
|
+
}))
|
|
325
|
+
const params = { value: 1 } as unknown as CallbackDataParams
|
|
326
|
+
const html = fmt(params)
|
|
327
|
+
// no name → no top label div should be present
|
|
328
|
+
expect(html).not.toContain(
|
|
329
|
+
'color:#FFFFFF;font-weight:400;line-height:1; margin-bottom: 10px',
|
|
330
|
+
)
|
|
331
|
+
})
|
|
332
|
+
})
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# Widgets v1 vs v2 — Performance Comparison
|
|
2
|
+
|
|
3
|
+
> **Status:** Measured 2026-05-12 on Apple M4 Pro / macOS 26.4.1 / Chrome 147
|
|
4
|
+
> headless. Storybook dev mode (Vite HMR). 5 cold-mount runs per variant, 15
|
|
5
|
+
> total update ticks per dynamic variant (3 ticks × 5 runs). Medians reported.
|
|
6
|
+
|
|
7
|
+
## TL;DR
|
|
8
|
+
|
|
9
|
+
**v2 is ~2× faster than v1 across every variant measured.** Largest wins are
|
|
10
|
+
on dynamic mount (-60 % to -64 %) and 200-widget static (-60 %); the smallest
|
|
11
|
+
(but still substantial) win is the 200-widget update tick (-46 %).
|
|
12
|
+
|
|
13
|
+
| Variant | v1 (ms, median) | v2 (ms, median) | Δ ms | Δ % |
|
|
14
|
+
| --------------------------- | --------------: | --------------: | -----: | -----: |
|
|
15
|
+
| 100 widgets — static | 2 354.3 | 1 110.8 | -1 243 | -52.8% |
|
|
16
|
+
| 200 widgets — static | 7 831.2 | 3 159.4 | -4 672 | -59.7% |
|
|
17
|
+
| 100 widgets — dynamic mount | 2 613.9 | 944.5 | -1 669 | -63.9% |
|
|
18
|
+
| 200 widgets — dynamic mount | 7 500.5 | 2 988.1 | -4 512 | -60.2% |
|
|
19
|
+
| 100 widgets — update tick | 1 073.9 | 419.2 | -655 | -61.0% |
|
|
20
|
+
| 200 widgets — update tick | 3 403.6 | 1 831.3 | -1 572 | -46.2% |
|
|
21
|
+
|
|
22
|
+
## Methodology
|
|
23
|
+
|
|
24
|
+
Both versions ship a matching performance story under Storybook. Each renders
|
|
25
|
+
a deterministic grid of widgets (seeded PRNG, seed `42`) across 9 widget types:
|
|
26
|
+
`bar, pie, timeseries, histogram, scatterplot, category, formula, spread, range`.
|
|
27
|
+
|
|
28
|
+
Each story logs to the console after a double-`rAF` (so paint is included),
|
|
29
|
+
once on mount and once per data refresh in the dynamic variants:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
[Performance] 100 widgets rendered in 2354.3ms ← v1 mount
|
|
33
|
+
[Performance v2] 100 widgets updated in 419.2ms ← v2 per-tick update
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Stories
|
|
37
|
+
|
|
38
|
+
| | v1 | v2 |
|
|
39
|
+
| -------------- | ------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------- |
|
|
40
|
+
| Source | [performance.stories.tsx](../../../../apps/storybook/stories/react-ui/widgets/performance.stories.tsx) | [performance.stories.tsx](../../../../apps/storybook/stories/react-ui/widgets-v2/performance.stories.tsx) |
|
|
41
|
+
| Storybook path | `React Ui/Widgets/Performance` | `React UI/Widgets v2/Performance` |
|
|
42
|
+
| Console prefix | `[Performance]` | `[Performance v2]` |
|
|
43
|
+
|
|
44
|
+
### Procedure
|
|
45
|
+
|
|
46
|
+
1. `pnpm storybook` (already running on `:6006`).
|
|
47
|
+
2. Headless Chrome started via CDP on port 9333 (separate user-data-dir, no
|
|
48
|
+
throttling). Driver: [/tmp/perf-bench.mjs](/tmp/perf-bench.mjs) (one-off,
|
|
49
|
+
not checked in).
|
|
50
|
+
3. For each variant: 5 fresh navigations. On each navigation we capture the
|
|
51
|
+
first `[Performance...] rendered in Xms` log; for dynamic variants we also
|
|
52
|
+
capture the next 3 `updated in Xms` logs (one per 3 s tick).
|
|
53
|
+
4. Medians (and min/max for sanity) computed across runs / ticks.
|
|
54
|
+
|
|
55
|
+
### Environment
|
|
56
|
+
|
|
57
|
+
- **Machine:** Apple M4 Pro, 24 GB RAM
|
|
58
|
+
- **OS:** macOS 26.4.1 (build 25E253)
|
|
59
|
+
- **Browser:** Chrome 147.0.7727.138, headless=new, no throttling
|
|
60
|
+
- **Storybook:** v10.3.6, dev mode (Vite HMR), production build numbers will differ
|
|
61
|
+
- **Date measured:** 2026-05-12
|
|
62
|
+
|
|
63
|
+
## Results
|
|
64
|
+
|
|
65
|
+
### Static render (cold mount)
|
|
66
|
+
|
|
67
|
+
Time from initial render commit to second-rAF paint.
|
|
68
|
+
|
|
69
|
+
| Variant | v1 min/median/max (ms) | v2 min/median/max (ms) | Δ median (%) |
|
|
70
|
+
| ----------- | -------------------------------- | ------------------------------- | -----------: |
|
|
71
|
+
| 100 widgets | 2 214.5 / **2 354.3** / 2 509.6 | 1 020.0 / **1 110.8** / 1 132.5 | -52.8% |
|
|
72
|
+
| 200 widgets | 7 150.4 / **7 831.2** / 12 067.5 | 2 888.9 / **3 159.4** / 3 517.6 | -59.7% |
|
|
73
|
+
|
|
74
|
+
> v1's 200-widget run shows a notable outlier (12.1 s) on one of five runs; v2
|
|
75
|
+
> stays within a tight 2.9–3.5 s band. Median is robust to the outlier and is
|
|
76
|
+
> what should be cited.
|
|
77
|
+
|
|
78
|
+
### Cold mount inside the dynamic variant
|
|
79
|
+
|
|
80
|
+
Same as static, but rendered inside the `*Dynamic` story (which adds a sticky
|
|
81
|
+
update banner and a `setInterval`). Provided as a sanity check — these should
|
|
82
|
+
match the static numbers above and they do.
|
|
83
|
+
|
|
84
|
+
| Variant | v1 min/median/max (ms) | v2 min/median/max (ms) | Δ median (%) |
|
|
85
|
+
| ----------- | ------------------------------- | ------------------------------- | -----------: |
|
|
86
|
+
| 100 widgets | 2 303.2 / **2 613.9** / 2 833.3 | 936.0 / **944.5** / 1 273.0 | -63.9% |
|
|
87
|
+
| 200 widgets | 7 236.0 / **7 500.5** / 8 189.9 | 2 938.3 / **2 988.1** / 3 357.1 | -60.2% |
|
|
88
|
+
|
|
89
|
+
### Dynamic update (per 3 s tick)
|
|
90
|
+
|
|
91
|
+
Time per data refresh — measured after each `setWidgetDefs(...)` commit,
|
|
92
|
+
through double-`rAF` to paint. 15 ticks per variant (3 ticks × 5 runs).
|
|
93
|
+
|
|
94
|
+
| Variant | v1 min/median/max (ms) | v2 min/median/max (ms) | Δ median (%) |
|
|
95
|
+
| ----------- | ------------------------------- | ------------------------------- | -----------: |
|
|
96
|
+
| 100 widgets | 672.9 / **1 073.9** / 1 732.2 | 397.9 / **419.2** / 961.3 | -61.0% |
|
|
97
|
+
| 200 widgets | 2 807.2 / **3 403.6** / 6 048.8 | 1 727.9 / **1 831.3** / 3 471.0 | -46.2% |
|
|
98
|
+
|
|
99
|
+
> The first tick of each dynamic run is consistently the slowest in **both**
|
|
100
|
+
> versions (warmup / JIT / first ECharts dataset swap). v2 amortises this less
|
|
101
|
+
> dramatically than v1 — its update path is steadier (398–480 ms tail for 100
|
|
102
|
+
> widgets; 1 728–1 924 ms tail for 200) while v1 ticks remain noisy throughout
|
|
103
|
+
> (672–1 732 ms at 100; 2 807–6 049 ms at 200).
|
|
104
|
+
|
|
105
|
+
## Raw data
|
|
106
|
+
|
|
107
|
+
Captured to [/tmp/perf-bench.err](/tmp/perf-bench.err) during the run. Pasted
|
|
108
|
+
inline for reproducibility (the file is volatile / not checked in):
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
v1 / 100 static : 2509.6, 2354.3, 2249.9, 2214.5, 2408.7
|
|
112
|
+
v1 / 100 dynamic mount : 2402.2, 2303.2, 2613.9, 2833.3, 2801.8
|
|
113
|
+
v1 / 100 dynamic ticks (3 × 5 run) : 1732.2, 973.4, 672.9 | 1599.1, 994.6, 782.0 | 1688.3, 1020.0, 811.8 | 1181.1, 1255.0, 1073.9 | 975.8, 1457.5, 1110.5
|
|
114
|
+
v1 / 200 static : 8711.4, 12067.5, 7831.2, 7420.5, 7150.4
|
|
115
|
+
v1 / 200 dynamic mount : 8189.9, 7341.1, 7236.0, 7500.5, 7586.4
|
|
116
|
+
v1 / 200 dynamic ticks : 5367.8, 2979.2, 3403.6 | 2807.2, 6048.8, 3734.0 | 2877.3, 6021.2, 3754.5 | 2965.0, 3712.3, 3152.1 | 2945.4, 3823.6, 3112.9
|
|
117
|
+
v2 / 100 static : 1111.6, 1132.5, 1038.1, 1020.0, 1110.8
|
|
118
|
+
v2 / 100 dynamic mount : 1047.7, 944.5, 936.0, 938.9, 1273.0
|
|
119
|
+
v2 / 100 dynamic ticks : 453.2, 407.4, 419.2 | 480.1, 397.9, 403.4 | 428.3, 398.2, 411.8 | 442.7, 412.6, 409.5 | 961.3, 454.0, 604.1
|
|
120
|
+
v2 / 200 static : 3517.6, 3413.2, 2888.9, 3159.4, 2940.4
|
|
121
|
+
v2 / 200 dynamic mount : 2963.9, 3300.6, 3357.1, 2938.3, 2988.1
|
|
122
|
+
v2 / 200 dynamic ticks : 1784.5, 1781.5, 2103.6 | 3208.2, 1924.8, 1834.8 | 3097.6, 1831.3, 1727.9 | 3471.0, 1808.5, 1766.4 | 3137.2, 1821.7, 1759.3
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Architectural notes that affect comparability
|
|
126
|
+
|
|
127
|
+
These are **already known differences** between v1 and v2 — they explain part
|
|
128
|
+
of the delta and matter when judging whether the comparison is apples-to-apples:
|
|
129
|
+
|
|
130
|
+
- **v2 uses pre-composed wrappers from `apps/storybook/stories/modules/widgets/`**
|
|
131
|
+
(e.g. [`Bar`](../../../../apps/storybook/stories/modules/widgets/bar/bar.tsx)).
|
|
132
|
+
These include `Widget.Provider`, `Widget.Toolbox`, `Widget.FullScreen.Slot`,
|
|
133
|
+
`Widget.SelectionSummary`, etc. — i.e. v2 numbers include a slightly richer
|
|
134
|
+
default toolbar surface that v1's perf story does not exercise. Despite
|
|
135
|
+
doing **more** work, v2 still wins ~2× — the underlying primitives are
|
|
136
|
+
faster, not the toolbar that's missing.
|
|
137
|
+
- **Datum shape differs.** v1 uses `{ category, value }`; v2 uses
|
|
138
|
+
`{ name, value }`. Payload sizes are equivalent.
|
|
139
|
+
- **State management.** v1's `useWidgetStore` exposes per-widget config via
|
|
140
|
+
`state.widgets[id]` (one global store, O(n) keys). v2 introduces per-widget
|
|
141
|
+
stores via `getWidgetStore(id)` plus a `Widget.Provider` context. v2 trades
|
|
142
|
+
more mount-time allocations for far fewer cross-widget broadcasts on update
|
|
143
|
+
— which shows up clearly in the update-tick numbers (61 % faster at 100
|
|
144
|
+
widgets, 46 % at 200).
|
|
145
|
+
- **ECharts pipeline.** v2 puts BOTH option phases on a single
|
|
146
|
+
`optionFactory` closure passed as a prop to `Widget.Echart`: Echart's
|
|
147
|
+
layout effect seeds `rawOptions` from the factory's structural branch
|
|
148
|
+
once on mount, configTransforms (Stack/Zoom/Brush) mutate it via the
|
|
149
|
+
middleware, then Echart's render-time `useMemo` calls the factory again
|
|
150
|
+
to merge live `state.data` into the post-transform option. v1 builds
|
|
151
|
+
the full option per render. v2 should win on dynamic updates (no
|
|
152
|
+
re-init) — and does.
|
|
153
|
+
- **Ids.** The 200-widget variant in v2 uses `-dup`-suffixed ids so each of
|
|
154
|
+
the 200 instances has its own per-widget store; v1 reuses the same id across
|
|
155
|
+
the duplicate set (only 100 unique stores). Despite v2 having 2× more store
|
|
156
|
+
instances, it still beats v1.
|
|
157
|
+
|
|
158
|
+
## Observations
|
|
159
|
+
|
|
160
|
+
- **Cold-mount cost direction:** v2 wins by ~53 % at 100 widgets and ~60 % at 200. Scaling is closer to linear in v2 (1.1 s → 3.2 s ≈ 2.9×) than in v1
|
|
161
|
+
(2.4 s → 7.8 s ≈ 3.3×). At larger N the gap widens.
|
|
162
|
+
- **Dynamic-update cost direction:** v2 wins decisively (-61 % / -46 %). The
|
|
163
|
+
per-tick distribution is much tighter — v2's option-factory-fed `setOption`
|
|
164
|
+
avoids re-initialising charts.
|
|
165
|
+
- **Outlier widget types:** not measured per-type in this run. Hot candidates
|
|
166
|
+
for follow-up: `timeseries` (largest data payload, ECharts brush+searcher
|
|
167
|
+
toolbar) and `category` (DOM-heavy, no ECharts).
|
|
168
|
+
- **Variance:** v1 update ticks span 670–1 730 ms at 100 widgets — a 2.6×
|
|
169
|
+
spread, with the first tick of each navigation always slowest. v2 ticks
|
|
170
|
+
span 398–961 ms — 2.4× spread, but the 961 ms is a single outlier; the
|
|
171
|
+
P75 is closer to 450 ms.
|
|
172
|
+
- **First-tick warmup.** Both versions show a slower first tick after mount
|
|
173
|
+
(visible in both 100- and 200-widget update series). v2's first-tick
|
|
174
|
+
penalty is smaller in absolute terms but proportionally similar.
|
|
175
|
+
|
|
176
|
+
## Next steps
|
|
177
|
+
|
|
178
|
+
- [ ] Per-widget-type breakdown — re-run with `WIDGET_TYPES = ['timeseries']`,
|
|
179
|
+
then `['category']`, etc., to isolate which types contribute most to the
|
|
180
|
+
v2 win and where any v2 regressions might hide.
|
|
181
|
+
- [ ] Production-build numbers — Storybook dev mode includes HMR, source-map
|
|
182
|
+
eval, and React dev-mode checks. Expect both versions to be ~30 % faster
|
|
183
|
+
on a `storybook build` artifact; the relative gap may narrow if v1's
|
|
184
|
+
hotspots are dev-mode-only.
|
|
185
|
+
- [ ] Memory profile across 10 dynamic ticks — confirm no widget-store leak
|
|
186
|
+
in v2 (per-widget stores must be torn down when ids change in the doubled
|
|
187
|
+
variant).
|
|
188
|
+
- [ ] Lower-spec hardware — re-run on a baseline laptop to confirm the v2 win
|
|
189
|
+
isn't M4-specific.
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
|
|
2
|
+
import { act, fireEvent, render, screen } from '@testing-library/react'
|
|
3
|
+
import type { ECharts } from 'echarts'
|
|
4
|
+
import { BrushToggle } from './brush-toggle'
|
|
5
|
+
import { Provider } from '../../provider/widget-provider'
|
|
6
|
+
import {
|
|
7
|
+
applyTransforms,
|
|
8
|
+
clearAllWidgetStores,
|
|
9
|
+
getWidgetStore,
|
|
10
|
+
setEchartInstance,
|
|
11
|
+
} from '../../stores'
|
|
12
|
+
|
|
13
|
+
interface ChartHandlers {
|
|
14
|
+
finished?: () => void
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface MockChart {
|
|
18
|
+
dispatchAction: ReturnType<typeof vi.fn>
|
|
19
|
+
on: (ev: string, cb: () => void) => void
|
|
20
|
+
off: (ev: string, cb: () => void) => void
|
|
21
|
+
__handlers: ChartHandlers
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function makeMockChart(): MockChart {
|
|
25
|
+
const handlers: ChartHandlers = {}
|
|
26
|
+
return {
|
|
27
|
+
dispatchAction: vi.fn(),
|
|
28
|
+
on: (ev, cb) => {
|
|
29
|
+
if (ev === 'finished') handlers.finished = cb
|
|
30
|
+
},
|
|
31
|
+
off: (ev) => {
|
|
32
|
+
if (ev === 'finished') handlers.finished = undefined
|
|
33
|
+
},
|
|
34
|
+
__handlers: handlers,
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
beforeEach(() => clearAllWidgetStores())
|
|
39
|
+
afterEach(() => clearAllWidgetStores())
|
|
40
|
+
|
|
41
|
+
describe('<BrushToggle>', () => {
|
|
42
|
+
it('starts disabled by default', () => {
|
|
43
|
+
render(
|
|
44
|
+
<Provider id='bt-1' data={[]}>
|
|
45
|
+
<BrushToggle />
|
|
46
|
+
</Provider>,
|
|
47
|
+
)
|
|
48
|
+
expect(screen.getByLabelText('Enable brush selection')).toBeTruthy()
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('respects initialEnabled=true', () => {
|
|
52
|
+
render(
|
|
53
|
+
<Provider id='bt-2' data={[]}>
|
|
54
|
+
<BrushToggle initialEnabled />
|
|
55
|
+
</Provider>,
|
|
56
|
+
)
|
|
57
|
+
expect(screen.getByLabelText('Disable brush selection')).toBeTruthy()
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('clicking enables the transform — brush config appears in the post-pipeline option', () => {
|
|
61
|
+
render(
|
|
62
|
+
<Provider id='bt-3' data={[1]}>
|
|
63
|
+
<BrushToggle />
|
|
64
|
+
</Provider>,
|
|
65
|
+
)
|
|
66
|
+
fireEvent.click(screen.getByLabelText('Enable brush selection'))
|
|
67
|
+
// configTransforms now apply inside <Widget.Echart>; replay the
|
|
68
|
+
// pipeline locally over a blank structural option.
|
|
69
|
+
const configTransforms = getWidgetStore('bt-3').getState().configTransforms
|
|
70
|
+
const opts = applyTransforms({}, configTransforms) as {
|
|
71
|
+
brush?: { xAxisIndex?: string }
|
|
72
|
+
}
|
|
73
|
+
expect(opts.brush).toBeTruthy()
|
|
74
|
+
expect(opts.brush?.xAxisIndex).toBe('all')
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('dispatches takeGlobalCursor with brush config when enabled and a chart is registered', () => {
|
|
78
|
+
const chart = makeMockChart()
|
|
79
|
+
setEchartInstance('bt-4', chart as unknown as ECharts)
|
|
80
|
+
render(
|
|
81
|
+
<Provider id='bt-4' data={[1]}>
|
|
82
|
+
<BrushToggle initialEnabled />
|
|
83
|
+
</Provider>,
|
|
84
|
+
)
|
|
85
|
+
expect(chart.dispatchAction).toHaveBeenCalledWith({
|
|
86
|
+
type: 'takeGlobalCursor',
|
|
87
|
+
key: 'brush',
|
|
88
|
+
brushOption: { brushType: 'lineX', brushMode: 'multiple' },
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
it("re-dispatches takeGlobalCursor on the chart's 'finished' event", () => {
|
|
93
|
+
const chart = makeMockChart()
|
|
94
|
+
setEchartInstance('bt-5', chart as unknown as ECharts)
|
|
95
|
+
render(
|
|
96
|
+
<Provider id='bt-5' data={[1]}>
|
|
97
|
+
<BrushToggle initialEnabled />
|
|
98
|
+
</Provider>,
|
|
99
|
+
)
|
|
100
|
+
chart.dispatchAction.mockClear()
|
|
101
|
+
act(() => chart.__handlers.finished?.())
|
|
102
|
+
expect(chart.dispatchAction).toHaveBeenCalledWith({
|
|
103
|
+
type: 'takeGlobalCursor',
|
|
104
|
+
key: 'brush',
|
|
105
|
+
brushOption: { brushType: 'lineX', brushMode: 'multiple' },
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
it('on disable: clears the global cursor and wipes drawn areas', () => {
|
|
110
|
+
const chart = makeMockChart()
|
|
111
|
+
setEchartInstance('bt-6', chart as unknown as ECharts)
|
|
112
|
+
render(
|
|
113
|
+
<Provider id='bt-6' data={[1]}>
|
|
114
|
+
<BrushToggle initialEnabled />
|
|
115
|
+
</Provider>,
|
|
116
|
+
)
|
|
117
|
+
chart.dispatchAction.mockClear()
|
|
118
|
+
fireEvent.click(screen.getByLabelText('Disable brush selection'))
|
|
119
|
+
expect(chart.dispatchAction).toHaveBeenCalledWith({
|
|
120
|
+
type: 'takeGlobalCursor',
|
|
121
|
+
})
|
|
122
|
+
expect(chart.dispatchAction).toHaveBeenCalledWith({
|
|
123
|
+
type: 'brush',
|
|
124
|
+
areas: [],
|
|
125
|
+
})
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
it('honors brushType=rect and brushMode=single', () => {
|
|
129
|
+
const chart = makeMockChart()
|
|
130
|
+
setEchartInstance('bt-7', chart as unknown as ECharts)
|
|
131
|
+
render(
|
|
132
|
+
<Provider id='bt-7' data={[1]}>
|
|
133
|
+
<BrushToggle initialEnabled brushType='rect' brushMode='single' />
|
|
134
|
+
</Provider>,
|
|
135
|
+
)
|
|
136
|
+
expect(chart.dispatchAction).toHaveBeenCalledWith({
|
|
137
|
+
type: 'takeGlobalCursor',
|
|
138
|
+
key: 'brush',
|
|
139
|
+
brushOption: { brushType: 'rect', brushMode: 'single' },
|
|
140
|
+
})
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
it('wipes drawn brush areas when an external selection is cleared while enabled', () => {
|
|
144
|
+
const chart = makeMockChart()
|
|
145
|
+
setEchartInstance('bt-9', chart as unknown as ECharts)
|
|
146
|
+
const { rerender } = render(
|
|
147
|
+
<Provider id='bt-9' data={[1]}>
|
|
148
|
+
<BrushToggle initialEnabled selection={['a', 'b']} />
|
|
149
|
+
</Provider>,
|
|
150
|
+
)
|
|
151
|
+
chart.dispatchAction.mockClear()
|
|
152
|
+
rerender(
|
|
153
|
+
<Provider id='bt-9' data={[1]}>
|
|
154
|
+
<BrushToggle initialEnabled selection={[]} />
|
|
155
|
+
</Provider>,
|
|
156
|
+
)
|
|
157
|
+
expect(chart.dispatchAction).toHaveBeenCalledWith({
|
|
158
|
+
type: 'brush',
|
|
159
|
+
areas: [],
|
|
160
|
+
})
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
it('attaches the cursor reactively when the chart arrives *after* the toggle mounts', () => {
|
|
164
|
+
const chart = makeMockChart()
|
|
165
|
+
render(
|
|
166
|
+
<Provider id='bt-8' data={[1]}>
|
|
167
|
+
<BrushToggle initialEnabled />
|
|
168
|
+
</Provider>,
|
|
169
|
+
)
|
|
170
|
+
// Chart not yet registered — no dispatch should have happened.
|
|
171
|
+
expect(chart.dispatchAction).not.toHaveBeenCalled()
|
|
172
|
+
// Simulate the bridge mounting and publishing the instance.
|
|
173
|
+
act(() => setEchartInstance('bt-8', chart as unknown as ECharts))
|
|
174
|
+
expect(chart.dispatchAction).toHaveBeenCalledWith({
|
|
175
|
+
type: 'takeGlobalCursor',
|
|
176
|
+
key: 'brush',
|
|
177
|
+
brushOption: { brushType: 'lineX', brushMode: 'multiple' },
|
|
178
|
+
})
|
|
179
|
+
})
|
|
180
|
+
})
|