@cloudscape-design/components 3.0.12 → 3.0.15

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 (113) hide show
  1. package/alert/styles.scoped.css +0 -2
  2. package/annotation-context/annotation/styles.scoped.css +0 -1
  3. package/area-chart/styles.scoped.css +0 -1
  4. package/attribute-editor/styles.scoped.css +0 -1
  5. package/autosuggest/internal.d.ts.map +1 -1
  6. package/autosuggest/internal.js +19 -33
  7. package/autosuggest/internal.js.map +1 -1
  8. package/autosuggest/options-list.d.ts +19 -0
  9. package/autosuggest/options-list.d.ts.map +1 -0
  10. package/autosuggest/options-list.js +37 -0
  11. package/autosuggest/options-list.js.map +1 -0
  12. package/autosuggest/plain-list.d.ts +3 -5
  13. package/autosuggest/plain-list.d.ts.map +1 -1
  14. package/autosuggest/plain-list.js +7 -7
  15. package/autosuggest/plain-list.js.map +1 -1
  16. package/autosuggest/virtual-list.d.ts +2 -6
  17. package/autosuggest/virtual-list.d.ts.map +1 -1
  18. package/autosuggest/virtual-list.js +7 -7
  19. package/autosuggest/virtual-list.js.map +1 -1
  20. package/badge/styles.scoped.css +0 -1
  21. package/breadcrumb-group/styles.scoped.css +0 -2
  22. package/button/styles.scoped.css +0 -1
  23. package/button-dropdown/mobile-expandable-group/styles.scoped.css +0 -2
  24. package/cards/styles.scoped.css +0 -1
  25. package/checkbox/styles.scoped.css +0 -1
  26. package/code-editor/styles.scoped.css +0 -1
  27. package/column-layout/styles.scoped.css +0 -1
  28. package/container/styles.scoped.css +0 -1
  29. package/date-picker/calendar/index.d.ts +1 -1
  30. package/date-picker/calendar/index.d.ts.map +1 -1
  31. package/date-picker/calendar/index.js +3 -1
  32. package/date-picker/calendar/index.js.map +1 -1
  33. package/date-picker/embedded.d.ts +3 -0
  34. package/date-picker/embedded.d.ts.map +1 -0
  35. package/date-picker/embedded.js +15 -0
  36. package/date-picker/embedded.js.map +1 -0
  37. package/date-picker/index.d.ts.map +1 -1
  38. package/date-picker/index.js +14 -39
  39. package/date-picker/index.js.map +1 -1
  40. package/date-picker/interfaces.d.ts +12 -10
  41. package/date-picker/interfaces.d.ts.map +1 -1
  42. package/date-picker/interfaces.js.map +1 -1
  43. package/date-picker/styles.scoped.css +0 -2
  44. package/date-picker/use-date-picker.d.ts +17 -0
  45. package/date-picker/use-date-picker.d.ts.map +1 -0
  46. package/date-picker/use-date-picker.js +48 -0
  47. package/date-picker/use-date-picker.js.map +1 -0
  48. package/date-range-picker/calendar/header/button/index.d.ts +1 -2
  49. package/date-range-picker/calendar/header/button/index.d.ts.map +1 -1
  50. package/date-range-picker/calendar/header/button/index.js +2 -3
  51. package/date-range-picker/calendar/header/button/index.js.map +1 -1
  52. package/date-range-picker/calendar/header/index.d.ts +1 -2
  53. package/date-range-picker/calendar/header/index.d.ts.map +1 -1
  54. package/date-range-picker/calendar/header/index.js +3 -3
  55. package/date-range-picker/calendar/header/index.js.map +1 -1
  56. package/date-range-picker/calendar/index.js +1 -1
  57. package/date-range-picker/calendar/index.js.map +1 -1
  58. package/date-range-picker/styles.scoped.css +0 -3
  59. package/expandable-section/styles.scoped.css +0 -1
  60. package/flashbar/styles.scoped.css +0 -1
  61. package/form/styles.scoped.css +0 -1
  62. package/form-field/styles.scoped.css +0 -1
  63. package/grid/styles.scoped.css +0 -1
  64. package/header/styles.scoped.css +0 -1
  65. package/help-panel/styles.scoped.css +0 -1
  66. package/input/styles.scoped.css +0 -1
  67. package/internal/components/abstract-switch/styles.scoped.css +0 -1
  68. package/internal/components/button-trigger/styles.scoped.css +0 -1
  69. package/internal/components/chart-filter/styles.scoped.css +0 -1
  70. package/internal/components/chart-legend/styles.scoped.css +0 -1
  71. package/internal/components/chart-popover/styles.scoped.css +0 -1
  72. package/internal/components/chart-series-details/styles.scoped.css +0 -2
  73. package/internal/components/chart-series-marker/styles.scoped.css +0 -1
  74. package/internal/components/dropdown/styles.scoped.css +0 -2
  75. package/internal/components/dropdown-footer/styles.scoped.css +0 -1
  76. package/internal/components/dropdown-status/styles.scoped.css +0 -1
  77. package/internal/components/menu-dropdown/styles.scoped.css +0 -1
  78. package/internal/components/option/styles.scoped.css +0 -1
  79. package/internal/components/options-list/styles.scoped.css +0 -1
  80. package/internal/environment.js +1 -1
  81. package/link/styles.scoped.css +0 -1
  82. package/mixed-line-bar-chart/styles.scoped.css +0 -1
  83. package/modal/styles.scoped.css +0 -2
  84. package/multiselect/styles.scoped.css +0 -1
  85. package/package.json +1 -1
  86. package/pagination/styles.scoped.css +0 -1
  87. package/pie-chart/styles.scoped.css +0 -1
  88. package/popover/styles.scoped.css +0 -2
  89. package/progress-bar/styles.scoped.css +0 -1
  90. package/property-filter/styles.scoped.css +0 -1
  91. package/radio-group/styles.scoped.css +0 -1
  92. package/segmented-control/styles.scoped.css +0 -7
  93. package/select/styles.scoped.css +0 -1
  94. package/side-navigation/styles.scoped.css +0 -1
  95. package/split-panel/styles.scoped.css +0 -2
  96. package/table/resizer/styles.scoped.css +0 -1
  97. package/tabs/styles.scoped.css +0 -1
  98. package/text-content/styles.scoped.css +0 -1
  99. package/text-filter/styles.scoped.css +0 -1
  100. package/textarea/styles.scoped.css +0 -12
  101. package/tiles/styles.scoped.css +0 -2
  102. package/toggle/styles.scoped.css +0 -1
  103. package/token-group/styles.scoped.css +0 -2
  104. package/top-navigation/1.0-beta/styles.scoped.css +0 -1
  105. package/top-navigation/styles.scoped.css +0 -3
  106. package/tutorial-panel/components/tutorial-detail-view/styles.scoped.css +0 -1
  107. package/tutorial-panel/components/tutorial-list/styles.scoped.css +0 -3
  108. package/tutorial-panel/styles.scoped.css +0 -1
  109. package/wizard/styles.scoped.css +0 -1
  110. package/autosuggest/hooks/a11y.d.ts +0 -5
  111. package/autosuggest/hooks/a11y.d.ts.map +0 -1
  112. package/autosuggest/hooks/a11y.js +0 -24
  113. package/autosuggest/hooks/a11y.js.map +0 -1
@@ -133,7 +133,6 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
133
133
  font-stretch: normal;
134
134
  line-height: normal;
135
135
  -webkit-hyphens: none;
136
- -ms-hyphens: none;
137
136
  hyphens: none;
138
137
  letter-spacing: normal;
139
138
  list-style: disc outside none;
@@ -182,7 +181,6 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
182
181
  font-stretch: normal;
183
182
  line-height: normal;
184
183
  -webkit-hyphens: none;
185
- -ms-hyphens: none;
186
184
  hyphens: none;
187
185
  letter-spacing: normal;
188
186
  list-style: disc outside none;
@@ -196,7 +196,6 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
196
196
  font-stretch: normal;
197
197
  line-height: normal;
198
198
  -webkit-hyphens: none;
199
- -ms-hyphens: none;
200
199
  hyphens: none;
201
200
  letter-spacing: normal;
202
201
  list-style: disc outside none;
@@ -125,7 +125,6 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
125
125
  font-stretch: normal;
126
126
  line-height: normal;
127
127
  -webkit-hyphens: none;
128
- -ms-hyphens: none;
129
128
  hyphens: none;
130
129
  letter-spacing: normal;
131
130
  list-style: disc outside none;
@@ -133,7 +133,6 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
133
133
  font-stretch: normal;
134
134
  line-height: normal;
135
135
  -webkit-hyphens: none;
136
- -ms-hyphens: none;
137
136
  hyphens: none;
138
137
  letter-spacing: normal;
139
138
  list-style: disc outside none;
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAwD,MAAM,OAAO,CAAC;AAW7E,OAAO,EAAmB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAYjE,OAAO,EAA0B,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAGpF,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAKjD,OAAO,EAAE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tslib";
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  import clsx from 'clsx';
5
5
  import React, { useCallback, useEffect, useRef, useState } from 'react';
6
- import { useAutosuggestItems, useFilteredItems, useKeyboardHandler, useSelectVisibleOption, useHighlightVisibleOption, getParentGroup, } from './controller';
7
- import { useDropdownA11yProps } from './hooks/a11y';
8
- import VirtualList from './virtual-list';
9
- import PlainList from './plain-list';
6
+ import { useAutosuggestItems, useFilteredItems, useKeyboardHandler } from './controller';
10
7
  import Dropdown from '../internal/components/dropdown';
11
8
  import { useDropdownStatus } from '../internal/components/dropdown-status';
12
9
  import DropdownFooter from '../internal/components/dropdown-footer';
13
10
  import { useFormFieldContext } from '../internal/context/form-field-context';
14
11
  import { getBaseProps } from '../internal/base-component';
