@cloudscape-design/chart-components 1.0.17 → 1.0.18
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/components/core-legend.d.ts +2 -1
- package/core/components/core-legend.js +2 -2
- package/core/components/core-legend.js.map +1 -1
- package/core/interfaces.d.ts +6 -0
- package/core/interfaces.js.map +1 -1
- package/internal/components/chart-legend/index.d.ts +3 -1
- package/internal/components/chart-legend/index.js +6 -2
- package/internal/components/chart-legend/index.js.map +1 -1
- package/internal/components/chart-legend/styles.css.js +23 -17
- package/internal/components/chart-legend/styles.scoped.css +44 -26
- package/internal/components/chart-legend/styles.selectors.js +23 -17
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/manifest.json +1 -1
- package/internal-do-not-use/core-legend/index.d.ts +1 -1
- package/internal-do-not-use/core-legend/index.js +2 -2
- package/internal-do-not-use/core-legend/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
import { NonCancelableEventHandler } from "../../internal/events";
|
|
3
3
|
import { ChartAPI } from "../chart-api";
|
|
4
4
|
import { BaseI18nStrings, CoreChartProps } from "../interfaces";
|
|
5
|
-
export declare function ChartLegend({ api, title, actions, position, i18nStrings, onItemHighlight, getLegendTooltipContent, }: {
|
|
5
|
+
export declare function ChartLegend({ api, title, actions, position, i18nStrings, onItemHighlight, getLegendTooltipContent, horizontalAlignment, }: {
|
|
6
6
|
api: ChartAPI;
|
|
7
7
|
title?: string;
|
|
8
8
|
actions?: React.ReactNode;
|
|
9
9
|
position: "bottom" | "side";
|
|
10
|
+
horizontalAlignment?: CoreChartProps.LegendOptionsHorizontalAlignment;
|
|
10
11
|
i18nStrings?: BaseI18nStrings;
|
|
11
12
|
onItemHighlight?: NonCancelableEventHandler<CoreChartProps.LegendItemHighlightDetail>;
|
|
12
13
|
getLegendTooltipContent?: CoreChartProps.GetLegendTooltipContent;
|
|
@@ -5,7 +5,7 @@ import { useInternalI18n } from "@cloudscape-design/components/internal/do-not-u
|
|
|
5
5
|
import { ChartLegend as ChartLegendComponent } from "../../internal/components/chart-legend";
|
|
6
6
|
import { fireNonCancelableEvent } from "../../internal/events";
|
|
7
7
|
import { useSelector } from "../../internal/utils/async-store";
|
|
8
|
-
export function ChartLegend({ api, title, actions, position, i18nStrings, onItemHighlight, getLegendTooltipContent, }) {
|
|
8
|
+
export function ChartLegend({ api, title, actions, position, i18nStrings, onItemHighlight, getLegendTooltipContent, horizontalAlignment = "start", }) {
|
|
9
9
|
const i18n = useInternalI18n("[charts]");
|
|
10
10
|
const ariaLabel = i18n("i18nStrings.legendAriaLabel", i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.legendAriaLabel);
|
|
11
11
|
const legendItems = useSelector(api.legendStore, (s) => s.items);
|
|
@@ -13,7 +13,7 @@ export function ChartLegend({ api, title, actions, position, i18nStrings, onItem
|
|
|
13
13
|
if (legendItems.length === 0) {
|
|
14
14
|
return null;
|
|
15
15
|
}
|
|
16
|
-
return (_jsx(ChartLegendComponent, { ariaLabel: ariaLabel, legendTitle: title, items: legendItems, actions: actions, position: position, onItemVisibilityChange: api.onItemVisibilityChange, onItemHighlightExit: api.onClearChartItemsHighlight, onItemHighlightEnter: (item) => {
|
|
16
|
+
return (_jsx(ChartLegendComponent, { ariaLabel: ariaLabel, legendTitle: title, items: legendItems, horizontalAlignment: horizontalAlignment, actions: actions, position: position, onItemVisibilityChange: api.onItemVisibilityChange, onItemHighlightExit: api.onClearChartItemsHighlight, onItemHighlightEnter: (item) => {
|
|
17
17
|
api.onHighlightChartItems([item.id]);
|
|
18
18
|
fireNonCancelableEvent(onItemHighlight, { item });
|
|
19
19
|
}, getTooltipContent: (props) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-legend.js","sourceRoot":"","sources":["../../../../src/core/components/core-legend.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE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C,MAAM,KAAK,CAAC,EAAE;QAC5B,OAAO,IAAI,CAAC;KACb;IACD,OAAO,CACL,KAAC,oBAAoB,IACnB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,KAAK,EAClB,KAAK,EAAE,WAAW,EAClB,mBAAmB,EAAE,mBAAmB,EACxC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,sBAAsB,EAAE,GAAG,CAAC,sBAAsB,EAClD,mBAAmB,EAAE,GAAG,CAAC,0BAA0B,EACnD,oBAAoB,EAAE,CAAC,IAAI,EAAE,EAAE;YAC7B,GAAG,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;YACrC,sBAAsB,CAAC,eAAe,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QACpD,CAAC,EACD,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE;;YAC3B,IAAI,oBAAoB,EAAE;gBACxB,OAAO,IAAI,CAAC;aACb;YACD,OAAO,MAAA,uBAAuB,aAAvB,uBAAuB,uBAAvB,uBAAuB,CAAG,KAAK,CAAC,mCAAI,IAAI,CAAC;QAClD,CAAC,GACD,CACH,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useInternalI18n } from \"@cloudscape-design/components/internal/do-not-use/i18n\";\n\nimport { ChartLegend as ChartLegendComponent } from \"../../internal/components/chart-legend\";\nimport { fireNonCancelableEvent, NonCancelableEventHandler } from \"../../internal/events\";\nimport { useSelector } from \"../../internal/utils/async-store\";\nimport { ChartAPI } from \"../chart-api\";\nimport { BaseI18nStrings, CoreChartProps } from \"../interfaces\";\n\nexport function ChartLegend({\n api,\n title,\n actions,\n position,\n i18nStrings,\n onItemHighlight,\n getLegendTooltipContent,\n horizontalAlignment = \"start\",\n}: {\n api: ChartAPI;\n title?: string;\n actions?: React.ReactNode;\n position: \"bottom\" | \"side\";\n horizontalAlignment?: CoreChartProps.LegendOptionsHorizontalAlignment;\n i18nStrings?: BaseI18nStrings;\n onItemHighlight?: NonCancelableEventHandler<CoreChartProps.LegendItemHighlightDetail>;\n getLegendTooltipContent?: CoreChartProps.GetLegendTooltipContent;\n}) {\n const i18n = useInternalI18n(\"[charts]\");\n const ariaLabel = i18n(\"i18nStrings.legendAriaLabel\", i18nStrings?.legendAriaLabel);\n const legendItems = useSelector(api.legendStore, (s) => s.items);\n const isChartTooltipPinned = useSelector(api.tooltipStore, (s) => s.pinned);\n\n if (legendItems.length === 0) {\n return null;\n }\n return (\n <ChartLegendComponent\n ariaLabel={ariaLabel}\n legendTitle={title}\n items={legendItems}\n horizontalAlignment={horizontalAlignment}\n actions={actions}\n position={position}\n onItemVisibilityChange={api.onItemVisibilityChange}\n onItemHighlightExit={api.onClearChartItemsHighlight}\n onItemHighlightEnter={(item) => {\n api.onHighlightChartItems([item.id]);\n fireNonCancelableEvent(onItemHighlight, { item });\n }}\n getTooltipContent={(props) => {\n if (isChartTooltipPinned) {\n return null;\n }\n return getLegendTooltipContent?.(props) ?? null;\n }}\n />\n );\n}\n"]}
|
package/core/interfaces.d.ts
CHANGED
|
@@ -355,7 +355,12 @@ export declare namespace CoreChartProps {
|
|
|
355
355
|
interface LegendOptions extends BaseLegendOptions {
|
|
356
356
|
bottomMaxHeight?: number;
|
|
357
357
|
position?: "bottom" | "side";
|
|
358
|
+
/**
|
|
359
|
+
* This property only applies when `position="bottom"`.
|
|
360
|
+
*/
|
|
361
|
+
horizontalAlignment?: LegendOptionsHorizontalAlignment;
|
|
358
362
|
}
|
|
363
|
+
type LegendOptionsHorizontalAlignment = "start" | "center";
|
|
359
364
|
type LegendItem = InternalComponentTypes.LegendItem;
|
|
360
365
|
type LegendTooltipContent = InternalComponentTypes.LegendTooltipContent;
|
|
361
366
|
type GetLegendTooltipContent = InternalComponentTypes.GetLegendTooltipContent;
|
|
@@ -416,6 +421,7 @@ export interface CoreLegendProps {
|
|
|
416
421
|
ariaLabel?: string;
|
|
417
422
|
actions?: React.ReactNode;
|
|
418
423
|
alignment?: "horizontal" | "vertical";
|
|
424
|
+
horizontalAlignment?: CoreChartProps.LegendOptionsHorizontalAlignment;
|
|
419
425
|
onClearHighlight?: NonCancelableEventHandler;
|
|
420
426
|
onItemHighlight?: NonCancelableEventHandler<CoreLegendProps.ItemHighlightDetail>;
|
|
421
427
|
onVisibleItemsChange?: NonCancelableEventHandler<CoreLegendProps.VisibleItemsChangeDetail>;
|
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 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;\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 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 }\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 }\n export interface TooltipSlotProps {\n x: number;\n items: TooltipContentItem[];\n }\n\n export interface TooltipDetailsProps {\n point: Highcharts.Point;\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 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 { 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 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;\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 `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 }\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 }\n export interface TooltipSlotProps {\n x: number;\n items: TooltipContentItem[];\n }\n\n export interface TooltipDetailsProps {\n point: Highcharts.Point;\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,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { CoreChartProps } from "../../../core/interfaces";
|
|
2
3
|
import { GetLegendTooltipContentProps, LegendItem, LegendTooltipContent } from "../interfaces";
|
|
3
4
|
export interface ChartLegendProps {
|
|
4
5
|
items: readonly LegendItem[];
|
|
@@ -6,9 +7,10 @@ export interface ChartLegendProps {
|
|
|
6
7
|
ariaLabel?: string;
|
|
7
8
|
actions?: React.ReactNode;
|
|
8
9
|
position: "bottom" | "side";
|
|
10
|
+
horizontalAlignment: CoreChartProps.LegendOptionsHorizontalAlignment;
|
|
9
11
|
onItemHighlightEnter: (item: LegendItem) => void;
|
|
10
12
|
onItemHighlightExit: () => void;
|
|
11
13
|
onItemVisibilityChange: (hiddenItems: string[]) => void;
|
|
12
14
|
getTooltipContent: (props: GetLegendTooltipContentProps) => null | LegendTooltipContent;
|
|
13
15
|
}
|
|
14
|
-
export declare const ChartLegend: ({ items, legendTitle, ariaLabel, actions, position, onItemVisibilityChange, onItemHighlightEnter, onItemHighlightExit, getTooltipContent, }: ChartLegendProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare const ChartLegend: ({ items, legendTitle, ariaLabel, actions, position, onItemVisibilityChange, onItemHighlightEnter, onItemHighlightExit, getTooltipContent, horizontalAlignment, }: ChartLegendProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -12,7 +12,7 @@ import testClasses from "./test-classes/styles.css.js";
|
|
|
12
12
|
const TOOLTIP_BLUR_DELAY = 50;
|
|
13
13
|
const HIGHLIGHT_LOST_DELAY = 50;
|
|
14
14
|
const SCROLL_DELAY = 100;
|
|
15
|
-
export const ChartLegend = ({ items, legendTitle, ariaLabel, actions, position, onItemVisibilityChange, onItemHighlightEnter, onItemHighlightExit, getTooltipContent, }) => {
|
|
15
|
+
export const ChartLegend = ({ items, legendTitle, ariaLabel, actions, position, onItemVisibilityChange, onItemHighlightEnter, onItemHighlightExit, getTooltipContent, horizontalAlignment, }) => {
|
|
16
16
|
var _a;
|
|
17
17
|
const containerRef = useRef(null);
|
|
18
18
|
const elementsByIndexRef = useRef([]);
|
|
@@ -178,10 +178,13 @@ export const ChartLegend = ({ items, legendTitle, ariaLabel, actions, position,
|
|
|
178
178
|
const tooltipPosition = position === "bottom" ? "bottom" : "left";
|
|
179
179
|
return (_jsx(SingleTabStopNavigationProvider, { ref: navigationAPI, navigationActive: true, getNextFocusTarget: () => getNextFocusTarget(), onUnregisterActive: (element) => onUnregisterActive(element, navigationAPI), children: _jsxs("div", { ref: containerRef, role: "toolbar", "aria-label": legendTitle || ariaLabel, className: clsx(testClasses.root, styles.root, {
|
|
180
180
|
[styles["root-side"]]: position === "side",
|
|
181
|
-
}), onMouseEnter: () => (isMouseInContainer.current = true), onMouseLeave: () => (isMouseInContainer.current = false), children: [legendTitle && (_jsx(Box, { fontWeight: "bold", className: testClasses.title,
|
|
181
|
+
}), onMouseEnter: () => (isMouseInContainer.current = true), onMouseLeave: () => (isMouseInContainer.current = false), children: [legendTitle && (_jsx(Box, { fontWeight: "bold", className: clsx(testClasses.title, {
|
|
182
|
+
[styles[`legend-title-${horizontalAlignment}`]]: position === "bottom",
|
|
183
|
+
}), children: legendTitle })), _jsxs("div", {
|
|
182
184
|
// The list element is not focusable. However, the focus lands on it regardless, when testing in Firefox.
|
|
183
185
|
// Setting the tab index to -1 does fix the problem.
|
|
184
186
|
tabIndex: -1, className: clsx(styles.list, {
|
|
187
|
+
[styles[`list-bottom-${horizontalAlignment}`]]: position === "bottom",
|
|
185
188
|
[styles["list-bottom"]]: position === "bottom",
|
|
186
189
|
[styles["list-side"]]: position === "side",
|
|
187
190
|
}), children: [actions && (_jsx(_Fragment, { children: _jsxs("div", { className: clsx(testClasses.actions, styles.actions, {
|
|
@@ -191,6 +194,7 @@ export const ChartLegend = ({ items, legendTitle, ariaLabel, actions, position,
|
|
|
191
194
|
[styles["actions-divider-bottom"]]: position === "bottom",
|
|
192
195
|
[styles["actions-divider-side"]]: position === "side",
|
|
193
196
|
}) })] }) })), _jsx("div", { className: clsx({
|
|
197
|
+
[styles[`legend-bottom-${horizontalAlignment}`]]: position === "bottom",
|
|
194
198
|
[styles["legend-bottom"]]: position === "bottom",
|
|
195
199
|
[styles["legend-side"]]: position === "side",
|
|
196
200
|
}), children: items.map((item, index) => {
|
|
@@ -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,SAAS,EACT,OAAO,EAEP,+BAA+B,EAC/B,YAAY,EACZ,0BAA0B,GAC3B,MAAM,+CAA+C,CAAC;AACvD,OAAO,GAAG,MAAM,mCAAmC,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iEAAiE,CAAC;AAEvG,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,WAAW,MAAM,8BAA8B,CAAC;AAEvD,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,MAAM,YAAY,GAAG,GAAG,CAAC;AAczB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,E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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 from \"@cloudscape-design/components/box\";\nimport { InternalChartTooltip } from \"@cloudscape-design/components/internal/do-not-use/chart-tooltip\";\n\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 interface ChartLegendProps {\n items: readonly LegendItem[];\n legendTitle?: string;\n ariaLabel?: string;\n actions?: React.ReactNode;\n position: \"bottom\" | \"side\";\n onItemHighlightEnter: (item: LegendItem) => void;\n onItemHighlightExit: () => void;\n onItemVisibilityChange: (hiddenItems: string[]) => void;\n getTooltipContent: (props: GetLegendTooltipContentProps) => null | LegendTooltipContent;\n}\n\nexport const ChartLegend = ({\n items,\n legendTitle,\n ariaLabel,\n actions,\n position,\n onItemVisibilityChange,\n onItemHighlightEnter,\n onItemHighlightExit,\n getTooltipContent,\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 container = containerRef.current;\n const element = elementsByIndexRef.current?.[highlightedIndex];\n if (!container || !element) {\n return;\n }\n const elementRect = element.getBoundingClientRect();\n const containerRect = container.getBoundingClientRect();\n const isVisible = elementRect.top >= containerRect.top && elementRect.bottom <= containerRect.bottom;\n if (!isVisible) {\n const elementCenter = elementRect.top + elementRect.height / 2;\n const containerCenter = containerRect.top + containerRect.height / 2;\n const top = container.scrollTop + (elementCenter - containerCenter);\n container.scrollTo({ top, behavior: \"smooth\" });\n }\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 toggleItem = (itemId: string) => {\n const visibleItems = items.filter((i) => i.visible).map((i) => i.id);\n if (visibleItems.includes(itemId)) {\n onItemVisibilityChange(visibleItems.filter((visibleItemId) => visibleItemId !== itemId));\n } else {\n onItemVisibilityChange([...visibleItems, itemId]);\n }\n // Needed for touch devices.\n onItemHighlightExit();\n };\n\n const selectItem = (itemId: string) => {\n const visibleItems = items.filter((i) => i.visible).map((i) => i.id);\n if (visibleItems.length === 1 && visibleItems[0] === itemId) {\n onItemVisibilityChange(items.map((i) => i.id));\n } else {\n onItemVisibilityChange([itemId]);\n }\n // Needed for touch devices.\n onItemHighlightExit();\n };\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 = position === \"bottom\" ? \"bottom\" : \"left\";\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 ref={containerRef}\n role=\"toolbar\"\n aria-label={legendTitle || ariaLabel}\n className={clsx(testClasses.root, styles.root, {\n [styles[\"root-side\"]]: position === \"side\",\n })}\n onMouseEnter={() => (isMouseInContainer.current = true)}\n onMouseLeave={() => (isMouseInContainer.current = false)}\n >\n {legendTitle && (\n <Box fontWeight=\"bold\" className={testClasses.title}>\n {legendTitle}\n </Box>\n )}\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 className={clsx(styles.list, {\n [styles[\"list-bottom\"]]: position === \"bottom\",\n [styles[\"list-side\"]]: position === \"side\",\n })}\n >\n {actions && (\n <>\n <div\n className={clsx(testClasses.actions, styles.actions, {\n [styles[\"actions-bottom\"]]: position === \"bottom\",\n [styles[\"actions-side\"]]: position === \"side\",\n })}\n >\n {actions}\n <div\n className={clsx(styles[\"actions-divider\"], {\n [styles[\"actions-divider-bottom\"]]: position === \"bottom\",\n [styles[\"actions-divider-side\"]]: position === \"side\",\n })}\n />\n </div>\n </>\n )}\n <div\n className={clsx({\n [styles[\"legend-bottom\"]]: position === \"bottom\",\n [styles[\"legend-side\"]]: position === \"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[index];\n }\n };\n return (\n <LegendItemTrigger\n key={index}\n {...handlers}\n ref={thisTriggerRef}\n onClick={(event) => {\n if (event.metaKey || event.ctrlKey) {\n toggleItem(item.id);\n } else {\n selectItem(item.id);\n }\n }}\n isHighlighted={item.highlighted}\n someHighlighted={items.some((item) => item.highlighted)}\n itemId={item.id}\n label={item.name}\n visible={item.visible}\n marker={item.marker}\n />\n );\n })}\n </div>\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\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;AAC9E,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EACL,WAAW,EACX,SAAS,EACT,OAAO,EAEP,+BAA+B,EAC/B,YAAY,EACZ,0BAA0B,GAC3B,MAAM,+CAA+C,CAAC;AACvD,OAAO,GAAG,MAAM,mCAAmC,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iEAAiE,CAAC;AAGvG,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,WAAW,MAAM,8BAA8B,CAAC;AAEvD,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,MAAM,YAAY,GAAG,GAAG,CAAC;AAezB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAC1B,KAAK,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,QAAQ,EACR,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,GACF,EAAE,EAAE;;IACrB,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAClD,MAAM,kBAAkB,GAAG,MAAM,CAA8B,EAAE,CAAC,CAAC;IACnE,MAAM,eAAe,GAAG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,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 from \"@cloudscape-design/components/box\";\nimport { InternalChartTooltip } from \"@cloudscape-design/components/internal/do-not-use/chart-tooltip\";\n\nimport { CoreChartProps } from \"../../../core/interfaces\";\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 interface ChartLegendProps {\n items: readonly LegendItem[];\n legendTitle?: string;\n ariaLabel?: string;\n actions?: React.ReactNode;\n position: \"bottom\" | \"side\";\n horizontalAlignment: CoreChartProps.LegendOptionsHorizontalAlignment;\n onItemHighlightEnter: (item: LegendItem) => void;\n onItemHighlightExit: () => void;\n onItemVisibilityChange: (hiddenItems: string[]) => void;\n getTooltipContent: (props: GetLegendTooltipContentProps) => null | LegendTooltipContent;\n}\n\nexport const ChartLegend = ({\n items,\n legendTitle,\n ariaLabel,\n actions,\n position,\n onItemVisibilityChange,\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 container = containerRef.current;\n const element = elementsByIndexRef.current?.[highlightedIndex];\n if (!container || !element) {\n return;\n }\n const elementRect = element.getBoundingClientRect();\n const containerRect = container.getBoundingClientRect();\n const isVisible = elementRect.top >= containerRect.top && elementRect.bottom <= containerRect.bottom;\n if (!isVisible) {\n const elementCenter = elementRect.top + elementRect.height / 2;\n const containerCenter = containerRect.top + containerRect.height / 2;\n const top = container.scrollTop + (elementCenter - containerCenter);\n container.scrollTo({ top, behavior: \"smooth\" });\n }\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 toggleItem = (itemId: string) => {\n const visibleItems = items.filter((i) => i.visible).map((i) => i.id);\n if (visibleItems.includes(itemId)) {\n onItemVisibilityChange(visibleItems.filter((visibleItemId) => visibleItemId !== itemId));\n } else {\n onItemVisibilityChange([...visibleItems, itemId]);\n }\n // Needed for touch devices.\n onItemHighlightExit();\n };\n\n const selectItem = (itemId: string) => {\n const visibleItems = items.filter((i) => i.visible).map((i) => i.id);\n if (visibleItems.length === 1 && visibleItems[0] === itemId) {\n onItemVisibilityChange(items.map((i) => i.id));\n } else {\n onItemVisibilityChange([itemId]);\n }\n // Needed for touch devices.\n onItemHighlightExit();\n };\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 = position === \"bottom\" ? \"bottom\" : \"left\";\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 ref={containerRef}\n role=\"toolbar\"\n aria-label={legendTitle || ariaLabel}\n className={clsx(testClasses.root, styles.root, {\n [styles[\"root-side\"]]: position === \"side\",\n })}\n onMouseEnter={() => (isMouseInContainer.current = true)}\n onMouseLeave={() => (isMouseInContainer.current = false)}\n >\n {legendTitle && (\n <Box\n fontWeight=\"bold\"\n className={clsx(testClasses.title, {\n [styles[`legend-title-${horizontalAlignment}`]]: position === \"bottom\",\n })}\n >\n {legendTitle}\n </Box>\n )}\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 className={clsx(styles.list, {\n [styles[`list-bottom-${horizontalAlignment}`]]: position === \"bottom\",\n [styles[\"list-bottom\"]]: position === \"bottom\",\n [styles[\"list-side\"]]: position === \"side\",\n })}\n >\n {actions && (\n <>\n <div\n className={clsx(testClasses.actions, styles.actions, {\n [styles[\"actions-bottom\"]]: position === \"bottom\",\n [styles[\"actions-side\"]]: position === \"side\",\n })}\n >\n {actions}\n <div\n className={clsx(styles[\"actions-divider\"], {\n [styles[\"actions-divider-bottom\"]]: position === \"bottom\",\n [styles[\"actions-divider-side\"]]: position === \"side\",\n })}\n />\n </div>\n </>\n )}\n <div\n className={clsx({\n [styles[`legend-bottom-${horizontalAlignment}`]]: position === \"bottom\",\n [styles[\"legend-bottom\"]]: position === \"bottom\",\n [styles[\"legend-side\"]]: position === \"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[index];\n }\n };\n return (\n <LegendItemTrigger\n key={index}\n {...handlers}\n ref={thisTriggerRef}\n onClick={(event) => {\n if (event.metaKey || event.ctrlKey) {\n toggleItem(item.id);\n } else {\n selectItem(item.id);\n }\n }}\n isHighlighted={item.highlighted}\n someHighlighted={items.some((item) => item.highlighted)}\n itemId={item.id}\n label={item.name}\n visible={item.visible}\n marker={item.marker}\n />\n );\n })}\n </div>\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\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,28 @@
|
|
|
1
1
|
|
|
2
2
|
import './styles.scoped.css';
|
|
3
3
|
export default {
|
|
4
|
-
"focus-outline": "awsui_focus-
|
|
5
|
-
"item": "
|
|
6
|
-
"root": "
|
|
7
|
-
"root-side": "awsui_root-
|
|
8
|
-
"list": "
|
|
9
|
-
"list-bottom": "awsui_list-
|
|
10
|
-
"list-
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
4
|
+
"focus-outline": "awsui_focus-outline_1kjc7_oede3_15",
|
|
5
|
+
"item": "awsui_item_1kjc7_oede3_27",
|
|
6
|
+
"root": "awsui_root_1kjc7_oede3_41",
|
|
7
|
+
"root-side": "awsui_root-side_1kjc7_oede3_81",
|
|
8
|
+
"list": "awsui_list_1kjc7_oede3_86",
|
|
9
|
+
"list-bottom": "awsui_list-bottom_1kjc7_oede3_96",
|
|
10
|
+
"list-bottom-start": "awsui_list-bottom-start_1kjc7_oede3_99",
|
|
11
|
+
"list-bottom-center": "awsui_list-bottom-center_1kjc7_oede3_102",
|
|
12
|
+
"list-side": "awsui_list-side_1kjc7_oede3_106",
|
|
13
|
+
"legend-bottom": "awsui_legend-bottom_1kjc7_oede3_111",
|
|
14
|
+
"legend-bottom-start": "awsui_legend-bottom-start_1kjc7_oede3_118",
|
|
15
|
+
"legend-bottom-center": "awsui_legend-bottom-center_1kjc7_oede3_121",
|
|
16
|
+
"legend-title-start": "awsui_legend-title-start_1kjc7_oede3_125",
|
|
17
|
+
"legend-title-center": "awsui_legend-title-center_1kjc7_oede3_129",
|
|
18
|
+
"legend-side": "awsui_legend-side_1kjc7_oede3_133",
|
|
19
|
+
"item--inactive": "awsui_item--inactive_1kjc7_oede3_204",
|
|
20
|
+
"item--dimmed": "awsui_item--dimmed_1kjc7_oede3_210",
|
|
21
|
+
"item-label": "awsui_item-label_1kjc7_oede3_214",
|
|
22
|
+
"actions": "awsui_actions_1kjc7_oede3_224",
|
|
23
|
+
"actions-bottom": "awsui_actions-bottom_1kjc7_oede3_229",
|
|
24
|
+
"actions-side": "awsui_actions-side_1kjc7_oede3_233",
|
|
25
|
+
"actions-divider-bottom": "awsui_actions-divider-bottom_1kjc7_oede3_238",
|
|
26
|
+
"actions-divider-side": "awsui_actions-divider-side_1kjc7_oede3_245"
|
|
21
27
|
};
|
|
22
28
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
/* stylelint-disable @cloudscape-design/no-motion-outside-of-mixin, selector-combinator-disallowed-list, selector-pseudo-class-no-unknown, selector-class-pattern */
|
|
14
14
|
/* stylelint-enable @cloudscape-design/no-motion-outside-of-mixin, selector-combinator-disallowed-list, selector-pseudo-class-no-unknown, selector-class-pattern */
|
|
15
|
-
body[data-awsui-focus-visible=true] .awsui_focus-
|
|
15
|
+
body[data-awsui-focus-visible=true] .awsui_focus-outline_1kjc7_oede3_15:not(#\9) {
|
|
16
16
|
stroke: var(--color-border-item-focused-uk47pl, #006ce0);
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -24,21 +24,21 @@ body[data-awsui-focus-visible=true] .awsui_focus-outline_1kjc7_ordh1_15:not(#\9)
|
|
|
24
24
|
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
25
25
|
SPDX-License-Identifier: Apache-2.0
|
|
26
26
|
*/
|
|
27
|
-
.
|
|
27
|
+
.awsui_item_1kjc7_oede3_27:not(#\9) {
|
|
28
28
|
transition: opacity 90ms linear;
|
|
29
29
|
}
|
|
30
30
|
@media (prefers-reduced-motion: reduce) {
|
|
31
|
-
.
|
|
31
|
+
.awsui_item_1kjc7_oede3_27:not(#\9) {
|
|
32
32
|
animation: none;
|
|
33
33
|
transition: none;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
.awsui-motion-disabled .
|
|
36
|
+
.awsui-motion-disabled .awsui_item_1kjc7_oede3_27:not(#\9), .awsui-mode-entering .awsui_item_1kjc7_oede3_27:not(#\9) {
|
|
37
37
|
animation: none;
|
|
38
38
|
transition: none;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
.
|
|
41
|
+
.awsui_root_1kjc7_oede3_41:not(#\9) {
|
|
42
42
|
border-collapse: separate;
|
|
43
43
|
border-spacing: 0;
|
|
44
44
|
box-sizing: border-box;
|
|
@@ -74,16 +74,16 @@ body[data-awsui-focus-visible=true] .awsui_focus-outline_1kjc7_ordh1_15:not(#\9)
|
|
|
74
74
|
overflow: auto;
|
|
75
75
|
max-height: inherit;
|
|
76
76
|
}
|
|
77
|
-
.
|
|
77
|
+
.awsui_root_1kjc7_oede3_41:not(#\9):focus {
|
|
78
78
|
outline: none;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
.awsui_root-
|
|
81
|
+
.awsui_root-side_1kjc7_oede3_81:not(#\9) {
|
|
82
82
|
display: flex;
|
|
83
83
|
flex-direction: column;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
.
|
|
86
|
+
.awsui_list_1kjc7_oede3_86:not(#\9) {
|
|
87
87
|
display: flex;
|
|
88
88
|
list-style: none;
|
|
89
89
|
margin-block: 0;
|
|
@@ -93,33 +93,51 @@ body[data-awsui-focus-visible=true] .awsui_focus-outline_1kjc7_ordh1_15:not(#\9)
|
|
|
93
93
|
padding-block-start: var(--space-scaled-xs-xwoogq, 8px);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
.awsui_list-
|
|
96
|
+
.awsui_list-bottom_1kjc7_oede3_96:not(#\9) {
|
|
97
97
|
flex-wrap: wrap;
|
|
98
|
-
|
|
98
|
+
}
|
|
99
|
+
.awsui_list-bottom_1kjc7_oede3_96.awsui_list-bottom-start_1kjc7_oede3_99:not(#\9) {
|
|
100
|
+
justify-content: start;
|
|
101
|
+
}
|
|
102
|
+
.awsui_list-bottom_1kjc7_oede3_96.awsui_list-bottom-center_1kjc7_oede3_102:not(#\9) {
|
|
103
|
+
justify-content: center;
|
|
99
104
|
}
|
|
100
105
|
|
|
101
|
-
.awsui_list-
|
|
106
|
+
.awsui_list-side_1kjc7_oede3_106:not(#\9) {
|
|
102
107
|
flex-wrap: nowrap;
|
|
103
108
|
flex-direction: column;
|
|
104
109
|
}
|
|
105
110
|
|
|
106
|
-
.awsui_legend-
|
|
107
|
-
flex: 1;
|
|
111
|
+
.awsui_legend-bottom_1kjc7_oede3_111:not(#\9) {
|
|
108
112
|
display: flex;
|
|
109
113
|
flex-wrap: wrap;
|
|
110
114
|
flex-direction: row;
|
|
111
115
|
max-inline-size: 100%;
|
|
112
116
|
gap: var(--space-scaled-xxs-pfm1nx, 4px) var(--space-static-m-m6qboo, 16px);
|
|
113
117
|
}
|
|
118
|
+
.awsui_legend-bottom_1kjc7_oede3_111.awsui_legend-bottom-start_1kjc7_oede3_118:not(#\9) {
|
|
119
|
+
justify-content: start;
|
|
120
|
+
}
|
|
121
|
+
.awsui_legend-bottom_1kjc7_oede3_111.awsui_legend-bottom-center_1kjc7_oede3_121:not(#\9) {
|
|
122
|
+
justify-content: center;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.awsui_legend-title-start_1kjc7_oede3_125:not(#\9) {
|
|
126
|
+
text-align: start;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.awsui_legend-title-center_1kjc7_oede3_129:not(#\9) {
|
|
130
|
+
text-align: center;
|
|
131
|
+
}
|
|
114
132
|
|
|
115
|
-
.awsui_legend-
|
|
133
|
+
.awsui_legend-side_1kjc7_oede3_133:not(#\9) {
|
|
116
134
|
display: flex;
|
|
117
135
|
flex-wrap: wrap;
|
|
118
136
|
flex-direction: column;
|
|
119
137
|
gap: var(--space-scaled-xxs-pfm1nx, 4px) var(--space-static-m-m6qboo, 16px);
|
|
120
138
|
}
|
|
121
139
|
|
|
122
|
-
.
|
|
140
|
+
.awsui_item_1kjc7_oede3_27:not(#\9) {
|
|
123
141
|
border-collapse: separate;
|
|
124
142
|
border-spacing: 0;
|
|
125
143
|
box-sizing: border-box;
|
|
@@ -162,16 +180,16 @@ body[data-awsui-focus-visible=true] .awsui_focus-outline_1kjc7_ordh1_15:not(#\9)
|
|
|
162
180
|
opacity: 1;
|
|
163
181
|
max-inline-size: 100%;
|
|
164
182
|
}
|
|
165
|
-
.
|
|
183
|
+
.awsui_item_1kjc7_oede3_27:not(#\9):focus {
|
|
166
184
|
outline: none;
|
|
167
185
|
}
|
|
168
|
-
body[data-awsui-focus-visible=true] .
|
|
186
|
+
body[data-awsui-focus-visible=true] .awsui_item_1kjc7_oede3_27:not(#\9):focus {
|
|
169
187
|
position: relative;
|
|
170
188
|
box-sizing: border-box;
|
|
171
189
|
outline: 2px dotted transparent;
|
|
172
190
|
outline-offset: 1px;
|
|
173
191
|
}
|
|
174
|
-
body[data-awsui-focus-visible=true] .
|
|
192
|
+
body[data-awsui-focus-visible=true] .awsui_item_1kjc7_oede3_27:not(#\9):focus::before {
|
|
175
193
|
content: " ";
|
|
176
194
|
display: block;
|
|
177
195
|
position: absolute;
|
|
@@ -183,17 +201,17 @@ body[data-awsui-focus-visible=true] .awsui_item_1kjc7_ordh1_27:not(#\9):focus::b
|
|
|
183
201
|
border-radius: var(--border-radius-control-default-focus-ring-1uabki, 4px);
|
|
184
202
|
border: 2px solid var(--color-border-item-focused-uk47pl, #006ce0);
|
|
185
203
|
}
|
|
186
|
-
.
|
|
204
|
+
.awsui_item_1kjc7_oede3_27.awsui_item--inactive_1kjc7_oede3_204:not(#\9) {
|
|
187
205
|
color: var(--color-text-interactive-default-ugh9wp, #424650);
|
|
188
206
|
text-decoration: line-through;
|
|
189
207
|
text-decoration-thickness: 2px;
|
|
190
208
|
text-decoration-color: var(--color-text-interactive-default-ugh9wp, #424650);
|
|
191
209
|
}
|
|
192
|
-
.
|
|
210
|
+
.awsui_item_1kjc7_oede3_27.awsui_item--dimmed_1kjc7_oede3_210:not(#\9) {
|
|
193
211
|
opacity: 0.35;
|
|
194
212
|
}
|
|
195
213
|
|
|
196
|
-
.awsui_item-
|
|
214
|
+
.awsui_item-label_1kjc7_oede3_214:not(#\9) {
|
|
197
215
|
overflow: hidden;
|
|
198
216
|
white-space: nowrap;
|
|
199
217
|
text-overflow: ellipsis;
|
|
@@ -203,28 +221,28 @@ body[data-awsui-focus-visible=true] .awsui_item_1kjc7_ordh1_27:not(#\9):focus::b
|
|
|
203
221
|
-webkit-box-orient: vertical;
|
|
204
222
|
}
|
|
205
223
|
|
|
206
|
-
.
|
|
224
|
+
.awsui_actions_1kjc7_oede3_224:not(#\9) {
|
|
207
225
|
display: flex;
|
|
208
226
|
align-items: center;
|
|
209
227
|
}
|
|
210
228
|
|
|
211
|
-
.awsui_actions-
|
|
229
|
+
.awsui_actions-bottom_1kjc7_oede3_229:not(#\9) {
|
|
212
230
|
flex-direction: row;
|
|
213
231
|
}
|
|
214
232
|
|
|
215
|
-
.awsui_actions-
|
|
233
|
+
.awsui_actions-side_1kjc7_oede3_233:not(#\9) {
|
|
216
234
|
flex-direction: column;
|
|
217
235
|
align-items: flex-start;
|
|
218
236
|
}
|
|
219
237
|
|
|
220
|
-
.awsui_actions-divider-
|
|
238
|
+
.awsui_actions-divider-bottom_1kjc7_oede3_238:not(#\9) {
|
|
221
239
|
inline-size: 1px;
|
|
222
240
|
block-size: 80%;
|
|
223
241
|
margin-inline: var(--space-scaled-xs-xwoogq, 8px);
|
|
224
242
|
background: var(--color-border-divider-default-nr68jt, #c6c6cd);
|
|
225
243
|
}
|
|
226
244
|
|
|
227
|
-
.awsui_actions-divider-
|
|
245
|
+
.awsui_actions-divider-side_1kjc7_oede3_245:not(#\9) {
|
|
228
246
|
inline-size: 80%;
|
|
229
247
|
block-size: 1px;
|
|
230
248
|
margin-block-end: var(--space-scaled-xs-xwoogq, 8px);
|
|
@@ -2,22 +2,28 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"focus-outline": "awsui_focus-
|
|
6
|
-
"item": "
|
|
7
|
-
"root": "
|
|
8
|
-
"root-side": "awsui_root-
|
|
9
|
-
"list": "
|
|
10
|
-
"list-bottom": "awsui_list-
|
|
11
|
-
"list-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
5
|
+
"focus-outline": "awsui_focus-outline_1kjc7_oede3_15",
|
|
6
|
+
"item": "awsui_item_1kjc7_oede3_27",
|
|
7
|
+
"root": "awsui_root_1kjc7_oede3_41",
|
|
8
|
+
"root-side": "awsui_root-side_1kjc7_oede3_81",
|
|
9
|
+
"list": "awsui_list_1kjc7_oede3_86",
|
|
10
|
+
"list-bottom": "awsui_list-bottom_1kjc7_oede3_96",
|
|
11
|
+
"list-bottom-start": "awsui_list-bottom-start_1kjc7_oede3_99",
|
|
12
|
+
"list-bottom-center": "awsui_list-bottom-center_1kjc7_oede3_102",
|
|
13
|
+
"list-side": "awsui_list-side_1kjc7_oede3_106",
|
|
14
|
+
"legend-bottom": "awsui_legend-bottom_1kjc7_oede3_111",
|
|
15
|
+
"legend-bottom-start": "awsui_legend-bottom-start_1kjc7_oede3_118",
|
|
16
|
+
"legend-bottom-center": "awsui_legend-bottom-center_1kjc7_oede3_121",
|
|
17
|
+
"legend-title-start": "awsui_legend-title-start_1kjc7_oede3_125",
|
|
18
|
+
"legend-title-center": "awsui_legend-title-center_1kjc7_oede3_129",
|
|
19
|
+
"legend-side": "awsui_legend-side_1kjc7_oede3_133",
|
|
20
|
+
"item--inactive": "awsui_item--inactive_1kjc7_oede3_204",
|
|
21
|
+
"item--dimmed": "awsui_item--dimmed_1kjc7_oede3_210",
|
|
22
|
+
"item-label": "awsui_item-label_1kjc7_oede3_214",
|
|
23
|
+
"actions": "awsui_actions_1kjc7_oede3_224",
|
|
24
|
+
"actions-bottom": "awsui_actions-bottom_1kjc7_oede3_229",
|
|
25
|
+
"actions-side": "awsui_actions-side_1kjc7_oede3_233",
|
|
26
|
+
"actions-divider-bottom": "awsui_actions-divider-bottom_1kjc7_oede3_238",
|
|
27
|
+
"actions-divider-side": "awsui_actions-divider-side_1kjc7_oede3_245"
|
|
22
28
|
};
|
|
23
29
|
|
package/internal/environment.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export var PACKAGE_SOURCE = "chart-components";
|
|
2
|
-
export var PACKAGE_VERSION = "1.0.0 (
|
|
2
|
+
export var PACKAGE_VERSION = "1.0.0 (5a521628)";
|
|
3
3
|
export var THEME = "open-source-visual-refresh";
|
|
4
4
|
export var ALWAYS_VISUAL_REFRESH = true;
|
|
5
5
|
export var SYSTEM = "console";
|
package/internal/manifest.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { CoreLegendProps } from "../../core/interfaces";
|
|
2
|
-
export declare const CoreLegend: ({ items, title, actions, ariaLabel, alignment, onItemHighlight, onClearHighlight, onVisibleItemsChange, getLegendTooltipContent, }: CoreLegendProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
2
|
+
export declare const CoreLegend: ({ items, title, actions, ariaLabel, alignment, onItemHighlight, onClearHighlight, onVisibleItemsChange, getLegendTooltipContent, horizontalAlignment, }: CoreLegendProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { ChartLegend as ChartLegendComponent } from "../../internal/components/chart-legend";
|
|
3
3
|
import { fireNonCancelableEvent } from "../../internal/events";
|
|
4
|
-
export const CoreLegend = ({ items, title, actions, ariaLabel, alignment = "horizontal", onItemHighlight, onClearHighlight, onVisibleItemsChange, getLegendTooltipContent, }) => {
|
|
4
|
+
export const CoreLegend = ({ items, title, actions, ariaLabel, alignment = "horizontal", onItemHighlight, onClearHighlight, onVisibleItemsChange, getLegendTooltipContent, horizontalAlignment = "start", }) => {
|
|
5
5
|
const position = alignment === "horizontal" ? "bottom" : "side";
|
|
6
6
|
if (items.length === 0) {
|
|
7
7
|
return null;
|
|
8
8
|
}
|
|
9
|
-
return (_jsx(ChartLegendComponent, { items: items, actions: actions, legendTitle: title, position: position, ariaLabel: ariaLabel, getTooltipContent: (props) => { var _a; return (_a = getLegendTooltipContent === null || getLegendTooltipContent === void 0 ? void 0 : getLegendTooltipContent(props)) !== null && _a !== void 0 ? _a : null; }, onItemHighlightExit: () => fireNonCancelableEvent(onClearHighlight), onItemHighlightEnter: (item) => fireNonCancelableEvent(onItemHighlight, { item }), onItemVisibilityChange: (items) => fireNonCancelableEvent(onVisibleItemsChange, { items }) }));
|
|
9
|
+
return (_jsx(ChartLegendComponent, { items: items, actions: actions, legendTitle: title, position: position, horizontalAlignment: horizontalAlignment, ariaLabel: ariaLabel, getTooltipContent: (props) => { var _a; return (_a = getLegendTooltipContent === null || getLegendTooltipContent === void 0 ? void 0 : getLegendTooltipContent(props)) !== null && _a !== void 0 ? _a : null; }, onItemHighlightExit: () => fireNonCancelableEvent(onClearHighlight), onItemHighlightEnter: (item) => fireNonCancelableEvent(onItemHighlight, { item }), onItemVisibilityChange: (items) => fireNonCancelableEvent(onVisibleItemsChange, { items }) }));
|
|
10
10
|
};
|
|
11
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/internal-do-not-use/core-legend/index.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,WAAW,IAAI,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC7F,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EACzB,KAAK,EACL,KAAK,EACL,OAAO,EACP,SAAS,EACT,SAAS,GAAG,YAAY,EACxB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/internal-do-not-use/core-legend/index.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,WAAW,IAAI,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC7F,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EACzB,KAAK,EACL,KAAK,EACL,OAAO,EACP,SAAS,EACT,SAAS,GAAG,YAAY,EACxB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,GAAG,OAAO,GACb,EAAE,EAAE;IACpB,MAAM,QAAQ,GAAG,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;IAEhE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACtB,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,KAAC,oBAAoB,IACnB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,KAAK,EAClB,QAAQ,EAAE,QAAQ,EAClB,mBAAmB,EAAE,mBAAmB,EACxC,SAAS,EAAE,SAAS,EACpB,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,WAAC,OAAA,MAAA,uBAAuB,aAAvB,uBAAuB,uBAAvB,uBAAuB,CAAG,KAAK,CAAC,mCAAI,IAAI,CAAA,EAAA,EACtE,mBAAmB,EAAE,GAAG,EAAE,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,EACnE,oBAAoB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,sBAAsB,CAAC,eAAe,EAAE,EAAE,IAAI,EAAE,CAAC,EACjF,sBAAsB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,sBAAsB,CAAC,oBAAoB,EAAE,EAAE,KAAK,EAAE,CAAC,GAC1F,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { CoreLegendProps } from \"../../core/interfaces\";\nimport { ChartLegend as ChartLegendComponent } from \"../../internal/components/chart-legend\";\nimport { fireNonCancelableEvent } from \"../../internal/events\";\n\nexport const CoreLegend = ({\n items,\n title,\n actions,\n ariaLabel,\n alignment = \"horizontal\",\n onItemHighlight,\n onClearHighlight,\n onVisibleItemsChange,\n getLegendTooltipContent,\n horizontalAlignment = \"start\",\n}: CoreLegendProps) => {\n const position = alignment === \"horizontal\" ? \"bottom\" : \"side\";\n\n if (items.length === 0) {\n return null;\n }\n\n return (\n <ChartLegendComponent\n items={items}\n actions={actions}\n legendTitle={title}\n position={position}\n horizontalAlignment={horizontalAlignment}\n ariaLabel={ariaLabel}\n getTooltipContent={(props) => getLegendTooltipContent?.(props) ?? null}\n onItemHighlightExit={() => fireNonCancelableEvent(onClearHighlight)}\n onItemHighlightEnter={(item) => fireNonCancelableEvent(onItemHighlight, { item })}\n onItemVisibilityChange={(items) => fireNonCancelableEvent(onVisibleItemsChange, { items })}\n />\n );\n};\n"]}
|