@cloudscape-design/components 3.0.622 → 3.0.623

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.
Files changed (53) hide show
  1. package/area-chart/chart-container.js +11 -11
  2. package/area-chart/chart-container.js.map +1 -1
  3. package/area-chart/internal.d.ts.map +1 -1
  4. package/area-chart/internal.js +3 -0
  5. package/area-chart/internal.js.map +1 -1
  6. package/area-chart/model/compute-chart-props.d.ts +4 -3
  7. package/area-chart/model/compute-chart-props.d.ts.map +1 -1
  8. package/area-chart/model/compute-chart-props.js +5 -2
  9. package/area-chart/model/compute-chart-props.js.map +1 -1
  10. package/area-chart/model/index.d.ts +1 -1
  11. package/area-chart/model/index.d.ts.map +1 -1
  12. package/area-chart/model/index.js.map +1 -1
  13. package/area-chart/model/use-chart-model.d.ts +2 -1
  14. package/area-chart/model/use-chart-model.d.ts.map +1 -1
  15. package/area-chart/model/use-chart-model.js +23 -14
  16. package/area-chart/model/use-chart-model.js.map +1 -1
  17. package/container/use-sticky-header.js +1 -1
  18. package/container/use-sticky-header.js.map +1 -1
  19. package/internal/components/cartesian-chart/{bottom-labels.d.ts → block-end-labels.d.ts} +5 -5
  20. package/internal/components/cartesian-chart/block-end-labels.d.ts.map +1 -0
  21. package/internal/components/cartesian-chart/{bottom-labels.js → block-end-labels.js} +5 -5
  22. package/internal/components/cartesian-chart/block-end-labels.js.map +1 -0
  23. package/internal/components/cartesian-chart/{left-labels.d.ts → inline-start-labels.d.ts} +4 -4
  24. package/internal/components/cartesian-chart/inline-start-labels.d.ts.map +1 -0
  25. package/internal/components/cartesian-chart/{left-labels.js → inline-start-labels.js} +9 -6
  26. package/internal/components/cartesian-chart/inline-start-labels.js.map +1 -0
  27. package/internal/components/cartesian-chart/labels-measure.js +2 -2
  28. package/internal/components/cartesian-chart/labels-measure.js.map +1 -1
  29. package/internal/components/cartesian-chart/styles.css.js +27 -27
  30. package/internal/components/cartesian-chart/styles.scoped.css +31 -31
  31. package/internal/components/cartesian-chart/styles.selectors.js +27 -27
  32. package/internal/components/chart-legend/index.d.ts.map +1 -1
  33. package/internal/components/chart-legend/index.js +7 -10
  34. package/internal/components/chart-legend/index.js.map +1 -1
  35. package/internal/environment.js +1 -1
  36. package/internal/environment.json +1 -1
  37. package/internal/generated/theming/index.cjs +4 -0
  38. package/internal/generated/theming/index.cjs.d.ts +16 -0
  39. package/internal/generated/theming/index.d.ts +16 -0
  40. package/internal/generated/theming/index.js +4 -0
  41. package/internal/manifest.json +1 -1
  42. package/internal/utils/handle-key.d.ts +1 -1
  43. package/internal/utils/handle-key.d.ts.map +1 -1
  44. package/internal/utils/handle-key.js +1 -1
  45. package/internal/utils/handle-key.js.map +1 -1
  46. package/mixed-line-bar-chart/chart-container.d.ts.map +1 -1
  47. package/mixed-line-bar-chart/chart-container.js +12 -12
  48. package/mixed-line-bar-chart/chart-container.js.map +1 -1
  49. package/package.json +1 -1
  50. package/internal/components/cartesian-chart/bottom-labels.d.ts.map +0 -1
  51. package/internal/components/cartesian-chart/bottom-labels.js.map +0 -1
  52. package/internal/components/cartesian-chart/left-labels.d.ts.map +0 -1
  53. package/internal/components/cartesian-chart/left-labels.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"use-sticky-header.js","sourceRoot":"","sources":["../../../src/container/use-sticky-header.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAa,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACpG,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,UAAU,MAAM,gCAAgC,CAAC;AAaxD,MAAM,UAAU,aAAa,CAAC,EAC5B,QAAQ,EACR,cAAc,EAC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CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;YACtD,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YAChD,OAAO,GAAG,EAAE;gBACV,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;gBACzD,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YACrD,CAAC,CAAC;SACH;IACH,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;IAC7B,OAAO;QACL,QAAQ;QACR,OAAO;QACP,YAAY;KACb,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { RefObject, useState, useLayoutEffect, useCallback, useEffect, createContext } from 'react';\nimport { findUpUntil, supportsStickyPosition } from '../internal/utils/dom';\nimport { getOverflowParents } from '../internal/utils/scrollable-containers';\nimport { useMobile } from '../internal/hooks/use-mobile';\nimport globalVars from '../internal/styles/global-vars';\n\ninterface StickyHeaderContextProps {\n isStuck: boolean;\n}\n\ninterface ComputeOffsetProps {\n isMobile: boolean;\n __stickyOffset?: number;\n __mobileStickyOffset?: number;\n hasInnerOverflowParents: boolean;\n}\n\nexport function computeOffset({\n isMobile,\n __stickyOffset,\n __mobileStickyOffset,\n hasInnerOverflowParents,\n}: ComputeOffsetProps): string {\n const localOffset = isMobile ? (__stickyOffset ?? 0) - (__mobileStickyOffset ?? 0) : __stickyOffset ?? 0;\n if (hasInnerOverflowParents) {\n return `${localOffset}px`;\n }\n const globalOffset = `var(${globalVars.stickyVerticalTopOffset}, 0px)`;\n\n return `calc(${globalOffset} + ${localOffset}px)`;\n}\n\nexport const StickyHeaderContext = createContext<StickyHeaderContextProps>({\n isStuck: false,\n});\n\nexport const useStickyHeader = (\n rootRef: RefObject<HTMLDivElement>,\n headerRef: RefObject<HTMLDivElement>,\n __stickyHeader?: boolean,\n __stickyOffset?: number,\n __mobileStickyOffset?: number,\n __disableMobile = true\n) => {\n const isMobile = useMobile();\n const disableSticky = isMobile && __disableMobile;\n const isSticky = supportsStickyPosition() && !disableSticky && !!__stickyHeader;\n\n // If it has overflow parents inside the app layout, we shouldn't apply a sticky offset.\n const [hasInnerOverflowParents, setHasInnerOverflowParents] = useState(false);\n const [isStuck, setIsStuck] = useState(false);\n useLayoutEffect(() => {\n if (rootRef.current) {\n const overflowParents = getOverflowParents(rootRef.current);\n const mainElement = findUpUntil(rootRef.current, elem => elem.tagName === 'MAIN');\n // In both versions of the app layout, the scrolling element for disableBodyScroll\n // is the <main>. If the closest overflow parent is also the closest <main> and we have\n // offset values, it's safe to assume that it's the app layout scroll root and we\n // should stop there.\n setHasInnerOverflowParents(overflowParents.length > 0 && overflowParents[0] !== mainElement);\n }\n }, [rootRef]);\n\n const computedOffset = computeOffset({\n isMobile,\n __stickyOffset,\n __mobileStickyOffset,\n hasInnerOverflowParents,\n });\n\n const stickyStyles = isSticky\n ? {\n style: {\n top: computedOffset,\n },\n }\n : {};\n\n // \"stuck\" state, when the header has moved from its original posititon has a\n // box-shadow, applied here by a \"header-stuck\" className\n const checkIfStuck = useCallback(() => {\n if (rootRef.current && headerRef.current) {\n const rootTopBorderWidth = parseFloat(getComputedStyle(rootRef.current).borderTopWidth) || 0;\n const rootTop = rootRef.current.getBoundingClientRect().top + rootTopBorderWidth;\n const headerTop = headerRef.current.getBoundingClientRect().top;\n\n if (rootTop < headerTop) {\n setIsStuck(true);\n } else {\n setIsStuck(false);\n }\n }\n }, [rootRef, headerRef]);\n useEffect(() => {\n if (isSticky) {\n window.addEventListener('scroll', checkIfStuck, true);\n window.addEventListener('resize', checkIfStuck);\n return () => {\n window.removeEventListener('scroll', checkIfStuck, true);\n window.removeEventListener('resize', checkIfStuck);\n };\n }\n }, [isSticky, checkIfStuck]);\n return {\n isSticky,\n isStuck,\n stickySt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CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YAC7F,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC,GAAG,GAAG,kBAAkB,CAAC;YACjF,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC,GAAG,CAAC;YAEhE,IAAI,OAAO,GAAG,SAAS,EAAE;gBACvB,UAAU,CAAC,IAAI,CAAC,CAAC;aAClB;iBAAM;gBACL,UAAU,CAAC,KAAK,CAAC,CAAC;aACnB;SACF;IACH,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;IACzB,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,QAAQ,EAAE;YACZ,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;YACtD,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YAChD,OAAO,GAAG,EAAE;gBACV,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;gBACzD,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YACrD,CAAC,CAAC;SACH;IACH,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;IAC7B,OAAO;QACL,QAAQ;QACR,OAAO;QACP,YAAY;KACb,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { RefObject, useState, useLayoutEffect, useCallback, useEffect, createContext } from 'react';\nimport { findUpUntil, supportsStickyPosition } from '../internal/utils/dom';\nimport { getOverflowParents } from '../internal/utils/scrollable-containers';\nimport { useMobile } from '../internal/hooks/use-mobile';\nimport globalVars from '../internal/styles/global-vars';\n\ninterface StickyHeaderContextProps {\n isStuck: boolean;\n}\n\ninterface ComputeOffsetProps {\n isMobile: boolean;\n __stickyOffset?: number;\n __mobileStickyOffset?: number;\n hasInnerOverflowParents: boolean;\n}\n\nexport function computeOffset({\n isMobile,\n __stickyOffset,\n __mobileStickyOffset,\n hasInnerOverflowParents,\n}: ComputeOffsetProps): string {\n const localOffset = isMobile ? (__stickyOffset ?? 0) - (__mobileStickyOffset ?? 0) : __stickyOffset ?? 0;\n if (hasInnerOverflowParents || __stickyOffset !== undefined) {\n return `${localOffset}px`;\n }\n const globalOffset = `var(${globalVars.stickyVerticalTopOffset}, 0px)`;\n\n return `calc(${globalOffset} + ${localOffset}px)`;\n}\n\nexport const StickyHeaderContext = createContext<StickyHeaderContextProps>({\n isStuck: false,\n});\n\nexport const useStickyHeader = (\n rootRef: RefObject<HTMLDivElement>,\n headerRef: RefObject<HTMLDivElement>,\n __stickyHeader?: boolean,\n __stickyOffset?: number,\n __mobileStickyOffset?: number,\n __disableMobile = true\n) => {\n const isMobile = useMobile();\n const disableSticky = isMobile && __disableMobile;\n const isSticky = supportsStickyPosition() && !disableSticky && !!__stickyHeader;\n\n // If it has overflow parents inside the app layout, we shouldn't apply a sticky offset.\n const [hasInnerOverflowParents, setHasInnerOverflowParents] = useState(false);\n const [isStuck, setIsStuck] = useState(false);\n useLayoutEffect(() => {\n if (rootRef.current) {\n const overflowParents = getOverflowParents(rootRef.current);\n const mainElement = findUpUntil(rootRef.current, elem => elem.tagName === 'MAIN');\n // In both versions of the app layout, the scrolling element for disableBodyScroll\n // is the <main>. If the closest overflow parent is also the closest <main> and we have\n // offset values, it's safe to assume that it's the app layout scroll root and we\n // should stop there.\n setHasInnerOverflowParents(overflowParents.length > 0 && overflowParents[0] !== mainElement);\n }\n }, [rootRef]);\n\n const computedOffset = computeOffset({\n isMobile,\n __stickyOffset,\n __mobileStickyOffset,\n hasInnerOverflowParents,\n });\n\n const stickyStyles = isSticky\n ? {\n style: {\n top: computedOffset,\n },\n }\n : {};\n\n // \"stuck\" state, when the header has moved from its original posititon has a\n // box-shadow, applied here by a \"header-stuck\" className\n const checkIfStuck = useCallback(() => {\n if (rootRef.current && headerRef.current) {\n const rootTopBorderWidth = parseFloat(getComputedStyle(rootRef.current).borderTopWidth) || 0;\n const rootTop = rootRef.current.getBoundingClientRect().top + rootTopBorderWidth;\n const headerTop = headerRef.current.getBoundingClientRect().top;\n\n if (rootTop < headerTop) {\n setIsStuck(true);\n } else {\n setIsStuck(false);\n }\n }\n }, [rootRef, headerRef]);\n useEffect(() => {\n if (isSticky) {\n window.addEventListener('scroll', checkIfStuck, true);\n window.addEventListener('resize', checkIfStuck);\n return () => {\n window.removeEventListener('scroll', checkIfStuck, true);\n window.removeEventListener('resize', checkIfStuck);\n };\n }\n }, [isSticky, checkIfStuck]);\n return {\n isSticky,\n isStuck,\n stickyStyles,\n };\n};\n"]}
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { ChartDataTypes } from './interfaces';
3
3
  import { ChartScale, NumericChartScale } from './scales';