15
- import { useUniqueId } from '../internal/hooks/use-unique-id';
12
+ import { generateUniqueId, useUniqueId } from '../internal/hooks/use-unique-id';
16
13
  import useForwardFocus from '../internal/hooks/forward-focus';
17
14
  import { fireNonCancelableEvent } from '../internal/events';
18
15
  import { createHighlightedOptionHook } from '../internal/components/options-list/utils/use-highlight-option';
@@ -21,8 +18,8 @@ import styles from './styles.css.js';
21
18
  import { checkOptionValueField } from '../select/utils/check-option-value-field';
22
19
  import checkControlled from '../internal/hooks/check-controlled';
23
20
  import { fireCancelableEvent } from '../internal/events/index';
24
- import { useAnnouncement } from '../select/utils/use-announcement';
25
21
  import TabTrap from '../internal/components/tab-trap';
22
+ import AutosuggestOptionsList from './options-list';
26
23
  var isInteractive = function (option) {
27
24
  return !!option && !option.disabled && option.type !== 'parent';
28
25
  };
@@ -30,13 +27,6 @@ var isHighlightable = function (option) {
30
27
  return !!option && option.type !== 'parent';
31
28
  };
32
29
  var useHighlightedOption = createHighlightedOptionHook({ isHighlightable: isHighlightable });
33
- var createMouseEventHandler = function (handler, usingMouse) { return function (itemIndex) {
34
- // prevent mouse events to avoid losing focus from the input
35
- usingMouse.current = true;
36
- if (itemIndex > -1) {
37
- handler(itemIndex);
38
- }
39
- }; };
40
30
  var useLoadMoreItems = function (onLoadItems) {
41
31
  var lastFilteringText = useRef(null);
42
32
  return useCallback(function (firstPage, samePage, filteringText) {
@@ -106,10 +96,6 @@ var InternalAutosuggest = React.forwardRef(function (props, ref) {
106
96
  resetHighlight();
107
97
  onChange && onChange(e);
108
98
  };
109
- var highlightVisibleOption = useHighlightVisibleOption(filteredItems, setHighlightedIndex, isHighlightable);
110
- var selectVisibleOption = useSelectVisibleOption(filteredItems, selectOption, isInteractive);
111
- var handleMouseUp = createMouseEventHandler(selectVisibleOption, usingMouse);
112
- var handleMouseMove = createMouseEventHandler(highlightVisibleOption, usingMouse);
113
99
  var handleKeyDown = useKeyboardHandler(moveHighlight, openDropdown, selectHighlighted, usingMouse, open, onKeyDown);
114
100
  var handleLoadMore = useCallback(function () {
115
101
  options && options.length && statusType === 'pending' && fireLoadMore(false, false);
@@ -130,8 +116,21 @@ var InternalAutosuggest = React.forwardRef(function (props, ref) {
130
116
  var listId = useUniqueId('list');
131
117
  // From an a11y point of view we only count the dropdown as 'expanded' if there are items that a user can dropdown into
132
118
  var expanded = open && filteredItems.length > 1;
133
- var _h = useDropdownA11yProps(listId, expanded, ariaLabel, highlightedOption), inputA11yProps = _h[0], highlightedA11yProps = _h[1];
134
- var nativeAttributes = __assign({ name: name, placeholder: placeholder, autoFocus: autoFocus, onClick: openDropdown }, inputA11yProps);
119
+ var highlightedOptionId = highlightedOption ? generateUniqueId() : undefined;
120
+ var nativeAttributes = {
121
+ name: name,
122
+ placeholder: placeholder,
123
+ autoFocus: autoFocus,
124
+ onClick: openDropdown,
125
+ role: 'combobox',
126
+ 'aria-autocomplete': 'list',
127
+ 'aria-expanded': expanded,
128
+ 'aria-controls': listId,
129
+ // 'aria-owns' needed for safari+vo to announce activedescendant content
130
+ 'aria-owns': listId,
131
+ 'aria-label': ariaLabel,
132
+ 'aria-activedescendant': highlightedOptionId
133
+ };
135
134
  var handleInputFocus = function (e) {
136
135
  !__disableShowAll && setShowAll(true);
137
136
  var openPrevented = fireCancelableEvent(__onOpen, null);
@@ -148,30 +147,17 @@ var InternalAutosuggest = React.forwardRef(function (props, ref) {
148
147
  var isEmpty = !value && !filteredItems.length;
149
148
  var showRecoveryLink = open && statusType === 'error' && props.recoveryText;
150
149
  var dropdownStatus = useDropdownStatus(__assign(__assign({}, props), { isEmpty: isEmpty, onRecoveryClick: handleRecoveryClick }));
151
- var ListComponent = virtualScroll ? VirtualList : PlainList;
152
150
  var handleMouseDown = function (event) {
153
151
  // prevent currently focused element from losing it
154
152
  event.preventDefault();
155
153
  };
156
- var announcement = useAnnouncement({
157
- announceSelected: true,
158
- highlightedOption: highlightedOption,
159
- getParent: function (option) { var _a; return (_a = getParentGroup(option)) === null || _a === void 0 ? void 0 : _a.option; },
160
- selectedAriaLabel: selectedAriaLabel,
161
- renderHighlightedAriaLive: renderHighlightedAriaLive
162
- });
163
154
  return (React.createElement("div", __assign({}, baseProps, { className: clsx(styles.root, baseProps.className), ref: __internalRootRef, onBlur: handleBlur }),
164
155
  React.createElement(Dropdown, { minWidth: __dropdownWidth, stretchWidth: !__dropdownWidth, trigger: React.createElement(React.Fragment, null,
165
156
  React.createElement(InternalInput, __assign({ type: "search", value: value, onChange: handleInputChange, __onDelayedInput: function (event) { return fireLoadMore(true, false, event.detail.value); }, onFocus: handleInputFocus, onKeyDown: handleKeyDown, onKeyUp: onKeyUp, disabled: disabled, disableBrowserAutocorrect: disableBrowserAutocorrect, readOnly: readOnly, ariaRequired: ariaRequired, ref: inputRef, autoComplete: false, __nativeAttributes: nativeAttributes }, formFieldContext, { controlId: controlId })),
166
157
  React.createElement(TabTrap, { focusNextCallback: function () { return dropdownStatus.focusRecoveryLink(); }, disabled: !open || !showRecoveryLink })), onMouseDown: handleMouseDown, open: open, dropdownId: dropdownId, footer: dropdownStatus.isSticky ? (React.createElement("div", { ref: dropdownFooterRef, className: styles['dropdown-footer'] },
167
158
  React.createElement(TabTrap, { focusNextCallback: function () { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); }, disabled: !showRecoveryLink }),
168
159
  React.createElement(DropdownFooter, { content: dropdownStatus.content, hasItems: filteredItems.length >= 1 }),
169
- React.createElement(TabTrap, { focusNextCallback: function () { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); }, disabled: !showRecoveryLink }))) : null, expandToViewport: expandToViewport, hasContent: filteredItems.length >= 1 || dropdownStatus.content !== null }, open && (React.createElement(ListComponent, { listBottom: !dropdownStatus.isSticky ? React.createElement(DropdownFooter, { content: dropdownStatus.content }) : null, handleLoadMore: handleLoadMore, filteredItems: filteredItems, highlightText: filterText, usingMouse: usingMouse, highlightedOption: highlightedOption, enteredTextLabel: enteredTextLabel, ref: scrollToIndex, highlightedA11yProps: highlightedA11yProps, hasDropdownStatus: dropdownStatus.content !== null, menuProps: {
170
- id: listId,
171
- onMouseUp: handleMouseUp,
172
- onMouseMove: handleMouseMove,
173
- ariaLabelledby: controlId
174
- }, screenReaderContent: announcement })))));
160
+ React.createElement(TabTrap, { focusNextCallback: function () { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); }, disabled: !showRecoveryLink }))) : null, expandToViewport: expandToViewport, hasContent: filteredItems.length >= 1 || dropdownStatus.content !== null }, open && (React.createElement(AutosuggestOptionsList, { options: filteredItems, highlightedOption: highlightedOption, selectOption: selectOption, highlightedIndex: highlightedIndex, setHighlightedIndex: setHighlightedIndex, highlightedOptionId: highlightedOptionId, highlightText: filterText, listId: listId, controlId: controlId, enteredTextLabel: enteredTextLabel, handleLoadMore: handleLoadMore, hasDropdownStatus: dropdownStatus.content !== null, virtualScroll: virtualScroll, selectedAriaLabel: selectedAriaLabel, renderHighlightedAriaLive: renderHighlightedAriaLive, listBottom: !dropdownStatus.isSticky ? React.createElement(DropdownFooter, { content: dropdownStatus.content }) : null, usingMouse: usingMouse })))));
175
161
  });
176
162
  export default InternalAutosuggest;
177
163
  //# sourceMappingURL=internal.js.map
