@cloudscape-design/chart-components 1.0.46 → 1.0.48

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.
@@ -28,6 +28,10 @@ export const transformCartesianSeries = (originalSeries, visibleSeries) => {
28
28
  const thresholdY = getThresholdY(originalSeries, visibleSeries);
29
29
  function transformSeriesToHighcharts(s) {
30
30
  var _a, _b, _c;
31
+ // Highcharts does not properly update data on re-render. When the fake empty series is replaced with the real series,
32
+ // the properties are merged together, so the showInLegend=false is not overridden.
33
+ // That is why we explicitly override this property for all real series.
34
+ const shared = { showInLegend: true };
31
35
  if (s.type === "x-threshold" || s.type === "y-threshold") {
32
36
  const data = s.type === "x-threshold"
33
37
  ? thresholdY.map((y) => ({ x: s.value, y }))
@@ -39,7 +43,7 @@ export const transformCartesianSeries = (originalSeries, visibleSeries) => {
39
43
  color: (_a = s.color) !== null && _a !== void 0 ? _a : Styles.thresholdSeries.color,
40
44
  dashStyle: (_b = s.dashStyle) !== null && _b !== void 0 ? _b : Styles.thresholdSeries.dashStyle,
41
45
  };
42
- return { type: "line", id: s.id, name: s.name, data, custom, enableMouseTracking, ...style };
46
+ return { type: "line", id: s.id, name: s.name, data, custom, enableMouseTracking, ...style, ...shared };
43
47
  }
44
48
  if (s.type === "errorbar") {
45
49
  const color = (_c = s.color) !== null && _c !== void 0 ? _c : colorChartsErrorBarMarker;
@@ -48,7 +52,7 @@ export const transformCartesianSeries = (originalSeries, visibleSeries) => {
48
52
  const colors = { stemColor: color, whiskerColor: color };
49
53
  return { ...s, data: s.data, ...colors };
50
54
  }
51
- return { ...s, data: s.data };
55
+ return { ...s, data: s.data, ...shared };
52
56
  }
53
57
  const series = originalSeries.map(transformSeriesToHighcharts);
54
58
  // We inject a fake empty series so that the empty state still shows axes, if defined.
@@ -1 +1 @@
1
- {"version":3,"file":"chart-series-cartesian.js","sourceRoot":"","sources":["../../../src/cartesian-chart/chart-series-cartesian.tsx"],"names":[],"mappings":"AA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C;YACD,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type Highcharts from \"highcharts\";\n\nimport { colorChartsErrorBarMarker } from \"@cloudscape-design/design-tokens\";\n\nimport { PointDataItemType, RangeDataItemOptions } from \"../core/interfaces\";\nimport { createThresholdMetadata, getOptionsId } from \"../core/utils\";\nimport * as Styles from \"../internal/chart-styles\";\nimport { Writeable } from \"../internal/utils/utils\";\nimport { CartesianChartProps } from \"./interfaces\";\n\n// The utility transforms cartesian chart component's series to Highcharts series. This includes transforming\n// custom x- and y-threshold series types, that are represented as a combination of invisible line series, and plot lines.\n// The plot lines, unlike series, are rendered across the entire chart plot width or height.\nexport const transformCartesianSeries = (\n originalSeries: readonly CartesianChartProps.SeriesOptions[],\n visibleSeries: readonly string[],\n) => {\n // The injected plot lines have IDs matching the IDs of the threshold series. This is used by the core chart\n // to manage visibility and highlight state for them, when the corresponding threshold series are toggled\n // or highlighted in the legend or filter.\n const xPlotLines: Highcharts.XAxisPlotLinesOptions[] = [];\n const yPlotLines: Highcharts.YAxisPlotLinesOptions[] = [];\n for (const s of originalSeries) {\n const seriesId = getOptionsId(s);\n const style = { ...Styles.thresholdPlotLine, color: s.color ?? Styles.thresholdPlotLine.color };\n if (s.type === \"x-threshold\" && visibleSeries.includes(seriesId)) {\n xPlotLines.push({ id: seriesId, value: s.value, ...style, dashStyle: s.dashStyle ?? style.dashStyle });\n }\n if (s.type === \"y-threshold\" && visibleSeries.includes(seriesId)) {\n yPlotLines.push({ id: seriesId, value: s.value, ...style, dashStyle: s.dashStyle ?? style.dashStyle });\n }\n }\n // The threshold series require data points to enable keyboard navigation and hover effects.\n const thresholdX = getThresholdX(originalSeries, visibleSeries);\n const thresholdY = getThresholdY(originalSeries, visibleSeries);\n function transformSeriesToHighcharts(s: CartesianChartProps.SeriesOptions): Highcharts.SeriesOptionsType {\n if (s.type === \"x-threshold\" || s.type === \"y-threshold\") {\n const data =\n s.type === \"x-threshold\"\n ? thresholdY.map((y) => ({ x: s.value, y }))\n : thresholdX.map((x) => ({ x, y: s.value }));\n const { custom } = createThresholdMetadata(s.type, s.value);\n const enableMouseTracking = s.type === \"y-threshold\";\n const style = {\n ...Styles.thresholdSeries,\n color: s.color ?? Styles.thresholdSeries.color,\n dashStyle: s.dashStyle ?? Styles.thresholdSeries.dashStyle,\n };\n return { type: \"line\", id: s.id, name: s.name, data, custom, enableMouseTracking, ...style };\n }\n if (s.type === \"errorbar\") {\n const color = s.color ?? colorChartsErrorBarMarker;\n // In Highcharts, the error-bar series graphic color is represented as stem-, and whisker colors.\n // We simplify that, and only expose a single color prop that sets both of those.\n const colors = { stemColor: color, whiskerColor: color };\n return { ...s, data: s.data as Writeable<RangeDataItemOptions[]>, ...colors };\n }\n return { ...s, data: s.data as Writeable<PointDataItemType[]> };\n }\n const series = originalSeries.map(transformSeriesToHighcharts);\n // We inject a fake empty series so that the empty state still shows axes, if defined.\n if (series.length === 0) {\n series.push({ type: \"line\", data: [], showInLegend: false });\n }\n return { series, xPlotLines, yPlotLines };\n};\n\n// For x-threshold the point-based navigation is disabled as irrelevant. However, we still need at least\n// one data point for core chart to work correctly, so we find the first visible y value from other series.\nfunction getThresholdY(series: readonly CartesianChartProps.SeriesOptions[], visibleSeries: readonly string[]) {\n for (const s of getVisibleDataSeries(series, visibleSeries)) {\n for (const d of s.data) {\n const y = d === null ? null : typeof d === \"number\" ? d : d.y;\n if (y !== null) {\n return [y];\n }\n }\n }\n return [];\n}\n\n// For y-threshold we find all defined x values from other series and use it those to create an array of\n// data points. As result, the y-threshold series becomes properly navigable.\nfunction getThresholdX(series: readonly CartesianChartProps.SeriesOptions[], visibleSeries: readonly string[]) {\n const allX = new Set<number>();\n for (const s of getVisibleDataSeries(series, visibleSeries)) {\n for (let i = 0; i < s.data.length; i++) {\n const d = s.data[i];\n const x = (typeof d === \"object\" ? d?.x : i) ?? i;\n allX.add(x);\n }\n }\n return [...allX].sort((a, b) => a - b);\n}\n\nfunction getVisibleDataSeries(series: readonly CartesianChartProps.SeriesOptions[], visibleSeries: readonly string[]) {\n const dataSeries: Exclude<\n CartesianChartProps.SeriesOptions,\n | CartesianChartProps.XThresholdSeriesOptions\n | CartesianChartProps.YThresholdSeriesOptions\n | CartesianChartProps.ErrorBarSeriesOptions\n >[] = [];\n for (const s of series) {\n if (\n s.type !== \"x-threshold\" &&\n s.type !== \"y-threshold\" &&\n s.type !== \"errorbar\" &&\n visibleSeries.includes(getOptionsId(s))\n ) {\n dataSeries.push(s);\n }\n }\n return dataSeries;\n}\n"]}
1
+ {"version":3,"file":"chart-series-cartesian.js","sourceRoot":"","sources":["../../../src/cartesian-chart/chart-series-cartesian.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAItC,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAG7E,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,KAAK,MAAM,MAAM,0BAA0B,CAAC;AAInD,6GAA6G;AAC7G,0HAA0H;AAC1H,4FAA4F;AAC5F,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,cAA4D,EAC5D,aAAgC,EAChC,EAAE;;IACF,4GAA4G;IAC5G,yGAAyG;IACzG,0CAA0C;IAC1C,MAAM,UAAU,GAAuC,EAAE,CAAC;IAC1D,MAAM,UAAU,GAAuC,EAAE,CAAC;IAC1D,KAAK,MAAM,CAAC,IAAI,cAAc,EAAE,CAAC;QAC/B,MAAM,QAAQ,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QACjC,MAAM,KAAK,GAAG,EAAE,GAAG,MAAM,CAAC,iBAAiB,EAAE,KAAK,EAAE,MAAA,CAAC,CAAC,KAAK,mCAAI,MAAM,CAAC,iBAAiB,CAA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AAC,CAAC;YACpB,MAAM,CAAC,GAAG,MAAA,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,mCAAI,CAAC,CAAC;YAClD,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,oBAAoB,CAAC,MAAoD,EAAE,aAAgC;IAClH,MAAM,UAAU,GAKV,EAAE,CAAC;IACT,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,IACE,CAAC,CAAC,IAAI,KAAK,aAAa;YACxB,CAAC,CAAC,IAAI,KAAK,aAAa;YACxB,CAAC,CAAC,IAAI,KAAK,UAAU;YACrB,aAAa,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EACvC,CAAC;YACD,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type Highcharts from \"highcharts\";\n\nimport { colorChartsErrorBarMarker } from \"@cloudscape-design/design-tokens\";\n\nimport { PointDataItemType, RangeDataItemOptions } from \"../core/interfaces\";\nimport { createThresholdMetadata, getOptionsId } from \"../core/utils\";\nimport * as Styles from \"../internal/chart-styles\";\nimport { Writeable } from \"../internal/utils/utils\";\nimport { CartesianChartProps } from \"./interfaces\";\n\n// The utility transforms cartesian chart component's series to Highcharts series. This includes transforming\n// custom x- and y-threshold series types, that are represented as a combination of invisible line series, and plot lines.\n// The plot lines, unlike series, are rendered across the entire chart plot width or height.\nexport const transformCartesianSeries = (\n originalSeries: readonly CartesianChartProps.SeriesOptions[],\n visibleSeries: readonly string[],\n) => {\n // The injected plot lines have IDs matching the IDs of the threshold series. This is used by the core chart\n // to manage visibility and highlight state for them, when the corresponding threshold series are toggled\n // or highlighted in the legend or filter.\n const xPlotLines: Highcharts.XAxisPlotLinesOptions[] = [];\n const yPlotLines: Highcharts.YAxisPlotLinesOptions[] = [];\n for (const s of originalSeries) {\n const seriesId = getOptionsId(s);\n const style = { ...Styles.thresholdPlotLine, color: s.color ?? Styles.thresholdPlotLine.color };\n if (s.type === \"x-threshold\" && visibleSeries.includes(seriesId)) {\n xPlotLines.push({ id: seriesId, value: s.value, ...style, dashStyle: s.dashStyle ?? style.dashStyle });\n }\n if (s.type === \"y-threshold\" && visibleSeries.includes(seriesId)) {\n yPlotLines.push({ id: seriesId, value: s.value, ...style, dashStyle: s.dashStyle ?? style.dashStyle });\n }\n }\n // The threshold series require data points to enable keyboard navigation and hover effects.\n const thresholdX = getThresholdX(originalSeries, visibleSeries);\n const thresholdY = getThresholdY(originalSeries, visibleSeries);\n function transformSeriesToHighcharts(s: CartesianChartProps.SeriesOptions): Highcharts.SeriesOptionsType {\n // Highcharts does not properly update data on re-render. When the fake empty series is replaced with the real series,\n // the properties are merged together, so the showInLegend=false is not overridden.\n // That is why we explicitly override this property for all real series.\n const shared = { showInLegend: true };\n if (s.type === \"x-threshold\" || s.type === \"y-threshold\") {\n const data =\n s.type === \"x-threshold\"\n ? thresholdY.map((y) => ({ x: s.value, y }))\n : thresholdX.map((x) => ({ x, y: s.value }));\n const { custom } = createThresholdMetadata(s.type, s.value);\n const enableMouseTracking = s.type === \"y-threshold\";\n const style = {\n ...Styles.thresholdSeries,\n color: s.color ?? Styles.thresholdSeries.color,\n dashStyle: s.dashStyle ?? Styles.thresholdSeries.dashStyle,\n };\n return { type: \"line\", id: s.id, name: s.name, data, custom, enableMouseTracking, ...style, ...shared };\n }\n if (s.type === \"errorbar\") {\n const color = s.color ?? colorChartsErrorBarMarker;\n // In Highcharts, the error-bar series graphic color is represented as stem-, and whisker colors.\n // We simplify that, and only expose a single color prop that sets both of those.\n const colors = { stemColor: color, whiskerColor: color };\n return { ...s, data: s.data as Writeable<RangeDataItemOptions[]>, ...colors };\n }\n return { ...s, data: s.data as Writeable<PointDataItemType[]>, ...shared };\n }\n const series = originalSeries.map(transformSeriesToHighcharts);\n // We inject a fake empty series so that the empty state still shows axes, if defined.\n if (series.length === 0) {\n series.push({ type: \"line\", data: [], showInLegend: false });\n }\n return { series, xPlotLines, yPlotLines };\n};\n\n// For x-threshold the point-based navigation is disabled as irrelevant. However, we still need at least\n// one data point for core chart to work correctly, so we find the first visible y value from other series.\nfunction getThresholdY(series: readonly CartesianChartProps.SeriesOptions[], visibleSeries: readonly string[]) {\n for (const s of getVisibleDataSeries(series, visibleSeries)) {\n for (const d of s.data) {\n const y = d === null ? null : typeof d === \"number\" ? d : d.y;\n if (y !== null) {\n return [y];\n }\n }\n }\n return [];\n}\n\n// For y-threshold we find all defined x values from other series and use it those to create an array of\n// data points. As result, the y-threshold series becomes properly navigable.\nfunction getThresholdX(series: readonly CartesianChartProps.SeriesOptions[], visibleSeries: readonly string[]) {\n const allX = new Set<number>();\n for (const s of getVisibleDataSeries(series, visibleSeries)) {\n for (let i = 0; i < s.data.length; i++) {\n const d = s.data[i];\n const x = (typeof d === \"object\" ? d?.x : i) ?? i;\n allX.add(x);\n }\n }\n return [...allX].sort((a, b) => a - b);\n}\n\nfunction getVisibleDataSeries(series: readonly CartesianChartProps.SeriesOptions[], visibleSeries: readonly string[]) {\n const dataSeries: Exclude<\n CartesianChartProps.SeriesOptions,\n | CartesianChartProps.XThresholdSeriesOptions\n | CartesianChartProps.YThresholdSeriesOptions\n | CartesianChartProps.ErrorBarSeriesOptions\n >[] = [];\n for (const s of series) {\n if (\n s.type !== \"x-threshold\" &&\n s.type !== \"y-threshold\" &&\n s.type !== \"errorbar\" &&\n visibleSeries.includes(getOptionsId(s))\n ) {\n dataSeries.push(s);\n }\n }\n return dataSeries;\n}\n"]}
@@ -13,8 +13,11 @@ export declare class ChartExtraLegend extends AsyncStore<ReactiveLegendState> {
13
13
  constructor(context: ChartExtraContext);
14
14
  onChartRender: () => void;
15
15
  updateItemsVisibility: () => void;
16
- onItemVisibilityChange: (visibleItems: readonly string[], { isApiCall }: {
17
- isApiCall: boolean;
16
+ onItemVisibilityChange: (visibleItems: readonly string[], detail: {
17
+ interactionType: "api" | "filter";
18
+ } | {
19
+ interactionType: "toggle" | "select";
20
+ targetItemId: string;
18
21
  }) => void;
19
22
  onHighlightPoint: (point: Highcharts.Point) => void;
20
23
  onHighlightGroup: (group: readonly Highcharts.Point[]) => void;
@@ -26,14 +26,14 @@ export class ChartExtraLegend extends AsyncStore {
26
26
  }
27
27
  };
28
28
  // A callback to be called when items visibility changes from the outside or from the legend.
29
- this.onItemVisibilityChange = (visibleItems, { isApiCall }) => {
29
+ this.onItemVisibilityChange = (visibleItems, detail) => {
30
30
  const currentItems = this.get().items;
31
31
  const updatedItems = currentItems.map((i) => ({ ...i, visible: visibleItems.includes(i.id) }));
32
32
  if (this.visibilityMode === "internal") {
33
33
  this.updateLegendItems(updatedItems);
34
34
  updateItemsVisibility(this.context.chart(), this.get().items, visibleItems);
35
35
  }
36
- fireNonCancelableEvent(this.context.handlers.onVisibleItemsChange, { items: updatedItems, isApiCall });
36
+ fireNonCancelableEvent(this.context.handlers.onVisibleItemsChange, { items: updatedItems, ...detail });
37
37
  };
38
38
  // Updates legend highlight state when chart's point is highlighted.
39
39
  this.onHighlightPoint = (point) => {
@@ -1 +1 @@
1
- {"version":3,"file":"chart-extra-legend.js","sourceRoot":"","sources":["../../../../src/core/chart-api/chart-extra-legend.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,iBAAiB,EAAyB,MAAM,yCAAyC,CAAC;AAEnG,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,UAAU,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M,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC;QACpF,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAChC,IAAI,OAAO,KAAK,CAAC,UAAU,KAAK,UAAU,IAAI,iBAAiB,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;gBACvF,KAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC;YAChF,CAAC;QACH,CAAC;IACH,CAAC;IAED,+GAA+G;IAC/G,gHAAgH;IAChH,IAAI,cAAc,GAAG,CAAC,EAAE,CAAC;QACvB,KAAK,CAAC,MAAM,EAAE,CAAC;IACjB,CAAC;AACH,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type Highcharts from \"highcharts\";\n\nimport { LegendItem } from \"../../internal/components/interfaces\";\nimport { ChartSeriesMarker, ChartSeriesMarkerType } from \"../../internal/components/series-marker\";\nimport { ChartSeriesMarkerStatus } from \"../../internal/components/series-marker/interfaces\";\nimport { fireNonCancelableEvent } from \"../../internal/events\";\nimport AsyncStore from \"../../internal/utils/async-store\";\nimport { getChartSeries } from \"../../internal/utils/chart-series\";\nimport { isEqualArrays } from \"../../internal/utils/utils\";\nimport { CoreChartProps } from \"../interfaces\";\nimport { getChartLegendItems, getPointId, getSeriesId } from \"../utils\";\nimport { ChartExtraContext } from \"./chart-extra-context\";\n\n// The reactive state is used to propagate changes in legend items to the core legend React component.\nexport interface ReactiveLegendState {\n items: readonly CoreChartProps.LegendItem[];\n}\n\n// Chart helper that implements custom legend behaviors.\nexport class ChartExtraLegend extends AsyncStore<ReactiveLegendState> {\n private context: ChartExtraContext;\n private visibilityMode: \"internal\" | \"external\" = \"external\";\n\n constructor(context: ChartExtraContext) {\n super({ items: [] });\n this.context = context;\n }\n\n public onChartRender = () => {\n this.initLegend();\n this.updateItemsVisibility();\n };\n\n // If visible items are explicitly provided, we use them to update visibility of chart's series or points (by ID).\n // If not provided, the visibility state is managed internally.\n public updateItemsVisibility = () => {\n if (this.context.state.visibleItems) {\n this.visibilityMode = \"external\";\n updateItemsVisibility(this.context.chart(), this.get().items, this.context.state.visibleItems);\n } else {\n this.visibilityMode = \"internal\";\n }\n };\n\n // A callback to be called when items visibility changes from the outside or from the legend.\n public onItemVisibilityChange = (visibleItems: readonly string[], { isApiCall }: { isApiCall: boolean }) => {\n const currentItems = this.get().items;\n const updatedItems = currentItems.map((i) => ({ ...i, visible: visibleItems.includes(i.id) }));\n if (this.visibilityMode === \"internal\") {\n this.updateLegendItems(updatedItems);\n updateItemsVisibility(this.context.chart(), this.get().items, visibleItems);\n }\n fireNonCancelableEvent(this.context.handlers.onVisibleItemsChange, { items: updatedItems, isApiCall });\n };\n\n // Updates legend highlight state when chart's point is highlighted.\n public onHighlightPoint = (point: Highcharts.Point) => {\n const visibleItems = point.series.type === \"pie\" ? [getPointId(point)] : [getSeriesId(point.series)];\n this.onHighlightItems(visibleItems);\n };\n\n // Updates legend highlight state when chart's group of points is highlighted.\n public onHighlightGroup = (group: readonly Highcharts.Point[]) => {\n const visibleItems = group.map((point) => getSeriesId(point.series));\n this.onHighlightItems(visibleItems);\n };\n\n // Updates legend highlight state given an explicit list of item IDs. This is used to update state\n // when a legend item gets hovered or focused.\n public onHighlightItems = (highlightedItems: readonly string[]) => {\n const currentItems = this.get().items;\n const updatedItems = currentItems.map(({ ...i }) => ({ ...i, highlighted: highlightedItems.includes(i.id) }));\n this.updateLegendItems(updatedItems);\n };\n\n // Clears legend highlight state.\n public onClearHighlight = () => {\n const nextItems = this.get().items.map(({ ...item }) => ({ ...item, highlighted: false }));\n this.updateLegendItems(nextItems);\n };\n\n private initLegend = () => {\n const prevState = this.get().items.reduce((map, item) => map.set(item.id, item), new Map<string, LegendItem>());\n const itemSpecs = getChartLegendItems({\n chart: this.context.chart(),\n getItemOptions: this.context.settings.getItemOptions,\n itemMarkerStatusAriaLabel: this.context.settings.labels.itemMarkerLabel,\n });\n const legendItems = itemSpecs.map(\n ({ id, name, color, markerType, visible, status, isSecondary, markerAriaLabel }) => {\n const marker = this.renderMarker({ type: markerType, color, visible, status, ariaLabel: markerAriaLabel });\n return { id, name, marker, visible, isSecondary, highlighted: prevState.get(id)?.highlighted ?? false };\n },\n );\n this.updateLegendItems(legendItems);\n };\n\n private updateLegendItems = (nextItems: CoreChartProps.LegendItem[]) => {\n function isLegendItemsEqual(a: CoreChartProps.LegendItem, b: CoreChartProps.LegendItem) {\n return (\n a.id === b.id &&\n a.name === b.name &&\n a.marker === b.marker &&\n a.visible === b.visible &&\n a.highlighted === b.highlighted\n );\n }\n if (!isEqualArrays(this.get().items, nextItems, isLegendItemsEqual)) {\n this.set(() => ({ items: nextItems }));\n }\n };\n\n // The chart markers derive from type and color and are cached to avoid unnecessary renders,\n // and allow comparing them by reference.\n private markersCache = new Map<string, React.ReactNode>();\n public renderMarker({\n type,\n status = \"default\",\n color,\n visible = true,\n ariaLabel,\n }: {\n type: ChartSeriesMarkerType;\n color: string;\n visible?: boolean;\n status?: ChartSeriesMarkerStatus;\n ariaLabel?: string;\n }): React.ReactNode {\n const key = `${type}:${color}:${visible}:${status}`;\n const marker = this.markersCache.get(key) ?? (\n <ChartSeriesMarker type={type} color={color} visible={visible} status={status} ariaLabel={ariaLabel} />\n );\n this.markersCache.set(key, marker);\n return marker;\n }\n}\n\nfunction updateItemsVisibility(\n chart: Highcharts.Chart,\n legendItems: readonly CoreChartProps.LegendItem[],\n visibleItems?: readonly string[],\n) {\n const availableItemsSet = new Set(legendItems.map((i) => i.id));\n const visibleItemsSet = new Set(visibleItems);\n\n let updatesCounter = 0;\n const getVisibleAndCount = (id: string, visible: boolean) => {\n const nextVisible = visibleItemsSet.has(id);\n updatesCounter += nextVisible !== visible ? 1 : 0;\n return nextVisible;\n };\n\n for (const series of getChartSeries(chart.series)) {\n if (availableItemsSet.has(getSeriesId(series))) {\n series.setVisible(getVisibleAndCount(getSeriesId(series), series.visible), false);\n }\n for (const point of series.data) {\n if (typeof point.setVisible === \"function\" && availableItemsSet.has(getPointId(point))) {\n point.setVisible(getVisibleAndCount(getPointId(point), point.visible), false);\n }\n }\n }\n\n // The call `seriesOrPoint.setVisible(visible, false)` does not trigger the chart redraw, as it would otherwise\n // impact the performance. Instead, we trigger the redraw explicitly, if any change to visibility has been made.\n if (updatesCounter > 0) {\n chart.redraw();\n }\n}\n"]}
1
+ {"version":3,"file":"chart-extra-legend.js","sourceRoot":"","sources":["../../../../src/core/chart-api/chart-extra-legend.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,iBAAiB,EAAyB,MAAM,yCAAyC,CAAC;AAEnG,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,UAAU,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAQxE,wDAAwD;AACxD,MAAM,OAAO,gBAAiB,SAAQ,UAA+B;IAInE,YAAY,OAA0B;QACpC,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;QAHf,mBAAc,GAA4B,UAAU,CAAC;QAOtD,kBAAa,GAAG,GAAG,EAAE;YAC1B,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC/B,CAAC,CAAC;QAEF,kHAAkH;QAClH,+DAA+D;QACxD,0BAAqB,GAAG,GAAG,EAAE;YAClC,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;gBACpC,IAAI,CAAC,cAAc,GAAG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IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;IAE9C,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,MAAM,kBAAkB,GAAG,CAAC,EAAU,EAAE,OAAgB,EAAE,EAAE;QAC1D,MAAM,WAAW,GAAG,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5C,cAAc,IAAI,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAClD,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC;IAEF,KAAK,MAAM,MAAM,IAAI,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,IAAI,iBAAiB,CAAC,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;YAC/C,MAAM,CAAC,UAAU,CAAC,kBAAkB,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC;QACpF,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAChC,IAAI,OAAO,KAAK,CAAC,UAAU,KAAK,UAAU,IAAI,iBAAiB,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;gBACvF,KAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC;YAChF,CAAC;QACH,CAAC;IACH,CAAC;IAED,+GAA+G;IAC/G,gHAAgH;IAChH,IAAI,cAAc,GAAG,CAAC,EAAE,CAAC;QACvB,KAAK,CAAC,MAAM,EAAE,CAAC;IACjB,CAAC;AACH,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type Highcharts from \"highcharts\";\n\nimport { LegendItem } from \"../../internal/components/interfaces\";\nimport { ChartSeriesMarker, ChartSeriesMarkerType } from \"../../internal/components/series-marker\";\nimport { ChartSeriesMarkerStatus } from \"../../internal/components/series-marker/interfaces\";\nimport { fireNonCancelableEvent } from \"../../internal/events\";\nimport AsyncStore from \"../../internal/utils/async-store\";\nimport { getChartSeries } from \"../../internal/utils/chart-series\";\nimport { isEqualArrays } from \"../../internal/utils/utils\";\nimport { CoreChartProps } from \"../interfaces\";\nimport { getChartLegendItems, getPointId, getSeriesId } from \"../utils\";\nimport { ChartExtraContext } from \"./chart-extra-context\";\n\n// The reactive state is used to propagate changes in legend items to the core legend React component.\nexport interface ReactiveLegendState {\n items: readonly CoreChartProps.LegendItem[];\n}\n\n// Chart helper that implements custom legend behaviors.\nexport class ChartExtraLegend extends AsyncStore<ReactiveLegendState> {\n private context: ChartExtraContext;\n private visibilityMode: \"internal\" | \"external\" = \"external\";\n\n constructor(context: ChartExtraContext) {\n super({ items: [] });\n this.context = context;\n }\n\n public onChartRender = () => {\n this.initLegend();\n this.updateItemsVisibility();\n };\n\n // If visible items are explicitly provided, we use them to update visibility of chart's series or points (by ID).\n // If not provided, the visibility state is managed internally.\n public updateItemsVisibility = () => {\n if (this.context.state.visibleItems) {\n this.visibilityMode = \"external\";\n updateItemsVisibility(this.context.chart(), this.get().items, this.context.state.visibleItems);\n } else {\n this.visibilityMode = \"internal\";\n }\n };\n\n // A callback to be called when items visibility changes from the outside or from the legend.\n public onItemVisibilityChange = (\n visibleItems: readonly string[],\n detail: { interactionType: \"api\" | \"filter\" } | { interactionType: \"toggle\" | \"select\"; targetItemId: string },\n ) => {\n const currentItems = this.get().items;\n const updatedItems = currentItems.map((i) => ({ ...i, visible: visibleItems.includes(i.id) }));\n if (this.visibilityMode === \"internal\") {\n this.updateLegendItems(updatedItems);\n updateItemsVisibility(this.context.chart(), this.get().items, visibleItems);\n }\n fireNonCancelableEvent(this.context.handlers.onVisibleItemsChange, { items: updatedItems, ...detail });\n };\n\n // Updates legend highlight state when chart's point is highlighted.\n public onHighlightPoint = (point: Highcharts.Point) => {\n const visibleItems = point.series.type === \"pie\" ? [getPointId(point)] : [getSeriesId(point.series)];\n this.onHighlightItems(visibleItems);\n };\n\n // Updates legend highlight state when chart's group of points is highlighted.\n public onHighlightGroup = (group: readonly Highcharts.Point[]) => {\n const visibleItems = group.map((point) => getSeriesId(point.series));\n this.onHighlightItems(visibleItems);\n };\n\n // Updates legend highlight state given an explicit list of item IDs. This is used to update state\n // when a legend item gets hovered or focused.\n public onHighlightItems = (highlightedItems: readonly string[]) => {\n const currentItems = this.get().items;\n const updatedItems = currentItems.map(({ ...i }) => ({ ...i, highlighted: highlightedItems.includes(i.id) }));\n this.updateLegendItems(updatedItems);\n };\n\n // Clears legend highlight state.\n public onClearHighlight = () => {\n const nextItems = this.get().items.map(({ ...item }) => ({ ...item, highlighted: false }));\n this.updateLegendItems(nextItems);\n };\n\n private initLegend = () => {\n const prevState = this.get().items.reduce((map, item) => map.set(item.id, item), new Map<string, LegendItem>());\n const itemSpecs = getChartLegendItems({\n chart: this.context.chart(),\n getItemOptions: this.context.settings.getItemOptions,\n itemMarkerStatusAriaLabel: this.context.settings.labels.itemMarkerLabel,\n });\n const legendItems = itemSpecs.map(\n ({ id, name, color, markerType, visible, status, isSecondary, markerAriaLabel }) => {\n const marker = this.renderMarker({ type: markerType, color, visible, status, ariaLabel: markerAriaLabel });\n return { id, name, marker, visible, isSecondary, highlighted: prevState.get(id)?.highlighted ?? false };\n },\n );\n this.updateLegendItems(legendItems);\n };\n\n private updateLegendItems = (nextItems: CoreChartProps.LegendItem[]) => {\n function isLegendItemsEqual(a: CoreChartProps.LegendItem, b: CoreChartProps.LegendItem) {\n return (\n a.id === b.id &&\n a.name === b.name &&\n a.marker === b.marker &&\n a.visible === b.visible &&\n a.highlighted === b.highlighted\n );\n }\n if (!isEqualArrays(this.get().items, nextItems, isLegendItemsEqual)) {\n this.set(() => ({ items: nextItems }));\n }\n };\n\n // The chart markers derive from type and color and are cached to avoid unnecessary renders,\n // and allow comparing them by reference.\n private markersCache = new Map<string, React.ReactNode>();\n public renderMarker({\n type,\n status = \"default\",\n color,\n visible = true,\n ariaLabel,\n }: {\n type: ChartSeriesMarkerType;\n color: string;\n visible?: boolean;\n status?: ChartSeriesMarkerStatus;\n ariaLabel?: string;\n }): React.ReactNode {\n const key = `${type}:${color}:${visible}:${status}`;\n const marker = this.markersCache.get(key) ?? (\n <ChartSeriesMarker type={type} color={color} visible={visible} status={status} ariaLabel={ariaLabel} />\n );\n this.markersCache.set(key, marker);\n return marker;\n }\n}\n\nfunction updateItemsVisibility(\n chart: Highcharts.Chart,\n legendItems: readonly CoreChartProps.LegendItem[],\n visibleItems?: readonly string[],\n) {\n const availableItemsSet = new Set(legendItems.map((i) => i.id));\n const visibleItemsSet = new Set(visibleItems);\n\n let updatesCounter = 0;\n const getVisibleAndCount = (id: string, visible: boolean) => {\n const nextVisible = visibleItemsSet.has(id);\n updatesCounter += nextVisible !== visible ? 1 : 0;\n return nextVisible;\n };\n\n for (const series of getChartSeries(chart.series)) {\n if (availableItemsSet.has(getSeriesId(series))) {\n series.setVisible(getVisibleAndCount(getSeriesId(series), series.visible), false);\n }\n for (const point of series.data) {\n if (typeof point.setVisible === \"function\" && availableItemsSet.has(getPointId(point))) {\n point.setVisible(getVisibleAndCount(getPointId(point), point.visible), false);\n }\n }\n }\n\n // The call `seriesOrPoint.setVisible(visible, false)` does not trigger the chart redraw, as it would otherwise\n // impact the performance. Instead, we trigger the redraw explicitly, if any change to visibility has been made.\n if (updatesCounter > 0) {\n chart.redraw();\n }\n}\n"]}
@@ -45,13 +45,16 @@ export declare class ChartAPI {
45
45
  hideTooltip: () => void;
46
46
  setApplication: (element: null | HTMLElement) => void;
47
47
  updateItemsVisibility: () => void;
48
- onItemVisibilityChange: (items: readonly string[]) => void;
48
+ onItemVisibilityChange: (items: readonly string[], detail: {
49
+ interactionType: "filter";
50
+ } | {
51
+ interactionType: "toggle" | "select";
52
+ targetItemId: string;
53
+ }) => void;
49
54
  onHighlightChartItems: (itemIds: readonly string[]) => void;
50
55
  onClearChartItemsHighlight: () => void;
51
56
  highlightChartItems: (itemIds: readonly string[]) => void;
52
- setItemsVisible: (visibleItemsIds: readonly string[], { isApiCall }: {
53
- isApiCall: boolean;
54
- }) => void;
57
+ setItemsVisible: (visibleItemsIds: readonly string[]) => void;
55
58
  highlightChartPoint: (point: Highcharts.Point, { isApiCall }: {
56
59
  isApiCall: boolean;
57
60
  }) => void;
@@ -104,7 +104,7 @@ export class ChartAPI {
104
104
  // A callback to notify the helper when items visibility state changes.
105
105
  this.updateItemsVisibility = this.chartExtraLegend.updateItemsVisibility.bind(this.chartExtraLegend);
106
106
  // A callback used by the legend and filter components when series/segments visibility changes.
107
- this.onItemVisibilityChange = (items) => this.chartExtraLegend.onItemVisibilityChange(items, { isApiCall: false });
107
+ this.onItemVisibilityChange = (items, detail) => this.chartExtraLegend.onItemVisibilityChange(items, detail);
108
108
  // Callbacks used by the legend component when items highlight state changes.
109
109
  this.onHighlightChartItems = (itemIds) => {
110
110
  if (!this.isTooltipPinned) {
@@ -128,8 +128,8 @@ export class ChartAPI {
128
128
  this.chartExtraLegend.onHighlightItems(itemIds);
129
129
  }
130
130
  };
131
- this.setItemsVisible = (visibleItemsIds, { isApiCall }) => {
132
- this.chartExtraLegend.onItemVisibilityChange(visibleItemsIds, { isApiCall });
131
+ this.setItemsVisible = (visibleItemsIds) => {
132
+ this.chartExtraLegend.onItemVisibilityChange(visibleItemsIds, { interactionType: "api" });
133
133
  };
134
134
  this.highlightChartPoint = (point, { isApiCall }) => {
135
135
  if (!this.isTooltipPinned) {
@@ -253,7 +253,7 @@ export class ChartAPI {
253
253
  get publicApi() {
254
254
  return {
255
255
  highlightItems: (itemIds) => this.highlightChartItems(itemIds),
256
- setItemsVisible: (visibleItemIds) => this.setItemsVisible(visibleItemIds, { isApiCall: true }),
256
+ setItemsVisible: (visibleItemIds) => this.setItemsVisible(visibleItemIds),
257
257
  highlightChartPoint: (point) => this.highlightChartPoint(point, { isApiCall: true }),
258
258
  highlightChartGroup: (group) => this.highlightChartGroup(group, { isApiCall: true }),
259
259
  clearChartHighlight: () => this.clearChartHighlight({ isApiCall: true }),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/chart-api/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,EAC7B,6BAA6B,EAC7B,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAA2B,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAqB,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAClG,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAuB,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAgC,MAAM,0BAA0B,CAAC;AAC9F,OAAO,EAAE,gBAAgB,EAAuB,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAA6B,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAwB,MAAM,uBAAuB,CAAC;AAEhF,mGAAmG;AACnG,kGAAkG;AAClG,qEAAqE;AACrE,MAAM,UAAU,WAAW,CACzB,QAAoC,EACpC,QAAoC,EACpC,KAA8B;IAE9B,gGAAgG;IAChG,iGAAiG;IACjG,2DAA2D;IAC3D,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,QAAQ,CAAC,QAAQ,EAAE,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on.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useEffect, useRef } from \"react\";\nimport type Highcharts from \"highcharts\";\n\nimport { fireNonCancelableEvent } from \"../../internal/events\";\nimport { ReadonlyAsyncStore } from \"../../internal/utils/async-store\";\nimport { getChartSeries } from \"../../internal/utils/chart-series\";\nimport { getSeriesData } from \"../../internal/utils/series-data\";\nimport { Writeable } from \"../../internal/utils/utils\";\nimport {\n getChartAccessibleDescription,\n getGroupAccessibleDescription,\n getPointAccessibleDescription,\n isXThreshold,\n} from \"../utils\";\nimport { ChartExtraAxisTitles, ReactiveAxisTitlesState } from \"./chart-extra-axis-titles\";\nimport { ChartExtraContext, createChartContext, updateChartContext } from \"./chart-extra-context\";\nimport { ChartExtraHighlight } from \"./chart-extra-highlight\";\nimport { ChartExtraLegend, ReactiveLegendState } from \"./chart-extra-legend\";\nimport { ChartExtraNavigation, ChartExtraNavigationHandlers } from \"./chart-extra-navigation\";\nimport { ChartExtraNodata, ReactiveNodataState } from \"./chart-extra-nodata\";\nimport { ChartExtraPointer, ChartExtraPointerHandlers } from \"./chart-extra-pointer\";\nimport { ChartExtraTooltip, ReactiveTooltipState } from \"./chart-extra-tooltip\";\n\n// The API helper injects Cloudscape custom behaviors, and returns the API instance that comes with\n// reactive state and handlers to be assigned as Highcharts options, used by Cloudscape components\n// (tooltip, legend, and other), or exposed as public core chart API.\nexport function useChartAPI(\n settings: ChartExtraContext.Settings,\n handlers: ChartExtraContext.Handlers,\n state: ChartExtraContext.State,\n) {\n // The API helper instance defines many pieces of internal state with different lifecycles, most\n // of which are not be invalidated when the hook re-renders, or properties change. That is why we\n // create the instance once, when the component is mounted.\n const api = useRef(new ChartAPI(settings, handlers, state)).current;\n // The consumer-defined properties can still change during the component lifecycle. We propagate the\n // changes by updating the helper's context directly. That is fine for most of the properties, as those\n // are only used in event-based callbacks, and require nothing to recompute when there is a change.\n useEffect(() => {\n api.context.settings = settings;\n api.context.handlers = handlers;\n api.context.state = state;\n });\n\n // The only property that does require notifying the helper when it changes, is the visible items state.\n // We stringify the visible items array so that it is compared by value, and the effect is only fired when\n // there is an actual change to the visible items, including items order.\n const visibleItemsIndex = state.visibleItems ? state.visibleItems.join(\"::\") : null;\n useEffect(() => {\n // When visibleItemsIndex === null, it means the visible items state is managed internally inside the helper,\n // so no need to call the API method.\n // The api.updateItemsVisibility() can only be used once the chart is initialized, so we check for api.ready.\n // The initialization happens after the first React render, so the chart is expected to not be ready when the\n // effect is called for the first time. This is fine, as the initial visibility state is handled by the helper.\n // The code below is needed to notify the helper any time the visible items state changes.\n if (api.ready && visibleItemsIndex !== null) {\n api.updateItemsVisibility();\n }\n }, [api, visibleItemsIndex]);\n\n // Run cleanup code when the component unmounts.\n useEffect(() => () => api.onChartDestroy(), [api]);\n\n return api;\n}\n\n// The main chart helper that provides customizations to Highcharts, including tooltip, legend, keyboard navigation, and more.\n// It is split into multiple dedicated (chart-extra) helpers (highlight, tooltip, navigation, and other), most of which define\n// internal state, and have a lifecycle based on Highcharts render event.\n// The helper code has a shared context, which includes the consumer settings, visible items state, and derived state, computed\n// from Highcharts.Chart on each render, and reused for downstream computations for better efficiency.\nexport class ChartAPI {\n public context = createChartContext();\n private chartExtraHighlight = new ChartExtraHighlight(this.context);\n private chartExtraTooltip = new ChartExtraTooltip(this.context);\n private chartExtraNavigation = new ChartExtraNavigation(this.context, this.navigationHandlers);\n private chartExtraPointer = new ChartExtraPointer(this.context, this.pointerHandlers);\n private chartExtraLegend = new ChartExtraLegend(this.context);\n private chartExtraNodata = new ChartExtraNodata(this.context);\n private chartExtraAxisTitles = new ChartExtraAxisTitles(this.context);\n\n constructor(\n settings: ChartExtraContext.Settings,\n handlers: ChartExtraContext.Handlers,\n state: ChartExtraContext.State,\n ) {\n this.context.settings = settings;\n this.context.handlers = handlers;\n this.context.state = state;\n }\n\n // The ready() returns true if the chart is initialized and helper methods are safe to use (after Highcharts triggers onChartRender).\n // Using any of the helper methods before the chart is initialized will result in an exception.\n public get ready() {\n return !!this.context.chartOrNull;\n }\n\n // The Highcharts options to be merged with the rest of the configuration defined in the chart-core.\n public getOptions() {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const chartAPI = this;\n const onChartLoad: Highcharts.ChartLoadCallbackFunction = function (this) {\n chartAPI.chartExtraPointer.onChartLoad(this);\n };\n const onChartRender: Highcharts.ChartRenderCallbackFunction = function (this) {\n updateChartContext(chartAPI.context, this);\n chartAPI.chartExtraHighlight.onChartRender();\n chartAPI.chartExtraLegend.onChartRender();\n chartAPI.chartExtraNodata.onChartRender();\n chartAPI.chartExtraAxisTitles.onChartRender();\n chartAPI.chartExtraTooltip.onChartRender();\n chartAPI.handleDestroyedPoints();\n chartAPI.resetColorCounter();\n chartAPI.showMarkersForIsolatedPoints();\n };\n const onChartClick: Highcharts.ChartClickCallbackFunction = function () {\n chartAPI.chartExtraPointer.onChartClick(this.hoverPoint);\n };\n const onSeriesPointMouseOver: Highcharts.PointMouseOverCallbackFunction = function () {\n chartAPI.chartExtraPointer.onSeriesPointMouseOver(this);\n };\n const onSeriesPointMouseOut: Highcharts.PointMouseOutCallbackFunction = function () {\n chartAPI.chartExtraPointer.onSeriesPointMouseOut();\n };\n const onSeriesPointClick: Highcharts.PointClickCallbackFunction = function () {\n chartAPI.chartExtraPointer.onSeriesPointClick(this);\n };\n return {\n onChartLoad,\n onChartRender,\n onChartClick,\n onSeriesPointMouseOver,\n onSeriesPointMouseOut,\n onSeriesPointClick,\n };\n }\n\n // There is no cleanup or destroy event in Highcharts options, so we define a custom one\n // to be used when the React component unmounts.\n public onChartDestroy = () => {\n this.chartExtraNavigation.onChartDestroy();\n this.chartExtraPointer.onChartDestroy();\n this.chartExtraTooltip.onChartDestroy();\n };\n\n // Reactive state stores.\n public get tooltipStore() {\n return this.chartExtraTooltip as ReadonlyAsyncStore<ReactiveTooltipState>;\n }\n public get legendStore() {\n return this.chartExtraLegend as ReadonlyAsyncStore<ReactiveLegendState>;\n }\n public get nodataStore() {\n return this.chartExtraNodata as ReadonlyAsyncStore<ReactiveNodataState>;\n }\n public get axisTitlesStore() {\n return this.chartExtraAxisTitles as ReadonlyAsyncStore<ReactiveAxisTitlesState>;\n }\n\n // References to SVG elements used for tooltip placement.\n public getTargetTrack = this.chartExtraTooltip.getTargetTrack.bind(this.chartExtraTooltip);\n public getGroupTrack = this.chartExtraTooltip.getGroupTrack.bind(this.chartExtraTooltip);\n\n // Legend marker renderer.\n public renderMarker = this.chartExtraLegend.renderMarker.bind(this.chartExtraLegend);\n\n // Callbacks assigned to the tooltip.\n public onMouseEnterTooltip = this.chartExtraPointer.onMouseEnterTooltip.bind(this.chartExtraPointer);\n public onMouseLeaveTooltip = this.chartExtraPointer.onMouseLeaveTooltip.bind(this.chartExtraPointer);\n public onDismissTooltip = (outsideClick?: boolean) => {\n const { pinned, point, group } = this.chartExtraTooltip.get();\n if (pinned) {\n this.chartExtraTooltip.hideTooltip();\n // The chart highlight is preserved while the tooltip is pinned. We need to clear it manually here, for the case\n // when the pointer lands outside the chart after the tooltip is dismissed, so that the mouse-out event won't fire.\n this.clearChartHighlight({ isApiCall: false });\n // If the tooltip was not dismissed by clicking outside, we bring focus to the point or group, that was\n // associated with the tooltip, so that we user can continue keyboard navigation from that spot.\n if (!outsideClick) {\n this.chartExtraNavigation.focusApplication(point, group);\n }\n }\n };\n\n // Hide the tooltip from an action initiated by the tooltip's content\n public hideTooltip = () => {\n this.chartExtraTooltip.hideTooltip();\n // The chart highlight is preserved while the tooltip is pinned. We need to clear it manually here, for the case\n // when the pointer lands outside the chart after the tooltip is dismissed, so that the mouse-out event won't fire.\n this.clearChartHighlight({ isApiCall: false });\n };\n\n // Reference to the role=\"application\" element used for navigation.\n public setApplication = this.chartExtraNavigation.setApplication.bind(this.chartExtraNavigation);\n\n // A callback to notify the helper when items visibility state changes.\n public updateItemsVisibility = this.chartExtraLegend.updateItemsVisibility.bind(this.chartExtraLegend);\n\n // A callback used by the legend and filter components when series/segments visibility changes.\n public onItemVisibilityChange = (items: readonly string[]) =>\n this.chartExtraLegend.onItemVisibilityChange(items, { isApiCall: false });\n\n // Callbacks used by the legend component when items highlight state changes.\n public onHighlightChartItems = (itemIds: readonly string[]) => {\n if (!this.isTooltipPinned) {\n this.chartExtraHighlight.highlightChartItems(itemIds);\n this.chartExtraLegend.onHighlightItems(itemIds);\n }\n };\n public onClearChartItemsHighlight = () => {\n if (!this.isTooltipPinned) {\n this.chartExtraHighlight.clearChartItemsHighlight();\n this.chartExtraLegend.onClearHighlight();\n\n // Notify the consumer that a clear-highlight action was made.\n fireNonCancelableEvent(this.context.handlers.onClearHighlight, { isApiCall: false });\n }\n };\n\n // Callbacks used for hover and keyboard navigation, and also exposed to the public API to give the ability\n // to highlight and show tooltip for the given point or group manually.\n public highlightChartItems = (itemIds: readonly string[]) => {\n if (!this.isTooltipPinned) {\n this.chartExtraHighlight.highlightChartItems(itemIds);\n this.chartExtraLegend.onHighlightItems(itemIds);\n }\n };\n public setItemsVisible = (visibleItemsIds: readonly string[], { isApiCall }: { isApiCall: boolean }) => {\n this.chartExtraLegend.onItemVisibilityChange(visibleItemsIds, { isApiCall });\n };\n public highlightChartPoint = (point: Highcharts.Point, { isApiCall }: { isApiCall: boolean }) => {\n if (!this.isTooltipPinned) {\n this.highlightActions(point, { isApiCall });\n }\n };\n public highlightChartGroup = (group: readonly Highcharts.Point[], { isApiCall }: { isApiCall: boolean }) => {\n if (!this.isTooltipPinned) {\n this.highlightActions(group as Writeable<Highcharts.Point[]>, { isApiCall });\n }\n };\n public clearChartHighlight = ({ isApiCall }: { isApiCall: boolean }) => {\n if (!this.isTooltipPinned) {\n this.clearHighlightActions({ isApiCall });\n }\n };\n public get publicApi() {\n return {\n highlightItems: (itemIds: readonly string[]) => this.highlightChartItems(itemIds),\n setItemsVisible: (visibleItemIds: readonly string[]) => this.setItemsVisible(visibleItemIds, { isApiCall: true }),\n highlightChartPoint: (point: Highcharts.Point) => this.highlightChartPoint(point, { isApiCall: true }),\n highlightChartGroup: (group: readonly Highcharts.Point[]) => this.highlightChartGroup(group, { isApiCall: true }),\n clearChartHighlight: () => this.clearChartHighlight({ isApiCall: true }),\n };\n }\n\n // A set of callbacks required for keyboard navigation.\n private get navigationHandlers(): ChartExtraNavigationHandlers {\n return {\n onFocusChart: () => {\n this.clearChartHighlight({ isApiCall: false });\n this.chartExtraNavigation.announceChart(getChartAccessibleDescription(this.context.chart()));\n },\n onFocusGroup: (group: Highcharts.Point[]) => {\n this.highlightActions(group, { isApiCall: false, overrideTooltipLock: true });\n this.chartExtraNavigation.announceElement(getGroupAccessibleDescription(group), false);\n },\n onFocusPoint: (point: Highcharts.Point) => {\n const labels = this.context.settings.labels;\n this.highlightActions(point, { isApiCall: false, overrideTooltipLock: true });\n this.chartExtraNavigation.announceElement(getPointAccessibleDescription(point, labels), false);\n },\n onBlur: () => this.clearChartHighlight({ isApiCall: false }),\n onActivateGroup: () => {\n const current = this.chartExtraTooltip.get();\n if (current.group.length > 0) {\n this.chartExtraTooltip.pinTooltip();\n this.chartExtraNavigation.announceElement(getGroupAccessibleDescription(current.group), true);\n }\n },\n onActivatePoint: () => {\n const current = this.chartExtraTooltip.get();\n if (current.point) {\n const labels = this.context.settings.labels;\n this.chartExtraTooltip.pinTooltip();\n this.chartExtraNavigation.announceElement(getPointAccessibleDescription(current.point, labels), true);\n }\n },\n };\n }\n\n // A set of callbacks required for pointer navigation.\n private get pointerHandlers(): ChartExtraPointerHandlers {\n return {\n onPointHover: (point) => {\n this.highlightChartPoint(point, { isApiCall: false });\n },\n onGroupHover: (group) => {\n this.highlightChartGroup(group, { isApiCall: false });\n },\n onHoverLost: () => {\n this.clearChartHighlight({ isApiCall: false });\n },\n onPointClick: (point) => {\n this.pinTooltipOnPoint(point);\n },\n onGroupClick: (group) => {\n this.pinTooltipOnGroup(group);\n },\n };\n }\n\n // Area- or line series can be defined with just a single point, or include missing data (y=null) in such\n // a way, that certain points become isolated. As we prefer the markers to not be shown for area- and line\n // series by default, those points become invisible, unless hovered. To fix this, we use the function below,\n // that finds isolates points and overrides the marker.enabled configuration for those.\n // See: https://github.com/highcharts/highcharts/issues/1210.\n private showMarkersForIsolatedPoints() {\n let shouldRedraw = false;\n for (const s of this.context.chart().series) {\n const seriesData = getSeriesData(s.data);\n for (let i = 0; i < seriesData.length; i++) {\n const isEligibleSeries = !isXThreshold(s) && s.type !== \"scatter\" && !seriesData[i].options.marker?.enabled;\n if (\n isEligibleSeries &&\n (seriesData[i - 1]?.y === undefined || seriesData[i - 1]?.y === null) &&\n (seriesData[i + 1]?.y === undefined || seriesData[i + 1]?.y === null)\n ) {\n seriesData[i].update({ marker: { enabled: true } }, false);\n shouldRedraw = true;\n }\n }\n }\n if (shouldRedraw) {\n this.context.chart().redraw();\n }\n }\n\n // Highcharts sometimes destroys points upon re-rendering. As result, the already stored points can get\n // replaced by `{ destroyed: true }`. This can affect the tooltip state, making the component crash when\n // obtaining data from points, or making it hidden yet pinned, so not visible on hover until a click is made.\n // To prevent these issues, on each render we check for destroyed points in the tooltip state, and proactively\n // hide the tooltip if found. The behavior is only observed during the initial chart loading, and is not expected\n // to cause UX issues with the tooltip being closed unexpectedly.\n // See: https://github.com/highcharts/highcharts/issues/23175.\n private handleDestroyedPoints() {\n const tooltipState = this.chartExtraTooltip.get();\n if (tooltipState.group.some((p) => !p.series)) {\n this.chartExtraTooltip.hideTooltip();\n }\n }\n\n // We reset color counter so that when a series is removed and then added back - it will\n // have the same color as before, not the next one in the color sequence.\n // See: https://github.com/highcharts/highcharts/issues/23077.\n private resetColorCounter() {\n const chart = this.context.chart();\n if (\"colorCounter\" in chart && typeof chart.colorCounter === \"number\") {\n chart.colorCounter = getChartSeries(chart.series).length;\n }\n }\n\n private pinTooltipOnPoint = (point: Highcharts.Point) => {\n const currentPoint = this.chartExtraTooltip.get().point;\n const currentGroup = this.chartExtraTooltip.get().group;\n const positionsMatch = isPointsPositionsEqual(currentPoint ?? currentGroup[0], point);\n\n // If the previously hovered and now clicked positions match, and the the tooltip wasn't\n // dismissed just a moment ago, we make the tooltip pinned in this position.\n if (positionsMatch && !this.chartExtraTooltip.tooltipLock) {\n this.highlightActions(point, { isApiCall: false });\n this.chartExtraTooltip.pinTooltip();\n }\n // If the tooltip was just dismissed, it means this happened by clicking somewhere in the plot area.\n // If the clicked position differs from the one that was pinned - we show tooltip in the new position.\n else if (!positionsMatch && this.chartExtraTooltip.tooltipLock) {\n this.highlightActions(point, { isApiCall: false, overrideTooltipLock: true });\n }\n };\n\n private pinTooltipOnGroup = (group: Highcharts.Point[]) => {\n const currentPoint = this.chartExtraTooltip.get().point;\n const currentGroup = this.chartExtraTooltip.get().group;\n const positionsMatch = isPointsPositionsEqual(currentPoint ?? currentGroup[0], group[0]);\n\n // If the previously hovered and now clicked positions match, and the the tooltip wasn't\n // dismissed just a moment ago, we make the tooltip pinned in this position.\n if (positionsMatch && !this.chartExtraTooltip.tooltipLock) {\n this.highlightActions(group, { isApiCall: false });\n this.chartExtraTooltip.pinTooltip();\n }\n // If the tooltip was just dismissed, it means this happened by clicking somewhere in the plot area.\n // If the clicked position differs from the one that was pinned - we show tooltip in the new position.\n else if (!positionsMatch && this.chartExtraTooltip.tooltipLock) {\n this.highlightActions(group, { isApiCall: false, overrideTooltipLock: true });\n }\n };\n\n private highlightActions(\n target: Highcharts.Point | Highcharts.Point[],\n { isApiCall, overrideTooltipLock }: { isApiCall: boolean; overrideTooltipLock?: boolean },\n ) {\n const point = Array.isArray(target) ? null : target;\n const group = Array.isArray(target) ? target : this.context.derived.getPointsByX(target.x);\n\n if (!this.isTooltipPinned) {\n // Update Highcharts elements state.\n if (point) {\n this.chartExtraHighlight.highlightChartPoint(point);\n } else {\n this.chartExtraHighlight.highlightChartGroup(group);\n }\n\n // Update tooltip and legend state.\n if (point) {\n this.chartExtraLegend.onHighlightPoint(point);\n this.chartExtraTooltip.showTooltipOnPoint(point, group, overrideTooltipLock);\n } else {\n this.chartExtraLegend.onHighlightGroup(group);\n this.chartExtraTooltip.showTooltipOnGroup(group, overrideTooltipLock);\n }\n\n // Notify the consumer that a highlight action was made.\n fireNonCancelableEvent(this.context.handlers.onHighlight, { point, group, isApiCall });\n }\n }\n\n private clearHighlightActions = ({ isApiCall }: { isApiCall: boolean }) => {\n if (!this.isTooltipPinned) {\n // Update Highcharts elements state.\n this.chartExtraHighlight.clearChartItemsHighlight();\n\n // Update tooltip and legend state.\n this.chartExtraTooltip.hideTooltip();\n this.chartExtraLegend.onClearHighlight();\n\n // Notify the consumer that a clear-highlight action was made.\n fireNonCancelableEvent(this.context.handlers.onClearHighlight, { isApiCall });\n }\n };\n\n private get isTooltipPinned() {\n return this.chartExtraTooltip.get().pinned;\n }\n}\n\nfunction isPointsPositionsEqual(current?: Highcharts.Point, next?: Highcharts.Point) {\n return current?.x === next?.x && current?.y === next?.y;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/chart-api/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,EAC7B,6BAA6B,EAC7B,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAA2B,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAqB,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAClG,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAuB,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAgC,MAAM,0BAA0B,CAAC;AAC9F,OAAO,E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AED,SAAS,sBAAsB,CAAC,OAA0B,EAAE,IAAuB;IACjF,OAAO,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,CAAC,OAAK,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,CAAC,CAAA,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,CAAC,OAAK,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,CAAC,CAAA,CAAC;AAC1D,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useEffect, useRef } from \"react\";\nimport type Highcharts from \"highcharts\";\n\nimport { fireNonCancelableEvent } from \"../../internal/events\";\nimport { ReadonlyAsyncStore } from \"../../internal/utils/async-store\";\nimport { getChartSeries } from \"../../internal/utils/chart-series\";\nimport { getSeriesData } from \"../../internal/utils/series-data\";\nimport { Writeable } from \"../../internal/utils/utils\";\nimport {\n getChartAccessibleDescription,\n getGroupAccessibleDescription,\n getPointAccessibleDescription,\n isXThreshold,\n} from \"../utils\";\nimport { ChartExtraAxisTitles, ReactiveAxisTitlesState } from \"./chart-extra-axis-titles\";\nimport { ChartExtraContext, createChartContext, updateChartContext } from \"./chart-extra-context\";\nimport { ChartExtraHighlight } from \"./chart-extra-highlight\";\nimport { ChartExtraLegend, ReactiveLegendState } from \"./chart-extra-legend\";\nimport { ChartExtraNavigation, ChartExtraNavigationHandlers } from \"./chart-extra-navigation\";\nimport { ChartExtraNodata, ReactiveNodataState } from \"./chart-extra-nodata\";\nimport { ChartExtraPointer, ChartExtraPointerHandlers } from \"./chart-extra-pointer\";\nimport { ChartExtraTooltip, ReactiveTooltipState } from \"./chart-extra-tooltip\";\n\n// The API helper injects Cloudscape custom behaviors, and returns the API instance that comes with\n// reactive state and handlers to be assigned as Highcharts options, used by Cloudscape components\n// (tooltip, legend, and other), or exposed as public core chart API.\nexport function useChartAPI(\n settings: ChartExtraContext.Settings,\n handlers: ChartExtraContext.Handlers,\n state: ChartExtraContext.State,\n) {\n // The API helper instance defines many pieces of internal state with different lifecycles, most\n // of which are not be invalidated when the hook re-renders, or properties change. That is why we\n // create the instance once, when the component is mounted.\n const api = useRef(new ChartAPI(settings, handlers, state)).current;\n // The consumer-defined properties can still change during the component lifecycle. We propagate the\n // changes by updating the helper's context directly. That is fine for most of the properties, as those\n // are only used in event-based callbacks, and require nothing to recompute when there is a change.\n useEffect(() => {\n api.context.settings = settings;\n api.context.handlers = handlers;\n api.context.state = state;\n });\n\n // The only property that does require notifying the helper when it changes, is the visible items state.\n // We stringify the visible items array so that it is compared by value, and the effect is only fired when\n // there is an actual change to the visible items, including items order.\n const visibleItemsIndex = state.visibleItems ? state.visibleItems.join(\"::\") : null;\n useEffect(() => {\n // When visibleItemsIndex === null, it means the visible items state is managed internally inside the helper,\n // so no need to call the API method.\n // The api.updateItemsVisibility() can only be used once the chart is initialized, so we check for api.ready.\n // The initialization happens after the first React render, so the chart is expected to not be ready when the\n // effect is called for the first time. This is fine, as the initial visibility state is handled by the helper.\n // The code below is needed to notify the helper any time the visible items state changes.\n if (api.ready && visibleItemsIndex !== null) {\n api.updateItemsVisibility();\n }\n }, [api, visibleItemsIndex]);\n\n // Run cleanup code when the component unmounts.\n useEffect(() => () => api.onChartDestroy(), [api]);\n\n return api;\n}\n\n// The main chart helper that provides customizations to Highcharts, including tooltip, legend, keyboard navigation, and more.\n// It is split into multiple dedicated (chart-extra) helpers (highlight, tooltip, navigation, and other), most of which define\n// internal state, and have a lifecycle based on Highcharts render event.\n// The helper code has a shared context, which includes the consumer settings, visible items state, and derived state, computed\n// from Highcharts.Chart on each render, and reused for downstream computations for better efficiency.\nexport class ChartAPI {\n public context = createChartContext();\n private chartExtraHighlight = new ChartExtraHighlight(this.context);\n private chartExtraTooltip = new ChartExtraTooltip(this.context);\n private chartExtraNavigation = new ChartExtraNavigation(this.context, this.navigationHandlers);\n private chartExtraPointer = new ChartExtraPointer(this.context, this.pointerHandlers);\n private chartExtraLegend = new ChartExtraLegend(this.context);\n private chartExtraNodata = new ChartExtraNodata(this.context);\n private chartExtraAxisTitles = new ChartExtraAxisTitles(this.context);\n\n constructor(\n settings: ChartExtraContext.Settings,\n handlers: ChartExtraContext.Handlers,\n state: ChartExtraContext.State,\n ) {\n this.context.settings = settings;\n this.context.handlers = handlers;\n this.context.state = state;\n }\n\n // The ready() returns true if the chart is initialized and helper methods are safe to use (after Highcharts triggers onChartRender).\n // Using any of the helper methods before the chart is initialized will result in an exception.\n public get ready() {\n return !!this.context.chartOrNull;\n }\n\n // The Highcharts options to be merged with the rest of the configuration defined in the chart-core.\n public getOptions() {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const chartAPI = this;\n const onChartLoad: Highcharts.ChartLoadCallbackFunction = function (this) {\n chartAPI.chartExtraPointer.onChartLoad(this);\n };\n const onChartRender: Highcharts.ChartRenderCallbackFunction = function (this) {\n updateChartContext(chartAPI.context, this);\n chartAPI.chartExtraHighlight.onChartRender();\n chartAPI.chartExtraLegend.onChartRender();\n chartAPI.chartExtraNodata.onChartRender();\n chartAPI.chartExtraAxisTitles.onChartRender();\n chartAPI.chartExtraTooltip.onChartRender();\n chartAPI.handleDestroyedPoints();\n chartAPI.resetColorCounter();\n chartAPI.showMarkersForIsolatedPoints();\n };\n const onChartClick: Highcharts.ChartClickCallbackFunction = function () {\n chartAPI.chartExtraPointer.onChartClick(this.hoverPoint);\n };\n const onSeriesPointMouseOver: Highcharts.PointMouseOverCallbackFunction = function () {\n chartAPI.chartExtraPointer.onSeriesPointMouseOver(this);\n };\n const onSeriesPointMouseOut: Highcharts.PointMouseOutCallbackFunction = function () {\n chartAPI.chartExtraPointer.onSeriesPointMouseOut();\n };\n const onSeriesPointClick: Highcharts.PointClickCallbackFunction = function () {\n chartAPI.chartExtraPointer.onSeriesPointClick(this);\n };\n return {\n onChartLoad,\n onChartRender,\n onChartClick,\n onSeriesPointMouseOver,\n onSeriesPointMouseOut,\n onSeriesPointClick,\n };\n }\n\n // There is no cleanup or destroy event in Highcharts options, so we define a custom one\n // to be used when the React component unmounts.\n public onChartDestroy = () => {\n this.chartExtraNavigation.onChartDestroy();\n this.chartExtraPointer.onChartDestroy();\n this.chartExtraTooltip.onChartDestroy();\n };\n\n // Reactive state stores.\n public get tooltipStore() {\n return this.chartExtraTooltip as ReadonlyAsyncStore<ReactiveTooltipState>;\n }\n public get legendStore() {\n return this.chartExtraLegend as ReadonlyAsyncStore<ReactiveLegendState>;\n }\n public get nodataStore() {\n return this.chartExtraNodata as ReadonlyAsyncStore<ReactiveNodataState>;\n }\n public get axisTitlesStore() {\n return this.chartExtraAxisTitles as ReadonlyAsyncStore<ReactiveAxisTitlesState>;\n }\n\n // References to SVG elements used for tooltip placement.\n public getTargetTrack = this.chartExtraTooltip.getTargetTrack.bind(this.chartExtraTooltip);\n public getGroupTrack = this.chartExtraTooltip.getGroupTrack.bind(this.chartExtraTooltip);\n\n // Legend marker renderer.\n public renderMarker = this.chartExtraLegend.renderMarker.bind(this.chartExtraLegend);\n\n // Callbacks assigned to the tooltip.\n public onMouseEnterTooltip = this.chartExtraPointer.onMouseEnterTooltip.bind(this.chartExtraPointer);\n public onMouseLeaveTooltip = this.chartExtraPointer.onMouseLeaveTooltip.bind(this.chartExtraPointer);\n public onDismissTooltip = (outsideClick?: boolean) => {\n const { pinned, point, group } = this.chartExtraTooltip.get();\n if (pinned) {\n this.chartExtraTooltip.hideTooltip();\n // The chart highlight is preserved while the tooltip is pinned. We need to clear it manually here, for the case\n // when the pointer lands outside the chart after the tooltip is dismissed, so that the mouse-out event won't fire.\n this.clearChartHighlight({ isApiCall: false });\n // If the tooltip was not dismissed by clicking outside, we bring focus to the point or group, that was\n // associated with the tooltip, so that we user can continue keyboard navigation from that spot.\n if (!outsideClick) {\n this.chartExtraNavigation.focusApplication(point, group);\n }\n }\n };\n\n // Hide the tooltip from an action initiated by the tooltip's content\n public hideTooltip = () => {\n this.chartExtraTooltip.hideTooltip();\n // The chart highlight is preserved while the tooltip is pinned. We need to clear it manually here, for the case\n // when the pointer lands outside the chart after the tooltip is dismissed, so that the mouse-out event won't fire.\n this.clearChartHighlight({ isApiCall: false });\n };\n\n // Reference to the role=\"application\" element used for navigation.\n public setApplication = this.chartExtraNavigation.setApplication.bind(this.chartExtraNavigation);\n\n // A callback to notify the helper when items visibility state changes.\n public updateItemsVisibility = this.chartExtraLegend.updateItemsVisibility.bind(this.chartExtraLegend);\n\n // A callback used by the legend and filter components when series/segments visibility changes.\n public onItemVisibilityChange = (\n items: readonly string[],\n detail: { interactionType: \"filter\" } | { interactionType: \"toggle\" | \"select\"; targetItemId: string },\n ) => this.chartExtraLegend.onItemVisibilityChange(items, detail);\n\n // Callbacks used by the legend component when items highlight state changes.\n public onHighlightChartItems = (itemIds: readonly string[]) => {\n if (!this.isTooltipPinned) {\n this.chartExtraHighlight.highlightChartItems(itemIds);\n this.chartExtraLegend.onHighlightItems(itemIds);\n }\n };\n public onClearChartItemsHighlight = () => {\n if (!this.isTooltipPinned) {\n this.chartExtraHighlight.clearChartItemsHighlight();\n this.chartExtraLegend.onClearHighlight();\n\n // Notify the consumer that a clear-highlight action was made.\n fireNonCancelableEvent(this.context.handlers.onClearHighlight, { isApiCall: false });\n }\n };\n\n // Callbacks used for hover and keyboard navigation, and also exposed to the public API to give the ability\n // to highlight and show tooltip for the given point or group manually.\n public highlightChartItems = (itemIds: readonly string[]) => {\n if (!this.isTooltipPinned) {\n this.chartExtraHighlight.highlightChartItems(itemIds);\n this.chartExtraLegend.onHighlightItems(itemIds);\n }\n };\n public setItemsVisible = (visibleItemsIds: readonly string[]) => {\n this.chartExtraLegend.onItemVisibilityChange(visibleItemsIds, { interactionType: \"api\" });\n };\n public highlightChartPoint = (point: Highcharts.Point, { isApiCall }: { isApiCall: boolean }) => {\n if (!this.isTooltipPinned) {\n this.highlightActions(point, { isApiCall });\n }\n };\n public highlightChartGroup = (group: readonly Highcharts.Point[], { isApiCall }: { isApiCall: boolean }) => {\n if (!this.isTooltipPinned) {\n this.highlightActions(group as Writeable<Highcharts.Point[]>, { isApiCall });\n }\n };\n public clearChartHighlight = ({ isApiCall }: { isApiCall: boolean }) => {\n if (!this.isTooltipPinned) {\n this.clearHighlightActions({ isApiCall });\n }\n };\n public get publicApi() {\n return {\n highlightItems: (itemIds: readonly string[]) => this.highlightChartItems(itemIds),\n setItemsVisible: (visibleItemIds: readonly string[]) => this.setItemsVisible(visibleItemIds),\n highlightChartPoint: (point: Highcharts.Point) => this.highlightChartPoint(point, { isApiCall: true }),\n highlightChartGroup: (group: readonly Highcharts.Point[]) => this.highlightChartGroup(group, { isApiCall: true }),\n clearChartHighlight: () => this.clearChartHighlight({ isApiCall: true }),\n };\n }\n\n // A set of callbacks required for keyboard navigation.\n private get navigationHandlers(): ChartExtraNavigationHandlers {\n return {\n onFocusChart: () => {\n this.clearChartHighlight({ isApiCall: false });\n this.chartExtraNavigation.announceChart(getChartAccessibleDescription(this.context.chart()));\n },\n onFocusGroup: (group: Highcharts.Point[]) => {\n this.highlightActions(group, { isApiCall: false, overrideTooltipLock: true });\n this.chartExtraNavigation.announceElement(getGroupAccessibleDescription(group), false);\n },\n onFocusPoint: (point: Highcharts.Point) => {\n const labels = this.context.settings.labels;\n this.highlightActions(point, { isApiCall: false, overrideTooltipLock: true });\n this.chartExtraNavigation.announceElement(getPointAccessibleDescription(point, labels), false);\n },\n onBlur: () => this.clearChartHighlight({ isApiCall: false }),\n onActivateGroup: () => {\n const current = this.chartExtraTooltip.get();\n if (current.group.length > 0) {\n this.chartExtraTooltip.pinTooltip();\n this.chartExtraNavigation.announceElement(getGroupAccessibleDescription(current.group), true);\n }\n },\n onActivatePoint: () => {\n const current = this.chartExtraTooltip.get();\n if (current.point) {\n const labels = this.context.settings.labels;\n this.chartExtraTooltip.pinTooltip();\n this.chartExtraNavigation.announceElement(getPointAccessibleDescription(current.point, labels), true);\n }\n },\n };\n }\n\n // A set of callbacks required for pointer navigation.\n private get pointerHandlers(): ChartExtraPointerHandlers {\n return {\n onPointHover: (point) => {\n this.highlightChartPoint(point, { isApiCall: false });\n },\n onGroupHover: (group) => {\n this.highlightChartGroup(group, { isApiCall: false });\n },\n onHoverLost: () => {\n this.clearChartHighlight({ isApiCall: false });\n },\n onPointClick: (point) => {\n this.pinTooltipOnPoint(point);\n },\n onGroupClick: (group) => {\n this.pinTooltipOnGroup(group);\n },\n };\n }\n\n // Area- or line series can be defined with just a single point, or include missing data (y=null) in such\n // a way, that certain points become isolated. As we prefer the markers to not be shown for area- and line\n // series by default, those points become invisible, unless hovered. To fix this, we use the function below,\n // that finds isolates points and overrides the marker.enabled configuration for those.\n // See: https://github.com/highcharts/highcharts/issues/1210.\n private showMarkersForIsolatedPoints() {\n let shouldRedraw = false;\n for (const s of this.context.chart().series) {\n const seriesData = getSeriesData(s.data);\n for (let i = 0; i < seriesData.length; i++) {\n const isEligibleSeries = !isXThreshold(s) && s.type !== \"scatter\" && !seriesData[i].options.marker?.enabled;\n if (\n isEligibleSeries &&\n (seriesData[i - 1]?.y === undefined || seriesData[i - 1]?.y === null) &&\n (seriesData[i + 1]?.y === undefined || seriesData[i + 1]?.y === null)\n ) {\n seriesData[i].update({ marker: { enabled: true } }, false);\n shouldRedraw = true;\n }\n }\n }\n if (shouldRedraw) {\n this.context.chart().redraw();\n }\n }\n\n // Highcharts sometimes destroys points upon re-rendering. As result, the already stored points can get\n // replaced by `{ destroyed: true }`. This can affect the tooltip state, making the component crash when\n // obtaining data from points, or making it hidden yet pinned, so not visible on hover until a click is made.\n // To prevent these issues, on each render we check for destroyed points in the tooltip state, and proactively\n // hide the tooltip if found. The behavior is only observed during the initial chart loading, and is not expected\n // to cause UX issues with the tooltip being closed unexpectedly.\n // See: https://github.com/highcharts/highcharts/issues/23175.\n private handleDestroyedPoints() {\n const tooltipState = this.chartExtraTooltip.get();\n if (tooltipState.group.some((p) => !p.series)) {\n this.chartExtraTooltip.hideTooltip();\n }\n }\n\n // We reset color counter so that when a series is removed and then added back - it will\n // have the same color as before, not the next one in the color sequence.\n // See: https://github.com/highcharts/highcharts/issues/23077.\n private resetColorCounter() {\n const chart = this.context.chart();\n if (\"colorCounter\" in chart && typeof chart.colorCounter === \"number\") {\n chart.colorCounter = getChartSeries(chart.series).length;\n }\n }\n\n private pinTooltipOnPoint = (point: Highcharts.Point) => {\n const currentPoint = this.chartExtraTooltip.get().point;\n const currentGroup = this.chartExtraTooltip.get().group;\n const positionsMatch = isPointsPositionsEqual(currentPoint ?? currentGroup[0], point);\n\n // If the previously hovered and now clicked positions match, and the the tooltip wasn't\n // dismissed just a moment ago, we make the tooltip pinned in this position.\n if (positionsMatch && !this.chartExtraTooltip.tooltipLock) {\n this.highlightActions(point, { isApiCall: false });\n this.chartExtraTooltip.pinTooltip();\n }\n // If the tooltip was just dismissed, it means this happened by clicking somewhere in the plot area.\n // If the clicked position differs from the one that was pinned - we show tooltip in the new position.\n else if (!positionsMatch && this.chartExtraTooltip.tooltipLock) {\n this.highlightActions(point, { isApiCall: false, overrideTooltipLock: true });\n }\n };\n\n private pinTooltipOnGroup = (group: Highcharts.Point[]) => {\n const currentPoint = this.chartExtraTooltip.get().point;\n const currentGroup = this.chartExtraTooltip.get().group;\n const positionsMatch = isPointsPositionsEqual(currentPoint ?? currentGroup[0], group[0]);\n\n // If the previously hovered and now clicked positions match, and the the tooltip wasn't\n // dismissed just a moment ago, we make the tooltip pinned in this position.\n if (positionsMatch && !this.chartExtraTooltip.tooltipLock) {\n this.highlightActions(group, { isApiCall: false });\n this.chartExtraTooltip.pinTooltip();\n }\n // If the tooltip was just dismissed, it means this happened by clicking somewhere in the plot area.\n // If the clicked position differs from the one that was pinned - we show tooltip in the new position.\n else if (!positionsMatch && this.chartExtraTooltip.tooltipLock) {\n this.highlightActions(group, { isApiCall: false, overrideTooltipLock: true });\n }\n };\n\n private highlightActions(\n target: Highcharts.Point | Highcharts.Point[],\n { isApiCall, overrideTooltipLock }: { isApiCall: boolean; overrideTooltipLock?: boolean },\n ) {\n const point = Array.isArray(target) ? null : target;\n const group = Array.isArray(target) ? target : this.context.derived.getPointsByX(target.x);\n\n if (!this.isTooltipPinned) {\n // Update Highcharts elements state.\n if (point) {\n this.chartExtraHighlight.highlightChartPoint(point);\n } else {\n this.chartExtraHighlight.highlightChartGroup(group);\n }\n\n // Update tooltip and legend state.\n if (point) {\n this.chartExtraLegend.onHighlightPoint(point);\n this.chartExtraTooltip.showTooltipOnPoint(point, group, overrideTooltipLock);\n } else {\n this.chartExtraLegend.onHighlightGroup(group);\n this.chartExtraTooltip.showTooltipOnGroup(group, overrideTooltipLock);\n }\n\n // Notify the consumer that a highlight action was made.\n fireNonCancelableEvent(this.context.handlers.onHighlight, { point, group, isApiCall });\n }\n }\n\n private clearHighlightActions = ({ isApiCall }: { isApiCall: boolean }) => {\n if (!this.isTooltipPinned) {\n // Update Highcharts elements state.\n this.chartExtraHighlight.clearChartItemsHighlight();\n\n // Update tooltip and legend state.\n this.chartExtraTooltip.hideTooltip();\n this.chartExtraLegend.onClearHighlight();\n\n // Notify the consumer that a clear-highlight action was made.\n fireNonCancelableEvent(this.context.handlers.onClearHighlight, { isApiCall });\n }\n };\n\n private get isTooltipPinned() {\n return this.chartExtraTooltip.get().pinned;\n }\n}\n\nfunction isPointsPositionsEqual(current?: Highcharts.Point, next?: Highcharts.Point) {\n return current?.x === next?.x && current?.y === next?.y;\n}\n"]}
@@ -13,7 +13,7 @@ export function ChartFilters({ seriesFilter, additionalFilters, api, i18nStrings
13
13
  function ChartSeriesFilter({ api, i18nStrings }) {
14
14
  const i18n = useInternalI18n("[charts]");
15
15
  const legendItems = useSelector(api.legendStore, (s) => s.items);
16
- return (_jsx(InternalChartSeriesFilter, { items: legendItems, selectedItems: legendItems.filter((i) => i.visible).map((i) => i.id), onChange: ({ detail }) => api.onItemVisibilityChange(detail.selectedItems), i18nStrings: {
16
+ return (_jsx(InternalChartSeriesFilter, { items: legendItems, selectedItems: legendItems.filter((i) => i.visible).map((i) => i.id), onChange: ({ detail }) => api.onItemVisibilityChange(detail.selectedItems, { interactionType: "filter" }), i18nStrings: {
17
17
  filterLabel: i18n("i18nStrings.filterLabel", i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.seriesFilterLabel),
18
18
  filterPlaceholder: i18n("i18nStrings.filterPlaceholder", i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.seriesFilterPlaceholder),
19
19
  filterSelectedAriaLabel: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.seriesFilterSelectedAriaLabel,
@@ -1 +1 @@
1
- {"version":3,"file":"core-filters.js","sourceRoot":"","sources":["../../../../src/core/components/core-filters.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,wDAAwD,CAAC;AAEzF,OAAO,yBAAyB,MAAM,+CAA+C,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAI/D,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,WAAW,MAAM,+BAA+B,CAAC;AAExD,MAAM,UAAU,YAAY,CAAC,EAC3B,YAAY,EACZ,iBAAiB,EACjB,GAAG,EACH,WAAW,GAMZ;IACC,OAAO,CACL,eAAK,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC,aACxE,YAAY,IAAI,CACf,cAAK,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAAC,EAAE,MAAM,CAAC,sBAAsB,CAAC,CAAC,YACvF,KAAC,iBAAiB,IAAC,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,WAAW,GAAI,GACrD,CACP,EACA,iBAAiB,IAAI,cAAK,SAAS,EAAE,WAAW,CAAC,0BAA0B,CAAC,YAAG,iBAAiB,GAAO,IACpG,CACP,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,EAAE,GAAG,EAAE,WAAW,EAAoD;IAC/F,MAAM,IAAI,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;IACzC,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACjE,OAAO,CACL,KAAC,yBAAyB,IACxB,KAAK,EAAE,WAAW,EAClB,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EACpE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,sBAAsB,CAAC,MAAM,CAAC,aAAa,CAAC,EAC1E,WAAW,EAAE;YACX,WAAW,EAAE,IAAI,CAAC,yBAAyB,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,iBAAiB,CAAC;YAC5E,iBAAiB,EAAE,IAAI,CAAC,+BAA+B,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,uBAAuB,CAAC;YAC9F,uBAAuB,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,6BAA6B;SACpE,GACD,CACH,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport clsx from \"clsx\";\n\nimport { useInternalI18n } from \"@cloudscape-design/components/internal/do-not-use/i18n\";\n\nimport InternalChartSeriesFilter from \"../../internal/components/chart-series-filter\";\nimport { useSelector } from \"../../internal/utils/async-store\";\nimport { ChartAPI } from \"../chart-api\";\nimport { BaseI18nStrings } from \"../interfaces\";\n\nimport styles from \"../styles.css.js\";\nimport testClasses from \"../test-classes/styles.css.js\";\n\nexport function ChartFilters({\n seriesFilter,\n additionalFilters,\n api,\n i18nStrings,\n}: {\n seriesFilter?: boolean;\n additionalFilters?: React.ReactNode;\n api: ChartAPI;\n i18nStrings?: BaseI18nStrings;\n}) {\n return (\n <div className={clsx(testClasses[\"chart-filters\"], styles[\"chart-filters\"])}>\n {seriesFilter && (\n <div className={clsx(testClasses[\"chart-filters-series\"], styles[\"chart-filters-series\"])}>\n <ChartSeriesFilter api={api} i18nStrings={i18nStrings} />\n </div>\n )}\n {additionalFilters && <div className={testClasses[\"chart-filters-additional\"]}>{additionalFilters}</div>}\n </div>\n );\n}\n\nfunction ChartSeriesFilter({ api, i18nStrings }: { api: ChartAPI; i18nStrings?: BaseI18nStrings }) {\n const i18n = useInternalI18n(\"[charts]\");\n const legendItems = useSelector(api.legendStore, (s) => s.items);\n return (\n <InternalChartSeriesFilter\n items={legendItems}\n selectedItems={legendItems.filter((i) => i.visible).map((i) => i.id)}\n onChange={({ detail }) => api.onItemVisibilityChange(detail.selectedItems)}\n i18nStrings={{\n filterLabel: i18n(\"i18nStrings.filterLabel\", i18nStrings?.seriesFilterLabel),\n filterPlaceholder: i18n(\"i18nStrings.filterPlaceholder\", i18nStrings?.seriesFilterPlaceholder),\n filterSelectedAriaLabel: i18nStrings?.seriesFilterSelectedAriaLabel,\n }}\n />\n );\n}\n"]}
1
+ {"version":3,"file":"core-filters.js","sourceRoot":"","sources":["../../../../src/core/components/core-filters.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,wDAAwD,CAAC;AAEzF,OAAO,yBAAyB,MAAM,+CAA+C,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAI/D,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,WAAW,MAAM,+BAA+B,CAAC;AAExD,MAAM,UAAU,YAAY,CAAC,EAC3B,YAAY,EACZ,iBAAiB,EACjB,GAAG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,WAAW,CAAE,uBAAuB,CAAC;YAC9F,uBAAuB,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,6BAA6B;SACpE,GACD,CACH,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport clsx from \"clsx\";\n\nimport { useInternalI18n } from \"@cloudscape-design/components/internal/do-not-use/i18n\";\n\nimport InternalChartSeriesFilter from \"../../internal/components/chart-series-filter\";\nimport { useSelector } from \"../../internal/utils/async-store\";\nimport { ChartAPI } from \"../chart-api\";\nimport { BaseI18nStrings } from \"../interfaces\";\n\nimport styles from \"../styles.css.js\";\nimport testClasses from \"../test-classes/styles.css.js\";\n\nexport function ChartFilters({\n seriesFilter,\n additionalFilters,\n api,\n i18nStrings,\n}: {\n seriesFilter?: boolean;\n additionalFilters?: React.ReactNode;\n api: ChartAPI;\n i18nStrings?: BaseI18nStrings;\n}) {\n return (\n <div className={clsx(testClasses[\"chart-filters\"], styles[\"chart-filters\"])}>\n {seriesFilter && (\n <div className={clsx(testClasses[\"chart-filters-series\"], styles[\"chart-filters-series\"])}>\n <ChartSeriesFilter api={api} i18nStrings={i18nStrings} />\n </div>\n )}\n {additionalFilters && <div className={testClasses[\"chart-filters-additional\"]}>{additionalFilters}</div>}\n </div>\n );\n}\n\nfunction ChartSeriesFilter({ api, i18nStrings }: { api: ChartAPI; i18nStrings?: BaseI18nStrings }) {\n const i18n = useInternalI18n(\"[charts]\");\n const legendItems = useSelector(api.legendStore, (s) => s.items);\n return (\n <InternalChartSeriesFilter\n items={legendItems}\n selectedItems={legendItems.filter((i) => i.visible).map((i) => i.id)}\n onChange={({ detail }) => api.onItemVisibilityChange(detail.selectedItems, { interactionType: \"filter\" })}\n i18nStrings={{\n filterLabel: i18n(\"i18nStrings.filterLabel\", i18nStrings?.seriesFilterLabel),\n filterPlaceholder: i18n(\"i18nStrings.filterPlaceholder\", i18nStrings?.seriesFilterPlaceholder),\n filterSelectedAriaLabel: i18nStrings?.seriesFilterSelectedAriaLabel,\n }}\n />\n );\n}\n"]}
@@ -21,10 +21,10 @@ export function ChartLegend({ api, title, actions, alignment, className, isSecon
21
21
  const onToggleItem = (itemId) => {
22
22
  const visibleItems = legendItems.filter((i) => i.visible).map((i) => i.id);
23
23
  if (visibleItems.includes(itemId)) {
24
- api.onItemVisibilityChange(visibleItems.filter((visibleItemId) => visibleItemId !== itemId));
24
+ api.onItemVisibilityChange(visibleItems.filter((visibleItemId) => visibleItemId !== itemId), { interactionType: "toggle", targetItemId: itemId });
25
25
  }
26
26
  else {
27
- api.onItemVisibilityChange([...visibleItems, itemId]);
27
+ api.onItemVisibilityChange([...visibleItems, itemId], { interactionType: "toggle", targetItemId: itemId });
28
28
  }
29
29
  // Needed for touch devices.
30
30
  api.onClearChartItemsHighlight();
@@ -32,10 +32,10 @@ export function ChartLegend({ api, title, actions, alignment, className, isSecon
32
32
  const onSelectItem = (itemId) => {
33
33
  const visibleItems = legendItems.filter((i) => i.visible).map((i) => i.id);
34
34
  if (visibleItems.length === 1 && visibleItems[0] === itemId) {
35
- api.onItemVisibilityChange(legendItems.map((i) => i.id));
35
+ api.onItemVisibilityChange(legendItems.map((i) => i.id), { interactionType: "select", targetItemId: itemId });
36
36
  }
37
37
  else {
38
- api.onItemVisibilityChange([itemId]);
38
+ api.onItemVisibilityChange([itemId], { interactionType: "select", targetItemId: itemId });
39
39
  }
40
40
  // Needed for touch devices.
41
41
  api.onClearChartItemsHighlight();
@@ -1 +1 @@
1
- {"version":3,"file":"core-legend.js","sourceRoot":"","sources":["../../../../src/core/components/core-legend.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,wDAAwD,CAAC;AAEzF,OAAO,EAAE,WAAW,IAAI,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC7F,OAAO,EAAE,sBAAsB,EAA6B,MAAM,uBAAuB,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I,CAAC;IACd,CAAC;IACD,OAAO,CACL,KAAC,oBAAoB,IACnB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,KAAK,EAClB,KAAK,EAAE,aAAa,EACpB,eAAe,EAAE,eAAe,EAChC,mBAAmB,EAAE,mBAAmB,EACxC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAC1B,mBAAmB,EAAE,GAAG,CAAC,0BAA0B,EACnD,oBAAoB,EAAE,CAAC,IAAI,EAAE,EAAE;YAC7B,GAAG,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;YACrC,sBAAsB,CAAC,eAAe,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QACpD,CAAC,EACD,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE;;YAC3B,IAAI,oBAAoB,EAAE,CAAC;gBACzB,OAAO,IAAI,CAAC;YACd,CAAC;YACD,OAAO,MAAA,uBAAuB,aAAvB,uBAAuB,uBAAvB,uBAAuB,CAAG,KAAK,CAAC,mCAAI,IAAI,CAAC;QAClD,CAAC,GACD,CACH,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useInternalI18n } from \"@cloudscape-design/components/internal/do-not-use/i18n\";\n\nimport { ChartLegend as ChartLegendComponent } from \"../../internal/components/chart-legend\";\nimport { fireNonCancelableEvent, NonCancelableEventHandler } from \"../../internal/events\";\nimport { useSelector } from \"../../internal/utils/async-store\";\nimport { ChartAPI } from \"../chart-api\";\nimport { CoreChartProps, CoreI18nStrings } from \"../interfaces\";\n\nexport function ChartLegend({\n api,\n title,\n actions,\n alignment,\n className,\n isSecondary,\n i18nStrings,\n onItemHighlight,\n getLegendTooltipContent,\n horizontalAlignment = \"start\",\n}: {\n api: ChartAPI;\n title?: string;\n className?: string;\n isSecondary: boolean;\n actions?: React.ReactNode;\n alignment: \"horizontal\" | \"vertical\";\n horizontalAlignment?: \"start\" | \"center\" | \"end\";\n i18nStrings?: CoreI18nStrings;\n onItemHighlight?: NonCancelableEventHandler<CoreChartProps.LegendItemHighlightDetail>;\n getLegendTooltipContent?: CoreChartProps.GetLegendTooltipContent;\n}) {\n const i18n = useInternalI18n(\"[charts]\");\n const legendAriaLabel = i18n(\"i18nStrings.legendAriaLabel\", i18nStrings?.legendAriaLabel);\n // There's currently no builtin property for the secondary ARIA\n // label, it must be explicitly provided by the consumers.\n const secondaryLegendAriaLabel = i18nStrings?.secondaryLegendAriaLabel;\n const ariaLabel = isSecondary ? secondaryLegendAriaLabel : legendAriaLabel;\n\n const legendItems = useSelector(api.legendStore, (s) => s.items);\n const someHighlighted = legendItems.some((item) => item.highlighted);\n const isChartTooltipPinned = useSelector(api.tooltipStore, (s) => s.pinned);\n const filteredItems = isSecondary\n ? legendItems.filter((item) => item.isSecondary)\n : legendItems.filter((item) => !item.isSecondary);\n\n const onToggleItem = (itemId: string) => {\n const visibleItems = legendItems.filter((i) => i.visible).map((i) => i.id);\n if (visibleItems.includes(itemId)) {\n api.onItemVisibilityChange(visibleItems.filter((visibleItemId) => visibleItemId !== itemId));\n } else {\n api.onItemVisibilityChange([...visibleItems, itemId]);\n }\n // Needed for touch devices.\n api.onClearChartItemsHighlight();\n };\n\n const onSelectItem = (itemId: string) => {\n const visibleItems = legendItems.filter((i) => i.visible).map((i) => i.id);\n if (visibleItems.length === 1 && visibleItems[0] === itemId) {\n api.onItemVisibilityChange(legendItems.map((i) => i.id));\n } else {\n api.onItemVisibilityChange([itemId]);\n }\n // Needed for touch devices.\n api.onClearChartItemsHighlight();\n };\n\n if (filteredItems.length === 0) {\n return null;\n }\n return (\n <ChartLegendComponent\n ariaLabel={ariaLabel}\n className={className}\n legendTitle={title}\n items={filteredItems}\n someHighlighted={someHighlighted}\n horizontalAlignment={horizontalAlignment}\n actions={actions}\n alignment={alignment}\n onToggleItem={onToggleItem}\n onSelectItem={onSelectItem}\n onItemHighlightExit={api.onClearChartItemsHighlight}\n onItemHighlightEnter={(item) => {\n api.onHighlightChartItems([item.id]);\n fireNonCancelableEvent(onItemHighlight, { item });\n }}\n getTooltipContent={(props) => {\n if (isChartTooltipPinned) {\n return null;\n }\n return getLegendTooltipContent?.(props) ?? null;\n }}\n />\n );\n}\n"]}
1
+ {"version":3,"file":"core-legend.js","sourceRoot":"","sources":["../../../../src/core/components/core-legend.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,wDAAwD,CAAC;AAEzF,OAAO,EAAE,WAAW,IAAI,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC7F,OAAO,EAAE,sBAAsB,EAA6B,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAI/D,MAAM,UAAU,WAAW,CAAC,EAC1B,GAAG,EACH,KAAK,EACL,OAAO,EACP,SAAS,EACT,SAAS,EACT,WAAW,EACX,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,mBAAmB,GAAG,OAAO,GAY9B;IACC,MAAM,IAAI,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;IACzC,MAAM,eAAe,GAAG,IAAI,CAAC,6BAA6B,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,eAAe,CAAC,CAAC;IAC1F,+DAA+D;IAC/D,0DAA0D;IAC1D,MAAM,wBAAwB,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,wBAAwB,CAAC;IACvE,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,eAAe,CAAC;IAE3E,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,K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,CAAC,CAAC,CAAC;YACrC,sBAAsB,CAAC,eAAe,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QACpD,CAAC,EACD,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE;;YAC3B,IAAI,oBAAoB,EAAE,CAAC;gBACzB,OAAO,IAAI,CAAC;YACd,CAAC;YACD,OAAO,MAAA,uBAAuB,aAAvB,uBAAuB,uBAAvB,uBAAuB,CAAG,KAAK,CAAC,mCAAI,IAAI,CAAC;QAClD,CAAC,GACD,CACH,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useInternalI18n } from \"@cloudscape-design/components/internal/do-not-use/i18n\";\n\nimport { ChartLegend as ChartLegendComponent } from \"../../internal/components/chart-legend\";\nimport { fireNonCancelableEvent, NonCancelableEventHandler } from \"../../internal/events\";\nimport { useSelector } from \"../../internal/utils/async-store\";\nimport { ChartAPI } from \"../chart-api\";\nimport { CoreChartProps, CoreI18nStrings } from \"../interfaces\";\n\nexport function ChartLegend({\n api,\n title,\n actions,\n alignment,\n className,\n isSecondary,\n i18nStrings,\n onItemHighlight,\n getLegendTooltipContent,\n horizontalAlignment = \"start\",\n}: {\n api: ChartAPI;\n title?: string;\n className?: string;\n isSecondary: boolean;\n actions?: React.ReactNode;\n alignment: \"horizontal\" | \"vertical\";\n horizontalAlignment?: \"start\" | \"center\" | \"end\";\n i18nStrings?: CoreI18nStrings;\n onItemHighlight?: NonCancelableEventHandler<CoreChartProps.LegendItemHighlightDetail>;\n getLegendTooltipContent?: CoreChartProps.GetLegendTooltipContent;\n}) {\n const i18n = useInternalI18n(\"[charts]\");\n const legendAriaLabel = i18n(\"i18nStrings.legendAriaLabel\", i18nStrings?.legendAriaLabel);\n // There's currently no builtin property for the secondary ARIA\n // label, it must be explicitly provided by the consumers.\n const secondaryLegendAriaLabel = i18nStrings?.secondaryLegendAriaLabel;\n const ariaLabel = isSecondary ? secondaryLegendAriaLabel : legendAriaLabel;\n\n const legendItems = useSelector(api.legendStore, (s) => s.items);\n const someHighlighted = legendItems.some((item) => item.highlighted);\n const isChartTooltipPinned = useSelector(api.tooltipStore, (s) => s.pinned);\n const filteredItems = isSecondary\n ? legendItems.filter((item) => item.isSecondary)\n : legendItems.filter((item) => !item.isSecondary);\n\n const onToggleItem = (itemId: string) => {\n const visibleItems = legendItems.filter((i) => i.visible).map((i) => i.id);\n if (visibleItems.includes(itemId)) {\n api.onItemVisibilityChange(\n visibleItems.filter((visibleItemId) => visibleItemId !== itemId),\n { interactionType: \"toggle\", targetItemId: itemId },\n );\n } else {\n api.onItemVisibilityChange([...visibleItems, itemId], { interactionType: \"toggle\", targetItemId: itemId });\n }\n // Needed for touch devices.\n api.onClearChartItemsHighlight();\n };\n\n const onSelectItem = (itemId: string) => {\n const visibleItems = legendItems.filter((i) => i.visible).map((i) => i.id);\n if (visibleItems.length === 1 && visibleItems[0] === itemId) {\n api.onItemVisibilityChange(\n legendItems.map((i) => i.id),\n { interactionType: \"select\", targetItemId: itemId },\n );\n } else {\n api.onItemVisibilityChange([itemId], { interactionType: \"select\", targetItemId: itemId });\n }\n // Needed for touch devices.\n api.onClearChartItemsHighlight();\n };\n\n if (filteredItems.length === 0) {\n return null;\n }\n return (\n <ChartLegendComponent\n ariaLabel={ariaLabel}\n className={className}\n legendTitle={title}\n items={filteredItems}\n someHighlighted={someHighlighted}\n horizontalAlignment={horizontalAlignment}\n actions={actions}\n alignment={alignment}\n onToggleItem={onToggleItem}\n onSelectItem={onSelectItem}\n onItemHighlightExit={api.onClearChartItemsHighlight}\n onItemHighlightEnter={(item) => {\n api.onHighlightChartItems([item.id]);\n fireNonCancelableEvent(onItemHighlight, { item });\n }}\n getTooltipContent={(props) => {\n if (isChartTooltipPinned) {\n return null;\n }\n return getLegendTooltipContent?.(props) ?? null;\n }}\n />\n );\n}\n"]}
@@ -444,10 +444,23 @@ export declare namespace CoreChartProps {
444
444
  interface LegendItemHighlightDetail {
445
445
  item: LegendItem;
446
446
  }
447
- interface VisibleItemsChangeDetail {
448
- items: readonly LegendItem[];
449
- isApiCall: boolean;
447
+ interface ApiInteraction {
448
+ interactionType: "api";
449
+ }
450
+ interface FilterInteraction {
451
+ interactionType: "filter";
452
+ }
453
+ interface ToggleInteraction {
454
+ interactionType: "toggle";
455
+ targetItemId: string;
450
456
  }
457
+ interface SelectInteraction {
458
+ interactionType: "select";
459
+ targetItemId: string;
460
+ }
461
+ type VisibleItemsChangeDetail = {
462
+ items: readonly LegendItem[];
463
+ } & (ApiInteraction | FilterInteraction | ToggleInteraction | SelectInteraction);
451
464
  interface HighlightChangeDetail {
452
465
  point: null | Highcharts.Point;
453
466
  group: readonly Highcharts.Point[];
@@ -476,9 +489,9 @@ export declare namespace CoreLegendProps {
476
489
  interface ItemHighlightDetail {
477
490
  item: Item;
478
491
  }
479
- interface VisibleItemsChangeDetail {
492
+ type VisibleItemsChangeDetail = {
480
493
  items: readonly string[];
481
- }
494
+ } & (CoreChartProps.ToggleInteraction | CoreChartProps.SelectInteraction);
482
495
  }
483
496
  export interface Rect {
484
497
  x: number;
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/core/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type Highcharts from \"highcharts\";\n\nimport type * as InternalComponentTypes from \"../internal/components/interfaces\";\nimport { ChartSeriesMarkerStatus } from \"../internal/components/series-marker/interfaces\";\nimport { type NonCancelableEventHandler } from \"../internal/events\";\n\n// All charts take `highcharts` instance, that can be served statically or dynamically.\n// Although it has to be of type Highcharts, the TS type we use is `null | object`, so\n// that it is ignored by the documenter.\n\n/**\n * This interface includes common public chart properties, applicable for all chart types.\n */\nexport interface BaseChartOptions {\n /**\n * The Highcharts instance, which can be obtained using `import Highcharts from \"highcharts\"`.\n * Supported Highcharts versions: 12.\n */\n highcharts: null | object;\n\n /**\n * Custom content that renders when `highcharts=null`. It renders a spinner if not defined.\n */\n fallback?: React.ReactNode;\n\n /**\n * The height of the chart plot in pixels. It does not include legend and filter.\n */\n chartHeight?: number;\n\n /**\n * The chart automatically adjusts its height to fill the parent container when this property is set.\n */\n fitHeight?: boolean;\n\n /**\n * Defines the minimum allowed height of the chart plot. Use this when `fitHeight=true` to\n * prevent the chart plot from becoming too small to display its content. When the parent\n * container is shorter than the minimum height, a vertical scrollbar appears automatically.\n */\n chartMinHeight?: number;\n\n /**\n * Defines the minimum allowed width of the chart plot. When the parent container is narrower than the\n * minimum width, the horizontal scrollbar is automatically added.\n */\n chartMinWidth?: number;\n\n /**\n * Defines the ARIA label for the chart container.\n * This property corresponds to [lang.chartContainerLabel](https://api.highcharts.com/highcharts/lang.accessibility.chartContainerLabel),\n * and requires the [accessibility module](https://www.highcharts.com/docs/accessibility/accessibility-module).\n */\n ariaLabel?: string;\n\n /**\n * Defines the ARIA description of the chart container.\n * This property corresponds to [accessibility.description](https://api.highcharts.com/highcharts/accessibility.description),\n * and requires the [accessibility module](https://www.highcharts.com/docs/accessibility/accessibility-module).\n */\n ariaDescription?: string;\n\n /**\n * Defines chart legend options, including:\n * * `enabled` (optional, boolean) - Hides legend when set to `false`.\n * * `title` (optional, string) - Visible label, shown above the legend.\n * * `actions` (optional, slot) - A slot before the legend that can be used to render custom actions.\n */\n legend?: BaseLegendOptions;\n\n /**\n * Defines options to represent empty, no-match, loading, and error state of the chart, including:\n * * `statusType` (optional, \"finished\" | \"loading\" | \"error\") - Specifies the current status of loading data.\n * * `empty` (optional, ReactNode) - Content displayed when the chart data is empty.\n * * `noMatch` (optional, ReactNode) - Content displayed when there is no data to display due to the built-in filtering.\n * * `loading` (optional, ReactNode) - Content displayed when `statusType=\"loading\"`. If omitted, the default loading state\n * is shown, using `i18n.loadingText` or built-in i18n.\n * * `error` (optional, ReactNode) - Content displayed when `statusType=\"error\"`. If omitted, the default error state\n * is shown, using `i18n.errorText` and `i18n.recoveryText` (when `onRecoveryClick` is provided), or built-in i18n.\n * * `onRecoveryClick` (optional, function) - Called when the user clicks the recovery button that appears when using default error\n * state, and only if `onRecoveryClick` is provided. Use this to enable the user to retry a failed request or provide another option\n * for the user to recover from the error.\n */\n noData?: BaseNoDataOptions;\n\n /**\n * Defines options for filtering in the chart, including:\n * * `seriesFilter` (optional, boolean) - Displays default series filter at the top of the chart.\n * * `additionalFilters` (optional, slot) - A slot for custom chart filters at the top of the chart.\n */\n filter?: BaseFilterOptions;\n}\n\nexport interface BaseLegendOptions {\n enabled?: boolean;\n title?: string;\n actions?: React.ReactNode;\n}\n\nexport interface BaseNoDataOptions {\n statusType?: \"finished\" | \"loading\" | \"error\";\n empty?: React.ReactNode;\n error?: React.ReactNode;\n loading?: React.ReactNode;\n noMatch?: React.ReactNode;\n onRecoveryClick?: NonCancelableEventHandler;\n}\n\nexport interface BaseTooltipDetail {\n key: React.ReactNode;\n value: React.ReactNode;\n}\n\nexport interface BaseI18nStrings {\n loadingText?: string;\n errorText?: string;\n recoveryText?: string;\n seriesFilterLabel?: string;\n seriesFilterPlaceholder?: string;\n seriesFilterSelectedAriaLabel?: string;\n legendAriaLabel?: string;\n detailPopoverDismissAriaLabel?: string;\n chartRoleDescription?: string;\n}\n\nexport interface CoreI18nStrings extends BaseI18nStrings {\n /**\n * ARIA label for the secondary legend when using dual axes charts.\n *\n * **Important**: When using dual axes, you should explicitly provide visible titles or ARIA labels\n * for both the primary and secondary legends to ensure proper accessibility. The primary legend\n * has built-in i18n support through `legendAriaLabel`, but the secondary legend currently requires\n * this property to be explicitly provided.\n */\n secondaryLegendAriaLabel?: string;\n\n /**\n * ARIA label for the marker of a series. Series with status \"default\" will not announce a label, thus excluded by this method.\n */\n itemMarkerStatusAriaLabel?: (status: Exclude<ChartSeriesMarkerStatus, \"default\">) => string;\n}\n\nexport interface WithCartesianI18nStrings {\n /**\n * An object that contains all of the localized strings required by the component.\n * @i18n\n *\n * Available properties:\n * * `loadingText` (optional, string) - Text, displayed when the chart is loading, i.e. when `noData.statusType` is set to \"loading\".\n * * `errorText` (optional, string) - Text, displayed when the chart is in error state, i.e. when `noData.statusType` is set to \"error\".\n * * `recoveryText` (optional, string) - Text for the recovery button, displayed next to the error text.\n * * `seriesFilterLabel` (optional, string) - Text for the visible label of the default series filter.\n * * `seriesFilterPlaceholder` (optional, string) - Text for the default series filter placeholder.\n * * `seriesFilterSelectedAriaLabel` (optional, string) - ARIA label of the default series filter which is appended to any option that is selected.\n * * `legendAriaLabel` (optional, string) - ARIA label that is associated with the legend in case there is no visible `legend.title` defined.\n * * `detailPopoverDismissAriaLabel` (optional, string) - ARIA label for the details popover dismiss button.\n * * `chartRoleDescription` (optional, string) - Accessible role description of the chart plot area, e.g. \"interactive chart\".\n * * `xAxisRoleDescription` (optional, string) - Accessible role description of the x axis, e.g. \"x axis\".\n * * `yAxisRoleDescription` (optional, string) - Accessible role description of the y axis, e.g. \"y axis\".\n */\n i18nStrings?: CartesianI18nStrings;\n}\n\nexport interface WithPieI18nStrings {\n /**\n * An object that contains all of the localized strings required by the component.\n * @i18n\n *\n * Available properties:\n * * `loadingText` (optional, string) - Text, displayed when the chart is loading, i.e. when `noData.statusType` is set to \"loading\".\n * * `errorText` (optional, string) - Text, displayed when the chart is in error state, i.e. when `noData.statusType` is set to \"error\".\n * * `recoveryText` (optional, string) - Text for the recovery button, displayed next to the error text.\n * * `seriesFilterLabel` (optional, string) - Text for the visible label of the default series filter.\n * * `seriesFilterPlaceholder` (optional, string) - Text for the default series filter placeholder.\n * * `seriesFilterSelectedAriaLabel` (optional, string) - ARIA label of the default series filter which is appended to any option that is selected.\n * * `legendAriaLabel` (optional, string) - ARIA label that is associated with the legend in case there is no visible `legend.title` defined.\n * * `detailPopoverDismissAriaLabel` (optional, string) - ARIA label for the details popover dismiss button.\n * * `chartRoleDescription` (optional, string) - Accessible role description of the chart plot area, e.g. \"interactive chart\".\n * * `segmentRoleDescription` (optional, string) - Accessible role description of the segment.\n */\n i18nStrings?: PieI18nStrings;\n}\n\nexport interface CartesianI18nStrings extends BaseI18nStrings {\n xAxisRoleDescription?: string;\n yAxisRoleDescription?: string;\n}\n\nexport interface PieI18nStrings extends BaseI18nStrings {\n segmentRoleDescription?: string;\n}\n\nexport interface BaseFilterOptions {\n seriesFilter?: boolean;\n additionalFilters?: React.ReactNode;\n}\n\nexport interface BaseTooltipPointFormatted {\n key?: React.ReactNode;\n value?: React.ReactNode;\n description?: React.ReactNode;\n expandable?: boolean;\n subItems?: ReadonlyArray<{ key: React.ReactNode; value: React.ReactNode }>;\n}\n\nexport interface AreaSeriesOptions extends BaseCartesianLineLikeOptions {\n type: \"area\";\n data: readonly PointDataItemType[];\n}\n\nexport interface AreaSplineSeriesOptions extends BaseCartesianLineLikeOptions {\n type: \"areaspline\";\n data: readonly PointDataItemType[];\n}\n\nexport interface ColumnSeriesOptions extends BaseCartesianSeriesOptions {\n type: \"column\";\n data: readonly PointDataItemType[];\n}\n\nexport interface LineSeriesOptions extends BaseCartesianLineLikeOptions {\n type: \"line\";\n data: readonly PointDataItemType[];\n}\n\nexport interface SplineSeriesOptions extends BaseCartesianLineLikeOptions {\n type: \"spline\";\n data: readonly PointDataItemType[];\n}\n\nexport interface ScatterSeriesOptions extends BaseCartesianSeriesOptions {\n type: \"scatter\";\n data: readonly PointDataItemType[];\n marker?: PointMarkerOptions;\n}\n\nexport interface ErrorBarSeriesOptions extends Omit<BaseCartesianSeriesOptions, \"name\"> {\n type: \"errorbar\";\n name?: string;\n data: readonly RangeDataItemOptions[];\n linkedTo: string;\n}\n\nexport interface XThresholdSeriesOptions extends BaseCartesianLineLikeOptions {\n type: \"x-threshold\";\n value: number;\n}\n\nexport interface YThresholdSeriesOptions extends BaseCartesianLineLikeOptions {\n type: \"y-threshold\";\n value: number;\n}\n\nexport interface PieSeriesOptions extends BaseSeriesOptions {\n type: \"pie\";\n data: readonly PieSegmentOptions[];\n}\n\nexport interface DonutSeriesOptions extends BaseSeriesOptions {\n type: \"donut\";\n data: readonly PieSegmentOptions[];\n}\n\nexport interface PieSegmentOptions {\n y: number | null;\n id?: string;\n name: string;\n color?: string;\n}\n\nexport type PointDataItemType = null | number | PointDataItemOptions;\n\nexport interface PointDataItemOptions {\n x?: number;\n y: number | null;\n}\n\nexport interface RangeDataItemOptions {\n x?: number;\n low: number;\n high: number;\n}\n\ninterface BaseSeriesOptions {\n id?: string;\n name: string;\n color?: string;\n}\n\ntype BaseCartesianSeriesOptions = BaseSeriesOptions;\n\ninterface BaseCartesianLineLikeOptions extends BaseCartesianSeriesOptions {\n dashStyle?: Highcharts.DashStyleValue;\n}\n\n// The symbols union matches that of Highcharts.PointMarkerOptionsObject\ninterface PointMarkerOptions {\n symbol?: \"circle\" | \"diamond\" | \"square\" | \"triangle\" | \"triangle-down\";\n}\n\nexport interface CoreCartesianOptions {\n /**\n * When set to `true`, adds a visual emphasis on the zero baseline axis.\n */\n emphasizeBaseline?: boolean;\n /**\n * Controls the placement of the vertical axis title.\n * When set to \"side\", displays the title along the axis line.\n */\n verticalAxisTitlePlacement?: \"top\" | \"side\";\n}\n\nexport interface CoreChartProps\n extends\n Pick<\n BaseChartOptions,\n | \"highcharts\"\n | \"fallback\"\n | \"fitHeight\"\n | \"chartHeight\"\n | \"chartMinHeight\"\n | \"chartMinWidth\"\n | \"ariaLabel\"\n | \"ariaDescription\"\n | \"filter\"\n | \"noData\"\n >,\n CoreCartesianOptions {\n /**\n * The Highcharts options. Cloudscape injects custom styles and settings, but all can be\n * overridden with explicitly provided options. An exception is event handlers - those are\n * not overridden, but merged with Cloudscape event handlers so that both are getting called.\n */\n options: CoreChartProps.ChartOptions;\n /**\n * The Cloudscape tooltip, that comes with a vertical cursor when used on cartesian series.\n * The tooltip content is only shown when `getContent` property is defined, which is called\n * for each visited { x, y } point.\n */\n tooltip?: CoreChartProps.TooltipOptions;\n /**\n * A custom slot above the chart plot, chart's axis title, and filter.\n */\n header?: CoreChartProps.HeaderOptions;\n /**\n * Prop for passing a custom navigation control component to be rendered with the chart.\n * Use this property to add timeline navigation, range selectors, or other custom navigation elements.\n */\n navigator?: React.ReactNode;\n /**\n * A custom slot below the chart plot and legend.\n */\n footer?: CoreChartProps.FooterOptions;\n /**\n * Chart legend options.\n */\n legend?: CoreChartProps.LegendOptions;\n /**\n * The callback to init the chart's API when it is ready. The API includes the Highcharts chart object, and\n * additional Cloudscape methods.\n */\n callback?: (chart: CoreChartProps.ChartAPI) => void;\n /**\n * This is used to provide a test-utils selector. Do not use this property to provide custom styles.\n */\n className?: string;\n /**\n * IDs of visible series or points.\n */\n visibleItems?: readonly string[];\n /**\n * Called when a legend item is highlighted.\n */\n onLegendItemHighlight?: NonCancelableEventHandler<CoreChartProps.LegendItemHighlightDetail>;\n /**\n * Called when series/points visibility changes due to user interaction with legend or filter.\n */\n onVisibleItemsChange?: NonCancelableEventHandler<CoreChartProps.VisibleItemsChangeDetail>;\n /**\n * Called whenever chart tooltip is rendered to provide content for tooltip's header, body, and (optional) footer.\n */\n getTooltipContent?: CoreChartProps.GetTooltipContent;\n /**\n * Called whenever a legend item is hovered to provide content for legend tooltip's header, body, and (optional) footer.\n * If not provided, no tooltip will be displayed.\n */\n getLegendTooltipContent?: CoreChartProps.GetLegendTooltipContent;\n /**\n * Called whenever chart point or group is highlighted.\n */\n onHighlight?: NonCancelableEventHandler<CoreChartProps.HighlightChangeDetail>;\n /**\n * Called whenever chart point or group loses highlight.\n */\n onClearHighlight?: NonCancelableEventHandler<CoreChartProps.HighlightClearDetail>;\n /**\n * Use Cloudscape keyboard navigation.\n */\n keyboardNavigation?: boolean;\n /**\n * An object that contains all of the localized strings required by the component.\n * @i18n\n */\n i18nStrings?: CoreChartProps.I18nStrings;\n /**\n * Specifies the options for each item in the chart.\n */\n getItemOptions?: CoreChartProps.GetItemOptions;\n}\n\nexport namespace CoreChartProps {\n // The API methods allow programmatic triggering of chart's behaviors, some of which are not accessible via React state.\n // This enables advanced integration scenarios, such as building a custom legend, or making multiple charts synchronized.\n export interface ChartAPI {\n chart: Highcharts.Chart;\n highcharts: typeof Highcharts;\n highlightItems(itemIds: readonly string[]): void;\n setItemsVisible(itemIds: readonly string[]): void;\n highlightChartPoint(point: Highcharts.Point): void;\n highlightChartGroup(group: readonly Highcharts.Point[]): void;\n clearChartHighlight(): void;\n }\n\n /**\n * The item id. Can be the id of a series or a point.\n */\n export type GetItemOptions = (itemId: string) => CoreChartProps.ChartItemOptions;\n\n // The extended version of Highcharts.Options. The axes types are extended with Cloudscape value formatter.\n // We use a custom formatter because we cannot use the built-in Highcharts formatter for our tooltip.\n export type ChartOptions = Omit<Highcharts.Options, \"xAxis\" | \"yAxis\"> & {\n xAxis?: XAxisOptions | XAxisOptions[];\n yAxis?: YAxisOptions | YAxisOptions[];\n };\n export type XAxisOptions = Highcharts.XAxisOptions & { valueFormatter?: (value: null | number) => string };\n export type YAxisOptions = Highcharts.YAxisOptions & { valueFormatter?: (value: null | number) => string };\n\n export interface ChartItemOptions {\n /**\n * If specified, specifies the status of an item.\n * An item can be a point or a series.\n */\n status?: ChartSeriesMarkerStatus;\n }\n\n export interface HeaderOptions {\n content: React.ReactNode;\n }\n export interface FooterOptions {\n content: React.ReactNode;\n }\n\n export interface LegendOptions extends BaseLegendOptions {\n bottomMaxHeight?: number;\n position?: \"bottom\" | \"side\";\n /**\n * This property only applies when there are secondary items.\n */\n secondaryLegendTitle?: string;\n /**\n * This property only applies when there are secondary items.\n */\n secondaryLegendActions?: React.ReactNode;\n /**\n * This property only applies when there are no secondary items and `position=\"bottom\"`.\n */\n horizontalAlignment?: LegendOptionsHorizontalAlignment;\n }\n\n export type LegendOptionsHorizontalAlignment = \"start\" | \"center\";\n\n export type LegendItem = InternalComponentTypes.LegendItem;\n export type LegendTooltipContent = InternalComponentTypes.LegendTooltipContent;\n export type GetLegendTooltipContent = InternalComponentTypes.GetLegendTooltipContent;\n export type GetLegendTooltipContentProps = InternalComponentTypes.GetLegendTooltipContentProps;\n\n export interface TooltipOptions {\n enabled?: boolean;\n placement?: \"middle\" | \"outside\" | \"target\";\n size?: \"small\" | \"medium\" | \"large\";\n debounce?: number | boolean;\n seriesSorting?: \"as-added\" | \"by-value-desc\";\n }\n\n export type GetTooltipContent = (props: GetTooltipContentProps) => TooltipContentRenderer;\n export interface GetTooltipContentProps {\n point: null | Highcharts.Point;\n group: readonly Highcharts.Point[];\n }\n export interface TooltipContentRenderer {\n point?: (props: TooltipPointProps) => TooltipPointFormatted;\n details?: (props: TooltipDetailsProps) => readonly TooltipDetail[];\n header?: (props: TooltipSlotProps) => React.ReactNode;\n body?: (props: TooltipSlotProps) => React.ReactNode;\n footer?: (props: TooltipSlotProps) => React.ReactNode;\n }\n export type TooltipPointFormatted = BaseTooltipPointFormatted;\n export interface TooltipContentItem {\n point: Highcharts.Point;\n errorRanges: Highcharts.Point[];\n }\n export interface TooltipPointProps {\n item: TooltipContentItem;\n hideTooltip: () => void;\n }\n export interface TooltipSlotProps {\n x: number;\n items: TooltipContentItem[];\n hideTooltip: () => void;\n }\n\n export interface TooltipDetailsProps {\n point: Highcharts.Point;\n hideTooltip: () => void;\n }\n\n export type TooltipDetail = BaseTooltipDetail;\n\n export interface LegendItemHighlightDetail {\n item: LegendItem;\n }\n export interface VisibleItemsChangeDetail {\n items: readonly LegendItem[];\n isApiCall: boolean;\n }\n export interface HighlightChangeDetail {\n point: null | Highcharts.Point;\n group: readonly Highcharts.Point[];\n isApiCall: boolean;\n }\n export interface HighlightClearDetail {\n isApiCall: boolean;\n }\n\n export type I18nStrings = CartesianI18nStrings & PieI18nStrings & CoreI18nStrings;\n}\n\nexport interface CoreLegendProps {\n items: readonly CoreLegendProps.Item[];\n title?: string;\n ariaLabel?: string;\n actions?: React.ReactNode;\n alignment?: \"horizontal\" | \"vertical\";\n horizontalAlignment?: CoreChartProps.LegendOptionsHorizontalAlignment;\n onClearHighlight?: NonCancelableEventHandler;\n onItemHighlight?: NonCancelableEventHandler<CoreLegendProps.ItemHighlightDetail>;\n onVisibleItemsChange?: NonCancelableEventHandler<CoreLegendProps.VisibleItemsChangeDetail>;\n getLegendTooltipContent?: CoreLegendProps.GetTooltipContent;\n}\n\nexport namespace CoreLegendProps {\n export type Item = InternalComponentTypes.LegendItem;\n export type GetTooltipContent = InternalComponentTypes.GetLegendTooltipContent;\n export interface ItemHighlightDetail {\n item: Item;\n }\n export interface VisibleItemsChangeDetail {\n items: readonly string[];\n }\n}\n\n// Utility types\n\nexport interface Rect {\n x: number;\n y: number;\n height: number;\n width: number;\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/core/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type Highcharts from \"highcharts\";\n\nimport type * as InternalComponentTypes from \"../internal/components/interfaces\";\nimport { ChartSeriesMarkerStatus } from \"../internal/components/series-marker/interfaces\";\nimport { type NonCancelableEventHandler } from \"../internal/events\";\n\n// All charts take `highcharts` instance, that can be served statically or dynamically.\n// Although it has to be of type Highcharts, the TS type we use is `null | object`, so\n// that it is ignored by the documenter.\n\n/**\n * This interface includes common public chart properties, applicable for all chart types.\n */\nexport interface BaseChartOptions {\n /**\n * The Highcharts instance, which can be obtained using `import Highcharts from \"highcharts\"`.\n * Supported Highcharts versions: 12.\n */\n highcharts: null | object;\n\n /**\n * Custom content that renders when `highcharts=null`. It renders a spinner if not defined.\n */\n fallback?: React.ReactNode;\n\n /**\n * The height of the chart plot in pixels. It does not include legend and filter.\n */\n chartHeight?: number;\n\n /**\n * The chart automatically adjusts its height to fill the parent container when this property is set.\n */\n fitHeight?: boolean;\n\n /**\n * Defines the minimum allowed height of the chart plot. Use this when `fitHeight=true` to\n * prevent the chart plot from becoming too small to display its content. When the parent\n * container is shorter than the minimum height, a vertical scrollbar appears automatically.\n */\n chartMinHeight?: number;\n\n /**\n * Defines the minimum allowed width of the chart plot. When the parent container is narrower than the\n * minimum width, the horizontal scrollbar is automatically added.\n */\n chartMinWidth?: number;\n\n /**\n * Defines the ARIA label for the chart container.\n * This property corresponds to [lang.chartContainerLabel](https://api.highcharts.com/highcharts/lang.accessibility.chartContainerLabel),\n * and requires the [accessibility module](https://www.highcharts.com/docs/accessibility/accessibility-module).\n */\n ariaLabel?: string;\n\n /**\n * Defines the ARIA description of the chart container.\n * This property corresponds to [accessibility.description](https://api.highcharts.com/highcharts/accessibility.description),\n * and requires the [accessibility module](https://www.highcharts.com/docs/accessibility/accessibility-module).\n */\n ariaDescription?: string;\n\n /**\n * Defines chart legend options, including:\n * * `enabled` (optional, boolean) - Hides legend when set to `false`.\n * * `title` (optional, string) - Visible label, shown above the legend.\n * * `actions` (optional, slot) - A slot before the legend that can be used to render custom actions.\n */\n legend?: BaseLegendOptions;\n\n /**\n * Defines options to represent empty, no-match, loading, and error state of the chart, including:\n * * `statusType` (optional, \"finished\" | \"loading\" | \"error\") - Specifies the current status of loading data.\n * * `empty` (optional, ReactNode) - Content displayed when the chart data is empty.\n * * `noMatch` (optional, ReactNode) - Content displayed when there is no data to display due to the built-in filtering.\n * * `loading` (optional, ReactNode) - Content displayed when `statusType=\"loading\"`. If omitted, the default loading state\n * is shown, using `i18n.loadingText` or built-in i18n.\n * * `error` (optional, ReactNode) - Content displayed when `statusType=\"error\"`. If omitted, the default error state\n * is shown, using `i18n.errorText` and `i18n.recoveryText` (when `onRecoveryClick` is provided), or built-in i18n.\n * * `onRecoveryClick` (optional, function) - Called when the user clicks the recovery button that appears when using default error\n * state, and only if `onRecoveryClick` is provided. Use this to enable the user to retry a failed request or provide another option\n * for the user to recover from the error.\n */\n noData?: BaseNoDataOptions;\n\n /**\n * Defines options for filtering in the chart, including:\n * * `seriesFilter` (optional, boolean) - Displays default series filter at the top of the chart.\n * * `additionalFilters` (optional, slot) - A slot for custom chart filters at the top of the chart.\n */\n filter?: BaseFilterOptions;\n}\n\nexport interface BaseLegendOptions {\n enabled?: boolean;\n title?: string;\n actions?: React.ReactNode;\n}\n\nexport interface BaseNoDataOptions {\n statusType?: \"finished\" | \"loading\" | \"error\";\n empty?: React.ReactNode;\n error?: React.ReactNode;\n loading?: React.ReactNode;\n noMatch?: React.ReactNode;\n onRecoveryClick?: NonCancelableEventHandler;\n}\n\nexport interface BaseTooltipDetail {\n key: React.ReactNode;\n value: React.ReactNode;\n}\n\nexport interface BaseI18nStrings {\n loadingText?: string;\n errorText?: string;\n recoveryText?: string;\n seriesFilterLabel?: string;\n seriesFilterPlaceholder?: string;\n seriesFilterSelectedAriaLabel?: string;\n legendAriaLabel?: string;\n detailPopoverDismissAriaLabel?: string;\n chartRoleDescription?: string;\n}\n\nexport interface CoreI18nStrings extends BaseI18nStrings {\n /**\n * ARIA label for the secondary legend when using dual axes charts.\n *\n * **Important**: When using dual axes, you should explicitly provide visible titles or ARIA labels\n * for both the primary and secondary legends to ensure proper accessibility. The primary legend\n * has built-in i18n support through `legendAriaLabel`, but the secondary legend currently requires\n * this property to be explicitly provided.\n */\n secondaryLegendAriaLabel?: string;\n\n /**\n * ARIA label for the marker of a series. Series with status \"default\" will not announce a label, thus excluded by this method.\n */\n itemMarkerStatusAriaLabel?: (status: Exclude<ChartSeriesMarkerStatus, \"default\">) => string;\n}\n\nexport interface WithCartesianI18nStrings {\n /**\n * An object that contains all of the localized strings required by the component.\n * @i18n\n *\n * Available properties:\n * * `loadingText` (optional, string) - Text, displayed when the chart is loading, i.e. when `noData.statusType` is set to \"loading\".\n * * `errorText` (optional, string) - Text, displayed when the chart is in error state, i.e. when `noData.statusType` is set to \"error\".\n * * `recoveryText` (optional, string) - Text for the recovery button, displayed next to the error text.\n * * `seriesFilterLabel` (optional, string) - Text for the visible label of the default series filter.\n * * `seriesFilterPlaceholder` (optional, string) - Text for the default series filter placeholder.\n * * `seriesFilterSelectedAriaLabel` (optional, string) - ARIA label of the default series filter which is appended to any option that is selected.\n * * `legendAriaLabel` (optional, string) - ARIA label that is associated with the legend in case there is no visible `legend.title` defined.\n * * `detailPopoverDismissAriaLabel` (optional, string) - ARIA label for the details popover dismiss button.\n * * `chartRoleDescription` (optional, string) - Accessible role description of the chart plot area, e.g. \"interactive chart\".\n * * `xAxisRoleDescription` (optional, string) - Accessible role description of the x axis, e.g. \"x axis\".\n * * `yAxisRoleDescription` (optional, string) - Accessible role description of the y axis, e.g. \"y axis\".\n */\n i18nStrings?: CartesianI18nStrings;\n}\n\nexport interface WithPieI18nStrings {\n /**\n * An object that contains all of the localized strings required by the component.\n * @i18n\n *\n * Available properties:\n * * `loadingText` (optional, string) - Text, displayed when the chart is loading, i.e. when `noData.statusType` is set to \"loading\".\n * * `errorText` (optional, string) - Text, displayed when the chart is in error state, i.e. when `noData.statusType` is set to \"error\".\n * * `recoveryText` (optional, string) - Text for the recovery button, displayed next to the error text.\n * * `seriesFilterLabel` (optional, string) - Text for the visible label of the default series filter.\n * * `seriesFilterPlaceholder` (optional, string) - Text for the default series filter placeholder.\n * * `seriesFilterSelectedAriaLabel` (optional, string) - ARIA label of the default series filter which is appended to any option that is selected.\n * * `legendAriaLabel` (optional, string) - ARIA label that is associated with the legend in case there is no visible `legend.title` defined.\n * * `detailPopoverDismissAriaLabel` (optional, string) - ARIA label for the details popover dismiss button.\n * * `chartRoleDescription` (optional, string) - Accessible role description of the chart plot area, e.g. \"interactive chart\".\n * * `segmentRoleDescription` (optional, string) - Accessible role description of the segment.\n */\n i18nStrings?: PieI18nStrings;\n}\n\nexport interface CartesianI18nStrings extends BaseI18nStrings {\n xAxisRoleDescription?: string;\n yAxisRoleDescription?: string;\n}\n\nexport interface PieI18nStrings extends BaseI18nStrings {\n segmentRoleDescription?: string;\n}\n\nexport interface BaseFilterOptions {\n seriesFilter?: boolean;\n additionalFilters?: React.ReactNode;\n}\n\nexport interface BaseTooltipPointFormatted {\n key?: React.ReactNode;\n value?: React.ReactNode;\n description?: React.ReactNode;\n expandable?: boolean;\n subItems?: ReadonlyArray<{ key: React.ReactNode; value: React.ReactNode }>;\n}\n\nexport interface AreaSeriesOptions extends BaseCartesianLineLikeOptions {\n type: \"area\";\n data: readonly PointDataItemType[];\n}\n\nexport interface AreaSplineSeriesOptions extends BaseCartesianLineLikeOptions {\n type: \"areaspline\";\n data: readonly PointDataItemType[];\n}\n\nexport interface ColumnSeriesOptions extends BaseCartesianSeriesOptions {\n type: \"column\";\n data: readonly PointDataItemType[];\n}\n\nexport interface LineSeriesOptions extends BaseCartesianLineLikeOptions {\n type: \"line\";\n data: readonly PointDataItemType[];\n}\n\nexport interface SplineSeriesOptions extends BaseCartesianLineLikeOptions {\n type: \"spline\";\n data: readonly PointDataItemType[];\n}\n\nexport interface ScatterSeriesOptions extends BaseCartesianSeriesOptions {\n type: \"scatter\";\n data: readonly PointDataItemType[];\n marker?: PointMarkerOptions;\n}\n\nexport interface ErrorBarSeriesOptions extends Omit<BaseCartesianSeriesOptions, \"name\"> {\n type: \"errorbar\";\n name?: string;\n data: readonly RangeDataItemOptions[];\n linkedTo: string;\n}\n\nexport interface XThresholdSeriesOptions extends BaseCartesianLineLikeOptions {\n type: \"x-threshold\";\n value: number;\n}\n\nexport interface YThresholdSeriesOptions extends BaseCartesianLineLikeOptions {\n type: \"y-threshold\";\n value: number;\n}\n\nexport interface PieSeriesOptions extends BaseSeriesOptions {\n type: \"pie\";\n data: readonly PieSegmentOptions[];\n}\n\nexport interface DonutSeriesOptions extends BaseSeriesOptions {\n type: \"donut\";\n data: readonly PieSegmentOptions[];\n}\n\nexport interface PieSegmentOptions {\n y: number | null;\n id?: string;\n name: string;\n color?: string;\n}\n\nexport type PointDataItemType = null | number | PointDataItemOptions;\n\nexport interface PointDataItemOptions {\n x?: number;\n y: number | null;\n}\n\nexport interface RangeDataItemOptions {\n x?: number;\n low: number;\n high: number;\n}\n\ninterface BaseSeriesOptions {\n id?: string;\n name: string;\n color?: string;\n}\n\ntype BaseCartesianSeriesOptions = BaseSeriesOptions;\n\ninterface BaseCartesianLineLikeOptions extends BaseCartesianSeriesOptions {\n dashStyle?: Highcharts.DashStyleValue;\n}\n\n// The symbols union matches that of Highcharts.PointMarkerOptionsObject\ninterface PointMarkerOptions {\n symbol?: \"circle\" | \"diamond\" | \"square\" | \"triangle\" | \"triangle-down\";\n}\n\nexport interface CoreCartesianOptions {\n /**\n * When set to `true`, adds a visual emphasis on the zero baseline axis.\n */\n emphasizeBaseline?: boolean;\n /**\n * Controls the placement of the vertical axis title.\n * When set to \"side\", displays the title along the axis line.\n */\n verticalAxisTitlePlacement?: \"top\" | \"side\";\n}\n\nexport interface CoreChartProps\n extends\n Pick<\n BaseChartOptions,\n | \"highcharts\"\n | \"fallback\"\n | \"fitHeight\"\n | \"chartHeight\"\n | \"chartMinHeight\"\n | \"chartMinWidth\"\n | \"ariaLabel\"\n | \"ariaDescription\"\n | \"filter\"\n | \"noData\"\n >,\n CoreCartesianOptions {\n /**\n * The Highcharts options. Cloudscape injects custom styles and settings, but all can be\n * overridden with explicitly provided options. An exception is event handlers - those are\n * not overridden, but merged with Cloudscape event handlers so that both are getting called.\n */\n options: CoreChartProps.ChartOptions;\n /**\n * The Cloudscape tooltip, that comes with a vertical cursor when used on cartesian series.\n * The tooltip content is only shown when `getContent` property is defined, which is called\n * for each visited { x, y } point.\n */\n tooltip?: CoreChartProps.TooltipOptions;\n /**\n * A custom slot above the chart plot, chart's axis title, and filter.\n */\n header?: CoreChartProps.HeaderOptions;\n /**\n * Prop for passing a custom navigation control component to be rendered with the chart.\n * Use this property to add timeline navigation, range selectors, or other custom navigation elements.\n */\n navigator?: React.ReactNode;\n /**\n * A custom slot below the chart plot and legend.\n */\n footer?: CoreChartProps.FooterOptions;\n /**\n * Chart legend options.\n */\n legend?: CoreChartProps.LegendOptions;\n /**\n * The callback to init the chart's API when it is ready. The API includes the Highcharts chart object, and\n * additional Cloudscape methods.\n */\n callback?: (chart: CoreChartProps.ChartAPI) => void;\n /**\n * This is used to provide a test-utils selector. Do not use this property to provide custom styles.\n */\n className?: string;\n /**\n * IDs of visible series or points.\n */\n visibleItems?: readonly string[];\n /**\n * Called when a legend item is highlighted.\n */\n onLegendItemHighlight?: NonCancelableEventHandler<CoreChartProps.LegendItemHighlightDetail>;\n /**\n * Called when series/points visibility changes due to user interaction with legend or filter.\n */\n onVisibleItemsChange?: NonCancelableEventHandler<CoreChartProps.VisibleItemsChangeDetail>;\n /**\n * Called whenever chart tooltip is rendered to provide content for tooltip's header, body, and (optional) footer.\n */\n getTooltipContent?: CoreChartProps.GetTooltipContent;\n /**\n * Called whenever a legend item is hovered to provide content for legend tooltip's header, body, and (optional) footer.\n * If not provided, no tooltip will be displayed.\n */\n getLegendTooltipContent?: CoreChartProps.GetLegendTooltipContent;\n /**\n * Called whenever chart point or group is highlighted.\n */\n onHighlight?: NonCancelableEventHandler<CoreChartProps.HighlightChangeDetail>;\n /**\n * Called whenever chart point or group loses highlight.\n */\n onClearHighlight?: NonCancelableEventHandler<CoreChartProps.HighlightClearDetail>;\n /**\n * Use Cloudscape keyboard navigation.\n */\n keyboardNavigation?: boolean;\n /**\n * An object that contains all of the localized strings required by the component.\n * @i18n\n */\n i18nStrings?: CoreChartProps.I18nStrings;\n /**\n * Specifies the options for each item in the chart.\n */\n getItemOptions?: CoreChartProps.GetItemOptions;\n}\n\nexport namespace CoreChartProps {\n // The API methods allow programmatic triggering of chart's behaviors, some of which are not accessible via React state.\n // This enables advanced integration scenarios, such as building a custom legend, or making multiple charts synchronized.\n export interface ChartAPI {\n chart: Highcharts.Chart;\n highcharts: typeof Highcharts;\n highlightItems(itemIds: readonly string[]): void;\n setItemsVisible(itemIds: readonly string[]): void;\n highlightChartPoint(point: Highcharts.Point): void;\n highlightChartGroup(group: readonly Highcharts.Point[]): void;\n clearChartHighlight(): void;\n }\n\n /**\n * The item id. Can be the id of a series or a point.\n */\n export type GetItemOptions = (itemId: string) => CoreChartProps.ChartItemOptions;\n\n // The extended version of Highcharts.Options. The axes types are extended with Cloudscape value formatter.\n // We use a custom formatter because we cannot use the built-in Highcharts formatter for our tooltip.\n export type ChartOptions = Omit<Highcharts.Options, \"xAxis\" | \"yAxis\"> & {\n xAxis?: XAxisOptions | XAxisOptions[];\n yAxis?: YAxisOptions | YAxisOptions[];\n };\n export type XAxisOptions = Highcharts.XAxisOptions & { valueFormatter?: (value: null | number) => string };\n export type YAxisOptions = Highcharts.YAxisOptions & { valueFormatter?: (value: null | number) => string };\n\n export interface ChartItemOptions {\n /**\n * If specified, specifies the status of an item.\n * An item can be a point or a series.\n */\n status?: ChartSeriesMarkerStatus;\n }\n\n export interface HeaderOptions {\n content: React.ReactNode;\n }\n export interface FooterOptions {\n content: React.ReactNode;\n }\n\n export interface LegendOptions extends BaseLegendOptions {\n bottomMaxHeight?: number;\n position?: \"bottom\" | \"side\";\n /**\n * This property only applies when there are secondary items.\n */\n secondaryLegendTitle?: string;\n /**\n * This property only applies when there are secondary items.\n */\n secondaryLegendActions?: React.ReactNode;\n /**\n * This property only applies when there are no secondary items and `position=\"bottom\"`.\n */\n horizontalAlignment?: LegendOptionsHorizontalAlignment;\n }\n\n export type LegendOptionsHorizontalAlignment = \"start\" | \"center\";\n\n export type LegendItem = InternalComponentTypes.LegendItem;\n export type LegendTooltipContent = InternalComponentTypes.LegendTooltipContent;\n export type GetLegendTooltipContent = InternalComponentTypes.GetLegendTooltipContent;\n export type GetLegendTooltipContentProps = InternalComponentTypes.GetLegendTooltipContentProps;\n\n export interface TooltipOptions {\n enabled?: boolean;\n placement?: \"middle\" | \"outside\" | \"target\";\n size?: \"small\" | \"medium\" | \"large\";\n debounce?: number | boolean;\n seriesSorting?: \"as-added\" | \"by-value-desc\";\n }\n\n export type GetTooltipContent = (props: GetTooltipContentProps) => TooltipContentRenderer;\n export interface GetTooltipContentProps {\n point: null | Highcharts.Point;\n group: readonly Highcharts.Point[];\n }\n export interface TooltipContentRenderer {\n point?: (props: TooltipPointProps) => TooltipPointFormatted;\n details?: (props: TooltipDetailsProps) => readonly TooltipDetail[];\n header?: (props: TooltipSlotProps) => React.ReactNode;\n body?: (props: TooltipSlotProps) => React.ReactNode;\n footer?: (props: TooltipSlotProps) => React.ReactNode;\n }\n export type TooltipPointFormatted = BaseTooltipPointFormatted;\n export interface TooltipContentItem {\n point: Highcharts.Point;\n errorRanges: Highcharts.Point[];\n }\n export interface TooltipPointProps {\n item: TooltipContentItem;\n hideTooltip: () => void;\n }\n export interface TooltipSlotProps {\n x: number;\n items: TooltipContentItem[];\n hideTooltip: () => void;\n }\n\n export interface TooltipDetailsProps {\n point: Highcharts.Point;\n hideTooltip: () => void;\n }\n\n export type TooltipDetail = BaseTooltipDetail;\n\n export interface LegendItemHighlightDetail {\n item: LegendItem;\n }\n\n export interface ApiInteraction {\n interactionType: \"api\";\n }\n export interface FilterInteraction {\n interactionType: \"filter\";\n }\n export interface ToggleInteraction {\n interactionType: \"toggle\";\n targetItemId: string;\n }\n export interface SelectInteraction {\n interactionType: \"select\";\n targetItemId: string;\n }\n\n export type VisibleItemsChangeDetail = { items: readonly LegendItem[] } & (\n | ApiInteraction\n | FilterInteraction\n | ToggleInteraction\n | SelectInteraction\n );\n\n export interface HighlightChangeDetail {\n point: null | Highcharts.Point;\n group: readonly Highcharts.Point[];\n isApiCall: boolean;\n }\n export interface HighlightClearDetail {\n isApiCall: boolean;\n }\n\n export type I18nStrings = CartesianI18nStrings & PieI18nStrings & CoreI18nStrings;\n}\n\nexport interface CoreLegendProps {\n items: readonly CoreLegendProps.Item[];\n title?: string;\n ariaLabel?: string;\n actions?: React.ReactNode;\n alignment?: \"horizontal\" | \"vertical\";\n horizontalAlignment?: CoreChartProps.LegendOptionsHorizontalAlignment;\n onClearHighlight?: NonCancelableEventHandler;\n onItemHighlight?: NonCancelableEventHandler<CoreLegendProps.ItemHighlightDetail>;\n onVisibleItemsChange?: NonCancelableEventHandler<CoreLegendProps.VisibleItemsChangeDetail>;\n getLegendTooltipContent?: CoreLegendProps.GetTooltipContent;\n}\n\nexport namespace CoreLegendProps {\n export type Item = InternalComponentTypes.LegendItem;\n export type GetTooltipContent = InternalComponentTypes.GetLegendTooltipContent;\n export interface ItemHighlightDetail {\n item: Item;\n }\n export type VisibleItemsChangeDetail = { items: readonly string[] } & (\n | CoreChartProps.ToggleInteraction\n | CoreChartProps.SelectInteraction\n );\n}\n\n// Utility types\n\nexport interface Rect {\n x: number;\n y: number;\n height: number;\n width: number;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  export var PACKAGE_SOURCE = "chart-components";
2
- export var PACKAGE_VERSION = "1.0.0 (668220c0)";
2
+ export var PACKAGE_VERSION = "1.0.0 (3a4021d6)";
3
3
  export var THEME = "open-source-visual-refresh";
4
4
  export var ALWAYS_VISUAL_REFRESH = true;
5
5
  export var SYSTEM = "core";
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "PACKAGE_SOURCE": "chart-components",
3
- "PACKAGE_VERSION": "1.0.0 (668220c0)",
3
+ "PACKAGE_VERSION": "1.0.0 (3a4021d6)",
4
4
  "THEME": "open-source-visual-refresh",
5
5
  "ALWAYS_VISUAL_REFRESH": true,
6
6
  "SYSTEM": "core"
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "668220c088c4e7f47c878de379595ddfec0a74ac"
2
+ "commit": "3a4021d62a265f9276cfffd7a30604247979f3c0"
3
3
  }
@@ -12,21 +12,33 @@ export const CoreLegend = ({ items, title, actions, ariaLabel: legendAriaLabel,
12
12
  if (visibleItems.includes(itemId)) {
13
13
  fireNonCancelableEvent(onVisibleItemsChange, {
14
14
  items: visibleItems.filter((visibleItemId) => visibleItemId !== itemId),
15
+ interactionType: "toggle",
16
+ targetItemId: itemId,
15
17
  });
16
18
  }
17
19
  else {
18
20
  fireNonCancelableEvent(onVisibleItemsChange, {
19
21
  items: [...visibleItems, itemId],
22
+ interactionType: "toggle",
23
+ targetItemId: itemId,
20
24
  });
21
25
  }
22
26
  };
23
27
  const onSelectItem = (itemId) => {
24
28
  const visibleItems = items.filter((i) => i.visible).map((i) => i.id);
25
29
  if (visibleItems.length === 1 && visibleItems[0] === itemId) {
26
- fireNonCancelableEvent(onVisibleItemsChange, { items: items.map((i) => i.id) });
30
+ fireNonCancelableEvent(onVisibleItemsChange, {
31
+ items: items.map((i) => i.id),
32
+ interactionType: "select",
33
+ targetItemId: itemId,
34
+ });
27
35
  }
28
36
  else {
29
- fireNonCancelableEvent(onVisibleItemsChange, { items: [itemId] });
37
+ fireNonCancelableEvent(onVisibleItemsChange, {
38
+ items: [itemId],
39
+ interactionType: "select",
40
+ targetItemId: itemId,
41
+ });
30
42
  }
31
43
  };
32
44
  if (items.length === 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/internal-do-not-use/core-legend/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,wDAAwD,CAAC;AAGzF,OAAO,EAAE,WAAW,IAAI,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC7F,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EACzB,KAAK,EACL,KAAK,EACL,OAAO,EACP,SAAS,EAAE,eAAe,EAC1B,SAAS,GAAG,YAAY,EACxB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,GAAG,OAAO,GACb,EAAE,EAAE;IACpB,MAAM,IAAI,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;IACzC,MAAM,SAAS,GAAG,IAAI,CAAC,6BAA6B,EAAE,eAAe,CAAC,CAAC;IAEvE,MAAM,YAAY,GAAG,CAAC,MAAc,EAAE,EAAE;QACtC,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,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AE,mBAAmB,EACxC,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,EACvD,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAC1B,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,WAAC,OAAA,MAAA,uBAAuB,aAAvB,uBAAuB,uBAAvB,uBAAuB,CAAG,KAAK,CAAC,mCAAI,IAAI,CAAA,EAAA,EACtE,mBAAmB,EAAE,GAAG,EAAE,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,EACnE,oBAAoB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,sBAAsB,CAAC,eAAe,EAAE,EAAE,IAAI,EAAE,CAAC,GACjF,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useInternalI18n } from \"@cloudscape-design/components/internal/do-not-use/i18n\";\n\nimport { CoreLegendProps } from \"../../core/interfaces\";\nimport { ChartLegend as ChartLegendComponent } from \"../../internal/components/chart-legend\";\nimport { fireNonCancelableEvent } from \"../../internal/events\";\n\nexport const CoreLegend = ({\n items,\n title,\n actions,\n ariaLabel: legendAriaLabel,\n alignment = \"horizontal\",\n onItemHighlight,\n onClearHighlight,\n onVisibleItemsChange,\n getLegendTooltipContent,\n horizontalAlignment = \"start\",\n}: CoreLegendProps) => {\n const i18n = useInternalI18n(\"[charts]\");\n const ariaLabel = i18n(\"i18nStrings.legendAriaLabel\", legendAriaLabel);\n\n const onToggleItem = (itemId: string) => {\n const visibleItems = items.filter((i) => i.visible).map((i) => i.id);\n if (visibleItems.includes(itemId)) {\n fireNonCancelableEvent(onVisibleItemsChange, {\n items: visibleItems.filter((visibleItemId) => visibleItemId !== itemId),\n });\n } else {\n fireNonCancelableEvent(onVisibleItemsChange, {\n items: [...visibleItems, itemId],\n });\n }\n };\n\n const onSelectItem = (itemId: string) => {\n const visibleItems = items.filter((i) => i.visible).map((i) => i.id);\n if (visibleItems.length === 1 && visibleItems[0] === itemId) {\n fireNonCancelableEvent(onVisibleItemsChange, { items: items.map((i) => i.id) });\n } else {\n fireNonCancelableEvent(onVisibleItemsChange, { items: [itemId] });\n }\n };\n\n if (items.length === 0) {\n return null;\n }\n\n return (\n <ChartLegendComponent\n items={items}\n actions={actions}\n legendTitle={title}\n alignment={alignment}\n horizontalAlignment={horizontalAlignment}\n ariaLabel={ariaLabel}\n someHighlighted={items.some((item) => item.highlighted)}\n onToggleItem={onToggleItem}\n onSelectItem={onSelectItem}\n getTooltipContent={(props) => getLegendTooltipContent?.(props) ?? null}\n onItemHighlightExit={() => fireNonCancelableEvent(onClearHighlight)}\n onItemHighlightEnter={(item) => fireNonCancelableEvent(onItemHighlight, { item })}\n />\n );\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/internal-do-not-use/core-legend/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,wDAAwD,CAAC;AAGzF,OAAO,EAAE,WAAW,IAAI,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC7F,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EACzB,KAAK,EACL,KAAK,EACL,OAAO,EACP,SAAS,EAAE,eAAe,EAC1B,SAAS,GAAG,YAAY,EACxB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,GAAG,OAAO,GACb,EAAE,EAAE;IACpB,MAAM,IAAI,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;IACzC,MAAM,SAAS,GAAG,IAAI,CAAC,6BAA6B,EAAE,eAAe,CAAC,CAAC;IAEvE,MAAM,YAAY,GAAG,CAAC,MAAc,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B,CAAC,oBAAoB,EAAE;gBAC3C,KAAK,EAAE,CAAC,MAAM,CAAC;gBACf,eAAe,EAAE,QAAQ;gBACzB,YAAY,EAAE,MAAM;aACrB,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;IAEF,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,KAAC,oBAAoB,IACnB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,KAAK,EAClB,SAAS,EAAE,SAAS,EACpB,mBAAmB,EAAE,mBAAmB,EACxC,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,EACvD,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAC1B,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,WAAC,OAAA,MAAA,uBAAuB,aAAvB,uBAAuB,uBAAvB,uBAAuB,CAAG,KAAK,CAAC,mCAAI,IAAI,CAAA,EAAA,EACtE,mBAAmB,EAAE,GAAG,EAAE,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,EACnE,oBAAoB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,sBAAsB,CAAC,eAAe,EAAE,EAAE,IAAI,EAAE,CAAC,GACjF,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useInternalI18n } from \"@cloudscape-design/components/internal/do-not-use/i18n\";\n\nimport { CoreLegendProps } from \"../../core/interfaces\";\nimport { ChartLegend as ChartLegendComponent } from \"../../internal/components/chart-legend\";\nimport { fireNonCancelableEvent } from \"../../internal/events\";\n\nexport const CoreLegend = ({\n items,\n title,\n actions,\n ariaLabel: legendAriaLabel,\n alignment = \"horizontal\",\n onItemHighlight,\n onClearHighlight,\n onVisibleItemsChange,\n getLegendTooltipContent,\n horizontalAlignment = \"start\",\n}: CoreLegendProps) => {\n const i18n = useInternalI18n(\"[charts]\");\n const ariaLabel = i18n(\"i18nStrings.legendAriaLabel\", legendAriaLabel);\n\n const onToggleItem = (itemId: string) => {\n const visibleItems = items.filter((i) => i.visible).map((i) => i.id);\n if (visibleItems.includes(itemId)) {\n fireNonCancelableEvent(onVisibleItemsChange, {\n items: visibleItems.filter((visibleItemId) => visibleItemId !== itemId),\n interactionType: \"toggle\",\n targetItemId: itemId,\n });\n } else {\n fireNonCancelableEvent(onVisibleItemsChange, {\n items: [...visibleItems, itemId],\n interactionType: \"toggle\",\n targetItemId: itemId,\n });\n }\n };\n\n const onSelectItem = (itemId: string) => {\n const visibleItems = items.filter((i) => i.visible).map((i) => i.id);\n if (visibleItems.length === 1 && visibleItems[0] === itemId) {\n fireNonCancelableEvent(onVisibleItemsChange, {\n items: items.map((i) => i.id),\n interactionType: \"select\",\n targetItemId: itemId,\n });\n } else {\n fireNonCancelableEvent(onVisibleItemsChange, {\n items: [itemId],\n interactionType: \"select\",\n targetItemId: itemId,\n });\n }\n };\n\n if (items.length === 0) {\n return null;\n }\n\n return (\n <ChartLegendComponent\n items={items}\n actions={actions}\n legendTitle={title}\n alignment={alignment}\n horizontalAlignment={horizontalAlignment}\n ariaLabel={ariaLabel}\n someHighlighted={items.some((item) => item.highlighted)}\n onToggleItem={onToggleItem}\n onSelectItem={onSelectItem}\n getTooltipContent={(props) => getLegendTooltipContent?.(props) ?? null}\n onItemHighlightExit={() => fireNonCancelableEvent(onClearHighlight)}\n onItemHighlightEnter={(item) => fireNonCancelableEvent(onItemHighlight, { item })}\n />\n );\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudscape-design/chart-components",
3
- "version": "1.0.46",
3
+ "version": "1.0.48",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cloudscape-design/chart-components.git"