4
4
  import { FormattedTick } from './label-utils';
5
- interface BottomLabelsProps {
5
+ interface BlockEndLabelsProps {
6
6
  axis?: 'x' | 'y';
7
7
  width: number;
8
8
  height: number;
@@ -14,7 +14,7 @@ interface BottomLabelsProps {
14
14
  virtualTextRef: React.Ref<SVGTextElement>;
15
15
  formattedTicks: readonly FormattedTick[];
16
16
  }
17
- export declare function useBottomLabels({ ticks, scale, tickFormatter, }: {
17
+ export declare function useBLockEndLabels({ ticks, scale, tickFormatter, }: {
18
18
  scale: ChartScale | NumericChartScale;
19
19
  ticks: readonly ChartDataTypes[];
20
20
  tickFormatter?: (value: ChartDataTypes) => string;
@@ -23,7 +23,7 @@ export declare function useBottomLabels({ ticks, scale, tickFormatter, }: {
23
23
  formattedTicks: FormattedTick[];
24
24
  height: number;
25
25
  };
26
- declare const _default: typeof BottomLabels;
26
+ declare const _default: typeof BlockEndLabels;
27
27
  export default _default;
28
- declare function BottomLabels({ axis, width, height, scale, title, ariaRoleDescription, offsetLeft, offsetRight, virtualTextRef, formattedTicks, }: BottomLabelsProps): JSX.Element;
29
- //# sourceMappingURL=bottom-labels.d.ts.map
28
+ declare function BlockEndLabels({ axis, width, height, scale, title, ariaRoleDescription, offsetLeft, offsetRight, virtualTextRef, formattedTicks, }: BlockEndLabelsProps): JSX.Element;
29
+ //# sourceMappingURL=block-end-labels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-end-labels.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/cartesian-chart/block-end-labels.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAuB,MAAM,OAAO,CAAC;AAG5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAIzD,OAAO,EAAgC,aAAa,EAAE,MAAM,eAAe,CAAC;AAG5E,UAAU,mBAAmB;IAC3B,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,UAAU,GAAG,iBAAiB,CAAC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAC1C,cAAc,EAAE,SAAS,aAAa,EAAE,CAAC;CAC1C;AAED,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,KAAK,EACL,aAAa,GACd,EAAE;IACD,KAAK,EAAE,UAAU,GAAG,iBAAiB,CAAC;IACtC,KAAK,EAAE,SAAS,cAAc,EAAE,CAAC;IACjC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,MAAM,CAAC;CACnD;;;;EA4BA;;AAED,wBAA6D;AAG7D,iBAAS,cAAc,CAAC,EACtB,IAAU,EACV,KAAK,EACL,MAAM,EACN,KAAK,EACL,KAAK,EACL,mBAAmB,EACnB,UAAc,EACd,WAAe,EACf,cAAc,EACd,cAAc,GACf,EAAE,mBAAmB,eAkDrB"}
@@ -6,7 +6,7 @@ import { TICK_LENGTH, TICK_LINE_HEIGHT, TICK_MARGIN } from './constants';
6
6
  import styles from './styles.css.js';
7
7
  import { formatTicks, getVisibleTicks } from './label-utils';
8
8
  import { useInternalI18n } from '../../../i18n/context';
9
- export function useBottomLabels({ ticks, scale, tickFormatter, }) {
9
+ export function useBLockEndLabels({ ticks, scale, tickFormatter, }) {
10
10
  const virtualTextRef = useRef(null);
11
11
  const cacheRef = useRef({});
12
12
  const getLabelSpace = (label) => {
@@ -30,16 +30,16 @@ export function useBottomLabels({ ticks, scale, tickFormatter, }) {
30
30
  }
31
31
  return { virtualTextRef, formattedTicks, height };
32
32
  }
33
- export default memo(BottomLabels);
33
+ export default memo(BlockEndLabels);
34
34
  // Renders the visible tick labels on the bottom axis, as well as their grid lines.
35
- function BottomLabels({ axis = 'x', width, height, scale, title, ariaRoleDescription, offsetLeft = 0, offsetRight = 0, virtualTextRef, formattedTicks, }) {
35
+ function BlockEndLabels({ axis = 'x', width, height, scale, title, ariaRoleDescription, offsetLeft = 0, offsetRight = 0, virtualTextRef, formattedTicks, }) {
36
36
  const i18n = useInternalI18n('[charts]');
37
37
  const xOffset = scale.isCategorical() && axis === 'x' ? Math.max(0, scale.d3Scale.bandwidth() - 1) / 2 : 0;
38
38
  const from = 0 - offsetLeft - xOffset;
39
39
  const until = width + offsetRight - xOffset;
40
40
  const balanceLabels = axis === 'x' && scale.scaleType !== 'log';
41
41
  const visibleTicks = getVisibleTicks(formattedTicks, from, until, balanceLabels);
42
- return (React.createElement("g", { transform: `translate(0,${height})`, className: styles['labels-bottom'], "aria-label": title, role: "list", "aria-roledescription": i18n('i18nStrings.chartAriaRoleDescription', ariaRoleDescription), "aria-hidden": true },
42
+ return (React.createElement("g", { transform: `translate(0,${height})`, className: styles['labels-block-end'], "aria-label": title, role: "list", "aria-roledescription": i18n('i18nStrings.chartAriaRoleDescription', ariaRoleDescription), "aria-hidden": true },
43
43
  visibleTicks.map(({ position, lines }, index) => isFinite(position) && (React.createElement("g", { key: index, transform: `translate(${position + xOffset},0)`, className: clsx(styles.ticks, styles['ticks--bottom'], {
44
44
  [styles['ticks--x']]: axis === 'x',
45
45
  [styles['ticks--y']]: axis === 'y',
@@ -48,4 +48,4 @@ function BottomLabels({ axis = 'x', width, height, scale, title, ariaRoleDescrip
48
48
  lines.map((line, lineIndex) => (React.createElement("text", { className: styles.ticks__text, key: lineIndex, x: 0, y: TICK_LENGTH + TICK_MARGIN + lineIndex * TICK_LINE_HEIGHT }, line)))))),
49
49
  React.createElement("text", { ref: virtualTextRef, x: 0, y: 0, style: { visibility: 'hidden' }, "aria-hidden": "true" })));
50
50
  }
51
- //# sourceMappingURL=bottom-labels.js.map
51
+ //# sourceMappingURL=block-end-labels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-end-labels.js","sourceRoot":"","sources":["../../../../../src/internal/components/cartesian-chart/block-end-labels.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEzE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAiB,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAexD,MAAM,UAAU,iBAAiB,CAAC,EAChC,KAAK,EACL,KAAK,EACL,aAAa,GAKd;IACC,MAAM,cAAc,GA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AAC,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,KAAK,GAAG;gBAClC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,KAAK,GAAG;aACnC,CAAC,EACF,IAAI,EAAC,UAAU,gBACH,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YAE5B,8BAAM,SAAS,EAAE,MAAM,CAAC,WAAW,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,WAAW,iBAAc,MAAM,GAAG;YAC/F,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,CAC9B,8BACE,SAAS,EAAE,MAAM,CAAC,WAAW,EAC7B,GAAG,EAAE,SAAS,EACd,CAAC,EAAE,CAAC,EACJ,CAAC,EAAE,WAAW,GAAG,WAAW,GAAG,SAAS,GAAG,gBAAgB,IAE1D,IAAI,CACA,CACR,CAAC,CACA,CACL,CACJ;QAED,8BAAM,GAAG,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,iBAAc,MAAM,GAAQ,CAChG,CACL,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { memo, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { ChartDataTypes } from './interfaces';\nimport { ChartScale, NumericChartScale } from './scales';\nimport { TICK_LENGTH, TICK_LINE_HEIGHT, TICK_MARGIN } from './constants';\n\nimport styles from './styles.css.js';\nimport { formatTicks, getVisibleTicks, FormattedTick } from './label-utils';\nimport { useInternalI18n } from '../../../i18n/context';\n\ninterface BlockEndLabelsProps {\n axis?: 'x' | 'y';\n width: number;\n height: number;\n scale: ChartScale | NumericChartScale;\n title?: string;\n ariaRoleDescription?: string;\n offsetLeft?: number;\n offsetRight?: number;\n virtualTextRef: React.Ref<SVGTextElement>;\n formattedTicks: readonly FormattedTick[];\n}\n\nexport function useBLockEndLabels({\n ticks,\n scale,\n tickFormatter,\n}: {\n scale: ChartScale | NumericChartScale;\n ticks: readonly ChartDataTypes[];\n tickFormatter?: (value: ChartDataTypes) => string;\n}) {\n const virtualTextRef = useRef<SVGTextElement>(null);\n\n const cacheRef = useRef<{ [label: string]: number }>({});\n const getLabelSpace = (label: string) => {\n if (cacheRef.current[label] !== undefined && cacheRef.current[label] !== 0) {\n return cacheRef.current[label];\n }\n if (virtualTextRef.current && virtualTextRef.current.getComputedTextLength) {\n virtualTextRef.current.textContent = label;\n cacheRef.current[label] = virtualTextRef.current.getComputedTextLength();\n return cacheRef.current[label];\n }\n return 0;\n };\n\n const formattedTicks = formatTicks({ ticks, scale, getLabelSpace, tickFormatter });\n\n if (virtualTextRef.current) {\n virtualTextRef.current.textContent = '';\n }\n\n let height = TICK_LENGTH + TICK_MARGIN;\n for (const { lines } of formattedTicks) {\n height = Math.max(height, TICK_LENGTH + TICK_MARGIN + lines.length * TICK_LINE_HEIGHT);\n }\n\n return { virtualTextRef, formattedTicks, height };\n}\n\nexport default memo(BlockEndLabels) as typeof BlockEndLabels;\n\n// Renders the visible tick labels on the bottom axis, as well as their grid lines.\nfunction BlockEndLabels({\n axis = 'x',\n width,\n height,\n scale,\n title,\n ariaRoleDescription,\n offsetLeft = 0,\n offsetRight = 0,\n virtualTextRef,\n formattedTicks,\n}: BlockEndLabelsProps) {\n const i18n = useInternalI18n('[charts]');\n\n const xOffset = scale.isCategorical() && axis === 'x' ? Math.max(0, scale.d3Scale.bandwidth() - 1) / 2 : 0;\n\n const from = 0 - offsetLeft - xOffset;\n const until = width + offsetRight - xOffset;\n const balanceLabels = axis === 'x' && scale.scaleType !== 'log';\n const visibleTicks = getVisibleTicks(formattedTicks, from, until, balanceLabels);\n\n return (\n <g\n transform={`translate(0,${height})`}\n className={styles['labels-block-end']}\n aria-label={title}\n role=\"list\"\n aria-roledescription={i18n('i18nStrings.chartAriaRoleDescription', ariaRoleDescription)}\n aria-hidden={true}\n >\n {visibleTicks.map(\n ({ position, lines }, index) =>\n isFinite(position) && (\n <g\n key={index}\n transform={`translate(${position + xOffset},0)`}\n className={clsx(styles.ticks, styles['ticks--bottom'], {\n [styles['ticks--x']]: axis === 'x',\n [styles['ticks--y']]: axis === 'y',\n })}\n role=\"listitem\"\n aria-label={lines.join('\\n')}\n >\n <line className={styles.ticks__line} x1={0} x2={0} y1={0} y2={TICK_LENGTH} aria-hidden=\"true\" />\n {lines.map((line, lineIndex) => (\n <text\n className={styles.ticks__text}\n key={lineIndex}\n x={0}\n y={TICK_LENGTH + TICK_MARGIN + lineIndex * TICK_LINE_HEIGHT}\n >\n {line}\n </text>\n ))}\n </g>\n )\n )}\n\n <text ref={virtualTextRef} x={0} y={0} style={{ visibility: 'hidden' }} aria-hidden=\"true\"></text>\n </g>\n );\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { ChartScale, NumericChartScale } from './scales';
3
3
  import { ChartDataTypes } from '../../../mixed-line-bar-chart/interfaces';
4
- interface LeftLabelsProps {
4
+ interface InlineStartLabelsProps {
5
5
  axis?: 'x' | 'y';
6
6
  plotWidth: number;
7
7
  plotHeight: number;
@@ -12,7 +12,7 @@ interface LeftLabelsProps {
12
12
  title?: string;
13
13
  ariaRoleDescription?: string;
14
14
  }
15
- declare const _default: typeof LeftLabels;
15
+ declare const _default: typeof InlineStartLabels;
16
16
  export default _default;
17
- declare function LeftLabels({ axis, plotWidth, plotHeight, maxLabelsWidth, scale, ticks, tickFormatter, title, ariaRoleDescription, }: LeftLabelsProps): JSX.Element;
18
- //# sourceMappingURL=left-labels.d.ts.map
17
+ declare function InlineStartLabels({ axis, plotWidth, plotHeight, maxLabelsWidth, scale, ticks, tickFormatter, title, ariaRoleDescription, }: InlineStartLabelsProps): JSX.Element;
18
+ //# sourceMappingURL=inline-start-labels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline-start-labels.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/cartesian-chart/inline-start-labels.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAKzD,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAO1E,UAAU,sBAAsB;IAC9B,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,UAAU,GAAG,iBAAiB,CAAC;IACtC,KAAK,EAAE,SAAS,cAAc,EAAE,CAAC;IACjC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;;AAED,wBAAmE;AAGnE,iBAAS,iBAAiB,CAAC,EACzB,IAAU,EACV,SAAS,EACT,UAAU,EACV,cAAyC,EACzC,KAAK,EACL,KAAK,EACL,aAAa,EACb,KAAK,EACL,mBAAmB,GACpB,EAAE,sBAAsB,eA+ExB"}
@@ -7,10 +7,11 @@ import styles from './styles.css.js';
7
7
  import { formatTicks, getSVGTextSize, getVisibleTicks } from './label-utils';
8
8
  import { useInternalI18n } from '../../../i18n/context';
9
9
  import ResponsiveText from '../responsive-text';
10
+ import { getIsRtl } from '../../direction';
10
11
  const OFFSET_PX = 12;
11
- export default memo(LeftLabels);
12
- // Renders the visible tick labels on the left axis, as well as their grid lines.
13
- function LeftLabels({ axis = 'y', plotWidth, plotHeight, maxLabelsWidth = Number.POSITIVE_INFINITY, scale, ticks, tickFormatter, title, ariaRoleDescription, }) {
12
+ export default memo(InlineStartLabels);
13
+ // Renders the visible tick labels on the value axis, as well as their grid lines.
14
+ function InlineStartLabels({ axis = 'y', plotWidth, plotHeight, maxLabelsWidth = Number.POSITIVE_INFINITY, scale, ticks, tickFormatter, title, ariaRoleDescription, }) {
14
15
  const i18n = useInternalI18n('[charts]');
15
16
  const virtualTextRef = useRef(null);
16
17
  const yOffset = axis === 'x' && scale.isCategorical() ? Math.max(0, scale.d3Scale.bandwidth() - 1) / 2 : 0;
@@ -33,13 +34,15 @@ function LeftLabels({ axis = 'y', plotWidth, plotHeight, maxLabelsWidth = Number
33
34
  const from = 0 - OFFSET_PX - yOffset;
34
35
  const until = plotHeight + OFFSET_PX - yOffset;
35
36
  const visibleTicks = getVisibleTicks(formattedTicks, from, until);
36
- return (React.createElement("g", { className: clsx(styles['labels-left']), "aria-label": title, role: "list", "aria-roledescription": i18n('i18nStrings.chartAriaRoleDescription', ariaRoleDescription), "aria-hidden": true },
37
+ const isRtl = virtualTextRef.current ? getIsRtl(virtualTextRef.current) : false;
38
+ return (React.createElement("g", { className: clsx(styles['labels-inline-start']), "aria-label": title, role: "list", "aria-roledescription": i18n('i18nStrings.chartAriaRoleDescription', ariaRoleDescription), "aria-hidden": true },
37
39
  visibleTicks.map(({ position, lines }, index) => isFinite(position) && (React.createElement("g", { key: index, role: "listitem", transform: `translate(0,${position + yOffset})`, className: clsx(styles.ticks, axis === 'x' ? styles['ticks--x'] : styles['ticks--y']) },
38
40
  axis === 'y' && (React.createElement("line", { className: clsx(styles.grid, styles.ticks_line), x1: -TICK_LENGTH, y1: 0, x2: plotWidth, y2: 0, "aria-hidden": "true" })),
39
41
  lines.map((line, lineIndex) => {
40
42
  var _a, _b;
43
+ const x = -(TICK_LENGTH + TICK_MARGIN);
41
44
  const lineTextProps = {
42
- x: -(TICK_LENGTH + TICK_MARGIN),
45
+ x: !isRtl ? x : plotWidth - x,
43
46
  y: (lineIndex - (lines.length - 1) * 0.5) * TICK_LINE_HEIGHT,
44
47
  className: styles.ticks__text,
45
48
  children: line,
@@ -48,4 +51,4 @@ function LeftLabels({ axis = 'y', plotWidth, plotHeight, maxLabelsWidth = Number
48
51
  })))),
49
52
  React.createElement("text", { ref: virtualTextRef, x: 0, y: 0, style: { visibility: 'hidden' }, "aria-hidden": "true" })));
50
53
  }
51
- //# sourceMappingURL=left-labels.js.map
54
+ //# sourceMappingURL=inline-start-labels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline-start-labels.js","sourceRoot":"","sources":["../../../../../src/internal/components/cartesian-chart/inline-start-labels.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEzE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,MAAM,SAAS,GAAG,EAAE,CAAC;AAcrB,eAAe,IAAI,CAAC,iBAAiB,CAA6B,CAAC;AAEnE,kFAAkF;AAClF,SAAS,iBAAiB,CAAC,EACzB,IAAI,GAAG,GAAG,EACV,SAAS,EACT,UAAU,EACV,cAAc,GAAG,MAAM,CAAC,iBAAiB,EACzC,KAAK,EACL,KAAK,EACL,aAAa,EACb,KAAK,EACL,mBAAmB,GACI;IACvB,MAAM,IAAI,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;IACzC,MAAM,cAAc,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAEpD,MAAM,OAAO,GAAG,IAAI,KAAK,GAAG,IAAI,KAAK,CAAC,aAAa,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AAW;oBAC7B,QAAQ,EAAE,IAAI;iBACf,CAAC;gBACF,OAAO,CAAC,MAAA,MAAA,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,0CAAE,KAAK,mCAAI,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CACxE,oBAAC,cAAc,kBAAC,GAAG,EAAE,SAAS,IAAM,aAAa,IAAE,QAAQ,EAAE,cAAc,IAAI,CAChF,CAAC,CAAC,CAAC,CACF,4CAAM,GAAG,EAAE,SAAS,IAAM,aAAa,EAAI,CAC5C,CAAC;YACJ,CAAC,CAAC,CACA,CACL,CACJ;QAED,8BAAM,GAAG,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,iBAAc,MAAM,GAAQ,CAChG,CACL,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { memo, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { ChartScale, NumericChartScale } from './scales';\nimport { TICK_LENGTH, TICK_LINE_HEIGHT, TICK_MARGIN } from './constants';\n\nimport styles from './styles.css.js';\nimport { formatTicks, getSVGTextSize, getVisibleTicks } from './label-utils';\nimport { ChartDataTypes } from '../../../mixed-line-bar-chart/interfaces';\nimport { useInternalI18n } from '../../../i18n/context';\nimport ResponsiveText from '../responsive-text';\nimport { getIsRtl } from '../../direction';\n\nconst OFFSET_PX = 12;\n\ninterface InlineStartLabelsProps {\n axis?: 'x' | 'y';\n plotWidth: number;\n plotHeight: number;\n maxLabelsWidth?: number;\n scale: ChartScale | NumericChartScale;\n ticks: readonly ChartDataTypes[];\n tickFormatter?: (value: number) => string;\n title?: string;\n ariaRoleDescription?: string;\n}\n\nexport default memo(InlineStartLabels) as typeof InlineStartLabels;\n\n// Renders the visible tick labels on the value axis, as well as their grid lines.\nfunction InlineStartLabels({\n axis = 'y',\n plotWidth,\n plotHeight,\n maxLabelsWidth = Number.POSITIVE_INFINITY,\n scale,\n ticks,\n tickFormatter,\n title,\n ariaRoleDescription,\n}: InlineStartLabelsProps) {\n const i18n = useInternalI18n('[charts]');\n const virtualTextRef = useRef<SVGTextElement>(null);\n\n const yOffset = axis === 'x' && scale.isCategorical() ? Math.max(0, scale.d3Scale.bandwidth() - 1) / 2 : 0;\n\n const labelToBoxCache = useRef<{ [label: string]: undefined | { width: number; height: number } }>({});\n const getLabelSpace = (label: string) => {\n if (labelToBoxCache.current[label] !== undefined) {\n return labelToBoxCache.current[label]?.height ?? 0;\n }\n if (virtualTextRef.current) {\n virtualTextRef.current.textContent = label;\n }\n labelToBoxCache.current[label] = getSVGTextSize(virtualTextRef.current);\n return labelToBoxCache.current[label]?.height ?? 0;\n };\n\n const formattedTicks = formatTicks({ ticks, scale, getLabelSpace, tickFormatter });\n\n if (virtualTextRef.current) {\n virtualTextRef.current.textContent = '';\n }\n\n const from = 0 - OFFSET_PX - yOffset;\n const until = plotHeight + OFFSET_PX - yOffset;\n const visibleTicks = getVisibleTicks(formattedTicks, from, until);\n\n const isRtl = virtualTextRef.current ? getIsRtl(virtualTextRef.current) : false;\n\n return (\n <g\n className={clsx(styles['labels-inline-start'])}\n aria-label={title}\n role=\"list\"\n aria-roledescription={i18n('i18nStrings.chartAriaRoleDescription', ariaRoleDescription)}\n aria-hidden={true}\n >\n {visibleTicks.map(\n ({ position, lines }, index) =>\n isFinite(position) && (\n <g\n key={index}\n role=\"listitem\"\n transform={`translate(0,${position + yOffset})`}\n className={clsx(styles.ticks, axis === 'x' ? styles['ticks--x'] : styles['ticks--y'])}\n >\n {axis === 'y' && (\n <line\n className={clsx(styles.grid, styles.ticks_line)}\n x1={-TICK_LENGTH}\n y1={0}\n x2={plotWidth}\n y2={0}\n aria-hidden=\"true\"\n />\n )}\n\n {lines.map((line, lineIndex) => {\n const x = -(TICK_LENGTH + TICK_MARGIN);\n const lineTextProps = {\n x: !isRtl ? x : plotWidth - x,\n y: (lineIndex - (lines.length - 1) * 0.5) * TICK_LINE_HEIGHT,\n className: styles.ticks__text,\n children: line,\n };\n return (labelToBoxCache.current[lines[0]]?.width ?? 0) > maxLabelsWidth ? (\n <ResponsiveText key={lineIndex} {...lineTextProps} maxWidth={maxLabelsWidth} />\n ) : (\n <text key={lineIndex} {...lineTextProps} />\n );\n })}\n </g>\n )\n )}\n\n <text ref={virtualTextRef} x={0} y={0} style={{ visibility: 'hidden' }} aria-hidden=\"true\"></text>\n </g>\n );\n}\n"]}
@@ -19,8 +19,8 @@ function LabelsMeasure({ scale, ticks, tickFormatter, autoWidth, maxLabelsWidth
19
19
  }
20
20
  const formattedValue = tickFormatter ? tickFormatter(value) : value.toString();
21
21
  const lines = (formattedValue + '').split('\n');
22
- return (React.createElement(Fragment, { key: `${value}` }, lines.map((line, lineIndex) => (React.createElement("div", { key: lineIndex, className: styles['labels-left__label'], "aria-hidden": "true" }, line)))));
22
+ return (React.createElement(Fragment, { key: `${value}` }, lines.map((line, lineIndex) => (React.createElement("div", { key: lineIndex, className: styles['labels-inline-start__label'], "aria-hidden": "true" }, line)))));
23
23
  };
24
- return (React.createElement("div", { ref: ref, className: clsx(styles['labels-left'], styles['labels-left--hidden']), style: { maxWidth: maxLabelsWidth } }, ticks.map(labelMapper)));
24
+ return (React.createElement("div", { ref: ref, className: clsx(styles['labels-inline-start'], styles['labels-inline-start--hidden']), style: { maxWidth: maxLabelsWidth } }, ticks.map(labelMapper)));
25
25
  }
26
26
  //# sourceMappingURL=labels-measure.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"labels-measure.js","sourceRoot":"","sources":["../../../../../src/internal/components/cartesian-chart/labels-measure.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,IAAI,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,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CACL,6BACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC,qBAAqB,CAAC,CAAC,EACrE,KAAK,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,IAElC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CACnB,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { memo, useEffect, Fragment } from 'react';\nimport clsx from 'clsx';\n\nimport { ChartScale, NumericChartScale } from './scales';\n\nimport styles from './styles.css.js';\nimport { ChartDataTypes } from '../../../mixed-line-bar-chart/interfaces';\nimport { useContainerQuery } from '@cloudscape-design/component-toolkit';\n\ninterface LabelsMeasureProps {\n scale: ChartScale | NumericChartScale;\n ticks: readonly ChartDataTypes[];\n tickFormatter?: (value: ChartDataTypes) => string;\n autoWidth: (value: number) => void;\n maxLabelsWidth?: number;\n}\n\nexport default memo(LabelsMeasure) as typeof LabelsMeasure;\n\n// Places the invisible left-hand side labels to calculate their maximum width.\nfunction LabelsMeasure({ scale, ticks, tickFormatter, autoWidth, maxLabelsWidth }: LabelsMeasureProps) {\n const [width, ref] = useContainerQuery<number>(rect => rect.contentBoxWidth);\n\n // Tell elements's width to the parent.\n useEffect(() => {\n autoWidth(width || 0);\n }, [autoWidth, width]);\n\n const labelMapper = (value: ChartDataTypes) => {\n const scaledValue = scale.d3Scale(value as any);\n if (scaledValue === undefined || !isFinite(scaledValue)) {\n return null;\n }\n\n const formattedValue = tickFormatter ? tickFormatter(value as any) : value.toString();\n const lines = (formattedValue + '').split('\\n');\n\n return (\n <Fragment key={`${value}`}>\n {lines.map((line, lineIndex) => (\n <div key={lineIndex} className={styles['labels-left__label']} aria-hidden=\"true\">\n {line}\n </div>\n ))}\n </Fragment>\n );\n };\n\n return (\n <div\n ref={ref}\n className={clsx(styles['labels-left'], styles['labels-left--hidden'])}\n style={{ maxWidth: maxLabelsWidth }}\n >\n {ticks.map(labelMapper)}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"labels-measure.js","sourceRoot":"","sources":["../../../../../src/internal/components/cartesian-chart/labels-measure.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAUzE,eAAe,IAAI,CAAC,aAAa,CAAyB,CAAC;AAE3D,+EAA+E;AAC/E,SAAS,aAAa,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,EAAsB;IACnG,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,iBAAiB,CAAS,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAE7E,uCAAuC;IACvC,SAAS,CAAC,GAAG,EAAE;QACb,SAAS,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;IACxB,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IAEvB,MAAM,WAAW,GAAG,CAAC,KAAqB,EAAE,EAAE;QAC5C,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,KAAY,CAAC,CAAC;QAChD,IAAI,WAAW,KAAK,SAAS,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;YACvD,OAAO,IAAI,CAAC;SACb;QAED,MAAM,cAAc,GAAG,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,KAAY,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACtF,MAAM,KAAK,GAAG,CAAC,cAAc,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEhD,OAAO,CACL,oBAAC,QAAQ,IAAC,GAAG,EAAE,GAAG,KAAK,EAAE,IACtB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,CAC9B,6BAAK,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,4BAA4B,CAAC,iBAAc,MAAM,IACrF,IAAI,CACD,CACP,CAAC,CACO,CACZ,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CACL,6BACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC,6BAA6B,CAAC,CAAC,EACrF,KAAK,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,IAElC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CACnB,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { memo, useEffect, Fragment } from 'react';\nimport clsx from 'clsx';\n\nimport { ChartScale, NumericChartScale } from './scales';\n\nimport styles from './styles.css.js';\nimport { ChartDataTypes } from '../../../mixed-line-bar-chart/interfaces';\nimport { useContainerQuery } from '@cloudscape-design/component-toolkit';\n\ninterface LabelsMeasureProps {\n scale: ChartScale | NumericChartScale;\n ticks: readonly ChartDataTypes[];\n tickFormatter?: (value: ChartDataTypes) => string;\n autoWidth: (value: number) => void;\n maxLabelsWidth?: number;\n}\n\nexport default memo(LabelsMeasure) as typeof LabelsMeasure;\n\n// Places the invisible left-hand side labels to calculate their maximum width.\nfunction LabelsMeasure({ scale, ticks, tickFormatter, autoWidth, maxLabelsWidth }: LabelsMeasureProps) {\n const [width, ref] = useContainerQuery<number>(rect => rect.contentBoxWidth);\n\n // Tell elements's width to the parent.\n useEffect(() => {\n autoWidth(width || 0);\n }, [autoWidth, width]);\n\n const labelMapper = (value: ChartDataTypes) => {\n const scaledValue = scale.d3Scale(value as any);\n if (scaledValue === undefined || !isFinite(scaledValue)) {\n return null;\n }\n\n const formattedValue = tickFormatter ? tickFormatter(value as any) : value.toString();\n const lines = (formattedValue + '').split('\\n');\n\n return (\n <Fragment key={`${value}`}>\n {lines.map((line, lineIndex) => (\n <div key={lineIndex} className={styles['labels-inline-start__label']} aria-hidden=\"true\">\n {line}\n </div>\n ))}\n </Fragment>\n );\n };\n\n return (\n <div\n ref={ref}\n className={clsx(styles['labels-inline-start'], styles['labels-inline-start--hidden'])}\n style={{ maxWidth: maxLabelsWidth }}\n >\n {ticks.map(labelMapper)}\n </div>\n );\n}\n"]}
@@ -1,32 +1,32 @@
1
1
 
2
2
  import './styles.scoped.css';
3
3
  export default {
4
- "axis": "awsui_axis_f0fot_f6jsx_9",
5
- "vertical-marker": "awsui_vertical-marker_f0fot_f6jsx_10",
6
- "axis--emphasized": "awsui_axis--emphasized_f0fot_f6jsx_15",
7
- "axis-label": "awsui_axis-label_f0fot_f6jsx_19",
8
- "axis-label--x": "awsui_axis-label--x_f0fot_f6jsx_24",
9
- "axis-label--y": "awsui_axis-label--y_f0fot_f6jsx_25",
10
- "grid": "awsui_grid_f0fot_f6jsx_29",
11
- "ticks__line": "awsui_ticks__line_f0fot_f6jsx_34",
12
- "ticks__text": "awsui_ticks__text_f0fot_f6jsx_39",
13
- "ticks--y": "awsui_ticks--y_f0fot_f6jsx_44",
14
- "ticks--x": "awsui_ticks--x_f0fot_f6jsx_45",
15
- "ticks--bottom": "awsui_ticks--bottom_f0fot_f6jsx_49",
16
- "labels-left": "awsui_labels-left_f0fot_f6jsx_54",
17
- "ticks": "awsui_ticks_f0fot_f6jsx_34",
18
- "labels-left__label": "awsui_labels-left__label_f0fot_f6jsx_69",
19
- "labels-left--hidden": "awsui_labels-left--hidden_f0fot_f6jsx_73",
20
- "labels-bottom": "awsui_labels-bottom_f0fot_f6jsx_81",
21
- "vertical-marker-circle": "awsui_vertical-marker-circle_f0fot_f6jsx_92",
22
- "vertical-marker-circle-active": "awsui_vertical-marker-circle-active_f0fot_f6jsx_98",
23
- "focus-outline": "awsui_focus-outline_f0fot_f6jsx_103",
24
- "chart-container": "awsui_chart-container_f0fot_f6jsx_111",
25
- "fit-height": "awsui_fit-height_f0fot_f6jsx_116",
26
- "chart-container-outer": "awsui_chart-container-outer_f0fot_f6jsx_121",
27
- "chart-container-inner": "awsui_chart-container-inner_f0fot_f6jsx_128",
28
- "chart-container-plot-wrapper": "awsui_chart-container-plot-wrapper_f0fot_f6jsx_135",
29
- "chart-container-plot": "awsui_chart-container-plot_f0fot_f6jsx_135",
30
- "chart-container-bottom-labels": "awsui_chart-container-bottom-labels_f0fot_f6jsx_147"
4
+ "axis": "awsui_axis_f0fot_11j60_9",
5
+ "vertical-marker": "awsui_vertical-marker_f0fot_11j60_10",
6
+ "axis--emphasized": "awsui_axis--emphasized_f0fot_11j60_15",
7
+ "axis-label": "awsui_axis-label_f0fot_11j60_19",
8
+ "axis-label--x": "awsui_axis-label--x_f0fot_11j60_24",
9
+ "axis-label--y": "awsui_axis-label--y_f0fot_11j60_25",
10
+ "grid": "awsui_grid_f0fot_11j60_29",
11
+ "ticks__line": "awsui_ticks__line_f0fot_11j60_34",
12
+ "ticks__text": "awsui_ticks__text_f0fot_11j60_39",
13
+ "ticks--y": "awsui_ticks--y_f0fot_11j60_44",
14
+ "ticks--x": "awsui_ticks--x_f0fot_11j60_45",
15
+ "ticks--bottom": "awsui_ticks--bottom_f0fot_11j60_49",
16
+ "labels-inline-start": "awsui_labels-inline-start_f0fot_11j60_54",
17
+ "ticks": "awsui_ticks_f0fot_11j60_34",
18
+ "labels-inline-start__label": "awsui_labels-inline-start__label_f0fot_11j60_69",
19
+ "labels-inline-start--hidden": "awsui_labels-inline-start--hidden_f0fot_11j60_73",
20
+ "labels-block-end": "awsui_labels-block-end_f0fot_11j60_81",
21
+ "vertical-marker-circle": "awsui_vertical-marker-circle_f0fot_11j60_92",
22
+ "vertical-marker-circle-active": "awsui_vertical-marker-circle-active_f0fot_11j60_98",
23
+ "focus-outline": "awsui_focus-outline_f0fot_11j60_103",
24
+ "chart-container": "awsui_chart-container_f0fot_11j60_111",
25
+ "fit-height": "awsui_fit-height_f0fot_11j60_116",
26
+ "chart-container-outer": "awsui_chart-container-outer_f0fot_11j60_121",
27
+ "chart-container-inner": "awsui_chart-container-inner_f0fot_11j60_128",
28
+ "chart-container-plot-wrapper": "awsui_chart-container-plot-wrapper_f0fot_11j60_135",
29
+ "chart-container-plot": "awsui_chart-container-plot_f0fot_11j60_135",
30
+ "chart-container-bottom-labels": "awsui_chart-container-bottom-labels_f0fot_11j60_147"
31
31
  };
32
32
 
@@ -6,101 +6,101 @@
6
6
  Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
7
7
  SPDX-License-Identifier: Apache-2.0
8
8
  */
9
- .awsui_axis_f0fot_f6jsx_9:not(#\9),
10
- .awsui_vertical-marker_f0fot_f6jsx_10:not(#\9) {
9
+ .awsui_axis_f0fot_11j60_9:not(#\9),
10
+ .awsui_vertical-marker_f0fot_11j60_10:not(#\9) {
11
11
  stroke: var(--color-charts-line-axis-r7291n, #d1d5db);
12
12
  stroke-width: 1px;
13
13
  }
14
14
 
15
- .awsui_axis--emphasized_f0fot_f6jsx_15:not(#\9) {
15
+ .awsui_axis--emphasized_f0fot_11j60_15:not(#\9) {
16
16
  stroke-width: 2px;
17
17
  }
18
18
 
19
- .awsui_axis-label_f0fot_f6jsx_19:not(#\9) {
19
+ .awsui_axis-label_f0fot_11j60_19:not(#\9) {
20
20
  font-weight: bold;
21
21
  fill: var(--color-text-body-default-at06ol, #000716);
22
22
  }
23
23
 
24
- .awsui_axis-label--x_f0fot_f6jsx_24:not(#\9),
25
- .awsui_axis-label--y_f0fot_f6jsx_25:not(#\9) {
24
+ .awsui_axis-label--x_f0fot_11j60_24:not(#\9),
25
+ .awsui_axis-label--y_f0fot_11j60_25:not(#\9) {
26
26
  /* used in test-utils */
27
27
  }
28
28
 
29
- .awsui_grid_f0fot_f6jsx_29:not(#\9) {
29
+ .awsui_grid_f0fot_11j60_29:not(#\9) {
30
30
  stroke: var(--color-charts-line-grid-9oxvql, #d1d5db);
31
31
  stroke-width: 1px;
32
32
  }
33
33
 
34
- .awsui_ticks__line_f0fot_f6jsx_34:not(#\9) {
34
+ .awsui_ticks__line_f0fot_11j60_34:not(#\9) {
35
35
  stroke: var(--color-charts-line-tick-mf5hvw, #d1d5db);
36
36
  stroke-width: 1px;
37
37
  }
38
38
 
39
- .awsui_ticks__text_f0fot_f6jsx_39:not(#\9) {
39
+ .awsui_ticks__text_f0fot_11j60_39:not(#\9) {
40
40
  font-size: var(--font-chart-detail-size-1n389u, 12px);
41
41
  fill: var(--color-text-body-secondary-w9jvno, #414d5c);
42
42
  }
43
43
 
44
- .awsui_ticks--y_f0fot_f6jsx_44:not(#\9),
45
- .awsui_ticks--x_f0fot_f6jsx_45:not(#\9) {
44
+ .awsui_ticks--y_f0fot_11j60_44:not(#\9),
45
+ .awsui_ticks--x_f0fot_11j60_45:not(#\9) {
46
46
  /* used in test-utils */
47
47
  }
48
48
 
49
- .awsui_ticks--bottom_f0fot_f6jsx_49 > .awsui_ticks__text_f0fot_f6jsx_39:not(#\9) {
49
+ .awsui_ticks--bottom_f0fot_11j60_49 > .awsui_ticks__text_f0fot_11j60_39:not(#\9) {
50
50
  text-anchor: middle;
51
51
  dominant-baseline: hanging;
52
52
  }
53
53
 
54
- .awsui_labels-left_f0fot_f6jsx_54 > .awsui_ticks_f0fot_f6jsx_34 > .awsui_ticks__text_f0fot_f6jsx_39:not(#\9) {
54
+ .awsui_labels-inline-start_f0fot_11j60_54 > .awsui_ticks_f0fot_11j60_34 > .awsui_ticks__text_f0fot_11j60_39:not(#\9) {
55
55
  text-anchor: end;
56
56
  dominant-baseline: central;
57
57
  }
58
58
 
59
- .awsui_labels-left_f0fot_f6jsx_54:not(#\9) {
59
+ .awsui_labels-inline-start_f0fot_11j60_54:not(#\9) {
60
60
  position: relative;
61
61
  margin-inline-end: 12px;
62
62
  }
63
- .awsui_labels-left_f0fot_f6jsx_54 > .awsui_axis-label_f0fot_f6jsx_19:not(#\9) {
63
+ .awsui_labels-inline-start_f0fot_11j60_54 > .awsui_axis-label_f0fot_11j60_19:not(#\9) {
64
64
  position: absolute;
65
65
  visibility: visible;
66
66
  white-space: nowrap;
67
67
  }
68
68
 
69
- .awsui_labels-left__label_f0fot_f6jsx_69:not(#\9) {
69
+ .awsui_labels-inline-start__label_f0fot_11j60_69:not(#\9) {
70
70
  position: absolute;
71
71
  }
72
72
 
73
- .awsui_labels-left--hidden_f0fot_f6jsx_73:not(#\9) {
73
+ .awsui_labels-inline-start--hidden_f0fot_11j60_73:not(#\9) {
74
74
  visibility: hidden;
75
75
  }
76
- .awsui_labels-left--hidden_f0fot_f6jsx_73 > .awsui_labels-left__label_f0fot_f6jsx_69:not(#\9) {
76
+ .awsui_labels-inline-start--hidden_f0fot_11j60_73 > .awsui_labels-inline-start__label_f0fot_11j60_69:not(#\9) {
77
77
  position: relative;
78
78
  white-space: nowrap;
79
79
  }
80
80
 
81
- .awsui_labels-bottom_f0fot_f6jsx_81:not(#\9) {
81
+ .awsui_labels-block-end_f0fot_11j60_81:not(#\9) {
82
82
  position: relative;
83
83
  display: block;
84
84
  inline-size: 100%;
85
85
  overflow: visible;
86
86
  }
87
87
 
88
- .awsui_vertical-marker_f0fot_f6jsx_10:not(#\9) {
88
+ .awsui_vertical-marker_f0fot_11j60_10:not(#\9) {
89
89
  pointer-events: none;
90
90
  }
91
91
 
92
- .awsui_vertical-marker-circle_f0fot_f6jsx_92:not(#\9) {
92
+ .awsui_vertical-marker-circle_f0fot_11j60_92:not(#\9) {
93
93
  fill: var(--color-background-container-content-4un1ap, #ffffff);
94
94
  pointer-events: none;
95
95
  stroke-width: var(--border-line-chart-width-9mzos2, 2px);
96
96
  }
97
97
 
98
- .awsui_vertical-marker-circle-active_f0fot_f6jsx_98:not(#\9) {
98
+ .awsui_vertical-marker-circle-active_f0fot_11j60_98:not(#\9) {
99
99
  cursor: pointer;
100
100
  stroke-width: var(--border-line-chart-width-9mzos2, 2px);
101
101
  }
102
102
 
103
- .awsui_focus-outline_f0fot_f6jsx_103:not(#\9) {
103
+ .awsui_focus-outline_f0fot_11j60_103:not(#\9) {
104
104
  outline: none;
105
105
  pointer-events: none;
106
106
  fill: none;
@@ -108,42 +108,42 @@
108
108
  stroke-width: 2px;
109
109
  }
110
110
 
111
- .awsui_chart-container_f0fot_f6jsx_111:not(#\9) {
111
+ .awsui_chart-container_f0fot_11j60_111:not(#\9) {
112
112
  display: flex;
113
113
  inline-size: 100%;
114
114
  flex-direction: column;
115
115
  }
116
- .awsui_chart-container_f0fot_f6jsx_111.awsui_fit-height_f0fot_f6jsx_116:not(#\9) {
116
+ .awsui_chart-container_f0fot_11j60_111.awsui_fit-height_f0fot_11j60_116:not(#\9) {
117
117
  block-size: 100%;
118
118
  min-block-size: inherit;
119
119
  }
120
120
 
121
- .awsui_chart-container-outer_f0fot_f6jsx_121:not(#\9) {
121
+ .awsui_chart-container-outer_f0fot_11j60_121:not(#\9) {
122
122
  display: flex;
123
123
  }
124
- .awsui_chart-container-outer_f0fot_f6jsx_121.awsui_fit-height_f0fot_f6jsx_116:not(#\9) {
124
+ .awsui_chart-container-outer_f0fot_11j60_121.awsui_fit-height_f0fot_11j60_116:not(#\9) {
125
125
  flex: 1;
126
126
  }
127
127
 
128
- .awsui_chart-container-inner_f0fot_f6jsx_128:not(#\9) {
128
+ .awsui_chart-container-inner_f0fot_11j60_128:not(#\9) {
129
129
  position: relative;
130
130
  display: flex;
131
131
  flex-direction: column;
132
132
  inline-size: 100%;
133
133
  }
134
134
 
135
- .awsui_chart-container-plot-wrapper_f0fot_f6jsx_135.awsui_fit-height_f0fot_f6jsx_116:not(#\9) {
135
+ .awsui_chart-container-plot-wrapper_f0fot_11j60_135.awsui_fit-height_f0fot_11j60_116:not(#\9) {
136
136
  display: block;
137
137
  position: relative;
138
138
  flex: 1;
139
139
  }
140
140
 
141
- .awsui_chart-container-plot_f0fot_f6jsx_135.awsui_fit-height_f0fot_f6jsx_116:not(#\9) {
141
+ .awsui_chart-container-plot_f0fot_11j60_135.awsui_fit-height_f0fot_11j60_116:not(#\9) {
142
142
  display: block;
143
143
  position: absolute;
144
144
  inset: 0;
145
145
  }
146
146
 
147
- .awsui_chart-container-bottom-labels_f0fot_f6jsx_147.awsui_fit-height_f0fot_f6jsx_116:not(#\9) {
147
+ .awsui_chart-container-bottom-labels_f0fot_11j60_147.awsui_fit-height_f0fot_11j60_116:not(#\9) {
148
148
  display: block;
149
149
  }
@@ -2,32 +2,32 @@
2
2
  // es-module interop with Babel and Typescript
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  module.exports.default = {
5
- "axis": "awsui_axis_f0fot_f6jsx_9",
6
- "vertical-marker": "awsui_vertical-marker_f0fot_f6jsx_10",
7
- "axis--emphasized": "awsui_axis--emphasized_f0fot_f6jsx_15",
8
- "axis-label": "awsui_axis-label_f0fot_f6jsx_19",
9
- "axis-label--x": "awsui_axis-label--x_f0fot_f6jsx_24",
10
- "axis-label--y": "awsui_axis-label--y_f0fot_f6jsx_25",
11
- "grid": "awsui_grid_f0fot_f6jsx_29",
12
- "ticks__line": "awsui_ticks__line_f0fot_f6jsx_34",
13
- "ticks__text": "awsui_ticks__text_f0fot_f6jsx_39",
14
- "ticks--y": "awsui_ticks--y_f0fot_f6jsx_44",
15
- "ticks--x": "awsui_ticks--x_f0fot_f6jsx_45",
16
- "ticks--bottom": "awsui_ticks--bottom_f0fot_f6jsx_49",
17
- "labels-left": "awsui_labels-left_f0fot_f6jsx_54",
18
- "ticks": "awsui_ticks_f0fot_f6jsx_34",
19
- "labels-left__label": "awsui_labels-left__label_f0fot_f6jsx_69",
20
- "labels-left--hidden": "awsui_labels-left--hidden_f0fot_f6jsx_73",
21
- "labels-bottom": "awsui_labels-bottom_f0fot_f6jsx_81",
22
- "vertical-marker-circle": "awsui_vertical-marker-circle_f0fot_f6jsx_92",
23
- "vertical-marker-circle-active": "awsui_vertical-marker-circle-active_f0fot_f6jsx_98",
24
- "focus-outline": "awsui_focus-outline_f0fot_f6jsx_103",
25
- "chart-container": "awsui_chart-container_f0fot_f6jsx_111",
26
- "fit-height": "awsui_fit-height_f0fot_f6jsx_116",
27
- "chart-container-outer": "awsui_chart-container-outer_f0fot_f6jsx_121",
28
- "chart-container-inner": "awsui_chart-container-inner_f0fot_f6jsx_128",
29
- "chart-container-plot-wrapper": "awsui_chart-container-plot-wrapper_f0fot_f6jsx_135",
30
- "chart-container-plot": "awsui_chart-container-plot_f0fot_f6jsx_135",
31
- "chart-container-bottom-labels": "awsui_chart-container-bottom-labels_f0fot_f6jsx_147"
5
+ "axis": "awsui_axis_f0fot_11j60_9",
6
+ "vertical-marker": "awsui_vertical-marker_f0fot_11j60_10",
7
+ "axis--emphasized": "awsui_axis--emphasized_f0fot_11j60_15",
8
+ "axis-label": "awsui_axis-label_f0fot_11j60_19",
9
+ "axis-label--x": "awsui_axis-label--x_f0fot_11j60_24",
10
+ "axis-label--y": "awsui_axis-label--y_f0fot_11j60_25",
11
+ "grid": "awsui_grid_f0fot_11j60_29",
12
+ "ticks__line": "awsui_ticks__line_f0fot_11j60_34",
13
+ "ticks__text": "awsui_ticks__text_f0fot_11j60_39",
14
+ "ticks--y": "awsui_ticks--y_f0fot_11j60_44",
15
+ "ticks--x": "awsui_ticks--x_f0fot_11j60_45",
16
+ "ticks--bottom": "awsui_ticks--bottom_f0fot_11j60_49",
17
+ "labels-inline-start": "awsui_labels-inline-start_f0fot_11j60_54",
18
+ "ticks": "awsui_ticks_f0fot_11j60_34",
19
+ "labels-inline-start__label": "awsui_labels-inline-start__label_f0fot_11j60_69",
20
+ "labels-inline-start--hidden": "awsui_labels-inline-start--hidden_f0fot_11j60_73",
21
+ "labels-block-end": "awsui_labels-block-end_f0fot_11j60_81",
22
+ "vertical-marker-circle": "awsui_vertical-marker-circle_f0fot_11j60_92",
23
+ "vertical-marker-circle-active": "awsui_vertical-marker-circle-active_f0fot_11j60_98",
24
+ "focus-outline": "awsui_focus-outline_f0fot_11j60_103",
25
+ "chart-container": "awsui_chart-container_f0fot_11j60_111",
26
+ "fit-height": "awsui_fit-height_f0fot_11j60_116",
27
+ "chart-container-outer": "awsui_chart-container-outer_f0fot_11j60_121",
28
+ "chart-container-inner": "awsui_chart-container-inner_f0fot_11j60_128",
29
+ "chart-container-plot-wrapper": "awsui_chart-container-plot-wrapper_f0fot_11j60_135",
30
+ "chart-container-plot": "awsui_chart-container-plot_f0fot_11j60_135",
31
+ "chart-container-bottom-labels": "awsui_chart-container-bottom-labels_f0fot_11j60_147"
32
32
  };
33
33
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/chart-legend/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAuB,MAAM,OAAO,CAAC;AAI5C,OAAqB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAI7E,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,qBAAqB,CAAC;IAC5B,KAAK,EAAE,CAAC,CAAC;CACV;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,MAAM,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,iBAAiB,EAAE,CAAC,GAAG,IAAI,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACnD,iBAAiB,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;CAC/C;;AAED,wBAAuD;AAEvD,iBAAS,WAAW,CAAC,CAAC,EAAE,EACtB,MAAM,EACN,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,SAAS,EACT,gBAAgB,GACjB,EAAE,gBAAgB,CAAC,CAAC,CAAC,eAwHrB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/chart-legend/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAuB,MAAM,OAAO,CAAC;AAI5C,OAAqB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAK7E,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,qBAAqB,CAAC;IAC5B,KAAK,EAAE,CAAC,CAAC;CACV;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,MAAM,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,iBAAiB,EAAE,CAAC,GAAG,IAAI,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACnD,iBAAiB,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;CAC/C;;AAED,wBAAuD;AAEvD,iBAAS,WAAW,CAAC,CAAC,EAAE,EACtB,MAAM,EACN,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,SAAS,EACT,gBAAgB,GACjB,EAAE,gBAAgB,CAAC,CAAC,CAAC,eAkHrB"}
@@ -7,19 +7,20 @@ import { KeyCode } from '../../keycode';
7
7
  import SeriesMarker from '../chart-series-marker';
8
8
  import styles from './styles.css.js';
9
9
  import { useInternalI18n } from '../../../i18n/context';
10
+ import handleKey from '../../utils/handle-key';
10
11
  export default memo(ChartLegend);
11
12
  function ChartLegend({ series, onHighlightChange, highlightedSeries, legendTitle, ariaLabel, plotContainerRef, }) {
12
13
  const i18n = useInternalI18n('[charts]');
13
14
  const containerRef = useRef(null);
14
15
  const segmentsRef = useRef([]);
15
16
  const highlightedSeriesIndex = findSeriesIndex(series, highlightedSeries);
16
- const highlightLeft = () => {
17
+ const highlightInlineStart = () => {
17
18
  var _a;
18
19
  const currentIndex = highlightedSeriesIndex !== null && highlightedSeriesIndex !== void 0 ? highlightedSeriesIndex : 0;
19
20
  const nextIndex = currentIndex - 1 >= 0 ? currentIndex - 1 : series.length - 1;
20
21
  (_a = segmentsRef.current[nextIndex]) === null || _a === void 0 ? void 0 : _a.focus();
21
22
  };
22
- const highlightRight = () => {
23
+ const highlightInlineEnd = () => {
23
24
  var _a;
24
25
  const currentIndex = highlightedSeriesIndex !== null && highlightedSeriesIndex !== void 0 ? highlightedSeriesIndex : 0;
25
26
  const nextIndex = currentIndex + 1 < series.length ? currentIndex + 1 : 0;
@@ -29,14 +30,10 @@ function ChartLegend({ series, onHighlightChange, highlightedSeries, legendTitle
29
30
  if (event.keyCode === KeyCode.right || event.keyCode === KeyCode.left) {
30
31
  // Preventing default fixes an issue in Safari+VO when VO additionally interprets arrow keys as its commands.
31
32
  event.preventDefault();
32
- switch (event.keyCode) {
33
- case KeyCode.left:
34
- return highlightLeft();
35
- case KeyCode.right:
36
- return highlightRight();
37
- default:
38
- return;
39
- }
33
+ handleKey(event, {
34
+ onInlineStart: () => highlightInlineStart(),
35
+ onInlineEnd: () => highlightInlineEnd(),
36
+ });
40
37
  }
41
38
  };
42
39
  const handleSelection = (index) => {