@cloudscape-design/components-themeable 3.0.271 → 3.0.273

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 (55) hide show
  1. package/lib/internal/manifest.json +1 -1
  2. package/lib/internal/scss/button/styles.scss +2 -8
  3. package/lib/internal/scss/collection-preferences/content-display/sortable-item.scss +1 -1
  4. package/lib/internal/scss/expandable-section/styles.scss +16 -2
  5. package/lib/internal/scss/file-upload/file-input/styles.scss +8 -0
  6. package/lib/internal/template/attribute-editor/interfaces.d.ts +3 -2
  7. package/lib/internal/template/attribute-editor/interfaces.d.ts.map +1 -1
  8. package/lib/internal/template/attribute-editor/interfaces.js.map +1 -1
  9. package/lib/internal/template/attribute-editor/row.d.ts.map +1 -1
  10. package/lib/internal/template/attribute-editor/row.js +2 -1
  11. package/lib/internal/template/attribute-editor/row.js.map +1 -1
  12. package/lib/internal/template/autosuggest/options-controller.d.ts +1 -1
  13. package/lib/internal/template/autosuggest/options-controller.d.ts.map +1 -1
  14. package/lib/internal/template/autosuggest/options-controller.js +22 -23
  15. package/lib/internal/template/autosuggest/options-controller.js.map +1 -1
  16. package/lib/internal/template/autosuggest/options-list.d.ts.map +1 -1
  17. package/lib/internal/template/autosuggest/options-list.js +1 -2
  18. package/lib/internal/template/autosuggest/options-list.js.map +1 -1
  19. package/lib/internal/template/button/internal.d.ts +0 -1
  20. package/lib/internal/template/button/internal.d.ts.map +1 -1
  21. package/lib/internal/template/button/internal.js +1 -3
  22. package/lib/internal/template/button/internal.js.map +1 -1
  23. package/lib/internal/template/button/styles.css.js +18 -20
  24. package/lib/internal/template/button/styles.scoped.css +136 -298
  25. package/lib/internal/template/button/styles.selectors.js +18 -20
  26. package/lib/internal/template/collection-preferences/content-display/styles.css.js +15 -15
  27. package/lib/internal/template/collection-preferences/content-display/styles.scoped.css +24 -24
  28. package/lib/internal/template/collection-preferences/content-display/styles.selectors.js +15 -15
  29. package/lib/internal/template/collection-preferences/styles.css.js +36 -36
  30. package/lib/internal/template/collection-preferences/styles.scoped.css +46 -46
  31. package/lib/internal/template/collection-preferences/styles.selectors.js +36 -36
  32. package/lib/internal/template/expandable-section/expandable-section-header.js +1 -1
  33. package/lib/internal/template/expandable-section/expandable-section-header.js.map +1 -1
  34. package/lib/internal/template/expandable-section/styles.css.js +24 -23
  35. package/lib/internal/template/expandable-section/styles.scoped.css +66 -44
  36. package/lib/internal/template/expandable-section/styles.selectors.js +24 -23
  37. package/lib/internal/template/file-upload/file-input/index.d.ts.map +1 -1
  38. package/lib/internal/template/file-upload/file-input/index.js +2 -1
  39. package/lib/internal/template/file-upload/file-input/index.js.map +1 -1
  40. package/lib/internal/template/file-upload/file-input/styles.css.js +4 -3
  41. package/lib/internal/template/file-upload/file-input/styles.scoped.css +107 -4
  42. package/lib/internal/template/file-upload/file-input/styles.selectors.js +4 -3
  43. package/lib/internal/template/internal/components/autosuggest-input/index.js +1 -1
  44. package/lib/internal/template/internal/components/autosuggest-input/index.js.map +1 -1
  45. package/lib/internal/template/internal/components/options-list/utils/test-indexes.d.ts +1 -1
  46. package/lib/internal/template/internal/components/options-list/utils/test-indexes.d.ts.map +1 -1
  47. package/lib/internal/template/internal/components/options-list/utils/test-indexes.js.map +1 -1
  48. package/lib/internal/template/internal/environment.js +1 -1
  49. package/lib/internal/template/tag-editor/index.d.ts.map +1 -1
  50. package/lib/internal/template/tag-editor/index.js +6 -1
  51. package/lib/internal/template/tag-editor/index.js.map +1 -1
  52. package/lib/internal/template/tag-editor/interfaces.d.ts +1 -0
  53. package/lib/internal/template/tag-editor/interfaces.d.ts.map +1 -1
  54. package/lib/internal/template/tag-editor/interfaces.js.map +1 -1
  55. package/package.json +1 -1
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "db6bd09c052e0598e2a9c2e90d09ddbf4b6a7b38"
2
+ "commit": "51fcfbb24e561426e56decb7f9c81949265eb0b4"
3
3
  }
@@ -38,13 +38,7 @@
38
38
  text-decoration: none;
39
39
  }
40
40
 
41
- &:not(.hide-focus-outline) {
42
- @include focus-visible.when-visible {
43
- @include styles.focus-highlight(awsui.$space-button-focus-outline-gutter);
44
- }
45
- }
46
- // stylelint-disable-next-line selector-combinator-disallowed-list
47
- body[data-awsui-focus-visible='true'] &.force-focus-outline {
41
+ @include focus-visible.when-visible {
48
42
  @include styles.focus-highlight(awsui.$space-button-focus-outline-gutter);
49
43
  }
50
44
  &.variant-icon,
@@ -59,7 +53,7 @@
59
53
  );
60
54
  }
61
55
  }
