@cloudscape-design/components 3.0.363 → 3.0.365

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 (96) hide show
  1. package/alert/internal.d.ts.map +1 -1
  2. package/alert/internal.js +13 -14
  3. package/alert/internal.js.map +1 -1
  4. package/alert/styles.css.js +25 -25
  5. package/alert/styles.scoped.css +52 -66
  6. package/alert/styles.selectors.js +25 -25
  7. package/breadcrumb-group/internal.d.ts.map +1 -1
  8. package/breadcrumb-group/internal.js +5 -5
  9. package/breadcrumb-group/internal.js.map +1 -1
  10. package/button-dropdown/interfaces.d.ts +9 -1
  11. package/button-dropdown/interfaces.d.ts.map +1 -1
  12. package/button-dropdown/interfaces.js.map +1 -1
  13. package/button-dropdown/internal.d.ts.map +1 -1
  14. package/button-dropdown/internal.js +9 -2
  15. package/button-dropdown/internal.js.map +1 -1
  16. package/button-dropdown/styles.css.js +15 -14
  17. package/button-dropdown/styles.scoped.css +25 -21
  18. package/button-dropdown/styles.selectors.js +15 -14
  19. package/form/index.d.ts.map +1 -1
  20. package/form/index.js +2 -1
  21. package/form/index.js.map +1 -1
  22. package/internal/analytics/components/analytics-funnel.d.ts +1 -1
  23. package/internal/analytics/components/analytics-funnel.d.ts.map +1 -1
  24. package/internal/analytics/components/analytics-funnel.js +92 -26
  25. package/internal/analytics/components/analytics-funnel.js.map +1 -1
  26. package/internal/analytics/context/analytics-context.d.ts +4 -0
  27. package/internal/analytics/context/analytics-context.d.ts.map +1 -1
  28. package/internal/analytics/context/analytics-context.js +4 -0
  29. package/internal/analytics/context/analytics-context.js.map +1 -1
  30. package/internal/analytics/hooks/use-funnel.d.ts +2 -0
  31. package/internal/analytics/hooks/use-funnel.d.ts.map +1 -1
  32. package/internal/components/menu-dropdown/index.d.ts +1 -1
  33. package/internal/components/menu-dropdown/index.d.ts.map +1 -1
  34. package/internal/components/menu-dropdown/index.js +7 -5
  35. package/internal/components/menu-dropdown/index.js.map +1 -1
  36. package/internal/components/menu-dropdown/interfaces.d.ts +1 -0
  37. package/internal/components/menu-dropdown/interfaces.d.ts.map +1 -1
  38. package/internal/components/menu-dropdown/interfaces.js.map +1 -1
  39. package/internal/environment.js +1 -1
  40. package/internal/environment.json +1 -1
  41. package/internal/manifest.json +1 -1
  42. package/mixed-line-bar-chart/bar-series.d.ts.map +1 -1
  43. package/mixed-line-bar-chart/bar-series.js +14 -3
  44. package/mixed-line-bar-chart/bar-series.js.map +1 -1
  45. package/mixed-line-bar-chart/styles.css.js +11 -11
  46. package/mixed-line-bar-chart/styles.scoped.css +17 -22
  47. package/mixed-line-bar-chart/styles.selectors.js +11 -11
  48. package/modal/internal.d.ts.map +1 -1
  49. package/modal/internal.js +14 -12
  50. package/modal/internal.js.map +1 -1
  51. package/package.json +1 -1
  52. package/progress-bar/index.d.ts.map +1 -1
  53. package/progress-bar/index.js +7 -4
  54. package/progress-bar/index.js.map +1 -1
  55. package/table/body-cell/td-element.d.ts +2 -1
  56. package/table/body-cell/td-element.d.ts.map +1 -1
  57. package/table/body-cell/td-element.js +3 -3
  58. package/table/body-cell/td-element.js.map +1 -1
  59. package/table/header-cell/index.d.ts +1 -1
  60. package/table/header-cell/index.d.ts.map +1 -1
  61. package/table/header-cell/index.js +2 -2
  62. package/table/header-cell/index.js.map +1 -1
  63. package/table/internal.d.ts.map +1 -1
  64. package/table/internal.js +13 -15
  65. package/table/internal.js.map +1 -1
  66. package/table/table-role/index.d.ts +3 -1
  67. package/table/table-role/index.d.ts.map +1 -1
  68. package/table/table-role/index.js +2 -1
  69. package/table/table-role/index.js.map +1 -1
  70. package/table/table-role/interfaces.d.ts +18 -0
  71. package/table/table-role/interfaces.d.ts.map +1 -0
  72. package/table/table-role/interfaces.js +4 -0
  73. package/table/table-role/interfaces.js.map +1 -0
  74. package/table/table-role/table-role-helper.d.ts +16 -4
  75. package/table/table-role/table-role-helper.d.ts.map +1 -1
  76. package/table/table-role/table-role-helper.js +40 -6
  77. package/table/table-role/table-role-helper.js.map +1 -1
  78. package/table/table-role/use-grid-navigation.d.ts +7 -0
  79. package/table/table-role/use-grid-navigation.d.ts.map +1 -0
  80. package/table/table-role/use-grid-navigation.js +185 -0
  81. package/table/table-role/use-grid-navigation.js.map +1 -0
  82. package/table/table-role/utils.d.ts +23 -0
  83. package/table/table-role/utils.d.ts.map +1 -0
  84. package/table/table-role/utils.js +141 -0
  85. package/table/table-role/utils.js.map +1 -0
  86. package/table/thead.d.ts.map +1 -1
  87. package/table/thead.js +4 -4
  88. package/table/thead.js.map +1 -1
  89. package/test-utils/dom/button-dropdown/index.js +1 -3
  90. package/test-utils/dom/button-dropdown/index.js.map +1 -1
  91. package/test-utils/selectors/button-dropdown/index.js +1 -3
  92. package/test-utils/selectors/button-dropdown/index.js.map +1 -1
  93. package/test-utils/tsconfig.tsbuildinfo +1 -1
  94. package/wizard/index.d.ts.map +1 -1
  95. package/wizard/index.js +8 -1
  96. package/wizard/index.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["button-dropdown/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { BaseNavigationDetail, CancelableEventHandler } from '../internal/events';\nimport { IconProps } from '../icon/interfaces';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { ExpandToViewport } from '../internal/components/dropdown/interfaces';\nimport { ButtonProps } from '../button/interfaces';\n\nexport interface ButtonDropdownProps extends BaseComponentProps, ExpandToViewport {\n /**\n * Array of objects, each having the following properties:\n\n * - `id` (string) - allows to identify the item that the user clicked on. Mandatory for individual items, optional for categories.\n\n * - `text` (string) - description shown in the menu for this item. Mandatory for individual items, optional for categories.\n\n * - `lang` (string) - (Optional) The language of the item, provided as a BCP 47 language tag.\n\n * - `disabled` (boolean) - whether the item is disabled. Disabled items are not clickable, but they can be highlighted with the keyboard to make them accessible.\n\n * - `disabledReason` (string) - (Optional) Displays text near the `text` property when item is disabled. Use to provide additional context.\n\n * - `items` (ReadonlyArray<Item>): an array of item objects. Items will be rendered as nested menu items but only for the first nesting level, multi-nesting is not supported.\n * An item which belongs to nested group has the following properties: `id`, `text`, `disabled` and `description`.\n\n * - `description` (string) - additional data that will be passed to a `data-description` attribute.\n\n * - `href` (string) - (Optional) Defines the target URL of the menu item, turning it into a link.\n\n * - `external` (boolean) - Marks a menu item as external by adding an icon after the menu item text. The link will open in a new tab when clicked. Note that this only works when `href` is also provided.\n\n * - `externalIconAriaLabel` (string) - Adds an `aria-label` to the external icon.\n\n * - `iconName` (string) - (Optional) Specifies the name of the icon, used with the [icon component](/components/icon/).\n\n * - `iconAlt` (string) - (Optional) Specifies alternate text for the icon when using `iconUrl`.\n\n * - `iconUrl` (string) - (Optional) Specifies the URL of a custom icon.\n\n * - `iconSvg` (ReactNode) - (Optional) Custom SVG icon. Equivalent to the `svg` slot of the [icon component](/components/icon/).\n\n */\n items: ReadonlyArray<ButtonDropdownProps.ItemOrGroup>;\n /**\n * Determines whether the button dropdown is disabled. Users cannot interact with the control if it's disabled.\n */\n disabled?: boolean;\n /**\n * Renders the button as being in a loading state. It takes precedence over the `disabled` if both are set to `true`.\n * It prevents clicks.\n */\n loading?: boolean;\n /**\n * Specifies the text that screen reader announces when the button dropdown is in a loading state.\n */\n loadingText?: string;\n /** Determines the general styling of the button dropdown.\n * * `primary` for primary buttons\n * * `normal` for secondary buttons\n * * `icon` for icon buttons\n * * `inline-icon` for icon buttons with no outer padding\n */\n variant?: ButtonDropdownProps.Variant;\n /**\n * Controls expandability of the item groups.\n */\n expandableGroups?: boolean;\n /**\n * Adds `aria-label` to the button dropdown trigger.\n * It should be used in buttons that don't have text in order to make them accessible.\n */\n ariaLabel?: string;\n /**\n * Text displayed in the button dropdown trigger.\n * @displayname text\n */\n children?: React.ReactNode;\n /**\n * Called when the user clicks on an item, and the item is not disabled. The event detail object contains the id of the clicked item.\n */\n onItemClick?: CancelableEventHandler<ButtonDropdownProps.ItemClickDetails>;\n /**\n * Called when the user clicks on an item with the left mouse button without pressing\n * modifier keys (that is, CTRL, ALT, SHIFT, META), and the item has an `href` set.\n */\n onItemFollow?: CancelableEventHandler<ButtonDropdownProps.ItemClickDetails>;\n /**\n * A standalone action that is shown prior to the dropdown trigger. Use it with \"primary\" variant only.\n * Main action properties:\n * * `text` (string) - Specifies the text shown in the main action.\n * * `external` (boolean) - Marks the main action as external by adding an icon after the text. The link will open in a new tab when clicked. Note that this only works when `href` is also provided.\n * * `externalIconAriaLabel` (string) - Adds an ARIA label to the external icon.\n *\n * The main action also supports the following properties of the [button](/components/button/?tabId=api) component:\n * `ariaLabel`, `disabled`, `loading`, `loadingText`, `href`, `target`, `rel`, `download`, `iconAlt`, `iconName`, `iconUrl`, `iconSvg`, `onClick`, `onFollow`.\n */\n mainAction?: ButtonDropdownProps.MainAction;\n}\n\nexport namespace ButtonDropdownProps {\n export type Variant = 'normal' | 'primary' | 'icon' | 'inline-icon';\n\n export interface MainAction {\n text: string;\n ariaLabel?: string;\n onClick?: CancelableEventHandler<ButtonProps.ClickDetail>;\n onFollow?: CancelableEventHandler<ButtonProps.FollowDetail>;\n disabled?: boolean;\n loading?: boolean;\n loadingText?: string;\n href?: string;\n target?: string;\n rel?: string;\n download?: boolean | string;\n external?: boolean;\n externalIconAriaLabel?: string;\n iconAlt?: string;\n iconName?: IconProps.Name;\n iconUrl?: string;\n iconSvg?: React.ReactNode;\n }\n\n export interface Item {\n id: string;\n text: string;\n lang?: string;\n disabled?: boolean;\n disabledReason?: string;\n description?: string;\n href?: string;\n external?: boolean;\n externalIconAriaLabel?: string;\n iconAlt?: string;\n iconName?: IconProps.Name;\n iconUrl?: string;\n iconSvg?: React.ReactNode;\n }\n\n export interface ItemGroup extends Omit<Item, 'id' | 'text'> {\n id?: string;\n text?: string;\n items: Items;\n }\n\n export type ItemOrGroup = Item | ItemGroup;\n\n export type Items = ReadonlyArray<ItemOrGroup>;\n\n export interface ItemClickDetails extends BaseNavigationDetail {\n id: string;\n }\n\n export interface Ref {\n /**\n * Focuses the underlying native button.\n */\n focus(): void;\n }\n}\n\nexport interface ButtonDropdownSettings {\n // this means whether action is required to make group expand\n hasExpandableGroups: boolean;\n // on smaller screens expandable groups are integrated into parent dropdown\n // this changes keyboard navigation, highlight and activation behavior for parent dropdown\n isInRestrictedView?: boolean;\n}\n\nexport interface HighlightProps {\n targetItem: ButtonDropdownProps.ItemOrGroup | null;\n isHighlighted: (item: ButtonDropdownProps.ItemOrGroup) => boolean;\n isKeyboardHighlight: (item: ButtonDropdownProps.ItemOrGroup) => boolean;\n isExpanded: (group: ButtonDropdownProps.ItemGroup) => boolean;\n highlightItem: (item: ButtonDropdownProps.ItemOrGroup) => void;\n}\n\nexport type GroupToggle = (item: ButtonDropdownProps.ItemGroup, event: React.SyntheticEvent) => void;\nexport type ItemActivate = (item: ButtonDropdownProps.Item, event: React.MouseEvent | React.KeyboardEvent) => void;\n\nexport interface CategoryProps extends HighlightProps {\n item: ButtonDropdownProps.ItemGroup;\n onGroupToggle: GroupToggle;\n onItemActivate: ItemActivate;\n disabled: boolean;\n expandToViewport?: boolean;\n variant?: ItemListProps['variant'];\n}\n\nexport interface ItemListProps extends HighlightProps {\n items: ButtonDropdownProps.Items;\n onGroupToggle: GroupToggle;\n onItemActivate: ItemActivate;\n categoryDisabled?: boolean;\n hasExpandableGroups?: boolean;\n hasCategoryHeader?: boolean;\n expandToViewport?: boolean;\n variant?: InternalButtonDropdownProps['variant'];\n}\n\nexport interface LinkItem extends ButtonDropdownProps.Item {\n href: string;\n}\n\nexport interface ItemProps {\n item: ButtonDropdownProps.Item | LinkItem;\n disabled: boolean;\n highlighted: boolean;\n onItemActivate: ItemActivate;\n highlightItem: (item: ButtonDropdownProps.ItemOrGroup) => void;\n first?: boolean;\n last: boolean;\n hasCategoryHeader: boolean;\n isKeyboardHighlighted?: boolean;\n variant?: ItemListProps['variant'];\n}\n\nexport interface InternalButtonDropdownProps extends Omit<ButtonDropdownProps, 'variant'>, InternalBaseComponentProps {\n customTriggerBuilder?: (\n clickHandler: () => void,\n ref: React.Ref<any>,\n isDisabled: boolean,\n isExpanded: boolean,\n ariaLabel?: string\n ) => React.ReactNode;\n variant?: ButtonDropdownProps['variant'] | 'navigation';\n\n /**\n * Optional text that is displayed as the title at the top of the dropdown.\n */\n title?: string;\n\n /**\n * Optional text that is displayed underneath the title at the top of the dropdown.\n */\n description?: string;\n\n /**\n * Determines that the dropdown should preferably be aligned to the center of the trigger\n * instead of dropping left or right.\n */\n preferCenter?: boolean;\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["button-dropdown/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { BaseNavigationDetail, CancelableEventHandler } from '../internal/events';\nimport { IconProps } from '../icon/interfaces';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { ExpandToViewport } from '../internal/components/dropdown/interfaces';\nimport { ButtonProps } from '../button/interfaces';\n\nexport interface ButtonDropdownProps extends BaseComponentProps, ExpandToViewport {\n /**\n * Array of objects, each having the following properties:\n\n * - `id` (string) - allows to identify the item that the user clicked on. Mandatory for individual items, optional for categories.\n\n * - `text` (string) - description shown in the menu for this item. Mandatory for individual items, optional for categories.\n\n * - `lang` (string) - (Optional) The language of the item, provided as a BCP 47 language tag.\n\n * - `disabled` (boolean) - whether the item is disabled. Disabled items are not clickable, but they can be highlighted with the keyboard to make them accessible.\n\n * - `disabledReason` (string) - (Optional) Displays text near the `text` property when item is disabled. Use to provide additional context.\n\n * - `items` (ReadonlyArray<Item>): an array of item objects. Items will be rendered as nested menu items but only for the first nesting level, multi-nesting is not supported.\n * An item which belongs to nested group has the following properties: `id`, `text`, `disabled` and `description`.\n\n * - `description` (string) - additional data that will be passed to a `data-description` attribute.\n\n * - `href` (string) - (Optional) Defines the target URL of the menu item, turning it into a link.\n\n * - `external` (boolean) - Marks a menu item as external by adding an icon after the menu item text. The link will open in a new tab when clicked. Note that this only works when `href` is also provided.\n\n * - `externalIconAriaLabel` (string) - Adds an `aria-label` to the external icon.\n\n * - `iconName` (string) - (Optional) Specifies the name of the icon, used with the [icon component](/components/icon/).\n\n * - `iconAlt` (string) - (Optional) Specifies alternate text for the icon when using `iconUrl`.\n\n * - `iconUrl` (string) - (Optional) Specifies the URL of a custom icon.\n\n * - `iconSvg` (ReactNode) - (Optional) Custom SVG icon. Equivalent to the `svg` slot of the [icon component](/components/icon/).\n\n */\n items: ReadonlyArray<ButtonDropdownProps.ItemOrGroup>;\n /**\n * Determines whether the button dropdown is disabled. Users cannot interact with the control if it's disabled.\n */\n disabled?: boolean;\n /**\n * Renders the button as being in a loading state. It takes precedence over the `disabled` if both are set to `true`.\n * It prevents clicks.\n */\n loading?: boolean;\n /**\n * Specifies the text that screen reader announces when the button dropdown is in a loading state.\n */\n loadingText?: string;\n /** Determines the general styling of the button dropdown.\n * * `primary` for primary buttons\n * * `normal` for secondary buttons\n * * `icon` for icon buttons\n * * `inline-icon` for icon buttons with no outer padding\n */\n variant?: ButtonDropdownProps.Variant;\n /**\n * Controls expandability of the item groups.\n */\n expandableGroups?: boolean;\n /**\n * Adds `aria-label` to the button dropdown trigger.\n * It should be used in buttons that don't have text in order to make them accessible.\n */\n ariaLabel?: string;\n /**\n * Text displayed in the button dropdown trigger.\n * @displayname text\n */\n children?: React.ReactNode;\n /**\n * Called when the user clicks on an item, and the item is not disabled. The event detail object contains the id of the clicked item.\n */\n onItemClick?: CancelableEventHandler<ButtonDropdownProps.ItemClickDetails>;\n /**\n * Called when the user clicks on an item with the left mouse button without pressing\n * modifier keys (that is, CTRL, ALT, SHIFT, META), and the item has an `href` set.\n */\n onItemFollow?: CancelableEventHandler<ButtonDropdownProps.ItemClickDetails>;\n /**\n * A standalone action that is shown prior to the dropdown trigger. Use it with \"primary\" variant only.\n * Main action properties:\n * * `text` (string) - Specifies the text shown in the main action.\n * * `external` (boolean) - Marks the main action as external by adding an icon after the text. The link will open in a new tab when clicked. Note that this only works when `href` is also provided.\n * * `externalIconAriaLabel` (string) - Adds an ARIA label to the external icon.\n *\n * The main action also supports the following properties of the [button](/components/button/?tabId=api) component:\n * `ariaLabel`, `disabled`, `loading`, `loadingText`, `href`, `target`, `rel`, `download`, `iconAlt`, `iconName`, `iconUrl`, `iconSvg`, `onClick`, `onFollow`.\n */\n mainAction?: ButtonDropdownProps.MainAction;\n}\n\nexport namespace ButtonDropdownProps {\n export type Variant = 'normal' | 'primary' | 'icon' | 'inline-icon';\n\n export interface MainAction {\n text: string;\n ariaLabel?: string;\n onClick?: CancelableEventHandler<ButtonProps.ClickDetail>;\n onFollow?: CancelableEventHandler<ButtonProps.FollowDetail>;\n disabled?: boolean;\n loading?: boolean;\n loadingText?: string;\n href?: string;\n target?: string;\n rel?: string;\n download?: boolean | string;\n external?: boolean;\n externalIconAriaLabel?: string;\n iconAlt?: string;\n iconName?: IconProps.Name;\n iconUrl?: string;\n iconSvg?: React.ReactNode;\n }\n\n export interface Item {\n id: string;\n text: string;\n lang?: string;\n disabled?: boolean;\n disabledReason?: string;\n description?: string;\n href?: string;\n external?: boolean;\n externalIconAriaLabel?: string;\n iconAlt?: string;\n iconName?: IconProps.Name;\n iconUrl?: string;\n iconSvg?: React.ReactNode;\n }\n\n export interface ItemGroup extends Omit<Item, 'id' | 'text'> {\n id?: string;\n text?: string;\n items: Items;\n }\n\n export type ItemOrGroup = Item | ItemGroup;\n\n export type Items = ReadonlyArray<ItemOrGroup>;\n\n export interface ItemClickDetails extends BaseNavigationDetail {\n id: string;\n }\n\n export interface Ref {\n /**\n * Focuses the underlying native button.\n */\n focus(): void;\n }\n}\n\nexport interface ButtonDropdownSettings {\n // this means whether action is required to make group expand\n hasExpandableGroups: boolean;\n // on smaller screens expandable groups are integrated into parent dropdown\n // this changes keyboard navigation, highlight and activation behavior for parent dropdown\n isInRestrictedView?: boolean;\n}\n\nexport interface HighlightProps {\n targetItem: ButtonDropdownProps.ItemOrGroup | null;\n isHighlighted: (item: ButtonDropdownProps.ItemOrGroup) => boolean;\n isKeyboardHighlight: (item: ButtonDropdownProps.ItemOrGroup) => boolean;\n isExpanded: (group: ButtonDropdownProps.ItemGroup) => boolean;\n highlightItem: (item: ButtonDropdownProps.ItemOrGroup) => void;\n}\n\nexport type GroupToggle = (item: ButtonDropdownProps.ItemGroup, event: React.SyntheticEvent) => void;\nexport type ItemActivate = (item: ButtonDropdownProps.Item, event: React.MouseEvent | React.KeyboardEvent) => void;\n\nexport interface CategoryProps extends HighlightProps {\n item: ButtonDropdownProps.ItemGroup;\n onGroupToggle: GroupToggle;\n onItemActivate: ItemActivate;\n disabled: boolean;\n expandToViewport?: boolean;\n variant?: ItemListProps['variant'];\n}\n\nexport interface ItemListProps extends HighlightProps {\n items: ButtonDropdownProps.Items;\n onGroupToggle: GroupToggle;\n onItemActivate: ItemActivate;\n categoryDisabled?: boolean;\n hasExpandableGroups?: boolean;\n hasCategoryHeader?: boolean;\n expandToViewport?: boolean;\n variant?: InternalButtonDropdownProps['variant'];\n}\n\nexport interface LinkItem extends ButtonDropdownProps.Item {\n href: string;\n}\n\nexport interface ItemProps {\n item: ButtonDropdownProps.Item | LinkItem;\n disabled: boolean;\n highlighted: boolean;\n onItemActivate: ItemActivate;\n highlightItem: (item: ButtonDropdownProps.ItemOrGroup) => void;\n first?: boolean;\n last: boolean;\n hasCategoryHeader: boolean;\n isKeyboardHighlighted?: boolean;\n variant?: ItemListProps['variant'];\n}\n\nexport interface InternalButtonDropdownProps extends Omit<ButtonDropdownProps, 'variant'>, InternalBaseComponentProps {\n customTriggerBuilder?: (props: CustomTriggerProps) => React.ReactNode;\n variant?: ButtonDropdownProps['variant'] | 'navigation';\n\n /**\n * Optional text that is displayed as the title at the top of the dropdown.\n */\n title?: string;\n\n /**\n * Optional text that is displayed underneath the title at the top of the dropdown.\n */\n description?: string;\n\n /**\n * Determines that the dropdown should preferably be aligned to the center of the trigger\n * instead of dropping left or right.\n */\n preferCenter?: boolean;\n}\n\nexport interface CustomTriggerProps {\n triggerRef: React.Ref<HTMLElement>;\n testUtilsClass: string;\n ariaLabel: string | undefined;\n disabled: boolean;\n isOpen: boolean;\n onClick: () => void;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["button-dropdown/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAGjD,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAkBhF,QAAA,MAAM,sBAAsB,6GAmQ3B,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["button-dropdown/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAGjD,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAkBhF,QAAA,MAAM,sBAAsB,6GA0Q3B,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
@@ -70,7 +70,7 @@ const InternalButtonDropdown = React.forwardRef((_a, ref) => {
70
70
  iconAlign: 'right',
71
71
  __iconClass: canBeOpened && isOpen ? styles['rotate-up'] : styles['rotate-down'],
72
72
  };
73
- const baseTriggerProps = Object.assign(Object.assign({ className: styles['trigger-button'] }, iconProps), { variant: triggerVariant, loading,
73
+ const baseTriggerProps = Object.assign(Object.assign({ className: clsx(styles['trigger-button'], styles['test-utils-button-trigger']) }, iconProps), { variant: triggerVariant, loading,
74
74
  loadingText,
75
75
  disabled, onClick: (event) => {
76
76
  event.preventDefault();
@@ -80,7 +80,14 @@ const InternalButtonDropdown = React.forwardRef((_a, ref) => {
80
80
  } });
81
81
  let trigger = null;
82
82
  if (customTriggerBuilder) {
83
- trigger = (React.createElement("div", { className: styles['dropdown-trigger'] }, customTriggerBuilder(clickHandler, triggerRef, disabled, isOpen, ariaLabel)));
83
+ trigger = (React.createElement("div", { className: styles['dropdown-trigger'] }, customTriggerBuilder({
84
+ testUtilsClass: styles['test-utils-button-trigger'],
85
+ onClick: clickHandler,
86
+ triggerRef,
87
+ ariaLabel,
88
+ disabled,
89
+ isOpen,
90
+ })));
84
91
  }
85
92
  else if (isMainAction) {
86
93
  const { text, iconName, iconAlt, iconSvg, iconUrl, external, externalIconAriaLabel } = mainAction, mainActionProps = __rest(mainAction, ["text", "iconName", "iconAlt", "iconSvg", "iconUrl", "external", "externalIconAriaLabel"]);
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["button-dropdown/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,QAAQ,MAAM,iCAAiC,CAAC;AACvD,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,WAAW,MAAM,qCAAqC,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAuB,MAAM,oBAAoB,CAAC;AAEzE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE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U,EAAE,GAAG,EAAE,IAEzC,KAAK,CACM,CACV,CACP;gBACA,WAAW,IAAI,CACd,oBAAC,WAAW,IAAC,QAAQ,EAAC,QAAQ;oBAC5B,8BAAM,SAAS,EAAE,MAAM,CAAC,WAAW,IAAG,WAAW,CAAQ,CAC7C,CACf,CACG,CACP;YACD,oBAAC,WAAW,IACV,IAAI,EAAE,WAAW,IAAI,MAAM,EAC3B,QAAQ,EAAC,QAAQ,EACjB,IAAI,EAAC,MAAM,EACX,iBAAiB,EAAE,IAAI,EACvB,cAAc,EAAE,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,EAChD,UAAU,EAAC,UAAU;gBAErB,oBAAC,SAAS,IACR,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,mBAAmB,EAAE,gBAAgB,EACrC,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,EAC5B,mBAAmB,EAAE,mBAAmB,EACxC,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,EAAE,OAAO,GAChB,CACU,CACL,CACP,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,sBAAsB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef } from 'react';\nimport clsx from 'clsx';\nimport styles from './styles.css.js';\nimport { ButtonDropdownProps, InternalButtonDropdownProps } from './interfaces';\nimport { getBaseProps } from '../internal/base-component';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport Dropdown from '../internal/components/dropdown';\nimport ItemsList from './items-list';\nimport { useButtonDropdown } from './utils/use-button-dropdown';\nimport OptionsList from '../internal/components/options-list';\nimport { InternalButton, InternalButtonProps } from '../button/internal';\nimport { ButtonProps } from '../button/interfaces';\nimport { useMobile } from '../internal/hooks/use-mobile';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport InternalBox from '../box/internal';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\nimport { isDevelopment } from '../internal/is-development';\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode/index.js';\nimport { useFunnel } from '../internal/analytics/hooks/use-funnel.js';\n\nconst InternalButtonDropdown = React.forwardRef(\n (\n {\n items,\n variant = 'normal',\n loading = false,\n loadingText,\n disabled = false,\n expandableGroups = false,\n children,\n onItemClick,\n onItemFollow,\n customTriggerBuilder,\n expandToViewport,\n ariaLabel,\n title,\n description,\n preferCenter,\n mainAction,\n __internalRootRef,\n ...props\n }: InternalButtonDropdownProps,\n ref: React.Ref<ButtonDropdownProps.Ref>\n ) => {\n const isInRestrictedView = useMobile();\n const dropdownId = useUniqueId('dropdown');\n for (const item of items) {\n checkSafeUrl('ButtonDropdown', item.href);\n }\n if (mainAction) {\n checkSafeUrl('ButtonDropdown', mainAction.href);\n }\n\n if (isDevelopment) {\n if (mainAction && variant !== 'primary') {\n warnOnce('ButtonDropdown', 'Main action is only supported for \"primary\" component variant.');\n }\n }\n const isMainAction = mainAction && variant === 'primary';\n const isVisualRefresh = useVisualRefresh();\n\n const {\n isOpen,\n targetItem,\n isHighlighted,\n isKeyboardHighlight,\n isExpanded,\n highlightItem,\n onKeyDown,\n onKeyUp,\n onItemActivate,\n onGroupToggle,\n toggleDropdown,\n closeDropdown,\n setIsUsingMouse,\n } = useButtonDropdown({\n items,\n onItemClick,\n onItemFollow,\n onReturnFocus: () => triggerRef.current?.focus(),\n expandToViewport,\n hasExpandableGroups: expandableGroups,\n isInRestrictedView,\n });\n\n const handleMouseEvent = () => {\n setIsUsingMouse(true);\n };\n\n const baseProps = getBaseProps(props);\n\n const mainActionRef = useRef<HTMLElement>(null);\n const triggerRef = useRef<HTMLElement>(null);\n\n useForwardFocus(ref, isMainAction ? mainActionRef : triggerRef);\n\n const clickHandler = () => {\n if (!loading && !disabled) {\n // Prevent moving highlight on mobiles to avoid disabled state reason popup if defined.\n toggleDropdown({ moveHighlightOnOpen: !isInRestrictedView });\n }\n };\n\n const canBeOpened = !loading && !disabled;\n\n const triggerVariant = variant === 'navigation' ? undefined : variant === 'inline-icon' ? 'inline-icon' : variant;\n const iconProps: Partial<ButtonProps & { __iconClass?: string }> =\n variant === 'icon' || variant === 'inline-icon'\n ? {\n iconName: 'ellipsis',\n }\n : {\n iconName: 'caret-down-filled',\n iconAlign: 'right',\n __iconClass: canBeOpened && isOpen ? styles['rotate-up'] : styles['rotate-down'],\n };\n\n const baseTriggerProps: InternalButtonProps = {\n className: styles['trigger-button'],\n ...iconProps,\n variant: triggerVariant,\n loading,\n loadingText,\n disabled,\n onClick: (event: Event) => {\n event.preventDefault();\n clickHandler();\n },\n ariaLabel,\n ariaExpanded: canBeOpened && isOpen,\n formAction: 'none',\n __nativeAttributes: {\n 'aria-haspopup': true,\n },\n };\n\n let trigger: React.ReactNode = null;\n if (customTriggerBuilder) {\n trigger = (\n <div className={styles['dropdown-trigger']}>\n {customTriggerBuilder(clickHandler, triggerRef, disabled, isOpen, ariaLabel)}\n </div>\n );\n } else if (isMainAction) {\n const { text, iconName, iconAlt, iconSvg, iconUrl, external, externalIconAriaLabel, ...mainActionProps } =\n mainAction;\n const mainActionIconProps = external\n ? ({ iconName: 'external', iconAlign: 'right' } as const)\n : ({ iconName, iconAlt, iconSvg, iconUrl } as const);\n const mainActionAriaLabel = externalIconAriaLabel\n ? `${mainAction.ariaLabel ?? mainAction.text} ${mainAction.externalIconAriaLabel}`\n : undefined;\n\n trigger = (\n <div role=\"group\" aria-label={ariaLabel} className={styles['split-trigger-wrapper']}>\n <div\n className={clsx(styles['trigger-item'], styles['split-trigger'])}\n // Close dropdown upon main action click unless event is cancelled.\n onClick={closeDropdown}\n // Prevent keyboard events from propagation to the button dropdown handler.\n onKeyDown={e => e.stopPropagation()}\n onKeyUp={e => e.stopPropagation()}\n >\n <InternalButton\n ref={mainActionRef}\n {...mainActionProps}\n {...mainActionIconProps}\n className={styles['trigger-button']}\n variant=\"primary\"\n ariaLabel={mainActionAriaLabel}\n formAction=\"none\"\n >\n {text}\n </InternalButton>\n </div>\n <div\n className={clsx(\n styles['trigger-item'],\n styles['dropdown-trigger'],\n isVisualRefresh && styles['visual-refresh']\n )}\n >\n <InternalButton ref={triggerRef} {...baseTriggerProps} />\n </div>\n </div>\n );\n } else {\n trigger = (\n <div className={styles['dropdown-trigger']}>\n <InternalButton ref={triggerRef} {...baseTriggerProps}>\n {children}\n </InternalButton>\n </div>\n );\n }\n\n const hasHeader = title || description;\n const headerId = useUniqueId('awsui-button-dropdown__header');\n\n const { loadingButtonCount } = useFunnel();\n useEffect(() => {\n if (loading) {\n loadingButtonCount.current++;\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n loadingButtonCount.current--;\n };\n }\n }, [loading, loadingButtonCount]);\n\n return (\n <div\n {...baseProps}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n onMouseDown={handleMouseEvent}\n onMouseMove={handleMouseEvent}\n className={clsx(styles['button-dropdown'], styles[`variant-${variant}`], baseProps.className)}\n aria-owns={expandToViewport && isOpen ? dropdownId : undefined}\n ref={__internalRootRef}\n >\n <Dropdown\n open={canBeOpened && isOpen}\n stretchWidth={false}\n stretchTriggerHeight={variant === 'navigation'}\n expandToViewport={expandToViewport}\n preferCenter={preferCenter}\n onDropdownClose={() => toggleDropdown()}\n trigger={trigger}\n dropdownId={dropdownId}\n >\n {hasHeader && (\n <div className={styles.header} id={headerId}>\n {title && (\n <div className={styles.title}>\n <InternalBox\n fontSize=\"heading-s\"\n fontWeight=\"bold\"\n color=\"inherit\"\n tagOverride=\"h2\"\n margin={{ vertical: 'n', horizontal: 'n' }}\n >\n {title}\n </InternalBox>\n </div>\n )}\n {description && (\n <InternalBox fontSize=\"body-s\">\n <span className={styles.description}>{description}</span>\n </InternalBox>\n )}\n </div>\n )}\n <OptionsList\n open={canBeOpened && isOpen}\n position=\"static\"\n role=\"menu\"\n decreaseTopMargin={true}\n ariaLabelledby={hasHeader ? headerId : undefined}\n statusType=\"finished\"\n >\n <ItemsList\n items={items}\n onItemActivate={onItemActivate}\n onGroupToggle={onGroupToggle}\n hasExpandableGroups={expandableGroups}\n targetItem={targetItem}\n isHighlighted={isHighlighted}\n isKeyboardHighlight={isKeyboardHighlight}\n isExpanded={isExpanded}\n highlightItem={highlightItem}\n expandToViewport={expandToViewport}\n variant={variant}\n />\n </OptionsList>\n </Dropdown>\n </div>\n );\n }\n);\n\nexport default InternalButtonDropdown;\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["button-dropdown/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,QAAQ,MAAM,iCAAiC,CAAC;AACvD,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,WAAW,MAAM,qCAAqC,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAuB,MAAM,oBAAoB,CAAC;AAEzE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EA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AAE,EAAE,QAAQ,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,IAEzC,KAAK,CACM,CACV,CACP;gBACA,WAAW,IAAI,CACd,oBAAC,WAAW,IAAC,QAAQ,EAAC,QAAQ;oBAC5B,8BAAM,SAAS,EAAE,MAAM,CAAC,WAAW,IAAG,WAAW,CAAQ,CAC7C,CACf,CACG,CACP;YACD,oBAAC,WAAW,IACV,IAAI,EAAE,WAAW,IAAI,MAAM,EAC3B,QAAQ,EAAC,QAAQ,EACjB,IAAI,EAAC,MAAM,EACX,iBAAiB,EAAE,IAAI,EACvB,cAAc,EAAE,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,EAChD,UAAU,EAAC,UAAU;gBAErB,oBAAC,SAAS,IACR,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,mBAAmB,EAAE,gBAAgB,EACrC,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,EAC5B,mBAAmB,EAAE,mBAAmB,EACxC,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,EAAE,OAAO,GAChB,CACU,CACL,CACP,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,sBAAsB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef } from 'react';\nimport clsx from 'clsx';\nimport styles from './styles.css.js';\nimport { ButtonDropdownProps, InternalButtonDropdownProps } from './interfaces';\nimport { getBaseProps } from '../internal/base-component';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport Dropdown from '../internal/components/dropdown';\nimport ItemsList from './items-list';\nimport { useButtonDropdown } from './utils/use-button-dropdown';\nimport OptionsList from '../internal/components/options-list';\nimport { InternalButton, InternalButtonProps } from '../button/internal';\nimport { ButtonProps } from '../button/interfaces';\nimport { useMobile } from '../internal/hooks/use-mobile';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport InternalBox from '../box/internal';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\nimport { isDevelopment } from '../internal/is-development';\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode/index.js';\nimport { useFunnel } from '../internal/analytics/hooks/use-funnel.js';\n\nconst InternalButtonDropdown = React.forwardRef(\n (\n {\n items,\n variant = 'normal',\n loading = false,\n loadingText,\n disabled = false,\n expandableGroups = false,\n children,\n onItemClick,\n onItemFollow,\n customTriggerBuilder,\n expandToViewport,\n ariaLabel,\n title,\n description,\n preferCenter,\n mainAction,\n __internalRootRef,\n ...props\n }: InternalButtonDropdownProps,\n ref: React.Ref<ButtonDropdownProps.Ref>\n ) => {\n const isInRestrictedView = useMobile();\n const dropdownId = useUniqueId('dropdown');\n for (const item of items) {\n checkSafeUrl('ButtonDropdown', item.href);\n }\n if (mainAction) {\n checkSafeUrl('ButtonDropdown', mainAction.href);\n }\n\n if (isDevelopment) {\n if (mainAction && variant !== 'primary') {\n warnOnce('ButtonDropdown', 'Main action is only supported for \"primary\" component variant.');\n }\n }\n const isMainAction = mainAction && variant === 'primary';\n const isVisualRefresh = useVisualRefresh();\n\n const {\n isOpen,\n targetItem,\n isHighlighted,\n isKeyboardHighlight,\n isExpanded,\n highlightItem,\n onKeyDown,\n onKeyUp,\n onItemActivate,\n onGroupToggle,\n toggleDropdown,\n closeDropdown,\n setIsUsingMouse,\n } = useButtonDropdown({\n items,\n onItemClick,\n onItemFollow,\n onReturnFocus: () => triggerRef.current?.focus(),\n expandToViewport,\n hasExpandableGroups: expandableGroups,\n isInRestrictedView,\n });\n\n const handleMouseEvent = () => {\n setIsUsingMouse(true);\n };\n\n const baseProps = getBaseProps(props);\n\n const mainActionRef = useRef<HTMLElement>(null);\n const triggerRef = useRef<HTMLElement>(null);\n\n useForwardFocus(ref, isMainAction ? mainActionRef : triggerRef);\n\n const clickHandler = () => {\n if (!loading && !disabled) {\n // Prevent moving highlight on mobiles to avoid disabled state reason popup if defined.\n toggleDropdown({ moveHighlightOnOpen: !isInRestrictedView });\n }\n };\n\n const canBeOpened = !loading && !disabled;\n\n const triggerVariant = variant === 'navigation' ? undefined : variant === 'inline-icon' ? 'inline-icon' : variant;\n const iconProps: Partial<ButtonProps & { __iconClass?: string }> =\n variant === 'icon' || variant === 'inline-icon'\n ? {\n iconName: 'ellipsis',\n }\n : {\n iconName: 'caret-down-filled',\n iconAlign: 'right',\n __iconClass: canBeOpened && isOpen ? styles['rotate-up'] : styles['rotate-down'],\n };\n\n const baseTriggerProps: InternalButtonProps = {\n className: clsx(styles['trigger-button'], styles['test-utils-button-trigger']),\n ...iconProps,\n variant: triggerVariant,\n loading,\n loadingText,\n disabled,\n onClick: (event: Event) => {\n event.preventDefault();\n clickHandler();\n },\n ariaLabel,\n ariaExpanded: canBeOpened && isOpen,\n formAction: 'none',\n __nativeAttributes: {\n 'aria-haspopup': true,\n },\n };\n\n let trigger: React.ReactNode = null;\n if (customTriggerBuilder) {\n trigger = (\n <div className={styles['dropdown-trigger']}>\n {customTriggerBuilder({\n testUtilsClass: styles['test-utils-button-trigger'],\n onClick: clickHandler,\n triggerRef,\n ariaLabel,\n disabled,\n isOpen,\n })}\n </div>\n );\n } else if (isMainAction) {\n const { text, iconName, iconAlt, iconSvg, iconUrl, external, externalIconAriaLabel, ...mainActionProps } =\n mainAction;\n const mainActionIconProps = external\n ? ({ iconName: 'external', iconAlign: 'right' } as const)\n : ({ iconName, iconAlt, iconSvg, iconUrl } as const);\n const mainActionAriaLabel = externalIconAriaLabel\n ? `${mainAction.ariaLabel ?? mainAction.text} ${mainAction.externalIconAriaLabel}`\n : undefined;\n\n trigger = (\n <div role=\"group\" aria-label={ariaLabel} className={styles['split-trigger-wrapper']}>\n <div\n className={clsx(styles['trigger-item'], styles['split-trigger'])}\n // Close dropdown upon main action click unless event is cancelled.\n onClick={closeDropdown}\n // Prevent keyboard events from propagation to the button dropdown handler.\n onKeyDown={e => e.stopPropagation()}\n onKeyUp={e => e.stopPropagation()}\n >\n <InternalButton\n ref={mainActionRef}\n {...mainActionProps}\n {...mainActionIconProps}\n className={styles['trigger-button']}\n variant=\"primary\"\n ariaLabel={mainActionAriaLabel}\n formAction=\"none\"\n >\n {text}\n </InternalButton>\n </div>\n <div\n className={clsx(\n styles['trigger-item'],\n styles['dropdown-trigger'],\n isVisualRefresh && styles['visual-refresh']\n )}\n >\n <InternalButton ref={triggerRef} {...baseTriggerProps} />\n </div>\n </div>\n );\n } else {\n trigger = (\n <div className={styles['dropdown-trigger']}>\n <InternalButton ref={triggerRef} {...baseTriggerProps}>\n {children}\n </InternalButton>\n </div>\n );\n }\n\n const hasHeader = title || description;\n const headerId = useUniqueId('awsui-button-dropdown__header');\n\n const { loadingButtonCount } = useFunnel();\n useEffect(() => {\n if (loading) {\n loadingButtonCount.current++;\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n loadingButtonCount.current--;\n };\n }\n }, [loading, loadingButtonCount]);\n\n return (\n <div\n {...baseProps}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n onMouseDown={handleMouseEvent}\n onMouseMove={handleMouseEvent}\n className={clsx(styles['button-dropdown'], styles[`variant-${variant}`], baseProps.className)}\n aria-owns={expandToViewport && isOpen ? dropdownId : undefined}\n ref={__internalRootRef}\n >\n <Dropdown\n open={canBeOpened && isOpen}\n stretchWidth={false}\n stretchTriggerHeight={variant === 'navigation'}\n expandToViewport={expandToViewport}\n preferCenter={preferCenter}\n onDropdownClose={() => toggleDropdown()}\n trigger={trigger}\n dropdownId={dropdownId}\n >\n {hasHeader && (\n <div className={styles.header} id={headerId}>\n {title && (\n <div className={styles.title}>\n <InternalBox\n fontSize=\"heading-s\"\n fontWeight=\"bold\"\n color=\"inherit\"\n tagOverride=\"h2\"\n margin={{ vertical: 'n', horizontal: 'n' }}\n >\n {title}\n </InternalBox>\n </div>\n )}\n {description && (\n <InternalBox fontSize=\"body-s\">\n <span className={styles.description}>{description}</span>\n </InternalBox>\n )}\n </div>\n )}\n <OptionsList\n open={canBeOpened && isOpen}\n position=\"static\"\n role=\"menu\"\n decreaseTopMargin={true}\n ariaLabelledby={hasHeader ? headerId : undefined}\n statusType=\"finished\"\n >\n <ItemsList\n items={items}\n onItemActivate={onItemActivate}\n onGroupToggle={onGroupToggle}\n hasExpandableGroups={expandableGroups}\n targetItem={targetItem}\n isHighlighted={isHighlighted}\n isKeyboardHighlight={isKeyboardHighlight}\n isExpanded={isExpanded}\n highlightItem={highlightItem}\n expandToViewport={expandToViewport}\n variant={variant}\n />\n </OptionsList>\n </Dropdown>\n </div>\n );\n }\n);\n\nexport default InternalButtonDropdown;\n"]}
@@ -1,19 +1,20 @@
1
1
 
2
2
  import './styles.scoped.css';
3
3
  export default {
4
- "button-dropdown": "awsui_button-dropdown_sne0l_15mtc_93",
5
- "items-list-container": "awsui_items-list-container_sne0l_15mtc_97",
6
- "awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-0_sne0l_15mtc_1",
7
- "rotate-up": "awsui_rotate-up_sne0l_15mtc_114",
8
- "rotate-down": "awsui_rotate-down_sne0l_15mtc_129",
9
- "header": "awsui_header_sne0l_15mtc_144",
10
- "title": "awsui_title_sne0l_15mtc_153",
11
- "description": "awsui_description_sne0l_15mtc_154",
12
- "split-trigger-wrapper": "awsui_split-trigger-wrapper_sne0l_15mtc_158",
13
- "trigger-item": "awsui_trigger-item_sne0l_15mtc_161",
14
- "trigger-button": "awsui_trigger-button_sne0l_15mtc_164",
15
- "visual-refresh": "awsui_visual-refresh_sne0l_15mtc_176",
16
- "split-trigger": "awsui_split-trigger_sne0l_15mtc_158",
17
- "dropdown-trigger": "awsui_dropdown-trigger_sne0l_15mtc_184"
4
+ "button-dropdown": "awsui_button-dropdown_sne0l_hitos_93",
5
+ "items-list-container": "awsui_items-list-container_sne0l_hitos_97",
6
+ "awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-0_sne0l_hitos_1",
7
+ "rotate-up": "awsui_rotate-up_sne0l_hitos_114",
8
+ "rotate-down": "awsui_rotate-down_sne0l_hitos_129",
9
+ "header": "awsui_header_sne0l_hitos_144",
10
+ "title": "awsui_title_sne0l_hitos_153",
11
+ "description": "awsui_description_sne0l_hitos_154",
12
+ "split-trigger-wrapper": "awsui_split-trigger-wrapper_sne0l_hitos_158",
13
+ "trigger-item": "awsui_trigger-item_sne0l_hitos_161",
14
+ "trigger-button": "awsui_trigger-button_sne0l_hitos_164",
15
+ "visual-refresh": "awsui_visual-refresh_sne0l_hitos_176",
16
+ "split-trigger": "awsui_split-trigger_sne0l_hitos_158",
17
+ "dropdown-trigger": "awsui_dropdown-trigger_sne0l_hitos_184",
18
+ "test-utils-button-trigger": "awsui_test-utils-button-trigger_sne0l_hitos_188"
18
19
  };
19
20
 
@@ -90,58 +90,58 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
90
90
  Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
91
91
  SPDX-License-Identifier: Apache-2.0
92
92
  */
93
- .awsui_button-dropdown_sne0l_15mtc_93:not(#\9) {
93
+ .awsui_button-dropdown_sne0l_hitos_93:not(#\9) {
94
94
  display: inline-block;
95
95
  }
96
96
 
97
- .awsui_items-list-container_sne0l_15mtc_97:not(#\9) {
97
+ .awsui_items-list-container_sne0l_hitos_97:not(#\9) {
98
98
  padding: 0;
99
99
  margin: 0;
100
- animation: awsui_awsui-motion-fade-in-0_sne0l_15mtc_1 500ms var(--motion-easing-show-quick-vc5zgd, ease-out);
100
+ animation: awsui_awsui-motion-fade-in-0_sne0l_hitos_1 500ms var(--motion-easing-show-quick-vc5zgd, ease-out);
101
101
  animation-fill-mode: none;
102
102
  }
103
103
  @media (prefers-reduced-motion: reduce) {
104
- .awsui_items-list-container_sne0l_15mtc_97:not(#\9) {
104
+ .awsui_items-list-container_sne0l_hitos_97:not(#\9) {
105
105
  animation: none;
106
106
  transition: none;
107
107
  }
108
108
  }
109
- .awsui-motion-disabled .awsui_items-list-container_sne0l_15mtc_97:not(#\9), .awsui-mode-entering .awsui_items-list-container_sne0l_15mtc_97:not(#\9) {
109
+ .awsui-motion-disabled .awsui_items-list-container_sne0l_hitos_97:not(#\9), .awsui-mode-entering .awsui_items-list-container_sne0l_hitos_97:not(#\9) {
110
110
  animation: none;
111
111
  transition: none;
112
112
  }
113
113
 
114
- .awsui_rotate-up_sne0l_15mtc_114:not(#\9) {
114
+ .awsui_rotate-up_sne0l_hitos_114:not(#\9) {
115
115
  transform: rotate(-180deg);
116
116
  transition: transform var(--motion-duration-rotate-180-dpvl4m, 135ms) var(--motion-easing-rotate-180-e270ko, cubic-bezier(0.165, 0.84, 0.44, 1));
117
117
  }
118
118
  @media (prefers-reduced-motion: reduce) {
119
- .awsui_rotate-up_sne0l_15mtc_114:not(#\9) {
119
+ .awsui_rotate-up_sne0l_hitos_114:not(#\9) {
120
120
  animation: none;
121
121
  transition: none;
122
122
  }
123
123
  }
124
- .awsui-motion-disabled .awsui_rotate-up_sne0l_15mtc_114:not(#\9), .awsui-mode-entering .awsui_rotate-up_sne0l_15mtc_114:not(#\9) {
124
+ .awsui-motion-disabled .awsui_rotate-up_sne0l_hitos_114:not(#\9), .awsui-mode-entering .awsui_rotate-up_sne0l_hitos_114:not(#\9) {
125
125
  animation: none;
126
126
  transition: none;
127
127
  }
128
128
 
129
- .awsui_rotate-down_sne0l_15mtc_129:not(#\9) {
129
+ .awsui_rotate-down_sne0l_hitos_129:not(#\9) {
130
130
  transform: rotate(0deg);
131
131
  transition: transform var(--motion-duration-rotate-180-dpvl4m, 135ms) var(--motion-easing-rotate-180-e270ko, cubic-bezier(0.165, 0.84, 0.44, 1));
132
132
  }
133
133
  @media (prefers-reduced-motion: reduce) {
134
- .awsui_rotate-down_sne0l_15mtc_129:not(#\9) {
134
+ .awsui_rotate-down_sne0l_hitos_129:not(#\9) {
135
135
  animation: none;
136
136
  transition: none;
137
137
  }
138
138
  }
139
- .awsui-motion-disabled .awsui_rotate-down_sne0l_15mtc_129:not(#\9), .awsui-mode-entering .awsui_rotate-down_sne0l_15mtc_129:not(#\9) {
139
+ .awsui-motion-disabled .awsui_rotate-down_sne0l_hitos_129:not(#\9), .awsui-mode-entering .awsui_rotate-down_sne0l_hitos_129:not(#\9) {
140
140
  animation: none;
141
141
  transition: none;
142
142
  }
143
143
 
144
- .awsui_header_sne0l_15mtc_144:not(#\9) {
144
+ .awsui_header_sne0l_hitos_144:not(#\9) {
145
145
  display: flex;
146
146
  flex-direction: column;
147
147
  list-style: none;
@@ -150,37 +150,41 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
150
150
  border-bottom: var(--border-field-width-09w7vk, 2px) solid var(--color-border-dropdown-group-zgquz8, #e9ebed);
151
151
  }
152
152
 
153
- .awsui_title_sne0l_15mtc_153:not(#\9),
154
- .awsui_description_sne0l_15mtc_154:not(#\9) {
153
+ .awsui_title_sne0l_hitos_153:not(#\9),
154
+ .awsui_description_sne0l_hitos_154:not(#\9) {
155
155
  color: var(--color-text-dropdown-header-ga95zo, #000716);
156
156
  }
157
157
 
158
- .awsui_split-trigger-wrapper_sne0l_15mtc_158:not(#\9) {
158
+ .awsui_split-trigger-wrapper_sne0l_hitos_158:not(#\9) {
159
159
  display: flex;
160
160
  }
161
- .awsui_split-trigger-wrapper_sne0l_15mtc_158 > .awsui_trigger-item_sne0l_15mtc_161 > button:not(#\9):focus {
161
+ .awsui_split-trigger-wrapper_sne0l_hitos_158 > .awsui_trigger-item_sne0l_hitos_161 > button:not(#\9):focus {
162
162
  z-index: 1;
163
163
  }
164
- .awsui_split-trigger-wrapper_sne0l_15mtc_158 > .awsui_trigger-item_sne0l_15mtc_161:not(#\9):not(:last-child) > .awsui_trigger-button_sne0l_15mtc_164 {
164
+ .awsui_split-trigger-wrapper_sne0l_hitos_158 > .awsui_trigger-item_sne0l_hitos_161:not(#\9):not(:last-child) > .awsui_trigger-button_sne0l_hitos_164 {
165
165
  border-top-right-radius: 0;
166
166
  border-bottom-right-radius: 0;
167
167
  padding-right: var(--space-xs-zb16t3, 8px);
168
168
  margin-right: var(--space-xxxs-zbmxqb, 2px);
169
169
  }
170
- .awsui_split-trigger-wrapper_sne0l_15mtc_158 > .awsui_trigger-item_sne0l_15mtc_161:not(#\9):not(:first-child) > .awsui_trigger-button_sne0l_15mtc_164 {
170
+ .awsui_split-trigger-wrapper_sne0l_hitos_158 > .awsui_trigger-item_sne0l_hitos_161:not(#\9):not(:first-child) > .awsui_trigger-button_sne0l_hitos_164 {
171
171
  border-top-left-radius: 0;
172
172
  border-bottom-left-radius: 0;
173
173
  padding-left: calc(var(--space-xs-zb16t3, 8px) - 2px);
174
174
  padding-right: calc(var(--space-xs-zb16t3, 8px) - 2px);
175
175
  }
176
- .awsui_split-trigger-wrapper_sne0l_15mtc_158 > .awsui_trigger-item_sne0l_15mtc_161:not(#\9):not(:first-child).awsui_visual-refresh_sne0l_15mtc_176 > .awsui_trigger-button_sne0l_15mtc_164 {
176
+ .awsui_split-trigger-wrapper_sne0l_hitos_158 > .awsui_trigger-item_sne0l_hitos_161:not(#\9):not(:first-child).awsui_visual-refresh_sne0l_hitos_176 > .awsui_trigger-button_sne0l_hitos_164 {
177
177
  padding-right: calc(var(--space-s-34lx8l, 12px) - 2px);
178
178
  }
179
179
 
180
- .awsui_split-trigger_sne0l_15mtc_158:not(#\9) {
180
+ .awsui_split-trigger_sne0l_hitos_158:not(#\9) {
181
181
  display: contents;
182
182
  }
183
183
 
184
- .awsui_dropdown-trigger_sne0l_15mtc_184:not(#\9) {
184
+ .awsui_dropdown-trigger_sne0l_hitos_184:not(#\9) {
185
185
  display: contents;
186
+ }
187
+
188
+ .awsui_test-utils-button-trigger_sne0l_hitos_188:not(#\9) {
189
+ /* used in test-utils */
186
190
  }
@@ -2,19 +2,20 @@
2
2
  // es-module interop with Babel and Typescript
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  module.exports.default = {
5
- "button-dropdown": "awsui_button-dropdown_sne0l_15mtc_93",
6
- "items-list-container": "awsui_items-list-container_sne0l_15mtc_97",
7
- "awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-0_sne0l_15mtc_1",
8
- "rotate-up": "awsui_rotate-up_sne0l_15mtc_114",
9
- "rotate-down": "awsui_rotate-down_sne0l_15mtc_129",
10
- "header": "awsui_header_sne0l_15mtc_144",
11
- "title": "awsui_title_sne0l_15mtc_153",
12
- "description": "awsui_description_sne0l_15mtc_154",
13
- "split-trigger-wrapper": "awsui_split-trigger-wrapper_sne0l_15mtc_158",
14
- "trigger-item": "awsui_trigger-item_sne0l_15mtc_161",
15
- "trigger-button": "awsui_trigger-button_sne0l_15mtc_164",
16
- "visual-refresh": "awsui_visual-refresh_sne0l_15mtc_176",
17
- "split-trigger": "awsui_split-trigger_sne0l_15mtc_158",
18
- "dropdown-trigger": "awsui_dropdown-trigger_sne0l_15mtc_184"
5
+ "button-dropdown": "awsui_button-dropdown_sne0l_hitos_93",
6
+ "items-list-container": "awsui_items-list-container_sne0l_hitos_97",
7
+ "awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-0_sne0l_hitos_1",
8
+ "rotate-up": "awsui_rotate-up_sne0l_hitos_114",
9
+ "rotate-down": "awsui_rotate-down_sne0l_hitos_129",
10
+ "header": "awsui_header_sne0l_hitos_144",
11
+ "title": "awsui_title_sne0l_hitos_153",
12
+ "description": "awsui_description_sne0l_hitos_154",
13
+ "split-trigger-wrapper": "awsui_split-trigger-wrapper_sne0l_hitos_158",
14
+ "trigger-item": "awsui_trigger-item_sne0l_hitos_161",
15
+ "trigger-button": "awsui_trigger-button_sne0l_hitos_164",
16
+ "visual-refresh": "awsui_visual-refresh_sne0l_hitos_176",
17
+ "split-trigger": "awsui_split-trigger_sne0l_hitos_158",
18
+ "dropdown-trigger": "awsui_dropdown-trigger_sne0l_hitos_184",
19
+ "test-utils-button-trigger": "awsui_test-utils-button-trigger_sne0l_hitos_188"
19
20
  };
20
21
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["form/index.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AASzC,OAAO,EAAE,SAAS,EAAE,CAAC;AA4BrB,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAAE,OAAqB,EAAE,GAAG,KAAK,EAAE,EAAE,SAAS,eAU1E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["form/index.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AASzC,OAAO,EAAE,SAAS,EAAE,CAAC;AAoBrB,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAAE,OAAqB,EAAE,GAAG,KAAK,EAAE,EAAE,SAAS,eAU1E"}
package/form/index.js CHANGED
@@ -19,7 +19,8 @@ const FormWithAnalytics = (_a) => {
19
19
  funnelSubmit();
20
20
  }
21
21
  };
22
- return (React.createElement(InternalForm, Object.assign({ variant: variant, actions: actions && (React.createElement(ButtonContext.Provider, { value: { onClick: handleActionButtonClick } }, actions)) }, props, funnelProps, funnelStepProps)));
22
+ return (React.createElement(ButtonContext.Provider, { value: { onClick: handleActionButtonClick } },
23
+ React.createElement(InternalForm, Object.assign({ variant: variant, actions: actions }, props, funnelProps, funnelStepProps))));
23
24
  };
24
25
  export default function Form(_a) {
25
26
  var { variant = 'full-page' } = _a, props = __rest(_a, ["variant"]);
package/form/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["form/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,YAAY,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,aAAa,EAAC,mBAAmB,EAAE,EAAE,EAAE,gBAAgB,EAAE,CAAC;QACpF,oBAAC,mBAAmB,IAAC,UAAU,EAAE,CAAC,EAAE,gBAAgB,EAAE,qBAAqB,EAAE;YAC3E,oBAAC,iBAAiB,kBAAC,OAAO,EAAE,OAAO,IAAM,KAAK,EAAM,kBAAkB,EAAI,CACtD,CACN,CACnB,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { FormProps } from './interfaces';\nimport InternalForm from './internal';\nimport useBaseComponent from '../internal/hooks/use-base-component';\n\nimport { AnalyticsFunnel, AnalyticsFunnelStep } from '../internal/analytics/components/analytics-funnel';\nimport { getFunnelNameSelector } from '../internal/analytics/selectors';\nimport { ButtonContext, ButtonContextProps } from '../internal/context/button-context';\nimport { useFunnel, useFunnelStep } from '../internal/analytics/hooks/use-funnel';\n\nexport { FormProps };\n\nconst FormWithAnalytics = ({ variant = 'full-page', actions, ...props }: FormProps) => {\n const { funnelProps, funnelSubmit, funnelNextOrSubmitAttempt } = useFunnel();\n const { funnelStepProps } = useFunnelStep();\n\n const handleActionButtonClick: ButtonContextProps['onClick'] = ({ variant }) => {\n if (variant === 'primary') {\n funnelNextOrSubmitAttempt();\n funnelSubmit();\n }\n };\n\n return (\n <InternalForm\n variant={variant}\n actions={\n actions && (\n <ButtonContext.Provider value={{ onClick: handleActionButtonClick }}>{actions}</ButtonContext.Provider>\n )\n }\n {...props}\n {...funnelProps}\n {...funnelStepProps}\n />\n );\n};\n\nexport default function Form({ variant = 'full-page', ...props }: FormProps) {\n const baseComponentProps = useBaseComponent('Form');\n\n return (\n <AnalyticsFunnel funnelType=\"single-page\" optionalStepNumbers={[]} totalFunnelSteps={1}>\n <AnalyticsFunnelStep stepNumber={1} stepNameSelector={getFunnelNameSelector()}>\n <FormWithAnalytics variant={variant} {...props} {...baseComponentProps} />\n </AnalyticsFunnelStep>\n </AnalyticsFunnel>\n );\n}\n\napplyDisplayName(Form, 'Form');\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["form/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,YAAY,MAAM,YAAY,CAAC;AACtC,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAC;AACzG,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,aAAa,EAAsB,MAAM,oCAAoC,CAAC;AACvF,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAIlF,MAAM,iBAAiB,GAAG,CAAC,EAAuD,EAAE,EAAE;QAA3D,EAAE,OAAO,GAAG,WAAW,EAAE,OAAO,OAAuB,EAAlB,KAAK,cAA1C,sBAA4C,CAAF;IACnE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,yBAAyB,EAAE,GAAG,SAAS,EAAE,CAAC;IAC7E,MAAM,EAAE,eAAe,EAAE,GAAG,aAAa,EAAE,CAAC;IAE5C,MAAM,uBAAuB,GAAkC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;QAC7E,IAAI,OAAO,KAAK,SAAS,EAAE;YACzB,yBAAyB,EAAE,CAAC;YAC5B,YAAY,EAAE,CAAC;SAChB;IACH,CAAC,CAAC;IAEF,OAAO,CACL,oBAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,OAAO,EAAE,uBAAuB,EAAE;QACjE,oBAAC,YAAY,kBAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,IAAM,KAAK,EAAM,WAAW,EAAM,eAAe,EAAI,CAC9E,CAC1B,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAA8C;QAA9C,EAAE,OAAO,GAAG,WAAW,OAAuB,EAAlB,KAAK,cAAjC,WAAmC,CAAF;IAC5D,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAEpD,OAAO,CACL,oBAAC,eAAe,IAAC,UAAU,EAAC,aAAa,EAAC,mBAAmB,EAAE,EAAE,EAAE,gBAAgB,EAAE,CAAC;QACpF,oBAAC,mBAAmB,IAAC,UAAU,EAAE,CAAC,EAAE,gBAAgB,EAAE,qBAAqB,EAAE;YAC3E,oBAAC,iBAAiB,kBAAC,OAAO,EAAE,OAAO,IAAM,KAAK,EAAM,kBAAkB,EAAI,CACtD,CACN,CACnB,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { FormProps } from './interfaces';\nimport InternalForm from './internal';\nimport useBaseComponent from '../internal/hooks/use-base-component';\n\nimport { AnalyticsFunnel, AnalyticsFunnelStep } from '../internal/analytics/components/analytics-funnel';\nimport { getFunnelNameSelector } from '../internal/analytics/selectors';\nimport { ButtonContext, ButtonContextProps } from '../internal/context/button-context';\nimport { useFunnel, useFunnelStep } from '../internal/analytics/hooks/use-funnel';\n\nexport { FormProps };\n\nconst FormWithAnalytics = ({ variant = 'full-page', actions, ...props }: FormProps) => {\n const { funnelProps, funnelSubmit, funnelNextOrSubmitAttempt } = useFunnel();\n const { funnelStepProps } = useFunnelStep();\n\n const handleActionButtonClick: ButtonContextProps['onClick'] = ({ variant }) => {\n if (variant === 'primary') {\n funnelNextOrSubmitAttempt();\n funnelSubmit();\n }\n };\n\n return (\n <ButtonContext.Provider value={{ onClick: handleActionButtonClick }}>\n <InternalForm variant={variant} actions={actions} {...props} {...funnelProps} {...funnelStepProps} />\n </ButtonContext.Provider>\n );\n};\n\nexport default function Form({ variant = 'full-page', ...props }: FormProps) {\n const baseComponentProps = useBaseComponent('Form');\n\n return (\n <AnalyticsFunnel funnelType=\"single-page\" optionalStepNumbers={[]} totalFunnelSteps={1}>\n <AnalyticsFunnelStep stepNumber={1} stepNameSelector={getFunnelNameSelector()}>\n <FormWithAnalytics variant={variant} {...props} {...baseComponentProps} />\n </AnalyticsFunnelStep>\n </AnalyticsFunnel>\n );\n}\n\napplyDisplayName(Form, 'Form');\n"]}
@@ -5,7 +5,7 @@ export declare const FUNNEL_VERSION = "1.0";
5
5
  type AnalyticsFunnelProps = {
6
6
  children?: React.ReactNode;
7
7
  } & Pick<FunnelProps, 'funnelType' | 'optionalStepNumbers' | 'totalFunnelSteps'>;
8
- export declare const AnalyticsFunnel: ({ children, ...props }: AnalyticsFunnelProps) => JSX.Element;
8
+ export declare const AnalyticsFunnel: (props: AnalyticsFunnelProps) => JSX.Element;
9
9
  type AnalyticsFunnelStepProps = {
10
10
  children?: React.ReactNode | ((props: FunnelStepContextValue) => React.ReactNode);
11
11
  } & Pick<FunnelStepProps, 'stepNumber' | 'stepNameSelector'>;
@@ -1 +1 @@
1
- {"version":3,"file":"analytics-funnel.d.ts","sourceRoot":"lib/default/","sources":["internal/analytics/components/analytics-funnel.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAEvE,OAAO,EAKL,sBAAsB,EAGvB,MAAM,8BAA8B,CAAC;AAQtC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAW7D,eAAO,MAAM,cAAc,QAAQ,CAAC;AAEpC,KAAK,oBAAoB,GAAG;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,GA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AAG,kBAAkB,CAAC,CAAC;AAE7D,eAAO,MAAM,mBAAmB,UAAW,wBAAwB,gBAMlE,CAAC;AAyFF,UAAU,2BAA2B;IACnC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,eAAO,MAAM,sBAAsB,iBAAkB,2BAA2B,gBAmF/E,CAAC"}
@@ -10,7 +10,20 @@ import { PACKAGE_VERSION } from '../../environment';
10
10
  import { FunnelMetrics } from '../';
11
11
  import { DATA_ATTR_FUNNEL_STEP, getFunnelNameSelector, getNameFromSelector, getSubStepAllSelector, getSubStepNameSelector, getSubStepSelector, } from '../selectors';
12
12
  export const FUNNEL_VERSION = '1.0';
13
- export const AnalyticsFunnel = (_a) => {
13
+ export const AnalyticsFunnel = (props) => {
14
+ const { isInFunnel } = useFunnel();
15
+ /*
16
+ If the current funnel component is a Form (i.e. single-page funnel), it should
17
+ defer its funnel-handling to a parent Form element, if present.
18
+ Wizards (i.e. multi-page funnels) always take highest precedence for handling funnels,
19
+ and do not defer to any other element.
20
+ */
21
+ if (isInFunnel && props.funnelType === 'single-page') {
22
+ return React.createElement(React.Fragment, null, props.children);
23
+ }
24
+ return React.createElement(InnerAnalyticsFunnel, Object.assign({}, props));
25
+ };
26
+ const InnerAnalyticsFunnel = (_a) => {
14
27
  var { children } = _a, props = __rest(_a, ["children"]);
15
28
  const [funnelInteractionId, setFunnelInteractionId] = useState('');
16
29
  const [submissionAttempt, setSubmissionAttempt] = useState(0);
@@ -18,6 +31,7 @@ export const AnalyticsFunnel = (_a) => {
18
31
  const funnelState = useRef('default');
19
32
  const errorCount = useRef(0);
20
33
  const loadingButtonCount = useRef(0);
34
+ const wizardCount = useRef(0);
21
35
  const latestFocusCleanupFunction = useRef(undefined);
22
36
  // This useEffect hook is run once on component mount to initiate the funnel analytics.
23
37
  // It first calls the 'funnelStart' method from FunnelMetrics, providing all necessary details
@@ -30,23 +44,37 @@ export const AnalyticsFunnel = (_a) => {
30
44
  // The eslint-disable is required as we deliberately want this effect to run only once on mount and unmount,
31
45
  // hence we do not provide any dependencies.
32
46
  useEffect(() => {
33
- // Reset the state, in case the component was re-mounted.
34
- funnelState.current = 'default';
35
- const funnelInteractionId = FunnelMetrics.funnelStart({
36
- funnelNameSelector: getFunnelNameSelector(),
37
- optionalStepNumbers: props.optionalStepNumbers,
38
- funnelType: props.funnelType,
39
- totalFunnelSteps: props.totalFunnelSteps,
40
- componentVersion: PACKAGE_VERSION,
41
- theme: isVisualRefresh ? 'vr' : 'classic',
42
- funnelVersion: FUNNEL_VERSION,
43
- });
44
- setFunnelInteractionId(funnelInteractionId);
47
+ /*
48
+ We run this effect with a delay, in order to detect whether this funnel contains a Wizard.
49
+ If it does contain a Wizard, that Wizard should take precedence for handling the funnel, and
50
+ this current funnel component should do nothing.
51
+ */
52
+ const handle = setTimeout(() => {
53
+ if (props.funnelType === 'single-page' && wizardCount.current > 0) {
54
+ return;
55
+ }
56
+ // Reset the state, in case the component was re-mounted.
57
+ funnelState.current = 'default';
58
+ const funnelInteractionId = FunnelMetrics.funnelStart({
59
+ funnelNameSelector: getFunnelNameSelector(),
60
+ optionalStepNumbers: props.optionalStepNumbers,
61
+ funnelType: props.funnelType,
62
+ totalFunnelSteps: props.totalFunnelSteps,
63
+ componentVersion: PACKAGE_VERSION,
64
+ theme: isVisualRefresh ? 'vr' : 'classic',
65
+ funnelVersion: FUNNEL_VERSION,
66
+ });
67
+ setFunnelInteractionId(funnelInteractionId);
68
+ }, 1);
45
69
  /*
46
70
  A funnel counts as "successful" if it is unmounted after being "complete".
47
71
  */
48
72
  /* eslint-disable react-hooks/exhaustive-deps */
49
73
  return () => {
74
+ clearTimeout(handle);
75
+ if (props.funnelType === 'single-page' && wizardCount.current > 0) {
76
+ return;
77
+ }
50
78
  if (funnelState.current === 'validating') {
51
79
  // Finish the validation phase early.
52
80
  FunnelMetrics.funnelComplete({ funnelInteractionId });
@@ -112,17 +140,23 @@ export const AnalyticsFunnel = (_a) => {
112
140
  errorCount,
113
141
  loadingButtonCount,
114
142
  latestFocusCleanupFunction,
143
+ isInFunnel: true,
144
+ wizardCount,
115
145
  };
116
146
  return React.createElement(FunnelContext.Provider, { value: funnelContextValue }, children);
117
147
  };
118
- export const AnalyticsFunnelStep = (props) => (
119
- /*
120
- This wrapper is used to apply a `key` property to the actual (inner) AnalyticsFunnelStep
121
- element. This allows us to keep the state and effects separate per step.
122
- */
123
- React.createElement(InnerAnalyticsFunnelStep, Object.assign({}, props, { key: props.stepNumber })));
148
+ export const AnalyticsFunnelStep = (props) => {
149
+ /*
150
+ This wrapper is used to apply a `key` property to the actual (inner) AnalyticsFunnelStep
151
+ element. This allows us to keep the state and effects separate per step.
152
+ */
153
+ return React.createElement(InnerAnalyticsFunnelStep, Object.assign({}, props, { key: props.stepNumber }));
154
+ };
124
155
  const InnerAnalyticsFunnelStep = ({ children, stepNumber, stepNameSelector }) => {
125
- const { funnelInteractionId, funnelState } = useFunnel();
156
+ const { funnelInteractionId, funnelState, funnelType } = useFunnel();
157
+ const parentStep = useFunnelStep();
158
+ const parentStepExists = parentStep.isInStep;
159
+ const parentStepFunnelInteractionId = parentStep.funnelInteractionId;
126
160
  const funnelStepProps = { [DATA_ATTR_FUNNEL_STEP]: stepNumber };
127
161
  const subStepCount = useRef(0);
128
162
  // This useEffect hook is used to track the start and completion of interaction with the step.
@@ -130,8 +164,20 @@ const InnerAnalyticsFunnelStep = ({ children, stepNumber, stepNameSelector }) =>
130
164
  // to record the beginning of the interaction with the current step.
131
165
  // On unmount, it does a similar thing but this time calling 'funnelStepComplete' to record the completion of the interaction.
132
166
  useEffect(() => {
167
+ if (!funnelInteractionId) {
168
+ // This step is not inside an active funnel.
169
+ return;
170
+ }
171
+ if (parentStepExists && parentStepFunnelInteractionId) {
172
+ /*
173
+ This step is inside another step, which already reports events as
174
+ part of an active funnel (i.e. that step is not a parent of a Wizard).
175
+ Thus, this current step does not need to report any events.
176
+ */
177
+ return;
178
+ }
133
179
  const stepName = getNameFromSelector(stepNameSelector);
134
- if (funnelInteractionId && funnelState.current === 'default') {
180
+ if (funnelState.current === 'default') {
135
181
  FunnelMetrics.funnelStepStart({
136
182
  funnelInteractionId,
137
183
  stepNumber,
@@ -143,7 +189,7 @@ const InnerAnalyticsFunnelStep = ({ children, stepNumber, stepNameSelector }) =>
143
189
  }
144
190
  return () => {
145
191
  // eslint-disable-next-line react-hooks/exhaustive-deps
146
- if (funnelInteractionId && funnelState.current !== 'cancelled') {
192
+ if (funnelState.current !== 'cancelled') {
147
193
  FunnelMetrics.funnelStepComplete({
148
194
  funnelInteractionId,
149
195
  stepNumber,
@@ -155,10 +201,30 @@ const InnerAnalyticsFunnelStep = ({ children, stepNumber, stepNameSelector }) =>
155
201
  });
156
202
  }
157
203
  };
158
- //eslint-disable-next-line react-hooks/exhaustive-deps
159
- }, [funnelInteractionId, stepNumber, stepNameSelector]);
160
- const contextValue = { stepNumber, stepNameSelector, funnelStepProps, subStepCount };
161
- return (React.createElement(FunnelStepContext.Provider, { value: contextValue }, typeof children === 'function' ? children(contextValue) : children));
204
+ }, [
205
+ funnelInteractionId,
206
+ stepNumber,
207
+ stepNameSelector,
208
+ funnelState,
209
+ parentStepExists,
210
+ funnelType,
211
+ parentStepFunnelInteractionId,
212
+ ]);
213
+ const contextValue = {
214
+ stepNumber,
215
+ stepNameSelector,
216
+ funnelStepProps,
217
+ subStepCount,
218
+ isInStep: true,
219
+ funnelInteractionId,
220
+ };
221
+ /*
222
+ If this step is inside another step which already reports events as part of an active
223
+ funnel (i.e. that step is not a parent of a Wizard), the current step becomes invisible
224
+ in the hierarchy by passing the context of its parent through.
225
+ */
226
+ const effectiveContextValue = parentStepExists && parentStepFunnelInteractionId ? parentStep : contextValue;
227
+ return (React.createElement(FunnelStepContext.Provider, { value: effectiveContextValue }, typeof children === 'function' ? children(effectiveContextValue) : children));
162
228
  };
163
229
  export const AnalyticsFunnelSubStep = ({ children }) => {
164
230
  const subStepId = useUniqueId('substep');