@cloudscape-design/components 3.0.294 → 3.0.295

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 (108) hide show
  1. package/alert/internal.d.ts.map +1 -1
  2. package/alert/internal.js +1 -1
  3. package/alert/internal.js.map +1 -1
  4. package/area-chart/elements/use-highlight-details.d.ts.map +1 -1
  5. package/area-chart/elements/use-highlight-details.js +3 -1
  6. package/area-chart/elements/use-highlight-details.js.map +1 -1
  7. package/area-chart/interfaces.d.ts +1 -0
  8. package/area-chart/interfaces.d.ts.map +1 -1
  9. package/area-chart/interfaces.js.map +1 -1
  10. package/breadcrumb-group/item/item.d.ts.map +1 -1
  11. package/breadcrumb-group/item/item.js +9 -6
  12. package/breadcrumb-group/item/item.js.map +1 -1
  13. package/button/internal.d.ts.map +1 -1
  14. package/button/internal.js +6 -1
  15. package/button/internal.js.map +1 -1
  16. package/container/index.d.ts.map +1 -1
  17. package/container/index.js +3 -1
  18. package/container/index.js.map +1 -1
  19. package/container/internal.d.ts.map +1 -1
  20. package/container/internal.js +4 -2
  21. package/container/internal.js.map +1 -1
  22. package/form/index.d.ts.map +1 -1
  23. package/form/index.js +5 -1
  24. package/form/index.js.map +1 -1
  25. package/form/internal.d.ts.map +1 -1
  26. package/form/internal.js +11 -2
  27. package/form/internal.js.map +1 -1
  28. package/form-field/internal.d.ts.map +1 -1
  29. package/form-field/internal.js +28 -2
  30. package/form-field/internal.js.map +1 -1
  31. package/header/internal.d.ts.map +1 -1
  32. package/header/internal.js +1 -1
  33. package/header/internal.js.map +1 -1
  34. package/internal/analytics/hooks/use-funnel.d.ts.map +1 -1
  35. package/internal/analytics/hooks/use-funnel.js +17 -11
  36. package/internal/analytics/hooks/use-funnel.js.map +1 -1
  37. package/internal/components/cartesian-chart/bottom-labels.d.ts.map +1 -1
  38. package/internal/components/cartesian-chart/bottom-labels.js +3 -1
  39. package/internal/components/cartesian-chart/bottom-labels.js.map +1 -1
  40. package/internal/components/cartesian-chart/interfaces.d.ts +4 -0
  41. package/internal/components/cartesian-chart/interfaces.d.ts.map +1 -1
  42. package/internal/components/cartesian-chart/interfaces.js.map +1 -1
  43. package/internal/components/cartesian-chart/left-labels.d.ts.map +1 -1
  44. package/internal/components/cartesian-chart/left-labels.js +3 -1
  45. package/internal/components/cartesian-chart/left-labels.js.map +1 -1
  46. package/internal/components/chart-filter/index.d.ts.map +1 -1
  47. package/internal/components/chart-filter/index.js +4 -2
  48. package/internal/components/chart-filter/index.js.map +1 -1
  49. package/internal/components/chart-legend/index.d.ts.map +1 -1
  50. package/internal/components/chart-legend/index.js +3 -1
  51. package/internal/components/chart-legend/index.js.map +1 -1
  52. package/internal/components/chart-plot/index.d.ts.map +1 -1
  53. package/internal/components/chart-plot/index.js +3 -1
  54. package/internal/components/chart-plot/index.js.map +1 -1
  55. package/internal/components/chart-status-container/index.d.ts.map +1 -1
  56. package/internal/components/chart-status-container/index.js +7 -4
  57. package/internal/components/chart-status-container/index.js.map +1 -1
  58. package/internal/environment.js +1 -1
  59. package/internal/i18n/testing.d.ts +8 -0
  60. package/internal/i18n/testing.d.ts.map +1 -0
  61. package/internal/i18n/testing.js +8 -0
  62. package/internal/i18n/testing.js.map +1 -0
  63. package/internal/manifest.json +1 -1
  64. package/link/internal.d.ts.map +1 -1
  65. package/link/internal.js +35 -1
  66. package/link/internal.js.map +1 -1
  67. package/package.json +1 -1
  68. package/pie-chart/interfaces.d.ts +4 -0
  69. package/pie-chart/interfaces.d.ts.map +1 -1
  70. package/pie-chart/interfaces.js.map +1 -1
  71. package/pie-chart/pie-chart.d.ts.map +1 -1
  72. package/pie-chart/pie-chart.js +3 -1
  73. package/pie-chart/pie-chart.js.map +1 -1
  74. package/pie-chart/segments.d.ts.map +1 -1
  75. package/pie-chart/segments.js +3 -1
  76. package/pie-chart/segments.js.map +1 -1
  77. package/pie-chart/utils.d.ts +2 -1
  78. package/pie-chart/utils.d.ts.map +1 -1
  79. package/pie-chart/utils.js +3 -3
  80. package/pie-chart/utils.js.map +1 -1
  81. package/popover/body.d.ts.map +1 -1
  82. package/popover/body.js +3 -1
  83. package/popover/body.js.map +1 -1
  84. package/popover/interfaces.d.ts +1 -0
  85. package/popover/interfaces.d.ts.map +1 -1
  86. package/popover/interfaces.js.map +1 -1
  87. package/table/styles.css.js +34 -33
  88. package/table/styles.scoped.css +41 -41
  89. package/table/styles.selectors.js +34 -33
  90. package/tiles/interfaces.d.ts +4 -0
  91. package/tiles/interfaces.d.ts.map +1 -1
  92. package/tiles/interfaces.js.map +1 -1
  93. package/tiles/internal.d.ts.map +1 -1
  94. package/tiles/internal.js +2 -2
  95. package/tiles/internal.js.map +1 -1
  96. package/top-navigation/interfaces.d.ts +2 -0
  97. package/top-navigation/interfaces.d.ts.map +1 -1
  98. package/top-navigation/interfaces.js.map +1 -1
  99. package/top-navigation/parts/overflow-menu/menu-item.d.ts +1 -0
  100. package/top-navigation/parts/overflow-menu/menu-item.d.ts.map +1 -1
  101. package/top-navigation/parts/overflow-menu/menu-item.js +2 -0
  102. package/top-navigation/parts/overflow-menu/menu-item.js.map +1 -1
  103. package/top-navigation/parts/overflow-menu/views/submenu.d.ts.map +1 -1
  104. package/top-navigation/parts/overflow-menu/views/submenu.js +1 -0
  105. package/top-navigation/parts/overflow-menu/views/submenu.js.map +1 -1
  106. package/top-navigation/parts/overflow-menu/views/utilities.d.ts.map +1 -1
  107. package/top-navigation/parts/overflow-menu/views/utilities.js +1 -1
  108. package/top-navigation/parts/overflow-menu/views/utilities.js.map +1 -1
@@ -1,7 +1,7 @@
1
1
  import { __rest } from "tslib";
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import React from 'react';
4
+ import React, { useEffect } from 'react';
5
5
  import clsx from 'clsx';
6
6
  import { getBaseProps } from '../internal/base-component';
7
7
  import { FormFieldContext, useFormFieldContext } from '../internal/context/form-field-context';
@@ -13,6 +13,9 @@ import { getAriaDescribedBy, getGridDefinition, getSlotIds } from './util';
13
13
  import styles from './styles.css.js';
14
14
  import { joinStrings } from '../internal/utils/strings';
15
15
  import { useInternalI18n } from '../internal/i18n/context';
