@cloudscape-design/chart-components 1.0.33 → 1.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/chart-api/chart-extra-context.d.ts +1 -0
- package/core/chart-api/chart-extra-context.js.map +1 -1
- package/core/chart-api/chart-extra-legend.d.ts +8 -1
- package/core/chart-api/chart-extra-legend.js +10 -6
- package/core/chart-api/chart-extra-legend.js.map +1 -1
- package/core/chart-api/index.d.ts +7 -1
- package/core/chart-core.d.ts +1 -1
- package/core/chart-core.js +2 -1
- package/core/chart-core.js.map +1 -1
- package/core/components/core-tooltip.js +25 -7
- package/core/components/core-tooltip.js.map +1 -1
- package/core/i18n-utils.d.ts +3 -8
- package/core/i18n-utils.js +9 -0
- package/core/i18n-utils.js.map +1 -1
- package/core/interfaces.d.ts +22 -2
- package/core/interfaces.js.map +1 -1
- package/core/utils.d.ts +8 -1
- package/core/utils.js +10 -3
- package/core/utils.js.map +1 -1
- package/internal/components/chart-legend/index.js +2 -1
- package/internal/components/chart-legend/index.js.map +1 -1
- package/internal/components/chart-legend/styles.css.js +17 -17
- package/internal/components/chart-legend/styles.scoped.css +25 -25
- package/internal/components/chart-legend/styles.selectors.js +17 -17
- package/internal/components/series-details/styles.css.js +18 -17
- package/internal/components/series-details/styles.scoped.css +32 -27
- package/internal/components/series-details/styles.selectors.js +18 -17
- package/internal/components/series-marker/index.d.ts +4 -1
- package/internal/components/series-marker/index.js +34 -21
- package/internal/components/series-marker/index.js.map +1 -1
- package/internal/components/series-marker/interfaces.d.ts +1 -0
- package/internal/components/series-marker/interfaces.js.map +1 -1
- package/internal/components/series-marker/styles.css.js +3 -2
- package/internal/components/series-marker/styles.scoped.css +9 -4
- package/internal/components/series-marker/styles.selectors.js +3 -2
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/manifest.json +1 -1
- package/package.json +2 -2
package/core/i18n-utils.js
CHANGED
|
@@ -13,6 +13,15 @@ export function useChartI18n({ ariaLabel, ariaDescription, i18nStrings, }) {
|
|
|
13
13
|
chartXAxisLabel: i18n("i18nStrings.xAxisAriaRoleDescription", i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.xAxisRoleDescription),
|
|
14
14
|
chartYAxisLabel: i18n("i18nStrings.yAxisAriaRoleDescription", i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.yAxisRoleDescription),
|
|
15
15
|
chartSegmentLabel: i18nPie("i18nStrings.segmentAriaRoleDescription", i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.segmentRoleDescription),
|
|
16
|
+
itemMarkerLabel: (status = "default") => {
|
|
17
|
+
var _a;
|
|
18
|
+
switch (status) {
|
|
19
|
+
case "warning":
|
|
20
|
+
return (_a = i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.itemMarkerStatusAriaLabel) === null || _a === void 0 ? void 0 : _a.call(i18nStrings, status);
|
|
21
|
+
default:
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
},
|
|
16
25
|
};
|
|
17
26
|
}
|
|
18
27
|
//# sourceMappingURL=i18n-utils.js.map
|
package/core/i18n-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n-utils.js","sourceRoot":"","sources":["../../../src/core/i18n-utils.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,wDAAwD,CAAC;
|
|
1
|
+
{"version":3,"file":"i18n-utils.js","sourceRoot":"","sources":["../../../src/core/i18n-utils.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,wDAAwD,CAAC;AAezF,MAAM,UAAU,YAAY,CAAC,EAC3B,SAAS,EACT,eAAe,EACf,WAAW,GAKZ;IACC,MAAM,IAAI,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;IACzC,MAAM,OAAO,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;IAC7C,OAAO;QACL,UAAU,EAAE,SAAS;QACrB,gBAAgB,EAAE,eAAe;QACjC,2GAA2G;QAC3G,8CAA8C;QAC9C,mBAAmB,EAAE,IAAI,CAAC,sCAAsC,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,oBAAoB,CAAC;QACpG,eAAe,EAAE,IAAI,CAAC,sCAAsC,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,oBAAoB,CAAC;QAChG,eAAe,EAAE,IAAI,CAAC,sCAAsC,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,oBAAoB,CAAC;QAChG,iBAAiB,EAAE,OAAO,CAAC,wCAAwC,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,sBAAsB,CAAC;QACzG,eAAe,EAAE,CAAC,MAAM,GAAG,SAAS,EAAE,EAAE;;YACtC,QAAQ,MAAM,EAAE;gBACd,KAAK,SAAS;oBACZ,OAAO,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,yBAAyB,4DAAG,MAAM,CAAC,CAAC;gBAC1D;oBACE,OAAO,SAAS,CAAC;aACpB;QACH,CAAC;KACF,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 { ChartSeriesMarkerStatus } from \"../internal/components/series-marker/interfaces\";\nimport { CoreChartProps } from \"./interfaces\";\n\nexport interface ChartLabels {\n chartLabel?: string;\n chartDescription?: string;\n chartContainerLabel?: string;\n chartXAxisLabel?: string;\n chartYAxisLabel?: string;\n chartSegmentLabel?: string;\n itemMarkerLabel?: (status?: ChartSeriesMarkerStatus) => string | undefined;\n}\n\nexport function useChartI18n({\n ariaLabel,\n ariaDescription,\n i18nStrings,\n}: {\n ariaLabel?: string;\n ariaDescription?: string;\n i18nStrings?: CoreChartProps.I18nStrings;\n}): ChartLabels {\n const i18n = useInternalI18n(\"[charts]\");\n const i18nPie = useInternalI18n(\"pie-chart\");\n return {\n chartLabel: ariaLabel,\n chartDescription: ariaDescription,\n // We reuse existing translations as passing for now, but it is possible to introduce new i18n strings that\n // are parametrized with axes names, and more.\n chartContainerLabel: i18n(\"i18nStrings.chartAriaRoleDescription\", i18nStrings?.chartRoleDescription),\n chartXAxisLabel: i18n(\"i18nStrings.xAxisAriaRoleDescription\", i18nStrings?.xAxisRoleDescription),\n chartYAxisLabel: i18n(\"i18nStrings.yAxisAriaRoleDescription\", i18nStrings?.yAxisRoleDescription),\n chartSegmentLabel: i18nPie(\"i18nStrings.segmentAriaRoleDescription\", i18nStrings?.segmentRoleDescription),\n itemMarkerLabel: (status = \"default\") => {\n switch (status) {\n case \"warning\":\n return i18nStrings?.itemMarkerStatusAriaLabel?.(status);\n default:\n return undefined;\n }\n },\n };\n}\n"]}
|
package/core/interfaces.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type Highcharts from "highcharts";
|
|
2
2
|
import type * as InternalComponentTypes from "../internal/components/interfaces";
|
|
3
|
+
import { ChartSeriesMarkerStatus } from "../internal/components/series-marker/interfaces";
|
|
3
4
|
import { type NonCancelableEventHandler } from "../internal/events";
|
|
4
5
|
/**
|
|
5
6
|
* This interface includes common public chart properties, applicable for all chart types.
|
|
@@ -111,6 +112,10 @@ export interface CoreI18nStrings extends BaseI18nStrings {
|
|
|
111
112
|
* this property to be explicitly provided.
|
|
112
113
|
*/
|
|
113
114
|
secondaryLegendAriaLabel?: string;
|
|
115
|
+
/**
|
|
116
|
+
* ARIA label for the marker of a series. Series with status "default" will not announce a label, thus excluded by this method.
|
|
117
|
+
*/
|
|
118
|
+
itemMarkerStatusAriaLabel?: (status: Exclude<ChartSeriesMarkerStatus, "default">) => string;
|
|
114
119
|
}
|
|
115
120
|
export interface WithCartesianI18nStrings {
|
|
116
121
|
/**
|
|
@@ -334,7 +339,11 @@ export interface CoreChartProps extends Pick<BaseChartOptions, "highcharts" | "f
|
|
|
334
339
|
* An object that contains all of the localized strings required by the component.
|
|
335
340
|
* @i18n
|
|
336
341
|
*/
|
|
337
|
-
i18nStrings?:
|
|
342
|
+
i18nStrings?: CoreChartProps.I18nStrings;
|
|
343
|
+
/**
|
|
344
|
+
* Specifies the options for each item in the chart.
|
|
345
|
+
*/
|
|
346
|
+
getItemOptions?: CoreChartProps.GetItemOptions;
|
|
338
347
|
}
|
|
339
348
|
export declare namespace CoreChartProps {
|
|
340
349
|
interface ChartAPI {
|
|
@@ -346,6 +355,10 @@ export declare namespace CoreChartProps {
|
|
|
346
355
|
highlightChartGroup(group: readonly Highcharts.Point[]): void;
|
|
347
356
|
clearChartHighlight(): void;
|
|
348
357
|
}
|
|
358
|
+
/**
|
|
359
|
+
* The item id. Can be the id of a series or a point.
|
|
360
|
+
*/
|
|
361
|
+
type GetItemOptions = (itemId: string) => CoreChartProps.ChartItemOptions;
|
|
349
362
|
type ChartOptions = Omit<Highcharts.Options, "xAxis" | "yAxis"> & {
|
|
350
363
|
xAxis?: XAxisOptions | XAxisOptions[];
|
|
351
364
|
yAxis?: YAxisOptions | YAxisOptions[];
|
|
@@ -356,6 +369,13 @@ export declare namespace CoreChartProps {
|
|
|
356
369
|
type YAxisOptions = Highcharts.YAxisOptions & {
|
|
357
370
|
valueFormatter?: (value: null | number) => string;
|
|
358
371
|
};
|
|
372
|
+
interface ChartItemOptions {
|
|
373
|
+
/**
|
|
374
|
+
* If specified, specifies the status of an item.
|
|
375
|
+
* An item can be a point or a series.
|
|
376
|
+
*/
|
|
377
|
+
status?: ChartSeriesMarkerStatus;
|
|
378
|
+
}
|
|
359
379
|
interface HeaderOptions {
|
|
360
380
|
content: React.ReactNode;
|
|
361
381
|
}
|
|
@@ -436,7 +456,7 @@ export declare namespace CoreChartProps {
|
|
|
436
456
|
interface HighlightClearDetail {
|
|
437
457
|
isApiCall: boolean;
|
|
438
458
|
}
|
|
439
|
-
type I18nStrings = CartesianI18nStrings & PieI18nStrings;
|
|
459
|
+
type I18nStrings = CartesianI18nStrings & PieI18nStrings & CoreI18nStrings;
|
|
440
460
|
}
|
|
441
461
|
export interface CoreLegendProps {
|
|
442
462
|
items: readonly CoreLegendProps.Item[];
|
package/core/interfaces.js.map
CHANGED
|
@@ -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 { 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\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 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?: CartesianI18nStrings & PieI18nStrings & CoreI18nStrings;\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 // 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 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;\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 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"]}
|
package/core/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type Highcharts from "highcharts";
|
|
2
2
|
import { ChartSeriesMarkerType } from "../internal/components/series-marker";
|
|
3
|
+
import { ChartSeriesMarkerStatus } from "../internal/components/series-marker/interfaces";
|
|
3
4
|
import { ChartLabels } from "./i18n-utils";
|
|
4
5
|
import { CoreChartProps, Rect } from "./interfaces";
|
|
5
6
|
export interface LegendItemSpec {
|
|
@@ -9,6 +10,8 @@ export interface LegendItemSpec {
|
|
|
9
10
|
color: string;
|
|
10
11
|
visible: boolean;
|
|
11
12
|
isSecondary: boolean;
|
|
13
|
+
status?: ChartSeriesMarkerStatus;
|
|
14
|
+
markerAriaLabel?: string;
|
|
12
15
|
}
|
|
13
16
|
export declare function getSeriesId(series: Highcharts.Series): string;
|
|
14
17
|
export declare function getPointId(point: Highcharts.Point): string;
|
|
@@ -36,7 +39,11 @@ export declare function isPointVisible(point: Highcharts.Point): boolean;
|
|
|
36
39
|
export declare function getSeriesMarkerType(series?: Highcharts.Series): ChartSeriesMarkerType;
|
|
37
40
|
export declare function getSeriesColor(series?: Highcharts.Series): string;
|
|
38
41
|
export declare function getPointColor(point?: Highcharts.Point): string;
|
|
39
|
-
export declare function getChartLegendItems(chart
|
|
42
|
+
export declare function getChartLegendItems({ chart, getItemOptions, itemMarkerStatusAriaLabel, }: {
|
|
43
|
+
chart: Highcharts.Chart;
|
|
44
|
+
getItemOptions?: CoreChartProps.GetItemOptions;
|
|
45
|
+
itemMarkerStatusAriaLabel?: ChartLabels["itemMarkerLabel"];
|
|
46
|
+
}): readonly LegendItemSpec[];
|
|
40
47
|
export type LegendItemOptions = Highcharts.SeriesOptionsType | Highcharts.PointOptionsType;
|
|
41
48
|
export declare function getVisibleLegendItems(options: Highcharts.Options): {
|
|
42
49
|
primaryItems: LegendItemOptions[];
|
package/core/utils.js
CHANGED
|
@@ -93,7 +93,7 @@ export function getPointColor(point) {
|
|
|
93
93
|
// using this custom function, respecting Highcharts' showInLegend flag (defined for series only).
|
|
94
94
|
// There exists a Highcharts APIs to access legend items, but it is unfortunately not available, when
|
|
95
95
|
// Highcharts legend is disabled. Instead, we use this custom method to collect legend items from the chart.
|
|
96
|
-
export function getChartLegendItems(chart) {
|
|
96
|
+
export function getChartLegendItems({ chart, getItemOptions = () => ({}), itemMarkerStatusAriaLabel, }) {
|
|
97
97
|
var _a, _b, _c;
|
|
98
98
|
const legendItems = [];
|
|
99
99
|
const isInverted = (_a = chart.inverted) !== null && _a !== void 0 ? _a : false;
|
|
@@ -110,25 +110,32 @@ export function getChartLegendItems(chart) {
|
|
|
110
110
|
// We respect Highcharts showInLegend option to allow hiding certain series from the legend.
|
|
111
111
|
// The same is not supported for pie chart segments.
|
|
112
112
|
if (series.options.showInLegend !== false) {
|
|
113
|
+
const seriesId = getSeriesId(series);
|
|
114
|
+
const itemProps = getItemOptions(seriesId);
|
|
115
|
+
const status = itemProps.status;
|
|
113
116
|
legendItems.push({
|
|
114
|
-
id:
|
|
117
|
+
id: seriesId,
|
|
115
118
|
name: series.name,
|
|
116
119
|
markerType: getSeriesMarkerType(series),
|
|
117
120
|
color: getSeriesColor(series),
|
|
118
121
|
visible: series.visible,
|
|
119
122
|
isSecondary,
|
|
123
|
+
status: status,
|
|
124
|
+
markerAriaLabel: itemMarkerStatusAriaLabel === null || itemMarkerStatusAriaLabel === void 0 ? void 0 : itemMarkerStatusAriaLabel(status),
|
|
120
125
|
});
|
|
121
126
|
}
|
|
122
127
|
};
|
|
123
128
|
const addPointItem = (point, isSecondary) => {
|
|
124
129
|
var _a;
|
|
125
130
|
if (((_a = point === null || point === void 0 ? void 0 : point.series) === null || _a === void 0 ? void 0 : _a.type) === "pie") {
|
|
131
|
+
const pointId = getPointId(point);
|
|
126
132
|
legendItems.push({
|
|
127
|
-
id:
|
|
133
|
+
id: pointId,
|
|
128
134
|
name: point.name,
|
|
129
135
|
markerType: getSeriesMarkerType(point.series),
|
|
130
136
|
color: getPointColor(point),
|
|
131
137
|
visible: point.visible,
|
|
138
|
+
status: getItemOptions(pointId).status,
|
|
132
139
|
isSecondary,
|
|
133
140
|
});
|
|
134
141
|
}
|
package/core/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/core/utils.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAKtC,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAa5C,yHAAyH;AACzH,6HAA6H;AAC7H,gFAAgF;AAChF,MAAM,UAAU,WAAW,CAAC,MAAyB;IACnD,OAAO,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC;AACD,MAAM,UAAU,UAAU,CAAC,KAAuB;IAChD,OAAO,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AACD,MAAM,UAAU,YAAY,CAAC,OAAuC;;IAClE,OAAO,MAAA,MAAA,OAAO,CAAC,EAAE,mCAAI,OAAO,CAAC,IAAI,mCAAI,eAAe,EAAE,CAAC;AACzD,CAAC;AACD,SAAS,eAAe;IACtB,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG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,mCAAI,CAAC,CAAC;IAC/B,OAAO,YAAY,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,YAAY,CAAC,IAAU,EAAE,KAAuB,EAAE,aAAsB;IAC/E,OAAO,aAAa,IAAI,KAAK,CAAC,QAAQ;QACpC,CAAC,CAAC;YACE,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;YAC5D,CAAC,EAAE,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;YAC3D,KAAK,EAAE,IAAI,CAAC,MAAM;YAClB,MAAM,EAAE,IAAI,CAAC,KAAK;SACnB;QACH,CAAC,CAAC;YACE,CAAC,EAAE,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;YAC1B,CAAC,EAAE,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;YACzB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;AACR,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 { ChartSeriesMarkerType } from \"../internal/components/series-marker\";\nimport { getChartSeries } from \"../internal/utils/chart-series\";\nimport { castArray } from \"../internal/utils/utils\";\nimport { getFormatter } from \"./formatters\";\nimport { ChartLabels } from \"./i18n-utils\";\nimport { CoreChartProps, Rect } from \"./interfaces\";\n\nexport interface LegendItemSpec {\n id: string;\n name: string;\n markerType: ChartSeriesMarkerType;\n color: string;\n visible: boolean;\n isSecondary: boolean;\n}\n\n// The below functions extract unique identifier from series, point, or options. The identifier can be item's ID or name.\n// We expect that items requiring referencing (e.g. in order to control their visibility) have the unique identifier defined.\n// Otherwise, we return a randomized id that is to ensure no accidental matches.\nexport function getSeriesId(series: Highcharts.Series): string {\n return getOptionsId(series.options);\n}\nexport function getPointId(point: Highcharts.Point): string {\n return getOptionsId(point.options);\n}\nexport function getOptionsId(options: { id?: string; name?: string }): string {\n return options.id ?? options.name ?? noIdPlaceholder();\n}\nfunction noIdPlaceholder(): string {\n const rand = (Math.random() * 1_000_000).toFixed(0).padStart(6, \"0\");\n return \"awsui-no-id-placeholder-\" + rand;\n}\n\n// There are more possible values that series.stacking can take, but we only explicitly support \"normal\".\nexport function isSeriesStacked(series: Highcharts.Series) {\n return (series.options as any).stacking === \"normal\";\n}\n\n// The threshold series are custom series, implemented as a combination of line series, and plot lines.\n// As Highcharts does not support custom series declaration, we annotate threshold series by using the\n// series.custom property. This is then used in our utilities to recognize threshold series, and retrieve\n// the associated threshold value.\ninterface ThresholdOptions<T extends \"x-threshold\" | \"y-threshold\"> {\n custom: {\n awsui: {\n type: T;\n threshold: number;\n };\n };\n}\nexport function createThresholdMetadata<T extends \"x-threshold\" | \"y-threshold\">(\n type: T,\n value: number,\n): ThresholdOptions<T> {\n return { custom: { awsui: { type, threshold: value } } };\n}\nexport function isXThreshold(\n s: Highcharts.Series,\n): s is Highcharts.Series & { options: ThresholdOptions<\"x-threshold\"> } {\n return typeof s.options.custom === \"object\" && s.options.custom.awsui?.type === \"x-threshold\";\n}\nexport function isYThreshold(\n s: Highcharts.Series,\n): s is Highcharts.Series & { options: ThresholdOptions<\"y-threshold\"> } {\n return typeof s.options.custom === \"object\" && s.options.custom.awsui?.type === \"y-threshold\";\n}\n\n// We check point.series explicitly because Highcharts can destroy point objects, replacing the\n// contents with { destroyed: true }, violating the point's TS contract.\n// See: https://github.com/highcharts/highcharts/issues/23175.\nexport function isPointVisible(point: Highcharts.Point) {\n return point.visible && point.series && point.series.visible;\n}\n\nexport function getSeriesMarkerType(series?: Highcharts.Series): ChartSeriesMarkerType {\n if (!series) {\n return \"large-square\";\n }\n const seriesSymbol = \"symbol\" in series && typeof series.symbol === \"string\" ? series.symbol : \"circle\";\n // In Highcharts, dashStyle supports different types of dashes: https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/\n // Return a dashed legend symbol for all of these dashes, excluding the default \"Solid\" option\n if (\"dashStyle\" in series.options && series.options.dashStyle && series.options.dashStyle !== \"Solid\") {\n return \"dashed\";\n }\n switch (series.type) {\n case \"area\":\n case \"areaspline\":\n return \"hollow-square\";\n case \"line\":\n case \"spline\":\n return \"line\";\n case \"scatter\":\n switch (seriesSymbol) {\n case \"square\":\n return \"square\";\n case \"diamond\":\n return \"diamond\";\n case \"triangle\":\n return \"triangle\";\n case \"triangle-down\":\n return \"triangle-down\";\n case \"circle\":\n default:\n return \"circle\";\n }\n case \"column\":\n case \"pie\":\n return \"large-square\";\n case \"errorbar\":\n default:\n return \"large-square\";\n }\n}\n\n// Highcharts supports color objects to represent gradients and more, but we only support string\n// colors in our markers. In case a non-string color is defined, we use black color as as fallback.\nexport function getSeriesColor(series?: Highcharts.Series): string {\n return typeof series?.color === \"string\" ? series.color : \"black\";\n}\nexport function getPointColor(point?: Highcharts.Point): string {\n return typeof point?.color === \"string\" ? point.color : \"black\";\n}\n\n// The custom legend implementation does not rely on the Highcharts legend. When Highcharts legend is disabled,\n// the chart object does not include information on legend items. Instead, we collect series and pie segments\n// using this custom function, respecting Highcharts' showInLegend flag (defined for series only).\n\n// There exists a Highcharts APIs to access legend items, but it is unfortunately not available, when\n// Highcharts legend is disabled. Instead, we use this custom method to collect legend items from the chart.\nexport function getChartLegendItems(chart: Highcharts.Chart): readonly LegendItemSpec[] {\n const legendItems: LegendItemSpec[] = [];\n const isInverted = chart.inverted ?? false;\n const addSeriesItem = (series: Highcharts.Series, isSecondary: boolean) => {\n // The pie series is not shown in the legend. Instead, we show pie segments.\n if (series.type === \"pie\") {\n return;\n }\n // We only support errorbar series that are linked to other series. Those are not represented separately\n // in the legend, but can be controlled from the outside, using controllable items visibility API.\n if (series.type === \"errorbar\") {\n return;\n }\n // We respect Highcharts showInLegend option to allow hiding certain series from the legend.\n // The same is not supported for pie chart segments.\n if (series.options.showInLegend !== false) {\n legendItems.push({\n id: getSeriesId(series),\n name: series.name,\n markerType: getSeriesMarkerType(series),\n color: getSeriesColor(series),\n visible: series.visible,\n isSecondary,\n });\n }\n };\n const addPointItem = (point: Highcharts.Point, isSecondary: boolean) => {\n if (point?.series?.type === \"pie\") {\n legendItems.push({\n id: getPointId(point),\n name: point.name,\n markerType: getSeriesMarkerType(point.series),\n color: getPointColor(point),\n visible: point.visible,\n isSecondary,\n });\n }\n };\n for (const s of getChartSeries(chart.series)) {\n const valueAxis = isInverted ? s.xAxis : s.yAxis;\n const isSecondary = valueAxis?.options?.opposite ?? false;\n addSeriesItem(s, isSecondary);\n s.data.forEach((p) => addPointItem(p, isSecondary));\n }\n return legendItems;\n}\n\nexport type LegendItemOptions = Highcharts.SeriesOptionsType | Highcharts.PointOptionsType;\n\nexport function getVisibleLegendItems(options: Highcharts.Options) {\n const isInverted = options.chart?.inverted ?? false;\n const valueAxes = (isInverted ? castArray(options.xAxis) : castArray(options.yAxis)) ?? [];\n const defaultOpposite = valueAxes.length > 0 ? (valueAxes[0].opposite ?? false) : false;\n\n const primaryItems: LegendItemOptions[] = [];\n const secondaryItems: LegendItemOptions[] = [];\n const addLegendItem = (item: LegendItemOptions) => {\n if (isSecondaryLegendItem(item, isInverted, defaultOpposite, valueAxes)) {\n secondaryItems.push(item);\n } else {\n primaryItems.push(item);\n }\n };\n\n options.series?.forEach((series) => {\n // The pie series is not shown in the legend. Instead, we show pie segments (points).\n if (series.type === \"pie\") {\n if (Array.isArray(series.data)) {\n series.data.forEach((point) => addLegendItem(point));\n }\n return;\n }\n // We only support errorbar series that are linked to other series. Those are not represented separately\n // in the legend, but can be controlled from the outside, using controllable items visibility API.\n if (series.type === \"errorbar\") {\n return;\n }\n if (series.showInLegend !== false) {\n addLegendItem(series);\n }\n });\n\n return { primaryItems, secondaryItems };\n}\n\nfunction isSecondaryLegendItem(\n item: LegendItemOptions,\n isInverted: boolean,\n defaultOpposite: boolean,\n valueAxes: Array<{ id?: string; opposite?: boolean }>,\n): boolean {\n // Only items that have an associated axis can be considered secondary\n if (item && typeof item === \"object\" && (\"xAxis\" in item || \"yAxis\" in item)) {\n const axisRef = isInverted ? (item.xAxis ?? 0) : (item.yAxis ?? 0);\n // An axis reference can be an index into the axes array or an explicitly passed id\n const valueAxis = typeof axisRef === \"number\" ? valueAxes[axisRef] : valueAxes.find((a) => a.id === axisRef);\n return valueAxis?.opposite ?? false;\n }\n return defaultOpposite;\n}\n\nexport function getLegendsProps(\n options: CoreChartProps.ChartOptions,\n legendOptions: CoreChartProps.LegendOptions | undefined,\n) {\n // While Highcharts supports more than two axes, this\n // implementation supports at most two, in which case one\n // of them must be set as opposite (secondary).\n const { primaryItems, secondaryItems } = getVisibleLegendItems(options);\n return {\n primary:\n primaryItems.length === 0\n ? undefined\n : ({\n isSecondary: false,\n title: legendOptions?.title,\n actions: legendOptions?.actions,\n alignment: legendOptions?.position === \"side\" ? \"vertical\" : \"horizontal\",\n horizontalAlignment: secondaryItems.length === 0 ? legendOptions?.horizontalAlignment : \"start\",\n } as const),\n secondary:\n secondaryItems.length === 0\n ? undefined\n : ({\n isSecondary: true,\n title: legendOptions?.secondaryLegendTitle,\n actions: legendOptions?.secondaryLegendActions,\n alignment: legendOptions?.position === \"side\" ? \"vertical\" : \"horizontal\",\n horizontalAlignment: \"end\",\n } as const),\n };\n}\n\n// This function returns coordinates of a rectangle, including the target point.\n// There are differences in how the rectangle is computed, but in all cases it is supposed to\n// enclose the point's visual representation in the chart, with no extra offsets.\nexport function getPointRect(point: Highcharts.Point): Rect {\n if (!point.series) {\n return { x: 0, y: 0, width: 0, height: 0 };\n }\n\n switch (point.series.type) {\n case \"column\":\n return getColumnPointRect(point);\n case \"errorbar\":\n return getErrorBarPointRect(point);\n default:\n return getDefaultPointRect(point);\n }\n}\n\n// The group rect is only used for cartesian charts. It returns coordinates of a rectangle,\n// which includes all given points, but also stretched vertically or horizontally (in inverted charts)\n// to the entire chart's height or width.\nexport function getGroupRect(points: readonly Highcharts.Point[]): Rect {\n if (points.length === 0 || !points[0].series) {\n return { x: 0, y: 0, width: 0, height: 0 };\n }\n const chart = points[0].series.chart;\n const rects = points.map(getPointRect);\n const [first, ...rest] = rects;\n let minX = first.x,\n minY = first.y,\n maxX = first.x + first.width,\n maxY = first.y + first.height;\n for (const r of rest) {\n minX = Math.min(minX, r.x);\n minY = Math.min(minY, r.y);\n maxX = Math.max(maxX, r.x + r.width);\n maxY = Math.max(maxY, r.y + r.height);\n }\n return safeRect(\n chart.inverted\n ? { x: chart.plotLeft, y: minY, width: chart.plotWidth, height: maxY - minY }\n : { x: minX, y: chart.plotTop, width: maxX - minX, height: chart.plotHeight },\n );\n}\n\n// We ensure rect width and height are non-zero to ensure its position is calculated correctly in Firefox.\nexport function safeRect(rect: Rect): Rect {\n return { ...rect, width: Math.max(0.1, rect.width), height: Math.max(0.1, rect.height) };\n}\n\nexport function getChartAccessibleDescription(chart: Highcharts.Chart) {\n return chart.options.lang?.accessibility?.chartContainerLabel ?? \"\";\n}\n\nexport function getPointAccessibleDescription(point: Highcharts.Point, labels: ChartLabels) {\n if (point.series.xAxis && point.series.yAxis) {\n const formattedX = getFormatter(point.series.xAxis)(point.x);\n const formattedY = getFormatter(point.series.yAxis)(point.y);\n return `${formattedX} ${formattedY}, ${point.series.name}`;\n } else if (point.series.type === \"pie\") {\n const segmentLabel = labels.chartSegmentLabel ? `${labels.chartSegmentLabel} ` : \"\";\n return `${segmentLabel}${point.name}, ${point.y}. ${point.series.name}`;\n } else {\n return \"\";\n }\n}\n\nexport function getGroupAccessibleDescription(group: readonly Highcharts.Point[]) {\n const firstPoint = group[0];\n return getFormatter(firstPoint.series.xAxis)(firstPoint.x);\n}\n\n// The area-, line-, or scatter series markers are rendered as single graphic elements,\n// and we can use their respective b-boxes to compute rects.\nfunction getDefaultPointRect(point: Highcharts.Point): Rect {\n const chart = point.series.chart;\n if (point.graphic) {\n const box = point.graphic.getBBox();\n return getChartRect(box, chart, false);\n }\n return getPointRectFromCoordinates(point);\n}\n\n// The column series graphic elements are rectangles, and they are inverted if the chart is inverted,\n// so that rect's width becomes height and vice-versa.\nfunction getColumnPointRect(point: Highcharts.Point): Rect {\n const chart = point.series.chart;\n if (point.graphic) {\n return getChartRect(point.graphic.getBBox(), chart, true);\n }\n return getPointRectFromCoordinates(point);\n}\n\n// The errorbar series point rect cannot be computed from the respective graphic element (it gives wrong position).\n// Instead, we have to rely on the internal \"whiskers\" element b-box, which can be inverted, too.\nfunction getErrorBarPointRect(point: Highcharts.Point): Rect {\n const chart = point.series.chart;\n if (\"whiskers\" in point) {\n return getChartRect((point.whiskers as Highcharts.SVGElement).getBBox(), chart, true);\n }\n return getPointRectFromCoordinates(point);\n}\n\n// The point graphic is not present in large charts to optimize performance.\n// In that case we compute point rects from their coordinates. We also assume the point\n// size is small, and thereby give it 0 width and height, which is alright as there is a\n// small offset that we use for focus outline anyways.\n// See: https://www.highcharts.com/blog/news/175-highcharts-performance-boost/\nfunction getPointRectFromCoordinates(point: Highcharts.Point) {\n const chart = point.series.chart;\n const plotX = point.plotX ?? 0;\n const plotY = point.plotY ?? 0;\n return getChartRect({ x: plotX, y: plotY, width: 0, height: 0 }, chart, true);\n}\n\nfunction getChartRect(rect: Rect, chart: Highcharts.Chart, canBeInverted: boolean): Rect {\n return canBeInverted && chart.inverted\n ? {\n x: chart.plotWidth + chart.plotLeft - (rect.y + rect.height),\n y: chart.plotHeight + chart.plotTop - (rect.x + rect.width),\n width: rect.height,\n height: rect.width,\n }\n : {\n x: chart.plotLeft + rect.x,\n y: chart.plotTop + rect.y,\n width: rect.width,\n height: rect.height,\n };\n}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,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,YAAY,CAAC,IAAU,EAAE,KAAuB,EAAE,aAAsB;IAC/E,OAAO,aAAa,IAAI,KAAK,CAAC,QAAQ;QACpC,CAAC,CAAC;YACE,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;YAC5D,CAAC,EAAE,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;YAC3D,KAAK,EAAE,IAAI,CAAC,MAAM;YAClB,MAAM,EAAE,IAAI,CAAC,KAAK;SACnB;QACH,CAAC,CAAC;YACE,CAAC,EAAE,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;YAC1B,CAAC,EAAE,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;YACzB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;AACR,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 { ChartSeriesMarkerType } from \"../internal/components/series-marker\";\nimport { ChartSeriesMarkerStatus } from \"../internal/components/series-marker/interfaces\";\nimport { getChartSeries } from \"../internal/utils/chart-series\";\nimport { castArray } from \"../internal/utils/utils\";\nimport { getFormatter } from \"./formatters\";\nimport { ChartLabels } from \"./i18n-utils\";\nimport { CoreChartProps, Rect } from \"./interfaces\";\n\nexport interface LegendItemSpec {\n id: string;\n name: string;\n markerType: ChartSeriesMarkerType;\n color: string;\n visible: boolean;\n isSecondary: boolean;\n status?: ChartSeriesMarkerStatus;\n markerAriaLabel?: string;\n}\n\n// The below functions extract unique identifier from series, point, or options. The identifier can be item's ID or name.\n// We expect that items requiring referencing (e.g. in order to control their visibility) have the unique identifier defined.\n// Otherwise, we return a randomized id that is to ensure no accidental matches.\nexport function getSeriesId(series: Highcharts.Series): string {\n return getOptionsId(series.options);\n}\nexport function getPointId(point: Highcharts.Point): string {\n return getOptionsId(point.options);\n}\nexport function getOptionsId(options: { id?: string; name?: string }): string {\n return options.id ?? options.name ?? noIdPlaceholder();\n}\nfunction noIdPlaceholder(): string {\n const rand = (Math.random() * 1_000_000).toFixed(0).padStart(6, \"0\");\n return \"awsui-no-id-placeholder-\" + rand;\n}\n\n// There are more possible values that series.stacking can take, but we only explicitly support \"normal\".\nexport function isSeriesStacked(series: Highcharts.Series) {\n return (series.options as any).stacking === \"normal\";\n}\n\n// The threshold series are custom series, implemented as a combination of line series, and plot lines.\n// As Highcharts does not support custom series declaration, we annotate threshold series by using the\n// series.custom property. This is then used in our utilities to recognize threshold series, and retrieve\n// the associated threshold value.\ninterface ThresholdOptions<T extends \"x-threshold\" | \"y-threshold\"> {\n custom: {\n awsui: {\n type: T;\n threshold: number;\n };\n };\n}\nexport function createThresholdMetadata<T extends \"x-threshold\" | \"y-threshold\">(\n type: T,\n value: number,\n): ThresholdOptions<T> {\n return { custom: { awsui: { type, threshold: value } } };\n}\nexport function isXThreshold(\n s: Highcharts.Series,\n): s is Highcharts.Series & { options: ThresholdOptions<\"x-threshold\"> } {\n return typeof s.options.custom === \"object\" && s.options.custom.awsui?.type === \"x-threshold\";\n}\nexport function isYThreshold(\n s: Highcharts.Series,\n): s is Highcharts.Series & { options: ThresholdOptions<\"y-threshold\"> } {\n return typeof s.options.custom === \"object\" && s.options.custom.awsui?.type === \"y-threshold\";\n}\n\n// We check point.series explicitly because Highcharts can destroy point objects, replacing the\n// contents with { destroyed: true }, violating the point's TS contract.\n// See: https://github.com/highcharts/highcharts/issues/23175.\nexport function isPointVisible(point: Highcharts.Point) {\n return point.visible && point.series && point.series.visible;\n}\n\nexport function getSeriesMarkerType(series?: Highcharts.Series): ChartSeriesMarkerType {\n if (!series) {\n return \"large-square\";\n }\n const seriesSymbol = \"symbol\" in series && typeof series.symbol === \"string\" ? series.symbol : \"circle\";\n // In Highcharts, dashStyle supports different types of dashes: https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/\n // Return a dashed legend symbol for all of these dashes, excluding the default \"Solid\" option\n if (\"dashStyle\" in series.options && series.options.dashStyle && series.options.dashStyle !== \"Solid\") {\n return \"dashed\";\n }\n switch (series.type) {\n case \"area\":\n case \"areaspline\":\n return \"hollow-square\";\n case \"line\":\n case \"spline\":\n return \"line\";\n case \"scatter\":\n switch (seriesSymbol) {\n case \"square\":\n return \"square\";\n case \"diamond\":\n return \"diamond\";\n case \"triangle\":\n return \"triangle\";\n case \"triangle-down\":\n return \"triangle-down\";\n case \"circle\":\n default:\n return \"circle\";\n }\n case \"column\":\n case \"pie\":\n return \"large-square\";\n case \"errorbar\":\n default:\n return \"large-square\";\n }\n}\n\n// Highcharts supports color objects to represent gradients and more, but we only support string\n// colors in our markers. In case a non-string color is defined, we use black color as as fallback.\nexport function getSeriesColor(series?: Highcharts.Series): string {\n return typeof series?.color === \"string\" ? series.color : \"black\";\n}\nexport function getPointColor(point?: Highcharts.Point): string {\n return typeof point?.color === \"string\" ? point.color : \"black\";\n}\n\n// The custom legend implementation does not rely on the Highcharts legend. When Highcharts legend is disabled,\n// the chart object does not include information on legend items. Instead, we collect series and pie segments\n// using this custom function, respecting Highcharts' showInLegend flag (defined for series only).\n\n// There exists a Highcharts APIs to access legend items, but it is unfortunately not available, when\n// Highcharts legend is disabled. Instead, we use this custom method to collect legend items from the chart.\nexport function getChartLegendItems({\n chart,\n getItemOptions = () => ({}),\n itemMarkerStatusAriaLabel,\n}: {\n chart: Highcharts.Chart;\n getItemOptions?: CoreChartProps.GetItemOptions;\n itemMarkerStatusAriaLabel?: ChartLabels[\"itemMarkerLabel\"];\n}): readonly LegendItemSpec[] {\n const legendItems: LegendItemSpec[] = [];\n const isInverted = chart.inverted ?? false;\n const addSeriesItem = (series: Highcharts.Series, isSecondary: boolean) => {\n // The pie series is not shown in the legend. Instead, we show pie segments.\n if (series.type === \"pie\") {\n return;\n }\n // We only support errorbar series that are linked to other series. Those are not represented separately\n // in the legend, but can be controlled from the outside, using controllable items visibility API.\n if (series.type === \"errorbar\") {\n return;\n }\n // We respect Highcharts showInLegend option to allow hiding certain series from the legend.\n // The same is not supported for pie chart segments.\n if (series.options.showInLegend !== false) {\n const seriesId = getSeriesId(series);\n const itemProps = getItemOptions(seriesId);\n const status = itemProps.status;\n legendItems.push({\n id: seriesId,\n name: series.name,\n markerType: getSeriesMarkerType(series),\n color: getSeriesColor(series),\n visible: series.visible,\n isSecondary,\n status: status,\n markerAriaLabel: itemMarkerStatusAriaLabel?.(status),\n });\n }\n };\n const addPointItem = (point: Highcharts.Point, isSecondary: boolean) => {\n if (point?.series?.type === \"pie\") {\n const pointId = getPointId(point);\n legendItems.push({\n id: pointId,\n name: point.name,\n markerType: getSeriesMarkerType(point.series),\n color: getPointColor(point),\n visible: point.visible,\n status: getItemOptions(pointId).status,\n isSecondary,\n });\n }\n };\n for (const s of getChartSeries(chart.series)) {\n const valueAxis = isInverted ? s.xAxis : s.yAxis;\n const isSecondary = valueAxis?.options?.opposite ?? false;\n addSeriesItem(s, isSecondary);\n s.data.forEach((p) => addPointItem(p, isSecondary));\n }\n return legendItems;\n}\n\nexport type LegendItemOptions = Highcharts.SeriesOptionsType | Highcharts.PointOptionsType;\n\nexport function getVisibleLegendItems(options: Highcharts.Options) {\n const isInverted = options.chart?.inverted ?? false;\n const valueAxes = (isInverted ? castArray(options.xAxis) : castArray(options.yAxis)) ?? [];\n const defaultOpposite = valueAxes.length > 0 ? (valueAxes[0].opposite ?? false) : false;\n\n const primaryItems: LegendItemOptions[] = [];\n const secondaryItems: LegendItemOptions[] = [];\n const addLegendItem = (item: LegendItemOptions) => {\n if (isSecondaryLegendItem(item, isInverted, defaultOpposite, valueAxes)) {\n secondaryItems.push(item);\n } else {\n primaryItems.push(item);\n }\n };\n\n options.series?.forEach((series) => {\n // The pie series is not shown in the legend. Instead, we show pie segments (points).\n if (series.type === \"pie\") {\n if (Array.isArray(series.data)) {\n series.data.forEach((point) => addLegendItem(point));\n }\n return;\n }\n // We only support errorbar series that are linked to other series. Those are not represented separately\n // in the legend, but can be controlled from the outside, using controllable items visibility API.\n if (series.type === \"errorbar\") {\n return;\n }\n if (series.showInLegend !== false) {\n addLegendItem(series);\n }\n });\n\n return { primaryItems, secondaryItems };\n}\n\nfunction isSecondaryLegendItem(\n item: LegendItemOptions,\n isInverted: boolean,\n defaultOpposite: boolean,\n valueAxes: Array<{ id?: string; opposite?: boolean }>,\n): boolean {\n // Only items that have an associated axis can be considered secondary\n if (item && typeof item === \"object\" && (\"xAxis\" in item || \"yAxis\" in item)) {\n const axisRef = isInverted ? (item.xAxis ?? 0) : (item.yAxis ?? 0);\n // An axis reference can be an index into the axes array or an explicitly passed id\n const valueAxis = typeof axisRef === \"number\" ? valueAxes[axisRef] : valueAxes.find((a) => a.id === axisRef);\n return valueAxis?.opposite ?? false;\n }\n return defaultOpposite;\n}\n\nexport function getLegendsProps(\n options: CoreChartProps.ChartOptions,\n legendOptions: CoreChartProps.LegendOptions | undefined,\n) {\n // While Highcharts supports more than two axes, this\n // implementation supports at most two, in which case one\n // of them must be set as opposite (secondary).\n const { primaryItems, secondaryItems } = getVisibleLegendItems(options);\n return {\n primary:\n primaryItems.length === 0\n ? undefined\n : ({\n isSecondary: false,\n title: legendOptions?.title,\n actions: legendOptions?.actions,\n alignment: legendOptions?.position === \"side\" ? \"vertical\" : \"horizontal\",\n horizontalAlignment: secondaryItems.length === 0 ? legendOptions?.horizontalAlignment : \"start\",\n } as const),\n secondary:\n secondaryItems.length === 0\n ? undefined\n : ({\n isSecondary: true,\n title: legendOptions?.secondaryLegendTitle,\n actions: legendOptions?.secondaryLegendActions,\n alignment: legendOptions?.position === \"side\" ? \"vertical\" : \"horizontal\",\n horizontalAlignment: \"end\",\n } as const),\n };\n}\n\n// This function returns coordinates of a rectangle, including the target point.\n// There are differences in how the rectangle is computed, but in all cases it is supposed to\n// enclose the point's visual representation in the chart, with no extra offsets.\nexport function getPointRect(point: Highcharts.Point): Rect {\n if (!point.series) {\n return { x: 0, y: 0, width: 0, height: 0 };\n }\n\n switch (point.series.type) {\n case \"column\":\n return getColumnPointRect(point);\n case \"errorbar\":\n return getErrorBarPointRect(point);\n default:\n return getDefaultPointRect(point);\n }\n}\n\n// The group rect is only used for cartesian charts. It returns coordinates of a rectangle,\n// which includes all given points, but also stretched vertically or horizontally (in inverted charts)\n// to the entire chart's height or width.\nexport function getGroupRect(points: readonly Highcharts.Point[]): Rect {\n if (points.length === 0 || !points[0].series) {\n return { x: 0, y: 0, width: 0, height: 0 };\n }\n const chart = points[0].series.chart;\n const rects = points.map(getPointRect);\n const [first, ...rest] = rects;\n let minX = first.x,\n minY = first.y,\n maxX = first.x + first.width,\n maxY = first.y + first.height;\n for (const r of rest) {\n minX = Math.min(minX, r.x);\n minY = Math.min(minY, r.y);\n maxX = Math.max(maxX, r.x + r.width);\n maxY = Math.max(maxY, r.y + r.height);\n }\n return safeRect(\n chart.inverted\n ? { x: chart.plotLeft, y: minY, width: chart.plotWidth, height: maxY - minY }\n : { x: minX, y: chart.plotTop, width: maxX - minX, height: chart.plotHeight },\n );\n}\n\n// We ensure rect width and height are non-zero to ensure its position is calculated correctly in Firefox.\nexport function safeRect(rect: Rect): Rect {\n return { ...rect, width: Math.max(0.1, rect.width), height: Math.max(0.1, rect.height) };\n}\n\nexport function getChartAccessibleDescription(chart: Highcharts.Chart) {\n return chart.options.lang?.accessibility?.chartContainerLabel ?? \"\";\n}\n\nexport function getPointAccessibleDescription(point: Highcharts.Point, labels: ChartLabels) {\n if (point.series.xAxis && point.series.yAxis) {\n const formattedX = getFormatter(point.series.xAxis)(point.x);\n const formattedY = getFormatter(point.series.yAxis)(point.y);\n return `${formattedX} ${formattedY}, ${point.series.name}`;\n } else if (point.series.type === \"pie\") {\n const segmentLabel = labels.chartSegmentLabel ? `${labels.chartSegmentLabel} ` : \"\";\n return `${segmentLabel}${point.name}, ${point.y}. ${point.series.name}`;\n } else {\n return \"\";\n }\n}\n\nexport function getGroupAccessibleDescription(group: readonly Highcharts.Point[]) {\n const firstPoint = group[0];\n return getFormatter(firstPoint.series.xAxis)(firstPoint.x);\n}\n\n// The area-, line-, or scatter series markers are rendered as single graphic elements,\n// and we can use their respective b-boxes to compute rects.\nfunction getDefaultPointRect(point: Highcharts.Point): Rect {\n const chart = point.series.chart;\n if (point.graphic) {\n const box = point.graphic.getBBox();\n return getChartRect(box, chart, false);\n }\n return getPointRectFromCoordinates(point);\n}\n\n// The column series graphic elements are rectangles, and they are inverted if the chart is inverted,\n// so that rect's width becomes height and vice-versa.\nfunction getColumnPointRect(point: Highcharts.Point): Rect {\n const chart = point.series.chart;\n if (point.graphic) {\n return getChartRect(point.graphic.getBBox(), chart, true);\n }\n return getPointRectFromCoordinates(point);\n}\n\n// The errorbar series point rect cannot be computed from the respective graphic element (it gives wrong position).\n// Instead, we have to rely on the internal \"whiskers\" element b-box, which can be inverted, too.\nfunction getErrorBarPointRect(point: Highcharts.Point): Rect {\n const chart = point.series.chart;\n if (\"whiskers\" in point) {\n return getChartRect((point.whiskers as Highcharts.SVGElement).getBBox(), chart, true);\n }\n return getPointRectFromCoordinates(point);\n}\n\n// The point graphic is not present in large charts to optimize performance.\n// In that case we compute point rects from their coordinates. We also assume the point\n// size is small, and thereby give it 0 width and height, which is alright as there is a\n// small offset that we use for focus outline anyways.\n// See: https://www.highcharts.com/blog/news/175-highcharts-performance-boost/\nfunction getPointRectFromCoordinates(point: Highcharts.Point) {\n const chart = point.series.chart;\n const plotX = point.plotX ?? 0;\n const plotY = point.plotY ?? 0;\n return getChartRect({ x: plotX, y: plotY, width: 0, height: 0 }, chart, true);\n}\n\nfunction getChartRect(rect: Rect, chart: Highcharts.Chart, canBeInverted: boolean): Rect {\n return canBeInverted && chart.inverted\n ? {\n x: chart.plotWidth + chart.plotLeft - (rect.y + rect.height),\n y: chart.plotHeight + chart.plotTop - (rect.x + rect.width),\n width: rect.height,\n height: rect.width,\n }\n : {\n x: chart.plotLeft + rect.x,\n y: chart.plotTop + rect.y,\n width: rect.width,\n height: rect.height,\n };\n}\n"]}
|
|
@@ -10,6 +10,7 @@ import { scrollIntoViewNearestContainer } from "../../utils/dom";
|
|
|
10
10
|
import { DebouncedCall } from "../../utils/utils";
|
|
11
11
|
import styles from "./styles.css.js";
|
|
12
12
|
import testClasses from "./test-classes/styles.css.js";
|
|
13
|
+
const TOOLTIP_SHOW_DELAY = 300;
|
|
13
14
|
const TOOLTIP_BLUR_DELAY = 50;
|
|
14
15
|
const HIGHLIGHT_LOST_DELAY = 50;
|
|
15
16
|
const SCROLL_DELAY = 100;
|
|
@@ -27,7 +28,7 @@ export const ChartLegend = ({ items, legendTitle, ariaLabel, actions, alignment,
|
|
|
27
28
|
const control = new DebouncedCall();
|
|
28
29
|
return {
|
|
29
30
|
showTooltip(itemId) {
|
|
30
|
-
control.call(() => setTooltipItemId(itemId));
|
|
31
|
+
control.call(() => setTooltipItemId(itemId), TOOLTIP_SHOW_DELAY);
|
|
31
32
|
},
|
|
32
33
|
hideTooltip(lock = false) {
|
|
33
34
|
control.call(() => setTooltipItemId(null), TOOLTIP_BLUR_DELAY);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/chart-legend/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,UAAU,EAAO,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9E,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EACL,WAAW,EACX,SAA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C,aAAa;YAC3D,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,EAAE,eAAe,IAAI,CAAC,aAAa;SAChE,CAAC,EACF,GAAG,EAAE,SAAS,EACd,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,aAEnB,MAAM,EACP,eAAM,SAAS,EAAE,MAAM,CAAC,YAAY,CAAC,YAAG,KAAK,GAAQ,IAC9C,CACV,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { forwardRef, Ref, useEffect, useMemo, useRef, useState } from \"react\";\nimport clsx from \"clsx\";\n\nimport {\n circleIndex,\n handleKey,\n KeyCode,\n SingleTabStopNavigationAPI,\n SingleTabStopNavigationProvider,\n useMergeRefs,\n useSingleTabStopNavigation,\n} from \"@cloudscape-design/component-toolkit/internal\";\nimport Box, { BoxProps } from \"@cloudscape-design/components/box\";\nimport { InternalChartTooltip } from \"@cloudscape-design/components/internal/do-not-use/chart-tooltip\";\n\nimport { scrollIntoViewNearestContainer } from \"../../utils/dom\";\nimport { DebouncedCall } from \"../../utils/utils\";\nimport { GetLegendTooltipContentProps, LegendItem, LegendTooltipContent } from \"../interfaces\";\n\nimport styles from \"./styles.css.js\";\nimport testClasses from \"./test-classes/styles.css.js\";\n\nconst TOOLTIP_BLUR_DELAY = 50;\nconst HIGHLIGHT_LOST_DELAY = 50;\nconst SCROLL_DELAY = 100;\n\nexport type LegendAlignment = \"horizontal\" | \"vertical\";\nexport type LegendHorizontalAlignment = \"start\" | \"center\" | \"end\";\n\nexport interface ChartLegendProps {\n items: readonly LegendItem[];\n legendTitle?: string;\n ariaLabel?: string;\n className?: string;\n actions?: React.ReactNode;\n someHighlighted: boolean;\n alignment: LegendAlignment;\n horizontalAlignment: LegendHorizontalAlignment;\n onToggleItem: (itemId: string) => void;\n onSelectItem: (itemId: string) => void;\n onItemHighlightEnter: (item: LegendItem) => void;\n onItemHighlightExit: () => void;\n getTooltipContent: (props: GetLegendTooltipContentProps) => null | LegendTooltipContent;\n}\n\nexport const ChartLegend = ({\n items,\n legendTitle,\n ariaLabel,\n actions,\n alignment,\n className,\n someHighlighted,\n onToggleItem,\n onSelectItem,\n onItemHighlightEnter,\n onItemHighlightExit,\n getTooltipContent,\n horizontalAlignment,\n}: ChartLegendProps) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const elementsByIndexRef = useRef<Record<number, HTMLElement>>([]);\n const elementsByIdRef = useRef<Record<string, HTMLElement>>({});\n const tooltipRef = useRef<HTMLElement>(null);\n const highlightControl = useMemo(() => new DebouncedCall(), []);\n const scrollIntoViewControl = useMemo(() => new DebouncedCall(), []);\n const [selectedIndex, setSelectedIndex] = useState<number>(0);\n const [tooltipItemId, setTooltipItemId] = useState<string | null>(null);\n const { showTooltip, hideTooltip } = useMemo(() => {\n const control = new DebouncedCall();\n return {\n showTooltip(itemId: string) {\n control.call(() => setTooltipItemId(itemId));\n },\n hideTooltip(lock = false) {\n control.call(() => setTooltipItemId(null), TOOLTIP_BLUR_DELAY);\n if (lock) {\n control.lock(TOOLTIP_BLUR_DELAY);\n }\n },\n };\n }, []);\n\n useEffect(() => {\n if (!tooltipItemId) {\n return;\n }\n const onDocumentKeyDown = (event: KeyboardEvent) => {\n if (event.keyCode === KeyCode.escape) {\n hideTooltip(true);\n elementsByIdRef.current[tooltipItemId]?.focus();\n }\n };\n document.addEventListener(\"keydown\", onDocumentKeyDown, true);\n return () => {\n document.removeEventListener(\"keydown\", onDocumentKeyDown, true);\n };\n }, [items, tooltipItemId, hideTooltip]);\n const isMouseInContainer = useRef<boolean>(false);\n\n // Scrolling to the highlighted legend item.\n useEffect(() => {\n const highlightedIndex = items.findIndex((item) => item.highlighted);\n if (highlightedIndex === -1) {\n return;\n }\n scrollIntoViewControl.call(() => {\n if (isMouseInContainer.current) {\n return;\n }\n const element = elementsByIndexRef.current?.[highlightedIndex];\n if (!element) {\n return;\n }\n scrollIntoViewNearestContainer(element, { behavior: \"smooth\", scrollMode: \"if-needed\" });\n }, SCROLL_DELAY);\n }, [items, scrollIntoViewControl]);\n\n const showHighlight = (itemId: string) => {\n const item = items.find((item) => item.id === itemId);\n if (item?.visible) {\n highlightControl.cancelPrevious();\n onItemHighlightEnter(item);\n }\n };\n const clearHighlight = () => {\n highlightControl.call(onItemHighlightExit, HIGHLIGHT_LOST_DELAY);\n };\n\n const navigationAPI = useRef<SingleTabStopNavigationAPI>(null);\n\n function onFocus(index: number, itemId: string) {\n setSelectedIndex(index);\n navigationAPI.current!.updateFocusTarget();\n showHighlight(itemId);\n showTooltip(itemId);\n }\n\n function onBlur(event: React.FocusEvent) {\n navigationAPI.current!.updateFocusTarget();\n\n // Hide tooltip and clear highlight unless focus moves inside tooltip;\n if (tooltipRef.current && event.relatedTarget && !tooltipRef.current.contains(event.relatedTarget)) {\n clearHighlight();\n hideTooltip();\n }\n }\n\n function focusElement(index: number) {\n elementsByIndexRef.current[index]?.focus();\n }\n\n function onKeyDown(event: React.KeyboardEvent<HTMLElement>) {\n if (\n event.keyCode === KeyCode.right ||\n event.keyCode === KeyCode.left ||\n event.keyCode === KeyCode.up ||\n event.keyCode === KeyCode.down ||\n event.keyCode === KeyCode.home ||\n event.keyCode === KeyCode.end ||\n event.keyCode === KeyCode.escape\n ) {\n // Preventing default fixes an issue in Safari+VO when VO additionally interprets arrow keys as its commands.\n event.preventDefault();\n\n const range = [0, items.length - 1] as [number, number];\n\n handleKey(event, {\n onInlineStart: () => focusElement(circleIndex(selectedIndex - 1, range)),\n onInlineEnd: () => focusElement(circleIndex(selectedIndex + 1, range)),\n onBlockStart: () => focusElement(circleIndex(selectedIndex - 1, range)),\n onBlockEnd: () => focusElement(circleIndex(selectedIndex + 1, range)),\n onHome: () => focusElement(0),\n onEnd: () => focusElement(items.length - 1),\n onEscape: () => onItemHighlightExit(),\n });\n }\n }\n\n function getNextFocusTarget(): null | HTMLElement {\n if (containerRef.current) {\n const buttons: HTMLButtonElement[] = Array.from(containerRef.current.querySelectorAll(`.${styles.item}`));\n return buttons[selectedIndex] ?? null;\n }\n return null;\n }\n\n function onUnregisterActive(\n focusableElement: HTMLElement,\n navigationAPI: React.RefObject<{ getFocusTarget: () => HTMLElement | null }>,\n ) {\n const target = navigationAPI.current?.getFocusTarget();\n\n if (target && target.dataset.itemid !== focusableElement.dataset.itemid) {\n target.focus();\n }\n }\n\n useEffect(() => {\n navigationAPI.current!.updateFocusTarget();\n });\n\n const isVertical = alignment === \"vertical\";\n\n const tooltipTrack = useRef<null | HTMLElement>(null);\n const tooltipTarget = items.find((item) => item.id === tooltipItemId) ?? null;\n tooltipTrack.current = tooltipItemId ? elementsByIdRef.current[tooltipItemId] : null;\n const tooltipContent = tooltipTarget && getTooltipContent({ legendItem: tooltipTarget });\n const tooltipPosition = isVertical ? \"left\" : \"bottom\";\n\n return (\n <SingleTabStopNavigationProvider\n ref={navigationAPI}\n navigationActive={true}\n getNextFocusTarget={() => getNextFocusTarget()}\n onUnregisterActive={(element: HTMLElement) => onUnregisterActive(element, navigationAPI)}\n >\n <div\n role=\"toolbar\"\n aria-label={legendTitle || ariaLabel}\n className={clsx(testClasses.root, styles.root, className)}\n onMouseEnter={() => (isMouseInContainer.current = true)}\n onMouseLeave={() => (isMouseInContainer.current = false)}\n >\n {legendTitle && (\n <Box fontWeight=\"bold\" className={testClasses.title} textAlign={getBoxTextAlignment(horizontalAlignment)}>\n {legendTitle}\n </Box>\n )}\n <div\n // The list element is not focusable. However, the focus lands on it regardless, when testing in Firefox.\n // Setting the tab index to -1 does fix the problem.\n tabIndex={-1}\n ref={containerRef}\n className={clsx(styles.list, {\n [styles[`list-bottom-${horizontalAlignment}`]]: !isVertical,\n [styles[\"list-bottom\"]]: !isVertical,\n [styles[\"list-side\"]]: isVertical,\n })}\n >\n {actions && (\n <>\n <div className={clsx(testClasses.actions, styles.actions, styles[\"actions-bottom\"])}>\n {actions}\n {!isVertical && <div className={styles[\"actions-divider-bottom\"]} />}\n </div>\n {isVertical && <div className={styles[\"actions-divider-side\"]} />}\n </>\n )}\n {items.map((item, index) => {\n const handlers = {\n onMouseEnter: () => {\n showHighlight(item.id);\n showTooltip(item.id);\n },\n onMouseLeave: () => {\n clearHighlight();\n hideTooltip();\n },\n onFocus: () => {\n onFocus(index, item.id);\n },\n onBlur: (event: React.FocusEvent) => {\n onBlur(event);\n },\n onKeyDown,\n };\n const thisTriggerRef = (elem: null | HTMLElement) => {\n if (elem) {\n elementsByIndexRef.current[index] = elem;\n elementsByIdRef.current[item.id] = elem;\n } else {\n delete elementsByIndexRef.current[index];\n delete elementsByIdRef.current[item.id];\n }\n };\n return (\n <LegendItemTrigger\n key={index}\n {...handlers}\n ref={thisTriggerRef}\n onClick={(event) => {\n if (event.metaKey || event.ctrlKey) {\n onToggleItem(item.id);\n } else {\n onSelectItem(item.id);\n }\n }}\n isHighlighted={item.highlighted}\n someHighlighted={someHighlighted}\n itemId={item.id}\n label={item.name}\n visible={item.visible}\n marker={item.marker}\n />\n );\n })}\n </div>\n {tooltipContent && (\n <InternalChartTooltip\n trackRef={tooltipTrack}\n trackKey={tooltipTarget.id}\n container={null}\n dismissButton={false}\n onDismiss={() => {}}\n position={tooltipPosition}\n title={tooltipContent.header}\n onMouseEnter={() => showTooltip(tooltipTarget.id)}\n onMouseLeave={() => hideTooltip()}\n onBlur={() => hideTooltip()}\n footer={\n tooltipContent.footer && (\n <>\n <hr aria-hidden={true} />\n {tooltipContent.footer}\n </>\n )\n }\n >\n {tooltipContent.body}\n </InternalChartTooltip>\n )}\n </div>\n </SingleTabStopNavigationProvider>\n );\n};\n\nfunction getBoxTextAlignment(horizontalAlignment: LegendHorizontalAlignment): BoxProps.TextAlign {\n switch (horizontalAlignment) {\n case \"start\":\n return \"left\";\n case \"center\":\n return \"center\";\n case \"end\":\n return \"right\";\n }\n}\n\nconst LegendItemTrigger = forwardRef(\n (\n {\n isHighlighted,\n someHighlighted,\n itemId,\n label,\n marker,\n visible,\n onClick,\n triggerRef,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n onKeyDown,\n }: {\n isHighlighted?: boolean;\n someHighlighted?: boolean;\n itemId: string;\n label: string;\n marker?: React.ReactNode;\n visible: boolean;\n onClick: (event: React.MouseEvent) => void;\n onMarkerClick?: () => void;\n triggerRef?: Ref<HTMLElement>;\n onMouseEnter?: () => void;\n onMouseLeave?: () => void;\n onFocus?: () => void;\n onBlur?: (event: React.FocusEvent) => void;\n onKeyDown?: (event: React.KeyboardEvent<HTMLElement>) => void;\n },\n ref: Ref<HTMLButtonElement>,\n ) => {\n const refObject = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs(ref, triggerRef, refObject);\n const { tabIndex } = useSingleTabStopNavigation(refObject);\n return (\n <button\n data-itemid={itemId}\n aria-pressed={visible}\n aria-current={isHighlighted}\n className={clsx(testClasses.item, styles.item, {\n [styles[\"item--inactive\"]]: !visible,\n [testClasses[\"hidden-item\"]]: !visible,\n [styles[\"item--dimmed\"]]: someHighlighted && !isHighlighted,\n [testClasses[\"dimmed-item\"]]: someHighlighted && !isHighlighted,\n })}\n ref={mergedRef}\n tabIndex={tabIndex}\n onClick={onClick}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n >\n {marker}\n <span className={styles[\"item-label\"]}>{label}</span>\n </button>\n );\n },\n);\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/chart-legend/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,UAAU,EAAO,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC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CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,OAAO;YACtC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,eAAe,IAAI,CAAC,aAAa;YAC3D,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,EAAE,eAAe,IAAI,CAAC,aAAa;SAChE,CAAC,EACF,GAAG,EAAE,SAAS,EACd,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,aAEnB,MAAM,EACP,eAAM,SAAS,EAAE,MAAM,CAAC,YAAY,CAAC,YAAG,KAAK,GAAQ,IAC9C,CACV,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { forwardRef, Ref, useEffect, useMemo, useRef, useState } from \"react\";\nimport clsx from \"clsx\";\n\nimport {\n circleIndex,\n handleKey,\n KeyCode,\n SingleTabStopNavigationAPI,\n SingleTabStopNavigationProvider,\n useMergeRefs,\n useSingleTabStopNavigation,\n} from \"@cloudscape-design/component-toolkit/internal\";\nimport Box, { BoxProps } from \"@cloudscape-design/components/box\";\nimport { InternalChartTooltip } from \"@cloudscape-design/components/internal/do-not-use/chart-tooltip\";\n\nimport { scrollIntoViewNearestContainer } from \"../../utils/dom\";\nimport { DebouncedCall } from \"../../utils/utils\";\nimport { GetLegendTooltipContentProps, LegendItem, LegendTooltipContent } from \"../interfaces\";\n\nimport styles from \"./styles.css.js\";\nimport testClasses from \"./test-classes/styles.css.js\";\n\nconst TOOLTIP_SHOW_DELAY = 300;\nconst TOOLTIP_BLUR_DELAY = 50;\nconst HIGHLIGHT_LOST_DELAY = 50;\nconst SCROLL_DELAY = 100;\n\nexport type LegendAlignment = \"horizontal\" | \"vertical\";\nexport type LegendHorizontalAlignment = \"start\" | \"center\" | \"end\";\n\nexport interface ChartLegendProps {\n items: readonly LegendItem[];\n legendTitle?: string;\n ariaLabel?: string;\n className?: string;\n actions?: React.ReactNode;\n someHighlighted: boolean;\n alignment: LegendAlignment;\n horizontalAlignment: LegendHorizontalAlignment;\n onToggleItem: (itemId: string) => void;\n onSelectItem: (itemId: string) => void;\n onItemHighlightEnter: (item: LegendItem) => void;\n onItemHighlightExit: () => void;\n getTooltipContent: (props: GetLegendTooltipContentProps) => null | LegendTooltipContent;\n}\n\nexport const ChartLegend = ({\n items,\n legendTitle,\n ariaLabel,\n actions,\n alignment,\n className,\n someHighlighted,\n onToggleItem,\n onSelectItem,\n onItemHighlightEnter,\n onItemHighlightExit,\n getTooltipContent,\n horizontalAlignment,\n}: ChartLegendProps) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const elementsByIndexRef = useRef<Record<number, HTMLElement>>([]);\n const elementsByIdRef = useRef<Record<string, HTMLElement>>({});\n const tooltipRef = useRef<HTMLElement>(null);\n const highlightControl = useMemo(() => new DebouncedCall(), []);\n const scrollIntoViewControl = useMemo(() => new DebouncedCall(), []);\n const [selectedIndex, setSelectedIndex] = useState<number>(0);\n const [tooltipItemId, setTooltipItemId] = useState<string | null>(null);\n const { showTooltip, hideTooltip } = useMemo(() => {\n const control = new DebouncedCall();\n return {\n showTooltip(itemId: string) {\n control.call(() => setTooltipItemId(itemId), TOOLTIP_SHOW_DELAY);\n },\n hideTooltip(lock = false) {\n control.call(() => setTooltipItemId(null), TOOLTIP_BLUR_DELAY);\n if (lock) {\n control.lock(TOOLTIP_BLUR_DELAY);\n }\n },\n };\n }, []);\n\n useEffect(() => {\n if (!tooltipItemId) {\n return;\n }\n const onDocumentKeyDown = (event: KeyboardEvent) => {\n if (event.keyCode === KeyCode.escape) {\n hideTooltip(true);\n elementsByIdRef.current[tooltipItemId]?.focus();\n }\n };\n document.addEventListener(\"keydown\", onDocumentKeyDown, true);\n return () => {\n document.removeEventListener(\"keydown\", onDocumentKeyDown, true);\n };\n }, [items, tooltipItemId, hideTooltip]);\n const isMouseInContainer = useRef<boolean>(false);\n\n // Scrolling to the highlighted legend item.\n useEffect(() => {\n const highlightedIndex = items.findIndex((item) => item.highlighted);\n if (highlightedIndex === -1) {\n return;\n }\n scrollIntoViewControl.call(() => {\n if (isMouseInContainer.current) {\n return;\n }\n const element = elementsByIndexRef.current?.[highlightedIndex];\n if (!element) {\n return;\n }\n scrollIntoViewNearestContainer(element, { behavior: \"smooth\", scrollMode: \"if-needed\" });\n }, SCROLL_DELAY);\n }, [items, scrollIntoViewControl]);\n\n const showHighlight = (itemId: string) => {\n const item = items.find((item) => item.id === itemId);\n if (item?.visible) {\n highlightControl.cancelPrevious();\n onItemHighlightEnter(item);\n }\n };\n const clearHighlight = () => {\n highlightControl.call(onItemHighlightExit, HIGHLIGHT_LOST_DELAY);\n };\n\n const navigationAPI = useRef<SingleTabStopNavigationAPI>(null);\n\n function onFocus(index: number, itemId: string) {\n setSelectedIndex(index);\n navigationAPI.current!.updateFocusTarget();\n showHighlight(itemId);\n showTooltip(itemId);\n }\n\n function onBlur(event: React.FocusEvent) {\n navigationAPI.current!.updateFocusTarget();\n\n // Hide tooltip and clear highlight unless focus moves inside tooltip;\n if (tooltipRef.current && event.relatedTarget && !tooltipRef.current.contains(event.relatedTarget)) {\n clearHighlight();\n hideTooltip();\n }\n }\n\n function focusElement(index: number) {\n elementsByIndexRef.current[index]?.focus();\n }\n\n function onKeyDown(event: React.KeyboardEvent<HTMLElement>) {\n if (\n event.keyCode === KeyCode.right ||\n event.keyCode === KeyCode.left ||\n event.keyCode === KeyCode.up ||\n event.keyCode === KeyCode.down ||\n event.keyCode === KeyCode.home ||\n event.keyCode === KeyCode.end ||\n event.keyCode === KeyCode.escape\n ) {\n // Preventing default fixes an issue in Safari+VO when VO additionally interprets arrow keys as its commands.\n event.preventDefault();\n\n const range = [0, items.length - 1] as [number, number];\n\n handleKey(event, {\n onInlineStart: () => focusElement(circleIndex(selectedIndex - 1, range)),\n onInlineEnd: () => focusElement(circleIndex(selectedIndex + 1, range)),\n onBlockStart: () => focusElement(circleIndex(selectedIndex - 1, range)),\n onBlockEnd: () => focusElement(circleIndex(selectedIndex + 1, range)),\n onHome: () => focusElement(0),\n onEnd: () => focusElement(items.length - 1),\n onEscape: () => onItemHighlightExit(),\n });\n }\n }\n\n function getNextFocusTarget(): null | HTMLElement {\n if (containerRef.current) {\n const buttons: HTMLButtonElement[] = Array.from(containerRef.current.querySelectorAll(`.${styles.item}`));\n return buttons[selectedIndex] ?? null;\n }\n return null;\n }\n\n function onUnregisterActive(\n focusableElement: HTMLElement,\n navigationAPI: React.RefObject<{ getFocusTarget: () => HTMLElement | null }>,\n ) {\n const target = navigationAPI.current?.getFocusTarget();\n\n if (target && target.dataset.itemid !== focusableElement.dataset.itemid) {\n target.focus();\n }\n }\n\n useEffect(() => {\n navigationAPI.current!.updateFocusTarget();\n });\n\n const isVertical = alignment === \"vertical\";\n\n const tooltipTrack = useRef<null | HTMLElement>(null);\n const tooltipTarget = items.find((item) => item.id === tooltipItemId) ?? null;\n tooltipTrack.current = tooltipItemId ? elementsByIdRef.current[tooltipItemId] : null;\n const tooltipContent = tooltipTarget && getTooltipContent({ legendItem: tooltipTarget });\n const tooltipPosition = isVertical ? \"left\" : \"bottom\";\n\n return (\n <SingleTabStopNavigationProvider\n ref={navigationAPI}\n navigationActive={true}\n getNextFocusTarget={() => getNextFocusTarget()}\n onUnregisterActive={(element: HTMLElement) => onUnregisterActive(element, navigationAPI)}\n >\n <div\n role=\"toolbar\"\n aria-label={legendTitle || ariaLabel}\n className={clsx(testClasses.root, styles.root, className)}\n onMouseEnter={() => (isMouseInContainer.current = true)}\n onMouseLeave={() => (isMouseInContainer.current = false)}\n >\n {legendTitle && (\n <Box fontWeight=\"bold\" className={testClasses.title} textAlign={getBoxTextAlignment(horizontalAlignment)}>\n {legendTitle}\n </Box>\n )}\n <div\n // The list element is not focusable. However, the focus lands on it regardless, when testing in Firefox.\n // Setting the tab index to -1 does fix the problem.\n tabIndex={-1}\n ref={containerRef}\n className={clsx(styles.list, {\n [styles[`list-bottom-${horizontalAlignment}`]]: !isVertical,\n [styles[\"list-bottom\"]]: !isVertical,\n [styles[\"list-side\"]]: isVertical,\n })}\n >\n {actions && (\n <>\n <div className={clsx(testClasses.actions, styles.actions, styles[\"actions-bottom\"])}>\n {actions}\n {!isVertical && <div className={styles[\"actions-divider-bottom\"]} />}\n </div>\n {isVertical && <div className={styles[\"actions-divider-side\"]} />}\n </>\n )}\n {items.map((item, index) => {\n const handlers = {\n onMouseEnter: () => {\n showHighlight(item.id);\n showTooltip(item.id);\n },\n onMouseLeave: () => {\n clearHighlight();\n hideTooltip();\n },\n onFocus: () => {\n onFocus(index, item.id);\n },\n onBlur: (event: React.FocusEvent) => {\n onBlur(event);\n },\n onKeyDown,\n };\n const thisTriggerRef = (elem: null | HTMLElement) => {\n if (elem) {\n elementsByIndexRef.current[index] = elem;\n elementsByIdRef.current[item.id] = elem;\n } else {\n delete elementsByIndexRef.current[index];\n delete elementsByIdRef.current[item.id];\n }\n };\n return (\n <LegendItemTrigger\n key={index}\n {...handlers}\n ref={thisTriggerRef}\n onClick={(event) => {\n if (event.metaKey || event.ctrlKey) {\n onToggleItem(item.id);\n } else {\n onSelectItem(item.id);\n }\n }}\n isHighlighted={item.highlighted}\n someHighlighted={someHighlighted}\n itemId={item.id}\n label={item.name}\n visible={item.visible}\n marker={item.marker}\n />\n );\n })}\n </div>\n {tooltipContent && (\n <InternalChartTooltip\n trackRef={tooltipTrack}\n trackKey={tooltipTarget.id}\n container={null}\n dismissButton={false}\n onDismiss={() => {}}\n position={tooltipPosition}\n title={tooltipContent.header}\n onMouseEnter={() => showTooltip(tooltipTarget.id)}\n onMouseLeave={() => hideTooltip()}\n onBlur={() => hideTooltip()}\n footer={\n tooltipContent.footer && (\n <>\n <hr aria-hidden={true} />\n {tooltipContent.footer}\n </>\n )\n }\n >\n {tooltipContent.body}\n </InternalChartTooltip>\n )}\n </div>\n </SingleTabStopNavigationProvider>\n );\n};\n\nfunction getBoxTextAlignment(horizontalAlignment: LegendHorizontalAlignment): BoxProps.TextAlign {\n switch (horizontalAlignment) {\n case \"start\":\n return \"left\";\n case \"center\":\n return \"center\";\n case \"end\":\n return \"right\";\n }\n}\n\nconst LegendItemTrigger = forwardRef(\n (\n {\n isHighlighted,\n someHighlighted,\n itemId,\n label,\n marker,\n visible,\n onClick,\n triggerRef,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n onKeyDown,\n }: {\n isHighlighted?: boolean;\n someHighlighted?: boolean;\n itemId: string;\n label: string;\n marker?: React.ReactNode;\n visible: boolean;\n onClick: (event: React.MouseEvent) => void;\n onMarkerClick?: () => void;\n triggerRef?: Ref<HTMLElement>;\n onMouseEnter?: () => void;\n onMouseLeave?: () => void;\n onFocus?: () => void;\n onBlur?: (event: React.FocusEvent) => void;\n onKeyDown?: (event: React.KeyboardEvent<HTMLElement>) => void;\n },\n ref: Ref<HTMLButtonElement>,\n ) => {\n const refObject = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs(ref, triggerRef, refObject);\n const { tabIndex } = useSingleTabStopNavigation(refObject);\n return (\n <button\n data-itemid={itemId}\n aria-pressed={visible}\n aria-current={isHighlighted}\n className={clsx(testClasses.item, styles.item, {\n [styles[\"item--inactive\"]]: !visible,\n [testClasses[\"hidden-item\"]]: !visible,\n [styles[\"item--dimmed\"]]: someHighlighted && !isHighlighted,\n [testClasses[\"dimmed-item\"]]: someHighlighted && !isHighlighted,\n })}\n ref={mergedRef}\n tabIndex={tabIndex}\n onClick={onClick}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n >\n {marker}\n <span className={styles[\"item-label\"]}>{label}</span>\n </button>\n );\n },\n);\n"]}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
|
|
2
2
|
import './styles.scoped.css';
|
|
3
3
|
export default {
|
|
4
|
-
"focus-outline": "awsui_focus-
|
|
5
|
-
"item": "
|
|
6
|
-
"root": "
|
|
7
|
-
"list": "
|
|
8
|
-
"list-bottom": "awsui_list-
|
|
9
|
-
"list-bottom-start": "awsui_list-bottom-
|
|
10
|
-
"list-bottom-center": "awsui_list-bottom-
|
|
11
|
-
"list-bottom-end": "awsui_list-bottom-
|
|
12
|
-
"list-side": "awsui_list-
|
|
13
|
-
"item--inactive": "awsui_item--
|
|
14
|
-
"item--dimmed": "awsui_item--
|
|
15
|
-
"item-label": "awsui_item-
|
|
16
|
-
"actions": "
|
|
17
|
-
"actions-bottom": "awsui_actions-
|
|
18
|
-
"actions-side": "awsui_actions-
|
|
19
|
-
"actions-divider-bottom": "awsui_actions-divider-
|
|
20
|
-
"actions-divider-side": "awsui_actions-divider-
|
|
4
|
+
"focus-outline": "awsui_focus-outline_1kjc7_16cox_15",
|
|
5
|
+
"item": "awsui_item_1kjc7_16cox_27",
|
|
6
|
+
"root": "awsui_root_1kjc7_16cox_41",
|
|
7
|
+
"list": "awsui_list_1kjc7_16cox_85",
|
|
8
|
+
"list-bottom": "awsui_list-bottom_1kjc7_16cox_96",
|
|
9
|
+
"list-bottom-start": "awsui_list-bottom-start_1kjc7_16cox_100",
|
|
10
|
+
"list-bottom-center": "awsui_list-bottom-center_1kjc7_16cox_103",
|
|
11
|
+
"list-bottom-end": "awsui_list-bottom-end_1kjc7_16cox_106",
|
|
12
|
+
"list-side": "awsui_list-side_1kjc7_16cox_110",
|
|
13
|
+
"item--inactive": "awsui_item--inactive_1kjc7_16cox_180",
|
|
14
|
+
"item--dimmed": "awsui_item--dimmed_1kjc7_16cox_186",
|
|
15
|
+
"item-label": "awsui_item-label_1kjc7_16cox_190",
|
|
16
|
+
"actions": "awsui_actions_1kjc7_16cox_200",
|
|
17
|
+
"actions-bottom": "awsui_actions-bottom_1kjc7_16cox_205",
|
|
18
|
+
"actions-side": "awsui_actions-side_1kjc7_16cox_209",
|
|
19
|
+
"actions-divider-bottom": "awsui_actions-divider-bottom_1kjc7_16cox_214",
|
|
20
|
+
"actions-divider-side": "awsui_actions-divider-side_1kjc7_16cox_221"
|
|
21
21
|
};
|
|
22
22
|
|