@@ -1 +1 @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AE,SAAS;aAC1B,EACD,mBAAmB,EAAE,YAAY,GACjC,CACH,CACQ,CACP,CACP,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,mBAAmB,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, { Ref, useCallback, useEffect, useRef, useState } from 'react';\n\nimport {\n useAutosuggestItems,\n useFilteredItems,\n useKeyboardHandler,\n useSelectVisibleOption,\n useHighlightVisibleOption,\n getParentGroup,\n} from './controller';\nimport { useDropdownA11yProps } from './hooks/a11y';\nimport { AutosuggestItem, AutosuggestProps } from './interfaces';\nimport VirtualList from './virtual-list';\nimport PlainList from './plain-list';\n\nimport Dropdown from '../internal/components/dropdown';\nimport { useDropdownStatus } from '../internal/components/dropdown-status';\nimport DropdownFooter from '../internal/components/dropdown-footer';\n\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { getBaseProps } from '../internal/base-component';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { fireNonCancelableEvent, CancelableEventHandler } from '../internal/events';\nimport { createHighlightedOptionHook } from '../internal/components/options-list/utils/use-highlight-option';\nimport InternalInput from '../input/internal';\nimport { InputProps } from '../input/interfaces';\nimport styles from './styles.css.js';\nimport { checkOptionValueField } from '../select/utils/check-option-value-field';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { fireCancelableEvent } from '../internal/events/index';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useAnnouncement } from '../select/utils/use-announcement';\nimport { OptionGroup } from '../internal/components/option/interfaces';\nimport TabTrap from '../internal/components/tab-trap';\n\nexport interface InternalAutosuggestProps extends AutosuggestProps, InternalBaseComponentProps {\n __filterText?: string;\n __dropdownWidth?: number;\n __onOptionClick?: CancelableEventHandler<AutosuggestProps.Option>;\n __disableShowAll?: boolean;\n __hideEnteredTextOption?: boolean;\n __onOpen?: CancelableEventHandler<null>;\n}\n\nconst isInteractive = (option?: AutosuggestItem) => {\n return !!option && !option.disabled && option.type !== 'parent';\n};\n\nconst isHighlightable = (option?: AutosuggestItem) => {\n return !!option && option.type !== 'parent';\n};\n\nconst useHighlightedOption = createHighlightedOptionHook({ isHighlightable: isHighlightable });\n\nconst createMouseEventHandler =\n (handler: (index: number) => void, usingMouse: React.MutableRefObject<boolean>) => (itemIndex: number) => {\n // prevent mouse events to avoid losing focus from the input\n usingMouse.current = true;\n if (itemIndex > -1) {\n handler(itemIndex);\n }\n };\n\nconst useLoadMoreItems = (onLoadItems: AutosuggestProps['onLoadItems']) => {\n const lastFilteringText = useRef<string | null>(null);\n return useCallback(\n (firstPage: boolean, samePage: boolean, filteringText?: string) => {\n if (samePage || !firstPage || filteringText === undefined || lastFilteringText.current !== filteringText) {\n if (filteringText !== undefined) {\n lastFilteringText.current = filteringText;\n }\n if (lastFilteringText.current !== null && onLoadItems) {\n fireNonCancelableEvent(onLoadItems, { filteringText: lastFilteringText.current, firstPage, samePage });\n }\n }\n },\n [onLoadItems]\n );\n};\n\nconst InternalAutosuggest = React.forwardRef((props: InternalAutosuggestProps, ref: Ref<InputProps.Ref>) => {\n const {\n value,\n onChange,\n onBlur,\n onFocus,\n onKeyUp,\n onLoadItems,\n options,\n filteringType = 'auto',\n statusType = 'finished',\n placeholder,\n name,\n disabled,\n disableBrowserAutocorrect = false,\n autoFocus,\n readOnly,\n ariaLabel,\n ariaRequired,\n enteredTextLabel,\n onKeyDown,\n virtualScroll,\n expandToViewport,\n onSelect,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n __dropdownWidth,\n __onOptionClick,\n __disableShowAll,\n __hideEnteredTextOption,\n __onOpen,\n __internalRootRef,\n ...rest\n } = props;\n let { __filterText: filterText } = rest;\n filterText = filterText === undefined ? value : filterText;\n\n checkControlled('Autosuggest', 'value', value, 'onChange', onChange);\n checkOptionValueField('Autosuggest', 'options', options);\n\n const usingMouse = useRef(true);\n const [showAll, setShowAll] = useState(false);\n const [open, setOpen] = useState(false);\n const autosuggestItems = useAutosuggestItems(options);\n const filteredItems = useFilteredItems(\n autosuggestItems,\n value,\n filterText,\n filteringType,\n showAll,\n __hideEnteredTextOption\n );\n const openDropdown = () => !readOnly && setOpen(true);\n const scrollToIndex = useRef<(index: number) => void>(null);\n const { highlightedOption, highlightedIndex, moveHighlight, resetHighlight, setHighlightedIndex } =\n useHighlightedOption(filteredItems);\n const closeDropdown = () => {\n setOpen(false);\n resetHighlight();\n };\n const handleBlur: React.FocusEventHandler = event => {\n if (event.currentTarget.contains(event.relatedTarget) || dropdownFooterRef.current?.contains(event.relatedTarget)) {\n return;\n }\n closeDropdown();\n fireNonCancelableEvent(onBlur);\n };\n const selectOption = (option: AutosuggestItem) => {\n const value = option.value || '';\n fireNonCancelableEvent(onChange, { value });\n const selectedCancelled = fireCancelableEvent(__onOptionClick, option);\n if (!selectedCancelled) {\n closeDropdown();\n } else {\n resetHighlight();\n }\n fireNonCancelableEvent(onSelect, { value });\n };\n const selectHighlighted = () => {\n if (highlightedOption) {\n if (isInteractive(highlightedOption)) {\n selectOption(highlightedOption);\n }\n } else {\n closeDropdown();\n }\n };\n\n const fireLoadMore = useLoadMoreItems(onLoadItems);\n\n const handleInputChange: InputProps['onChange'] = e => {\n openDropdown();\n setShowAll(false);\n resetHighlight();\n onChange && onChange(e);\n };\n\n const highlightVisibleOption = useHighlightVisibleOption(filteredItems, setHighlightedIndex, isHighlightable);\n const selectVisibleOption = useSelectVisibleOption(filteredItems, selectOption, isInteractive);\n const handleMouseUp = createMouseEventHandler(selectVisibleOption, usingMouse);\n const handleMouseMove = createMouseEventHandler(highlightVisibleOption, usingMouse);\n const handleKeyDown = useKeyboardHandler(moveHighlight, openDropdown, selectHighlighted, usingMouse, open, onKeyDown);\n const handleLoadMore = useCallback(() => {\n options && options.length && statusType === 'pending' && fireLoadMore(false, false);\n }, [fireLoadMore, options, statusType]);\n const handleRecoveryClick = useCallback(() => {\n fireLoadMore(false, true);\n inputRef.current?.focus();\n }, [fireLoadMore]);\n\n const formFieldContext = useFormFieldContext(rest);\n const baseProps = getBaseProps(rest);\n const inputRef = useRef<HTMLInputElement>(null);\n const dropdownFooterRef = useRef<HTMLDivElement>(null);\n useForwardFocus(ref, inputRef);\n\n const selfControlId = useUniqueId('input');\n const controlId = formFieldContext.controlId ?? selfControlId;\n const dropdownId = useUniqueId('dropdown');\n const listId = useUniqueId('list');\n\n // From an a11y point of view we only count the dropdown as 'expanded' if there are items that a user can dropdown into\n const expanded = open && filteredItems.length > 1;\n const [inputA11yProps, highlightedA11yProps] = useDropdownA11yProps(listId, expanded, ariaLabel, highlightedOption);\n\n const nativeAttributes = {\n name,\n placeholder,\n autoFocus,\n onClick: openDropdown,\n ...inputA11yProps,\n };\n const handleInputFocus: InputProps['onFocus'] = e => {\n !__disableShowAll && setShowAll(true);\n const openPrevented = fireCancelableEvent(__onOpen, null);\n if (!openPrevented) {\n openDropdown();\n fireLoadMore(true, false, '');\n }\n onFocus?.(e);\n };\n\n useEffect(() => {\n scrollToIndex.current?.(highlightedIndex);\n }, [highlightedIndex]);\n\n const isEmpty = !value && !filteredItems.length;\n const showRecoveryLink = open && statusType === 'error' && props.recoveryText;\n const dropdownStatus = useDropdownStatus({ ...props, isEmpty, onRecoveryClick: handleRecoveryClick });\n const ListComponent = virtualScroll ? VirtualList : PlainList;\n\n const handleMouseDown = (event: React.MouseEvent) => {\n // prevent currently focused element from losing it\n event.preventDefault();\n };\n\n const announcement = useAnnouncement({\n announceSelected: true,\n highlightedOption,\n getParent: option => getParentGroup(option)?.option as undefined | OptionGroup,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n });\n\n return (\n <div {...baseProps} className={clsx(styles.root, baseProps.className)} ref={__internalRootRef} onBlur={handleBlur}>\n <Dropdown\n minWidth={__dropdownWidth}\n stretchWidth={!__dropdownWidth}\n trigger={\n <>\n <InternalInput\n type=\"search\"\n value={value}\n onChange={handleInputChange}\n __onDelayedInput={event => fireLoadMore(true, false, event.detail.value)}\n onFocus={handleInputFocus}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n disabled={disabled}\n disableBrowserAutocorrect={disableBrowserAutocorrect}\n readOnly={readOnly}\n ariaRequired={ariaRequired}\n ref={inputRef}\n autoComplete={false}\n __nativeAttributes={nativeAttributes}\n {...formFieldContext}\n controlId={controlId}\n />\n <TabTrap\n focusNextCallback={() => dropdownStatus.focusRecoveryLink()}\n disabled={!open || !showRecoveryLink}\n />\n </>\n }\n onMouseDown={handleMouseDown}\n open={open}\n dropdownId={dropdownId}\n footer={\n dropdownStatus.isSticky ? (\n <div ref={dropdownFooterRef} className={styles['dropdown-footer']}>\n <TabTrap focusNextCallback={() => inputRef.current?.focus()} disabled={!showRecoveryLink} />\n <DropdownFooter content={dropdownStatus.content} hasItems={filteredItems.length >= 1} />\n <TabTrap focusNextCallback={() => inputRef.current?.focus()} disabled={!showRecoveryLink} />\n </div>\n ) : null\n }\n expandToViewport={expandToViewport}\n hasContent={filteredItems.length >= 1 || dropdownStatus.content !== null}\n >\n {open && (\n <ListComponent\n listBottom={!dropdownStatus.isSticky ? <DropdownFooter content={dropdownStatus.content} /> : null}\n handleLoadMore={handleLoadMore}\n filteredItems={filteredItems}\n highlightText={filterText}\n usingMouse={usingMouse}\n highlightedOption={highlightedOption}\n enteredTextLabel={enteredTextLabel}\n ref={scrollToIndex}\n highlightedA11yProps={highlightedA11yProps}\n hasDropdownStatus={dropdownStatus.content !== null}\n menuProps={{\n id: listId,\n onMouseUp: handleMouseUp,\n onMouseMove: handleMouseMove,\n ariaLabelledby: controlId,\n }}\n screenReaderContent={announcement}\n />\n )}\n </Dropdown>\n </div>\n );\n});\n\nexport default InternalAutosuggest;\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/autosuggest/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;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AAO,KAAK,IAAI,EAClD,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,iBAAiB,EACpC,yBAAyB,EAAE,yBAAyB,EACpD,UAAU,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,oBAAC,cAAc,IAAC,OAAO,EAAE,cAAc,CAAC,OAAO,GAAI,CAAC,CAAC,CAAC,IAAI,EACjG,UAAU,EAAE,UAAU,GACtB,CACH,CACQ,CACP,CACP,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,mBAAmB,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, { Ref, useCallback, useEffect, useRef, useState } from 'react';\n\nimport { useAutosuggestItems, useFilteredItems, useKeyboardHandler } from './controller';\nimport { AutosuggestItem, AutosuggestProps } from './interfaces';\n\nimport Dropdown from '../internal/components/dropdown';\nimport { useDropdownStatus } from '../internal/components/dropdown-status';\nimport DropdownFooter from '../internal/components/dropdown-footer';\n\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { getBaseProps } from '../internal/base-component';\nimport { generateUniqueId, useUniqueId } from '../internal/hooks/use-unique-id';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { fireNonCancelableEvent, CancelableEventHandler } from '../internal/events';\nimport { createHighlightedOptionHook } from '../internal/components/options-list/utils/use-highlight-option';\nimport InternalInput from '../input/internal';\nimport { InputProps } from '../input/interfaces';\nimport styles from './styles.css.js';\nimport { checkOptionValueField } from '../select/utils/check-option-value-field';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { fireCancelableEvent } from '../internal/events/index';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport TabTrap from '../internal/components/tab-trap';\nimport AutosuggestOptionsList from './options-list';\n\nexport interface InternalAutosuggestProps extends AutosuggestProps, InternalBaseComponentProps {\n __filterText?: string;\n __dropdownWidth?: number;\n __onOptionClick?: CancelableEventHandler<AutosuggestProps.Option>;\n __disableShowAll?: boolean;\n __hideEnteredTextOption?: boolean;\n __onOpen?: CancelableEventHandler<null>;\n}\n\nconst isInteractive = (option?: AutosuggestItem) => {\n return !!option && !option.disabled && option.type !== 'parent';\n};\n\nconst isHighlightable = (option?: AutosuggestItem) => {\n return !!option && option.type !== 'parent';\n};\n\nconst useHighlightedOption = createHighlightedOptionHook({ isHighlightable: isHighlightable });\n\nconst useLoadMoreItems = (onLoadItems: AutosuggestProps['onLoadItems']) => {\n const lastFilteringText = useRef<string | null>(null);\n return useCallback(\n (firstPage: boolean, samePage: boolean, filteringText?: string) => {\n if (samePage || !firstPage || filteringText === undefined || lastFilteringText.current !== filteringText) {\n if (filteringText !== undefined) {\n lastFilteringText.current = filteringText;\n }\n if (lastFilteringText.current !== null && onLoadItems) {\n fireNonCancelableEvent(onLoadItems, { filteringText: lastFilteringText.current, firstPage, samePage });\n }\n }\n },\n [onLoadItems]\n );\n};\n\nconst InternalAutosuggest = React.forwardRef((props: InternalAutosuggestProps, ref: Ref<InputProps.Ref>) => {\n const {\n value,\n onChange,\n onBlur,\n onFocus,\n onKeyUp,\n onLoadItems,\n options,\n filteringType = 'auto',\n statusType = 'finished',\n placeholder,\n name,\n disabled,\n disableBrowserAutocorrect = false,\n autoFocus,\n readOnly,\n ariaLabel,\n ariaRequired,\n enteredTextLabel,\n onKeyDown,\n virtualScroll,\n expandToViewport,\n onSelect,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n __dropdownWidth,\n __onOptionClick,\n __disableShowAll,\n __hideEnteredTextOption,\n __onOpen,\n __internalRootRef,\n ...rest\n } = props;\n let { __filterText: filterText } = rest;\n filterText = filterText === undefined ? value : filterText;\n\n checkControlled('Autosuggest', 'value', value, 'onChange', onChange);\n checkOptionValueField('Autosuggest', 'options', options);\n\n const usingMouse = useRef(true);\n const [showAll, setShowAll] = useState(false);\n const [open, setOpen] = useState(false);\n const autosuggestItems = useAutosuggestItems(options);\n const filteredItems = useFilteredItems(\n autosuggestItems,\n value,\n filterText,\n filteringType,\n showAll,\n __hideEnteredTextOption\n );\n const openDropdown = () => !readOnly && setOpen(true);\n const scrollToIndex = useRef<(index: number) => void>(null);\n const { highlightedOption, highlightedIndex, moveHighlight, resetHighlight, setHighlightedIndex } =\n useHighlightedOption(filteredItems);\n const closeDropdown = () => {\n setOpen(false);\n resetHighlight();\n };\n const handleBlur: React.FocusEventHandler = event => {\n if (event.currentTarget.contains(event.relatedTarget) || dropdownFooterRef.current?.contains(event.relatedTarget)) {\n return;\n }\n closeDropdown();\n fireNonCancelableEvent(onBlur);\n };\n const selectOption = (option: AutosuggestItem) => {\n const value = option.value || '';\n fireNonCancelableEvent(onChange, { value });\n const selectedCancelled = fireCancelableEvent(__onOptionClick, option);\n if (!selectedCancelled) {\n closeDropdown();\n } else {\n resetHighlight();\n }\n fireNonCancelableEvent(onSelect, { value });\n };\n const selectHighlighted = () => {\n if (highlightedOption) {\n if (isInteractive(highlightedOption)) {\n selectOption(highlightedOption);\n }\n } else {\n closeDropdown();\n }\n };\n\n const fireLoadMore = useLoadMoreItems(onLoadItems);\n\n const handleInputChange: InputProps['onChange'] = e => {\n openDropdown();\n setShowAll(false);\n resetHighlight();\n onChange && onChange(e);\n };\n\n const handleKeyDown = useKeyboardHandler(moveHighlight, openDropdown, selectHighlighted, usingMouse, open, onKeyDown);\n const handleLoadMore = useCallback(() => {\n options && options.length && statusType === 'pending' && fireLoadMore(false, false);\n }, [fireLoadMore, options, statusType]);\n const handleRecoveryClick = useCallback(() => {\n fireLoadMore(false, true);\n inputRef.current?.focus();\n }, [fireLoadMore]);\n\n const formFieldContext = useFormFieldContext(rest);\n const baseProps = getBaseProps(rest);\n const inputRef = useRef<HTMLInputElement>(null);\n const dropdownFooterRef = useRef<HTMLDivElement>(null);\n useForwardFocus(ref, inputRef);\n\n const selfControlId = useUniqueId('input');\n const controlId = formFieldContext.controlId ?? selfControlId;\n const dropdownId = useUniqueId('dropdown');\n const listId = useUniqueId('list');\n\n // From an a11y point of view we only count the dropdown as 'expanded' if there are items that a user can dropdown into\n const expanded = open && filteredItems.length > 1;\n const highlightedOptionId = highlightedOption ? generateUniqueId() : undefined;\n const nativeAttributes = {\n name,\n placeholder,\n autoFocus,\n onClick: openDropdown,\n role: 'combobox',\n 'aria-autocomplete': 'list',\n 'aria-expanded': expanded,\n 'aria-controls': listId,\n // 'aria-owns' needed for safari+vo to announce activedescendant content\n 'aria-owns': listId,\n 'aria-label': ariaLabel,\n 'aria-activedescendant': highlightedOptionId,\n };\n\n const handleInputFocus: InputProps['onFocus'] = e => {\n !__disableShowAll && setShowAll(true);\n const openPrevented = fireCancelableEvent(__onOpen, null);\n if (!openPrevented) {\n openDropdown();\n fireLoadMore(true, false, '');\n }\n onFocus?.(e);\n };\n\n useEffect(() => {\n scrollToIndex.current?.(highlightedIndex);\n }, [highlightedIndex]);\n\n const isEmpty = !value && !filteredItems.length;\n const showRecoveryLink = open && statusType === 'error' && props.recoveryText;\n const dropdownStatus = useDropdownStatus({ ...props, isEmpty, onRecoveryClick: handleRecoveryClick });\n\n const handleMouseDown = (event: React.MouseEvent) => {\n // prevent currently focused element from losing it\n event.preventDefault();\n };\n\n return (\n <div {...baseProps} className={clsx(styles.root, baseProps.className)} ref={__internalRootRef} onBlur={handleBlur}>\n <Dropdown\n minWidth={__dropdownWidth}\n stretchWidth={!__dropdownWidth}\n trigger={\n <>\n <InternalInput\n type=\"search\"\n value={value}\n onChange={handleInputChange}\n __onDelayedInput={event => fireLoadMore(true, false, event.detail.value)}\n onFocus={handleInputFocus}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n disabled={disabled}\n disableBrowserAutocorrect={disableBrowserAutocorrect}\n readOnly={readOnly}\n ariaRequired={ariaRequired}\n ref={inputRef}\n autoComplete={false}\n __nativeAttributes={nativeAttributes}\n {...formFieldContext}\n controlId={controlId}\n />\n <TabTrap\n focusNextCallback={() => dropdownStatus.focusRecoveryLink()}\n disabled={!open || !showRecoveryLink}\n />\n </>\n }\n onMouseDown={handleMouseDown}\n open={open}\n dropdownId={dropdownId}\n footer={\n dropdownStatus.isSticky ? (\n <div ref={dropdownFooterRef} className={styles['dropdown-footer']}>\n <TabTrap focusNextCallback={() => inputRef.current?.focus()} disabled={!showRecoveryLink} />\n <DropdownFooter content={dropdownStatus.content} hasItems={filteredItems.length >= 1} />\n <TabTrap focusNextCallback={() => inputRef.current?.focus()} disabled={!showRecoveryLink} />\n </div>\n ) : null\n }\n expandToViewport={expandToViewport}\n hasContent={filteredItems.length >= 1 || dropdownStatus.content !== null}\n >\n {open && (\n <AutosuggestOptionsList\n options={filteredItems}\n highlightedOption={highlightedOption}\n selectOption={selectOption}\n highlightedIndex={highlightedIndex}\n setHighlightedIndex={setHighlightedIndex}\n highlightedOptionId={highlightedOptionId}\n highlightText={filterText}\n listId={listId}\n controlId={controlId}\n enteredTextLabel={enteredTextLabel}\n handleLoadMore={handleLoadMore}\n hasDropdownStatus={dropdownStatus.content !== null}\n virtualScroll={virtualScroll}\n selectedAriaLabel={selectedAriaLabel}\n renderHighlightedAriaLive={renderHighlightedAriaLive}\n listBottom={!dropdownStatus.isSticky ? <DropdownFooter content={dropdownStatus.content} /> : null}\n usingMouse={usingMouse}\n />\n )}\n </Dropdown>\n </div>\n );\n});\n\nexport default InternalAutosuggest;\n"]}
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { AutosuggestItem, AutosuggestProps } from './interfaces';
3
+ export interface AutosuggestOptionsListProps extends Pick<AutosuggestProps, 'enteredTextLabel' | 'virtualScroll' | 'selectedAriaLabel' | 'renderHighlightedAriaLive'> {
4
+ options: AutosuggestItem[];
5
+ highlightedOption?: AutosuggestItem;
6
+ selectOption: (option: AutosuggestItem) => void;
7
+ highlightedIndex: number;
8
+ setHighlightedIndex: (index: number) => void;
9
+ highlightedOptionId?: string;
10
+ highlightText: string;
11
+ listId: string;
12
+ controlId: string;
13
+ handleLoadMore: () => void;
14
+ hasDropdownStatus?: boolean;
15
+ listBottom?: React.ReactNode;
16
+ usingMouse: React.MutableRefObject<boolean>;
17
+ }
18
+ export default function AutosuggestOptionsList({ options, highlightedOption, selectOption, highlightedIndex, setHighlightedIndex, highlightedOptionId, highlightText, listId, controlId, enteredTextLabel, handleLoadMore, hasDropdownStatus, virtualScroll, selectedAriaLabel, renderHighlightedAriaLive, listBottom, usingMouse, }: AutosuggestOptionsListProps): JSX.Element;
19
+ //# sourceMappingURL=options-list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options-list.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/options-list.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAOjE,MAAM,WAAW,2BACf,SAAQ,IAAI,CACV,gBAAgB,EAChB,kBAAkB,GAAG,eAAe,GAAG,mBAAmB,GAAG,2BAA2B,CACzF;IACD,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,iBAAiB,CAAC,EAAE,eAAe,CAAC;IACpC,YAAY,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IAChD,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,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,UAAU,EAAE,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;CAC7C;AAmBD,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAC7C,OAAO,EACP,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,MAAM,EACN,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EACzB,UAAU,EACV,UAAU,GACX,EAAE,2BAA2B,eAgC7B"}
@@ -0,0 +1,37 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import React from 'react';
4
+ import { useSelectVisibleOption, useHighlightVisibleOption, getParentGroup } from './controller';
5
+ import VirtualList from './virtual-list';
6
+ import PlainList from './plain-list';
7
+ import { useAnnouncement } from '../select/utils/use-announcement';
8
+ var isInteractive = function (option) {
9
+ return !!option && !option.disabled && option.type !== 'parent';
10
+ };
11
+ var isHighlightable = function (option) {
12
+ return !!option && option.type !== 'parent';
13
+ };
14
+ var createMouseEventHandler = function (handler, usingMouse) { return function (itemIndex) {
15
+ // prevent mouse events to avoid losing focus from the input
16
+ usingMouse.current = true;
17
+ if (itemIndex > -1) {
18
+ handler(itemIndex);
19
+ }
20
+ }; };
21
+ export default function AutosuggestOptionsList(_a) {
22
+ var options = _a.options, highlightedOption = _a.highlightedOption, selectOption = _a.selectOption, highlightedIndex = _a.highlightedIndex, setHighlightedIndex = _a.setHighlightedIndex, highlightedOptionId = _a.highlightedOptionId, highlightText = _a.highlightText, listId = _a.listId, controlId = _a.controlId, enteredTextLabel = _a.enteredTextLabel, handleLoadMore = _a.handleLoadMore, hasDropdownStatus = _a.hasDropdownStatus, virtualScroll = _a.virtualScroll, selectedAriaLabel = _a.selectedAriaLabel, renderHighlightedAriaLive = _a.renderHighlightedAriaLive, listBottom = _a.listBottom, usingMouse = _a.usingMouse;
23
+ var highlightVisibleOption = useHighlightVisibleOption(options, setHighlightedIndex, isHighlightable);
24
+ var selectVisibleOption = useSelectVisibleOption(options, selectOption, isInteractive);
25
+ var handleMouseUp = createMouseEventHandler(selectVisibleOption, usingMouse);
26
+ var handleMouseMove = createMouseEventHandler(highlightVisibleOption, usingMouse);
27
+ var ListComponent = virtualScroll ? VirtualList : PlainList;
28
+ var announcement = useAnnouncement({
29
+ announceSelected: true,
30
+ highlightedOption: highlightedOption,
31
+ getParent: function (option) { var _a; return (_a = getParentGroup(option)) === null || _a === void 0 ? void 0 : _a.option; },
32
+ selectedAriaLabel: selectedAriaLabel,
33
+ renderHighlightedAriaLive: renderHighlightedAriaLive
34
+ });
35
+ return (React.createElement(ListComponent, { listBottom: listBottom, handleLoadMore: handleLoadMore, filteredItems: options, highlightText: highlightText, usingMouse: usingMouse, highlightedOption: highlightedOption, highlightedIndex: highlightedIndex, enteredTextLabel: enteredTextLabel, highlightedA11yProps: highlightedOptionId ? { id: highlightedOptionId } : {}, hasDropdownStatus: hasDropdownStatus, menuProps: { id: listId, ariaLabelledby: controlId, onMouseUp: handleMouseUp, onMouseMove: handleMouseMove }, screenReaderContent: announcement }));
36
+ }
37
+ //# sourceMappingURL=options-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options-list.js","sourceRoot":"","sources":["../../../src/autosuggest/options-list.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEjG,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAuBnE,IAAM,aAAa,GAAG,UAAC,MAAwB;IAC7C,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;AAClE,CAAC,CAAC;AAEF,IAAM,eAAe,GAAG,UAAC,MAAwB;IAC/C,OAAO,CAAC,C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AI,OAAA,MAAA,cAAc,CAAC,MAAM,CAAC,0CAAE,MAAiC,CAAA,EAAA;QAC9E,iBAAiB,mBAAA;QACjB,yBAAyB,2BAAA;KAC1B,CAAC,CAAC;IAEH,OAAO,CACL,oBAAC,aAAa,IACZ,UAAU,EAAE,UAAU,EACtB,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,OAAO,EACtB,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,UAAU,EACtB,iBAAiB,EAAE,iBAAiB,EACpC,gBAAgB,EAAE,gBAAgB,EAClC,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,EAAE,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,eAAe,EAAE,EAC5G,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 { useSelectVisibleOption, useHighlightVisibleOption, getParentGroup } from './controller';\nimport { AutosuggestItem, 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 options: AutosuggestItem[];\n highlightedOption?: AutosuggestItem;\n selectOption: (option: AutosuggestItem) => void;\n highlightedIndex: number;\n setHighlightedIndex: (index: number) => void;\n highlightedOptionId?: string;\n highlightText: string;\n listId: string;\n controlId: string;\n handleLoadMore: () => void;\n hasDropdownStatus?: boolean;\n listBottom?: React.ReactNode;\n usingMouse: React.MutableRefObject<boolean>;\n}\n\nconst isInteractive = (option?: AutosuggestItem) => {\n return !!option && !option.disabled && option.type !== 'parent';\n};\n\nconst isHighlightable = (option?: AutosuggestItem) => {\n return !!option && option.type !== 'parent';\n};\n\nconst createMouseEventHandler =\n (handler: (index: number) => void, usingMouse: React.MutableRefObject<boolean>) => (itemIndex: number) => {\n // prevent mouse events to avoid losing focus from the input\n usingMouse.current = true;\n if (itemIndex > -1) {\n handler(itemIndex);\n }\n };\n\nexport default function AutosuggestOptionsList({\n options,\n highlightedOption,\n selectOption,\n highlightedIndex,\n setHighlightedIndex,\n highlightedOptionId,\n highlightText,\n listId,\n controlId,\n enteredTextLabel,\n handleLoadMore,\n hasDropdownStatus,\n virtualScroll,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n listBottom,\n usingMouse,\n}: AutosuggestOptionsListProps) {\n const highlightVisibleOption = useHighlightVisibleOption(options, setHighlightedIndex, isHighlightable);\n const selectVisibleOption = useSelectVisibleOption(options, selectOption, isInteractive);\n const handleMouseUp = createMouseEventHandler(selectVisibleOption, usingMouse);\n const handleMouseMove = createMouseEventHandler(highlightVisibleOption, usingMouse);\n\n const ListComponent = virtualScroll ? VirtualList : PlainList;\n\n const announcement = useAnnouncement({\n announceSelected: true,\n 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 filteredItems={options}\n highlightText={highlightText}\n usingMouse={usingMouse}\n highlightedOption={highlightedOption}\n highlightedIndex={highlightedIndex}\n enteredTextLabel={enteredTextLabel}\n highlightedA11yProps={highlightedOptionId ? { id: highlightedOptionId } : {}}\n hasDropdownStatus={hasDropdownStatus}\n menuProps={{ id: listId, ariaLabelledby: controlId, onMouseUp: handleMouseUp, onMouseMove: handleMouseMove }}\n screenReaderContent={announcement}\n />\n );\n}\n"]}
@@ -7,6 +7,7 @@ export interface ListProps {
7
7
  filteredItems: AutosuggestItem[];
8
8
  usingMouse: React.MutableRefObject<boolean>;
9
9
  highlightedOption?: AutosuggestItem;
10
+ highlightedIndex: number;
10
11
  enteredTextLabel: AutosuggestProps.EnteredTextLabel;
11
12
  highlightedA11yProps: Record<string, string | number | boolean>;
12
13
  hasDropdownStatus?: boolean;
@@ -14,15 +15,12 @@ export interface ListProps {
14
15
  listBottom?: React.ReactNode;
15
16
  screenReaderContent?: string;
16
17
  }
17
- declare namespace PlainListProps {
18
- type PlainListRef = (index: number) => void;
19
- }
20
18
  export declare const getOptionProps: (index: number, item: AutosuggestItem, filteredItems: AutosuggestItem[], highlightedA11yProps: ListProps['highlightedA11yProps'], highlightedOption?: ListProps['highlightedOption'], hasDropdownStatus?: boolean | undefined) => {
21
19
  className?: string | undefined;
22
20
  id?: string | undefined;
23
21
  nativeAttributes: Record<string, string | number | boolean>;
24
22
  padBottom: boolean;
25
23
  };
26
- declare const _default: React.ForwardRefExoticComponent<ListProps & React.RefAttributes<PlainListProps.PlainListRef>>;
27
- export default _default;
24
+ declare const PlainList: ({ handleLoadMore, filteredItems, usingMouse, menuProps, highlightedOption, highlightedIndex, enteredTextLabel, highlightedA11yProps, hasDropdownStatus, highlightText, listBottom, screenReaderContent, }: ListProps) => JSX.Element;
25
+ export default PlainList;
28
26
  //# sourceMappingURL=plain-list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plain-list.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/plain-list.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAEvE,OAAoB,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAKpF,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGjE,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE,UA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AiB,CAAC,EAAE,eAAe,CAAC;IACpC,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,gBAAgB,CAAC,gBAAgB,CAAC;IACpD,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;IAChE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,eAAO,MAAM,cAAc,UAClB,MAAM,QACP,eAAe,iBACN,eAAe,EAAE,wBACV,SAAS,CAAC,sBAAsB,CAAC,sBACnC,SAAS,CAAC,mBAAmB,CAAC;;;;;CAUnD,CAAC;AAEF,QAAA,MAAM,SAAS,8MAaZ,SAAS,gBAiDX,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { __assign } from "tslib";
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import React, { forwardRef, useImperativeHandle, useRef } from 'react';
4
+ import React, { useEffect, useRef } from 'react';
5
5
  import OptionsList from '../internal/components/options-list';
6
6
  import { scrollUntilVisible } from '../internal/utils/scrollable-containers';
7
7
  import { getBaseProps } from '../internal/base-component';
@@ -15,16 +15,16 @@ export var getOptionProps = function (index, item, filteredItems, highlightedA11
15
15
  var padBottom = !hasDropdownStatus && isNotEnteredTextItem && isLastItem;
16
16
  return __assign({ nativeAttributes: nativeAttributes, padBottom: padBottom }, baseOptionProps);
17
17
  };
18
- var PlainList = function (_a, ref) {
19
- var handleLoadMore = _a.handleLoadMore, filteredItems = _a.filteredItems, usingMouse = _a.usingMouse, menuProps = _a.menuProps, highlightedOption = _a.highlightedOption, enteredTextLabel = _a.enteredTextLabel, highlightedA11yProps = _a.highlightedA11yProps, hasDropdownStatus = _a.hasDropdownStatus, highlightText = _a.highlightText, listBottom = _a.listBottom, screenReaderContent = _a.screenReaderContent;
18
+ var PlainList = function (_a) {
19
+ var handleLoadMore = _a.handleLoadMore, filteredItems = _a.filteredItems, usingMouse = _a.usingMouse, menuProps = _a.menuProps, highlightedOption = _a.highlightedOption, highlightedIndex = _a.highlightedIndex, enteredTextLabel = _a.enteredTextLabel, highlightedA11yProps = _a.highlightedA11yProps, hasDropdownStatus = _a.hasDropdownStatus, highlightText = _a.highlightText, listBottom = _a.listBottom, screenReaderContent = _a.screenReaderContent;
20
20
  var listRef = useRef(null);
21
- useImperativeHandle(ref, function () { return function (index) {
21
+ useEffect(function () {
22
22
  var _a;
23
- var item = (_a = listRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("[data-mouse-target=\"".concat(index, "\"]"));
23
+ var item = (_a = listRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("[data-mouse-target=\"".concat(highlightedIndex, "\"]"));
24
24
  if (!usingMouse.current && item) {
25
25
  scrollUntilVisible(item);
26
26
  }
27
- }; }, [usingMouse, listRef]);
27
+ }, [usingMouse, highlightedIndex]);
28
28
  return (React.createElement(OptionsList, __assign({}, menuProps, { onLoadMore: handleLoadMore, open: true, ref: listRef,
29
29
  // to prevent closing the list when clicking the scrollbar on IE11
30
30
  nativeAttributes: { unselectable: 'on' } }),
@@ -34,5 +34,5 @@ var PlainList = function (_a, ref) {
34
34
  }),
35
35
  listBottom ? (React.createElement("li", { role: "option", className: styles['list-bottom'] }, listBottom)) : null));
36
36
  };
37
- export default forwardRef(PlainList);
37
+ export default PlainList;
38
38
  //# sourceMappingURL=plain-list.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plain-list.js","sourceRoot":"","sources":["../../../src/autosuggest/plain-list.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEvE,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,CAAC,+BAAuB,KAAK,QAAI,CAAC,CAAC;QAC9E,IAAI,CAAC,UAAU,CAAC,OAAO,IAAI,IAAI,EAAE;YAC/B,kBAAkB,CAAC,IAAmB,CAAC,CAAC;SACzC;IACH,CAAC,EALK,CAKL,EACD,CAAC,UAAU,EAAE,OAAO,CAAC,CACtB,CAAC;IAEF,OAAO,CACL,oBAAC,WAAW,eACN,SAAS,IACb,UAAU,EAAE,cAAc,EAC1B,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,OAAO;QACZ,kEAAkE;QAClE,gBAAgB,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE;QAEvC,aAAa,CAAC,GAAG,CAAC,UAAC,IAAI,EAAE,KAAK;YAC7B,IAAM,WAAW,GAAG,cAAc,CAChC,KAAK,EACL,IAAI,EACJ,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,CAClB,CAAC;YAEF,OAAO,CACL,oBAAC,iBAAiB,aAChB,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,IAAI,EACZ,WAAW,EAAE,IAAI,KAAK,iBAAiB,EACvC,GAAG,EAAE,KAAK,uBACS,KAAK,EACxB,gBAAgB,EAAE,gBAAgB,EAClC,mBAAmB,EAAE,mBAAmB,IACpC,WAAW,EACf,CACH,CAAC;QACJ,CAAC,CAAC;QACD,UAAU,CAAC,CAAC,CAAC,CACZ,4BAAI,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAE,MAAM,CAAC,aAAa,CAAC,IAC/C,UAAU,CACR,CACN,CAAC,CAAC,CAAC,IAAI,CACI,CACf,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC,SAAS,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { forwardRef, useImperativeHandle, useRef } from 'react';\n\nimport OptionsList, { OptionsListProps } from '../internal/components/options-list';\nimport { scrollUntilVisible } from '../internal/utils/scrollable-containers';\nimport { getBaseProps } from '../internal/base-component';\n\nimport AutosuggestOption from './autosuggest-option';\nimport { AutosuggestProps, AutosuggestItem } from './interfaces';\nimport styles from './styles.css.js';\n\nexport interface ListProps {\n menuProps: Omit<OptionsListProps, 'children'>;\n handleLoadMore: () => void;\n filteredItems: AutosuggestItem[];\n usingMouse: React.MutableRefObject<boolean>;\n highlightedOption?: AutosuggestItem;\n enteredTextLabel: AutosuggestProps.EnteredTextLabel;\n highlightedA11yProps: Record<string, string | number | boolean>;\n hasDropdownStatus?: boolean;\n highlightText: string;\n listBottom?: React.ReactNode;\n screenReaderContent?: string;\n}\n\nnamespace PlainListProps {\n export type PlainListRef = (index: number) => void;\n}\n\nexport const getOptionProps = (\n index: number,\n item: AutosuggestItem,\n filteredItems: AutosuggestItem[],\n highlightedA11yProps: ListProps['highlightedA11yProps'],\n highlightedOption?: ListProps['highlightedOption'],\n hasDropdownStatus?: boolean\n) => {\n const nativeAttributes = item === highlightedOption ? highlightedA11yProps : {};\n const baseOptionProps = getBaseProps(nativeAttributes);\n const isLastItem = index === filteredItems.length - 1;\n const isNotEnteredTextItem = filteredItems.length > 1;\n const padBottom = !hasDropdownStatus && isNotEnteredTextItem && isLastItem;\n\n return { nativeAttributes, padBottom, ...baseOptionProps };\n};\n\nconst PlainList = (\n {\n handleLoadMore,\n filteredItems,\n usingMouse,\n menuProps,\n highlightedOption,\n enteredTextLabel,\n highlightedA11yProps,\n hasDropdownStatus,\n highlightText,\n listBottom,\n screenReaderContent,\n }: ListProps,\n ref: React.Ref<PlainListProps.PlainListRef>\n) => {\n const listRef = useRef<HTMLUListElement>(null);\n useImperativeHandle(\n ref,\n () => (index: number) => {\n const item = listRef.current?.querySelector(`[data-mouse-target=\"${index}\"]`);\n if (!usingMouse.current && item) {\n scrollUntilVisible(item as HTMLElement);\n }\n },\n [usingMouse, listRef]\n );\n\n return (\n <OptionsList\n {...menuProps}\n onLoadMore={handleLoadMore}\n open={true}\n ref={listRef}\n // to prevent closing the list when clicking the scrollbar on IE11\n nativeAttributes={{ unselectable: 'on' }}\n >\n {filteredItems.map((item, index) => {\n const optionProps = getOptionProps(\n index,\n item,\n filteredItems,\n highlightedA11yProps,\n highlightedOption,\n hasDropdownStatus\n );\n\n return (\n <AutosuggestOption\n highlightText={highlightText}\n option={item}\n highlighted={item === highlightedOption}\n key={index}\n data-mouse-target={index}\n enteredTextLabel={enteredTextLabel}\n screenReaderContent={screenReaderContent}\n {...optionProps}\n />\n );\n })}\n {listBottom ? (\n <li role=\"option\" className={styles['list-bottom']}>\n {listBottom}\n </li>\n ) : null}\n </OptionsList>\n );\n};\n\nexport default forwardRef(PlainList);\n"]}
1
+ {"version":3,"file":"plain-list.js","sourceRoot":"","sources":["../../../src/autosuggest/plain-list.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,WAAiC,MAAM,qCAAqC,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AAErD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAiBrC,MAAM,CAAC,IAAM,cAAc,GAAG,UAC5B,KAAa,EACb,IAAqB,EACrB,aAAgC,EAChC,oBAAuD,EACvD,iBAAkD,EAClD,iBAA2B;IAE3B,IAAM,gBAAgB,GAAG,IAAI,KAAK,iBAAiB,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;IAChF,IAAM,eAAe,GAAG,YAAY,CAAC,gBAAgB,CAAC,CAAC;IACvD,IAAM,UAAU,GAAG,KAAK,KAAK,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;IACtD,IAAM,oBAAoB,GAAG,aAAa,CAAC,MAAM,GAAG,CAAC,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AI,KAAK,iBAAiB,EACvC,GAAG,EAAE,KAAK,uBACS,KAAK,EACxB,gBAAgB,EAAE,gBAAgB,EAClC,mBAAmB,EAAE,mBAAmB,IACpC,WAAW,EACf,CACH,CAAC;QACJ,CAAC,CAAC;QACD,UAAU,CAAC,CAAC,CAAC,CACZ,4BAAI,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAE,MAAM,CAAC,aAAa,CAAC,IAC/C,UAAU,CACR,CACN,CAAC,CAAC,CAAC,IAAI,CACI,CACf,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,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';\n\nimport OptionsList, { OptionsListProps } from '../internal/components/options-list';\nimport { scrollUntilVisible } from '../internal/utils/scrollable-containers';\nimport { getBaseProps } from '../internal/base-component';\n\nimport AutosuggestOption from './autosuggest-option';\nimport { AutosuggestProps, AutosuggestItem } from './interfaces';\nimport styles from './styles.css.js';\n\nexport interface ListProps {\n menuProps: Omit<OptionsListProps, 'children'>;\n handleLoadMore: () => void;\n filteredItems: AutosuggestItem[];\n usingMouse: React.MutableRefObject<boolean>;\n highlightedOption?: AutosuggestItem;\n highlightedIndex: number;\n enteredTextLabel: AutosuggestProps.EnteredTextLabel;\n highlightedA11yProps: Record<string, string | number | boolean>;\n hasDropdownStatus?: boolean;\n highlightText: string;\n listBottom?: React.ReactNode;\n screenReaderContent?: string;\n}\n\nexport const getOptionProps = (\n index: number,\n item: AutosuggestItem,\n filteredItems: AutosuggestItem[],\n highlightedA11yProps: ListProps['highlightedA11yProps'],\n highlightedOption?: ListProps['highlightedOption'],\n hasDropdownStatus?: boolean\n) => {\n const nativeAttributes = item === highlightedOption ? highlightedA11yProps : {};\n const baseOptionProps = getBaseProps(nativeAttributes);\n const isLastItem = index === filteredItems.length - 1;\n const isNotEnteredTextItem = filteredItems.length > 1;\n const padBottom = !hasDropdownStatus && isNotEnteredTextItem && isLastItem;\n\n return { nativeAttributes, padBottom, ...baseOptionProps };\n};\n\nconst PlainList = ({\n handleLoadMore,\n filteredItems,\n usingMouse,\n menuProps,\n highlightedOption,\n highlightedIndex,\n enteredTextLabel,\n highlightedA11yProps,\n hasDropdownStatus,\n highlightText,\n listBottom,\n screenReaderContent,\n}: ListProps) => {\n const listRef = useRef<HTMLUListElement>(null);\n\n useEffect(() => {\n const item = listRef.current?.querySelector(`[data-mouse-target=\"${highlightedIndex}\"]`);\n if (!usingMouse.current && item) {\n scrollUntilVisible(item as HTMLElement);\n }\n }, [usingMouse, highlightedIndex]);\n\n return (\n <OptionsList\n {...menuProps}\n onLoadMore={handleLoadMore}\n open={true}\n ref={listRef}\n // to prevent closing the list when clicking the scrollbar on IE11\n nativeAttributes={{ unselectable: 'on' }}\n >\n {filteredItems.map((item, index) => {\n const optionProps = getOptionProps(\n index,\n item,\n filteredItems,\n highlightedA11yProps,\n highlightedOption,\n hasDropdownStatus\n );\n\n return (\n <AutosuggestOption\n highlightText={highlightText}\n option={item}\n highlighted={item === highlightedOption}\n key={index}\n data-mouse-target={index}\n enteredTextLabel={enteredTextLabel}\n screenReaderContent={screenReaderContent}\n {...optionProps}\n />\n );\n })}\n {listBottom ? (\n <li role=\"option\" className={styles['list-bottom']}>\n {listBottom}\n </li>\n ) : null}\n </OptionsList>\n );\n};\n\nexport default PlainList;\n"]}
@@ -1,8 +1,4 @@
1
- import React from 'react';
2
1
  import { ListProps } from './plain-list';
3
- declare namespace VirtualListProps {
4
- type VirtualListRef = (index: number) => void;
5
- }
6
- declare const _default: React.ForwardRefExoticComponent<ListProps & React.RefAttributes<VirtualListProps.VirtualListRef>>;
7
- export default _default;
2
+ declare const VirtualList: ({ handleLoadMore, filteredItems, usingMouse, menuProps, highlightedOption, highlightedIndex, enteredTextLabel, highlightedA11yProps, hasDropdownStatus, highlightText, listBottom, screenReaderContent, }: ListProps) => JSX.Element;
3
+ export default VirtualList;
8
4
  //# sourceMappingURL=virtual-list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-list.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/virtual-list.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA+D,MAAM,OAAO,CAAC;AAOpF,OAAO,EAAkB,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzD,kBAAU,gBAAgB,CAAC;IACzB,KAAY,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACtD;;AA+FD,wBAAuC"}
1
+ {"version":3,"file":"virtual-list.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/virtual-list.tsx"],"names":[],"mappings":"AASA,OAAO,EAAkB,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzD,QAAA,MAAM,WAAW,8MAad,SAAS,gBA0EX,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1,15 +1,15 @@
1
1
  import { __assign } from "tslib";
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import React, { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
4
+ import React, { useCallback, useEffect, useImperativeHandle, useRef } from 'react';
5
5
  import { useVirtual } from 'react-virtual';
6
6
  import OptionsList from '../internal/components/options-list';
7
7
  import { useContainerQuery } from '../internal/hooks/container-queries';
8
8
  import AutosuggestOption from './autosuggest-option';
9
9
  import { getOptionProps } from './plain-list';
10
10
  import styles from './styles.css.js';
11
- var VirtualList = function (_a, ref) {
12
- var handleLoadMore = _a.handleLoadMore, filteredItems = _a.filteredItems, usingMouse = _a.usingMouse, menuProps = _a.menuProps, highlightedOption = _a.highlightedOption, enteredTextLabel = _a.enteredTextLabel, highlightedA11yProps = _a.highlightedA11yProps, hasDropdownStatus = _a.hasDropdownStatus, highlightText = _a.highlightText, listBottom = _a.listBottom, screenReaderContent = _a.screenReaderContent;
11
+ var VirtualList = function (_a) {
12
+ var handleLoadMore = _a.handleLoadMore, filteredItems = _a.filteredItems, usingMouse = _a.usingMouse, menuProps = _a.menuProps, highlightedOption = _a.highlightedOption, highlightedIndex = _a.highlightedIndex, enteredTextLabel = _a.enteredTextLabel, highlightedA11yProps = _a.highlightedA11yProps, hasDropdownStatus = _a.hasDropdownStatus, highlightText = _a.highlightText, listBottom = _a.listBottom, screenReaderContent = _a.screenReaderContent;
13
13
  var scrollRef = useRef(null);
14
14
  // update component, when it gets wider or narrower to reposition items
15
15
  var _b = useContainerQuery(function (rect) { return rect.width; }, []), width = _b[0], strutRef = _b[1];
@@ -25,11 +25,11 @@ var VirtualList = function (_a, ref) {
25
25
  estimateSize: useCallback(function () { return 31; }, [width, highlightText]),
26
26
  overscan: 5
27
27
  });
28
- useImperativeHandle(ref, function () { return function (index) {
28
+ useEffect(function () {
29
29
  if (!usingMouse.current) {
30
- rowVirtualizer.scrollToIndex(index);
30
+ rowVirtualizer.scrollToIndex(highlightedIndex);
31
31
  }
32
- }; }, [usingMouse, rowVirtualizer]);
32
+ }, [usingMouse, rowVirtualizer, highlightedIndex]);
33
33
  return (React.createElement(OptionsList, __assign({}, menuProps, { onLoadMore: handleLoadMore, ref: scrollRef, open: true,
34
34
  // to prevent closing the list when clicking the scrollbar on IE11
35
35
  nativeAttributes: { unselectable: 'on' } }),
@@ -42,5 +42,5 @@ var VirtualList = function (_a, ref) {
42
42
  }),
43
43
  listBottom ? (React.createElement("li", { role: "option", className: styles['list-bottom'] }, listBottom)) : null));
44
44
  };
45
- export default forwardRef(VirtualList);
45
+ export default VirtualList;
46
46
  //# sourceMappingURL=virtual-list.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-list.js","sourceRoot":"","sources":["../../../src/autosuggest/virtual-list.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACpF,OAAO,EAAE,U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E,mBAAmB,EACxC,WAAW,EAAE,aAAa,CAAC,MAAM,EACjC,YAAY,EAAE,KAAK,GAAG,CAAC,IACnB,WAAW,EACf,CACH,CAAC;QACJ,CAAC,CAAC;QACD,UAAU,CAAC,CAAC,CAAC,CACZ,4BAAI,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAE,MAAM,CAAC,aAAa,CAAC,IAC/C,UAAU,CACR,CACN,CAAC,CAAC,CAAC,IAAI,CACI,CACf,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC,WAAW,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';\nimport { useVirtual } from 'react-virtual';\n\nimport OptionsList from '../internal/components/options-list';\nimport { useContainerQuery } from '../internal/hooks/container-queries';\n\nimport AutosuggestOption from './autosuggest-option';\nimport { getOptionProps, ListProps } from './plain-list';\nimport styles from './styles.css.js';\n\nnamespace VirtualListProps {\n export type VirtualListRef = (index: number) => void;\n}\nconst VirtualList = (\n {\n handleLoadMore,\n filteredItems,\n usingMouse,\n menuProps,\n highlightedOption,\n enteredTextLabel,\n highlightedA11yProps,\n hasDropdownStatus,\n highlightText,\n listBottom,\n screenReaderContent,\n }: ListProps,\n ref: React.Ref<VirtualListProps.VirtualListRef>\n) => {\n const scrollRef = useRef<HTMLUListElement>(null);\n // update component, when it gets wider or narrower to reposition items\n const [width, strutRef] = useContainerQuery(rect => rect.width, []);\n useImperativeHandle(strutRef, () => scrollRef.current);\n const rowVirtualizer = useVirtual({\n size: filteredItems.length,\n parentRef: scrollRef,\n // estimateSize is a dependency of measurements memo. We update it to force full recalculation\n // when the height of any option could have changed:\n // 1: because the component got resized (width property got updated)\n // 2: becasue the option changed its content (highlightText property controls the highlight and the visibility of hidden tags)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n estimateSize: useCallback(() => 31, [width, highlightText]),\n overscan: 5,\n });\n useImperativeHandle(\n ref,\n () => (index: number) => {\n if (!usingMouse.current) {\n rowVirtualizer.scrollToIndex(index);\n }\n },\n [usingMouse, rowVirtualizer]\n );\n\n return (\n <OptionsList\n {...menuProps}\n onLoadMore={handleLoadMore}\n ref={scrollRef}\n open={true}\n // to prevent closing the list when clicking the scrollbar on IE11\n nativeAttributes={{ unselectable: 'on' }}\n >\n <div\n aria-hidden=\"true\"\n key=\"total-size\"\n className={styles['layout-strut']}\n style={{ height: rowVirtualizer.totalSize + (filteredItems.length === 1 ? 1 : 0) }}\n />\n {rowVirtualizer.virtualItems.map(virtualRow => {\n const { index, start, measureRef } = virtualRow;\n const item = filteredItems[index];\n const optionProps = getOptionProps(\n index,\n item,\n filteredItems,\n highlightedA11yProps,\n highlightedOption,\n hasDropdownStatus\n );\n\n return (\n <AutosuggestOption\n key={index}\n ref={measureRef}\n highlightText={highlightText}\n option={item}\n highlighted={item === highlightedOption}\n data-mouse-target={index}\n enteredTextLabel={enteredTextLabel}\n virtualPosition={start + (index === 0 ? 1 : 0)}\n screenReaderContent={screenReaderContent}\n ariaSetsize={filteredItems.length}\n ariaPosinset={index + 1}\n {...optionProps}\n />\n );\n })}\n {listBottom ? (\n <li role=\"option\" className={styles['list-bottom']}>\n {listBottom}\n </li>\n ) : null}\n </OptionsList>\n );\n};\n\nexport default forwardRef(VirtualList);\n"]}
1
+ {"version":3,"file":"virtual-list.js","sourceRoot":"","sources":["../../../src/autosuggest/virtual-list.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,WAAW,MAAM,qCAAqC,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAExE,OAAO,iBAAiB,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,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAE,MAAM,CAAC,aAAa,CAAC,IAC/C,UAAU,CACR,CACN,CAAC,CAAC,CAAC,IAAI,CACI,CACf,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useEffect, useImperativeHandle, useRef } from 'react';\nimport { useVirtual } from 'react-virtual';\n\nimport OptionsList from '../internal/components/options-list';\nimport { useContainerQuery } from '../internal/hooks/container-queries';\n\nimport AutosuggestOption from './autosuggest-option';\nimport { getOptionProps, ListProps } from './plain-list';\nimport styles from './styles.css.js';\n\nconst VirtualList = ({\n handleLoadMore,\n filteredItems,\n usingMouse,\n menuProps,\n highlightedOption,\n highlightedIndex,\n enteredTextLabel,\n highlightedA11yProps,\n hasDropdownStatus,\n highlightText,\n listBottom,\n screenReaderContent,\n}: ListProps) => {\n const scrollRef = useRef<HTMLUListElement>(null);\n // update component, when it gets wider or narrower to reposition items\n const [width, strutRef] = useContainerQuery(rect => rect.width, []);\n useImperativeHandle(strutRef, () => scrollRef.current);\n const rowVirtualizer = useVirtual({\n size: filteredItems.length,\n parentRef: scrollRef,\n // estimateSize is a dependency of measurements memo. We update it to force full recalculation\n // when the height of any option could have changed:\n // 1: because the component got resized (width property got updated)\n // 2: becasue the option changed its content (highlightText property controls the highlight and the visibility of hidden tags)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n estimateSize: useCallback(() => 31, [width, highlightText]),\n overscan: 5,\n });\n\n useEffect(() => {\n if (!usingMouse.current) {\n rowVirtualizer.scrollToIndex(highlightedIndex);\n }\n }, [usingMouse, rowVirtualizer, highlightedIndex]);\n\n return (\n <OptionsList\n {...menuProps}\n onLoadMore={handleLoadMore}\n ref={scrollRef}\n open={true}\n // to prevent closing the list when clicking the scrollbar on IE11\n nativeAttributes={{ unselectable: 'on' }}\n >\n <div\n aria-hidden=\"true\"\n key=\"total-size\"\n className={styles['layout-strut']}\n style={{ height: rowVirtualizer.totalSize + (filteredItems.length === 1 ? 1 : 0) }}\n />\n {rowVirtualizer.virtualItems.map(virtualRow => {\n const { index, start, measureRef } = virtualRow;\n const item = filteredItems[index];\n const optionProps = getOptionProps(\n index,\n item,\n filteredItems,\n highlightedA11yProps,\n highlightedOption,\n hasDropdownStatus\n );\n\n return (\n <AutosuggestOption\n key={index}\n ref={measureRef}\n highlightText={highlightText}\n option={item}\n highlighted={item === highlightedOption}\n data-mouse-target={index}\n enteredTextLabel={enteredTextLabel}\n virtualPosition={start + (index === 0 ? 1 : 0)}\n screenReaderContent={screenReaderContent}\n ariaSetsize={filteredItems.length}\n ariaPosinset={index + 1}\n {...optionProps}\n />\n );\n })}\n {listBottom ? (\n <li role=\"option\" className={styles['list-bottom']}>\n {listBottom}\n </li>\n ) : null}\n </OptionsList>\n );\n};\n\nexport default VirtualList;\n"]}
@@ -106,7 +106,6 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
106
106
  font-stretch: normal;
107
107
  line-height: normal;
108
108
  -webkit-hyphens: none;
109
- -ms-hyphens: none;
110
109
  hyphens: none;
111
110
  letter-spacing: normal;
112
111
  list-style: disc outside none;
@@ -106,7 +106,6 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
106
106
  font-stretch: normal;
107
107
  line-height: normal;
108
108
  -webkit-hyphens: none;
109
- -ms-hyphens: none;
110
109
  hyphens: none;
111
110
  letter-spacing: normal;
112
111
  list-style: disc outside none;
@@ -150,7 +149,6 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
150
149
  font-stretch: normal;
151
150
  line-height: normal;
152
151
  -webkit-hyphens: none;
153
- -ms-hyphens: none;
154
152
  hyphens: none;
155
153
  letter-spacing: normal;
156
154
  list-style: disc outside none;
@@ -114,7 +114,6 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
114
114
  font-stretch: normal;
115
115
  line-height: normal;
116
116
  -webkit-hyphens: none;
117
- -ms-hyphens: none;
118
117
  hyphens: none;
119
118
  letter-spacing: normal;
120
119
  list-style: disc outside none;
@@ -106,7 +106,6 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
106
106
  font-stretch: normal;
107
107
  line-height: normal;
108
108
  -webkit-hyphens: none;
109
- -ms-hyphens: none;
110
109
  hyphens: none;
111
110
  letter-spacing: normal;
112
111
  list-style: disc outside none;
@@ -140,7 +139,6 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
140
139
  .awsui_root_14cnr_zbvdk_93 > .awsui_dropdown_14cnr_zbvdk_109:not(#\9) {
141
140
  position: static;
142
141
  -webkit-user-select: none;
143
- -ms-user-select: none;
144
142
  user-select: none;
145
143
  background-color: #ffffff;
146
144
  background-color: var(--color-background-dropdown-item-default-fzdqsg, #ffffff);