@cloudscape-design/components 3.0.29 → 3.0.30
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.
- package/app-layout/visual-refresh/styles.css.js +59 -59
- package/app-layout/visual-refresh/styles.scoped.css +146 -146
- package/app-layout/visual-refresh/styles.selectors.js +59 -59
- package/autosuggest/controller.d.ts +1 -4
- package/autosuggest/controller.d.ts.map +1 -1
- package/autosuggest/controller.js +1 -45
- package/autosuggest/controller.js.map +1 -1
- package/autosuggest/internal.d.ts.map +1 -1
- package/autosuggest/internal.js +16 -23
- package/autosuggest/internal.js.map +1 -1
- package/autosuggest/options-controller.d.ts +22 -0
- package/autosuggest/options-controller.d.ts.map +1 -0
- package/autosuggest/options-controller.js +63 -0
- package/autosuggest/options-controller.js.map +1 -0
- package/autosuggest/options-list.d.ts.map +1 -1
- package/autosuggest/options-list.js +2 -1
- package/autosuggest/options-list.js.map +1 -1
- package/button-dropdown/category-elements/category-element.d.ts +1 -1
- package/button-dropdown/category-elements/category-element.d.ts.map +1 -1
- package/button-dropdown/category-elements/category-element.js +2 -2
- package/button-dropdown/category-elements/category-element.js.map +1 -1
- package/button-dropdown/category-elements/expandable-category-element.d.ts +1 -1
- package/button-dropdown/category-elements/expandable-category-element.d.ts.map +1 -1
- package/button-dropdown/category-elements/expandable-category-element.js +4 -2
- package/button-dropdown/category-elements/expandable-category-element.js.map +1 -1
- package/button-dropdown/category-elements/mobile-expandable-category-element.d.ts +1 -1
- package/button-dropdown/category-elements/mobile-expandable-category-element.d.ts.map +1 -1
- package/button-dropdown/category-elements/mobile-expandable-category-element.js +4 -2
- package/button-dropdown/category-elements/mobile-expandable-category-element.js.map +1 -1
- package/button-dropdown/category-elements/styles.css.js +13 -12
- package/button-dropdown/category-elements/styles.scoped.css +26 -22
- package/button-dropdown/category-elements/styles.selectors.js +13 -12
- package/button-dropdown/interfaces.d.ts +2 -0
- package/button-dropdown/interfaces.d.ts.map +1 -1
- package/button-dropdown/interfaces.js.map +1 -1
- package/button-dropdown/internal.d.ts.map +1 -1
- package/button-dropdown/internal.js +5 -10
- package/button-dropdown/internal.js.map +1 -1
- package/button-dropdown/item-element/index.d.ts +1 -1
- package/button-dropdown/item-element/index.d.ts.map +1 -1
- package/button-dropdown/item-element/index.js +2 -1
- package/button-dropdown/item-element/index.js.map +1 -1
- package/button-dropdown/item-element/styles.css.js +14 -13
- package/button-dropdown/item-element/styles.scoped.css +21 -17
- package/button-dropdown/item-element/styles.selectors.js +14 -13
- package/button-dropdown/items-list.d.ts +1 -1
- package/button-dropdown/items-list.d.ts.map +1 -1
- package/button-dropdown/items-list.js +4 -4
- package/button-dropdown/items-list.js.map +1 -1
- package/button-dropdown/utils/use-button-dropdown.d.ts +2 -2
- package/button-dropdown/utils/use-button-dropdown.d.ts.map +1 -1
- package/button-dropdown/utils/use-button-dropdown.js +7 -5
- package/button-dropdown/utils/use-button-dropdown.js.map +1 -1
- package/button-dropdown/utils/use-highlighted-menu.d.ts +1 -0
- package/button-dropdown/utils/use-highlighted-menu.d.ts.map +1 -1
- package/button-dropdown/utils/use-highlighted-menu.js +11 -3
- package/button-dropdown/utils/use-highlighted-menu.js.map +1 -1
- package/checkbox/styles.css.js +3 -3
- package/checkbox/styles.scoped.css +6 -6
- package/checkbox/styles.selectors.js +3 -3
- package/date-range-picker/dropdown.d.ts +1 -0
- package/date-range-picker/dropdown.d.ts.map +1 -1
- package/date-range-picker/dropdown.js +18 -30
- package/date-range-picker/dropdown.js.map +1 -1
- package/date-range-picker/embedded.d.ts +7 -0
- package/date-range-picker/embedded.d.ts.map +1 -0
- package/date-range-picker/embedded.js +46 -0
- package/date-range-picker/embedded.js.map +1 -0
- package/date-range-picker/index.d.ts.map +1 -1
- package/date-range-picker/index.js +2 -15
- package/date-range-picker/index.js.map +1 -1
- package/date-range-picker/interfaces.d.ts +46 -44
- package/date-range-picker/interfaces.d.ts.map +1 -1
- package/date-range-picker/interfaces.js.map +1 -1
- package/date-range-picker/use-date-range-picker.d.ts +29 -0
- package/date-range-picker/use-date-range-picker.d.ts.map +1 -0
- package/date-range-picker/use-date-range-picker.js +58 -0
- package/date-range-picker/use-date-range-picker.js.map +1 -0
- package/internal/components/abstract-switch/index.d.ts.map +1 -1
- package/internal/components/abstract-switch/index.js +5 -5
- package/internal/components/abstract-switch/index.js.map +1 -1
- package/internal/components/abstract-switch/styles.css.js +11 -11
- package/internal/components/abstract-switch/styles.scoped.css +20 -13
- package/internal/components/abstract-switch/styles.selectors.js +11 -11
- package/internal/environment.js +1 -1
- package/package.json +1 -1
- package/radio-group/styles.css.js +9 -9
- package/radio-group/styles.scoped.css +16 -16
- package/radio-group/styles.selectors.js +9 -9
- package/toggle/internal.d.ts.map +1 -1
- package/toggle/internal.js +3 -1
- package/toggle/internal.js.map +1 -1
- package/toggle/styles.css.js +8 -8
- package/toggle/styles.scoped.css +15 -14
- package/toggle/styles.selectors.js +8 -8
|
@@ -2,64 +2,64 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"appbar": "
|
|
6
|
-
"appbar-nav": "awsui_appbar-
|
|
7
|
-
"breadcrumbs": "
|
|
8
|
-
"appbar-tools": "awsui_appbar-
|
|
9
|
-
"has-breadcrumbs": "awsui_has-
|
|
10
|
-
"has-notifications-content": "awsui_has-notifications-
|
|
11
|
-
"has-header": "awsui_has-
|
|
12
|
-
"has-dynamic-overlap-height": "awsui_has-dynamic-overlap-
|
|
13
|
-
"content-type-wizard": "awsui_content-type-
|
|
14
|
-
"content-type-cards": "awsui_content-type-
|
|
15
|
-
"content-type-table": "awsui_content-type-
|
|
16
|
-
"background": "
|
|
17
|
-
"notifications-appbar-header": "awsui_notifications-appbar-
|
|
18
|
-
"sticky-notifications": "awsui_sticky-
|
|
19
|
-
"overlap": "
|
|
20
|
-
"content": "
|
|
21
|
-
"layout": "
|
|
22
|
-
"has-max-content-width": "awsui_has-max-content-
|
|
23
|
-
"is-overlap-disabled": "awsui_is-overlap-
|
|
24
|
-
"disable-body-scroll": "awsui_disable-body-
|
|
25
|
-
"has-sticky-notifications": "awsui_has-sticky-
|
|
26
|
-
"has-split-panel": "awsui_has-split-
|
|
27
|
-
"split-panel-position-bottom": "awsui_split-panel-position-
|
|
28
|
-
"has-content-gap-left": "awsui_has-content-gap-
|
|
29
|
-
"has-content-gap-right": "awsui_has-content-gap-
|
|
30
|
-
"block-body-scroll": "awsui_block-body-
|
|
31
|
-
"container": "
|
|
32
|
-
"disable-content-paddings": "awsui_disable-content-
|
|
33
|
-
"is-navigation-open": "awsui_is-navigation-
|
|
34
|
-
"is-tools-open": "awsui_is-tools-
|
|
35
|
-
"is-split-panel-open": "awsui_is-split-panel-
|
|
36
|
-
"split-panel-position-side": "awsui_split-panel-position-
|
|
37
|
-
"content-type-default": "awsui_content-type-
|
|
38
|
-
"content-type-form": "awsui_content-type-
|
|
39
|
-
"unfocusable": "
|
|
40
|
-
"navigation-container": "awsui_navigation-
|
|
41
|
-
"show-navigation": "awsui_show-
|
|
42
|
-
"animating": "
|
|
43
|
-
"showButtons": "
|
|
44
|
-
"navigation": "
|
|
45
|
-
"openNavigation": "
|
|
46
|
-
"animated-content": "awsui_animated-
|
|
47
|
-
"hide-navigation": "awsui_hide-
|
|
48
|
-
"notifications": "
|
|
49
|
-
"split-panel-bottom": "awsui_split-panel-
|
|
50
|
-
"position-bottom": "awsui_position-
|
|
51
|
-
"openSplitPanelBottom": "
|
|
52
|
-
"split-panel-side": "awsui_split-panel-
|
|
53
|
-
"position-side": "awsui_position-
|
|
54
|
-
"openSplitPanelSide": "
|
|
55
|
-
"tools-container": "awsui_tools-
|
|
56
|
-
"tools": "
|
|
57
|
-
"openTools": "
|
|
58
|
-
"has-tools-form-persistence": "awsui_has-tools-form-
|
|
59
|
-
"hide-tools": "awsui_hide-
|
|
60
|
-
"show-tools": "awsui_show-
|
|
61
|
-
"has-tools-form": "awsui_has-tools-
|
|
62
|
-
"trigger": "
|
|
63
|
-
"selected": "
|
|
5
|
+
"appbar": "awsui_appbar_hyvsj_zgnc1_93",
|
|
6
|
+
"appbar-nav": "awsui_appbar-nav_hyvsj_zgnc1_117",
|
|
7
|
+
"breadcrumbs": "awsui_breadcrumbs_hyvsj_zgnc1_121",
|
|
8
|
+
"appbar-tools": "awsui_appbar-tools_hyvsj_zgnc1_125",
|
|
9
|
+
"has-breadcrumbs": "awsui_has-breadcrumbs_hyvsj_zgnc1_160",
|
|
10
|
+
"has-notifications-content": "awsui_has-notifications-content_hyvsj_zgnc1_167",
|
|
11
|
+
"has-header": "awsui_has-header_hyvsj_zgnc1_173",
|
|
12
|
+
"has-dynamic-overlap-height": "awsui_has-dynamic-overlap-height_hyvsj_zgnc1_173",
|
|
13
|
+
"content-type-wizard": "awsui_content-type-wizard_hyvsj_zgnc1_174",
|
|
14
|
+
"content-type-cards": "awsui_content-type-cards_hyvsj_zgnc1_177",
|
|
15
|
+
"content-type-table": "awsui_content-type-table_hyvsj_zgnc1_178",
|
|
16
|
+
"background": "awsui_background_hyvsj_zgnc1_213",
|
|
17
|
+
"notifications-appbar-header": "awsui_notifications-appbar-header_hyvsj_zgnc1_216",
|
|
18
|
+
"sticky-notifications": "awsui_sticky-notifications_hyvsj_zgnc1_228",
|
|
19
|
+
"overlap": "awsui_overlap_hyvsj_zgnc1_234",
|
|
20
|
+
"content": "awsui_content_hyvsj_zgnc1_174",
|
|
21
|
+
"layout": "awsui_layout_hyvsj_zgnc1_322",
|
|
22
|
+
"has-max-content-width": "awsui_has-max-content-width_hyvsj_zgnc1_404",
|
|
23
|
+
"is-overlap-disabled": "awsui_is-overlap-disabled_hyvsj_zgnc1_431",
|
|
24
|
+
"disable-body-scroll": "awsui_disable-body-scroll_hyvsj_zgnc1_434",
|
|
25
|
+
"has-sticky-notifications": "awsui_has-sticky-notifications_hyvsj_zgnc1_438",
|
|
26
|
+
"has-split-panel": "awsui_has-split-panel_hyvsj_zgnc1_452",
|
|
27
|
+
"split-panel-position-bottom": "awsui_split-panel-position-bottom_hyvsj_zgnc1_452",
|
|
28
|
+
"has-content-gap-left": "awsui_has-content-gap-left_hyvsj_zgnc1_464",
|
|
29
|
+
"has-content-gap-right": "awsui_has-content-gap-right_hyvsj_zgnc1_467",
|
|
30
|
+
"block-body-scroll": "awsui_block-body-scroll_hyvsj_zgnc1_482",
|
|
31
|
+
"container": "awsui_container_hyvsj_zgnc1_490",
|
|
32
|
+
"disable-content-paddings": "awsui_disable-content-paddings_hyvsj_zgnc1_507",
|
|
33
|
+
"is-navigation-open": "awsui_is-navigation-open_hyvsj_zgnc1_512",
|
|
34
|
+
"is-tools-open": "awsui_is-tools-open_hyvsj_zgnc1_515",
|
|
35
|
+
"is-split-panel-open": "awsui_is-split-panel-open_hyvsj_zgnc1_515",
|
|
36
|
+
"split-panel-position-side": "awsui_split-panel-position-side_hyvsj_zgnc1_515",
|
|
37
|
+
"content-type-default": "awsui_content-type-default_hyvsj_zgnc1_535",
|
|
38
|
+
"content-type-form": "awsui_content-type-form_hyvsj_zgnc1_535",
|
|
39
|
+
"unfocusable": "awsui_unfocusable_hyvsj_zgnc1_576",
|
|
40
|
+
"navigation-container": "awsui_navigation-container_hyvsj_zgnc1_584",
|
|
41
|
+
"show-navigation": "awsui_show-navigation_hyvsj_zgnc1_608",
|
|
42
|
+
"animating": "awsui_animating_hyvsj_zgnc1_630",
|
|
43
|
+
"showButtons": "awsui_showButtons_hyvsj_zgnc1_1",
|
|
44
|
+
"navigation": "awsui_navigation_hyvsj_zgnc1_584",
|
|
45
|
+
"openNavigation": "awsui_openNavigation_hyvsj_zgnc1_1",
|
|
46
|
+
"animated-content": "awsui_animated-content_hyvsj_zgnc1_690",
|
|
47
|
+
"hide-navigation": "awsui_hide-navigation_hyvsj_zgnc1_699",
|
|
48
|
+
"notifications": "awsui_notifications_hyvsj_zgnc1_216",
|
|
49
|
+
"split-panel-bottom": "awsui_split-panel-bottom_hyvsj_zgnc1_766",
|
|
50
|
+
"position-bottom": "awsui_position-bottom_hyvsj_zgnc1_801",
|
|
51
|
+
"openSplitPanelBottom": "awsui_openSplitPanelBottom_hyvsj_zgnc1_1",
|
|
52
|
+
"split-panel-side": "awsui_split-panel-side_hyvsj_zgnc1_830",
|
|
53
|
+
"position-side": "awsui_position-side_hyvsj_zgnc1_857",
|
|
54
|
+
"openSplitPanelSide": "awsui_openSplitPanelSide_hyvsj_zgnc1_1",
|
|
55
|
+
"tools-container": "awsui_tools-container_hyvsj_zgnc1_894",
|
|
56
|
+
"tools": "awsui_tools_hyvsj_zgnc1_894",
|
|
57
|
+
"openTools": "awsui_openTools_hyvsj_zgnc1_1",
|
|
58
|
+
"has-tools-form-persistence": "awsui_has-tools-form-persistence_hyvsj_zgnc1_977",
|
|
59
|
+
"hide-tools": "awsui_hide-tools_hyvsj_zgnc1_987",
|
|
60
|
+
"show-tools": "awsui_show-tools_hyvsj_zgnc1_999",
|
|
61
|
+
"has-tools-form": "awsui_has-tools-form_hyvsj_zgnc1_977",
|
|
62
|
+
"trigger": "awsui_trigger_hyvsj_zgnc1_1056",
|
|
63
|
+
"selected": "awsui_selected_hyvsj_zgnc1_1094"
|
|
64
64
|
};
|
|
65
65
|
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { CancelableEventHandler, BaseKeyDetail } from '../internal/events';
|
|
2
|
-
import { AutosuggestItem
|
|
3
|
-
export declare const getParentGroup: (item: AutosuggestItem) => AutosuggestItem | undefined;
|
|
4
|
-
export declare const useAutosuggestItems: (options?: AutosuggestProps.Options) => AutosuggestItem[];
|
|
5
|
-
export declare const useFilteredItems: (autosuggestItems: AutosuggestItem[], value: string, filterText: string, filteringType: AutosuggestProps.FilteringType, showAll: boolean, __hideEnteredTextLabel?: boolean | undefined) => AutosuggestItem[];
|
|
2
|
+
import { AutosuggestItem } from './interfaces';
|
|
6
3
|
export declare const useSelectVisibleOption: (filteredItems: AutosuggestItem[], selectOption: (option: AutosuggestItem) => void, isInteractive: (option: AutosuggestItem) => boolean) => (index: number) => void;
|
|
7
4
|
export declare const useHighlightVisibleOption: (filteredItems: AutosuggestItem[], setHighlightedIndex: (index: number) => void, isHighlightable: (option: AutosuggestItem) => boolean) => (index: number) => void;
|
|
8
5
|
export declare const useKeyboardHandler: (moveHighlight: (direction: -1 | 1) => void, openDropdown: () => void, selectHighlighted: () => void, usingMouse: React.MutableRefObject<boolean>, open: boolean, onKeyDown?: CancelableEventHandler<BaseKeyDetail> | undefined) => (e: CustomEvent<BaseKeyDetail>) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/controller.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/controller.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAE3E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,eAAO,MAAM,sBAAsB,kBAClB,eAAe,EAAE,yBACT,eAAe,KAAK,IAAI,0BACvB,eAAe,KAAK,OAAO,aAGzC,MAAM,SAOf,CAAC;AAEJ,eAAO,MAAM,yBAAyB,kBACrB,eAAe,EAAE,+BACH,MAAM,KAAK,IAAI,4BAClB,eAAe,KAAK,OAAO,aAG3C,MAAM,SAOf,CAAC;AAEJ,eAAO,MAAM,kBAAkB,8BACF,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,gBAC5B,MAAM,IAAI,qBACL,MAAM,IAAI,cACjB,MAAM,gBAAgB,CAAC,OAAO,CAAC,QACrC,OAAO,wEAIP,YAAY,aAAa,CAAC,SA+BjC,CAAC"}
|
|
@@ -1,51 +1,7 @@
|
|
|
1
|
-
import { __assign, __rest, __spreadArray } from "tslib";
|
|
2
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
import { useCallback
|
|
5
|
-
import { filterOptions } from './utils/utils';
|
|
3
|
+
import { useCallback } from 'react';
|
|
6
4
|
import { KeyCode } from '../internal/keycode';
|
|
7
|
-
import { generateTestIndexes } from '../internal/components/options-list/utils/test-indexes';
|
|
8
|
-
var parentMap = new WeakMap();
|
|
9
|
-
export var getParentGroup = function (item) { return parentMap.get(item); };
|
|
10
|
-
export var useAutosuggestItems = function (options) {
|
|
11
|
-
if (options === void 0) { options = []; }
|
|
12
|
-
return useMemo(function () { return createItems(options); }, [options]);
|
|
13
|
-
};
|
|
14
|
-
function createItems(options) {
|
|
15
|
-
var items = [];
|
|
16
|
-
for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
|
|
17
|
-
var option = options_1[_i];
|
|
18
|
-
if (isGroup(option)) {
|
|
19
|
-
items.push.apply(items, flattenGroup(option));
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
items.push(__assign(__assign({}, option), { option: option }));
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return items;
|
|
26
|
-
}
|
|
27
|
-
function isGroup(optionOrGroup) {
|
|
28
|
-
return 'options' in optionOrGroup;
|
|
29
|
-
}
|
|
30
|
-
function flattenGroup(group) {
|
|
31
|
-
var options = group.options, rest = __rest(group, ["options"]);
|
|
32
|
-
var hasOnlyDisabledChildren = options.every(function (option) { return option.disabled; });
|
|
33
|
-
var parent = __assign(__assign({}, rest), { type: 'parent', disabled: rest.disabled || hasOnlyDisabledChildren, option: group });
|
|
34
|
-
var children = options.map(function (option) { return (__assign(__assign({}, option), { type: 'child', disabled: option.disabled || parent.disabled, option: option })); });
|
|
35
|
-
// TODO: Refactor parentMap and remove this side effect
|
|
36
|
-
children.forEach(function (child) { return parentMap.set(child, __assign(__assign({}, group), { option: group })); });
|
|
37
|
-
return [parent].concat(children);
|
|
38
|
-
}
|
|
39
|
-
export var useFilteredItems = function (autosuggestItems, value, filterText, filteringType, showAll, __hideEnteredTextLabel) {
|
|
40
|
-
return useMemo(function () {
|
|
41
|
-
var filteredItems = filteringType === 'auto' && !showAll ? filterOptions(autosuggestItems, filterText) : __spreadArray([], autosuggestItems, true);
|
|
42
|
-
if (value && !__hideEnteredTextLabel) {
|
|
43
|
-
filteredItems.unshift({ value: value, type: 'use-entered', option: { value: value } });
|
|
44
|
-
}
|
|
45
|
-
generateTestIndexes(filteredItems, getParentGroup);
|
|
46
|
-
return filteredItems;
|
|
47
|
-
}, [autosuggestItems, value, filterText, filteringType, showAll, __hideEnteredTextLabel]);
|
|
48
|
-
};
|
|
49
5
|
export var useSelectVisibleOption = function (filteredItems, selectOption, isInteractive) {
|
|
50
6
|
return useCallback(function (index) {
|
|
51
7
|
var option = filteredItems[index];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/autosuggest/controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/autosuggest/controller.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,MAAM,CAAC,IAAM,sBAAsB,GAAG,UACpC,aAAgC,EAChC,YAA+C,EAC/C,aAAmD;IAEnD,OAAA,WAAW,CACT,UAAC,KAAa;QACZ,IAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;QACpC,IAAI,MAAM,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE;YACnC,YAAY,CAAC,MAAM,CAAC,CAAC;SACtB;IACH,CAAC,EACD,CAAC,aAAa,EAAE,YAAY,EAAE,aAAa,CAAC,CAC7C;AARD,CAQC,CAAC;AAEJ,MAAM,CAAC,IAAM,yBAAyB,GAAG,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,EACD,CAAC,aAAa,EAAE,iBAAiB,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,CAAC,CAC9E,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useCallback } from 'react';\nimport { CancelableEventHandler, BaseKeyDetail } from '../internal/events';\nimport { KeyCode } from '../internal/keycode';\nimport { AutosuggestItem } from './interfaces';\n\nexport const useSelectVisibleOption = (\n filteredItems: AutosuggestItem[],\n selectOption: (option: AutosuggestItem) => void,\n isInteractive: (option: AutosuggestItem) => boolean\n) =>\n useCallback(\n (index: number) => {\n const option = filteredItems[index];\n if (option && isInteractive(option)) {\n selectOption(option);\n }\n },\n [filteredItems, selectOption, isInteractive]\n );\n\nexport const useHighlightVisibleOption = (\n filteredItems: AutosuggestItem[],\n setHighlightedIndex: (index: number) => void,\n isHighlightable: (option: AutosuggestItem) => boolean\n) =>\n useCallback(\n (index: number) => {\n const option = filteredItems[index];\n if (option && isHighlightable(option)) {\n setHighlightedIndex(index);\n }\n },\n [filteredItems, setHighlightedIndex, isHighlightable]\n );\n\nexport const useKeyboardHandler = (\n moveHighlight: (direction: -1 | 1) => void,\n openDropdown: () => void,\n selectHighlighted: () => void,\n usingMouse: React.MutableRefObject<boolean>,\n open: boolean,\n onKeyDown?: CancelableEventHandler<BaseKeyDetail>\n) => {\n return useCallback(\n (e: CustomEvent<BaseKeyDetail>) => {\n switch (e.detail.keyCode) {\n case KeyCode.down: {\n moveHighlight(1);\n openDropdown();\n usingMouse.current = false;\n e.preventDefault();\n break;\n }\n case KeyCode.up: {\n moveHighlight(-1);\n openDropdown();\n usingMouse.current = false;\n e.preventDefault();\n break;\n }\n case KeyCode.enter: {\n if (open) {\n selectHighlighted();\n e.preventDefault();\n }\n onKeyDown && onKeyDown(e);\n break;\n }\n default: {\n onKeyDown && onKeyDown(e);\n }\n }\n },\n [moveHighlight, selectHighlighted, onKeyDown, usingMouse, open, openDropdown]\n );\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAIlE,OAAO,EAAmB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAUjE,OAAO,EAA0B,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEpF,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAKjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAGlF,MAAM,WAAW,wBAAyB,SAAQ,gBAAgB,EAAE,0BAA0B;IAC5F,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,sBAAsB,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAClE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,EAAE,sBAAsB,CAAC,IAAI,CAAC,CAAC;CACzC;AAuBD,QAAA,MAAM,mBAAmB,iGAoNvB,CAAC;AAEH,eAAe,mBAAmB,CAAC"}
|
package/autosuggest/internal.js
CHANGED
|
@@ -2,8 +2,9 @@ import { __assign, __rest } from "tslib";
|
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import clsx from 'clsx';
|
|
5
|
-
import React, { useCallback,
|
|
6
|
-
import {
|
|
5
|
+
import React, { useCallback, useRef, useState } from 'react';
|
|
6
|
+
import { useKeyboardHandler } from './controller';
|
|
7
|
+
import { useAutosuggestItems } from './options-controller';
|
|
7
8
|
import Dropdown from '../internal/components/dropdown';
|
|
8
9
|
import { useDropdownStatus } from '../internal/components/dropdown-status';
|
|
9
10
|
import DropdownFooter from '../internal/components/dropdown-footer';
|
|
@@ -12,7 +13,6 @@ import { getBaseProps } from '../internal/base-component';
|
|
|
12
13
|
import { generateUniqueId, useUniqueId } from '../internal/hooks/use-unique-id';
|
|
13
14
|
import useForwardFocus from '../internal/hooks/forward-focus';
|
|
14
15
|
import { fireNonCancelableEvent } from '../internal/events';
|
|
15
|
-
import { createHighlightedOptionHook } from '../internal/components/options-list/utils/use-highlight-option';
|
|
16
16
|
import InternalInput from '../input/internal';
|
|
17
17
|
import styles from './styles.css.js';
|
|
18
18
|
import { checkOptionValueField } from '../select/utils/check-option-value-field';
|
|
@@ -22,10 +22,6 @@ import AutosuggestOptionsList from './options-list';
|
|
|
22
22
|
var isInteractive = function (option) {
|
|
23
23
|
return !!option && !option.disabled && option.type !== 'parent';
|
|
24
24
|
};
|
|
25
|
-
var isHighlightable = function (option) {
|
|
26
|
-
return !!option && option.type !== 'parent';
|
|
27
|
-
};
|
|
28
|
-
var useHighlightedOption = createHighlightedOptionHook({ isHighlightable: isHighlightable });
|
|
29
25
|
var useLoadMoreItems = function (onLoadItems) {
|
|
30
26
|
var lastFilteringText = useRef(null);
|
|
31
27
|
return useCallback(function (firstPage, samePage, filteringText) {
|
|
@@ -41,19 +37,20 @@ var useLoadMoreItems = function (onLoadItems) {
|
|
|
41
37
|
};
|
|
42
38
|
var InternalAutosuggest = React.forwardRef(function (props, ref) {
|
|
43
39
|
var _a;
|
|
44
|
-
var value = props.value, onChange = props.onChange, onBlur = props.onBlur, onFocus = props.onFocus, onKeyUp = props.onKeyUp, onLoadItems = props.onLoadItems, options = props.options, _b = props.filteringType, filteringType = _b === void 0 ? 'auto' : _b, _c = props.statusType, statusType = _c === void 0 ? 'finished' : _c, placeholder = props.placeholder, name = props.name, disabled = props.disabled, _d = props.disableBrowserAutocorrect, disableBrowserAutocorrect = _d === void 0 ? false : _d, autoFocus = props.autoFocus, readOnly = props.readOnly, ariaLabel = props.ariaLabel, ariaRequired = props.ariaRequired, enteredTextLabel = props.enteredTextLabel, onKeyDown = props.onKeyDown, virtualScroll = props.virtualScroll, expandToViewport = props.expandToViewport, onSelect = props.onSelect, selectedAriaLabel = props.selectedAriaLabel, renderHighlightedAriaLive = props.renderHighlightedAriaLive, __dropdownWidth = props.__dropdownWidth, __onOptionClick = props.__onOptionClick, __disableShowAll = props.__disableShowAll, __hideEnteredTextOption = props.__hideEnteredTextOption, __onOpen = props.__onOpen, __internalRootRef = props.__internalRootRef, rest = __rest(props, ["value", "onChange", "onBlur", "onFocus", "onKeyUp", "onLoadItems", "options", "filteringType", "statusType", "placeholder", "name", "disabled", "disableBrowserAutocorrect", "autoFocus", "readOnly", "ariaLabel", "ariaRequired", "enteredTextLabel", "onKeyDown", "virtualScroll", "expandToViewport", "onSelect", "selectedAriaLabel", "renderHighlightedAriaLive", "__dropdownWidth", "__onOptionClick", "__disableShowAll", "__hideEnteredTextOption", "__onOpen", "__internalRootRef"]);
|
|
45
|
-
var filterText =
|
|
46
|
-
filterText = filterText === undefined ? value : filterText;
|
|
40
|
+
var value = props.value, onChange = props.onChange, onBlur = props.onBlur, onFocus = props.onFocus, onKeyUp = props.onKeyUp, onLoadItems = props.onLoadItems, options = props.options, _b = props.filteringType, filteringType = _b === void 0 ? 'auto' : _b, _c = props.statusType, statusType = _c === void 0 ? 'finished' : _c, placeholder = props.placeholder, name = props.name, disabled = props.disabled, _d = props.disableBrowserAutocorrect, disableBrowserAutocorrect = _d === void 0 ? false : _d, autoFocus = props.autoFocus, readOnly = props.readOnly, ariaLabel = props.ariaLabel, ariaRequired = props.ariaRequired, enteredTextLabel = props.enteredTextLabel, onKeyDown = props.onKeyDown, virtualScroll = props.virtualScroll, expandToViewport = props.expandToViewport, onSelect = props.onSelect, selectedAriaLabel = props.selectedAriaLabel, renderHighlightedAriaLive = props.renderHighlightedAriaLive, __dropdownWidth = props.__dropdownWidth, __onOptionClick = props.__onOptionClick, __disableShowAll = props.__disableShowAll, __hideEnteredTextOption = props.__hideEnteredTextOption, __onOpen = props.__onOpen, __internalRootRef = props.__internalRootRef, __filterText = props.__filterText, rest = __rest(props, ["value", "onChange", "onBlur", "onFocus", "onKeyUp", "onLoadItems", "options", "filteringType", "statusType", "placeholder", "name", "disabled", "disableBrowserAutocorrect", "autoFocus", "readOnly", "ariaLabel", "ariaRequired", "enteredTextLabel", "onKeyDown", "virtualScroll", "expandToViewport", "onSelect", "selectedAriaLabel", "renderHighlightedAriaLive", "__dropdownWidth", "__onOptionClick", "__disableShowAll", "__hideEnteredTextOption", "__onOpen", "__internalRootRef", "__filterText"]);
|
|
41
|
+
var filterText = __filterText === undefined ? value : __filterText;
|
|
47
42
|
checkControlled('Autosuggest', 'value', value, 'onChange', onChange);
|
|
48
43
|
checkOptionValueField('Autosuggest', 'options', options);
|
|
49
44
|
var usingMouse = useRef(true);
|
|
50
|
-
var _e = useState(false),
|
|
51
|
-
var _f =
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
var _e = useState(false), open = _e[0], setOpen = _e[1];
|
|
46
|
+
var _f = useAutosuggestItems({
|
|
47
|
+
options: options || [],
|
|
48
|
+
filterValue: value,
|
|
49
|
+
filterText: filterText,
|
|
50
|
+
filteringType: filteringType,
|
|
51
|
+
hideEnteredTextLabel: __hideEnteredTextOption
|
|
52
|
+
}), items = _f.items, setShowAll = _f.setShowAll, highlightedOption = _f.highlightedOption, highlightedIndex = _f.highlightedIndex, moveHighlight = _f.moveHighlight, resetHighlight = _f.resetHighlight, setHighlightedIndex = _f.setHighlightedIndex;
|
|
54
53
|
var openDropdown = function () { return !readOnly && setOpen(true); };
|
|
55
|
-
var scrollToIndex = useRef(null);
|
|
56
|
-
var _g = useHighlightedOption(filteredItems), highlightedOption = _g.highlightedOption, highlightedIndex = _g.highlightedIndex, moveHighlight = _g.moveHighlight, resetHighlight = _g.resetHighlight, setHighlightedIndex = _g.setHighlightedIndex;
|
|
57
54
|
var closeDropdown = function () {
|
|
58
55
|
setOpen(false);
|
|
59
56
|
resetHighlight();
|
|
@@ -114,7 +111,7 @@ var InternalAutosuggest = React.forwardRef(function (props, ref) {
|
|
|
114
111
|
var dropdownId = useUniqueId('dropdown');
|
|
115
112
|
var listId = useUniqueId('list');
|
|
116
113
|
// From an a11y point of view we only count the dropdown as 'expanded' if there are items that a user can dropdown into
|
|
117
|
-
var expanded = open &&
|
|
114
|
+
var expanded = open && items.length > 1;
|
|
118
115
|
var highlightedOptionId = highlightedOption ? generateUniqueId() : undefined;
|
|
119
116
|
var nativeAttributes = {
|
|
120
117
|
name: name,
|
|
@@ -139,11 +136,7 @@ var InternalAutosuggest = React.forwardRef(function (props, ref) {
|
|
|
139
136
|
}
|
|
140
137
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
|
|
141
138
|
};
|
|
142
|
-
|
|
143
|
-
var _a;
|
|
144
|
-
(_a = scrollToIndex.current) === null || _a === void 0 ? void 0 : _a.call(scrollToIndex, highlightedIndex);
|
|
145
|
-
}, [highlightedIndex]);
|
|
146
|
-
var isEmpty = !value && !filteredItems.length;
|
|
139
|
+
var isEmpty = !value && !items.length;
|
|
147
140
|
var showRecoveryLink = open && statusType === 'error' && props.recoveryText;
|
|
148
141
|
var dropdownStatus = useDropdownStatus(__assign(__assign({}, props), { isEmpty: isEmpty, onRecoveryClick: handleRecoveryClick }));
|
|
149
142
|
var handleMouseDown = function (event) {
|
|
@@ -152,7 +145,7 @@ var InternalAutosuggest = React.forwardRef(function (props, ref) {
|
|
|
152
145
|
};
|
|
153
146
|
return (React.createElement("div", __assign({}, baseProps, { className: clsx(styles.root, baseProps.className), ref: __internalRootRef, onBlur: handleBlur }),
|
|
154
147
|
React.createElement(Dropdown, { minWidth: __dropdownWidth, stretchWidth: !__dropdownWidth, trigger: 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 })), onMouseDown: handleMouseDown, open: open, dropdownId: dropdownId, footer: dropdownStatus.isSticky ? (React.createElement("div", { ref: dropdownFooterRef, className: styles['dropdown-footer'] },
|
|
155
|
-
React.createElement(DropdownFooter, { content: dropdownStatus.content, hasItems:
|
|
148
|
+
React.createElement(DropdownFooter, { content: dropdownStatus.content, hasItems: items.length >= 1 }))) : null, expandToViewport: expandToViewport, hasContent: items.length >= 1 || dropdownStatus.content !== null, trapFocus: !!showRecoveryLink }, open && (React.createElement(AutosuggestOptionsList, { options: items, 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 })))));
|
|
156
149
|
});
|
|
157
150
|
export default InternalAutosuggest;
|
|
158
151
|
//# sourceMappingURL=internal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/autosuggest/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAO,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE7E,OAAO,EA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D,oBAAC,cAAc,IAAC,OAAO,EAAE,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa,CAAC,MAAM,IAAI,CAAC,GAAI,CACpF,CACP,CAAC,CAAC,CAAC,IAAI,EAEV,gBAAgB,EAAE,gBAAgB,EAClC,UAAU,EAAE,aAAa,CAAC,MAAM,IAAI,CAAC,IAAI,cAAc,CAAC,OAAO,KAAK,IAAI,EACxE,SAAS,EAAE,CAAC,CAAC,gBAAgB,IAE5B,IAAI,IAAI,CACP,oBAAC,sBAAsB,IACrB,OAAO,EAAE,aAAa,EACtB,iBAAiB,EAAE,iBAAiB,EACpC,YAAY,EAAE,YAAY,EAC1B,gBAAgB,EAAE,gBAAgB,EAClC,mBAAmB,EAAE,mBAAmB,EACxC,mBAAmB,EAAE,mBAAmB,EACxC,aAAa,EAAE,UAAU,EACzB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,gBAAgB,EAClC,cAAc,EAAE,cAAc,EAC9B,iBAAiB,EAAE,cAAc,CAAC,OAAO,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 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 <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 }\n onMouseDown={handleMouseDown}\n open={open}\n dropdownId={dropdownId}\n footer={\n dropdownStatus.isSticky ? (\n <div ref={dropdownFooterRef} className={styles['dropdown-footer']}>\n <DropdownFooter content={dropdownStatus.content} hasItems={filteredItems.length >= 1} />\n </div>\n ) : null\n }\n expandToViewport={expandToViewport}\n hasContent={filteredItems.length >= 1 || dropdownStatus.content !== null}\n trapFocus={!!showRecoveryLink}\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"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/autosuggest/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAO,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAElE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,QAAQ,MAAM,iCAAiC,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,cAAc,MAAM,wCAAwC,CAAC;AAEpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAA0B,MAAM,oBAAoB,CAAC;AACpF,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAE9C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,eAAe,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,sBAAsB,MAAM,gBAAgB,CAAC;AAWpD,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,IA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CAAC,OAAO,KAAK,IAAI,EAChE,SAAS,EAAE,CAAC,CAAC,gBAAgB,IAE5B,IAAI,IAAI,CACP,oBAAC,sBAAsB,IACrB,OAAO,EAAE,KAAK,EACd,iBAAiB,EAAE,iBAAiB,EACpC,YAAY,EAAE,YAAY,EAC1B,gBAAgB,EAAE,gBAAgB,EAClC,mBAAmB,EAAE,mBAAmB,EACxC,mBAAmB,EAAE,mBAAmB,EACxC,aAAa,EAAE,UAAU,EACzB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,gBAAgB,EAClC,cAAc,EAAE,cAAc,EAC9B,iBAAiB,EAAE,cAAc,CAAC,OAAO,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, useRef, useState } from 'react';\n\nimport { useKeyboardHandler } from './controller';\nimport { useAutosuggestItems } from './options-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 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 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 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 __filterText,\n ...rest\n } = props;\n const 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 [open, setOpen] = useState(false);\n const { items, setShowAll, highlightedOption, highlightedIndex, moveHighlight, resetHighlight, setHighlightedIndex } =\n useAutosuggestItems({\n options: options || [],\n filterValue: value,\n filterText,\n filteringType,\n hideEnteredTextLabel: __hideEnteredTextOption,\n });\n const openDropdown = () => !readOnly && setOpen(true);\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 && items.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 const isEmpty = !value && !items.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 <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 }\n onMouseDown={handleMouseDown}\n open={open}\n dropdownId={dropdownId}\n footer={\n dropdownStatus.isSticky ? (\n <div ref={dropdownFooterRef} className={styles['dropdown-footer']}>\n <DropdownFooter content={dropdownStatus.content} hasItems={items.length >= 1} />\n </div>\n ) : null\n }\n expandToViewport={expandToViewport}\n hasContent={items.length >= 1 || dropdownStatus.content !== null}\n trapFocus={!!showRecoveryLink}\n >\n {open && (\n <AutosuggestOptionsList\n options={items}\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,22 @@
|
|
|
1
|
+
import { AutosuggestItem, AutosuggestProps } from './interfaces';
|
|
2
|
+
declare type Options = AutosuggestProps.Options;
|
|
3
|
+
export interface UseAutosuggestItemsProps {
|
|
4
|
+
options: Options;
|
|
5
|
+
filterValue: string;
|
|
6
|
+
filterText: string;
|
|
7
|
+
filteringType: AutosuggestProps.FilteringType;
|
|
8
|
+
hideEnteredTextLabel?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const getParentGroup: (item: AutosuggestItem) => AutosuggestItem | undefined;
|
|
11
|
+
export declare const useAutosuggestItems: ({ options, filterValue, filterText, filteringType, hideEnteredTextLabel, }: UseAutosuggestItemsProps) => {
|
|
12
|
+
showAll: boolean;
|
|
13
|
+
setShowAll: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
14
|
+
items: AutosuggestItem[];
|
|
15
|
+
highlightedIndex: number;
|
|
16
|
+
highlightedOption: AutosuggestItem | undefined;
|
|
17
|
+
setHighlightedIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
18
|
+
moveHighlight: (direction: 1 | -1) => void;
|
|
19
|
+
resetHighlight: () => void;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=options-controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options-controller.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/options-controller.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGjE,aAAK,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC;AAExC,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,gBAAgB,CAAC,aAAa,CAAC;IAC9C,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AASD,eAAO,MAAM,cAAc,SAAU,eAAe,gCAAwB,CAAC;AAE7E,eAAO,MAAM,mBAAmB,+EAM7B,wBAAwB;;;;;;;;;CA2B1B,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { __assign, __rest, __spreadArray } from "tslib";
|
|
4
|
+
import { useMemo, useState } from 'react';
|
|
5
|
+
import { filterOptions } from './utils/utils';
|
|
6
|
+
import { generateTestIndexes } from '../internal/components/options-list/utils/test-indexes';
|
|
7
|
+
import { createHighlightedOptionHook } from '../internal/components/options-list/utils/use-highlight-option';
|
|
8
|
+
var isHighlightable = function (option) {
|
|
9
|
+
return !!option && option.type !== 'parent';
|
|
10
|
+
};
|
|
11
|
+
var useHighlightedOption = createHighlightedOptionHook({ isHighlightable: isHighlightable });
|
|
12
|
+
var parentMap = new WeakMap();
|
|
13
|
+
export var getParentGroup = function (item) { return parentMap.get(item); };
|
|
14
|
+
export var useAutosuggestItems = function (_a) {
|
|
15
|
+
var options = _a.options, filterValue = _a.filterValue, filterText = _a.filterText, filteringType = _a.filteringType, hideEnteredTextLabel = _a.hideEnteredTextLabel;
|
|
16
|
+
var _b = useState(false), showAll = _b[0], setShowAll = _b[1];
|
|
17
|
+
var items = useMemo(function () { return createItems(options); }, [options]);
|
|
18
|
+
var filteredItems = useMemo(function () {
|
|
19
|
+
var filteredItems = filteringType === 'auto' && !showAll ? filterOptions(items, filterText) : __spreadArray([], items, true);
|
|
20
|
+
if (filterValue && !hideEnteredTextLabel) {
|
|
21
|
+
filteredItems.unshift({ value: filterValue, type: 'use-entered', option: { value: filterValue } });
|
|
22
|
+
}
|
|
23
|
+
generateTestIndexes(filteredItems, getParentGroup);
|
|
24
|
+
return filteredItems;
|
|
25
|
+
}, [items, filterValue, filterText, filteringType, showAll, hideEnteredTextLabel]);
|
|
26
|
+
var _c = useHighlightedOption(filteredItems), highlightedOption = _c.highlightedOption, highlightedIndex = _c.highlightedIndex, moveHighlight = _c.moveHighlight, resetHighlight = _c.resetHighlight, setHighlightedIndex = _c.setHighlightedIndex;
|
|
27
|
+
return {
|
|
28
|
+
showAll: showAll,
|
|
29
|
+
setShowAll: setShowAll,
|
|
30
|
+
items: filteredItems,
|
|
31
|
+
highlightedIndex: highlightedIndex,
|
|
32
|
+
highlightedOption: highlightedOption,
|
|
33
|
+
setHighlightedIndex: setHighlightedIndex,
|
|
34
|
+
moveHighlight: moveHighlight,
|
|
35
|
+
resetHighlight: resetHighlight
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
function createItems(options) {
|
|
39
|
+
var items = [];
|
|
40
|
+
for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
|
|
41
|
+
var option = options_1[_i];
|
|
42
|
+
if (isGroup(option)) {
|
|
43
|
+
items.push.apply(items, flattenGroup(option));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
items.push(__assign(__assign({}, option), { option: option }));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return items;
|
|
50
|
+
}
|
|
51
|
+
function isGroup(optionOrGroup) {
|
|
52
|
+
return 'options' in optionOrGroup;
|
|
53
|
+
}
|
|
54
|
+
function flattenGroup(group) {
|
|
55
|
+
var options = group.options, rest = __rest(group, ["options"]);
|
|
56
|
+
var hasOnlyDisabledChildren = options.every(function (option) { return option.disabled; });
|
|
57
|
+
var parent = __assign(__assign({}, rest), { type: 'parent', disabled: rest.disabled || hasOnlyDisabledChildren, option: group });
|
|
58
|
+
var children = options.map(function (option) { return (__assign(__assign({}, option), { type: 'child', disabled: option.disabled || parent.disabled, option: option })); });
|
|
59
|
+
// TODO: Refactor parentMap and remove this side effect
|
|
60
|
+
children.forEach(function (child) { return parentMap.set(child, __assign(__assign({}, group), { option: group })); });
|
|
61
|
+
return [parent].concat(children);
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=options-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options-controller.js","sourceRoot":"","sources":["../../../src/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,EAAE,2BAA2B,EAAE,MAAM,gEAAgE,CAAC;AAY7G,IAAM,eAAe,GAAG,UAAC,MAAwB;IAC/C,OAAO,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC9C,CAAC,CAAC;AAEF,IAAM,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,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,EAC5C,MAAM,QAAA,IACN,EALwD,CAKxD,CAAC,CAAC;IACJ,uDAAuD;IACvD,QAAQ,CAAC,OAAO,CAAC,UAAA,KAAK,IAAI,OAAA,SAAS,CAAC,GAAG,CAAC,KAAK,wBAAO,KAAK,KAAE,MAAM,EAAE,KAAK,IAAG,EAAjD,CAAiD,CAAC,CAAC;IAC7E,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACnC,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 { createHighlightedOptionHook } 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}\n\nconst isHighlightable = (option?: AutosuggestItem) => {\n return !!option && option.type !== 'parent';\n};\n\nconst useHighlightedOption = createHighlightedOptionHook({ isHighlightable: isHighlightable });\n\nconst parentMap = new WeakMap<AutosuggestItem, AutosuggestItem>();\nexport const getParentGroup = (item: AutosuggestItem) => parentMap.get(item);\n\nexport const useAutosuggestItems = ({\n options,\n filterValue,\n filterText,\n filteringType,\n hideEnteredTextLabel,\n}: UseAutosuggestItemsProps) => {\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 { highlightedOption, highlightedIndex, moveHighlight, resetHighlight, setHighlightedIndex } =\n useHighlightedOption(filteredItems);\n\n return {\n showAll,\n setShowAll,\n items: filteredItems,\n highlightedIndex,\n highlightedOption,\n setHighlightedIndex,\n moveHighlight,\n resetHighlight,\n };\n};\n\nfunction createItems(options: Options): AutosuggestItem[] {\n const items: AutosuggestItem[] = [];\n for (const option of options) {\n if (isGroup(option)) {\n items.push(...flattenGroup(option));\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 const hasOnlyDisabledChildren = options.every(option => option.disabled);\n const parent: AutosuggestItem = {\n ...rest,\n type: 'parent',\n disabled: rest.disabled || hasOnlyDisabledChildren,\n option: group,\n };\n const children: AutosuggestItem[] = options.map(option => ({\n ...option,\n type: 'child',\n disabled: option.disabled || parent.disabled,\n option,\n }));\n // TODO: Refactor parentMap and remove this side effect\n children.forEach(child => parentMap.set(child, { ...group, option: group }));\n return [parent].concat(children);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options-list.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/options-list.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"options-list.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/options-list.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,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"}
|
|
@@ -1,7 +1,8 @@
|
|
|
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 { useSelectVisibleOption, useHighlightVisibleOption
|
|
4
|
+
import { useSelectVisibleOption, useHighlightVisibleOption } from './controller';
|
|
5
|
+
import { getParentGroup } from './options-controller';
|
|
5
6
|
import VirtualList from './virtual-list';
|
|
6
7
|
import PlainList from './plain-list';
|
|
7
8
|
import { useAnnouncement } from '../select/utils/use-announcement';
|
|
@@ -1 +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,
|
|
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,MAAM,cAAc,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,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,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC9C,CAAC,CAAC;AAEF,IAAM,uBAAuB,GAC3B,UAAC,OAAgC,EAAE,UAA2C,IAAK,OAAA,UAAC,SAAiB;IACnG,4DAA4D;IAC5D,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;IAC1B,IAAI,SAAS,GAAG,CAAC,CAAC,EAAE;QAClB,OAAO,CAAC,SAAS,CAAC,CAAC;KACpB;AACH,CAAC,EANkF,CAMlF,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AAgB,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 } from './controller';\nimport { getParentGroup } from './options-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"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { CategoryProps } from '../interfaces';
|
|
2
|
-
declare const CategoryElement: ({ item, onItemActivate, onGroupToggle, targetItem, isHighlighted, isExpanded, highlightItem, disabled, variant, }: CategoryProps) => JSX.Element;
|
|
2
|
+
declare const CategoryElement: ({ item, onItemActivate, onGroupToggle, targetItem, isHighlighted, isKeyboardHighlight, isExpanded, highlightItem, disabled, variant, }: CategoryProps) => JSX.Element;
|
|
3
3
|
export default CategoryElement;
|
|
4
4
|
//# sourceMappingURL=category-element.d.ts.map
|