@cloudscape-design/components 3.0.135 → 3.0.137
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/alert/internal.d.ts +1 -1
- package/alert/internal.d.ts.map +1 -1
- package/app-layout/visual-refresh/styles.css.js +60 -60
- package/app-layout/visual-refresh/styles.scoped.css +148 -148
- package/app-layout/visual-refresh/styles.selectors.js +60 -60
- package/area-chart/chart-container.d.ts.map +1 -1
- package/area-chart/chart-container.js +2 -1
- package/area-chart/chart-container.js.map +1 -1
- package/area-chart/internal.d.ts +1 -1
- package/area-chart/internal.d.ts.map +1 -1
- package/area-chart/model/async-store.d.ts +2 -2
- package/area-chart/model/async-store.d.ts.map +1 -1
- package/area-chart/model/interactions-store.d.ts.map +1 -1
- package/area-chart/model/interactions-store.js +1 -1
- package/area-chart/model/interactions-store.js.map +1 -1
- package/area-chart/model/use-chart-model.d.ts +1 -2
- package/area-chart/model/use-chart-model.d.ts.map +1 -1
- package/area-chart/model/use-chart-model.js +46 -10
- package/area-chart/model/use-chart-model.js.map +1 -1
- package/area-chart/model/use-filter-props.d.ts +1 -1
- package/area-chart/model/use-filter-props.d.ts.map +1 -1
- package/area-chart/model/use-highlight-props.d.ts +1 -1
- package/area-chart/model/use-highlight-props.d.ts.map +1 -1
- package/attribute-editor/internal.js.map +1 -1
- package/autosuggest/interfaces.d.ts +1 -1
- package/autosuggest/interfaces.d.ts.map +1 -1
- package/autosuggest/options-controller.d.ts +1 -1
- package/autosuggest/options-controller.d.ts.map +1 -1
- package/autosuggest/plain-list.d.ts +1 -1
- package/autosuggest/plain-list.d.ts.map +1 -1
- package/bar-chart/interfaces.d.ts +1 -1
- package/bar-chart/interfaces.d.ts.map +1 -1
- package/box/internal.d.ts +1 -1
- package/box/internal.d.ts.map +1 -1
- package/breadcrumb-group/internal.d.ts +1 -1
- package/breadcrumb-group/internal.d.ts.map +1 -1
- package/button-dropdown/interfaces.d.ts +2 -2
- package/button-dropdown/interfaces.d.ts.map +1 -1
- package/button-dropdown/utils/create-items-tree.d.ts +1 -1
- package/button-dropdown/utils/create-items-tree.d.ts.map +1 -1
- package/calendar/internal.d.ts +1 -1
- package/calendar/internal.d.ts.map +1 -1
- package/code-editor/interfaces.d.ts +2 -2
- package/code-editor/interfaces.d.ts.map +1 -1
- package/code-editor/util.d.ts +1 -1
- package/code-editor/util.d.ts.map +1 -1
- package/collection-preferences/index.d.ts +1 -1
- package/collection-preferences/index.d.ts.map +1 -1
- package/collection-preferences/index.js +10 -5
- package/collection-preferences/index.js.map +1 -1
- package/collection-preferences/interfaces.d.ts +17 -0
- package/collection-preferences/interfaces.d.ts.map +1 -1
- package/collection-preferences/interfaces.js.map +1 -1
- package/collection-preferences/styles.css.js +20 -19
- package/collection-preferences/styles.scoped.css +21 -20
- package/collection-preferences/styles.selectors.js +20 -19
- package/collection-preferences/utils.d.ts +6 -1
- package/collection-preferences/utils.d.ts.map +1 -1
- package/collection-preferences/utils.js +10 -1
- package/collection-preferences/utils.js.map +1 -1
- package/column-layout/internal.d.ts +2 -2
- package/column-layout/internal.d.ts.map +1 -1
- package/container/use-sticky-header.d.ts +1 -1
- package/container/use-sticky-header.d.ts.map +1 -1
- package/date-range-picker/calendar/range-inputs.d.ts +1 -1
- package/date-range-picker/calendar/range-inputs.d.ts.map +1 -1
- package/date-range-picker/interfaces.d.ts +2 -2
- package/date-range-picker/interfaces.d.ts.map +1 -1
- package/expandable-section/internal.d.ts +1 -1
- package/expandable-section/internal.d.ts.map +1 -1
- package/form/internal.d.ts +1 -1
- package/form/internal.d.ts.map +1 -1
- package/icon/internal.d.ts +1 -1
- package/icon/internal.d.ts.map +1 -1
- package/input/index.js.map +1 -1
- package/internal/base-component/styles.scoped.css +4 -0
- package/internal/breakpoints.d.ts +1 -1
- package/internal/breakpoints.d.ts.map +1 -1
- package/internal/components/autosuggest-input/index.js.map +1 -1
- package/internal/components/cartesian-chart/bottom-labels.d.ts.map +1 -1
- package/internal/components/cartesian-chart/bottom-labels.js +1 -1
- package/internal/components/cartesian-chart/bottom-labels.js.map +1 -1
- package/internal/components/cartesian-chart/interfaces.d.ts +8 -8
- package/internal/components/cartesian-chart/interfaces.d.ts.map +1 -1
- package/internal/components/cartesian-chart/scales.d.ts +2 -2
- package/internal/components/cartesian-chart/scales.d.ts.map +1 -1
- package/internal/components/chart-plot/application-controller.js +1 -1
- package/internal/components/chart-plot/application-controller.js.map +1 -1
- package/internal/components/chart-plot/focus-outline.d.ts +2 -1
- package/internal/components/chart-plot/focus-outline.d.ts.map +1 -1
- package/internal/components/chart-plot/focus-outline.js +6 -4
- package/internal/components/chart-plot/focus-outline.js.map +1 -1
- package/internal/components/chart-plot/index.d.ts +3 -2
- package/internal/components/chart-plot/index.d.ts.map +1 -1
- package/internal/components/chart-plot/index.js.map +1 -1
- package/internal/components/chart-plot/interfaces.d.ts +5 -0
- package/internal/components/chart-plot/interfaces.d.ts.map +1 -0
- package/internal/components/chart-plot/interfaces.js +2 -0
- package/internal/components/chart-plot/interfaces.js.map +1 -0
- package/internal/components/chart-series-marker/index.d.ts +1 -1
- package/internal/components/chart-series-marker/index.d.ts.map +1 -1
- package/internal/components/dropdown/context.d.ts +1 -1
- package/internal/components/dropdown/context.d.ts.map +1 -1
- package/internal/components/dropdown/dropdown-fit-handler.d.ts +5 -5
- package/internal/components/dropdown/dropdown-fit-handler.d.ts.map +1 -1
- package/internal/components/dropdown/interfaces.d.ts +1 -1
- package/internal/components/dropdown/interfaces.d.ts.map +1 -1
- package/internal/components/dropdown-status/index.d.ts +1 -1
- package/internal/components/dropdown-status/index.d.ts.map +1 -1
- package/internal/components/interfaces.d.ts +5 -0
- package/internal/components/interfaces.d.ts.map +1 -0
- package/internal/components/interfaces.js +2 -0
- package/internal/components/interfaces.js.map +1 -0
- package/internal/components/live-region/index.d.ts +1 -1
- package/internal/components/live-region/index.d.ts.map +1 -1
- package/internal/components/option/utils/filter-options.d.ts +3 -3
- package/internal/components/option/utils/filter-options.d.ts.map +1 -1
- package/internal/components/options-list/utils/use-highlight-option.d.ts +1 -1
- package/internal/components/options-list/utils/use-highlight-option.d.ts.map +1 -1
- package/internal/components/selectable-item/index.d.ts +1 -1
- package/internal/components/selectable-item/index.d.ts.map +1 -1
- package/internal/components/transition/index.d.ts +1 -1
- package/internal/components/transition/index.d.ts.map +1 -1
- package/internal/context/split-panel-context.d.ts +1 -1
- package/internal/context/split-panel-context.d.ts.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/events/index.d.ts +3 -3
- package/internal/events/index.d.ts.map +1 -1
- package/internal/generated/theming/index.cjs +26 -0
- package/internal/generated/theming/index.js +26 -0
- package/internal/hooks/container-queries/use-resize-observer.d.ts +1 -1
- package/internal/hooks/container-queries/use-resize-observer.d.ts.map +1 -1
- package/internal/hooks/forward-focus/index.js.map +1 -1
- package/internal/hooks/use-singleton-handler/index.d.ts +3 -3
- package/internal/hooks/use-singleton-handler/index.d.ts.map +1 -1
- package/internal/manifest.json +1 -1
- package/internal/metrics.d.ts +2 -2
- package/internal/metrics.d.ts.map +1 -1
- package/internal/metrics.js.map +1 -1
- package/internal/types.d.ts +1 -1
- package/internal/types.d.ts.map +1 -1
- package/internal/utils/locale/normalize-start-of-week.d.ts +1 -1
- package/internal/utils/locale/normalize-start-of-week.d.ts.map +1 -1
- package/internal/utils/scrollable-containers.d.ts +1 -1
- package/internal/utils/scrollable-containers.d.ts.map +1 -1
- package/internal/vendor/d3-scale.js +185 -186
- package/line-chart/interfaces.d.ts +1 -1
- package/line-chart/interfaces.d.ts.map +1 -1
- package/mixed-line-bar-chart/chart-container.d.ts +1 -2
- package/mixed-line-bar-chart/chart-container.d.ts.map +1 -1
- package/mixed-line-bar-chart/chart-container.js +55 -41
- package/mixed-line-bar-chart/chart-container.js.map +1 -1
- package/mixed-line-bar-chart/domain.js +4 -4
- package/mixed-line-bar-chart/domain.js.map +1 -1
- package/mixed-line-bar-chart/hooks/use-mouse-hover.d.ts +3 -4
- package/mixed-line-bar-chart/hooks/use-mouse-hover.d.ts.map +1 -1
- package/mixed-line-bar-chart/hooks/use-mouse-hover.js +22 -18
- package/mixed-line-bar-chart/hooks/use-mouse-hover.js.map +1 -1
- package/mixed-line-bar-chart/hooks/use-navigation.d.ts +7 -4
- package/mixed-line-bar-chart/hooks/use-navigation.d.ts.map +1 -1
- package/mixed-line-bar-chart/hooks/use-navigation.js +61 -31
- package/mixed-line-bar-chart/hooks/use-navigation.js.map +1 -1
- package/mixed-line-bar-chart/interfaces.d.ts +8 -4
- package/mixed-line-bar-chart/interfaces.d.ts.map +1 -1
- package/mixed-line-bar-chart/interfaces.js.map +1 -1
- package/mixed-line-bar-chart/internal.d.ts +1 -1
- package/mixed-line-bar-chart/internal.d.ts.map +1 -1
- package/mixed-line-bar-chart/internal.js +1 -1
- package/mixed-line-bar-chart/internal.js.map +1 -1
- package/mixed-line-bar-chart/utils.d.ts +1 -1
- package/mixed-line-bar-chart/utils.d.ts.map +1 -1
- package/modal/internal.d.ts +1 -1
- package/modal/internal.d.ts.map +1 -1
- package/package.json +1 -1
- package/pagination/internal.d.ts +1 -1
- package/pagination/internal.d.ts.map +1 -1
- package/popover/interfaces.d.ts +2 -2
- package/popover/interfaces.d.ts.map +1 -1
- package/property-filter/interfaces.d.ts +16 -16
- package/property-filter/interfaces.d.ts.map +1 -1
- package/property-filter/use-load-items.d.ts +2 -1
- package/property-filter/use-load-items.d.ts.map +1 -1
- package/s3-resource-selector/interfaces.d.ts +1 -1
- package/s3-resource-selector/interfaces.d.ts.map +1 -1
- package/segmented-control/internal.d.ts +1 -1
- package/segmented-control/internal.d.ts.map +1 -1
- package/select/utils/use-select.d.ts +3 -3
- package/select/utils/use-select.d.ts.map +1 -1
- package/select/utils/use-select.js +4 -3
- package/select/utils/use-select.js.map +1 -1
- package/side-navigation/util.d.ts +1 -1
- package/side-navigation/util.d.ts.map +1 -1
- package/space-between/internal.d.ts +1 -1
- package/space-between/internal.d.ts.map +1 -1
- package/table/body-cell/index.d.ts +3 -1
- package/table/body-cell/index.d.ts.map +1 -1
- package/table/body-cell/index.js +2 -2
- package/table/body-cell/index.js.map +1 -1
- package/table/body-cell/styles.css.js +8 -7
- package/table/body-cell/styles.scoped.css +21 -18
- package/table/body-cell/styles.selectors.js +8 -7
- package/table/header-cell/utils.d.ts +1 -1
- package/table/header-cell/utils.d.ts.map +1 -1
- package/table/interfaces.d.ts +4 -0
- package/table/interfaces.d.ts.map +1 -1
- package/table/interfaces.js.map +1 -1
- package/table/internal.d.ts.map +1 -1
- package/table/internal.js +4 -3
- package/table/internal.js.map +1 -1
- package/table/use-sticky-header.d.ts.map +1 -1
- package/table/use-sticky-header.js +4 -1
- package/table/use-sticky-header.js.map +1 -1
- package/tag-editor/validation.d.ts +1 -1
- package/tag-editor/validation.d.ts.map +1 -1
- package/test-utils/dom/collection-preferences/index.d.ts +1 -0
- package/test-utils/dom/collection-preferences/index.js +3 -0
- package/test-utils/dom/collection-preferences/index.js.map +1 -1
- package/test-utils/selectors/alert/index.js.map +1 -1
- package/test-utils/selectors/annotation/index.js.map +1 -1
- package/test-utils/selectors/app-layout/index.js.map +1 -1
- package/test-utils/selectors/area-chart/index.js.map +1 -1
- package/test-utils/selectors/attribute-editor/index.js.map +1 -1
- package/test-utils/selectors/autosuggest/index.js.map +1 -1
- package/test-utils/selectors/breadcrumb-group/index.js.map +1 -1
- package/test-utils/selectors/button/index.js.map +1 -1
- package/test-utils/selectors/button-dropdown/index.js.map +1 -1
- package/test-utils/selectors/calendar/index.js.map +1 -1
- package/test-utils/selectors/cards/index.js.map +1 -1
- package/test-utils/selectors/checkbox/index.js.map +1 -1
- package/test-utils/selectors/code-editor/index.js.map +1 -1
- package/test-utils/selectors/collection-preferences/index.d.ts +1 -0
- package/test-utils/selectors/collection-preferences/index.js +3 -0
- package/test-utils/selectors/collection-preferences/index.js.map +1 -1
- package/test-utils/selectors/collection-preferences/page-size-preference.js.map +1 -1
- package/test-utils/selectors/collection-preferences/visible-content-preference.js.map +1 -1
- package/test-utils/selectors/container/index.js.map +1 -1
- package/test-utils/selectors/content-layout/index.js.map +1 -1
- package/test-utils/selectors/date-picker/index.js +2 -2
- package/test-utils/selectors/date-picker/index.js.map +1 -1
- package/test-utils/selectors/date-range-picker/index.js +6 -3
- package/test-utils/selectors/date-range-picker/index.js.map +1 -1
- package/test-utils/selectors/expandable-section/index.js.map +1 -1
- package/test-utils/selectors/flashbar/flash.js.map +1 -1
- package/test-utils/selectors/flashbar/index.js.map +1 -1
- package/test-utils/selectors/form/index.js.map +1 -1
- package/test-utils/selectors/form-field/index.js.map +1 -1
- package/test-utils/selectors/grid/index.js.map +1 -1
- package/test-utils/selectors/header/index.js.map +1 -1
- package/test-utils/selectors/help-panel/index.js.map +1 -1
- package/test-utils/selectors/hotspot/index.js.map +1 -1
- package/test-utils/selectors/input/base-input.js.map +1 -1
- package/test-utils/selectors/input/index.js.map +1 -1
- package/test-utils/selectors/internal/abstract-switch.js.map +1 -1
- package/test-utils/selectors/internal/autosuggest-input.js.map +1 -1
- package/test-utils/selectors/internal/chart-filter.js.map +1 -1
- package/test-utils/selectors/internal/chart-legend.js.map +1 -1
- package/test-utils/selectors/internal/chart-popover.js.map +1 -1
- package/test-utils/selectors/internal/charts.js.map +1 -1
- package/test-utils/selectors/internal/dropdown-host.js.map +1 -1
- package/test-utils/selectors/internal/dropdown.js.map +1 -1
- package/test-utils/selectors/internal/filtering-token.js.map +1 -1
- package/test-utils/selectors/internal/option.js.map +1 -1
- package/test-utils/selectors/mixed-line-bar-chart/index.js.map +1 -1
- package/test-utils/selectors/modal/index.js.map +1 -1
- package/test-utils/selectors/multiselect/index.js.map +1 -1
- package/test-utils/selectors/pagination/index.js.map +1 -1
- package/test-utils/selectors/pie-chart/index.js.map +1 -1
- package/test-utils/selectors/popover/index.js.map +1 -1
- package/test-utils/selectors/progress-bar/index.js.map +1 -1
- package/test-utils/selectors/property-filter/index.js.map +1 -1
- package/test-utils/selectors/radio-group/index.js.map +1 -1
- package/test-utils/selectors/radio-group/radio-button.js.map +1 -1
- package/test-utils/selectors/s3-resource-selector/index.js.map +1 -1
- package/test-utils/selectors/segmented-control/index.js.map +1 -1
- package/test-utils/selectors/select/index.js.map +1 -1
- package/test-utils/selectors/side-navigation/index.js.map +1 -1
- package/test-utils/selectors/split-panel/index.js.map +1 -1
- package/test-utils/selectors/table/index.js +2 -1
- package/test-utils/selectors/table/index.js.map +1 -1
- package/test-utils/selectors/tabs/index.js.map +1 -1
- package/test-utils/selectors/tag-editor/index.js.map +1 -1
- package/test-utils/selectors/text-filter/index.js.map +1 -1
- package/test-utils/selectors/textarea/index.js.map +1 -1
- package/test-utils/selectors/tiles/index.js.map +1 -1
- package/test-utils/selectors/tiles/tile.js.map +1 -1
- package/test-utils/selectors/toggle/index.js.map +1 -1
- package/test-utils/selectors/token-group/index.js.map +1 -1
- package/test-utils/selectors/token-group/token.js.map +1 -1
- package/test-utils/selectors/top-navigation/1.0-beta/index.js.map +1 -1
- package/test-utils/selectors/top-navigation/index.js.map +1 -1
- package/test-utils/selectors/tutorial-panel/index.js.map +1 -1
- package/test-utils/selectors/tutorial-panel/tutorial.js.map +1 -1
- package/test-utils/selectors/wizard/index.js.map +1 -1
- package/test-utils/tsconfig.tsbuildinfo +1 -1
- package/theming/index.d.ts +1 -1
- package/theming/index.d.ts.map +1 -1
- package/token-group/internal.d.ts +1 -1
- package/token-group/internal.d.ts.map +1 -1
- package/top-navigation/1.0-beta/internal.d.ts +1 -1
- package/top-navigation/1.0-beta/internal.d.ts.map +1 -1
- package/top-navigation/internal.d.ts +1 -1
- package/top-navigation/internal.d.ts.map +1 -1
- package/top-navigation/parts/overflow-menu/menu-item.d.ts +2 -2
- package/top-navigation/parts/overflow-menu/menu-item.d.ts.map +1 -1
- package/top-navigation/parts/overflow-menu/menu-item.js.map +1 -1
- package/top-navigation/parts/overflow-menu/router.d.ts +1 -1
- package/top-navigation/parts/overflow-menu/router.d.ts.map +1 -1
- package/wizard/styles.css.js +32 -32
- package/wizard/styles.scoped.css +61 -60
- package/wizard/styles.selectors.js +32 -32
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-mouse-hover.js","sourceRoot":"","sources":["../../../../src/mixed-line-bar-chart/hooks/use-mouse-hover.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"use-mouse-hover.js","sourceRoot":"","sources":["../../../../src/mixed-line-bar-chart/hooks/use-mouse-hover.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAKxD,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAGtC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,IAAM,gBAAgB,GAAG,CAAC,CAAC;AAc3B,MAAM,UAAU,aAAa,CAAI,EAUT;QATtB,OAAO,aAAA,EACP,YAAY,kBAAA,EACZ,SAAS,eAAA,EACT,cAAc,oBAAA,EACd,cAAc,oBAAA,EACd,sBAAsB,4BAAA,EACtB,iBAAiB,uBAAA,EACjB,kBAAkB,wBAAA,EAClB,UAAU,gBAAA;IAEV,IAAM,iBAAiB,GAAG,UAAC,KAA+C;;QACxE,IAAM,OAAO,GAAI,KAAK,CAAC,MAAqB,CAAC,qBAAqB,EAAE,CAAC;QACrE,IAAM,OAAO,GAAG,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;QAE7C,IAAM,QAAQ,GAAG,YAAY;aAC1B,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,EAAH,CAAG,CAAC;aACb,MAAM,CAAC,UAAC,IAAI,EAAE,IAAI,IAAK,OAAA,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,I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AAM,cAAc,GAAG,UAAC,KAA+C;QACrE,IAAI,KAAK,CAAC,MAAM,KAAK,OAAO,CAAC,OAAQ,CAAC,GAAG,IAAI,CAAC,kBAAkB,EAAE;YAChE,IAAI,iBAAiB,EAAE;gBACrB,gBAAgB,CAAC,KAAK,CAAC,CAAC;aACzB;iBAAM,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;gBAClC,iBAAiB,CAAC,KAAK,CAAC,CAAC;aAC1B;SACF;IACH,CAAC,CAAC;IAEF,IAAM,aAAa,GAAG,UAAC,KAA+C;QACpE,IAAI,kBAAkB,EAAE;YACtB,OAAO;SACR;QACD,IACE,CAAC,YAAY,CAAC,OAAO,CAAC,OAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,aAAwB,CAAC;YACnE,wDAAwD;YACxD,CAAC,CAAC,KAAK,CAAC,aAAa,IAAK,KAAK,CAAC,aAAyB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;iBACpF,KAAK,CAAC,GAAG,CAAC;iBACV,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAC9B;YACA,UAAU,CAAC,IAAI,CAAC,CAAC;YACjB,sBAAsB,EAAE,CAAC;SAC1B;IACH,CAAC,CAAC;IAEF,OAAO,EAAE,cAAc,gBAAA,EAAE,aAAa,eAAA,EAAE,CAAC;AAC3C,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { nodeContains } from '../../internal/utils/dom';\n\nimport { ScaledBarGroup } from '../make-scaled-bar-groups';\nimport { ScaledPoint } from '../make-scaled-series';\n\nimport styles from '../styles.css.js';\nimport { ChartPlotRef } from '../../internal/components/chart-plot';\nimport { VerticalMarkerX } from '../interfaces';\nimport { isYThreshold } from '../utils';\n\nconst MAX_HOVER_MARGIN = 6;\n\nexport interface UseMouseHoverProps<T> {\n plotRef: React.RefObject<ChartPlotRef>;\n scaledSeries: ReadonlyArray<ScaledPoint<T>>;\n barGroups: ScaledBarGroup<T>[];\n highlightPoint: (point: ScaledPoint<T> | null) => void;\n highlightGroup: (groupIndex: number) => void;\n clearHighlightedSeries: () => void;\n isGroupNavigation: boolean;\n isHandlersDisabled: boolean;\n highlightX: (verticalMarker: VerticalMarkerX<T> | null) => void;\n}\n\nexport function useMouseHover<T>({\n plotRef,\n scaledSeries,\n barGroups,\n highlightPoint,\n highlightGroup,\n clearHighlightedSeries,\n isGroupNavigation,\n isHandlersDisabled,\n highlightX,\n}: UseMouseHoverProps<T>) {\n const onSeriesMouseMove = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n const svgRect = (event.target as SVGElement).getBoundingClientRect();\n const offsetX = event.clientX - svgRect.left;\n\n const closestX = scaledSeries\n .map(v => v.x)\n .reduce((prev, curr) => (Math.abs(curr - offsetX) < Math.abs(prev - offsetX) ? curr : prev), -Infinity);\n\n if (isFinite(closestX)) {\n const offsetY = event.clientY - svgRect.top;\n const closestY = scaledSeries\n .filter(v => v.x === closestX || isYThreshold(v.series))\n .map(v => v.y)\n .reduce((prev, curr) => (Math.abs(curr - offsetY) < Math.abs(prev - offsetY) ? curr : prev), -Infinity);\n\n if (\n isFinite(closestY) &&\n Math.abs(offsetX - closestX) < MAX_HOVER_MARGIN &&\n Math.abs(offsetY - closestY) < MAX_HOVER_MARGIN\n ) {\n const [{ color, datum, series }] = scaledSeries.filter(\n s => (s.x === closestX || isYThreshold(s.series)) && s.y === closestY\n );\n highlightPoint({ x: closestX, y: closestY, color, datum, series });\n } else {\n let datumX = null;\n for (const point of scaledSeries) {\n if (point.x === closestX) {\n datumX = point.datum?.x ?? null;\n break;\n }\n }\n highlightX({ scaledX: closestX, label: datumX });\n }\n }\n };\n\n const onGroupMouseMove = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n const svgRect = (event.target as SVGElement).getBoundingClientRect();\n const offsetX = event.clientX - svgRect.left;\n const offsetY = event.clientY - svgRect.top;\n\n // If hovering over some group - highlight it.\n for (let groupIndex = 0; groupIndex < barGroups.length; groupIndex++) {\n const {\n position: { x, y, width, height },\n } = barGroups[groupIndex];\n\n if (x <= offsetX && offsetX <= x + width && y <= offsetY && offsetY <= y + height) {\n highlightGroup(groupIndex);\n return;\n }\n }\n // Otherwise - clear the highlight.\n clearHighlightedSeries();\n };\n\n const onSVGMouseMove = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n if (event.target === plotRef.current!.svg && !isHandlersDisabled) {\n if (isGroupNavigation) {\n onGroupMouseMove(event);\n } else if (scaledSeries.length > 0) {\n onSeriesMouseMove(event);\n }\n }\n };\n\n const onSVGMouseOut = (event: React.MouseEvent<SVGElement, MouseEvent>) => {\n if (isHandlersDisabled) {\n return;\n }\n if (\n !nodeContains(plotRef.current!.svg, event.relatedTarget as Element) ||\n // `classList` is not supported on IE11 for SVG elements\n ((event.relatedTarget && (event.relatedTarget as Element).getAttribute('class')) || '')\n .split(' ')\n .indexOf(styles.series) > -1\n ) {\n highlightX(null);\n clearHighlightedSeries();\n }\n };\n\n return { onSVGMouseMove, onSVGMouseOut };\n}\n"]}
|
|
@@ -1,26 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { ChartContainerProps } from '../chart-container';
|
|
2
|
-
import { ChartDataTypes, MixedLineBarChartProps } from '../interfaces';
|
|
3
|
+
import { ChartDataTypes, MixedLineBarChartProps, VerticalMarkerX } from '../interfaces';
|
|
3
4
|
import { ChartScale, NumericChartScale } from '../../internal/components/cartesian-chart/scales';
|
|
4
5
|
import { ScaledPoint } from '../make-scaled-series';
|
|
5
6
|
import { ScaledBarGroup } from '../make-scaled-bar-groups';
|
|
6
|
-
export
|
|
7
|
+
export type UseNavigationProps<T extends ChartDataTypes> = Pick<ChartContainerProps<T>, 'highlightedSeries' | 'series' | 'visibleSeries'> & {
|
|
7
8
|
xScale: ChartScale;
|
|
8
9
|
yScale: NumericChartScale;
|
|
9
10
|
barGroups: ScaledBarGroup<T>[];
|
|
10
11
|
scaledSeries: ReadonlyArray<ScaledPoint<T>>;
|
|
11
12
|
highlightedPoint: ScaledPoint<T> | null;
|
|
12
13
|
highlightedGroupIndex: number | null;
|
|
13
|
-
legendSeries: null | MixedLineBarChartProps.ChartSeries<T>;
|
|
14
14
|
isHandlersDisabled: boolean;
|
|
15
15
|
pinPopover(pinned?: boolean): void;
|
|
16
16
|
highlightSeries(series: MixedLineBarChartProps.ChartSeries<T> | null): void;
|
|
17
17
|
highlightGroup(groupIndex: number): void;
|
|
18
18
|
highlightPoint(point: ScaledPoint<T> | null): void;
|
|
19
|
+
highlightX: (verticalMarker: VerticalMarkerX<T> | null) => void;
|
|
19
20
|
clearHighlightedSeries(): void;
|
|
21
|
+
verticalMarkerX: VerticalMarkerX<T> | null;
|
|
20
22
|
};
|
|
21
|
-
export declare function useNavigation<T extends ChartDataTypes>({ series, visibleSeries, scaledSeries, barGroups, xScale, yScale, highlightedPoint, highlightedGroupIndex, highlightedSeries,
|
|
23
|
+
export declare function useNavigation<T extends ChartDataTypes>({ series, visibleSeries, scaledSeries, barGroups, xScale, yScale, highlightedPoint, highlightedGroupIndex, highlightedSeries, isHandlersDisabled, pinPopover, highlightSeries, highlightGroup, highlightPoint, highlightX, verticalMarkerX, }: UseNavigationProps<T>): {
|
|
22
24
|
isGroupNavigation: boolean;
|
|
23
25
|
onFocus: () => void;
|
|
24
26
|
onKeyDown: (event: React.KeyboardEvent) => void;
|
|
27
|
+
xIndex: number;
|
|
25
28
|
};
|
|
26
29
|
//# sourceMappingURL=use-navigation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-navigation.d.ts","sourceRoot":"","sources":["../../../../src/mixed-line-bar-chart/hooks/use-navigation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-navigation.d.ts","sourceRoot":"","sources":["../../../../src/mixed-line-bar-chart/hooks/use-navigation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAyC,MA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,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CAC5C,CAAC;AAEF,wBAAgB,aAAa,CAAC,CAAC,SAAS,cAAc,EAAE,EACtD,MAAM,EACN,aAAa,EACb,YAAY,EACZ,SAAS,EACT,MAAM,EACN,MAAM,EACN,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,cAAc,EACd,cAAc,EACd,UAAU,EACV,eAAe,GAChB,EAAE,kBAAkB,CAAC,CAAC,CAAC;;;uBA0MZ,mBAAmB;;EA+B9B"}
|
|
@@ -5,33 +5,31 @@ import { useCallback, useMemo, useState } from 'react';
|
|
|
5
5
|
import { KeyCode } from '../../internal/keycode';
|
|
6
6
|
import { findNavigableSeries, isXThreshold, isYThreshold, nextValidDomainIndex } from '../utils';
|
|
7
7
|
export function useNavigation(_a) {
|
|
8
|
-
var series = _a.series, visibleSeries = _a.visibleSeries, scaledSeries = _a.scaledSeries, barGroups = _a.barGroups, xScale = _a.xScale, yScale = _a.yScale, highlightedPoint = _a.highlightedPoint, highlightedGroupIndex = _a.highlightedGroupIndex, highlightedSeries = _a.highlightedSeries,
|
|
8
|
+
var series = _a.series, visibleSeries = _a.visibleSeries, scaledSeries = _a.scaledSeries, barGroups = _a.barGroups, xScale = _a.xScale, yScale = _a.yScale, highlightedPoint = _a.highlightedPoint, highlightedGroupIndex = _a.highlightedGroupIndex, highlightedSeries = _a.highlightedSeries, isHandlersDisabled = _a.isHandlersDisabled, pinPopover = _a.pinPopover, highlightSeries = _a.highlightSeries, highlightGroup = _a.highlightGroup, highlightPoint = _a.highlightPoint, highlightX = _a.highlightX, verticalMarkerX = _a.verticalMarkerX;
|
|
9
9
|
var _b = useState(null), targetX = _b[0], setTargetX = _b[1];
|
|
10
|
+
var _c = useState(0), xIndex = _c[0], setXIndex = _c[1];
|
|
10
11
|
// There are two different types of navigation:
|
|
11
12
|
// 1) Group navigation for any chart that contains a bar series
|
|
12
13
|
// 2) Line navigation for any chart that only contains lines and thresholds
|
|
13
|
-
var isGroupNavigation = visibleSeries.some(function (_a) {
|
|
14
|
+
var isGroupNavigation = useMemo(function () { return visibleSeries.some(function (_a) {
|
|
14
15
|
var series = _a.series;
|
|
15
16
|
return series.type === 'bar';
|
|
16
|
-
});
|
|
17
|
+
}); }, [visibleSeries]);
|
|
17
18
|
// Make a list of series that can be navigated between. Bar series are treated as one.
|
|
18
19
|
var navigableSeries = useMemo(function () { return findNavigableSeries(visibleSeries); }, [visibleSeries]).navigableSeries;
|
|
20
|
+
var containsMultipleSeries = navigableSeries.length > 1;
|
|
19
21
|
var onBarGroupFocus = function () {
|
|
20
22
|
var groupIndex = highlightedGroupIndex !== null && highlightedGroupIndex !== void 0 ? highlightedGroupIndex : 0;
|
|
21
23
|
setTargetX(xScale.domain[groupIndex]);
|
|
22
24
|
highlightGroup(groupIndex);
|
|
23
25
|
};
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (scaledS.series === targetSeries) {
|
|
32
|
-
highlightPoint(scaledS);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
26
|
+
var onLineFocus = function () {
|
|
27
|
+
if (verticalMarkerX === null) {
|
|
28
|
+
if (containsMultipleSeries) {
|
|
29
|
+
moveToLineGroupIndex(0);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
moveBetweenSeries(0);
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
35
|
};
|
|
@@ -40,9 +38,21 @@ export function useNavigation(_a) {
|
|
|
40
38
|
onBarGroupFocus();
|
|
41
39
|
}
|
|
42
40
|
else {
|
|
43
|
-
|
|
41
|
+
onLineFocus();
|
|
44
42
|
}
|
|
45
43
|
};
|
|
44
|
+
// Returns all the unique X coordinates in scaledSeries.
|
|
45
|
+
// Assumes scaledSeries is sorted by `x`.
|
|
46
|
+
var allUniqueX = useMemo(function () {
|
|
47
|
+
var result = [];
|
|
48
|
+
for (var i = 0; i < scaledSeries.length; i += 1) {
|
|
49
|
+
var point = scaledSeries[i];
|
|
50
|
+
if (point !== undefined && (!result.length || result[result.length - 1].scaledX !== point.x)) {
|
|
51
|
+
result.push({ scaledX: point.x, datum: point.datum });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}, [scaledSeries]);
|
|
46
56
|
var moveBetweenSeries = useCallback(function (direction) {
|
|
47
57
|
var _a, _b, _c, _d;
|
|
48
58
|
if (isGroupNavigation) {
|
|
@@ -56,16 +66,23 @@ export function useNavigation(_a) {
|
|
|
56
66
|
previousSeriesIndex = navigableSeries.indexOf(highlightedSeries);
|
|
57
67
|
}
|
|
58
68
|
// Move forwards or backwards to the new series
|
|
69
|
+
// If index === -1, show all data points from all series at the given X instead of one single series
|
|
70
|
+
var firstPossibleIndex = containsMultipleSeries ? -1 : 0;
|
|
59
71
|
var nextSeriesIndex = 0;
|
|
60
|
-
if (previousSeriesIndex !==
|
|
72
|
+
if (previousSeriesIndex !== null) {
|
|
61
73
|
nextSeriesIndex = previousSeriesIndex + direction;
|
|
62
74
|
if (nextSeriesIndex > MAX_SERIES_INDEX) {
|
|
63
|
-
nextSeriesIndex =
|
|
75
|
+
nextSeriesIndex = firstPossibleIndex;
|
|
64
76
|
}
|
|
65
|
-
else if (nextSeriesIndex <
|
|
77
|
+
else if (nextSeriesIndex < firstPossibleIndex) {
|
|
66
78
|
nextSeriesIndex = MAX_SERIES_INDEX;
|
|
67
79
|
}
|
|
68
80
|
}
|
|
81
|
+
if (nextSeriesIndex === -1) {
|
|
82
|
+
highlightSeries(null);
|
|
83
|
+
highlightPoint(null);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
69
86
|
var nextSeries = navigableSeries[nextSeriesIndex];
|
|
70
87
|
var nextInternalSeries = series.filter(function (_a) {
|
|
71
88
|
var series = _a.series;
|
|
@@ -79,12 +96,10 @@ export function useNavigation(_a) {
|
|
|
79
96
|
if (nextSeries.type === 'line') {
|
|
80
97
|
var nextScaledSeries = scaledSeries.filter(function (it) { return it.series === nextSeries; });
|
|
81
98
|
var closestNextSeriesPoint = nextScaledSeries.reduce(function (prev, curr) { return (Math.abs(curr.x - targetXPoint) < Math.abs(prev.x - targetXPoint) ? curr : prev); }, { x: -Infinity, y: -Infinity });
|
|
82
|
-
highlightSeries(nextSeries);
|
|
83
99
|
highlightPoint(__assign(__assign({}, closestNextSeriesPoint), { color: nextInternalSeries.color, series: nextSeries }));
|
|
84
100
|
}
|
|
85
101
|
else if (isYThreshold(nextSeries)) {
|
|
86
102
|
var scaledTargetIndex = scaledSeries.map(function (it) { var _a; return ((_a = it.datum) === null || _a === void 0 ? void 0 : _a.x) || null; }).indexOf(targetX);
|
|
87
|
-
highlightSeries(nextSeries);
|
|
88
103
|
highlightPoint({
|
|
89
104
|
x: targetXPoint,
|
|
90
105
|
y: (_b = yScale.d3Scale(nextSeries.y)) !== null && _b !== void 0 ? _b : NaN,
|
|
@@ -94,7 +109,6 @@ export function useNavigation(_a) {
|
|
|
94
109
|
});
|
|
95
110
|
}
|
|
96
111
|
else if (isXThreshold(nextSeries)) {
|
|
97
|
-
highlightSeries(nextSeries);
|
|
98
112
|
highlightPoint({
|
|
99
113
|
x: (_d = xScale.d3Scale(nextSeries.x)) !== null && _d !== void 0 ? _d : NaN,
|
|
100
114
|
y: yScale.d3Scale.range()[0],
|
|
@@ -108,24 +122,25 @@ export function useNavigation(_a) {
|
|
|
108
122
|
xScale,
|
|
109
123
|
navigableSeries,
|
|
110
124
|
highlightedSeries,
|
|
111
|
-
|
|
112
|
-
series,
|
|
113
|
-
targetX,
|
|
125
|
+
containsMultipleSeries,
|
|
114
126
|
highlightSeries,
|
|
115
127
|
highlightPoint,
|
|
128
|
+
series,
|
|
129
|
+
targetX,
|
|
130
|
+
scaledSeries,
|
|
116
131
|
yScale,
|
|
117
132
|
]);
|
|
118
133
|
var moveWithinSeries = useCallback(function (direction) {
|
|
119
134
|
var _a;
|
|
120
135
|
var series = highlightedSeries || visibleSeries[0].series;
|
|
121
|
-
var previousPoint = highlightedPoint || scaledSeries[0];
|
|
122
136
|
if (series.type === 'line' || isYThreshold(series)) {
|
|
123
137
|
var targetScaledSeries = scaledSeries.filter(function (it) { return it.series === series; });
|
|
138
|
+
var previousPoint = highlightedPoint || targetScaledSeries[0];
|
|
124
139
|
var indexOfPreviousPoint = targetScaledSeries.map(function (it) { return it.x; }).indexOf(previousPoint.x);
|
|
125
140
|
var nextPointIndex = circleIndex(indexOfPreviousPoint + direction, [0, targetScaledSeries.length - 1]);
|
|
126
141
|
var nextPoint = targetScaledSeries[nextPointIndex];
|
|
127
142
|
setTargetX(((_a = nextPoint.datum) === null || _a === void 0 ? void 0 : _a.x) || null);
|
|
128
|
-
|
|
143
|
+
setXIndex(nextPointIndex);
|
|
129
144
|
highlightPoint(nextPoint);
|
|
130
145
|
}
|
|
131
146
|
else if (series.type === 'bar') {
|
|
@@ -149,15 +164,30 @@ export function useNavigation(_a) {
|
|
|
149
164
|
}, [
|
|
150
165
|
highlightedSeries,
|
|
151
166
|
visibleSeries,
|
|
152
|
-
highlightedPoint,
|
|
153
167
|
scaledSeries,
|
|
154
|
-
|
|
168
|
+
highlightedPoint,
|
|
155
169
|
highlightPoint,
|
|
156
170
|
xScale.domain,
|
|
157
171
|
highlightedGroupIndex,
|
|
158
172
|
barGroups,
|
|
159
173
|
highlightGroup,
|
|
160
174
|
]);
|
|
175
|
+
var moveToLineGroupIndex = useCallback(function (index) {
|
|
176
|
+
var _a, _b, _c, _d;
|
|
177
|
+
var point = allUniqueX[index];
|
|
178
|
+
setXIndex(index);
|
|
179
|
+
setTargetX(((_a = point.datum) === null || _a === void 0 ? void 0 : _a.x) || null);
|
|
180
|
+
highlightX({ scaledX: (_b = point === null || point === void 0 ? void 0 : point.scaledX) !== null && _b !== void 0 ? _b : null, label: (_d = (_c = point.datum) === null || _c === void 0 ? void 0 : _c.x) !== null && _d !== void 0 ? _d : null });
|
|
181
|
+
}, [allUniqueX, highlightX]);
|
|
182
|
+
var moveWithinXAxis = useCallback(function (direction) {
|
|
183
|
+
if (highlightedSeries || isGroupNavigation) {
|
|
184
|
+
moveWithinSeries(direction);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
var nextPointGroupIndex = circleIndex(xIndex + direction, [0, allUniqueX.length - 1]);
|
|
188
|
+
moveToLineGroupIndex(nextPointGroupIndex);
|
|
189
|
+
}
|
|
190
|
+
}, [highlightedSeries, isGroupNavigation, moveWithinSeries, xIndex, allUniqueX.length, moveToLineGroupIndex]);
|
|
161
191
|
var onKeyDown = useCallback(function (event) {
|
|
162
192
|
var keyCode = event.keyCode;
|
|
163
193
|
if (keyCode !== KeyCode.up &&
|
|
@@ -176,13 +206,13 @@ export function useNavigation(_a) {
|
|
|
176
206
|
moveBetweenSeries(keyCode === KeyCode.down ? 1 : -1);
|
|
177
207
|
}
|
|
178
208
|
else if (keyCode === KeyCode.left || keyCode === KeyCode.right) {
|
|
179
|
-
|
|
209
|
+
moveWithinXAxis(keyCode === KeyCode.right ? 1 : -1);
|
|
180
210
|
}
|
|
181
211
|
else if (keyCode === KeyCode.enter || keyCode === KeyCode.space) {
|
|
182
212
|
pinPopover();
|
|
183
213
|
}
|
|
184
|
-
}, [
|
|
185
|
-
return { isGroupNavigation: isGroupNavigation, onFocus: onFocus, onKeyDown: onKeyDown };
|
|
214
|
+
}, [isHandlersDisabled, moveBetweenSeries, moveWithinXAxis, pinPopover]);
|
|
215
|
+
return { isGroupNavigation: isGroupNavigation, onFocus: onFocus, onKeyDown: onKeyDown, xIndex: xIndex };
|
|
186
216
|
}
|
|
187
217
|
// Returns given index if it is in range or the opposite range boundary otherwise.
|
|
188
218
|
function circleIndex(index, _a) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-navigation.js","sourceRoot":"","sources":["../../../../src/mixed-line-bar-chart/hooks/use-navigation.ts"],"names":[],"mappings":";AAAA,qEAAqE;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AAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACtD;aAAM,IAAI,OAAO,KAAK,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,OAAO,CAAC,KAAK,EAAE;YACjE,UAAU,EAAE,CAAC;SACd;IACH,CAAC,EACD,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,UAAU,CAAC,CACtE,CAAC;IAEF,OAAO,EAAE,iBAAiB,mBAAA,EAAE,OAAO,SAAA,EAAE,SAAS,WAAA,EAAE,CAAC;AACnD,CAAC;AAED,kFAAkF;AAClF,SAAS,WAAW,CAAC,KAAa,EAAE,EAA4B;QAA3B,IAAI,QAAA,EAAE,EAAE,QAAA;IAC3C,IAAI,KAAK,GAAG,IAAI,EAAE;QAChB,OAAO,EAAE,CAAC;KACX;IACD,IAAI,KAAK,GAAG,EAAE,EAAE;QACd,OAAO,IAAI,CAAC;KACb;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useCallback, useMemo, useState } from 'react';\nimport { KeyCode } from '../../internal/keycode';\nimport { ChartContainerProps } from '../chart-container';\nimport { ChartDataTypes, MixedLineBarChartProps } from '../interfaces';\nimport { ChartScale, NumericChartScale } from '../../internal/components/cartesian-chart/scales';\nimport { findNavigableSeries, isXThreshold, isYThreshold, nextValidDomainIndex } from '../utils';\nimport { ScaledPoint } from '../make-scaled-series';\nimport { ScaledBarGroup } from '../make-scaled-bar-groups';\n\nexport type UseNavigationProps<T extends ChartDataTypes> = Pick<\n ChartContainerProps<T>,\n 'highlightedSeries' | 'series' | 'visibleSeries'\n> & {\n xScale: ChartScale;\n yScale: NumericChartScale;\n barGroups: ScaledBarGroup<T>[];\n scaledSeries: ReadonlyArray<ScaledPoint<T>>;\n\n highlightedPoint: ScaledPoint<T> | null;\n highlightedGroupIndex: number | null;\n legendSeries: null | MixedLineBarChartProps.ChartSeries<T>;\n isHandlersDisabled: boolean;\n\n pinPopover(pinned?: boolean): void;\n highlightSeries(series: MixedLineBarChartProps.ChartSeries<T> | null): void;\n highlightGroup(groupIndex: number): void;\n highlightPoint(point: ScaledPoint<T> | null): void;\n clearHighlightedSeries(): void;\n};\n\nexport function useNavigation<T extends ChartDataTypes>({\n series,\n visibleSeries,\n scaledSeries,\n barGroups,\n xScale,\n yScale,\n highlightedPoint,\n highlightedGroupIndex,\n highlightedSeries,\n legendSeries,\n isHandlersDisabled,\n pinPopover,\n highlightSeries,\n highlightGroup,\n highlightPoint,\n}: UseNavigationProps<T>) {\n const [targetX, setTargetX] = useState<T | null>(null);\n\n // There are two different types of navigation:\n // 1) Group navigation for any chart that contains a bar series\n // 2) Line navigation for any chart that only contains lines and thresholds\n const isGroupNavigation = visibleSeries.some(({ series }) => series.type === 'bar');\n\n // Make a list of series that can be navigated between. Bar series are treated as one.\n const { navigableSeries } = useMemo(() => findNavigableSeries(visibleSeries), [visibleSeries]);\n\n const onBarGroupFocus = () => {\n const groupIndex = highlightedGroupIndex ?? 0;\n setTargetX((xScale.domain as T[])[groupIndex]);\n highlightGroup(groupIndex);\n };\n\n const onLineGroupFocus = () => {\n if (!highlightedSeries || !highlightedPoint) {\n const targetSeries = highlightedSeries ?? legendSeries ?? series[0]?.series ?? null;\n highlightSeries(targetSeries);\n for (const scaledS of scaledSeries) {\n if (scaledS.series === targetSeries) {\n highlightPoint(scaledS);\n return;\n }\n }\n }\n };\n\n const onFocus = () => {\n if (isGroupNavigation) {\n onBarGroupFocus();\n } else {\n onLineGroupFocus();\n }\n };\n\n const moveBetweenSeries = useCallback(\n (direction: number) => {\n if (isGroupNavigation) {\n return;\n }\n\n const xOffset = xScale.isCategorical() ? Math.max(0, xScale.d3Scale.bandwidth() - 1) / 2 : 0;\n const MAX_SERIES_INDEX = navigableSeries.length - 1;\n\n // Find the index of the currently highlighted series (if any)\n let previousSeriesIndex = -1;\n if (highlightedSeries) {\n previousSeriesIndex = navigableSeries.indexOf(highlightedSeries);\n }\n\n // Move forwards or backwards to the new series\n let nextSeriesIndex = 0;\n if (previousSeriesIndex !== -1) {\n nextSeriesIndex = previousSeriesIndex + direction;\n if (nextSeriesIndex > MAX_SERIES_INDEX) {\n nextSeriesIndex = 0;\n } else if (nextSeriesIndex < 0) {\n nextSeriesIndex = MAX_SERIES_INDEX;\n }\n }\n\n const nextSeries = navigableSeries[nextSeriesIndex];\n const nextInternalSeries = series.filter(({ series }) => series === nextSeries)[0];\n\n // 2. Find point in the next series\n let targetXPoint = (xScale.d3Scale(targetX as any) ?? NaN) + xOffset;\n if (!isFinite(targetXPoint)) {\n targetXPoint = 0;\n }\n\n if (nextSeries.type === 'line') {\n const nextScaledSeries = scaledSeries.filter(it => it.series === nextSeries);\n const closestNextSeriesPoint = nextScaledSeries.reduce(\n (prev, curr) => (Math.abs(curr.x - targetXPoint) < Math.abs(prev.x - targetXPoint) ? curr : prev),\n { x: -Infinity, y: -Infinity }\n );\n highlightSeries(nextSeries);\n highlightPoint({ ...closestNextSeriesPoint, color: nextInternalSeries.color, series: nextSeries });\n } else if (isYThreshold(nextSeries)) {\n const scaledTargetIndex = scaledSeries.map(it => it.datum?.x || null).indexOf(targetX);\n highlightSeries(nextSeries);\n highlightPoint({\n x: targetXPoint,\n y: yScale.d3Scale(nextSeries.y) ?? NaN,\n color: nextInternalSeries.color,\n series: nextSeries,\n datum: scaledSeries[scaledTargetIndex]?.datum,\n });\n } else if (isXThreshold(nextSeries)) {\n highlightSeries(nextSeries);\n highlightPoint({\n x: xScale.d3Scale(nextSeries.x as any) ?? NaN,\n y: yScale.d3Scale.range()[0],\n color: nextInternalSeries.color,\n series: nextSeries,\n datum: { x: nextSeries.x, y: NaN },\n });\n }\n },\n [\n isGroupNavigation,\n xScale,\n navigableSeries,\n highlightedSeries,\n scaledSeries,\n series,\n targetX,\n highlightSeries,\n highlightPoint,\n yScale,\n ]\n );\n\n const moveWithinSeries = useCallback(\n (direction: number) => {\n const series = highlightedSeries || visibleSeries[0].series;\n const previousPoint = highlightedPoint || scaledSeries[0];\n\n if (series.type === 'line' || isYThreshold(series)) {\n const targetScaledSeries = scaledSeries.filter(it => it.series === series);\n const indexOfPreviousPoint = targetScaledSeries.map(it => it.x).indexOf(previousPoint.x);\n const nextPointIndex = circleIndex(indexOfPreviousPoint + direction, [0, targetScaledSeries.length - 1]);\n const nextPoint = targetScaledSeries[nextPointIndex];\n\n setTargetX(nextPoint.datum?.x || null);\n highlightSeries(series);\n highlightPoint(nextPoint);\n } else if (series.type === 'bar') {\n const xDomain = xScale.domain as T[];\n const MAX_GROUP_INDEX = xDomain.length - 1;\n\n let nextGroupIndex = 0;\n if (highlightedGroupIndex !== null) {\n // find next group\n nextGroupIndex = highlightedGroupIndex + direction;\n if (nextGroupIndex > MAX_GROUP_INDEX) {\n nextGroupIndex = 0;\n } else if (nextGroupIndex < 0) {\n nextGroupIndex = MAX_GROUP_INDEX;\n }\n }\n\n const nextDomainIndex = nextValidDomainIndex(nextGroupIndex, barGroups, direction);\n setTargetX(xDomain[nextDomainIndex]);\n highlightGroup(nextDomainIndex);\n }\n },\n [\n highlightedSeries,\n visibleSeries,\n highlightedPoint,\n scaledSeries,\n highlightSeries,\n highlightPoint,\n xScale.domain,\n highlightedGroupIndex,\n barGroups,\n highlightGroup,\n ]\n );\n\n const onKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n const keyCode = event.keyCode;\n if (\n keyCode !== KeyCode.up &&\n keyCode !== KeyCode.right &&\n keyCode !== KeyCode.down &&\n keyCode !== KeyCode.left &&\n keyCode !== KeyCode.space &&\n keyCode !== KeyCode.enter\n ) {\n return;\n }\n\n event.preventDefault();\n\n if (isHandlersDisabled) {\n return;\n }\n\n if (keyCode === KeyCode.down || keyCode === KeyCode.up) {\n moveBetweenSeries(keyCode === KeyCode.down ? 1 : -1);\n } else if (keyCode === KeyCode.left || keyCode === KeyCode.right) {\n moveWithinSeries(keyCode === KeyCode.right ? 1 : -1);\n } else if (keyCode === KeyCode.enter || keyCode === KeyCode.space) {\n pinPopover();\n }\n },\n [moveWithinSeries, moveBetweenSeries, isHandlersDisabled, pinPopover]\n );\n\n return { isGroupNavigation, onFocus, onKeyDown };\n}\n\n// Returns given index if it is in range or the opposite range boundary otherwise.\nfunction circleIndex(index: number, [from, to]: [number, number]): number {\n if (index < from) {\n return to;\n }\n if (index > to) {\n return from;\n }\n return index;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"use-navigation.js","sourceRoot":"","sources":["../../../../src/mixed-line-bar-chart/hooks/use-navigation.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAc,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAIjD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AA0BjG,MAAM,UAAU,aAAa,CAA2B,EAiBhC;QAhBtB,MAAM,YAAA,EACN,aAAa,mBAAA,EACb,YAAY,kBAAA,EACZ,SAAS,eAAA,EACT,MAAM,YAAA,EACN,MAAM,YAAA,EACN,gBAAgB,sBAAA,EAChB,qBAAqB,2BAAA,EACrB,iBAAiB,uBAAA,EACjB,kBAAkB,wBAAA,EAClB,UAAU,gBAAA,EACV,eAAe,qBAAA,EACf,cAAc,oBAAA,EACd,cAAc,oBAAA,EACd,UAAU,gBAAA,EACV,eAAe,qBAAA;IAET,IAAA,KAAwB,QAAQ,CAAW,IAAI,CAAC,EAA/C,OAAO,QAAA,EAAE,UAAU,QAA4B,CAAC;IACjD,IAAA,KAAsB,QAAQ,CAAC,CAAC,CAAC,EAAhC,MAAM,QAAA,EAAE,SAAS,QAAe,CAAC;IAExC,+CAA+C;IAC/C,+DAA+D;IAC/D,2EAA2E;IAC3E,IAAM,iB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;AAClF,SAAS,WAAW,CAAC,KAAa,EAAE,EAA4B;QAA3B,IAAI,QAAA,EAAE,EAAE,QAAA;IAC3C,IAAI,KAAK,GAAG,IAAI,EAAE;QAChB,OAAO,EAAE,CAAC;KACX;IACD,IAAI,KAAK,GAAG,EAAE,EAAE;QACd,OAAO,IAAI,CAAC;KACb;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useMemo, useState } from 'react';\nimport { KeyCode } from '../../internal/keycode';\nimport { ChartContainerProps } from '../chart-container';\nimport { ChartDataTypes, MixedLineBarChartProps, VerticalMarkerX } from '../interfaces';\nimport { ChartScale, NumericChartScale } from '../../internal/components/cartesian-chart/scales';\nimport { findNavigableSeries, isXThreshold, isYThreshold, nextValidDomainIndex } from '../utils';\nimport { ScaledPoint } from '../make-scaled-series';\nimport { ScaledBarGroup } from '../make-scaled-bar-groups';\n\nexport type UseNavigationProps<T extends ChartDataTypes> = Pick<\n ChartContainerProps<T>,\n 'highlightedSeries' | 'series' | 'visibleSeries'\n> & {\n xScale: ChartScale;\n yScale: NumericChartScale;\n barGroups: ScaledBarGroup<T>[];\n scaledSeries: ReadonlyArray<ScaledPoint<T>>;\n\n highlightedPoint: ScaledPoint<T> | null;\n highlightedGroupIndex: number | null;\n isHandlersDisabled: boolean;\n\n pinPopover(pinned?: boolean): void;\n highlightSeries(series: MixedLineBarChartProps.ChartSeries<T> | null): void;\n highlightGroup(groupIndex: number): void;\n highlightPoint(point: ScaledPoint<T> | null): void;\n highlightX: (verticalMarker: VerticalMarkerX<T> | null) => void;\n clearHighlightedSeries(): void;\n verticalMarkerX: VerticalMarkerX<T> | null;\n};\n\nexport function useNavigation<T extends ChartDataTypes>({\n series,\n visibleSeries,\n scaledSeries,\n barGroups,\n xScale,\n yScale,\n highlightedPoint,\n highlightedGroupIndex,\n highlightedSeries,\n isHandlersDisabled,\n pinPopover,\n highlightSeries,\n highlightGroup,\n highlightPoint,\n highlightX,\n verticalMarkerX,\n}: UseNavigationProps<T>) {\n const [targetX, setTargetX] = useState<T | null>(null);\n const [xIndex, setXIndex] = useState(0);\n\n // There are two different types of navigation:\n // 1) Group navigation for any chart that contains a bar series\n // 2) Line navigation for any chart that only contains lines and thresholds\n const isGroupNavigation = useMemo(() => visibleSeries.some(({ series }) => series.type === 'bar'), [visibleSeries]);\n\n // Make a list of series that can be navigated between. Bar series are treated as one.\n const { navigableSeries } = useMemo(() => findNavigableSeries(visibleSeries), [visibleSeries]);\n const containsMultipleSeries = navigableSeries.length > 1;\n\n const onBarGroupFocus = () => {\n const groupIndex = highlightedGroupIndex ?? 0;\n setTargetX((xScale.domain as T[])[groupIndex]);\n highlightGroup(groupIndex);\n };\n\n const onLineFocus = () => {\n if (verticalMarkerX === null) {\n if (containsMultipleSeries) {\n moveToLineGroupIndex(0);\n } else {\n moveBetweenSeries(0);\n }\n }\n };\n\n const onFocus = () => {\n if (isGroupNavigation) {\n onBarGroupFocus();\n } else {\n onLineFocus();\n }\n };\n\n // Returns all the unique X coordinates in scaledSeries.\n // Assumes scaledSeries is sorted by `x`.\n const allUniqueX = useMemo(() => {\n const result = [];\n for (let i = 0; i < scaledSeries.length; i += 1) {\n const point = scaledSeries[i];\n if (point !== undefined && (!result.length || result[result.length - 1].scaledX !== point.x)) {\n result.push({ scaledX: point.x, datum: point.datum });\n }\n }\n return result;\n }, [scaledSeries]);\n\n const moveBetweenSeries = useCallback(\n (direction: number) => {\n if (isGroupNavigation) {\n return;\n }\n\n const xOffset = xScale.isCategorical() ? Math.max(0, xScale.d3Scale.bandwidth() - 1) / 2 : 0;\n const MAX_SERIES_INDEX = navigableSeries.length - 1;\n\n // Find the index of the currently highlighted series (if any)\n let previousSeriesIndex = -1;\n if (highlightedSeries) {\n previousSeriesIndex = navigableSeries.indexOf(highlightedSeries);\n }\n\n // Move forwards or backwards to the new series\n // If index === -1, show all data points from all series at the given X instead of one single series\n const firstPossibleIndex = containsMultipleSeries ? -1 : 0;\n let nextSeriesIndex = 0;\n if (previousSeriesIndex !== null) {\n nextSeriesIndex = previousSeriesIndex + direction;\n if (nextSeriesIndex > MAX_SERIES_INDEX) {\n nextSeriesIndex = firstPossibleIndex;\n } else if (nextSeriesIndex < firstPossibleIndex) {\n nextSeriesIndex = MAX_SERIES_INDEX;\n }\n }\n if (nextSeriesIndex === -1) {\n highlightSeries(null);\n highlightPoint(null);\n return;\n }\n const nextSeries = navigableSeries[nextSeriesIndex];\n const nextInternalSeries = series.filter(({ series }) => series === nextSeries)[0];\n\n // 2. Find point in the next series\n let targetXPoint = (xScale.d3Scale(targetX as any) ?? NaN) + xOffset;\n if (!isFinite(targetXPoint)) {\n targetXPoint = 0;\n }\n\n if (nextSeries.type === 'line') {\n const nextScaledSeries = scaledSeries.filter(it => it.series === nextSeries);\n const closestNextSeriesPoint = nextScaledSeries.reduce(\n (prev, curr) => (Math.abs(curr.x - targetXPoint) < Math.abs(prev.x - targetXPoint) ? curr : prev),\n { x: -Infinity, y: -Infinity }\n );\n highlightPoint({ ...closestNextSeriesPoint, color: nextInternalSeries.color, series: nextSeries });\n } else if (isYThreshold(nextSeries)) {\n const scaledTargetIndex = scaledSeries.map(it => it.datum?.x || null).indexOf(targetX);\n highlightPoint({\n x: targetXPoint,\n y: yScale.d3Scale(nextSeries.y) ?? NaN,\n color: nextInternalSeries.color,\n series: nextSeries,\n datum: scaledSeries[scaledTargetIndex]?.datum,\n });\n } else if (isXThreshold(nextSeries)) {\n highlightPoint({\n x: xScale.d3Scale(nextSeries.x as any) ?? NaN,\n y: yScale.d3Scale.range()[0],\n color: nextInternalSeries.color,\n series: nextSeries,\n datum: { x: nextSeries.x, y: NaN },\n });\n }\n },\n [\n isGroupNavigation,\n xScale,\n navigableSeries,\n highlightedSeries,\n containsMultipleSeries,\n highlightSeries,\n highlightPoint,\n series,\n targetX,\n scaledSeries,\n yScale,\n ]\n );\n\n const moveWithinSeries = useCallback(\n (direction: number) => {\n const series = highlightedSeries || visibleSeries[0].series;\n\n if (series.type === 'line' || isYThreshold(series)) {\n const targetScaledSeries = scaledSeries.filter(it => it.series === series);\n const previousPoint = highlightedPoint || targetScaledSeries[0];\n const indexOfPreviousPoint = targetScaledSeries.map(it => it.x).indexOf(previousPoint.x);\n const nextPointIndex = circleIndex(indexOfPreviousPoint + direction, [0, targetScaledSeries.length - 1]);\n const nextPoint = targetScaledSeries[nextPointIndex];\n\n setTargetX(nextPoint.datum?.x || null);\n setXIndex(nextPointIndex);\n highlightPoint(nextPoint);\n } else if (series.type === 'bar') {\n const xDomain = xScale.domain as T[];\n const MAX_GROUP_INDEX = xDomain.length - 1;\n\n let nextGroupIndex = 0;\n if (highlightedGroupIndex !== null) {\n // find next group\n nextGroupIndex = highlightedGroupIndex + direction;\n if (nextGroupIndex > MAX_GROUP_INDEX) {\n nextGroupIndex = 0;\n } else if (nextGroupIndex < 0) {\n nextGroupIndex = MAX_GROUP_INDEX;\n }\n }\n\n const nextDomainIndex = nextValidDomainIndex(nextGroupIndex, barGroups, direction);\n setTargetX(xDomain[nextDomainIndex]);\n highlightGroup(nextDomainIndex);\n }\n },\n [\n highlightedSeries,\n visibleSeries,\n scaledSeries,\n highlightedPoint,\n highlightPoint,\n xScale.domain,\n highlightedGroupIndex,\n barGroups,\n highlightGroup,\n ]\n );\n\n const moveToLineGroupIndex = useCallback(\n (index: number) => {\n const point = allUniqueX[index];\n setXIndex(index);\n setTargetX(point.datum?.x || null);\n highlightX({ scaledX: point?.scaledX ?? null, label: point.datum?.x ?? null });\n },\n [allUniqueX, highlightX]\n );\n\n const moveWithinXAxis = useCallback(\n (direction: number) => {\n if (highlightedSeries || isGroupNavigation) {\n moveWithinSeries(direction);\n } else {\n const nextPointGroupIndex = circleIndex(xIndex + direction, [0, allUniqueX.length - 1]);\n moveToLineGroupIndex(nextPointGroupIndex);\n }\n },\n [highlightedSeries, isGroupNavigation, moveWithinSeries, xIndex, allUniqueX.length, moveToLineGroupIndex]\n );\n\n const onKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n const keyCode = event.keyCode;\n if (\n keyCode !== KeyCode.up &&\n keyCode !== KeyCode.right &&\n keyCode !== KeyCode.down &&\n keyCode !== KeyCode.left &&\n keyCode !== KeyCode.space &&\n keyCode !== KeyCode.enter\n ) {\n return;\n }\n\n event.preventDefault();\n\n if (isHandlersDisabled) {\n return;\n }\n\n if (keyCode === KeyCode.down || keyCode === KeyCode.up) {\n moveBetweenSeries(keyCode === KeyCode.down ? 1 : -1);\n } else if (keyCode === KeyCode.left || keyCode === KeyCode.right) {\n moveWithinXAxis(keyCode === KeyCode.right ? 1 : -1);\n } else if (keyCode === KeyCode.enter || keyCode === KeyCode.space) {\n pinPopover();\n }\n },\n [isHandlersDisabled, moveBetweenSeries, moveWithinXAxis, pinPopover]\n );\n\n return { isGroupNavigation, onFocus, onKeyDown, xIndex };\n}\n\n// Returns given index if it is in range or the opposite range boundary otherwise.\nfunction circleIndex(index: number, [from, to]: [number, number]): number {\n if (index < from) {\n return to;\n }\n if (index > to) {\n return from;\n }\n return index;\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CartesianChartProps } from '../internal/components/cartesian-chart/interfaces';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
2
|
+
export type ChartDataTypes = number | string | Date;
|
|
3
|
+
export type SeriesType = 'line' | 'bar';
|
|
4
|
+
export type ScaleType = 'linear' | 'log' | 'time' | 'categorical';
|
|
5
|
+
export type ScaleRange = [number, number];
|
|
6
6
|
export interface InternalChartSeries<T> {
|
|
7
7
|
index: number;
|
|
8
8
|
color: string;
|
|
@@ -78,4 +78,8 @@ export declare namespace MixedLineBarChartProps {
|
|
|
78
78
|
export type I18nStrings<T> = CartesianChartProps.I18nStrings<T>;
|
|
79
79
|
export {};
|
|
80
80
|
}
|
|
81
|
+
export interface VerticalMarkerX<T> {
|
|
82
|
+
scaledX: number;
|
|
83
|
+
label: T | null;
|
|
84
|
+
}
|
|
81
85
|
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAC;AAExF,
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAC;AAExF,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAEpD,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,KAAK,CAAC;AACxC,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,aAAa,CAAC;AAClE,MAAM,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE1C,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,sBAAsB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;CAC/C;AAED,MAAM,WAAW,sBAAsB,CAAC,CAAC,SAAS,cAAc,CAC9D,SAAQ,mBAAmB,CAAC,CAAC,EAAE,sBAAsB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IACrE;;;;;;;;;;OAUG;IACH,MAAM,EAAE,aAAa,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAE7D;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAA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ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { CartesianChartProps } from '../internal/components/cartesian-chart/interfaces';\n\nexport type ChartDataTypes = number | string | Date;\n\nexport type SeriesType = 'line' | 'bar';\nexport type ScaleType = 'linear' | 'log' | 'time' | 'categorical';\nexport type ScaleRange = [number, number];\n\nexport interface InternalChartSeries<T> {\n index: number;\n color: string;\n series: MixedLineBarChartProps.ChartSeries<T>;\n}\n\nexport interface MixedLineBarChartProps<T extends ChartDataTypes>\n extends CartesianChartProps<T, MixedLineBarChartProps.ChartSeries<T>> {\n /**\n * Array that represents the source of data for the displayed chart.\n * Each element can represent a line series, bar series, or a threshold, and can have the following properties:\n *\n * * `title` (string): A human-readable title for this series.\n * * `type` (string): Series type (`\"line\"`, `\"bar\"`, or `\"threshold\"`).\n * * `data` (Array): For line and bar series, an array of data points, represented as objects with `x` and `y` properties.\n * * `y` (number): For threshold series, the value of the threshold.\n * * `color` (string): (Optional) A color hex value for this series. When assigned, it takes priority over the automatically assigned color.\n * * `valueFormatter` (Function): (Optional) A function that formats data values before rendering in the UI, For example, in the details popover.\n */\n series: ReadonlyArray<MixedLineBarChartProps.ChartSeries<T>>;\n\n /**\n * When set to `true`, bars in the same data point are stacked instead of grouped next to each other.\n */\n stackedBars?: boolean;\n\n /**\n * When set to `true`, the x and y axes are flipped, which causes any bars to be rendered horizontally instead of vertically.\n * This can only be used when the chart consists exclusively of bar series.\n */\n horizontalBars?: boolean;\n\n /**\n * When set to `true`, adds a visual emphasis on the zero baseline axis.\n * See the usage guidelines for more details.\n */\n emphasizeBaselineAxis?: boolean;\n}\n\nexport namespace MixedLineBarChartProps {\n export interface Datum<T> {\n x: T;\n y: number;\n }\n\n interface IDataSeries<T> {\n type: 'line' | 'bar' | 'threshold';\n title: string;\n color?: string;\n\n // This makes sure that the element type of the array is reduced to just one type,\n // even if `T` is a union type, e.g. `number | string`.\n data: T extends unknown ? ReadonlyArray<Datum<T>> : ReadonlyArray<Datum<T>>;\n valueFormatter?: T extends unknown\n ? CartesianChartProps.ValueFormatter<number, T>\n : CartesianChartProps.ValueFormatter<number, T>;\n }\n\n export interface BarDataSeries<T> extends IDataSeries<T> {\n type: 'bar';\n }\n\n export interface LineDataSeries<T> extends IDataSeries<T> {\n type: 'line';\n }\n\n export interface ThresholdSeries<T = any> extends Omit<IDataSeries<never>, 'data' | 'valueFormatter'> {\n type: 'threshold';\n y?: number;\n x?: T;\n valueFormatter?: CartesianChartProps.TickFormatter<number>;\n }\n\n export interface YThresholdSeries extends Omit<ThresholdSeries<never>, 'x'> {\n type: 'threshold';\n y: number;\n valueFormatter?: CartesianChartProps.TickFormatter<number>;\n }\n\n export interface XThresholdSeries<T> extends Omit<ThresholdSeries<T>, 'y' | 'valueFormatter'> {\n type: 'threshold';\n x: T;\n }\n\n export type DataSeries<T> = LineDataSeries<T> | BarDataSeries<T>;\n\n export type ChartSeries<T> = DataSeries<T> | ThresholdSeries<T>;\n\n export type FilterChangeDetail<T> = CartesianChartProps.FilterChangeDetail<ChartSeries<T>>;\n\n export type HighlightChangeDetail<T> = CartesianChartProps.HighlightChangeDetail<ChartSeries<T>>;\n\n export type TickFormatter<T> = CartesianChartProps.TickFormatter<T>;\n\n export type ValueFormatter<YType, XType = null> = CartesianChartProps.ValueFormatter<YType, XType>;\n\n export type I18nStrings<T> = CartesianChartProps.I18nStrings<T>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { CartesianChartProps } from '../internal/components/cartesian-chart/interfaces';\n\nexport type ChartDataTypes = number | string | Date;\n\nexport type SeriesType = 'line' | 'bar';\nexport type ScaleType = 'linear' | 'log' | 'time' | 'categorical';\nexport type ScaleRange = [number, number];\n\nexport interface InternalChartSeries<T> {\n index: number;\n color: string;\n series: MixedLineBarChartProps.ChartSeries<T>;\n}\n\nexport interface MixedLineBarChartProps<T extends ChartDataTypes>\n extends CartesianChartProps<T, MixedLineBarChartProps.ChartSeries<T>> {\n /**\n * Array that represents the source of data for the displayed chart.\n * Each element can represent a line series, bar series, or a threshold, and can have the following properties:\n *\n * * `title` (string): A human-readable title for this series.\n * * `type` (string): Series type (`\"line\"`, `\"bar\"`, or `\"threshold\"`).\n * * `data` (Array): For line and bar series, an array of data points, represented as objects with `x` and `y` properties.\n * * `y` (number): For threshold series, the value of the threshold.\n * * `color` (string): (Optional) A color hex value for this series. When assigned, it takes priority over the automatically assigned color.\n * * `valueFormatter` (Function): (Optional) A function that formats data values before rendering in the UI, For example, in the details popover.\n */\n series: ReadonlyArray<MixedLineBarChartProps.ChartSeries<T>>;\n\n /**\n * When set to `true`, bars in the same data point are stacked instead of grouped next to each other.\n */\n stackedBars?: boolean;\n\n /**\n * When set to `true`, the x and y axes are flipped, which causes any bars to be rendered horizontally instead of vertically.\n * This can only be used when the chart consists exclusively of bar series.\n */\n horizontalBars?: boolean;\n\n /**\n * When set to `true`, adds a visual emphasis on the zero baseline axis.\n * See the usage guidelines for more details.\n */\n emphasizeBaselineAxis?: boolean;\n}\n\nexport namespace MixedLineBarChartProps {\n export interface Datum<T> {\n x: T;\n y: number;\n }\n\n interface IDataSeries<T> {\n type: 'line' | 'bar' | 'threshold';\n title: string;\n color?: string;\n\n // This makes sure that the element type of the array is reduced to just one type,\n // even if `T` is a union type, e.g. `number | string`.\n data: T extends unknown ? ReadonlyArray<Datum<T>> : ReadonlyArray<Datum<T>>;\n valueFormatter?: T extends unknown\n ? CartesianChartProps.ValueFormatter<number, T>\n : CartesianChartProps.ValueFormatter<number, T>;\n }\n\n export interface BarDataSeries<T> extends IDataSeries<T> {\n type: 'bar';\n }\n\n export interface LineDataSeries<T> extends IDataSeries<T> {\n type: 'line';\n }\n\n export interface ThresholdSeries<T = any> extends Omit<IDataSeries<never>, 'data' | 'valueFormatter'> {\n type: 'threshold';\n y?: number;\n x?: T;\n valueFormatter?: CartesianChartProps.TickFormatter<number>;\n }\n\n export interface YThresholdSeries extends Omit<ThresholdSeries<never>, 'x'> {\n type: 'threshold';\n y: number;\n valueFormatter?: CartesianChartProps.TickFormatter<number>;\n }\n\n export interface XThresholdSeries<T> extends Omit<ThresholdSeries<T>, 'y' | 'valueFormatter'> {\n type: 'threshold';\n x: T;\n }\n\n export type DataSeries<T> = LineDataSeries<T> | BarDataSeries<T>;\n\n export type ChartSeries<T> = DataSeries<T> | ThresholdSeries<T>;\n\n export type FilterChangeDetail<T> = CartesianChartProps.FilterChangeDetail<ChartSeries<T>>;\n\n export type HighlightChangeDetail<T> = CartesianChartProps.HighlightChangeDetail<ChartSeries<T>>;\n\n export type TickFormatter<T> = CartesianChartProps.TickFormatter<T>;\n\n export type ValueFormatter<YType, XType = null> = CartesianChartProps.ValueFormatter<YType, XType>;\n\n export type I18nStrings<T> = CartesianChartProps.I18nStrings<T>;\n}\n\nexport interface VerticalMarkerX<T> {\n scaledX: number;\n label: T | null;\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChartDataTypes, MixedLineBarChartProps } from './interfaces';
|
|
2
2
|
import { InternalBaseComponentProps } from '../internal/hooks/use-base-component';
|
|
3
3
|
import { SomeRequired } from '../internal/types';
|
|
4
|
-
|
|
4
|
+
type InternalMixedLineBarChartProps<T extends ChartDataTypes> = SomeRequired<MixedLineBarChartProps<T>, 'series' | 'height' | 'xScaleType' | 'yScaleType' | 'stackedBars' | 'horizontalBars' | 'statusType' | 'detailPopoverSize' | 'emphasizeBaselineAxis'> & InternalBaseComponentProps;
|
|
5
5
|
export default function InternalMixedLineBarChart<T extends number | string | Date>({ height, xScaleType, yScaleType, xDomain, yDomain, highlightedSeries: controlledHighlightedSeries, visibleSeries: controlledVisibleSeries, series: externalSeries, onFilterChange, onHighlightChange: controlledOnHighlightChange, i18nStrings, ariaLabel, ariaLabelledby, ariaDescription, xTitle, yTitle, stackedBars, horizontalBars, hideFilter, additionalFilters, hideLegend, legendTitle, statusType, detailPopoverSize, emphasizeBaselineAxis, empty, noMatch, errorText, loadingText, recoveryText, onRecoveryClick, __internalRootRef, ...props }: InternalMixedLineBarChartProps<T>): JSX.Element;
|
|
6
6
|
export {};
|
|
7
7
|
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/internal.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAMtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAMlF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/internal.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAMtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAMlF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,KAAK,8BAA8B,CAAC,CAAC,SAAS,cAAc,IAAI,YAAY,CAC1E,sBAAsB,CAAC,CAAC,CAAC,EACvB,QAAQ,GACR,QAAQ,GACR,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,gBAAgB,GAChB,YAAY,GACZ,mBAAmB,GACnB,uBAAuB,CAC1B,GACC,0BAA0B,CAAC;AAE7B,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,IAAI,EAAE,EAClF,MAAM,EACN,UAAU,EACV,UAAU,EACV,OAAO,EACP,OAAO,EACP,iBAAiB,EAAE,2BAA2B,EAC9C,aAAa,EAAE,uBAAuB,EACtC,MAAM,EAAE,cAAc,EACtB,cAAc,EACd,iBAAiB,EAAE,2BAA2B,EAC9C,WAAW,EACX,SAAS,EACT,cAAc,EACd,eAAe,EACf,MAAM,EACN,MAAM,EACN,WAAW,EACX,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EACrB,KAAK,EACL,OAAO,EACP,SAAS,EACT,WAAW,EACX,YAAY,EACZ,eAAe,EACf,iBAAwB,EACxB,GAAG,KAAK,EACT,EAAE,8BAA8B,CAAC,CAAC,CAAC,eAkNnC"}
|
|
@@ -117,7 +117,7 @@ export default function InternalMixedLineBarChart(_a) {
|
|
|
117
117
|
_b[styles['content--reserve-legend']] = reserveLegendSpace,
|
|
118
118
|
_b)), style: { minHeight: height } },
|
|
119
119
|
React.createElement(ChartStatusContainer, { isEmpty: isEmpty, isNoMatch: isNoMatch, showChart: showChart, statusType: statusType, empty: empty, noMatch: noMatch, loadingText: loadingText, errorText: errorText, recoveryText: recoveryText, onRecoveryClick: onRecoveryClick }),
|
|
120
|
-
showChart && (React.createElement(ChartContainer, { height: height, xScaleType: xScaleType, yScaleType: yScaleType, xDomain: xDomain, yDomain: yDomain, xTickFormatter: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.xTickFormatter, yTickFormatter: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.yTickFormatter, emphasizeBaselineAxis: emphasizeBaselineAxis, stackedBars: stackedBars, horizontalBars: horizontalBars, series: series, visibleSeries: visibleSeries, highlightedSeries: highlightedSeries, onHighlightChange: onHighlightChange, highlightedPoint: highlightedPoint, setHighlightedPoint: setHighlightedPoint, highlightedGroupIndex: highlightedGroupIndex, setHighlightedGroupIndex: setHighlightedGroupIndex,
|
|
120
|
+
showChart && (React.createElement(ChartContainer, { height: height, xScaleType: xScaleType, yScaleType: yScaleType, xDomain: xDomain, yDomain: yDomain, xTickFormatter: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.xTickFormatter, yTickFormatter: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.yTickFormatter, emphasizeBaselineAxis: emphasizeBaselineAxis, stackedBars: stackedBars, horizontalBars: horizontalBars, series: series, visibleSeries: visibleSeries, highlightedSeries: highlightedSeries, onHighlightChange: onHighlightChange, highlightedPoint: highlightedPoint, setHighlightedPoint: setHighlightedPoint, highlightedGroupIndex: highlightedGroupIndex, setHighlightedGroupIndex: setHighlightedGroupIndex, detailPopoverSize: detailPopoverSize, xTitle: xTitle, yTitle: yTitle, ariaLabel: ariaLabel, ariaLabelledby: ariaLabelledby, ariaDescription: ariaDescription, i18nStrings: i18nStrings, plotContainerRef: containerRef }))),
|
|
121
121
|
showLegend && (React.createElement(InternalBox, { margin: { top: 'm' } },
|
|
122
122
|
React.createElement(InternalChartLegend, { series: series, visibleSeries: externalVisibleSeries || [], highlightedSeries: legendSeries, onHighlightChange: onHighlightChange, legendTitle: legendTitle, ariaLabel: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.legendAriaLabel, plotContainerRef: containerRef })))));
|
|
123
123
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,oBAAoB,EAAE,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AACrG,OAAO,EA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,EAC5C,wBAAwB,EAAE,wBAAwB,EAClD,YAAY,EAAE,YAAY,EAC1B,iBAAiB,EAAE,iBAAiB,EACpC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,YAAY,GAC9B,CACH,CACG;QAEL,UAAU,IAAI,CACb,oBAAC,WAAW,IAAC,MAAM,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE;YAC/B,oBAAC,mBAAmB,IAClB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,qBAAqB,IAAI,EAAE,EAC1C,iBAAiB,EAAE,YAAY,EAC/B,iBAAiB,EAAE,iBAAiB,EACpC,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,eAAe,EACvC,gBAAgB,EAAE,YAAY,GAC9B,CACU,CACf,CACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useMemo, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport InternalBox from '../box/internal';\nimport ChartStatusContainer, { getChartStatus } from '../internal/components/chart-status-container';\nimport { useControllable } from '../internal/hooks/use-controllable';\nimport { usePrevious } from '../internal/hooks/use-previous';\nimport { warnOnce } from '../internal/logging';\n\nimport { ChartDataTypes, MixedLineBarChartProps } from './interfaces';\nimport InternalChartFilters from './chart-filters';\nimport InternalChartLegend from './chart-legend';\nimport ChartContainer from './chart-container';\nimport cartesianStyles from '../internal/components/cartesian-chart/styles.css.js';\nimport styles from './styles.css.js';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { isDevelopment } from '../internal/is-development';\nimport createCategoryColorScale from '../internal/utils/create-category-color-scale';\nimport { ScaledPoint } from './make-scaled-series';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { nodeContains } from '../internal/utils/dom';\nimport { SomeRequired } from '../internal/types';\nimport { isXThreshold, isYThreshold } from './utils';\n\ntype InternalMixedLineBarChartProps<T extends ChartDataTypes> = SomeRequired<\n MixedLineBarChartProps<T>,\n | 'series'\n | 'height'\n | 'xScaleType'\n | 'yScaleType'\n | 'stackedBars'\n | 'horizontalBars'\n | 'statusType'\n | 'detailPopoverSize'\n | 'emphasizeBaselineAxis'\n> &\n InternalBaseComponentProps;\n\nexport default function InternalMixedLineBarChart<T extends number | string | Date>({\n height,\n xScaleType,\n yScaleType,\n xDomain,\n yDomain,\n highlightedSeries: controlledHighlightedSeries,\n visibleSeries: controlledVisibleSeries,\n series: externalSeries,\n onFilterChange,\n onHighlightChange: controlledOnHighlightChange,\n i18nStrings,\n ariaLabel,\n ariaLabelledby,\n ariaDescription,\n xTitle,\n yTitle,\n stackedBars,\n horizontalBars,\n hideFilter,\n additionalFilters,\n hideLegend,\n legendTitle,\n statusType,\n detailPopoverSize,\n emphasizeBaselineAxis,\n empty,\n noMatch,\n errorText,\n loadingText,\n recoveryText,\n onRecoveryClick,\n __internalRootRef = null,\n ...props\n}: InternalMixedLineBarChartProps<T>) {\n const baseProps = getBaseProps(props);\n const containerRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const gotBarSeries = externalSeries.some(s => s.type === 'bar');\n const gotLineSeries = externalSeries.some(s => s.type === 'line');\n\n if (xScaleType !== 'categorical' && gotBarSeries) {\n warnOnce(\n 'MixedLineBarChart',\n `Bar series cannot be used with a ${xScaleType} scale. Use a categorical x axis instead.`\n );\n }\n\n if (horizontalBars && gotLineSeries) {\n warnOnce(\n 'MixedLineBarChart',\n `Property horizontalBars can only be used with charts that contain only bar or threshold series.`\n );\n }\n\n for (const s of externalSeries) {\n if (s.type === 'threshold' && s.x !== undefined && s.y !== undefined) {\n warnOnce('MixedLineBarChart', `Series of type \"threshold\" must contain either x or y property.`);\n }\n if (s.type === 'threshold' && s.x === undefined && s.y === undefined) {\n warnOnce('MixedLineBarChart', `Series of type \"threshold\" must contain either x or y property.`);\n }\n }\n }, [xScaleType, horizontalBars, externalSeries]);\n\n const series = useMemo(() => {\n // Generate series colors if not explicitly provided.\n // The thresholds use a dedicated colour scale.\n const colors = createCategoryColorScale(\n externalSeries,\n it => isYThreshold(it) || isXThreshold(it),\n it => it.color || null\n );\n\n return externalSeries.map((s, i) => ({ index: i, color: colors[i], series: s }));\n }, [externalSeries]);\n\n const [highlightedPoint, setHighlightedPoint] = useState<ScaledPoint<T> | null>(null);\n const [highlightedGroupIndex, setHighlightedGroupIndex] = useState<number | null>(null);\n const [highlightedSeries = null, setHighlightedSeries] = useControllable(\n controlledHighlightedSeries,\n controlledOnHighlightChange,\n null,\n {\n componentName: 'MixedLineBarChart',\n controlledProp: 'highlightedSeries',\n changeHandler: 'onHighlightChange',\n }\n );\n const [legendSeries, setLegendSeries] = useState<MixedLineBarChartProps.ChartSeries<T> | null>(highlightedSeries);\n useEffect(() => {\n setLegendSeries(controlledHighlightedSeries || null);\n }, [controlledHighlightedSeries]);\n\n const [externalVisibleSeries, setExternalVisibleSeries] = useControllable(\n controlledVisibleSeries,\n onFilterChange,\n externalSeries,\n {\n componentName: 'MixedLineBarChart',\n controlledProp: 'visibleSeries',\n changeHandler: 'onFilterChange',\n }\n );\n\n if (isDevelopment) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const previousSeries = usePrevious(externalSeries);\n\n const hasPrevious = !!(previousSeries && previousSeries.length);\n const hasCurrent = !!externalSeries.length;\n\n if (hasPrevious && hasCurrent && externalSeries !== previousSeries && !controlledVisibleSeries && !hideFilter) {\n warnOnce(\n 'MixedLineBarChart',\n 'The `series` value passed into the component changed. ' +\n 'This may cause problems with filtering - we recommend that you make the `series` value constant, ' +\n 'or provide a `visibleSeries` value that derives from the current `series` value.'\n );\n }\n }\n\n const visibleSeries = useMemo(\n () => series.filter(s => externalVisibleSeries?.indexOf(s.series) !== -1),\n [series, externalVisibleSeries]\n );\n\n const filterChange = (selectedSeries: ReadonlyArray<MixedLineBarChartProps.ChartSeries<T>>) => {\n setExternalVisibleSeries(selectedSeries);\n fireNonCancelableEvent(onFilterChange, {\n visibleSeries: selectedSeries,\n });\n };\n\n const onHighlightChange = (series: MixedLineBarChartProps.ChartSeries<T> | null) => {\n setHighlightedSeries(series);\n fireNonCancelableEvent(controlledOnHighlightChange, {\n highlightedSeries: series,\n });\n setLegendSeries(series);\n };\n\n const onBlur = (event: React.FocusEvent) => {\n if (event.relatedTarget && !nodeContains(containerRef.current, event.relatedTarget)) {\n highlightedSeries && onHighlightChange(highlightedSeries);\n setHighlightedPoint(null);\n setHighlightedGroupIndex(null);\n setLegendSeries(null);\n }\n };\n\n const { isEmpty, isNoMatch, showChart } = getChartStatus({\n externalData: externalSeries,\n visibleData: visibleSeries || [],\n statusType,\n });\n const showFilters = statusType === 'finished' && (!isEmpty || isNoMatch);\n const showLegend = !hideLegend && !isEmpty && statusType === 'finished';\n const reserveLegendSpace = !showChart && !hideLegend;\n const reserveFilterSpace = !showChart && !isNoMatch && (!hideFilter || additionalFilters);\n const mergedRef = useMergeRefs(containerRef, __internalRootRef);\n\n return (\n <div {...baseProps} className={clsx(baseProps.className, styles.root)} ref={mergedRef} onBlur={onBlur}>\n {showFilters && (\n <InternalBox className={cartesianStyles['filter-container']} margin={{ bottom: 'l' }}>\n <InternalChartFilters\n series={series}\n visibleSeries={externalVisibleSeries || []}\n onChange={filterChange}\n i18nStrings={i18nStrings}\n hideFilter={hideFilter}\n additionalFilters={additionalFilters}\n />\n </InternalBox>\n )}\n\n <div\n className={clsx(styles.content, {\n [styles['content--reserve-filter']]: reserveFilterSpace,\n [styles['content--reserve-legend']]: reserveLegendSpace,\n })}\n style={{ minHeight: height }}\n >\n <ChartStatusContainer\n isEmpty={isEmpty}\n isNoMatch={isNoMatch}\n showChart={showChart}\n statusType={statusType}\n empty={empty}\n noMatch={noMatch}\n loadingText={loadingText}\n errorText={errorText}\n recoveryText={recoveryText}\n onRecoveryClick={onRecoveryClick}\n />\n {showChart && (\n <ChartContainer\n height={height}\n xScaleType={xScaleType}\n yScaleType={yScaleType}\n xDomain={xDomain}\n yDomain={yDomain}\n xTickFormatter={i18nStrings?.xTickFormatter}\n yTickFormatter={i18nStrings?.yTickFormatter}\n emphasizeBaselineAxis={emphasizeBaselineAxis}\n stackedBars={stackedBars}\n horizontalBars={horizontalBars}\n series={series}\n visibleSeries={visibleSeries}\n highlightedSeries={highlightedSeries}\n onHighlightChange={onHighlightChange}\n highlightedPoint={highlightedPoint}\n setHighlightedPoint={setHighlightedPoint}\n highlightedGroupIndex={highlightedGroupIndex}\n setHighlightedGroupIndex={setHighlightedGroupIndex}\n legendSeries={legendSeries}\n detailPopoverSize={detailPopoverSize}\n xTitle={xTitle}\n yTitle={yTitle}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n ariaDescription={ariaDescription}\n i18nStrings={i18nStrings}\n plotContainerRef={containerRef}\n />\n )}\n </div>\n\n {showLegend && (\n <InternalBox margin={{ top: 'm' }}>\n <InternalChartLegend\n series={series}\n visibleSeries={externalVisibleSeries || []}\n highlightedSeries={legendSeries}\n onHighlightChange={onHighlightChange}\n legendTitle={legendTitle}\n ariaLabel={i18nStrings?.legendAriaLabel}\n plotContainerRef={containerRef}\n />\n </InternalBox>\n )}\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA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AAM,EAAE,MAAM,EACd,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,iBAAiB,EACpC,iBAAiB,EAAE,iBAAiB,EACpC,gBAAgB,EAAE,gBAAgB,EAClC,mBAAmB,EAAE,mBAAmB,EACxC,qBAAqB,EAAE,qBAAqB,EAC5C,wBAAwB,EAAE,wBAAwB,EAClD,iBAAiB,EAAE,iBAAiB,EACpC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,YAAY,GAC9B,CACH,CACG;QAEL,UAAU,IAAI,CACb,oBAAC,WAAW,IAAC,MAAM,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE;YAC/B,oBAAC,mBAAmB,IAClB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,qBAAqB,IAAI,EAAE,EAC1C,iBAAiB,EAAE,YAAY,EAC/B,iBAAiB,EAAE,iBAAiB,EACpC,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,eAAe,EACvC,gBAAgB,EAAE,YAAY,GAC9B,CACU,CACf,CACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useMemo, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport InternalBox from '../box/internal';\nimport ChartStatusContainer, { getChartStatus } from '../internal/components/chart-status-container';\nimport { useControllable } from '../internal/hooks/use-controllable';\nimport { usePrevious } from '../internal/hooks/use-previous';\nimport { warnOnce } from '../internal/logging';\n\nimport { ChartDataTypes, MixedLineBarChartProps } from './interfaces';\nimport InternalChartFilters from './chart-filters';\nimport InternalChartLegend from './chart-legend';\nimport ChartContainer from './chart-container';\nimport cartesianStyles from '../internal/components/cartesian-chart/styles.css.js';\nimport styles from './styles.css.js';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { isDevelopment } from '../internal/is-development';\nimport createCategoryColorScale from '../internal/utils/create-category-color-scale';\nimport { ScaledPoint } from './make-scaled-series';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { nodeContains } from '../internal/utils/dom';\nimport { SomeRequired } from '../internal/types';\nimport { isXThreshold, isYThreshold } from './utils';\n\ntype InternalMixedLineBarChartProps<T extends ChartDataTypes> = SomeRequired<\n MixedLineBarChartProps<T>,\n | 'series'\n | 'height'\n | 'xScaleType'\n | 'yScaleType'\n | 'stackedBars'\n | 'horizontalBars'\n | 'statusType'\n | 'detailPopoverSize'\n | 'emphasizeBaselineAxis'\n> &\n InternalBaseComponentProps;\n\nexport default function InternalMixedLineBarChart<T extends number | string | Date>({\n height,\n xScaleType,\n yScaleType,\n xDomain,\n yDomain,\n highlightedSeries: controlledHighlightedSeries,\n visibleSeries: controlledVisibleSeries,\n series: externalSeries,\n onFilterChange,\n onHighlightChange: controlledOnHighlightChange,\n i18nStrings,\n ariaLabel,\n ariaLabelledby,\n ariaDescription,\n xTitle,\n yTitle,\n stackedBars,\n horizontalBars,\n hideFilter,\n additionalFilters,\n hideLegend,\n legendTitle,\n statusType,\n detailPopoverSize,\n emphasizeBaselineAxis,\n empty,\n noMatch,\n errorText,\n loadingText,\n recoveryText,\n onRecoveryClick,\n __internalRootRef = null,\n ...props\n}: InternalMixedLineBarChartProps<T>) {\n const baseProps = getBaseProps(props);\n const containerRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const gotBarSeries = externalSeries.some(s => s.type === 'bar');\n const gotLineSeries = externalSeries.some(s => s.type === 'line');\n\n if (xScaleType !== 'categorical' && gotBarSeries) {\n warnOnce(\n 'MixedLineBarChart',\n `Bar series cannot be used with a ${xScaleType} scale. Use a categorical x axis instead.`\n );\n }\n\n if (horizontalBars && gotLineSeries) {\n warnOnce(\n 'MixedLineBarChart',\n `Property horizontalBars can only be used with charts that contain only bar or threshold series.`\n );\n }\n\n for (const s of externalSeries) {\n if (s.type === 'threshold' && s.x !== undefined && s.y !== undefined) {\n warnOnce('MixedLineBarChart', `Series of type \"threshold\" must contain either x or y property.`);\n }\n if (s.type === 'threshold' && s.x === undefined && s.y === undefined) {\n warnOnce('MixedLineBarChart', `Series of type \"threshold\" must contain either x or y property.`);\n }\n }\n }, [xScaleType, horizontalBars, externalSeries]);\n\n const series = useMemo(() => {\n // Generate series colors if not explicitly provided.\n // The thresholds use a dedicated colour scale.\n const colors = createCategoryColorScale(\n externalSeries,\n it => isYThreshold(it) || isXThreshold(it),\n it => it.color || null\n );\n\n return externalSeries.map((s, i) => ({ index: i, color: colors[i], series: s }));\n }, [externalSeries]);\n\n const [highlightedPoint, setHighlightedPoint] = useState<ScaledPoint<T> | null>(null);\n const [highlightedGroupIndex, setHighlightedGroupIndex] = useState<number | null>(null);\n const [highlightedSeries = null, setHighlightedSeries] = useControllable(\n controlledHighlightedSeries,\n controlledOnHighlightChange,\n null,\n {\n componentName: 'MixedLineBarChart',\n controlledProp: 'highlightedSeries',\n changeHandler: 'onHighlightChange',\n }\n );\n const [legendSeries, setLegendSeries] = useState<MixedLineBarChartProps.ChartSeries<T> | null>(highlightedSeries);\n useEffect(() => {\n setLegendSeries(controlledHighlightedSeries || null);\n }, [controlledHighlightedSeries]);\n\n const [externalVisibleSeries, setExternalVisibleSeries] = useControllable(\n controlledVisibleSeries,\n onFilterChange,\n externalSeries,\n {\n componentName: 'MixedLineBarChart',\n controlledProp: 'visibleSeries',\n changeHandler: 'onFilterChange',\n }\n );\n\n if (isDevelopment) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const previousSeries = usePrevious(externalSeries);\n\n const hasPrevious = !!(previousSeries && previousSeries.length);\n const hasCurrent = !!externalSeries.length;\n\n if (hasPrevious && hasCurrent && externalSeries !== previousSeries && !controlledVisibleSeries && !hideFilter) {\n warnOnce(\n 'MixedLineBarChart',\n 'The `series` value passed into the component changed. ' +\n 'This may cause problems with filtering - we recommend that you make the `series` value constant, ' +\n 'or provide a `visibleSeries` value that derives from the current `series` value.'\n );\n }\n }\n\n const visibleSeries = useMemo(\n () => series.filter(s => externalVisibleSeries?.indexOf(s.series) !== -1),\n [series, externalVisibleSeries]\n );\n\n const filterChange = (selectedSeries: ReadonlyArray<MixedLineBarChartProps.ChartSeries<T>>) => {\n setExternalVisibleSeries(selectedSeries);\n fireNonCancelableEvent(onFilterChange, {\n visibleSeries: selectedSeries,\n });\n };\n\n const onHighlightChange = (series: MixedLineBarChartProps.ChartSeries<T> | null) => {\n setHighlightedSeries(series);\n fireNonCancelableEvent(controlledOnHighlightChange, {\n highlightedSeries: series,\n });\n setLegendSeries(series);\n };\n\n const onBlur = (event: React.FocusEvent) => {\n if (event.relatedTarget && !nodeContains(containerRef.current, event.relatedTarget)) {\n highlightedSeries && onHighlightChange(highlightedSeries);\n setHighlightedPoint(null);\n setHighlightedGroupIndex(null);\n setLegendSeries(null);\n }\n };\n\n const { isEmpty, isNoMatch, showChart } = getChartStatus({\n externalData: externalSeries,\n visibleData: visibleSeries || [],\n statusType,\n });\n const showFilters = statusType === 'finished' && (!isEmpty || isNoMatch);\n const showLegend = !hideLegend && !isEmpty && statusType === 'finished';\n const reserveLegendSpace = !showChart && !hideLegend;\n const reserveFilterSpace = !showChart && !isNoMatch && (!hideFilter || additionalFilters);\n const mergedRef = useMergeRefs(containerRef, __internalRootRef);\n\n return (\n <div {...baseProps} className={clsx(baseProps.className, styles.root)} ref={mergedRef} onBlur={onBlur}>\n {showFilters && (\n <InternalBox className={cartesianStyles['filter-container']} margin={{ bottom: 'l' }}>\n <InternalChartFilters\n series={series}\n visibleSeries={externalVisibleSeries || []}\n onChange={filterChange}\n i18nStrings={i18nStrings}\n hideFilter={hideFilter}\n additionalFilters={additionalFilters}\n />\n </InternalBox>\n )}\n\n <div\n className={clsx(styles.content, {\n [styles['content--reserve-filter']]: reserveFilterSpace,\n [styles['content--reserve-legend']]: reserveLegendSpace,\n })}\n style={{ minHeight: height }}\n >\n <ChartStatusContainer\n isEmpty={isEmpty}\n isNoMatch={isNoMatch}\n showChart={showChart}\n statusType={statusType}\n empty={empty}\n noMatch={noMatch}\n loadingText={loadingText}\n errorText={errorText}\n recoveryText={recoveryText}\n onRecoveryClick={onRecoveryClick}\n />\n {showChart && (\n <ChartContainer\n height={height}\n xScaleType={xScaleType}\n yScaleType={yScaleType}\n xDomain={xDomain}\n yDomain={yDomain}\n xTickFormatter={i18nStrings?.xTickFormatter}\n yTickFormatter={i18nStrings?.yTickFormatter}\n emphasizeBaselineAxis={emphasizeBaselineAxis}\n stackedBars={stackedBars}\n horizontalBars={horizontalBars}\n series={series}\n visibleSeries={visibleSeries}\n highlightedSeries={highlightedSeries}\n onHighlightChange={onHighlightChange}\n highlightedPoint={highlightedPoint}\n setHighlightedPoint={setHighlightedPoint}\n highlightedGroupIndex={highlightedGroupIndex}\n setHighlightedGroupIndex={setHighlightedGroupIndex}\n detailPopoverSize={detailPopoverSize}\n xTitle={xTitle}\n yTitle={yTitle}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n ariaDescription={ariaDescription}\n i18nStrings={i18nStrings}\n plotContainerRef={containerRef}\n />\n )}\n </div>\n\n {showLegend && (\n <InternalBox margin={{ top: 'm' }}>\n <InternalChartLegend\n series={series}\n visibleSeries={externalVisibleSeries || []}\n highlightedSeries={legendSeries}\n onHighlightChange={onHighlightChange}\n legendTitle={legendTitle}\n ariaLabel={i18nStrings?.legendAriaLabel}\n plotContainerRef={containerRef}\n />\n </InternalBox>\n )}\n </div>\n );\n}\n"]}
|
|
@@ -16,7 +16,7 @@ export declare function findNavigableSeries<T extends ChartDataTypes>(series: Re
|
|
|
16
16
|
* With a special treat for Date values which need to be converted to numbers first.
|
|
17
17
|
*/
|
|
18
18
|
export declare const matchesX: <T>(x1: T, x2: T) => boolean;
|
|
19
|
-
export
|
|
19
|
+
export type OffsetMap = Record<string | number, number>;
|
|
20
20
|
export interface StackedOffsets {
|
|
21
21
|
positiveOffsets: OffsetMap;
|
|
22
22
|
negativeOffsets: OffsetMap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAIhE,CAAC;AAGF,eAAO,MAAM,oBAAoB,sBAAuB,MAAM,+DAqB7D,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,cAAc,EAAE,MAAM,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;;;EAgB1G;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,8BAKpB,CAAC;AAEF,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAIhE,CAAC;AAGF,eAAO,MAAM,oBAAoB,sBAAuB,MAAM,+DAqB7D,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,cAAc,EAAE,MAAM,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;;;EAgB1G;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,8BAKpB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC;AAExD,MAAM,WAAW,cAAc;IAC7B,eAAe,EAAE,SAAS,CAAC;IAC3B,eAAe,EAAE,SAAS,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,KAAK,CAAC,SAAS,sBAAsB,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE,CAAC,GACnE,cAAc,EAAE,CA6BlB;AAED,4DAA4D;AAC5D,eAAO,MAAM,WAAW,QAAS,cAAc,oBAAgD,CAAC;AAEhG,wBAAgB,YAAY,CAAC,CAAC,EAC5B,MAAM,EAAE,sBAAsB,CAAC,WAAW,CAAC,CAAC,CAAC,GAC5C,MAAM,IAAI,sBAAsB,CAAC,gBAAgB,CAEnD;AAED,wBAAgB,YAAY,CAAC,CAAC,EAC5B,MAAM,EAAE,sBAAsB,CAAC,WAAW,CAAC,CAAC,CAAC,GAC5C,MAAM,IAAI,sBAAsB,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAEtD;AAED,wBAAgB,YAAY,CAAC,CAAC,EAC5B,MAAM,EAAE,sBAAsB,CAAC,WAAW,CAAC,CAAC,CAAC,GAC5C,MAAM,IAAI,sBAAsB,CAAC,UAAU,CAAC,CAAC,CAAC,CAEhD"}
|
package/modal/internal.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InternalBaseComponentProps } from '../internal/hooks/use-base-component';
|
|
2
2
|
import { ModalProps } from './interfaces';
|
|
3
3
|
import { SomeRequired } from '../internal/types';
|
|
4
|
-
|
|
4
|
+
type InternalModalProps = SomeRequired<ModalProps, 'size' | 'closeAriaLabel'> & InternalBaseComponentProps;
|
|
5
5
|
export default function InternalModal({ size, visible, closeAriaLabel, header, children, footer, disableContentPaddings, onDismiss, modalRoot, __internalRootRef, ...rest }: InternalModalProps): JSX.Element;
|
|
6
6
|
export {};
|
|
7
7
|
//# sourceMappingURL=internal.d.ts.map
|
package/modal/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/modal/internal.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAWlF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/modal/internal.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAWlF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,KAAK,kBAAkB,GAAG,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,CAAC,GAAG,0BAA0B,CAAC;AAE3G,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,IAAI,EACJ,OAAO,EACP,cAAc,EACd,MAAM,EACN,QAAQ,EACR,MAAM,EACN,sBAAsB,EACtB,SAAS,EACT,SAAS,EACT,iBAAwB,EACxB,GAAG,IAAI,EACR,EAAE,kBAAkB,eA2HpB"}
|