62
- &.variant-inline-icon:not(.hide-focus-outline) {
56
+ &.variant-inline-icon {
63
57
  @include focus-visible.when-visible {
64
58
  @include styles.focus-highlight(awsui.$space-button-inline-icon-focus-outline-gutter);
65
59
  }
@@ -44,7 +44,7 @@ $border-radius: awsui.$border-radius-item;
44
44
  display: flex;
45
45
  flex-wrap: nowrap;
46
46
  justify-content: space-between;
47
- align-items: start;
47
+ align-items: flex-start;
48
48
  padding-top: awsui.$space-xs;
49
49
  padding-bottom: awsui.$space-xs;
50
50
  padding-right: 0;
@@ -99,6 +99,16 @@
99
99
  padding: 0;
100
100
  }
101
101
 
102
+ &-button {
103
+ box-sizing: border-box;
104
+ display: flex;
105
+
106
+ // Header buttons for non-container variants show the focus ring directly
107
+ @include focus-visible.when-visible {
108
+ @include styles.focus-highlight(0px);
109
+ }
110
+ }
111
+
102
112
  &-container {
103
113
  width: 100%;
104
114
  // The icon-container style is kept for variant='container' and header
@@ -106,17 +116,21 @@
106
116
  margin-top: awsui.$space-expandable-section-icon-offset-top;
107
117
  }
108
118
 
109
- &[data-awsui-focus-visible='true']:focus-within {
119
+ // stylelint-disable-next-line selector-combinator-disallowed-list
120
+ body[data-awsui-focus-visible='true'] &:focus-within {
110
121
  outline: none;
111
122
  text-decoration: none;
112
123
  padding: container.$header-focus-visible-padding;
113
124
 
114
125
  @include styles.form-focus-element(awsui.$border-radius-control-default-focus-ring);
115
126
  }
127
+
128
+ // Header buttons that sit in a container should not show focus because the parent container has a focus ring already
116
129
  &-button {
117
130
  box-sizing: border-box;
118
131
  display: flex;
119
- &:focus {
132
+
133
+ @include focus-visible.when-visible {
120
134
  outline: none;
121
135
  text-decoration: none;
122
136
  }
@@ -4,6 +4,7 @@
4
4
  */
5
5
 
6
6
  @use '../../internal/styles/tokens' as awsui;
7
+ @use '../../internal/styles' as styles;
7
8
 
8
9
  .upload-button,
9
10
  .upload-input {
@@ -18,3 +19,10 @@
18
19
  position: absolute;
19
20
  clip: rect(0, 0, 0, 0);
20
21
  }
22
+
23
+ .upload-button {
24
+ // stylelint-disable-next-line selector-combinator-disallowed-list
25
+ body[data-awsui-focus-visible='true'] &.force-focus-outline {
26
+ @include styles.focus-highlight(awsui.$space-button-focus-outline-gutter);
27
+ }
28
+ }
@@ -31,9 +31,10 @@ export declare namespace AttributeEditorProps {
31
31
  */
32
32
  focusAddButton(): void;
33
33
  }
34
- interface I18nStrings {
34
+ interface I18nStrings<T = any> {
35
35
  errorIconAriaLabel?: string;
36
36
  itemRemovedAriaLive?: string;
37
+ removeButtonAriaLabel?: (item: T) => string;
37
38
  }
38
39
  }
39
40
  export interface AttributeEditorProps<T> extends BaseComponentProps {
@@ -92,6 +93,6 @@ export interface AttributeEditorProps<T> extends BaseComponentProps {
92
93
  /**
93
94
  * An object containing all the necessary localized strings required by the component.
94
95
  */
95
- i18nStrings?: AttributeEditorProps.I18nStrings;
96
+ i18nStrings?: AttributeEditorProps.I18nStrings<T>;
96
97
  }
97
98
  //# sourceMappingURL=interfaces.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"lib/default/","sources":["attribute-editor/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAY/D,MAAM,WAAW,6BAA6B;IAC5C,CAAC,CAAC,EAAE,KAAK,EAA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CAAC,CAAC,CAAC;IAElE;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;;;;;;;OAUG;IACH,UAAU,EAAE,aAAa,CAAC,oBAAoB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAEnE;;OAEG;IACH,gBAAgB,CAAC,EAAE,yBAAyB,CAAC;IAE7C;;;OAGG;IACH,mBAAmB,CAAC,EAAE,yBAAyB,CAAC,oBAAoB,CAAC,uBAAuB,CAAC,CAAC;IAE9F;;OAEG;IACH,WAAW,CAAC,EAAE,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;CACnD"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["attribute-editor/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 { NonCancelableEventHandler } from '../internal/events';\n\n/*\n * HACK: Cast the component to a named parametrized interface.\n *\n * This lets us use React.forwardRef and still let the component have type\n * parameters, and the naming convention lets the documenter know that this is\n * a forwardRef-wrapped component.\n *\n * We don't need to expose this type to customers because it's just a simple\n * function type.\n */\nexport interface AttributeEditorForwardRefType {\n <T>(props: AttributeEditorProps<T> & { ref?: React.Ref<AttributeEditorProps.Ref> }): JSX.Element;\n}\n\nexport namespace AttributeEditorProps {\n export interface IsItemRemovableFunction<T> {\n (item: T): boolean;\n }\n\n export type FieldRenderable<T> = (item: T, itemIndex: number) => React.ReactNode;\n export interface FieldDefinition<T> {\n label?: React.ReactNode;\n info?: React.ReactNode;\n control?: FieldRenderable<T> | React.ReactNode;\n errorText?: FieldRenderable<T> | React.ReactNode;\n constraintText?: FieldRenderable<T> | React.ReactNode;\n }\n\n export interface RemoveButtonClickDetail {\n itemIndex: number;\n }\n\n export interface Ref {\n /**\n * Focuses the 'remove' button for the given row index.\n */\n focusRemoveButton(itemIndex: number): void;\n /**\n * Focuses the 'add' button. Use this, for example, after a user removes the last row.\n */\n focusAddButton(): void;\n }\n\n export interface I18nStrings {\n errorIconAriaLabel?: string;\n\n itemRemovedAriaLive?: string;\n }\n}\n\nexport interface AttributeEditorProps<T> extends BaseComponentProps {\n /**\n * Displayed when there are no items to display.\n */\n empty?: React.ReactNode;\n\n /**\n * Displayed below the add button. Use it for additional information related to the attribute editor.\n */\n additionalInfo?: React.ReactNode;\n\n /**\n * Specifies the text that's displayed in the add button.\n */\n addButtonText: string;\n\n /**\n * Specifies the text that's displayed in the remove button.\n */\n removeButtonText: string;\n\n /**\n * Specifies the items that serve as the data source for all rows.\n * The display of a row is handled by the `definition` property.\n */\n items?: ReadonlyArray<T>;\n\n /**\n * Function that determines whether an item is removable. When this function returns `false`, the remove\n * button is not rendered and the user can't remove the item.\n * By default, all items are removable.\n */\n isItemRemovable?: AttributeEditorProps.IsItemRemovableFunction<T>;\n\n /**\n * Determines whether the add button is disabled.\n */\n disableAddButton?: boolean;\n\n /**\n * Defines the editor configuration. Each object in the array represents one form field in the row.\n * * `label` (ReactNode) - Text label for the form field.\n * * `info` (ReactNode) - Info link for the form field.\n * * `errorText` ((item, itemIndex) => ReactNode) - Error message text to display as a control validation message.\n * It renders the form field as invalid if the returned value is not `null` or `undefined`.\n * * `constraintText` ((item, itemIndex) => ReactNode) - Text to display as a constraint message below the field.\n * * `control` ((item, itemIndex) => ReactNode) - A control to use as the input for the field.\n *\n * A maximum of four fields are supported.\n */\n definition: ReadonlyArray<AttributeEditorProps.FieldDefinition<T>>;\n\n /**\n * Called when add button is clicked.\n */\n onAddButtonClick?: NonCancelableEventHandler;\n\n /**\n * Called when remove button is clicked.\n * The event `detail` contains the index of the corresponding item.\n */\n onRemoveButtonClick?: NonCancelableEventHandler<AttributeEditorProps.RemoveButtonClickDetail>;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n */\n i18nStrings?: AttributeEditorProps.I18nStrings;\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["attribute-editor/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 { NonCancelableEventHandler } from '../internal/events';\n\n/*\n * HACK: Cast the component to a named parametrized interface.\n *\n * This lets us use React.forwardRef and still let the component have type\n * parameters, and the naming convention lets the documenter know that this is\n * a forwardRef-wrapped component.\n *\n * We don't need to expose this type to customers because it's just a simple\n * function type.\n */\nexport interface AttributeEditorForwardRefType {\n <T>(props: AttributeEditorProps<T> & { ref?: React.Ref<AttributeEditorProps.Ref> }): JSX.Element;\n}\n\nexport namespace AttributeEditorProps {\n export interface IsItemRemovableFunction<T> {\n (item: T): boolean;\n }\n\n export type FieldRenderable<T> = (item: T, itemIndex: number) => React.ReactNode;\n export interface FieldDefinition<T> {\n label?: React.ReactNode;\n info?: React.ReactNode;\n control?: FieldRenderable<T> | React.ReactNode;\n errorText?: FieldRenderable<T> | React.ReactNode;\n constraintText?: FieldRenderable<T> | React.ReactNode;\n }\n\n export interface RemoveButtonClickDetail {\n itemIndex: number;\n }\n\n export interface Ref {\n /**\n * Focuses the 'remove' button for the given row index.\n */\n focusRemoveButton(itemIndex: number): void;\n /**\n * Focuses the 'add' button. Use this, for example, after a user removes the last row.\n */\n focusAddButton(): void;\n }\n\n export interface I18nStrings<T = any> {\n errorIconAriaLabel?: string;\n itemRemovedAriaLive?: string;\n removeButtonAriaLabel?: (item: T) => string;\n }\n}\n\nexport interface AttributeEditorProps<T> extends BaseComponentProps {\n /**\n * Displayed when there are no items to display.\n */\n empty?: React.ReactNode;\n\n /**\n * Displayed below the add button. Use it for additional information related to the attribute editor.\n */\n additionalInfo?: React.ReactNode;\n\n /**\n * Specifies the text that's displayed in the add button.\n */\n addButtonText: string;\n\n /**\n * Specifies the text that's displayed in the remove button.\n */\n removeButtonText: string;\n\n /**\n * Specifies the items that serve as the data source for all rows.\n * The display of a row is handled by the `definition` property.\n */\n items?: ReadonlyArray<T>;\n\n /**\n * Function that determines whether an item is removable. When this function returns `false`, the remove\n * button is not rendered and the user can't remove the item.\n * By default, all items are removable.\n */\n isItemRemovable?: AttributeEditorProps.IsItemRemovableFunction<T>;\n\n /**\n * Determines whether the add button is disabled.\n */\n disableAddButton?: boolean;\n\n /**\n * Defines the editor configuration. Each object in the array represents one form field in the row.\n * * `label` (ReactNode) - Text label for the form field.\n * * `info` (ReactNode) - Info link for the form field.\n * * `errorText` ((item, itemIndex) => ReactNode) - Error message text to display as a control validation message.\n * It renders the form field as invalid if the returned value is not `null` or `undefined`.\n * * `constraintText` ((item, itemIndex) => ReactNode) - Text to display as a constraint message below the field.\n * * `control` ((item, itemIndex) => ReactNode) - A control to use as the input for the field.\n *\n * A maximum of four fields are supported.\n */\n definition: ReadonlyArray<AttributeEditorProps.FieldDefinition<T>>;\n\n /**\n * Called when add button is clicked.\n */\n onAddButtonClick?: NonCancelableEventHandler;\n\n /**\n * Called when remove button is clicked.\n * The event `detail` contains the index of the corresponding item.\n */\n onRemoveButtonClick?: NonCancelableEventHandler<AttributeEditorProps.RemoveButtonClickDetail>;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n */\n i18nStrings?: AttributeEditorProps.I18nStrings<T>;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"row.d.ts","sourceRoot":"lib/default/","sources":["attribute-editor/row.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAE3C,OAA6B,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAA0B,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAQvF,MAAM,WAAW,QAAQ,CAAC,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G,SAAS,CAAC,CAAC;IACrD,mBAAmB,CAAC,EAAE,yBAAyB,CAAC,oBAAoB,CAAC,uBAAuB,CAAC,CAAC;CAC/F;AAYD,eAAO,MAAM,GAAG,yLA2Ef,CAAC"}
@@ -17,6 +17,7 @@ function render(item, itemIndex, slot) {
17
17
  const GRID_DEFINITION = [{ colspan: { default: 12, xs: 9 } }];
18
18
  const REMOVABLE_GRID_DEFINITION = [{ colspan: { default: 12, xs: 9 } }, { colspan: { default: 12, xs: 3 } }];
19
19
  export const Row = React.memo(({ breakpoint, item, definition, i18nStrings = {}, index, removable, removeButtonText, removeButtonRefs, onRemoveButtonClick, }) => {
20
+ var _a;
20
21
  const isNarrowViewport = breakpoint === 'default' || breakpoint === 'xxs';
21
22
  const isWideViewport = !isNarrowViewport;
22
23
  const handleRemoveClick = useCallback(() => {
@@ -30,7 +31,7 @@ export const Row = React.memo(({ breakpoint, item, definition, i18nStrings = {},
30
31
  removable && (React.createElement(ButtonContainer, { index: index, isNarrowViewport: isNarrowViewport, hasLabel: definition.some(row => row.label) },
31
32
  React.createElement(InternalButton, { className: styles['remove-button'], formAction: "none", ref: ref => {
32
33
  removeButtonRefs[index] = ref !== null && ref !== void 0 ? ref : undefined;
33
- }, onClick: handleRemoveClick }, removeButtonText))))),
34
+ }, ariaLabel: (_a = i18nStrings.removeButtonAriaLabel) === null || _a === void 0 ? void 0 : _a.call(i18nStrings, item), onClick: handleRemoveClick }, removeButtonText))))),
34
35
  isNarrowViewport && React.createElement(Divider, null)));
35
36
  });