16
+ import { FunnelMetrics } from '../internal/analytics';
17
+ import { useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';
18
+ import { getSubStepAllSelector } from '../internal/analytics/selectors';
16
19
  export function FormFieldError({ id, children, errorIconAriaLabel }) {
17
20
  const i18n = useInternalI18n('form-field');
18
21
  return (React.createElement("div", { id: id, className: styles.error },
@@ -31,6 +34,7 @@ export default function InternalFormField(_a) {
31
34
  const instanceUniqueId = useUniqueId('formField');
32
35
  const generatedControlId = controlId || instanceUniqueId;
33
36
  const formFieldId = controlId || generatedControlId;
37
+ const { funnelInteractionId, stepNumber, stepNameSelector, subStepSelector, subStepNameSelector } = useFunnelSubStep();
34
38
  const slotIds = getSlotIds(formFieldId, label, description, constraintText, errorText);
35
39
  const ariaDescribedBy = getAriaDescribedBy(slotIds);
36
40
  const gridDefinition = getGridDefinition(stretch, !!secondaryControl, isRefresh);
@@ -40,7 +44,29 @@ export default function InternalFormField(_a) {
40
44
  ariaDescribedby: joinStrings(parentAriaDescribedby, ariaDescribedBy) || undefined,
41
45
  invalid: !!errorText || !!parentInvalid,
42
46
  };
43
- return (React.createElement("div", Object.assign({}, baseProps, { className: clsx(baseProps.className, styles.root), ref: __internalRootRef }),
47
+ const analyticsAttributes = {};
48
+ if (slotIds.label) {
49
+ analyticsAttributes['data-analytics-field-label-selector'] = `[id="${slotIds.label}"]`;
50
+ }
51
+ if (slotIds.error) {
52
+ analyticsAttributes['data-analytics-field-error-selector'] = `[id="${slotIds.error}"]`;
53
+ }
54
+ useEffect(() => {
55
+ if (funnelInteractionId && errorText) {
56
+ FunnelMetrics.funnelSubStepError({
57
+ funnelInteractionId,
58
+ subStepSelector,
59
+ subStepNameSelector,
60
+ stepNumber,
61
+ stepNameSelector,
62
+ fieldErrorSelector: `[id="${slotIds.error}"]`,
63
+ fieldLabelSelector: `[id="${slotIds.label}"]`,
64
+ subStepAllSelector: getSubStepAllSelector(),
65
+ });
66
+ }
67
+ // eslint-disable-next-line react-hooks/exhaustive-deps
68
+ }, [funnelInteractionId, errorText]);
69
+ return (React.createElement("div", Object.assign({}, baseProps, { className: clsx(baseProps.className, styles.root), ref: __internalRootRef }, analyticsAttributes),
44
70
  React.createElement("div", { className: clsx(__hideLabel && styles['visually-hidden']) },
45
71
  label && (React.createElement("label", { className: styles.label, id: slotIds.label, htmlFor: generatedControlId }, label)),
46
72
  !__hideLabel && info && React.createElement("span", { className: styles.info }, info)),
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["form-field/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE3E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAQ3D,MAAM,UAAU,cAAc,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,kBAAkB,EAAuB;IACtF,MAAM,IAAI,GAAG,eAAe,CAAC,YAAY,CAAC,CAAC;IAE3C,O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AAE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,WAAW,IAAI,MAAM,CAAC,cAAc,CAAC,CAAC;YAC1E,oBAAC,YAAY,IAAC,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB;gBAC5E,oBAAC,gBAAgB,CAAC,QAAQ,IACxB,KAAK,kBACH,SAAS,EAAE,kBAAkB,IAC1B,6BAA6B,KAGjC,QAAQ,IAAI,6BAAK,SAAS,EAAE,MAAM,CAAC,OAAO,IAAG,QAAQ,CAAO,CACnC;gBAE3B,gBAAgB,IAAI,CACnB,oBAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,6BAA6B;oBAC7D,6BAAK,SAAS,EAAE,MAAM,CAAC,mBAAmB,CAAC,IAAG,gBAAgB,CAAO,CAC3C,CAC7B,CACY,CACX;QAEL,CAAC,cAAc,IAAI,SAAS,CAAC,IAAI,CAChC,6BAAK,SAAS,EAAE,MAAM,CAAC,KAAK;YACzB,SAAS,IAAI,CACZ,oBAAC,cAAc,IAAC,EAAE,EAAE,OAAO,CAAC,KAAK,EAAE,kBAAkB,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,kBAAkB,IACnF,SAAS,CACK,CAClB;YACA,cAAc,IAAI,CACjB,oBAAC,cAAc,IAAC,EAAE,EAAE,OAAO,CAAC,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC,SAAS,IAC1D,cAAc,CACA,CAClB,CACG,CACP,CACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { FormFieldContext, useFormFieldContext } from '../internal/context/form-field-context';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\n\nimport InternalGrid from '../grid/internal';\nimport InternalIcon from '../icon/internal';\nimport { getAriaDescribedBy, getGridDefinition, getSlotIds } from './util';\n\nimport styles from './styles.css.js';\nimport { InternalFormFieldProps } from './interfaces';\nimport { joinStrings } from '../internal/utils/strings';\nimport { useInternalI18n } from '../internal/i18n/context';\n\ninterface FormFieldErrorProps {\n id?: string;\n children?: React.ReactNode;\n errorIconAriaLabel?: string;\n}\n\nexport function FormFieldError({ id, children, errorIconAriaLabel }: FormFieldErrorProps) {\n const i18n = useInternalI18n('form-field');\n\n return (\n <div id={id} className={styles.error}>\n <div className={styles['error-icon-shake-wrapper']}>\n <div\n role=\"img\"\n aria-label={i18n('i18nStrings.errorIconAriaLabel', errorIconAriaLabel)}\n className={styles['error-icon-scale-wrapper']}\n >\n <InternalIcon name=\"status-warning\" size=\"small\" />\n </div>\n </div>\n <span className={styles.error__message}>{children}</span>\n </div>\n );\n}\n\nexport function ConstraintText({\n id,\n hasError,\n children,\n}: {\n id?: string;\n hasError: boolean;\n children: React.ReactNode;\n}) {\n return (\n <div id={id} className={clsx(styles.constraint, hasError && styles['constraint-has-error'])}>\n {children}\n </div>\n );\n}\n\nexport default function InternalFormField({\n controlId,\n stretch = false,\n label,\n info,\n i18nStrings,\n children,\n secondaryControl,\n description,\n constraintText,\n errorText,\n __hideLabel,\n __internalRootRef = null,\n __disableGutters = false,\n ...rest\n}: InternalFormFieldProps) {\n const baseProps = getBaseProps(rest);\n const isRefresh = useVisualRefresh();\n\n const instanceUniqueId = useUniqueId('formField');\n const generatedControlId = controlId || instanceUniqueId;\n const formFieldId = controlId || generatedControlId;\n\n const slotIds = getSlotIds(formFieldId, label, description, constraintText, errorText);\n\n const ariaDescribedBy = getAriaDescribedBy(slotIds);\n\n const gridDefinition = getGridDefinition(stretch, !!secondaryControl, isRefresh);\n\n const {\n ariaLabelledby: parentAriaLabelledby,\n ariaDescribedby: parentAriaDescribedby,\n invalid: parentInvalid,\n } = useFormFieldContext({});\n\n const contextValuesWithoutControlId = {\n ariaLabelledby: joinStrings(parentAriaLabelledby, slotIds.label) || undefined,\n ariaDescribedby: joinStrings(parentAriaDescribedby, ariaDescribedBy) || undefined,\n invalid: !!errorText || !!parentInvalid,\n };\n\n return (\n <div {...baseProps} className={clsx(baseProps.className, styles.root)} ref={__internalRootRef}>\n <div className={clsx(__hideLabel && styles['visually-hidden'])}>\n {label && (\n <label className={styles.label} id={slotIds.label} htmlFor={generatedControlId}>\n {label}\n </label>\n )}\n {!__hideLabel && info && <span className={styles.info}>{info}</span>}\n </div>\n\n {description && (\n <div className={styles.description} id={slotIds.description}>\n {description}\n </div>\n )}\n\n <div className={clsx(styles.controls, __hideLabel && styles['label-hidden'])}>\n <InternalGrid gridDefinition={gridDefinition} disableGutters={__disableGutters}>\n <FormFieldContext.Provider\n value={{\n controlId: generatedControlId,\n ...contextValuesWithoutControlId,\n }}\n >\n {children && <div className={styles.control}>{children}</div>}\n </FormFieldContext.Provider>\n\n {secondaryControl && (\n <FormFieldContext.Provider value={contextValuesWithoutControlId}>\n <div className={styles['secondary-control']}>{secondaryControl}</div>\n </FormFieldContext.Provider>\n )}\n </InternalGrid>\n </div>\n\n {(constraintText || errorText) && (\n <div className={styles.hints}>\n {errorText && (\n <FormFieldError id={slotIds.error} errorIconAriaLabel={i18nStrings?.errorIconAriaLabel}>\n {errorText}\n </FormFieldError>\n )}\n {constraintText && (\n <ConstraintText id={slotIds.constraint} hasError={!!errorText}>\n {constraintText}\n </ConstraintText>\n )}\n </div>\n )}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["form-field/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC/F,OA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amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect } from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { FormFieldContext, useFormFieldContext } from '../internal/context/form-field-context';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\n\nimport InternalGrid from '../grid/internal';\nimport InternalIcon from '../icon/internal';\nimport { getAriaDescribedBy, getGridDefinition, getSlotIds } from './util';\n\nimport styles from './styles.css.js';\nimport { InternalFormFieldProps } from './interfaces';\nimport { joinStrings } from '../internal/utils/strings';\nimport { useInternalI18n } from '../internal/i18n/context';\n\nimport { FunnelMetrics } from '../internal/analytics';\nimport { useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';\nimport { getSubStepAllSelector } from '../internal/analytics/selectors';\n\ninterface FormFieldErrorProps {\n id?: string;\n children?: React.ReactNode;\n errorIconAriaLabel?: string;\n}\n\nexport function FormFieldError({ id, children, errorIconAriaLabel }: FormFieldErrorProps) {\n const i18n = useInternalI18n('form-field');\n\n return (\n <div id={id} className={styles.error}>\n <div className={styles['error-icon-shake-wrapper']}>\n <div\n role=\"img\"\n aria-label={i18n('i18nStrings.errorIconAriaLabel', errorIconAriaLabel)}\n className={styles['error-icon-scale-wrapper']}\n >\n <InternalIcon name=\"status-warning\" size=\"small\" />\n </div>\n </div>\n <span className={styles.error__message}>{children}</span>\n </div>\n );\n}\n\nexport function ConstraintText({\n id,\n hasError,\n children,\n}: {\n id?: string;\n hasError: boolean;\n children: React.ReactNode;\n}) {\n return (\n <div id={id} className={clsx(styles.constraint, hasError && styles['constraint-has-error'])}>\n {children}\n </div>\n );\n}\n\nexport default function InternalFormField({\n controlId,\n stretch = false,\n label,\n info,\n i18nStrings,\n children,\n secondaryControl,\n description,\n constraintText,\n errorText,\n __hideLabel,\n __internalRootRef = null,\n __disableGutters = false,\n ...rest\n}: InternalFormFieldProps) {\n const baseProps = getBaseProps(rest);\n const isRefresh = useVisualRefresh();\n\n const instanceUniqueId = useUniqueId('formField');\n const generatedControlId = controlId || instanceUniqueId;\n const formFieldId = controlId || generatedControlId;\n\n const { funnelInteractionId, stepNumber, stepNameSelector, subStepSelector, subStepNameSelector } =\n useFunnelSubStep();\n\n const slotIds = getSlotIds(formFieldId, label, description, constraintText, errorText);\n\n const ariaDescribedBy = getAriaDescribedBy(slotIds);\n\n const gridDefinition = getGridDefinition(stretch, !!secondaryControl, isRefresh);\n\n const {\n ariaLabelledby: parentAriaLabelledby,\n ariaDescribedby: parentAriaDescribedby,\n invalid: parentInvalid,\n } = useFormFieldContext({});\n\n const contextValuesWithoutControlId = {\n ariaLabelledby: joinStrings(parentAriaLabelledby, slotIds.label) || undefined,\n ariaDescribedby: joinStrings(parentAriaDescribedby, ariaDescribedBy) || undefined,\n invalid: !!errorText || !!parentInvalid,\n };\n\n const analyticsAttributes: Record<string, string> = {};\n\n if (slotIds.label) {\n analyticsAttributes['data-analytics-field-label-selector'] = `[id=\"${slotIds.label}\"]`;\n }\n\n if (slotIds.error) {\n analyticsAttributes['data-analytics-field-error-selector'] = `[id=\"${slotIds.error}\"]`;\n }\n\n useEffect(() => {\n if (funnelInteractionId && errorText) {\n FunnelMetrics.funnelSubStepError({\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n stepNumber,\n stepNameSelector,\n fieldErrorSelector: `[id=\"${slotIds.error}\"]`,\n fieldLabelSelector: `[id=\"${slotIds.label}\"]`,\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [funnelInteractionId, errorText]);\n\n return (\n <div\n {...baseProps}\n className={clsx(baseProps.className, styles.root)}\n ref={__internalRootRef}\n {...analyticsAttributes}\n >\n <div className={clsx(__hideLabel && styles['visually-hidden'])}>\n {label && (\n <label className={styles.label} id={slotIds.label} htmlFor={generatedControlId}>\n {label}\n </label>\n )}\n {!__hideLabel && info && <span className={styles.info}>{info}</span>}\n </div>\n\n {description && (\n <div className={styles.description} id={slotIds.description}>\n {description}\n </div>\n )}\n\n <div className={clsx(styles.controls, __hideLabel && styles['label-hidden'])}>\n <InternalGrid gridDefinition={gridDefinition} disableGutters={__disableGutters}>\n <FormFieldContext.Provider\n value={{\n controlId: generatedControlId,\n ...contextValuesWithoutControlId,\n }}\n >\n {children && <div className={styles.control}>{children}</div>}\n </FormFieldContext.Provider>\n\n {secondaryControl && (\n <FormFieldContext.Provider value={contextValuesWithoutControlId}>\n <div className={styles['secondary-control']}>{secondaryControl}</div>\n </FormFieldContext.Provider>\n )}\n </InternalGrid>\n </div>\n\n {(constraintText || errorText) && (\n <div className={styles.hints}>\n {errorText && (\n <FormFieldError id={slotIds.error} errorIconAriaLabel={i18nStrings?.errorIconAriaLabel}>\n {errorText}\n </FormFieldError>\n )}\n {constraintText && (\n <ConstraintText id={slotIds.constraint} hasError={!!errorText}>\n {constraintText}\n </ConstraintText>\n )}\n </div>\n )}\n </div>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["header/internal.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAElF,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,UAAU,mBAAoB,SAAQ,YAAY,CAAC,WAAW,EAAE,SAAS,CAAC,EAAE,0BAA0B;IACpG,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC;AAED,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,OAAO,EACP,kBAAkB,EAClB,QAAQ,EACR,OAAO,EACP,OAAO,EACP,WAAW,EACX,IAAI,EACJ,iBAAwB,EACxB,wBAAwB,EACxB,GAAG,SAAS,EACb,EAAE,mBAAmB,eAsErB"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["header/internal.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAElF,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,UAAU,mBAAoB,SAAQ,YAAY,CAAC,WAAW,EAAE,SAAS,CAAC,EAAE,0BAA0B;IACpG,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC;AAED,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,OAAO,EACP,kBAAkB,EAClB,QAAQ,EACR,OAAO,EACP,OAAO,EACP,WAAW,EACX,IAAI,EACJ,iBAAwB,EACxB,wBAAwB,EACxB,GAAG,SAAS,EACb,EAAE,mBAAmB,eAyErB"}
@@ -22,7 +22,7 @@ export default function InternalHeader(_a) {
22
22
  React.createElement("div", { className: clsx(styles.main, styles[`main-variant-${variantOverride}`], isRefresh && styles[`main-variant-${variantOverride}-refresh`]) },
23
23
  React.createElement("div", { className: clsx(styles.title, styles[`title-variant-${variantOverride}`], isRefresh && styles[`title-variant-${variantOverride}-refresh`]) },
24
24
  React.createElement(HeadingTag, { className: clsx(styles.heading, styles[`heading-variant-${variantOverride}`]) },
25
- React.createElement("span", { className: clsx(styles['heading-text'], styles[`heading-text-variant-${variantOverride}`]) }, children),
25
+ React.createElement("span", { "data-analytics": "heading-text", className: clsx(styles['heading-text'], styles[`heading-text-variant-${variantOverride}`]) }, children),
26
26
  counter !== undefined && React.createElement("span", { className: styles.counter },
27
27
  " ",
28
28
  counter)),
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["header/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,YAAY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,IAAI,CACV,6BACE,SAAS,EAAE,IAAI,CACb,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,mBAAmB,eAAe,EAAE,CAAC,EAC5C,SAAS,IAAI,MAAM,CAAC,mBAAmB,eAAe,UAAU,CAAC,CAClE,IAEA,OAAO,CACJ,CACP,CACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React, { useContext } from 'react';\nimport { getBaseProps } from '../internal/base-component';\nimport { StickyHeaderContext } from '../container/use-sticky-header';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { HeaderProps } from './interfaces';\nimport styles from './styles.css.js';\nimport { SomeRequired } from '../internal/types';\nimport { useMobile } from '../internal/hooks/use-mobile';\n\ninterface InternalHeaderProps extends SomeRequired<HeaderProps, 'variant'>, InternalBaseComponentProps {\n __disableActionsWrapping?: boolean;\n}\n\nexport default function InternalHeader({\n variant,\n headingTagOverride,\n children,\n actions,\n counter,\n description,\n info,\n __internalRootRef = null,\n __disableActionsWrapping,\n ...restProps\n}: InternalHeaderProps) {\n const isMobile = useMobile();\n const HeadingTag = headingTagOverride ?? (variant === 'awsui-h1-sticky' ? 'h1' : variant);\n const { isStuck } = useContext(StickyHeaderContext);\n const baseProps = getBaseProps(restProps);\n const isRefresh = useVisualRefresh();\n // If is mobile there is no need to have the dynamic variant because it's scrolled out of view\n const dynamicVariant = !isMobile && isStuck ? 'h2' : 'h1';\n const variantOverride = variant === 'awsui-h1-sticky' ? (isRefresh ? dynamicVariant : 'h2') : variant;\n return (\n <div\n {...baseProps}\n className={clsx(\n styles.root,\n baseProps.className,\n styles[`root-variant-${variantOverride}`],\n isRefresh && styles[`root-variant-${variantOverride}-refresh`],\n !actions && [styles[`root-no-actions`]],\n description && [styles[`root-has-description`]],\n __disableActionsWrapping && [styles['root-no-wrap']]\n )}\n ref={__internalRootRef}\n >\n <div\n className={clsx(\n styles.main,\n styles[`main-variant-${variantOverride}`],\n isRefresh && styles[`main-variant-${variantOverride}-refresh`]\n )}\n >\n <div\n className={clsx(\n styles.title,\n styles[`title-variant-${variantOverride}`],\n isRefresh && styles[`title-variant-${variantOverride}-refresh`]\n )}\n >\n <HeadingTag className={clsx(styles.heading, styles[`heading-variant-${variantOverride}`])}>\n <span className={clsx(styles['heading-text'], styles[`heading-text-variant-${variantOverride}`])}>\n {children}\n </span>\n {counter !== undefined && <span className={styles.counter}> {counter}</span>}\n </HeadingTag>\n {info && <span className={styles.info}>{info}</span>}\n </div>\n {description && (\n <p\n className={clsx(\n styles.description,\n styles[`description-variant-${variantOverride}`],\n isRefresh && styles[`description-variant-${variantOverride}-refresh`]\n )}\n >\n {description}\n </p>\n )}\n </div>\n {actions && (\n <div\n className={clsx(\n styles.actions,\n styles[`actions-variant-${variantOverride}`],\n isRefresh && styles[`actions-variant-${variantOverride}-refresh`]\n )}\n >\n {actions}\n </div>\n )}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["header/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAMzD,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EAWjB;QAXiB,EACrC,OAAO,EACP,kBAAkB,EAClB,QAAQ,EACR,OAAO,EACP,OAAO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,gBAAgB,eAAe,EAAE,CAAC,EACzC,SAAS,IAAI,MAAM,CAAC,gBAAgB,eAAe,UAAU,CAAC,CAC/D;YAED,6BACE,SAAS,EAAE,IAAI,CACb,MAAM,CAAC,KAAK,EACZ,MAAM,CAAC,iBAAiB,eAAe,EAAE,CAAC,EAC1C,SAAS,IAAI,MAAM,CAAC,iBAAiB,eAAe,UAAU,CAAC,CAChE;gBAED,oBAAC,UAAU,IAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,mBAAmB,eAAe,EAAE,CAAC,CAAC;oBACvF,gDACiB,cAAc,EAC7B,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,wBAAwB,eAAe,EAAE,CAAC,CAAC,IAEzF,QAAQ,CACJ;oBACN,OAAO,KAAK,SAAS,IAAI,8BAAM,SAAS,EAAE,MAAM,CAAC,OAAO;;wBAAI,OAAO,CAAQ,CACjE;gBACZ,IAAI,IAAI,8BAAM,SAAS,EAAE,MAAM,CAAC,IAAI,IAAG,IAAI,CAAQ,CAChD;YACL,WAAW,IAAI,CACd,2BACE,SAAS,EAAE,IAAI,CACb,MAAM,CAAC,WAAW,EAClB,MAAM,CAAC,uBAAuB,eAAe,EAAE,CAAC,EAChD,SAAS,IAAI,MAAM,CAAC,uBAAuB,eAAe,UAAU,CAAC,CACtE,IAEA,WAAW,CACV,CACL,CACG;QACL,OAAO,IAAI,CACV,6BACE,SAAS,EAAE,IAAI,CACb,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,mBAAmB,eAAe,EAAE,CAAC,EAC5C,SAAS,IAAI,MAAM,CAAC,mBAAmB,eAAe,UAAU,CAAC,CAClE,IAEA,OAAO,CACJ,CACP,CACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React, { useContext } from 'react';\nimport { getBaseProps } from '../internal/base-component';\nimport { StickyHeaderContext } from '../container/use-sticky-header';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { HeaderProps } from './interfaces';\nimport styles from './styles.css.js';\nimport { SomeRequired } from '../internal/types';\nimport { useMobile } from '../internal/hooks/use-mobile';\n\ninterface InternalHeaderProps extends SomeRequired<HeaderProps, 'variant'>, InternalBaseComponentProps {\n __disableActionsWrapping?: boolean;\n}\n\nexport default function InternalHeader({\n variant,\n headingTagOverride,\n children,\n actions,\n counter,\n description,\n info,\n __internalRootRef = null,\n __disableActionsWrapping,\n ...restProps\n}: InternalHeaderProps) {\n const isMobile = useMobile();\n const HeadingTag = headingTagOverride ?? (variant === 'awsui-h1-sticky' ? 'h1' : variant);\n const { isStuck } = useContext(StickyHeaderContext);\n const baseProps = getBaseProps(restProps);\n const isRefresh = useVisualRefresh();\n // If is mobile there is no need to have the dynamic variant because it's scrolled out of view\n const dynamicVariant = !isMobile && isStuck ? 'h2' : 'h1';\n const variantOverride = variant === 'awsui-h1-sticky' ? (isRefresh ? dynamicVariant : 'h2') : variant;\n return (\n <div\n {...baseProps}\n className={clsx(\n styles.root,\n baseProps.className,\n styles[`root-variant-${variantOverride}`],\n isRefresh && styles[`root-variant-${variantOverride}-refresh`],\n !actions && [styles[`root-no-actions`]],\n description && [styles[`root-has-description`]],\n __disableActionsWrapping && [styles['root-no-wrap']]\n )}\n ref={__internalRootRef}\n >\n <div\n className={clsx(\n styles.main,\n styles[`main-variant-${variantOverride}`],\n isRefresh && styles[`main-variant-${variantOverride}-refresh`]\n )}\n >\n <div\n className={clsx(\n styles.title,\n styles[`title-variant-${variantOverride}`],\n isRefresh && styles[`title-variant-${variantOverride}-refresh`]\n )}\n >\n <HeadingTag className={clsx(styles.heading, styles[`heading-variant-${variantOverride}`])}>\n <span\n data-analytics=\"heading-text\"\n className={clsx(styles['heading-text'], styles[`heading-text-variant-${variantOverride}`])}\n >\n {children}\n </span>\n {counter !== undefined && <span className={styles.counter}> {counter}</span>}\n </HeadingTag>\n {info && <span className={styles.info}>{info}</span>}\n </div>\n {description && (\n <p\n className={clsx(\n styles.description,\n styles[`description-variant-${variantOverride}`],\n isRefresh && styles[`description-variant-${variantOverride}-refresh`]\n )}\n >\n {description}\n </p>\n )}\n </div>\n {actions && (\n <div\n className={clsx(\n styles.actions,\n styles[`actions-variant-${variantOverride}`],\n isRefresh && styles[`actions-variant-${variantOverride}-refresh`]\n )}\n >\n {actions}\n </div>\n )}\n </div>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"use-funnel.d.ts","sourceRoot":"lib/default/","sources":["internal/analytics/hooks/use-funnel.ts"],"names":[],"mappings":";AAQA;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;CA2C5B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa;;;;;CAOzB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,SAAS;;;;;;;;;CAOrB,CAAC"}
1
+ {"version":3,"file":"use-funnel.d.ts","sourceRoot":"lib/default/","sources":["internal/analytics/hooks/use-funnel.ts"],"names":[],"mappings":";AAQA;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;CA6C5B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa;;;;;CASzB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,SAAS;;;;;;;;;CASrB,CAAC"}
@@ -44,11 +44,13 @@ export const useFunnelSubStep = () => {
44
44
  });
45
45
  }
46
46
  };
47
- const funnelSubStepProps = {
48
- 'data-analytics-funnel-substep': subStepId,
49
- onFocus,
50
- onBlur,
51
- };
47
+ const funnelSubStepProps = funnelInteractionId
48
+ ? {
49
+ 'data-analytics-funnel-substep': subStepId,
50
+ onFocus,
51
+ onBlur,
52
+ }
53
+ : {};
52
54
  return Object.assign({ funnelSubStepProps, subStepRef }, context);
53
55
  };
54
56
  /**
@@ -61,9 +63,11 @@ export const useFunnelSubStep = () => {
61
63
  */
62
64
  export const useFunnelStep = () => {
63
65
  const context = useContext(FunnelStepContext);
64
- const funnelStepProps = {
65
- 'data-analytics-funnel-step-index': context.stepNumber,
66
- };
66
+ const funnelStepProps = context.funnelInteractionId
67
+ ? {
68
+ 'data-analytics-funnel-step-index': context.stepNumber,
69
+ }
70
+ : {};
67
71
  return Object.assign({ funnelStepProps }, context);
68
72
  };
69
73
  /**
@@ -75,9 +79,11 @@ export const useFunnelStep = () => {
75
79
  */
76
80
  export const useFunnel = () => {
77
81
  const context = useContext(FunnelContext);
78
- const funnelProps = {
79
- 'data-analytics-funnel-interaction-id': context.funnelInteractionId,
80
- };
82
+ const funnelProps = context.funnelInteractionId
83
+ ? {
84
+ 'data-analytics-funnel-interaction-id': context.funnelInteractionId,
85
+ }
86
+ : {};
81
87
  return Object.assign({ funnelProps }, context);
82
88
  };
83
89
  //# sourceMappingURL=use-funnel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-funnel.js","sourceRoot":"lib/default/","sources":["internal/analytics/hooks/use-funnel.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACtG,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,MAAM,UAAU,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IACvD,MAAM,OAAO,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACjD,MAAM,EAAE,mBAAmB,EAAE,SAAS,EAAE,eAAe,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AC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE;IAC5B,MAAM,OAAO,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAC1C,MAAM,WAAW,GAA0D;QACzE,sCAAsC,EAAE,OAAO,CAAC,mBAAmB;KACpE,CAAC;IAEF,uBAAS,WAAW,IAAK,OAAO,EAAG;AACrC,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useContext, useRef } from 'react';\nimport { FunnelContext, FunnelStepContext, FunnelSubStepContext } from '../context/analytics-context';\nimport { getSubStepAllSelector } from '../selectors';\nimport { FunnelMetrics } from '../';\n\n/**\n * Custom React Hook to manage and interact with FunnelSubStep.\n * This hook will provide necessary properties and methods required\n * to track and manage interactions with a FunnelSubStep component.\n *\n * The `onFocus` method is used to track the beginning of interaction with the FunnelSubStep.\n * The `onBlur` method is used to track the completion of interaction with the FunnelSubStep.\n * The subStepId is a unique identifier for the funnel sub-step.\n * The subStepRef is a reference to the DOM element of the funnel sub-step.\n */\nexport const useFunnelSubStep = () => {\n const subStepRef = useRef<HTMLDivElement | null>(null);\n const context = useContext(FunnelSubStepContext);\n const { funnelInteractionId, subStepId, subStepSelector, subStepNameSelector, stepNumber, stepNameSelector } =\n context;\n\n const onFocus = (event: React.FocusEvent<HTMLDivElement>) => {\n if (\n funnelInteractionId &&\n subStepRef.current &&\n (!event.relatedTarget || !subStepRef.current.contains(event.relatedTarget as Node))\n ) {\n FunnelMetrics.funnelSubStepStart({\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n stepNumber,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n };\n\n const onBlur = (event: React.FocusEvent<HTMLDivElement>) => {\n if (funnelInteractionId && subStepRef.current && !subStepRef.current.contains(event.relatedTarget)) {\n FunnelMetrics.funnelSubStepComplete({\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n stepNumber,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n };\n\n const funnelSubStepProps: Record<string, any> = {\n 'data-analytics-funnel-substep': subStepId,\n onFocus,\n onBlur,\n };\n\n return { funnelSubStepProps, subStepRef, ...context };\n};\n\n/**\n * Custom React Hook to manage and interact with FunnelStep.\n * This hook will provide necessary properties required to track\n * and manage interactions with a FunnelStep component.\n *\n * The 'data-analytics-funnel-step-index' property of funnelStepProps is used to track the index of the current step in the funnel.\n * The context contains additional properties of the FunnelStep.\n */\nexport const useFunnelStep = () => {\n const context = useContext(FunnelStepContext);\n const funnelStepProps: Record<string, string | number | boolean | undefined> = {\n 'data-analytics-funnel-step-index': context.stepNumber,\n };\n\n return { funnelStepProps, ...context };\n};\n\n/**\n * Custom React Hook to manage and interact with Funnel.\n * This hook will provide necessary properties required to track\n * and manage interactions with a Funnel component.\n *\n * The 'data-analytics-funnel-interaction-id' property of funnelProps is used to track the unique identifier of the current interaction with the funnel.\n */\nexport const useFunnel = () => {\n const context = useContext(FunnelContext);\n const funnelProps: Record<string, string | number | boolean | undefined> = {\n 'data-analytics-funnel-interaction-id': context.funnelInteractionId,\n };\n\n return { funnelProps, ...context };\n};\n"]}
1
+ {"version":3,"file":"use-funnel.js","sourceRoot":"lib/default/","sources":["internal/analytics/hooks/use-funnel.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACtG,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,MAAM,UAAU,GAAG,MAAM,CAAw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OAAO,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAC9C,MAAM,eAAe,GAA0D,OAAO,CAAC,mBAAmB;QACxG,CAAC,CAAC;YACE,kCAAkC,EAAE,OAAO,CAAC,UAAU;SACvD;QACH,CAAC,CAAC,EAAE,CAAC;IAEP,uBAAS,eAAe,IAAK,OAAO,EAAG;AACzC,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE;IAC5B,MAAM,OAAO,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAC1C,MAAM,WAAW,GAA0D,OAAO,CAAC,mBAAmB;QACpG,CAAC,CAAC;YACE,sCAAsC,EAAE,OAAO,CAAC,mBAAmB;SACpE;QACH,CAAC,CAAC,EAAE,CAAC;IAEP,uBAAS,WAAW,IAAK,OAAO,EAAG;AACrC,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useContext, useRef } from 'react';\nimport { FunnelContext, FunnelStepContext, FunnelSubStepContext } from '../context/analytics-context';\nimport { getSubStepAllSelector } from '../selectors';\nimport { FunnelMetrics } from '../';\n\n/**\n * Custom React Hook to manage and interact with FunnelSubStep.\n * This hook will provide necessary properties and methods required\n * to track and manage interactions with a FunnelSubStep component.\n *\n * The `onFocus` method is used to track the beginning of interaction with the FunnelSubStep.\n * The `onBlur` method is used to track the completion of interaction with the FunnelSubStep.\n * The subStepId is a unique identifier for the funnel sub-step.\n * The subStepRef is a reference to the DOM element of the funnel sub-step.\n */\nexport const useFunnelSubStep = () => {\n const subStepRef = useRef<HTMLDivElement | null>(null);\n const context = useContext(FunnelSubStepContext);\n const { funnelInteractionId, subStepId, subStepSelector, subStepNameSelector, stepNumber, stepNameSelector } =\n context;\n\n const onFocus = (event: React.FocusEvent<HTMLDivElement>) => {\n if (\n funnelInteractionId &&\n subStepRef.current &&\n (!event.relatedTarget || !subStepRef.current.contains(event.relatedTarget as Node))\n ) {\n FunnelMetrics.funnelSubStepStart({\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n stepNumber,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n };\n\n const onBlur = (event: React.FocusEvent<HTMLDivElement>) => {\n if (funnelInteractionId && subStepRef.current && !subStepRef.current.contains(event.relatedTarget)) {\n FunnelMetrics.funnelSubStepComplete({\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n stepNumber,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n };\n\n const funnelSubStepProps: Record<string, any> = funnelInteractionId\n ? {\n 'data-analytics-funnel-substep': subStepId,\n onFocus,\n onBlur,\n }\n : {};\n\n return { funnelSubStepProps, subStepRef, ...context };\n};\n\n/**\n * Custom React Hook to manage and interact with FunnelStep.\n * This hook will provide necessary properties required to track\n * and manage interactions with a FunnelStep component.\n *\n * The 'data-analytics-funnel-step-index' property of funnelStepProps is used to track the index of the current step in the funnel.\n * The context contains additional properties of the FunnelStep.\n */\nexport const useFunnelStep = () => {\n const context = useContext(FunnelStepContext);\n const funnelStepProps: Record<string, string | number | boolean | undefined> = context.funnelInteractionId\n ? {\n 'data-analytics-funnel-step-index': context.stepNumber,\n }\n : {};\n\n return { funnelStepProps, ...context };\n};\n\n/**\n * Custom React Hook to manage and interact with Funnel.\n * This hook will provide necessary properties required to track\n * and manage interactions with a Funnel component.\n *\n * The 'data-analytics-funnel-interaction-id' property of funnelProps is used to track the unique identifier of the current interaction with the funnel.\n */\nexport const useFunnel = () => {\n const context = useContext(FunnelContext);\n const funnelProps: Record<string, string | number | boolean | undefined> = context.funnelInteractionId\n ? {\n 'data-analytics-funnel-interaction-id': context.funnelInteractionId,\n }\n : {};\n\n return { funnelProps, ...context };\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"bottom-labels.d.ts","sourceRoot":"lib/default/","sources":["internal/components/cartesian-chart/bottom-labels.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAMzD,UAAU,iBAAiB;IACzB,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,EAAE,SAAS,cAAc,EAAE,CAAC;IACjC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,MAAM,CAAC;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;;AAED,wBAAyD;AAGzD,iBAAS,YAAY,CAAC,EACpB,IAAU,EACV,KAAK,EACL,MAAM,EACN,KAAK,EACL,KAAK,EACL,aAAa,EACb,KAAK,EACL,mBAAmB,EACnB,UAAU,EACV,UAAc,EACd,WAAe,GAChB,EAAE,iBAAiB,eA+EnB"}
1
+ {"version":3,"file":"bottom-labels.d.ts","sourceRoot":"lib/default/","sources":["internal/components/cartesian-chart/bottom-labels.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAOzD,UAAU,iBAAiB;IACzB,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,EAAE,SAAS,cAAc,EAAE,CAAC;IACjC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,MAAM,CAAC;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;;AAED,wBAAyD;AAGzD,iBAAS,YAAY,CAAC,EACpB,IAAU,EACV,KAAK,EACL,MAAM,EACN,KAAK,EACL,KAAK,EACL,aAAa,EACb,KAAK,EACL,mBAAmB,EACnB,UAAU,EACV,UAAc,EACd,WAAe,GAChB,EAAE,iBAAiB,eAgFnB"}
@@ -5,9 +5,11 @@ import clsx from 'clsx';
5
5
  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
+ import { useInternalI18n } from '../../i18n/context';
8
9
  export default memo(BottomLabels);
9
10
  // Renders the visible tick labels on the bottom axis, as well as their grid lines.
10
11
  function BottomLabels({ axis = 'x', width, height, scale, ticks, tickFormatter, title, ariaRoleDescription, autoHeight, offsetLeft = 0, offsetRight = 0, }) {
12
+ const i18n = useInternalI18n('[charts]');
11
13
  const virtualTextRef = useRef(null);
12
14
  const xOffset = scale.isCategorical() && axis === 'x' ? Math.max(0, scale.d3Scale.bandwidth() - 1) / 2 : 0;
13
15
  const cacheRef = useRef({});
@@ -38,7 +40,7 @@ function BottomLabels({ axis = 'x', width, height, scale, ticks, tickFormatter,
38
40
  useEffect(() => {
39
41
  autoHeight(maxHeight);
40
42
  }, [autoHeight, maxHeight]);
41
- return (React.createElement("g", { transform: `translate(0,${height})`, className: styles['labels-bottom'], "aria-label": title, role: "list", "aria-roledescription": ariaRoleDescription, "aria-hidden": true },
43
+ return (React.createElement("g", { transform: `translate(0,${height})`, className: styles['labels-bottom'], "aria-label": title, role: "list", "aria-roledescription": i18n('i18nStrings.ariaRoleDescription', ariaRoleDescription), "aria-hidden": true },
42
44
  visibleTicks.map(({ position, lines }, index) => isFinite(position) && (React.createElement("g", { key: index, transform: `translate(${position + xOffset},0)`, className: clsx(styles.ticks, styles['ticks--bottom'], {
43
45
  [styles['ticks--x']]: axis === 'x',
44
46
  [styles['ticks--y']]: axis === 'y',
@@ -1 +1 @@
1
- {"version":3,"file":"bottom-labels.js","sourceRoot":"lib/default/","sources":["internal/components/cartesian-chart/bottom-labels.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACvD,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,EAAE,MAAM,eAAe,CAAC;AAgB7D,eAAe,IAAI,CAAC,YAAY,CAAwB,CAAC;AAEzD,mFAAmF;AACnF,SAAS,YAAY,CAAC,EACpB,IAAI,GAAG,GAAG,EACV,KAAK,EACL,MAAM,EACN,KAAK,EACL,KAAK,EACL,aAAa,EACb,KAAK,EACL,mBAAmB,EACnB,UAAU,EACV,UAAU,GAAG,CAAC,EACd,WAAW,GAAG,CAAC,GACG;IAClB,MAAM,cAAc,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAEpD,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,EAAE,IAAI,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE3G,MAAM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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, useEffect, 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 } from './label-utils';\n\ninterface BottomLabelsProps {\n axis?: 'x' | 'y';\n width: number;\n height: number;\n scale: ChartScale | NumericChartScale;\n ticks: readonly ChartDataTypes[];\n tickFormatter?: (value: ChartDataTypes) => string;\n title?: string;\n ariaRoleDescription?: string;\n autoHeight: (value: number) => void;\n offsetLeft?: number;\n offsetRight?: number;\n}\n\nexport default memo(BottomLabels) as typeof BottomLabels;\n\n// Renders the visible tick labels on the bottom axis, as well as their grid lines.\nfunction BottomLabels({\n axis = 'x',\n width,\n height,\n scale,\n ticks,\n tickFormatter,\n title,\n ariaRoleDescription,\n autoHeight,\n offsetLeft = 0,\n offsetRight = 0,\n}: BottomLabelsProps) {\n const virtualTextRef = useRef<SVGTextElement>(null);\n\n const xOffset = scale.isCategorical() && axis === 'x' ? Math.max(0, scale.d3Scale.bandwidth() - 1) / 2 : 0;\n\n const cacheRef = useRef<{ [label: string]: number }>({});\n const getLabelSpace = (label: string) => {\n if (cacheRef.current[label] !== undefined) {\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 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 let maxHeight = TICK_LENGTH + TICK_MARGIN;\n for (const { lines } of formattedTicks) {\n maxHeight = Math.max(maxHeight, TICK_LENGTH + TICK_MARGIN + lines.length * TICK_LINE_HEIGHT);\n }\n\n // Tell elements's height to the parent.\n useEffect(() => {\n autoHeight(maxHeight);\n }, [autoHeight, maxHeight]);\n\n return (\n <g\n transform={`translate(0,${height})`}\n className={styles['labels-bottom']}\n aria-label={title}\n role=\"list\"\n aria-roledescription={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
+ {"version":3,"file":"bottom-labels.js","sourceRoot":"lib/default/","sources":["internal/components/cartesian-chart/bottom-labels.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EA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\n// SPDX-License-Identifier: Apache-2.0\nimport React, { memo, useEffect, 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 } from './label-utils';\nimport { useInternalI18n } from '../../i18n/context';\n\ninterface BottomLabelsProps {\n axis?: 'x' | 'y';\n width: number;\n height: number;\n scale: ChartScale | NumericChartScale;\n ticks: readonly ChartDataTypes[];\n tickFormatter?: (value: ChartDataTypes) => string;\n title?: string;\n ariaRoleDescription?: string;\n autoHeight: (value: number) => void;\n offsetLeft?: number;\n offsetRight?: number;\n}\n\nexport default memo(BottomLabels) as typeof BottomLabels;\n\n// Renders the visible tick labels on the bottom axis, as well as their grid lines.\nfunction BottomLabels({\n axis = 'x',\n width,\n height,\n scale,\n ticks,\n tickFormatter,\n title,\n ariaRoleDescription,\n autoHeight,\n offsetLeft = 0,\n offsetRight = 0,\n}: BottomLabelsProps) {\n const i18n = useInternalI18n('[charts]');\n const virtualTextRef = useRef<SVGTextElement>(null);\n\n const xOffset = scale.isCategorical() && axis === 'x' ? Math.max(0, scale.d3Scale.bandwidth() - 1) / 2 : 0;\n\n const cacheRef = useRef<{ [label: string]: number }>({});\n const getLabelSpace = (label: string) => {\n if (cacheRef.current[label] !== undefined) {\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 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 let maxHeight = TICK_LENGTH + TICK_MARGIN;\n for (const { lines } of formattedTicks) {\n maxHeight = Math.max(maxHeight, TICK_LENGTH + TICK_MARGIN + lines.length * TICK_LINE_HEIGHT);\n }\n\n // Tell elements's height to the parent.\n useEffect(() => {\n autoHeight(maxHeight);\n }, [autoHeight, maxHeight]);\n\n return (\n <g\n transform={`translate(0,${height})`}\n className={styles['labels-bottom']}\n aria-label={title}\n role=\"list\"\n aria-roledescription={i18n('i18nStrings.ariaRoleDescription', 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"]}
@@ -57,6 +57,7 @@ export interface CartesianChartProps<T extends ChartDataTypes, Series> extends B
57
57
  ariaDescription?: string;
58
58
  /**
59
59
  * An object containing all the necessary localized strings required by the component.
60
+ * @i18n
60
61
  */
61
62
  i18nStrings?: CartesianChartProps.I18nStrings<T>;
62
63
  /**
@@ -114,14 +115,17 @@ export interface CartesianChartProps<T extends ChartDataTypes, Series> extends B
114
115
  noMatch?: React.ReactNode;
115
116
  /**
116
117
  * Text that is displayed when the chart is loading, i.e. when `statusType` is set to `"loading"`.
118
+ * @i18n
117
119
  */
118
120
  loadingText?: string;
119
121
  /**
120
122
  * Text that is displayed when the chart is in error state, i.e. when `statusType` is set to `"error"`.
123
+ * @i18n
121
124
  */
122
125
  errorText?: string;
123
126
  /**
124
127
  * Text for the recovery button that is displayed next to the error text.
128
+ * @i18n
125
129
  **/
126
130
  recoveryText?: string;
127
131
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"lib/default/","sources":["internal/components/cartesian-chart/interfaces.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,cAAc,EAAE,MAAM,CAAE,SAAQ,kBAAkB;IAC/F;;OAEG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;IAEvB;;OAEG;IACH,UAAU,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IAE9B;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,CAAC,SAAS,OAAO,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IAElE;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAEhC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,WAAW,CAAC,EAAE,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAEjD;;;OAGG;IACH,MAAM,CAAC,EAAE,M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AC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AAC5G,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,cAAc,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;AAC/D,MAAM,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["internal/components/cartesian-chart/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../../base-component';\nimport { NonCancelableEventHandler } from '../../events';\n\nexport interface CartesianChartProps<T extends ChartDataTypes, Series> extends BaseComponentProps {\n /**\n * Determines the type of scale for values on the x axis.\n */\n xScaleType?: ScaleType;\n\n /**\n * Determines the type of scale for values on the y axis.\n */\n yScaleType?: 'linear' | 'log';\n\n /**\n * Determines the domain of the x axis, i.e. the range of values that will be visible in the chart.\n * For numerical and time-based data this is represented as an array with two values: `[minimumValue, maximumValue]`.\n * For categorical data this is represented as an array of strings that determine the categories to display.\n *\n * It is recommended to set this explicitly. If not, the component will determine a domain that fits all data points.\n * When controlling this directly, make sure to update the value based on filtering changes.\n */\n xDomain?: T extends unknown ? ReadonlyArray<T> : ReadonlyArray<T>;\n\n /**\n * Determines the domain of the y axis, i.e. the range of values that will be visible in the chart.\n * The domain is defined by a tuple: `[minimumValue, maximumValue]`.\n *\n * It is recommended to set this explicitly. If not, the component will determine a domain that fits all data points.\n * When controlling this directly, make sure to update the value based on filtering changes.\n */\n yDomain?: ReadonlyArray<number>;\n\n /**\n * The title of the x axis.\n */\n xTitle?: string;\n\n /**\n * The title of the y axis.\n */\n yTitle?: string;\n\n /**\n * Optional title for the legend.\n */\n legendTitle?: string;\n\n /**\n * ARIA label that is assigned to the chart itself. It should match the visible label on the page, e.g. in the container header.\n * Do not use `ariaLabel` and `ariaLabelledby` at the same time.\n */\n ariaLabel?: string;\n\n /**\n * Sets `aria-labelledby` on the chart itself.\n * If there is a visible label for the chart on the page, e.g. in the container header, set this property to the ID of that header element.\n * Do not use `ariaLabel` and `ariaLabelledby` at the same time.\n */\n ariaLabelledby?: string;\n\n /**\n * A description of the chart that assistive technologies can use (through `aria-describedby`).\n * Provide a concise summary of the data visualized in the chart.\n */\n ariaDescription?: string;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n */\n i18nStrings?: CartesianChartProps.I18nStrings<T>;\n\n /**\n * An optional pixel value number that fixes the height of the chart area.\n * If not set explicitly, the component will use a default height that is defined internally.\n */\n height?: number;\n\n /**\n * Determines the maximum width the detail popover will be limited to.\n */\n detailPopoverSize?: 'small' | 'medium' | 'large';\n\n /**\n * When set to `true`, the legend beneath the chart is not displayed.\n * It is highly recommended to keep this set to `false`.\n */\n hideLegend?: boolean;\n\n /**\n * When set to `true`, the default filtering dropdown is not displayed.\n * It is still possible to render additional filters with the `additionalFilters` slot.\n */\n hideFilter?: boolean;\n\n /**\n * Additional filters that are added above the chart component.\n * Make sure to update the `data` property when any of your custom filters change the data to be displayed.\n */\n additionalFilters?: React.ReactNode;\n\n /**\n * The currently highlighted data series, usually through hovering over a series or the legend.\n * A value of `null` means no series is highlighted.\n *\n * - If you do not set this property, series are highlighted automatically when hovering over one of the triggers (uncontrolled behavior).\n * - If you explicitly set this property, you must set an `onHighlightChange` listener to update this property when a series should be highlighted (controlled behavior).\n */\n highlightedSeries?: Series | null;\n\n /**\n * An array of series objects that determines which of the data series are currently displayed, i.e. not filtered out.\n * - If you do not set this property, series are shown and hidden automatically when using the default filter component (uncontrolled behavior).\n * - If you explicitly set this property, you must set an `onFilterChange` listener to update this property when the visible series should change, or when one of your custom filters changes the number of visible series (controlled behavior).\n */\n visibleSeries?: ReadonlyArray<Series>;\n\n /**\n * Specifies the current status of loading data.\n * * `loading`: data fetching is in progress.\n * * `finished`: data has loaded successfully.\n * * `error`: an error occurred during fetch. You should provide user an option to recover.\n **/\n statusType?: 'loading' | 'finished' | 'error';\n\n /**\n * Content that is displayed when the data passed to the component is empty.\n */\n empty?: React.ReactNode;\n\n /**\n * Content that is displayed when there is no data to display due to the built-in filtering.\n */\n noMatch?: React.ReactNode;\n\n /**\n * Text that is displayed when the chart is loading, i.e. when `statusType` is set to `\"loading\"`.\n */\n loadingText?: string;\n\n /**\n * Text that is displayed when the chart is in error state, i.e. when `statusType` is set to `\"error\"`.\n */\n errorText?: string;\n\n /**\n * Text for the recovery button that is displayed next to the error text.\n **/\n recoveryText?: string;\n\n /**\n * Called when the user clicks the recovery button that appears when there is an error state.\n * Use this to enable the user to retry a failed request or provide another option for the user\n * to recover from the error.\n */\n onRecoveryClick?: NonCancelableEventHandler;\n\n /**\n * Called when the values of the internal filter component changed.\n * This will **not** be called for any custom filter components you have defined in `additionalFilters`.\n */\n onFilterChange?: NonCancelableEventHandler<CartesianChartProps.FilterChangeDetail<Series>>;\n\n /**\n * Called when the highlighted series has changed because of user interaction.\n */\n onHighlightChange?: NonCancelableEventHandler<CartesianChartProps.HighlightChangeDetail<Series>>;\n}\n\nexport namespace CartesianChartProps {\n export interface FilterChangeDetail<Series> {\n visibleSeries: ReadonlyArray<Series>;\n }\n\n export interface HighlightChangeDetail<Series> {\n highlightedSeries: Series | null;\n }\n\n export interface TickFormatter<T> {\n (value: T): string;\n }\n\n export interface ValueFormatter<YType, XType = null> {\n (yValue: YType, xValue: XType): string;\n }\n\n export interface I18nStrings<T> {\n /** Visible label of the default filter */\n filterLabel?: string;\n\n /** Placeholder text of the default filter */\n filterPlaceholder?: string;\n\n /** ARIA label for the default filter which is appended to any option that is selected */\n filterSelectedAriaLabel?: string;\n\n /** ARIA label that is associated with the legend in case there is no visible `legendTitle` defined */\n legendAriaLabel?: string;\n\n /** ARIA label for details popover dismiss button */\n detailPopoverDismissAriaLabel?: string;\n\n /** Name of the ARIA role description of the chart, e.g. \"line chart\" */\n chartAriaRoleDescription?: string;\n\n /** Name of the ARIA role description of the x axis, e.g. \"x axis\" */\n xAxisAriaRoleDescription?: string;\n\n /** Name of the ARIA role description of the y axis, e.g. \"y axis\" */\n yAxisAriaRoleDescription?: string;\n\n /** Function to format the displayed label of an x axis tick. */\n xTickFormatter?: TickFormatter<T>;\n\n /** Function to format the displayed label of a y axis tick. */\n yTickFormatter?: TickFormatter<number>;\n }\n}\n\nexport type ChartDataTypes = number | string | Date;\n\nexport type ScaleType = 'linear' | 'log' | 'time' | 'categorical';\nexport type XScaleType = 'linear' | 'log' | 'time' | 'categorical';\nexport type YScaleType = 'linear' | 'log';\nexport type ScaleRange = [number, number];\n\nexport type ChartDomain<T extends ChartDataTypes> = T extends unknown ? ReadonlyArray<T> : ReadonlyArray<T>;\nexport type XDomain<T extends ChartDataTypes> = ChartDomain<T>;\nexport type YDomain = ChartDomain<number>;\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["internal/components/cartesian-chart/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../../base-component';\nimport { NonCancelableEventHandler } from '../../events';\n\nexport interface CartesianChartProps<T extends ChartDataTypes, Series> extends BaseComponentProps {\n /**\n * Determines the type of scale for values on the x axis.\n */\n xScaleType?: ScaleType;\n\n /**\n * Determines the type of scale for values on the y axis.\n */\n yScaleType?: 'linear' | 'log';\n\n /**\n * Determines the domain of the x axis, i.e. the range of values that will be visible in the chart.\n * For numerical and time-based data this is represented as an array with two values: `[minimumValue, maximumValue]`.\n * For categorical data this is represented as an array of strings that determine the categories to display.\n *\n * It is recommended to set this explicitly. If not, the component will determine a domain that fits all data points.\n * When controlling this directly, make sure to update the value based on filtering changes.\n */\n xDomain?: T extends unknown ? ReadonlyArray<T> : ReadonlyArray<T>;\n\n /**\n * Determines the domain of the y axis, i.e. the range of values that will be visible in the chart.\n * The domain is defined by a tuple: `[minimumValue, maximumValue]`.\n *\n * It is recommended to set this explicitly. If not, the component will determine a domain that fits all data points.\n * When controlling this directly, make sure to update the value based on filtering changes.\n */\n yDomain?: ReadonlyArray<number>;\n\n /**\n * The title of the x axis.\n */\n xTitle?: string;\n\n /**\n * The title of the y axis.\n */\n yTitle?: string;\n\n /**\n * Optional title for the legend.\n */\n legendTitle?: string;\n\n /**\n * ARIA label that is assigned to the chart itself. It should match the visible label on the page, e.g. in the container header.\n * Do not use `ariaLabel` and `ariaLabelledby` at the same time.\n */\n ariaLabel?: string;\n\n /**\n * Sets `aria-labelledby` on the chart itself.\n * If there is a visible label for the chart on the page, e.g. in the container header, set this property to the ID of that header element.\n * Do not use `ariaLabel` and `ariaLabelledby` at the same time.\n */\n ariaLabelledby?: string;\n\n /**\n * A description of the chart that assistive technologies can use (through `aria-describedby`).\n * Provide a concise summary of the data visualized in the chart.\n */\n ariaDescription?: string;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n * @i18n\n */\n i18nStrings?: CartesianChartProps.I18nStrings<T>;\n\n /**\n * An optional pixel value number that fixes the height of the chart area.\n * If not set explicitly, the component will use a default height that is defined internally.\n */\n height?: number;\n\n /**\n * Determines the maximum width the detail popover will be limited to.\n */\n detailPopoverSize?: 'small' | 'medium' | 'large';\n\n /**\n * When set to `true`, the legend beneath the chart is not displayed.\n * It is highly recommended to keep this set to `false`.\n */\n hideLegend?: boolean;\n\n /**\n * When set to `true`, the default filtering dropdown is not displayed.\n * It is still possible to render additional filters with the `additionalFilters` slot.\n */\n hideFilter?: boolean;\n\n /**\n * Additional filters that are added above the chart component.\n * Make sure to update the `data` property when any of your custom filters change the data to be displayed.\n */\n additionalFilters?: React.ReactNode;\n\n /**\n * The currently highlighted data series, usually through hovering over a series or the legend.\n * A value of `null` means no series is highlighted.\n *\n * - If you do not set this property, series are highlighted automatically when hovering over one of the triggers (uncontrolled behavior).\n * - If you explicitly set this property, you must set an `onHighlightChange` listener to update this property when a series should be highlighted (controlled behavior).\n */\n highlightedSeries?: Series | null;\n\n /**\n * An array of series objects that determines which of the data series are currently displayed, i.e. not filtered out.\n * - If you do not set this property, series are shown and hidden automatically when using the default filter component (uncontrolled behavior).\n * - If you explicitly set this property, you must set an `onFilterChange` listener to update this property when the visible series should change, or when one of your custom filters changes the number of visible series (controlled behavior).\n */\n visibleSeries?: ReadonlyArray<Series>;\n\n /**\n * Specifies the current status of loading data.\n * * `loading`: data fetching is in progress.\n * * `finished`: data has loaded successfully.\n * * `error`: an error occurred during fetch. You should provide user an option to recover.\n **/\n statusType?: 'loading' | 'finished' | 'error';\n\n /**\n * Content that is displayed when the data passed to the component is empty.\n */\n empty?: React.ReactNode;\n\n /**\n * Content that is displayed when there is no data to display due to the built-in filtering.\n */\n noMatch?: React.ReactNode;\n\n /**\n * Text that is displayed when the chart is loading, i.e. when `statusType` is set to `\"loading\"`.\n * @i18n\n */\n loadingText?: string;\n\n /**\n * Text that is displayed when the chart is in error state, i.e. when `statusType` is set to `\"error\"`.\n * @i18n\n */\n errorText?: string;\n\n /**\n * Text for the recovery button that is displayed next to the error text.\n * @i18n\n **/\n recoveryText?: string;\n\n /**\n * Called when the user clicks the recovery button that appears when there is an error state.\n * Use this to enable the user to retry a failed request or provide another option for the user\n * to recover from the error.\n */\n onRecoveryClick?: NonCancelableEventHandler;\n\n /**\n * Called when the values of the internal filter component changed.\n * This will **not** be called for any custom filter components you have defined in `additionalFilters`.\n */\n onFilterChange?: NonCancelableEventHandler<CartesianChartProps.FilterChangeDetail<Series>>;\n\n /**\n * Called when the highlighted series has changed because of user interaction.\n */\n onHighlightChange?: NonCancelableEventHandler<CartesianChartProps.HighlightChangeDetail<Series>>;\n}\n\nexport namespace CartesianChartProps {\n export interface FilterChangeDetail<Series> {\n visibleSeries: ReadonlyArray<Series>;\n }\n\n export interface HighlightChangeDetail<Series> {\n highlightedSeries: Series | null;\n }\n\n export interface TickFormatter<T> {\n (value: T): string;\n }\n\n export interface ValueFormatter<YType, XType = null> {\n (yValue: YType, xValue: XType): string;\n }\n\n export interface I18nStrings<T> {\n /** Visible label of the default filter */\n filterLabel?: string;\n\n /** Placeholder text of the default filter */\n filterPlaceholder?: string;\n\n /** ARIA label for the default filter which is appended to any option that is selected */\n filterSelectedAriaLabel?: string;\n\n /** ARIA label that is associated with the legend in case there is no visible `legendTitle` defined */\n legendAriaLabel?: string;\n\n /** ARIA label for details popover dismiss button */\n detailPopoverDismissAriaLabel?: string;\n\n /** Name of the ARIA role description of the chart, e.g. \"line chart\" */\n chartAriaRoleDescription?: string;\n\n /** Name of the ARIA role description of the x axis, e.g. \"x axis\" */\n xAxisAriaRoleDescription?: string;\n\n /** Name of the ARIA role description of the y axis, e.g. \"y axis\" */\n yAxisAriaRoleDescription?: string;\n\n /** Function to format the displayed label of an x axis tick. */\n xTickFormatter?: TickFormatter<T>;\n\n /** Function to format the displayed label of a y axis tick. */\n yTickFormatter?: TickFormatter<number>;\n }\n}\n\nexport type ChartDataTypes = number | string | Date;\n\nexport type ScaleType = 'linear' | 'log' | 'time' | 'categorical';\nexport type XScaleType = 'linear' | 'log' | 'time' | 'categorical';\nexport type YScaleType = 'linear' | 'log';\nexport type ScaleRange = [number, number];\n\nexport type ChartDomain<T extends ChartDataTypes> = T extends unknown ? ReadonlyArray<T> : ReadonlyArray<T>;\nexport type XDomain<T extends ChartDataTypes> = ChartDomain<T>;\nexport type YDomain = ChartDomain<number>;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"left-labels.d.ts","sourceRoot":"lib/default/","sources":["internal/components/cartesian-chart/left-labels.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAKzD,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAI1E,UAAU,eAAe;IACvB,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,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,wBAAqD;AAGrD,iBAAS,UAAU,CAAC,EAClB,IAAU,EACV,KAAK,EACL,MAAM,EACN,KAAK,EACL,KAAK,EACL,aAAa,EACb,KAAK,EACL,mBAAmB,GACpB,EAAE,eAAe,eAiEjB"}
1
+ {"version":3,"file":"left-labels.d.ts","sourceRoot":"lib/default/","sources":["internal/components/cartesian-chart/left-labels.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAKzD,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAK1E,UAAU,eAAe;IACvB,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,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,wBAAqD;AAGrD,iBAAS,UAAU,CAAC,EAClB,IAAU,EACV,KAAK,EACL,MAAM,EACN,KAAK,EACL,KAAK,EACL,aAAa,EACb,KAAK,EACL,mBAAmB,GACpB,EAAE,eAAe,eAkEjB"}
@@ -5,10 +5,12 @@ import clsx from 'clsx';
5
5
  import { TICK_LENGTH, TICK_MARGIN } from './constants';
6
6
  import styles from './styles.css.js';
7
7
  import { formatTicks, getVisibleTicks } from './label-utils';
8
+ import { useInternalI18n } from '../../i18n/context';
8
9
  const OFFSET_PX = 12;
9
10
  export default memo(LeftLabels);
10
11
  // Renders the visible tick labels on the left axis, as well as their grid lines.
11
12
  function LeftLabels({ axis = 'y', width, height, scale, ticks, tickFormatter, title, ariaRoleDescription, }) {
13
+ const i18n = useInternalI18n('[charts]');
12
14
  const virtualTextRef = useRef(null);
13
15
  const yOffset = axis === 'x' && scale.isCategorical() ? Math.max(0, scale.d3Scale.bandwidth() - 1) / 2 : 0;
14
16
  const cacheRef = useRef({});
@@ -30,7 +32,7 @@ function LeftLabels({ axis = 'y', width, height, scale, ticks, tickFormatter, ti
30
32
  const from = 0 - OFFSET_PX - yOffset;
31
33
  const until = height + OFFSET_PX - yOffset;
32
34
  const visibleTicks = getVisibleTicks(formattedTicks, from, until);
33
- return (React.createElement("g", { className: clsx(styles['labels-left']), "aria-label": title, role: "list", "aria-roledescription": ariaRoleDescription, "aria-hidden": true },
35
+ return (React.createElement("g", { className: clsx(styles['labels-left']), "aria-label": title, role: "list", "aria-roledescription": i18n('i18nStrings.ariaRoleDescription', ariaRoleDescription), "aria-hidden": true },
34
36
  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']) },
35
37
  axis === 'y' && (React.createElement("line", { className: clsx(styles.grid, styles.ticks_line), x1: -TICK_LENGTH, y1: 0, x2: width, y2: 0, "aria-hidden": "true" })),
36
38
  React.createElement("text", { className: styles.ticks__text, x: -(TICK_LENGTH + TICK_MARGIN), y: 0 }, lines.join(' '))))),
@@ -1 +1 @@
1
- {"version":3,"file":"left-labels.js","sourceRoot":"lib/default/","sources":["internal/components/cartesian-chart/left-labels.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,IAAI,MAAM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W,EAAE,CAAC,EAAE,CAAC,CAAC,WAAW,GAAG,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC,IACvE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CACX,CACL,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_MARGIN } from './constants';\n\nimport styles from './styles.css.js';\nimport { formatTicks, getVisibleTicks } from './label-utils';\nimport { ChartDataTypes } from '../../../mixed-line-bar-chart/interfaces';\n\nconst OFFSET_PX = 12;\n\ninterface LeftLabelsProps {\n axis?: 'x' | 'y';\n width: number;\n height: 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(LeftLabels) as typeof LeftLabels;\n\n// Renders the visible tick labels on the left axis, as well as their grid lines.\nfunction LeftLabels({\n axis = 'y',\n width,\n height,\n scale,\n ticks,\n tickFormatter,\n title,\n ariaRoleDescription,\n}: LeftLabelsProps) {\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 cacheRef = useRef<{ [label: string]: number }>({});\n const getLabelSpace = (label: string) => {\n if (cacheRef.current[label] !== undefined) {\n return cacheRef.current[label];\n }\n if (virtualTextRef.current && virtualTextRef.current.getBBox) {\n virtualTextRef.current.textContent = label;\n cacheRef.current[label] = virtualTextRef.current.getBBox().height;\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 const from = 0 - OFFSET_PX - yOffset;\n const until = height + OFFSET_PX - yOffset;\n const visibleTicks = getVisibleTicks(formattedTicks, from, until);\n\n return (\n <g\n className={clsx(styles['labels-left'])}\n aria-label={title}\n role=\"list\"\n aria-roledescription={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={width}\n y2={0}\n aria-hidden=\"true\"\n />\n )}\n <text className={styles.ticks__text} x={-(TICK_LENGTH + TICK_MARGIN)} y={0}>\n {lines.join(' ')}\n </text>\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
+ {"version":3,"file":"left-labels.js","sourceRoot":"lib/default/","sources":["internal/components/cartesian-chart/left-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,WAAW,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,SAAS,GAAG,E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,CAAC,CACX,CACL,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_MARGIN } from './constants';\n\nimport styles from './styles.css.js';\nimport { formatTicks, getVisibleTicks } from './label-utils';\nimport { ChartDataTypes } from '../../../mixed-line-bar-chart/interfaces';\nimport { useInternalI18n } from '../../i18n/context';\n\nconst OFFSET_PX = 12;\n\ninterface LeftLabelsProps {\n axis?: 'x' | 'y';\n width: number;\n height: 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(LeftLabels) as typeof LeftLabels;\n\n// Renders the visible tick labels on the left axis, as well as their grid lines.\nfunction LeftLabels({\n axis = 'y',\n width,\n height,\n scale,\n ticks,\n tickFormatter,\n title,\n ariaRoleDescription,\n}: LeftLabelsProps) {\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 cacheRef = useRef<{ [label: string]: number }>({});\n const getLabelSpace = (label: string) => {\n if (cacheRef.current[label] !== undefined) {\n return cacheRef.current[label];\n }\n if (virtualTextRef.current && virtualTextRef.current.getBBox) {\n virtualTextRef.current.textContent = label;\n cacheRef.current[label] = virtualTextRef.current.getBBox().height;\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 const from = 0 - OFFSET_PX - yOffset;\n const until = height + OFFSET_PX - yOffset;\n const visibleTicks = getVisibleTicks(formattedTicks, from, until);\n\n return (\n <g\n className={clsx(styles['labels-left'])}\n aria-label={title}\n role=\"list\"\n aria-roledescription={i18n('i18nStrings.ariaRoleDescription', 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={width}\n y2={0}\n aria-hidden=\"true\"\n />\n )}\n <text className={styles.ticks__text} x={-(TICK_LENGTH + TICK_MARGIN)} y={0}>\n {lines.join(' ')}\n </text>\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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["internal/components/chart-filter/index.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,kBAAkB,EAAgB,MAAM,sBAAsB,CAAC;AAExE,OAAqB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAI7E,UAAU,WAAW;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,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;CAC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D,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;;AAED,wBAAuD;AAEvD,iBAAS,WAAW,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,eA6C3G"}
@@ -7,12 +7,14 @@ import InternalFormField from '../../../form-field/internal';
7
7
  import InternalMultiselect from '../../../multiselect/internal';
8
8
  import { getBaseProps } from '../../base-component';
9
9
  import SeriesMarker from '../chart-series-marker';
10
+ import { useInternalI18n } from '../../i18n/context';
10
11
  import styles from './styles.css.js';
11
12
  export default memo(ChartFilter);
12
13
  function ChartFilter(_a) {
13
14
  var { series, i18nStrings, selectedSeries, onChange } = _a, restProps = __rest(_a, ["series", "i18nStrings", "selectedSeries", "onChange"]);
14
15
  const baseProps = getBaseProps(restProps);
15
16
  const className = clsx(baseProps.className, styles.root);
17
+ const i18n = useInternalI18n('[charts]');
16
18
  const defaultOptions = series.map((d, i) => ({
17
19
  label: d.label,
18
20
  value: '' + i,
@@ -27,7 +29,7 @@ function ChartFilter(_a) {
27
29
  .map(option => option.datum);
28
30
  onChange(selectedSeries);
29
31
  }, [onChange, defaultOptions]);
30
- return (React.createElement(InternalFormField, Object.assign({}, baseProps, { label: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.filterLabel, className: className }),
31
- React.createElement(InternalMultiselect, { placeholder: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.filterPlaceholder, options: defaultOptions, selectedOptions: selectedOptions, onChange: updateSelection, className: styles['chart-filter'], selectedAriaLabel: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.filterSelectedAriaLabel, hideTokens: true })));
32
+ return (React.createElement(InternalFormField, Object.assign({}, baseProps, { label: i18n('i18nStrings.filterLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.filterLabel), className: className }),
33
+ React.createElement(InternalMultiselect, { placeholder: i18n('i18nStrings.filterPlaceholder', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.filterPlaceholder), options: defaultOptions, selectedOptions: selectedOptions, onChange: updateSelection, className: styles['chart-filter'], selectedAriaLabel: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.filterSelectedAriaLabel, hideTokens: true })));
32
34
  }
33
35
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["internal/components/chart-filter/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAGjD,OAAO,iBAAiB,MAAM,8BAA8B,CAAC;AAC7D,OAAO,mBAAmB,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAsB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,YAAuC,MAAM,wBAAwB,CAAC;AAE7E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAsBrC,eAAe,IAAI,CAAC,WAAW,CAAuB,CAAC;AAEvD,SAAS,WAAW,CAAI,EAAoF;QAApF,EAAE,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,QAAQ,OAAqC,EAAhC,SAAS,cAA7D,uDAA+D,CAAF;IACnF,MAAM,SAAS,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1C,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAEzD,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAC3C,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,KAAK,EAAE,EAAE,GAAG,CAAC;QACb,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,YAAY,EAAE,CACZ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ent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React, { useCallback, memo } from 'react';\n\nimport { NonCancelableEventHandler } from '../../events';\nimport InternalFormField from '../../../form-field/internal';\nimport InternalMultiselect from '../../../multiselect/internal';\nimport { BaseComponentProps, getBaseProps } from '../../base-component';\nimport { MultiselectProps } from '../../../multiselect/interfaces';\nimport SeriesMarker, { ChartSeriesMarkerType } from '../chart-series-marker';\n\nimport styles from './styles.css.js';\n\ninterface I18nStrings {\n filterLabel?: string;\n filterPlaceholder?: string;\n filterSelectedAriaLabel?: string;\n}\n\nexport interface ChartFilterItem<T> {\n label: string;\n color: string;\n type: ChartSeriesMarkerType;\n datum: T;\n}\n\nexport interface ChartFilterProps<T> extends BaseComponentProps {\n series: ReadonlyArray<ChartFilterItem<T>>;\n selectedSeries?: ReadonlyArray<T>;\n onChange: (selectedSeries: ReadonlyArray<T>) => void;\n i18nStrings?: I18nStrings;\n}\n\nexport default memo(ChartFilter) as typeof ChartFilter;\n\nfunction ChartFilter<T>({ series, i18nStrings, selectedSeries, onChange, ...restProps }: ChartFilterProps<T>) {\n const baseProps = getBaseProps(restProps);\n const className = clsx(baseProps.className, styles.root);\n\n const defaultOptions = series.map((d, i) => ({\n label: d.label,\n value: '' + i,\n datum: d.datum,\n __customIcon: (\n <span className={styles['custom-icon-wrapper']}>\n <SeriesMarker color={d.color} type={d.type} />\n </span>\n ),\n }));\n\n const selectedOptions = defaultOptions.filter(option => selectedSeries?.indexOf(option.datum) !== -1);\n\n const updateSelection = useCallback<NonCancelableEventHandler<MultiselectProps.MultiselectChangeDetail>>(\n ({ detail: { selectedOptions } }) => {\n const selectedSeries = defaultOptions\n .filter(option => selectedOptions.indexOf(option) !== -1)\n .map(option => option.datum);\n onChange(selectedSeries);\n },\n [onChange, defaultOptions]\n );\n\n return (\n <InternalFormField {...baseProps} label={i18nStrings?.filterLabel} className={className}>\n <InternalMultiselect\n placeholder={i18nStrings?.filterPlaceholder}\n options={defaultOptions}\n selectedOptions={selectedOptions}\n onChange={updateSelection}\n className={styles['chart-filter']}\n selectedAriaLabel={i18nStrings?.filterSelectedAriaLabel}\n hideTokens={true}\n />\n </InternalFormField>\n );\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["internal/components/chart-filter/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAGjD,OAAO,iBAAiB,MAAM,8BAA8B,CAAC;AAC7D,OAAO,mBAAmB,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAsB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,YAAuC,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAsBrC,eAAe,IAAI,CAAC,WAAW,CAAuB,CAAC;AAEvD,SAAS,WAAW,CAAI,EAAoF;QAApF,EAAE,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,QAAQ,OAAqC,EAAhC,SAAS,cAA7D,uDAA+D,CAAF;IACnF,MAAM,SAAS,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1C,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACzD,MAAM,IAAI,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;IAEzC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAC3C,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,KAAK,EAAE,EAAE,GAAG,CAAC;QACb,KAAK,EAAE,CAAC,CAAC,KAAK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AAW,CAAE,uBAAuB,EACvD,UAAU,EAAE,IAAI,GAChB,CACgB,CACrB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React, { useCallback, memo } from 'react';\n\nimport { NonCancelableEventHandler } from '../../events';\nimport InternalFormField from '../../../form-field/internal';\nimport InternalMultiselect from '../../../multiselect/internal';\nimport { BaseComponentProps, getBaseProps } from '../../base-component';\nimport { MultiselectProps } from '../../../multiselect/interfaces';\nimport SeriesMarker, { ChartSeriesMarkerType } from '../chart-series-marker';\nimport { useInternalI18n } from '../../i18n/context';\n\nimport styles from './styles.css.js';\n\ninterface I18nStrings {\n filterLabel?: string;\n filterPlaceholder?: string;\n filterSelectedAriaLabel?: string;\n}\n\nexport interface ChartFilterItem<T> {\n label: string;\n color: string;\n type: ChartSeriesMarkerType;\n datum: T;\n}\n\nexport interface ChartFilterProps<T> extends BaseComponentProps {\n series: ReadonlyArray<ChartFilterItem<T>>;\n selectedSeries?: ReadonlyArray<T>;\n onChange: (selectedSeries: ReadonlyArray<T>) => void;\n i18nStrings?: I18nStrings;\n}\n\nexport default memo(ChartFilter) as typeof ChartFilter;\n\nfunction ChartFilter<T>({ series, i18nStrings, selectedSeries, onChange, ...restProps }: ChartFilterProps<T>) {\n const baseProps = getBaseProps(restProps);\n const className = clsx(baseProps.className, styles.root);\n const i18n = useInternalI18n('[charts]');\n\n const defaultOptions = series.map((d, i) => ({\n label: d.label,\n value: '' + i,\n datum: d.datum,\n __customIcon: (\n <span className={styles['custom-icon-wrapper']}>\n <SeriesMarker color={d.color} type={d.type} />\n </span>\n ),\n }));\n\n const selectedOptions = defaultOptions.filter(option => selectedSeries?.indexOf(option.datum) !== -1);\n\n const updateSelection = useCallback<NonCancelableEventHandler<MultiselectProps.MultiselectChangeDetail>>(\n ({ detail: { selectedOptions } }) => {\n const selectedSeries = defaultOptions\n .filter(option => selectedOptions.indexOf(option) !== -1)\n .map(option => option.datum);\n onChange(selectedSeries);\n },\n [onChange, defaultOptions]\n );\n\n return (\n <InternalFormField\n {...baseProps}\n label={i18n('i18nStrings.filterLabel', i18nStrings?.filterLabel)}\n className={className}\n >\n <InternalMultiselect\n placeholder={i18n('i18nStrings.filterPlaceholder', i18nStrings?.filterPlaceholder)}\n options={defaultOptions}\n selectedOptions={selectedOptions}\n onChange={updateSelection}\n className={styles['chart-filter']}\n selectedAriaLabel={i18nStrings?.filterSelectedAriaLabel}\n hideTokens={true}\n />\n </InternalFormField>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["internal/components/chart-legend/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAuB,MAAM,OAAO,CAAC;AAI5C,OAAqB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAG7E,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,eAuHrB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["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"}
@@ -6,8 +6,10 @@ import InternalBox from '../../../box/internal';
6
6
  import { KeyCode } from '../../keycode';
7
7
  import SeriesMarker from '../chart-series-marker';
8
8
  import styles from './styles.css.js';
9
+ import { useInternalI18n } from '../../i18n/context';
9
10
  export default memo(ChartLegend);
10
11
  function ChartLegend({ series, onHighlightChange, highlightedSeries, legendTitle, ariaLabel, plotContainerRef, }) {
12
+ const i18n = useInternalI18n('[charts]');
11
13
  const containerRef = useRef(null);
12
14
  const segmentsRef = useRef([]);
13
15
  const highlightedSeriesIndex = findSeriesIndex(series, highlightedSeries);
@@ -63,7 +65,7 @@ function ChartLegend({ series, onHighlightChange, highlightedSeries, legendTitle
63
65
  onHighlightChange(null);
64
66
  };
65
67
  return (React.createElement(React.Fragment, null,
66
- React.createElement("div", { ref: containerRef, role: "toolbar", "aria-label": legendTitle || ariaLabel, className: styles.root, onKeyDown: handleKeyPress, onBlur: handleBlur },
68
+ React.createElement("div", { ref: containerRef, role: "toolbar", "aria-label": legendTitle || i18n('i18nStrings.legendAriaLabel', ariaLabel), className: styles.root, onKeyDown: handleKeyPress, onBlur: handleBlur },
67
69
  legendTitle && (React.createElement(InternalBox, { fontWeight: "bold", className: styles.title }, legendTitle)),
68
70
  React.createElement("div", { className: styles.list }, series.map((s, index) => {
69
71
  const someHighlighted = highlightedSeries !== null;