36
37
  const ButtonContainer = ({ index, children, isNarrowViewport, hasLabel }) => (React.createElement("div", { className: clsx({
@@ -1 +1 @@
1
- {"version":3,"file":"row.js","sourceRoot":"lib/default/","sources":["attribute-editor/row.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,KAAK,EAAE,EA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QAAQ,CACL,CACP,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport InternalBox from '../box/internal';\nimport styles from './styles.css.js';\nimport React, { useCallback } from 'react';\nimport InternalFormField from '../form-field/internal';\nimport InternalColumnLayout, { ColumnLayoutBreakpoint } from '../column-layout/internal';\nimport { AttributeEditorProps } from './interfaces';\nimport { ButtonProps } from '../button/interfaces';\nimport { fireNonCancelableEvent, NonCancelableEventHandler } from '../internal/events';\nimport InternalGrid from '../grid/internal';\nimport { InternalButton } from '../button/internal';\nimport clsx from 'clsx';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\n\nconst Divider = () => <InternalBox className={styles.divider} padding={{ top: 'l' }} />;\n\nexport interface RowProps<T> {\n breakpoint: ColumnLayoutBreakpoint | null;\n item: T;\n definition: ReadonlyArray<AttributeEditorProps.FieldDefinition<T>>;\n i18nStrings: AttributeEditorProps.I18nStrings | undefined;\n index: number;\n removable: boolean;\n removeButtonText: string;\n removeButtonRefs: Array<ButtonProps.Ref | undefined>;\n onRemoveButtonClick?: NonCancelableEventHandler<AttributeEditorProps.RemoveButtonClickDetail>;\n}\n\nfunction render<T>(\n item: T,\n itemIndex: number,\n slot: AttributeEditorProps.FieldRenderable<T> | React.ReactNode | undefined\n) {\n return typeof slot === 'function' ? slot(item, itemIndex) : slot;\n}\n\nconst GRID_DEFINITION = [{ colspan: { default: 12, xs: 9 } }];\nconst REMOVABLE_GRID_DEFINITION = [{ colspan: { default: 12, xs: 9 } }, { colspan: { default: 12, xs: 3 } }];\nexport const Row = React.memo(\n <T,>({\n breakpoint,\n item,\n definition,\n i18nStrings = {},\n index,\n removable,\n removeButtonText,\n removeButtonRefs,\n onRemoveButtonClick,\n }: RowProps<T>) => {\n const isNarrowViewport = breakpoint === 'default' || breakpoint === 'xxs';\n const isWideViewport = !isNarrowViewport;\n\n const handleRemoveClick = useCallback(() => {\n fireNonCancelableEvent(onRemoveButtonClick, { itemIndex: index });\n }, [onRemoveButtonClick, index]);\n\n const firstControlId = useUniqueId('first-control-id-');\n\n return (\n <InternalBox className={styles.row} margin={{ bottom: 's' }}>\n <div role=\"group\" aria-labelledby={`${firstControlId}-label ${firstControlId}`}>\n <InternalGrid\n __breakpoint={breakpoint}\n gridDefinition={removable ? REMOVABLE_GRID_DEFINITION : GRID_DEFINITION}\n >\n <InternalColumnLayout\n className={styles['row-control']}\n columns={definition.length}\n __breakpoint={breakpoint}\n >\n {definition.map(({ info, label, constraintText, errorText, control }, defIndex) => (\n <InternalFormField\n key={defIndex}\n className={styles.field}\n label={label}\n info={info}\n constraintText={render(item, index, constraintText)}\n errorText={render(item, index, errorText)}\n stretch={true}\n i18nStrings={{ errorIconAriaLabel: i18nStrings.errorIconAriaLabel }}\n __hideLabel={isWideViewport && index > 0}\n controlId={defIndex === 0 ? firstControlId : undefined}\n >\n {render(item, index, control)}\n </InternalFormField>\n ))}\n </InternalColumnLayout>\n {removable && (\n <ButtonContainer\n index={index}\n isNarrowViewport={isNarrowViewport}\n hasLabel={definition.some(row => row.label)}\n >\n <InternalButton\n className={styles['remove-button']}\n formAction=\"none\"\n ref={ref => {\n removeButtonRefs[index] = ref ?? undefined;\n }}\n onClick={handleRemoveClick}\n >\n {removeButtonText}\n </InternalButton>\n </ButtonContainer>\n )}\n </InternalGrid>\n </div>\n {isNarrowViewport && <Divider />}\n </InternalBox>\n );\n }\n);\n\ninterface ButtonContainer {\n index: number;\n children: React.ReactNode;\n isNarrowViewport: boolean;\n hasLabel: boolean;\n}\n\nconst ButtonContainer = ({ index, children, isNarrowViewport, hasLabel }: ButtonContainer) => (\n <div\n className={clsx({\n [styles['button-container-haslabel']]: !isNarrowViewport && index === 0 && hasLabel,\n [styles['button-container-nolabel']]: !isNarrowViewport && index === 0 && !hasLabel,\n [styles['right-align']]: isNarrowViewport,\n })}\n >\n {children}\n </div>\n);\n"]}
1
+ {"version":3,"file":"row.js","sourceRoot":"lib/default/","sources":["att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BAAgB,IAAI,KAAK,KAAK,CAAC,IAAI,QAAQ;QACnF,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC,EAAE,CAAC,gBAAgB,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,QAAQ;QACnF,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,gBAAgB;KAC1C,CAAC,IAED,QAAQ,CACL,CACP,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport InternalBox from '../box/internal';\nimport styles from './styles.css.js';\nimport React, { useCallback } from 'react';\nimport InternalFormField from '../form-field/internal';\nimport InternalColumnLayout, { ColumnLayoutBreakpoint } from '../column-layout/internal';\nimport { AttributeEditorProps } from './interfaces';\nimport { ButtonProps } from '../button/interfaces';\nimport { fireNonCancelableEvent, NonCancelableEventHandler } from '../internal/events';\nimport InternalGrid from '../grid/internal';\nimport { InternalButton } from '../button/internal';\nimport clsx from 'clsx';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\n\nconst Divider = () => <InternalBox className={styles.divider} padding={{ top: 'l' }} />;\n\nexport interface RowProps<T> {\n breakpoint: ColumnLayoutBreakpoint | null;\n item: T;\n definition: ReadonlyArray<AttributeEditorProps.FieldDefinition<T>>;\n i18nStrings: AttributeEditorProps.I18nStrings | undefined;\n index: number;\n removable: boolean;\n removeButtonText: string;\n removeButtonRefs: Array<ButtonProps.Ref | undefined>;\n onRemoveButtonClick?: NonCancelableEventHandler<AttributeEditorProps.RemoveButtonClickDetail>;\n}\n\nfunction render<T>(\n item: T,\n itemIndex: number,\n slot: AttributeEditorProps.FieldRenderable<T> | React.ReactNode | undefined\n) {\n return typeof slot === 'function' ? slot(item, itemIndex) : slot;\n}\n\nconst GRID_DEFINITION = [{ colspan: { default: 12, xs: 9 } }];\nconst REMOVABLE_GRID_DEFINITION = [{ colspan: { default: 12, xs: 9 } }, { colspan: { default: 12, xs: 3 } }];\nexport const Row = React.memo(\n <T,>({\n breakpoint,\n item,\n definition,\n i18nStrings = {},\n index,\n removable,\n removeButtonText,\n removeButtonRefs,\n onRemoveButtonClick,\n }: RowProps<T>) => {\n const isNarrowViewport = breakpoint === 'default' || breakpoint === 'xxs';\n const isWideViewport = !isNarrowViewport;\n\n const handleRemoveClick = useCallback(() => {\n fireNonCancelableEvent(onRemoveButtonClick, { itemIndex: index });\n }, [onRemoveButtonClick, index]);\n\n const firstControlId = useUniqueId('first-control-id-');\n\n return (\n <InternalBox className={styles.row} margin={{ bottom: 's' }}>\n <div role=\"group\" aria-labelledby={`${firstControlId}-label ${firstControlId}`}>\n <InternalGrid\n __breakpoint={breakpoint}\n gridDefinition={removable ? REMOVABLE_GRID_DEFINITION : GRID_DEFINITION}\n >\n <InternalColumnLayout\n className={styles['row-control']}\n columns={definition.length}\n __breakpoint={breakpoint}\n >\n {definition.map(({ info, label, constraintText, errorText, control }, defIndex) => (\n <InternalFormField\n key={defIndex}\n className={styles.field}\n label={label}\n info={info}\n constraintText={render(item, index, constraintText)}\n errorText={render(item, index, errorText)}\n stretch={true}\n i18nStrings={{ errorIconAriaLabel: i18nStrings.errorIconAriaLabel }}\n __hideLabel={isWideViewport && index > 0}\n controlId={defIndex === 0 ? firstControlId : undefined}\n >\n {render(item, index, control)}\n </InternalFormField>\n ))}\n </InternalColumnLayout>\n {removable && (\n <ButtonContainer\n index={index}\n isNarrowViewport={isNarrowViewport}\n hasLabel={definition.some(row => row.label)}\n >\n <InternalButton\n className={styles['remove-button']}\n formAction=\"none\"\n ref={ref => {\n removeButtonRefs[index] = ref ?? undefined;\n }}\n ariaLabel={i18nStrings.removeButtonAriaLabel?.(item)}\n onClick={handleRemoveClick}\n >\n {removeButtonText}\n </InternalButton>\n </ButtonContainer>\n )}\n </InternalGrid>\n </div>\n {isNarrowViewport && <Divider />}\n </InternalBox>\n );\n }\n);\n\ninterface ButtonContainer {\n index: number;\n children: React.ReactNode;\n isNarrowViewport: boolean;\n hasLabel: boolean;\n}\n\nconst ButtonContainer = ({ index, children, isNarrowViewport, hasLabel }: ButtonContainer) => (\n <div\n className={clsx({\n [styles['button-container-haslabel']]: !isNarrowViewport && index === 0 && hasLabel,\n [styles['button-container-nolabel']]: !isNarrowViewport && index === 0 && !hasLabel,\n [styles['right-align']]: isNarrowViewport,\n })}\n >\n {children}\n </div>\n);\n"]}
@@ -12,6 +12,7 @@ export interface UseAutosuggestItemsProps {
12
12
  export interface AutosuggestItemsState extends HighlightedOptionState<AutosuggestItem> {
13
13
  items: readonly AutosuggestItem[];
14
14
  showAll: boolean;
15
+ getItemGroup: (item: AutosuggestItem) => undefined | AutosuggestProps.OptionGroup;
15
16
  }
16
17
  export interface AutosuggestItemsHandlers extends HighlightedOptionHandlers<AutosuggestItem> {
17
18
  setShowAll(value: boolean): void;
@@ -19,7 +20,6 @@ export interface AutosuggestItemsHandlers extends HighlightedOptionHandlers<Auto
19
20
  highlightVisibleOptionWithMouse(index: number): void;
20
21
  selectVisibleOptionWithMouse(index: number): void;
21
22
  }
22
- export declare const getParentGroup: (item: AutosuggestItem) => AutosuggestItem | undefined;
23
23
  export declare const useAutosuggestItems: ({ options, filterValue, filterText, filteringType, hideEnteredTextLabel, onSelectItem, }: UseAutosuggestItemsProps) => [AutosuggestItemsState, AutosuggestItemsHandlers];
24
24
  export {};
25
25
  //# sourceMappingURL=options-controller.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"options-controller.d.ts","sourceRoot":"lib/default/","sources":["autosuggest/options-controller.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EAEvB,MAAM,gEAAgE,CAAC;AAExE,KAAK,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC;AAExC,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MA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AAC;CACjD;AAED,MAAM,WAAW,qBAAsB,SAAQ,sBAAsB,CAAC,eAAe,CAAC;IACpF,KAAK,EAAE,SAAS,eAAe,EAAE,CAAC;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,SAAS,GAAG,gBAAgB,CAAC,WAAW,CAAC;CACnF;AAED,MAAM,WAAW,wBAAyB,SAAQ,yBAAyB,CAAC,eAAe,CAAC;IAC1F,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IACjC,mCAAmC,IAAI,OAAO,CAAC;IAC/C,+BAA+B,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrD,4BAA4B,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACnD;AAQD,eAAO,MAAM,mBAAmB,6FAO7B,wBAAwB,KAAG,CAAC,qBAAqB,EAAE,wBAAwB,CAiD7E,CAAC"}
@@ -8,20 +8,18 @@ import { useHighlightedOption, } from '../internal/components/options-list/utils
8
8
  const isHighlightable = (option) => {
9
9
  return !!option && option.type !== 'parent';
10
10
  };
11
- const parentMap = new WeakMap();
12
- export const getParentGroup = (item) => parentMap.get(item);
13
11
  const isInteractive = (option) => !!option && !option.disabled && option.type !== 'parent';
14
12
  export const useAutosuggestItems = ({ options, filterValue, filterText, filteringType, hideEnteredTextLabel, onSelectItem, }) => {
15
13
  const [showAll, setShowAll] = useState(false);
16
- const items = useMemo(() => createItems(options), [options]);
14
+ const { items, getItemGroup } = useMemo(() => createItems(options), [options]);
17
15
  const filteredItems = useMemo(() => {
18
16
  const filteredItems = filteringType === 'auto' && !showAll ? filterOptions(items, filterText) : [...items];
19
17
  if (filterValue && !hideEnteredTextLabel) {
20
18
  filteredItems.unshift({ value: filterValue, type: 'use-entered', option: { value: filterValue } });
21
19
  }
22
- generateTestIndexes(filteredItems, getParentGroup);
20
+ generateTestIndexes(filteredItems, getItemGroup);
23
21
  return filteredItems;
24
- }, [items, filterValue, filterText, filteringType, showAll, hideEnteredTextLabel]);
22
+ }, [items, getItemGroup, filterValue, filterText, filteringType, showAll, hideEnteredTextLabel]);
25
23
  const [highlightedOptionState, highlightedOptionHandlers] = useHighlightedOption({
26
24
  options: filteredItems,
27
25
  isHighlightable,
@@ -44,7 +42,7 @@ export const useAutosuggestItems = ({ options, filterValue, filterText, filterin
44
42
  }
45
43
  };
46
44
  return [
47
- Object.assign(Object.assign({}, highlightedOptionState), { items: filteredItems, showAll }),
45
+ Object.assign(Object.assign({}, highlightedOptionState), { items: filteredItems, showAll, getItemGroup }),
48
46
  Object.assign(Object.assign({}, highlightedOptionHandlers), { setShowAll,
49
47
  selectHighlightedOptionWithKeyboard,
50
48
  highlightVisibleOptionWithMouse,
@@ -53,6 +51,8 @@ export const useAutosuggestItems = ({ options, filterValue, filterText, filterin
53
51
  };
54
52
  function createItems(options) {
55
53
  const items = [];
54
+ const itemToGroup = new WeakMap();
55
+ const getItemGroup = (item) => itemToGroup.get(item);
56
56
  for (const option of options) {
57
57
  if (isGroup(option)) {
58
58
  for (const item of flattenGroup(option)) {
@@ -63,25 +63,24 @@ function createItems(options) {
63
63
  items.push(Object.assign(Object.assign({}, option), { option }));
64
64
  }
65
65
  }
66
- return items;
66
+ function flattenGroup(group) {
67
+ const { options } = group, rest = __rest(group, ["options"]);
68
+ let hasOnlyDisabledChildren = true;
69
+ const items = [Object.assign(Object.assign({}, rest), { type: 'parent', option: group })];
70
+ for (const option of options) {
71
+ if (!option.disabled) {
72
+ hasOnlyDisabledChildren = false;
73
+ }
74
+ const childOption = Object.assign(Object.assign({}, option), { type: 'child', disabled: option.disabled || rest.disabled, option });
75
+ items.push(childOption);
76
+ itemToGroup.set(childOption, group);
77
+ }
78
+ items[0].disabled = items[0].disabled || hasOnlyDisabledChildren;
79
+ return items;
80
+ }
81
+ return { items, getItemGroup };
67
82
  }
68
83
  function isGroup(optionOrGroup) {
69
84
  return 'options' in optionOrGroup;
70
85
  }
71
- function flattenGroup(group) {
72
- const { options } = group, rest = __rest(group, ["options"]);
73
- let hasOnlyDisabledChildren = true;
74
- const items = [Object.assign(Object.assign({}, rest), { type: 'parent', option: group })];
75
- for (const option of options) {
76
- if (!option.disabled) {
77
- hasOnlyDisabledChildren = false;
78
- }
79
- const childOption = Object.assign(Object.assign({}, option), { type: 'child', disabled: option.disabled || rest.disabled, option });
80
- items.push(childOption);
81
- // TODO: Refactor parentMap and remove this side effect
82
- parentMap.set(childOption, Object.assign(Object.assign({}, group), { option: group }));
83
- }
84
- items[0].disabled = items[0].disabled || hasOnlyDisabledChildren;
85
- return items;
86
- }
87
86
  //# sourceMappingURL=options-controller.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"options-controller.js","sourceRoot":"lib/default/","sources":["autosuggest/options-controller.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wDAAwD,CAAC;AAE7F,OAAO,EAGL,oBAAoB,GACrB,MAAM,gEAAgE,CAAC;AAyBxE,MAAM,eAAe,GAAG,CAAC,MAAwB,EAAE,EAAE;IACnD,OAAO,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC9C,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,IAAI,OAAO,EAAoC,CAAC;AAClE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAqB,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAE7E,MAAM,aAAa,GAAG,CAAC,MAAwB,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;AAE7G,MAAM,CAAC,MA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AAI,uBAAuB,GAAG,IAAI,CAAC;IAEnC,MAAM,KAAK,GAAsB,iCAAM,IAAI,KAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAG,CAAC;IAE9E,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC5B,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;YACpB,uBAAuB,GAAG,KAAK,CAAC;SACjC;QAED,MAAM,WAAW,mCACZ,MAAM,KACT,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAC1C,MAAM,GACP,CAAC;QAEF,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAExB,uDAAuD;QACvD,SAAS,CAAC,GAAG,CAAC,WAAW,kCAAO,KAAK,KAAE,MAAM,EAAE,KAAK,IAAG,CAAC;KACzD;IAED,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,IAAI,uBAAuB,CAAC;IAEjE,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useMemo, useState } from 'react';\nimport { filterOptions } from './utils/utils';\nimport { generateTestIndexes } from '../internal/components/options-list/utils/test-indexes';\nimport { AutosuggestItem, AutosuggestProps } from './interfaces';\nimport {\n HighlightedOptionHandlers,\n HighlightedOptionState,\n useHighlightedOption,\n} from '../internal/components/options-list/utils/use-highlight-option';\n\ntype Options = AutosuggestProps.Options;\n\nexport interface UseAutosuggestItemsProps {\n options: Options;\n filterValue: string;\n filterText: string;\n filteringType: AutosuggestProps.FilteringType;\n hideEnteredTextLabel?: boolean;\n onSelectItem: (option: AutosuggestItem) => void;\n}\n\nexport interface AutosuggestItemsState extends HighlightedOptionState<AutosuggestItem> {\n items: readonly AutosuggestItem[];\n showAll: boolean;\n}\n\nexport interface AutosuggestItemsHandlers extends HighlightedOptionHandlers<AutosuggestItem> {\n setShowAll(value: boolean): void;\n selectHighlightedOptionWithKeyboard(): boolean;\n highlightVisibleOptionWithMouse(index: number): void;\n selectVisibleOptionWithMouse(index: number): void;\n}\n\nconst isHighlightable = (option?: AutosuggestItem) => {\n return !!option && option.type !== 'parent';\n};\n\nconst parentMap = new WeakMap<AutosuggestItem, AutosuggestItem>();\nexport const getParentGroup = (item: AutosuggestItem) => parentMap.get(item);\n\nconst isInteractive = (option?: AutosuggestItem) => !!option && !option.disabled && option.type !== 'parent';\n\nexport const useAutosuggestItems = ({\n options,\n filterValue,\n filterText,\n filteringType,\n hideEnteredTextLabel,\n onSelectItem,\n}: UseAutosuggestItemsProps): [AutosuggestItemsState, AutosuggestItemsHandlers] => {\n const [showAll, setShowAll] = useState(false);\n\n const items = useMemo(() => createItems(options), [options]);\n\n const filteredItems = useMemo(() => {\n const filteredItems = filteringType === 'auto' && !showAll ? filterOptions(items, filterText) : [...items];\n if (filterValue && !hideEnteredTextLabel) {\n filteredItems.unshift({ value: filterValue, type: 'use-entered', option: { value: filterValue } });\n }\n generateTestIndexes(filteredItems, getParentGroup);\n return filteredItems;\n }, [items, filterValue, filterText, filteringType, showAll, hideEnteredTextLabel]);\n\n const [highlightedOptionState, highlightedOptionHandlers] = useHighlightedOption({\n options: filteredItems,\n isHighlightable,\n });\n\n const selectHighlightedOptionWithKeyboard = () => {\n if (highlightedOptionState.highlightedOption && isInteractive(highlightedOptionState.highlightedOption)) {\n onSelectItem(highlightedOptionState.highlightedOption);\n return true;\n }\n return false;\n };\n\n const highlightVisibleOptionWithMouse = (index: number) => {\n if (filteredItems[index] && isHighlightable(filteredItems[index])) {\n highlightedOptionHandlers.setHighlightedIndexWithMouse(index);\n }\n };\n\n const selectVisibleOptionWithMouse = (index: number) => {\n if (filteredItems[index] && isInteractive(filteredItems[index])) {\n onSelectItem(filteredItems[index]);\n }\n };\n\n return [\n { ...highlightedOptionState, items: filteredItems, showAll },\n {\n ...highlightedOptionHandlers,\n setShowAll,\n selectHighlightedOptionWithKeyboard,\n highlightVisibleOptionWithMouse,\n selectVisibleOptionWithMouse,\n },\n ];\n};\n\nfunction createItems(options: Options): AutosuggestItem[] {\n const items: AutosuggestItem[] = [];\n for (const option of options) {\n if (isGroup(option)) {\n for (const item of flattenGroup(option)) {\n items.push(item);\n }\n } else {\n items.push({ ...option, option });\n }\n }\n return items;\n}\n\nfunction isGroup(optionOrGroup: AutosuggestProps.Option): optionOrGroup is AutosuggestProps.OptionGroup {\n return 'options' in optionOrGroup;\n}\n\nfunction flattenGroup(group: AutosuggestProps.OptionGroup): AutosuggestItem[] {\n const { options, ...rest } = group;\n\n let hasOnlyDisabledChildren = true;\n\n const items: AutosuggestItem[] = [{ ...rest, type: 'parent', option: group }];\n\n for (const option of options) {\n if (!option.disabled) {\n hasOnlyDisabledChildren = false;\n }\n\n const childOption: AutosuggestItem = {\n ...option,\n type: 'child',\n disabled: option.disabled || rest.disabled,\n option,\n };\n\n items.push(childOption);\n\n // TODO: Refactor parentMap and remove this side effect\n parentMap.set(childOption, { ...group, option: group });\n }\n\n items[0].disabled = items[0].disabled || hasOnlyDisabledChildren;\n\n return items;\n}\n"]}
1
+ {"version":3,"file":"options-controller.js","sourceRoot":"lib/default/","sources":["autosuggest/options-controller.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wDAAwD,CAAC;AAE7F,OAAO,EAGL,oBAAoB,GACrB,MAAM,gEAAgE,CAAC;AA0BxE,MAAM,eAAe,GAAG,CAAC,MAAwB,EAAE,EAAE;IACnD,OAAO,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC9C,CAAC,CAAC;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AAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAClB;SACF;aAAM;YACL,KAAK,CAAC,IAAI,iCAAM,MAAM,KAAE,MAAM,IAAG,CAAC;SACnC;KACF;IAED,SAAS,YAAY,CAAC,KAAmC;QACvD,MAAM,EAAE,OAAO,KAAc,KAAK,EAAd,IAAI,UAAK,KAAK,EAA5B,WAAoB,CAAQ,CAAC;QAEnC,IAAI,uBAAuB,GAAG,IAAI,CAAC;QAEnC,MAAM,KAAK,GAAsB,iCAAM,IAAI,KAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAG,CAAC;QAE9E,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;YAC5B,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;gBACpB,uBAAuB,GAAG,KAAK,CAAC;aACjC;YAED,MAAM,WAAW,mCACZ,MAAM,KACT,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAC1C,MAAM,GACP,CAAC;YAEF,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAExB,WAAW,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;SACrC;QAED,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,IAAI,uBAAuB,CAAC;QAEjE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;AACjC,CAAC;AAED,SAAS,OAAO,CAAC,aAAsC;IACrD,OAAO,SAAS,IAAI,aAAa,CAAC;AACpC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useMemo, useState } from 'react';\nimport { filterOptions } from './utils/utils';\nimport { generateTestIndexes } from '../internal/components/options-list/utils/test-indexes';\nimport { AutosuggestItem, AutosuggestProps } from './interfaces';\nimport {\n HighlightedOptionHandlers,\n HighlightedOptionState,\n useHighlightedOption,\n} from '../internal/components/options-list/utils/use-highlight-option';\n\ntype Options = AutosuggestProps.Options;\n\nexport interface UseAutosuggestItemsProps {\n options: Options;\n filterValue: string;\n filterText: string;\n filteringType: AutosuggestProps.FilteringType;\n hideEnteredTextLabel?: boolean;\n onSelectItem: (option: AutosuggestItem) => void;\n}\n\nexport interface AutosuggestItemsState extends HighlightedOptionState<AutosuggestItem> {\n items: readonly AutosuggestItem[];\n showAll: boolean;\n getItemGroup: (item: AutosuggestItem) => undefined | AutosuggestProps.OptionGroup;\n}\n\nexport interface AutosuggestItemsHandlers extends HighlightedOptionHandlers<AutosuggestItem> {\n setShowAll(value: boolean): void;\n selectHighlightedOptionWithKeyboard(): boolean;\n highlightVisibleOptionWithMouse(index: number): void;\n selectVisibleOptionWithMouse(index: number): void;\n}\n\nconst isHighlightable = (option?: AutosuggestItem) => {\n return !!option && option.type !== 'parent';\n};\n\nconst isInteractive = (option?: AutosuggestItem) => !!option && !option.disabled && option.type !== 'parent';\n\nexport const useAutosuggestItems = ({\n options,\n filterValue,\n filterText,\n filteringType,\n hideEnteredTextLabel,\n onSelectItem,\n}: UseAutosuggestItemsProps): [AutosuggestItemsState, AutosuggestItemsHandlers] => {\n const [showAll, setShowAll] = useState(false);\n\n const { items, getItemGroup } = useMemo(() => createItems(options), [options]);\n\n const filteredItems = useMemo(() => {\n const filteredItems = filteringType === 'auto' && !showAll ? filterOptions(items, filterText) : [...items];\n if (filterValue && !hideEnteredTextLabel) {\n filteredItems.unshift({ value: filterValue, type: 'use-entered', option: { value: filterValue } });\n }\n generateTestIndexes(filteredItems, getItemGroup);\n return filteredItems;\n }, [items, getItemGroup, filterValue, filterText, filteringType, showAll, hideEnteredTextLabel]);\n\n const [highlightedOptionState, highlightedOptionHandlers] = useHighlightedOption({\n options: filteredItems,\n isHighlightable,\n });\n\n const selectHighlightedOptionWithKeyboard = () => {\n if (highlightedOptionState.highlightedOption && isInteractive(highlightedOptionState.highlightedOption)) {\n onSelectItem(highlightedOptionState.highlightedOption);\n return true;\n }\n return false;\n };\n\n const highlightVisibleOptionWithMouse = (index: number) => {\n if (filteredItems[index] && isHighlightable(filteredItems[index])) {\n highlightedOptionHandlers.setHighlightedIndexWithMouse(index);\n }\n };\n\n const selectVisibleOptionWithMouse = (index: number) => {\n if (filteredItems[index] && isInteractive(filteredItems[index])) {\n onSelectItem(filteredItems[index]);\n }\n };\n\n return [\n { ...highlightedOptionState, items: filteredItems, showAll, getItemGroup },\n {\n ...highlightedOptionHandlers,\n setShowAll,\n selectHighlightedOptionWithKeyboard,\n highlightVisibleOptionWithMouse,\n selectVisibleOptionWithMouse,\n },\n ];\n};\n\nfunction createItems(options: Options) {\n const items: AutosuggestItem[] = [];\n const itemToGroup = new WeakMap<AutosuggestItem, AutosuggestProps.OptionGroup>();\n const getItemGroup = (item: AutosuggestItem) => itemToGroup.get(item);\n\n for (const option of options) {\n if (isGroup(option)) {\n for (const item of flattenGroup(option)) {\n items.push(item);\n }\n } else {\n items.push({ ...option, option });\n }\n }\n\n function flattenGroup(group: AutosuggestProps.OptionGroup) {\n const { options, ...rest } = group;\n\n let hasOnlyDisabledChildren = true;\n\n const items: AutosuggestItem[] = [{ ...rest, type: 'parent', option: group }];\n\n for (const option of options) {\n if (!option.disabled) {\n hasOnlyDisabledChildren = false;\n }\n\n const childOption: AutosuggestItem = {\n ...option,\n type: 'child',\n disabled: option.disabled || rest.disabled,\n option,\n };\n\n items.push(childOption);\n\n itemToGroup.set(childOption, group);\n }\n\n items[0].disabled = items[0].disabled || hasOnlyDisabledChildren;\n\n return items;\n }\n\n return { items, getItemGroup };\n}\n\nfunction isGroup(optionOrGroup: AutosuggestProps.Option): optionOrGroup is AutosuggestProps.OptionGroup {\n return 'options' in optionOrGroup;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"options-list.d.ts","sourceRoot":"lib/default/","sources":["autosuggest/options-list.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAkB,MAAM,sBAAsB,CAAC;AACvG,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAOhD,MAAM,WAAW,2BACf,SAAQ,IAAI,CACV,gBAAgB,EAChB,kBAAkB,GAAG,eAAe,GAAG,mBAAmB,GAAG,2BAA2B,CACzF;IACD,qBAAqB,EAAE,qBAAqB,CAAC;IAC7C,wBAAwB,EAAE,wBAAwB,CAAC;IACnD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AASD,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAC7C,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,aAAa,EACb,MAAM,EACN,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EACzB,UAAU,EACV,eAAe,GAChB,EAAE,2BAA2B,eAiC7B"}
1
+ {"version":3,"file":"options-list.d.ts","sourceRoot":"lib/default/","sources":["autosuggest/options-list.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAMhD,MAAM,WAAW,2BACf,SAAQ,IAAI,CACV,gBAAgB,EAChB,kBAAkB,GAAG,eAAe,GAAG,mBAAmB,GAAG,2BAA2B,CACzF;IACD,qBAAqB,EAAE,qBAAqB,CAAC;IAC7C,wBAAwB,EAAE,wBAAwB,CAAC;IACnD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AASD,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAC7C,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,aAAa,EACb,MAAM,EACN,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EACzB,UAAU,EACV,eAAe,GAChB,EAAE,2BAA2B,eAiC7B"}
@@ -1,7 +1,6 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import React from 'react';
4
- import { getParentGroup } from './options-controller';
5
4
  import VirtualList from './virtual-list';
6
5
  import PlainList from './plain-list';
7
6
  import { useAnnouncement } from '../select/utils/use-announcement';
@@ -19,7 +18,7 @@ export default function AutosuggestOptionsList({ autosuggestItemsState, autosugg
19
18
  const announcement = useAnnouncement({
20
19
  announceSelected: ((_a = autosuggestItemsState.highlightedOption) === null || _a === void 0 ? void 0 : _a.value) === highlightText,
21
20
  highlightedOption: autosuggestItemsState.highlightedOption,
22
- getParent: option => { var _a; return (_a = getParentGroup(option)) === null || _a === void 0 ? void 0 : _a.option; },
21
+ getParent: option => autosuggestItemsState.getItemGroup(option),
23
22
  selectedAriaLabel,
24
23
  renderHighlightedAriaLive,
25
24
  });
@@ -1 +1 @@
1
- {"version":3,"file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A,EAAA;QAC9E,iBAAiB;QACjB,yBAAyB;KAC1B,CAAC,CAAC;IAEH,OAAO,CACL,oBAAC,aAAa,IACZ,UAAU,EAAE,UAAU,EACtB,cAAc,EAAE,cAAc,EAC9B,qBAAqB,EAAE,qBAAqB,EAC5C,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,gBAAgB,EAClC,oBAAoB,EAAE,mBAAmB,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,mBAAmB,EAAE,CAAC,CAAC,CAAC,EAAE,EAC5E,iBAAiB,EAAE,iBAAiB,EACpC,SAAS,EAAE;YACT,EAAE,EAAE,MAAM;YACV,cAAc,EAAE,SAAS;YACzB,SAAS,EAAE,aAAa;YACxB,WAAW,EAAE,eAAe;YAC5B,eAAe;SAChB,EACD,mBAAmB,EAAE,YAAY,GACjC,CACH,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';\n\nimport { AutosuggestItemsHandlers, AutosuggestItemsState, getParentGroup } from './options-controller';\nimport { AutosuggestProps } from './interfaces';\nimport VirtualList from './virtual-list';\nimport PlainList from './plain-list';\n\nimport { useAnnouncement } from '../select/utils/use-announcement';\nimport { OptionGroup } from '../internal/components/option/interfaces';\n\nexport interface AutosuggestOptionsListProps\n extends Pick<\n AutosuggestProps,\n 'enteredTextLabel' | 'virtualScroll' | 'selectedAriaLabel' | 'renderHighlightedAriaLive'\n > {\n autosuggestItemsState: AutosuggestItemsState;\n autosuggestItemsHandlers: AutosuggestItemsHandlers;\n highlightedOptionId?: string;\n highlightText: string;\n listId: string;\n controlId: string;\n handleLoadMore: () => void;\n hasDropdownStatus?: boolean;\n listBottom?: React.ReactNode;\n ariaDescribedby?: string;\n}\n\nconst createMouseEventHandler = (handler: (index: number) => void) => (itemIndex: number) => {\n // prevent mouse events to avoid losing focus from the input\n if (itemIndex > -1) {\n handler(itemIndex);\n }\n};\n\nexport default function AutosuggestOptionsList({\n autosuggestItemsState,\n autosuggestItemsHandlers,\n highlightedOptionId,\n highlightText,\n listId,\n controlId,\n enteredTextLabel,\n handleLoadMore,\n hasDropdownStatus,\n virtualScroll,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n listBottom,\n ariaDescribedby,\n}: AutosuggestOptionsListProps) {\n const handleMouseUp = createMouseEventHandler(autosuggestItemsHandlers.selectVisibleOptionWithMouse);\n const handleMouseMove = createMouseEventHandler(autosuggestItemsHandlers.highlightVisibleOptionWithMouse);\n\n const ListComponent = virtualScroll ? VirtualList : PlainList;\n\n const announcement = useAnnouncement({\n announceSelected: autosuggestItemsState.highlightedOption?.value === highlightText,\n highlightedOption: autosuggestItemsState.highlightedOption,\n getParent: option => getParentGroup(option)?.option as undefined | OptionGroup,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n });\n\n return (\n <ListComponent\n listBottom={listBottom}\n handleLoadMore={handleLoadMore}\n autosuggestItemsState={autosuggestItemsState}\n highlightText={highlightText}\n enteredTextLabel={enteredTextLabel}\n highlightedA11yProps={highlightedOptionId ? { id: highlightedOptionId } : {}}\n hasDropdownStatus={hasDropdownStatus}\n menuProps={{\n id: listId,\n ariaLabelledby: controlId,\n onMouseUp: handleMouseUp,\n onMouseMove: handleMouseMove,\n ariaDescribedby,\n }}\n screenReaderContent={announcement}\n />\n );\n}\n"]}
1
+ {"version":3,"file":"options-list.js","sourceRoot":"lib/default/","sources":["autosuggest/options-list.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAmBnE,MAAM,uBAAuB,GAAG,CAAC,OAAgC,EAAE,EAAE,CAAC,CAAC,SAAiB,EAAE,EAAE;IAC1F,4DAA4D;IAC5D,IA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;YACxB,WAAW,EAAE,eAAe;YAC5B,eAAe;SAChB,EACD,mBAAmB,EAAE,YAAY,GACjC,CACH,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';\n\nimport { AutosuggestItemsHandlers, AutosuggestItemsState } from './options-controller';\nimport { AutosuggestProps } from './interfaces';\nimport VirtualList from './virtual-list';\nimport PlainList from './plain-list';\n\nimport { useAnnouncement } from '../select/utils/use-announcement';\n\nexport interface AutosuggestOptionsListProps\n extends Pick<\n AutosuggestProps,\n 'enteredTextLabel' | 'virtualScroll' | 'selectedAriaLabel' | 'renderHighlightedAriaLive'\n > {\n autosuggestItemsState: AutosuggestItemsState;\n autosuggestItemsHandlers: AutosuggestItemsHandlers;\n highlightedOptionId?: string;\n highlightText: string;\n listId: string;\n controlId: string;\n handleLoadMore: () => void;\n hasDropdownStatus?: boolean;\n listBottom?: React.ReactNode;\n ariaDescribedby?: string;\n}\n\nconst createMouseEventHandler = (handler: (index: number) => void) => (itemIndex: number) => {\n // prevent mouse events to avoid losing focus from the input\n if (itemIndex > -1) {\n handler(itemIndex);\n }\n};\n\nexport default function AutosuggestOptionsList({\n autosuggestItemsState,\n autosuggestItemsHandlers,\n highlightedOptionId,\n highlightText,\n listId,\n controlId,\n enteredTextLabel,\n handleLoadMore,\n hasDropdownStatus,\n virtualScroll,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n listBottom,\n ariaDescribedby,\n}: AutosuggestOptionsListProps) {\n const handleMouseUp = createMouseEventHandler(autosuggestItemsHandlers.selectVisibleOptionWithMouse);\n const handleMouseMove = createMouseEventHandler(autosuggestItemsHandlers.highlightVisibleOptionWithMouse);\n\n const ListComponent = virtualScroll ? VirtualList : PlainList;\n\n const announcement = useAnnouncement({\n announceSelected: autosuggestItemsState.highlightedOption?.value === highlightText,\n highlightedOption: autosuggestItemsState.highlightedOption,\n getParent: option => autosuggestItemsState.getItemGroup(option),\n selectedAriaLabel,\n renderHighlightedAriaLive,\n });\n\n return (\n <ListComponent\n listBottom={listBottom}\n handleLoadMore={handleLoadMore}\n autosuggestItemsState={autosuggestItemsState}\n highlightText={highlightText}\n enteredTextLabel={enteredTextLabel}\n highlightedA11yProps={highlightedOptionId ? { id: highlightedOptionId } : {}}\n hasDropdownStatus={hasDropdownStatus}\n menuProps={{\n id: listId,\n ariaLabelledby: controlId,\n onMouseUp: handleMouseUp,\n onMouseMove: handleMouseMove,\n ariaDescribedby,\n }}\n screenReaderContent={announcement}\n />\n );\n}\n"]}
@@ -6,7 +6,6 @@ export declare const InternalButton: React.ForwardRefExoticComponent<Omit<Button
6
6
  __nativeAttributes?: Record<string, any> | undefined;
7
7
  __iconClass?: string | undefined;
8
8
  __activated?: boolean | undefined;
9
- __forcedFocusState?: "none" | "focused" | undefined;
10
9
  } & InternalBaseComponentProps & React.RefAttributes<ButtonProps.Ref>>;
11
10
  export default InternalButton;
12
11
  //# sourceMappingURL=internal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["button/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAalF,eAAO,MAAM,cAAc;cAPf,WAAW,CAAC,SAAS,CAAC,GAAG,eAAe,GAAG,kBAAkB,GAAG,cAAc,GAAG,eAAe;;;;;sEAyI3G,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["button/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAYlF,eAAO,MAAM,cAAc;cANf,WAAW,CAAC,SAAS,CAAC,GAAG,eAAe,GAAG,kBAAkB,GAAG,cAAc,GAAG,eAAe;;;;sEAqI3G,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -11,7 +11,7 @@ import { checkSafeUrl } from '../internal/utils/check-safe-url';
11
11
  import { useMergeRefs } from '../internal/hooks/use-merge-refs';
12
12
  import LiveRegion from '../internal/components/live-region';
13
13
  export const InternalButton = React.forwardRef((_a, ref) => {
14
- var { children, iconName, __iconClass, onClick, onFollow, iconAlign = 'left', iconUrl, iconSvg, iconAlt, variant = 'normal', loading = false, loadingText, disabled = false, wrapText = true, href, target, rel, download, formAction = 'submit', ariaLabel, ariaExpanded, __forcedFocusState, __nativeAttributes, __internalRootRef = null, __activated = false } = _a, props = __rest(_a, ["children", "iconName", "__iconClass", "onClick", "onFollow", "iconAlign", "iconUrl", "iconSvg", "iconAlt", "variant", "loading", "loadingText", "disabled", "wrapText", "href", "target", "rel", "download", "formAction", "ariaLabel", "ariaExpanded", "__forcedFocusState", "__nativeAttributes", "__internalRootRef", "__activated"]);
14
+ var { children, iconName, __iconClass, onClick, onFollow, iconAlign = 'left', iconUrl, iconSvg, iconAlt, variant = 'normal', loading = false, loadingText, disabled = false, wrapText = true, href, target, rel, download, formAction = 'submit', ariaLabel, ariaExpanded, __nativeAttributes, __internalRootRef = null, __activated = false } = _a, props = __rest(_a, ["children", "iconName", "__iconClass", "onClick", "onFollow", "iconAlign", "iconUrl", "iconSvg", "iconAlt", "variant", "loading", "loadingText", "disabled", "wrapText", "href", "target", "rel", "download", "formAction", "ariaLabel", "ariaExpanded", "__nativeAttributes", "__internalRootRef", "__activated"]);
15
15
  checkSafeUrl('Button', href);
16
16
  const isAnchor = Boolean(href);
17
17
  const isNotInteractive = loading || disabled;
@@ -33,8 +33,6 @@ export const InternalButton = React.forwardRef((_a, ref) => {
33
33
  [styles['button-no-wrap']]: !wrapText,
34
34
  [styles['button-no-text']]: !shouldHaveContent,
35
35
  [styles['is-activated']]: __activated,
36
- [styles['hide-focus-outline']]: __forcedFocusState === 'none',
37
- [styles['force-focus-outline']]: __forcedFocusState === 'focused',
38
36
  });
39
37
  const buttonProps = Object.assign(Object.assign(Object.assign({}, props), __nativeAttributes), {
40
38
  // https://github.com/microsoft/TypeScript/issues/36659
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["button/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAmB,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGrE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,UAAU,MAAM,oCAAoC,CAAC;AAU5D,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CAC5C,CACE,EA2BsB,EACtB,GAA+B,EAC/B,EAAE;QA7BF,EACE,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,OAAO,EACP,QAAQ,EACR,SAAS,GAAG,MAAM,EAClB,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,GAAG,QAAQ,EAClB,OAAO,GAAG,KAAK,EACf,WAAW,EACX,QAAQ,GAAG,KAAK,EAChB,QAAQ,GAAG,IAAI,EACf,IAAI,EACJ,MAAM,EACN,GAAG,EACH,QAAQ,EACR,UAAU,GAAG,QAAQ,EACrB,SAAS,EACT,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,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CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,SAAS,CAAC,EACrE,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,mBAC5B,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EAClD,QAAQ,EAAE,QAAQ,KAEjB,aAAa,CACZ;YACH,OAAO,IAAI,WAAW,IAAI,oBAAC,UAAU,QAAE,WAAW,CAAc,CAChE,CACJ,CAAC;KACH;IACD,OAAO,CACL;QACE,gDACM,WAAW,IACf,IAAI,EAAE,UAAU,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EACjD,QAAQ,EAAE,QAAQ,mBACH,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,KAErD,aAAa,CACP;QACR,OAAO,IAAI,WAAW,IAAI,oBAAC,UAAU,QAAE,WAAW,CAAc,CAChE,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,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, useRef } from 'react';\nimport { fireCancelableEvent, isPlainLeftClick } from '../internal/events';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport styles from './styles.css.js';\nimport { ButtonIconProps, LeftIcon, RightIcon } from './icon-helper';\nimport { ButtonProps } from './interfaces';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport LiveRegion from '../internal/components/live-region';\n\ntype InternalButtonProps = Omit<ButtonProps, 'variant'> & {\n variant?: ButtonProps['variant'] | 'flashbar-icon' | 'breadcrumb-group' | 'menu-trigger' | 'modal-dismiss';\n __nativeAttributes?: Record<string, any>;\n __iconClass?: string;\n __activated?: boolean;\n __forcedFocusState?: 'none' | 'focused';\n} & InternalBaseComponentProps;\n\nexport const InternalButton = React.forwardRef(\n (\n {\n children,\n iconName,\n __iconClass,\n onClick,\n onFollow,\n iconAlign = 'left',\n iconUrl,\n iconSvg,\n iconAlt,\n variant = 'normal',\n loading = false,\n loadingText,\n disabled = false,\n wrapText = true,\n href,\n target,\n rel,\n download,\n formAction = 'submit',\n ariaLabel,\n ariaExpanded,\n __forcedFocusState,\n __nativeAttributes,\n __internalRootRef = null,\n __activated = false,\n ...props\n }: InternalButtonProps,\n ref: React.Ref<ButtonProps.Ref>\n ) => {\n checkSafeUrl('Button', href);\n const isAnchor = Boolean(href);\n const isNotInteractive = loading || disabled;\n const shouldHaveContent =\n children && ['icon', 'inline-icon', 'flashbar-icon', 'modal-dismiss'].indexOf(variant) === -1;\n\n const buttonRef = useRef<HTMLElement>(null);\n useForwardFocus(ref, buttonRef);\n\n const handleClick = useCallback(\n (event: React.MouseEvent) => {\n if (isNotInteractive) {\n return event.preventDefault();\n }\n\n if (isAnchor && isPlainLeftClick(event)) {\n fireCancelableEvent(onFollow, null, event);\n }\n\n const { altKey, button, ctrlKey, metaKey, shiftKey } = event;\n fireCancelableEvent(onClick, { altKey, button, ctrlKey, metaKey, shiftKey }, event);\n },\n [isAnchor, isNotInteractive, onClick, onFollow]\n );\n\n const buttonClass = clsx(props.className, styles.button, styles[`variant-${variant}`], {\n [styles.disabled]: isNotInteractive,\n [styles['button-no-wrap']]: !wrapText,\n [styles['button-no-text']]: !shouldHaveContent,\n [styles['is-activated']]: __activated,\n [styles['hide-focus-outline']]: __forcedFocusState === 'none',\n [styles['force-focus-outline']]: __forcedFocusState === 'focused',\n });\n\n const buttonProps = {\n ...props,\n ...__nativeAttributes,\n // https://github.com/microsoft/TypeScript/issues/36659\n ref: useMergeRefs(buttonRef as any, __internalRootRef),\n 'aria-label': ariaLabel,\n 'aria-expanded': ariaExpanded,\n className: buttonClass,\n onClick: handleClick,\n } as const;\n const iconProps: ButtonIconProps = {\n loading,\n iconName,\n iconAlign,\n iconUrl,\n iconSvg,\n iconAlt,\n variant,\n iconClass: __iconClass,\n iconSize: variant === 'modal-dismiss' ? 'medium' : 'normal',\n };\n const buttonContent = (\n <>\n <LeftIcon {...iconProps} />\n {shouldHaveContent && <span className={styles.content}>{children}</span>}\n <RightIcon {...iconProps} />\n </>\n );\n\n if (isAnchor) {\n return (\n // https://github.com/yannickcr/eslint-plugin-react/issues/2962\n // eslint-disable-next-line react/jsx-no-target-blank\n <>\n <a\n {...buttonProps}\n href={href}\n target={target}\n // security recommendation: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target\n rel={rel ?? (target === '_blank' ? 'noopener noreferrer' : undefined)}\n tabIndex={isNotInteractive ? -1 : undefined}\n aria-disabled={isNotInteractive ? true : undefined}\n download={download}\n >\n {buttonContent}\n </a>\n {loading && loadingText && <LiveRegion>{loadingText}</LiveRegion>}\n </>\n );\n }\n return (\n <>\n <button\n {...buttonProps}\n type={formAction === 'none' ? 'button' : 'submit'}\n disabled={disabled}\n aria-disabled={loading && !disabled ? true : undefined}\n >\n {buttonContent}\n </button>\n {loading && loadingText && <LiveRegion>{loadingText}</LiveRegion>}\n </>\n );\n }\n);\n\nexport default InternalButton;\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["button/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAmB,QAAQ,EAAE,SA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Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React, { useCallback, useRef } from 'react';\nimport { fireCancelableEvent, isPlainLeftClick } from '../internal/events';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport styles from './styles.css.js';\nimport { ButtonIconProps, LeftIcon, RightIcon } from './icon-helper';\nimport { ButtonProps } from './interfaces';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport LiveRegion from '../internal/components/live-region';\n\ntype InternalButtonProps = Omit<ButtonProps, 'variant'> & {\n variant?: ButtonProps['variant'] | 'flashbar-icon' | 'breadcrumb-group' | 'menu-trigger' | 'modal-dismiss';\n __nativeAttributes?: Record<string, any>;\n __iconClass?: string;\n __activated?: boolean;\n} & InternalBaseComponentProps;\n\nexport const InternalButton = React.forwardRef(\n (\n {\n children,\n iconName,\n __iconClass,\n onClick,\n onFollow,\n iconAlign = 'left',\n iconUrl,\n iconSvg,\n iconAlt,\n variant = 'normal',\n loading = false,\n loadingText,\n disabled = false,\n wrapText = true,\n href,\n target,\n rel,\n download,\n formAction = 'submit',\n ariaLabel,\n ariaExpanded,\n __nativeAttributes,\n __internalRootRef = null,\n __activated = false,\n ...props\n }: InternalButtonProps,\n ref: React.Ref<ButtonProps.Ref>\n ) => {\n checkSafeUrl('Button', href);\n const isAnchor = Boolean(href);\n const isNotInteractive = loading || disabled;\n const shouldHaveContent =\n children && ['icon', 'inline-icon', 'flashbar-icon', 'modal-dismiss'].indexOf(variant) === -1;\n\n const buttonRef = useRef<HTMLElement>(null);\n useForwardFocus(ref, buttonRef);\n\n const handleClick = useCallback(\n (event: React.MouseEvent) => {\n if (isNotInteractive) {\n return event.preventDefault();\n }\n\n if (isAnchor && isPlainLeftClick(event)) {\n fireCancelableEvent(onFollow, null, event);\n }\n\n const { altKey, button, ctrlKey, metaKey, shiftKey } = event;\n fireCancelableEvent(onClick, { altKey, button, ctrlKey, metaKey, shiftKey }, event);\n },\n [isAnchor, isNotInteractive, onClick, onFollow]\n );\n\n const buttonClass = clsx(props.className, styles.button, styles[`variant-${variant}`], {\n [styles.disabled]: isNotInteractive,\n [styles['button-no-wrap']]: !wrapText,\n [styles['button-no-text']]: !shouldHaveContent,\n [styles['is-activated']]: __activated,\n });\n\n const buttonProps = {\n ...props,\n ...__nativeAttributes,\n // https://github.com/microsoft/TypeScript/issues/36659\n ref: useMergeRefs(buttonRef as any, __internalRootRef),\n 'aria-label': ariaLabel,\n 'aria-expanded': ariaExpanded,\n className: buttonClass,\n onClick: handleClick,\n } as const;\n const iconProps: ButtonIconProps = {\n loading,\n iconName,\n iconAlign,\n iconUrl,\n iconSvg,\n iconAlt,\n variant,\n iconClass: __iconClass,\n iconSize: variant === 'modal-dismiss' ? 'medium' : 'normal',\n };\n const buttonContent = (\n <>\n <LeftIcon {...iconProps} />\n {shouldHaveContent && <span className={styles.content}>{children}</span>}\n <RightIcon {...iconProps} />\n </>\n );\n\n if (isAnchor) {\n return (\n // https://github.com/yannickcr/eslint-plugin-react/issues/2962\n // eslint-disable-next-line react/jsx-no-target-blank\n <>\n <a\n {...buttonProps}\n href={href}\n target={target}\n // security recommendation: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target\n rel={rel ?? (target === '_blank' ? 'noopener noreferrer' : undefined)}\n tabIndex={isNotInteractive ? -1 : undefined}\n aria-disabled={isNotInteractive ? true : undefined}\n download={download}\n >\n {buttonContent}\n </a>\n {loading && loadingText && <LiveRegion>{loadingText}</LiveRegion>}\n </>\n );\n }\n return (\n <>\n <button\n {...buttonProps}\n type={formAction === 'none' ? 'button' : 'submit'}\n disabled={disabled}\n aria-disabled={loading && !disabled ? true : undefined}\n >\n {buttonContent}\n </button>\n {loading && loadingText && <LiveRegion>{loadingText}</LiveRegion>}\n </>\n );\n }\n);\n\nexport default InternalButton;\n"]}
@@ -1,25 +1,23 @@
1
1
 
2
2
  import './styles.scoped.css';
3
3
  export default {
4
- "content": "awsui_content_vjswe_19zni_97",
5
- "button": "awsui_button_vjswe_19zni_101",
6
- "variant-normal": "awsui_variant-normal_vjswe_19zni_126",
7
- "is-activated": "awsui_is-activated_vjswe_19zni_139",
8
- "hide-focus-outline": "awsui_hide-focus-outline_vjswe_19zni_148",
9
- "force-focus-outline": "awsui_force-focus-outline_vjswe_19zni_166",
10
- "variant-icon": "awsui_variant-icon_vjswe_19zni_184",
11
- "variant-modal-dismiss": "awsui_variant-modal-dismiss_vjswe_19zni_184",
12
- "variant-flashbar-icon": "awsui_variant-flashbar-icon_vjswe_19zni_184",
13
- "variant-inline-icon": "awsui_variant-inline-icon_vjswe_19zni_202",
14
- "disabled": "awsui_disabled_vjswe_19zni_220",
15
- "variant-primary": "awsui_variant-primary_vjswe_19zni_228",
16
- "variant-link": "awsui_variant-link_vjswe_19zni_330",
17
- "variant-breadcrumb-group": "awsui_variant-breadcrumb-group_vjswe_19zni_840",
18
- "variant-menu-trigger": "awsui_variant-menu-trigger_vjswe_19zni_945",
19
- "button-no-text": "awsui_button-no-text_vjswe_19zni_1047",
20
- "button-no-wrap": "awsui_button-no-wrap_vjswe_19zni_1051",
21
- "icon-left": "awsui_icon-left_vjswe_19zni_1067",
22
- "icon-right": "awsui_icon-right_vjswe_19zni_1072",
23
- "icon": "awsui_icon_vjswe_19zni_1067"
4
+ "content": "awsui_content_vjswe_lsp5t_97",
5
+ "button": "awsui_button_vjswe_lsp5t_101",
6
+ "variant-normal": "awsui_variant-normal_vjswe_lsp5t_126",
7
+ "is-activated": "awsui_is-activated_vjswe_lsp5t_139",
8
+ "variant-icon": "awsui_variant-icon_vjswe_lsp5t_166",
9
+ "variant-modal-dismiss": "awsui_variant-modal-dismiss_vjswe_lsp5t_166",
10
+ "variant-flashbar-icon": "awsui_variant-flashbar-icon_vjswe_lsp5t_166",
11
+ "variant-inline-icon": "awsui_variant-inline-icon_vjswe_lsp5t_184",
12
+ "disabled": "awsui_disabled_vjswe_lsp5t_202",
13
+ "variant-primary": "awsui_variant-primary_vjswe_lsp5t_210",
14
+ "variant-link": "awsui_variant-link_vjswe_lsp5t_294",
15
+ "variant-breadcrumb-group": "awsui_variant-breadcrumb-group_vjswe_lsp5t_714",
16
+ "variant-menu-trigger": "awsui_variant-menu-trigger_vjswe_lsp5t_801",
17
+ "button-no-text": "awsui_button-no-text_vjswe_lsp5t_885",
18
+ "button-no-wrap": "awsui_button-no-wrap_vjswe_lsp5t_889",
19
+ "icon-left": "awsui_icon-left_vjswe_lsp5t_905",
20
+ "icon-right": "awsui_icon-right_vjswe_lsp5t_910",
21
+ "icon": "awsui_icon_vjswe_lsp5t_905"
24
22
  };
25
23