@cloudscape-design/components 3.0.29 → 3.0.32
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/index.d.ts.map +1 -1
- package/app-layout/index.js +6 -21
- package/app-layout/index.js.map +1 -1
- package/app-layout/notifications/index.d.ts.map +1 -1
- package/app-layout/notifications/index.js +5 -16
- package/app-layout/notifications/index.js.map +1 -1
- package/app-layout/notifications/styles.css.js +1 -1
- package/app-layout/notifications/styles.scoped.css +2 -1
- package/app-layout/notifications/styles.selectors.js +1 -1
- 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/autosuggest-option.d.ts +1 -0
- package/autosuggest/autosuggest-option.d.ts.map +1 -1
- package/autosuggest/autosuggest-option.js +2 -2
- package/autosuggest/autosuggest-option.js.map +1 -1
- package/autosuggest/controller.d.ts +2 -5
- package/autosuggest/controller.d.ts.map +1 -1
- package/autosuggest/controller.js +5 -49
- package/autosuggest/controller.js.map +1 -1
- package/autosuggest/internal.d.ts +0 -7
- package/autosuggest/internal.d.ts.map +1 -1
- package/autosuggest/internal.js +23 -40
- package/autosuggest/internal.js.map +1 -1
- package/autosuggest/options-controller.d.ts +25 -0
- package/autosuggest/options-controller.d.ts.map +1 -0
- package/autosuggest/options-controller.js +64 -0
- package/autosuggest/options-controller.js.map +1 -0
- package/autosuggest/options-list.d.ts +3 -2
- package/autosuggest/options-list.d.ts.map +1 -1
- package/autosuggest/options-list.js +8 -7
- package/autosuggest/options-list.js.map +1 -1
- package/autosuggest/plain-list.d.ts +2 -2
- package/autosuggest/plain-list.d.ts.map +1 -1
- package/autosuggest/plain-list.js +4 -4
- package/autosuggest/plain-list.js.map +1 -1
- package/autosuggest/virtual-list.d.ts +1 -1
- package/autosuggest/virtual-list.d.ts.map +1 -1
- package/autosuggest/virtual-list.js +4 -4
- package/autosuggest/virtual-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/components/options-list/utils/use-highlight-option.d.ts +7 -2
- package/internal/components/options-list/utils/use-highlight-option.d.ts.map +1 -1
- package/internal/components/options-list/utils/use-highlight-option.js +10 -3
- package/internal/components/options-list/utils/use-highlight-option.js.map +1 -1
- package/internal/components/selectable-item/index.d.ts +1 -1
- package/internal/components/selectable-item/index.d.ts.map +1 -1
- package/internal/components/selectable-item/index.js +2 -2
- package/internal/components/selectable-item/index.js.map +1 -1
- package/internal/components/selectable-item/styles.css.js +16 -16
- package/internal/components/selectable-item/styles.scoped.css +29 -30
- package/internal/components/selectable-item/styles.selectors.js +16 -16
- package/internal/environment.js +1 -1
- package/multiselect/internal.d.ts.map +1 -1
- package/multiselect/internal.js +2 -2
- package/multiselect/internal.js.map +1 -1
- package/package.json +1 -1
- package/property-filter/controller.d.ts +2 -2
- package/property-filter/controller.js +3 -3
- package/property-filter/controller.js.map +1 -1
- package/property-filter/index.d.ts.map +1 -1
- package/property-filter/index.js +3 -3
- package/property-filter/index.js.map +1 -1
- package/property-filter/property-filter-autosuggest.d.ts +14 -0
- package/property-filter/property-filter-autosuggest.d.ts.map +1 -0
- package/property-filter/property-filter-autosuggest.js +143 -0
- package/property-filter/property-filter-autosuggest.js.map +1 -0
- 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/select/internal.d.ts.map +1 -1
- package/select/internal.js +2 -2
- package/select/internal.js.map +1 -1
- package/select/parts/item.d.ts +1 -1
- package/select/parts/item.d.ts.map +1 -1
- package/select/parts/item.js +6 -3
- package/select/parts/item.js.map +1 -1
- package/select/parts/multiselect-item.d.ts +1 -1
- package/select/parts/multiselect-item.d.ts.map +1 -1
- package/select/parts/multiselect-item.js +2 -2
- package/select/parts/multiselect-item.js.map +1 -1
- package/select/parts/plain-list.d.ts +1 -1
- package/select/parts/plain-list.d.ts.map +1 -1
- package/select/parts/plain-list.js +4 -4
- package/select/parts/plain-list.js.map +1 -1
- package/select/parts/styles.css.js +8 -7
- package/select/parts/styles.scoped.css +12 -7
- package/select/parts/styles.selectors.js +8 -7
- package/select/parts/virtual-list.js +4 -4
- package/select/parts/virtual-list.js.map +1 -1
- package/select/utils/get-item-props.d.ts +1 -2
- package/select/utils/get-item-props.d.ts.map +1 -1
- package/select/utils/get-item-props.js +3 -3
- package/select/utils/get-item-props.js.map +1 -1
- package/select/utils/render-options.d.ts +2 -2
- package/select/utils/render-options.d.ts.map +1 -1
- package/select/utils/render-options.js +2 -3
- package/select/utils/render-options.js.map +1 -1
- package/select/utils/use-select.d.ts +1 -0
- package/select/utils/use-select.d.ts.map +1 -1
- package/select/utils/use-select.js +2 -1
- package/select/utils/use-select.js.map +1 -1
- 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
- package/app-layout/dark-header/index.d.ts +0 -11
- package/app-layout/dark-header/index.d.ts.map +0 -1
- package/app-layout/dark-header/index.js +0 -10
- package/app-layout/dark-header/index.js.map +0 -1
- package/app-layout/dark-header/styles.css.js +0 -6
- package/app-layout/dark-header/styles.scoped.css +0 -13
- package/app-layout/dark-header/styles.selectors.js +0 -7
- package/app-layout/utils/use-sticky-position.d.ts +0 -2
- package/app-layout/utils/use-sticky-position.d.ts.map +0 -1
- package/app-layout/utils/use-sticky-position.js +0 -54
- package/app-layout/utils/use-sticky-position.js.map +0 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
2
|
+
import { AutosuggestItem, AutosuggestProps } from './interfaces';
|
|
3
|
+
declare type Options = AutosuggestProps.Options;
|
|
4
|
+
export interface UseAutosuggestItemsProps {
|
|
5
|
+
options: Options;
|
|
6
|
+
filterValue: string;
|
|
7
|
+
filterText: string;
|
|
8
|
+
filteringType: AutosuggestProps.FilteringType;
|
|
9
|
+
isKeyboard: MutableRefObject<boolean>;
|
|
10
|
+
hideEnteredTextLabel?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const getParentGroup: (item: AutosuggestItem) => AutosuggestItem | undefined;
|
|
13
|
+
export declare const useAutosuggestItems: ({ options, filterValue, filterText, filteringType, isKeyboard, hideEnteredTextLabel, }: UseAutosuggestItemsProps) => {
|
|
14
|
+
showAll: boolean;
|
|
15
|
+
setShowAll: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
16
|
+
items: AutosuggestItem[];
|
|
17
|
+
highlightedIndex: number;
|
|
18
|
+
highlightedType: "mouse" | "keyboard";
|
|
19
|
+
highlightedOption: AutosuggestItem | undefined;
|
|
20
|
+
setHighlightedIndex: (index: number) => void;
|
|
21
|
+
moveHighlight: (direction: 1 | -1) => void;
|
|
22
|
+
resetHighlight: () => void;
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
25
|
+
//# 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":"AAGA,OAAO,EAAqB,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAG5D,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,UAAU,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACtC,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AASD,eAAO,MAAM,cAAc,SAAU,eAAe,gCAAwB,CAAC;AAE7E,eAAO,MAAM,mBAAmB,2FAO7B,wBAAwB;;;;;;;;;;CA4B1B,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
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, isKeyboard = _a.isKeyboard, 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({ options: filteredItems, isKeyboard: isKeyboard }), highlightedOption = _c.highlightedOption, highlightedIndex = _c.highlightedIndex, highlightedType = _c.highlightedType, moveHighlight = _c.moveHighlight, resetHighlight = _c.resetHighlight, setHighlightedIndex = _c.setHighlightedIndex;
|
|
27
|
+
return {
|
|
28
|
+
showAll: showAll,
|
|
29
|
+
setShowAll: setShowAll,
|
|
30
|
+
items: filteredItems,
|
|
31
|
+
highlightedIndex: highlightedIndex,
|
|
32
|
+
highlightedType: highlightedType,
|
|
33
|
+
highlightedOption: highlightedOption,
|
|
34
|
+
setHighlightedIndex: setHighlightedIndex,
|
|
35
|
+
moveHighlight: moveHighlight,
|
|
36
|
+
resetHighlight: resetHighlight
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
function createItems(options) {
|
|
40
|
+
var items = [];
|
|
41
|
+
for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
|
|
42
|
+
var option = options_1[_i];
|
|
43
|
+
if (isGroup(option)) {
|
|
44
|
+
items.push.apply(items, flattenGroup(option));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
items.push(__assign(__assign({}, option), { option: option }));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return items;
|
|
51
|
+
}
|
|
52
|
+
function isGroup(optionOrGroup) {
|
|
53
|
+
return 'options' in optionOrGroup;
|
|
54
|
+
}
|
|
55
|
+
function flattenGroup(group) {
|
|
56
|
+
var options = group.options, rest = __rest(group, ["options"]);
|
|
57
|
+
var hasOnlyDisabledChildren = options.every(function (option) { return option.disabled; });
|
|
58
|
+
var parent = __assign(__assign({}, rest), { type: 'parent', disabled: rest.disabled || hasOnlyDisabledChildren, option: group });
|
|
59
|
+
var children = options.map(function (option) { return (__assign(__assign({}, option), { type: 'child', disabled: option.disabled || parent.disabled, option: option })); });
|
|
60
|
+
// TODO: Refactor parentMap and remove this side effect
|
|
61
|
+
children.forEach(function (child) { return parentMap.set(child, __assign(__assign({}, group), { option: group })); });
|
|
62
|
+
return [parent].concat(children);
|
|
63
|
+
}
|
|
64
|
+
//# 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,EAAoB,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,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AAuB,GAAG,OAAO,CAAC,KAAK,CAAC,UAAA,MAAM,IAAI,OAAA,MAAM,CAAC,QAAQ,EAAf,CAAe,CAAC,CAAC;IACzE,IAAM,MAAM,yBACP,IAAI,KACP,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,uBAAuB,EAClD,MAAM,EAAE,KAAK,GACd,CAAC;IACF,IAAM,QAAQ,GAAsB,OAAO,CAAC,GAAG,CAAC,UAAA,MAAM,IAAI,OAAA,uBACrD,MAAM,KACT,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, MutableRefObject } 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 isKeyboard: MutableRefObject<boolean>;\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 isKeyboard,\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, highlightedType, moveHighlight, resetHighlight, setHighlightedIndex } =\n useHighlightedOption({ options: filteredItems, isKeyboard });\n\n return {\n showAll,\n setShowAll,\n items: filteredItems,\n highlightedIndex,\n highlightedType,\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"]}
|
|
@@ -13,7 +13,8 @@ export interface AutosuggestOptionsListProps extends Pick<AutosuggestProps, 'ent
|
|
|
13
13
|
handleLoadMore: () => void;
|
|
14
14
|
hasDropdownStatus?: boolean;
|
|
15
15
|
listBottom?: React.ReactNode;
|
|
16
|
-
|
|
16
|
+
isKeyboard: React.MutableRefObject<boolean>;
|
|
17
|
+
highlightedType: 'mouse' | 'keyboard';
|
|
17
18
|
}
|
|
18
|
-
export default function AutosuggestOptionsList({ options, highlightedOption, selectOption, highlightedIndex, setHighlightedIndex, highlightedOptionId, highlightText, listId, controlId, enteredTextLabel, handleLoadMore, hasDropdownStatus, virtualScroll, selectedAriaLabel, renderHighlightedAriaLive, listBottom,
|
|
19
|
+
export default function AutosuggestOptionsList({ options, highlightedOption, selectOption, highlightedIndex, setHighlightedIndex, highlightedOptionId, highlightText, listId, controlId, enteredTextLabel, handleLoadMore, hasDropdownStatus, virtualScroll, selectedAriaLabel, renderHighlightedAriaLive, listBottom, isKeyboard, highlightedType, }: AutosuggestOptionsListProps): JSX.Element;
|
|
19
20
|
//# sourceMappingURL=options-list.d.ts.map
|
|
@@ -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;IAC5C,eAAe,EAAE,OAAO,GAAG,UAAU,CAAC;CACvC;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,EACV,eAAe,GAChB,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';
|
|
@@ -11,19 +12,19 @@ var isInteractive = function (option) {
|
|
|
11
12
|
var isHighlightable = function (option) {
|
|
12
13
|
return !!option && option.type !== 'parent';
|
|
13
14
|
};
|
|
14
|
-
var createMouseEventHandler = function (handler,
|
|
15
|
+
var createMouseEventHandler = function (handler, isKeyboard) { return function (itemIndex) {
|
|
15
16
|
// prevent mouse events to avoid losing focus from the input
|
|
16
|
-
|
|
17
|
+
isKeyboard.current = false;
|
|
17
18
|
if (itemIndex > -1) {
|
|
18
19
|
handler(itemIndex);
|
|
19
20
|
}
|
|
20
21
|
}; };
|
|
21
22
|
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,
|
|
23
|
+
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, isKeyboard = _a.isKeyboard, highlightedType = _a.highlightedType;
|
|
23
24
|
var highlightVisibleOption = useHighlightVisibleOption(options, setHighlightedIndex, isHighlightable);
|
|
24
25
|
var selectVisibleOption = useSelectVisibleOption(options, selectOption, isInteractive);
|
|
25
|
-
var handleMouseUp = createMouseEventHandler(selectVisibleOption,
|
|
26
|
-
var handleMouseMove = createMouseEventHandler(highlightVisibleOption,
|
|
26
|
+
var handleMouseUp = createMouseEventHandler(selectVisibleOption, isKeyboard);
|
|
27
|
+
var handleMouseMove = createMouseEventHandler(highlightVisibleOption, isKeyboard);
|
|
27
28
|
var ListComponent = virtualScroll ? VirtualList : PlainList;
|
|
28
29
|
var announcement = useAnnouncement({
|
|
29
30
|
announceSelected: true,
|
|
@@ -32,6 +33,6 @@ export default function AutosuggestOptionsList(_a) {
|
|
|
32
33
|
selectedAriaLabel: selectedAriaLabel,
|
|
33
34
|
renderHighlightedAriaLive: renderHighlightedAriaLive
|
|
34
35
|
});
|
|
35
|
-
return (React.createElement(ListComponent, { listBottom: listBottom, handleLoadMore: handleLoadMore, filteredItems: options, highlightText: highlightText,
|
|
36
|
+
return (React.createElement(ListComponent, { listBottom: listBottom, handleLoadMore: handleLoadMore, filteredItems: options, highlightText: highlightText, highlightedOption: highlightedOption, highlightedIndex: highlightedIndex, enteredTextLabel: enteredTextLabel, highlightedA11yProps: highlightedOptionId ? { id: highlightedOptionId } : {}, hasDropdownStatus: hasDropdownStatus, menuProps: { id: listId, ariaLabelledby: controlId, onMouseUp: handleMouseUp, onMouseMove: handleMouseMove }, screenReaderContent: announcement, highlightedType: highlightedType }));
|
|
36
37
|
}
|
|
37
38
|
//# sourceMappingURL=options-list.js.map
|
|
@@ -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,sCA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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 isKeyboard: React.MutableRefObject<boolean>;\n highlightedType: 'mouse' | 'keyboard';\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, isKeyboard: React.MutableRefObject<boolean>) => (itemIndex: number) => {\n // prevent mouse events to avoid losing focus from the input\n isKeyboard.current = false;\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 isKeyboard,\n highlightedType,\n}: AutosuggestOptionsListProps) {\n const highlightVisibleOption = useHighlightVisibleOption(options, setHighlightedIndex, isHighlightable);\n const selectVisibleOption = useSelectVisibleOption(options, selectOption, isInteractive);\n const handleMouseUp = createMouseEventHandler(selectVisibleOption, isKeyboard);\n const handleMouseMove = createMouseEventHandler(highlightVisibleOption, isKeyboard);\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 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 highlightedType={highlightedType}\n />\n );\n}\n"]}
|
|
@@ -5,9 +5,9 @@ export interface ListProps {
|
|
|
5
5
|
menuProps: Omit<OptionsListProps, 'children'>;
|
|
6
6
|
handleLoadMore: () => void;
|
|
7
7
|
filteredItems: AutosuggestItem[];
|
|
8
|
-
usingMouse: React.MutableRefObject<boolean>;
|
|
9
8
|
highlightedOption?: AutosuggestItem;
|
|
10
9
|
highlightedIndex: number;
|
|
10
|
+
highlightedType: 'mouse' | 'keyboard';
|
|
11
11
|
enteredTextLabel: AutosuggestProps.EnteredTextLabel;
|
|
12
12
|
highlightedA11yProps: Record<string, string | number | boolean>;
|
|
13
13
|
hasDropdownStatus?: boolean;
|
|
@@ -21,6 +21,6 @@ export declare const getOptionProps: (index: number, item: AutosuggestItem, filt
|
|
|
21
21
|
nativeAttributes: Record<string, string | number | boolean>;
|
|
22
22
|
padBottom: boolean;
|
|
23
23
|
};
|
|
24
|
-
declare const PlainList: ({ handleLoadMore, filteredItems,
|
|
24
|
+
declare const PlainList: ({ handleLoadMore, filteredItems, menuProps, highlightedOption, highlightedIndex, highlightedType, enteredTextLabel, highlightedA11yProps, hasDropdownStatus, highlightText, listBottom, screenReaderContent, }: ListProps) => JSX.Element;
|
|
25
25
|
export default PlainList;
|
|
26
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,KAA4B,MAAM,OAAO,CAAC;AAEjD,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,UAAU,CAAC,CAAC;IAC9C,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,aAAa,EAAE,eAAe,EAAE,CAAC;IACjC,
|
|
1
|
+
{"version":3,"file":"plain-list.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/plain-list.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,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,UAAU,CAAC,CAAC;IAC9C,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,aAAa,EAAE,eAAe,EAAE,CAAC;IACjC,iBAAiB,CAAC,EAAE,eAAe,CAAC;IACpC,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,OAAO,GAAG,UAAU,CAAC;IACtC,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,mNAaZ,SAAS,gBAiDX,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -16,21 +16,21 @@ export var getOptionProps = function (index, item, filteredItems, highlightedA11
|
|
|
16
16
|
return __assign({ nativeAttributes: nativeAttributes, padBottom: padBottom }, baseOptionProps);
|
|
17
17
|
};
|
|
18
18
|
var PlainList = function (_a) {
|
|
19
|
-
var handleLoadMore = _a.handleLoadMore, filteredItems = _a.filteredItems,
|
|
19
|
+
var handleLoadMore = _a.handleLoadMore, filteredItems = _a.filteredItems, menuProps = _a.menuProps, highlightedOption = _a.highlightedOption, highlightedIndex = _a.highlightedIndex, highlightedType = _a.highlightedType, 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
21
|
useEffect(function () {
|
|
22
22
|
var _a;
|
|
23
23
|
var item = (_a = listRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("[data-mouse-target=\"".concat(highlightedIndex, "\"]"));
|
|
24
|
-
if (
|
|
24
|
+
if (highlightedType === 'keyboard' && item) {
|
|
25
25
|
scrollUntilVisible(item);
|
|
26
26
|
}
|
|
27
|
-
}, [
|
|
27
|
+
}, [highlightedType, 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' } }),
|
|
31
31
|
filteredItems.map(function (item, index) {
|
|
32
32
|
var optionProps = getOptionProps(index, item, filteredItems, highlightedA11yProps, highlightedOption, hasDropdownStatus);
|
|
33
|
-
return (React.createElement(AutosuggestOption, __assign({ highlightText: highlightText, option: item, highlighted: item === highlightedOption, key: index, "data-mouse-target": index, enteredTextLabel: enteredTextLabel, screenReaderContent: screenReaderContent }, optionProps)));
|
|
33
|
+
return (React.createElement(AutosuggestOption, __assign({ highlightText: highlightText, option: item, highlighted: item === highlightedOption, key: index, "data-mouse-target": index, enteredTextLabel: enteredTextLabel, screenReaderContent: screenReaderContent, highlightedType: highlightedType }, optionProps)));
|
|
34
34
|
}),
|
|
35
35
|
listBottom ? (React.createElement("li", { role: "option", className: styles['list-bottom'] }, listBottom)) : null));
|
|
36
36
|
};
|
|
@@ -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,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,K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AC,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,EACxC,eAAe,EAAE,eAAe,IAC5B,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 highlightedOption?: AutosuggestItem;\n highlightedIndex: number;\n highlightedType: 'mouse' | 'keyboard';\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 menuProps,\n highlightedOption,\n highlightedIndex,\n highlightedType,\n enteredTextLabel,\n highlightedA11yProps,\n hasDropdownStatus,\n highlightText,\n listBottom,\n screenReaderContent,\n}: ListProps) => {\n const listRef = useRef<HTMLUListElement>(null);\n useEffect(() => {\n const item = listRef.current?.querySelector(`[data-mouse-target=\"${highlightedIndex}\"]`);\n if (highlightedType === 'keyboard' && item) {\n scrollUntilVisible(item as HTMLElement);\n }\n }, [highlightedType, 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 highlightedType={highlightedType}\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,4 +1,4 @@
|
|
|
1
1
|
import { ListProps } from './plain-list';
|
|
2
|
-
declare const VirtualList: ({ handleLoadMore, filteredItems,
|
|
2
|
+
declare const VirtualList: ({ handleLoadMore, filteredItems, menuProps, highlightedOption, highlightedIndex, highlightedType, enteredTextLabel, highlightedA11yProps, hasDropdownStatus, highlightText, listBottom, screenReaderContent, }: ListProps) => JSX.Element;
|
|
3
3
|
export default VirtualList;
|
|
4
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":"AASA,OAAO,EAAkB,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzD,QAAA,MAAM,WAAW,
|
|
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,mNAad,SAAS,gBA2EX,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -9,7 +9,7 @@ import AutosuggestOption from './autosuggest-option';
|
|
|
9
9
|
import { getOptionProps } from './plain-list';
|
|
10
10
|
import styles from './styles.css.js';
|
|
11
11
|
var VirtualList = function (_a) {
|
|
12
|
-
var handleLoadMore = _a.handleLoadMore, filteredItems = _a.filteredItems,
|
|
12
|
+
var handleLoadMore = _a.handleLoadMore, filteredItems = _a.filteredItems, menuProps = _a.menuProps, highlightedOption = _a.highlightedOption, highlightedIndex = _a.highlightedIndex, highlightedType = _a.highlightedType, 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];
|
|
@@ -26,10 +26,10 @@ var VirtualList = function (_a) {
|
|
|
26
26
|
overscan: 5
|
|
27
27
|
});
|
|
28
28
|
useEffect(function () {
|
|
29
|
-
if (
|
|
29
|
+
if (highlightedType === 'keyboard') {
|
|
30
30
|
rowVirtualizer.scrollToIndex(highlightedIndex);
|
|
31
31
|
}
|
|
32
|
-
}, [
|
|
32
|
+
}, [highlightedType, 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' } }),
|
|
@@ -38,7 +38,7 @@ var VirtualList = function (_a) {
|
|
|
38
38
|
var index = virtualRow.index, start = virtualRow.start, measureRef = virtualRow.measureRef;
|
|
39
39
|
var item = filteredItems[index];
|
|
40
40
|
var optionProps = getOptionProps(index, item, filteredItems, highlightedA11yProps, highlightedOption, hasDropdownStatus);
|
|
41
|
-
return (React.createElement(AutosuggestOption, __assign({ key: index, ref: measureRef, highlightText: highlightText, option: item, highlighted: item === highlightedOption, "data-mouse-target": index, enteredTextLabel: enteredTextLabel, virtualPosition: start + (index === 0 ? 1 : 0), screenReaderContent: screenReaderContent, ariaSetsize: filteredItems.length, ariaPosinset: index + 1 }, optionProps)));
|
|
41
|
+
return (React.createElement(AutosuggestOption, __assign({ key: index, ref: measureRef, highlightText: highlightText, option: item, highlighted: item === highlightedOption, "data-mouse-target": index, enteredTextLabel: enteredTextLabel, virtualPosition: start + (index === 0 ? 1 : 0), screenReaderContent: screenReaderContent, ariaSetsize: filteredItems.length, ariaPosinset: index + 1, highlightedType: highlightedType }, optionProps)));
|
|
42
42
|
}),
|
|
43
43
|
listBottom ? (React.createElement("li", { role: "option", className: styles['list-bottom'] }, listBottom)) : null));
|
|
44
44
|
};
|
|
@@ -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,WAAW,EAAE,SAAS,EAAE,mBAAmB,E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MAAlC,EAAE,KAAK,GAAiB,UAAU,MAA3B,EAAE,UAAU,GAAK,UAAU,WAAf,CAAgB;YAChD,IAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;YAClC,IAAM,WAAW,GAAG,cAAc,CAChC,KAAK,EACL,IAAI,EACJ,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,CAClB,CAAC;YAEF,OAAO,CACL,oBAAC,iBAAiB,aAChB,GAAG,EAAE,KAAK,EACV,GAAG,EAAE,UAAU,EACf,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,IAAI,EACZ,WAAW,EAAE,IAAI,KAAK,iBAAiB,uBACpB,KAAK,EACxB,gBAAgB,EAAE,gBAAgB,EAClC,eAAe,EAAE,KAAK,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC9C,mBAAmB,EAAE,mBAAmB,EACxC,WAAW,EAAE,aAAa,CAAC,MAAM,EACjC,YAAY,EAAE,KAAK,GAAG,CAAC,EACvB,eAAe,EAAE,eAAe,IAC5B,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,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 menuProps,\n highlightedOption,\n highlightedIndex,\n highlightedType,\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 (highlightedType === 'keyboard') {\n rowVirtualizer.scrollToIndex(highlightedIndex);\n }\n }, [highlightedType, 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 highlightedType={highlightedType}\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"]}
|
|
@@ -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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"category-element.d.ts","sourceRoot":"","sources":["../../../../src/button-dropdown/category-elements/category-element.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAM9C,QAAA,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"category-element.d.ts","sourceRoot":"","sources":["../../../../src/button-dropdown/category-elements/category-element.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAM9C,QAAA,MAAM,eAAe,2IAWlB,aAAa,gBAiCf,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -4,12 +4,12 @@ import styles from './styles.css.js';
|
|
|
4
4
|
import ItemsList from '../items-list';
|
|
5
5
|
var CategoryElement = function (_a) {
|
|
6
6
|
var _b;
|
|
7
|
-
var item = _a.item, onItemActivate = _a.onItemActivate, onGroupToggle = _a.onGroupToggle, targetItem = _a.targetItem, isHighlighted = _a.isHighlighted, isExpanded = _a.isExpanded, highlightItem = _a.highlightItem, disabled = _a.disabled, variant = _a.variant;
|
|
7
|
+
var item = _a.item, onItemActivate = _a.onItemActivate, onGroupToggle = _a.onGroupToggle, targetItem = _a.targetItem, isHighlighted = _a.isHighlighted, isKeyboardHighlight = _a.isKeyboardHighlight, isExpanded = _a.isExpanded, highlightItem = _a.highlightItem, disabled = _a.disabled, variant = _a.variant;
|
|
8
8
|
// Hide the category title element from screen readers because it will be
|
|
9
9
|
// provided as an ARIA label.
|
|
10
10
|
return (React.createElement("li", { className: clsx(styles.category, styles["variant-".concat(variant)], disabled && styles.disabled), role: "presentation", "aria-disabled": disabled ? 'true' : undefined },
|
|
11
11
|
item.text && (React.createElement("p", { className: clsx(styles.header, (_b = {}, _b[styles.disabled] = disabled, _b)), "aria-hidden": "true" }, item.text)),
|
|
12
|
-
React.createElement("ul", { className: clsx(styles['items-list-container']), role: "group", "aria-label": item.text }, item.items && (React.createElement(ItemsList, { items: item.items, onItemActivate: onItemActivate, onGroupToggle: onGroupToggle, targetItem: targetItem, isHighlighted: isHighlighted, isExpanded: isExpanded, highlightItem: highlightItem, categoryDisabled: disabled, hasCategoryHeader: !!item.text, variant: variant })))));
|
|
12
|
+
React.createElement("ul", { className: clsx(styles['items-list-container']), role: "group", "aria-label": item.text }, item.items && (React.createElement(ItemsList, { items: item.items, onItemActivate: onItemActivate, onGroupToggle: onGroupToggle, targetItem: targetItem, isHighlighted: isHighlighted, isKeyboardHighlight: isKeyboardHighlight, isExpanded: isExpanded, highlightItem: highlightItem, categoryDisabled: disabled, hasCategoryHeader: !!item.text, variant: variant })))));
|
|
13
13
|
};
|
|
14
14
|
export default CategoryElement;
|
|
15
15
|
//# sourceMappingURL=category-element.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"category-element.js","sourceRoot":"","sources":["../../../../src/button-dropdown/category-elements/category-element.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,SAAS,MAAM,eAAe,CAAC;AAEtC,IAAM,eAAe,GAAG,UAAC,
|
|
1
|
+
{"version":3,"file":"category-element.js","sourceRoot":"","sources":["../../../../src/button-dropdown/category-elements/category-element.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,SAAS,MAAM,eAAe,CAAC;AAEtC,IAAM,eAAe,GAAG,UAAC,EAWT;;QAVd,IAAI,UAAA,EACJ,cAAc,oBAAA,EACd,aAAa,mBAAA,EACb,UAAU,gBAAA,EACV,aAAa,mBAAA,EACb,mBAAmB,yBAAA,EACnB,UAAU,gBAAA,EACV,aAAa,mBAAA,EACb,QAAQ,cAAA,EACR,OAAO,aAAA;IAEP,yEAAyE;IACzE,6BAA6B;IAC7B,OAAO,CACL,4BACE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,kBAAW,OAAO,CAAE,CAAC,EAAE,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,EAC3F,IAAI,EAAC,cAAc,mBACJ,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;QAE3C,IAAI,CAAC,IAAI,IAAI,CACZ,2BAAG,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,YAAI,GAAC,MAAM,CAAC,QAAQ,IAAG,QAAQ,MAAG,iBAAc,MAAM,IACnF,IAAI,CAAC,IAAI,CACR,CACL;QACD,4BAAI,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,EAAE,IAAI,EAAC,OAAO,gBAAa,IAAI,CAAC,IAAI,IACpF,IAAI,CAAC,KAAK,IAAI,CACb,oBAAC,SAAS,IACR,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,EAC5B,mBAAmB,EAAE,mBAAmB,EACxC,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,QAAQ,EAC1B,iBAAiB,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAC9B,OAAO,EAAE,OAAO,GAChB,CACH,CACE,CACF,CACN,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { CategoryProps } from '../interfaces';\nimport React from 'react';\nimport clsx from 'clsx';\nimport styles from './styles.css.js';\nimport ItemsList from '../items-list';\n\nconst CategoryElement = ({\n item,\n onItemActivate,\n onGroupToggle,\n targetItem,\n isHighlighted,\n isKeyboardHighlight,\n isExpanded,\n highlightItem,\n disabled,\n variant,\n}: CategoryProps) => {\n // Hide the category title element from screen readers because it will be\n // provided as an ARIA label.\n return (\n <li\n className={clsx(styles.category, styles[`variant-${variant}`], disabled && styles.disabled)}\n role=\"presentation\"\n aria-disabled={disabled ? 'true' : undefined}\n >\n {item.text && (\n <p className={clsx(styles.header, { [styles.disabled]: disabled })} aria-hidden=\"true\">\n {item.text}\n </p>\n )}\n <ul className={clsx(styles['items-list-container'])} role=\"group\" aria-label={item.text}>\n {item.items && (\n <ItemsList\n items={item.items}\n onItemActivate={onItemActivate}\n onGroupToggle={onGroupToggle}\n targetItem={targetItem}\n isHighlighted={isHighlighted}\n isKeyboardHighlight={isKeyboardHighlight}\n isExpanded={isExpanded}\n highlightItem={highlightItem}\n categoryDisabled={disabled}\n hasCategoryHeader={!!item.text}\n variant={variant}\n />\n )}\n </ul>\n </li>\n );\n};\n\nexport default CategoryElement;\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { CategoryProps } from '../interfaces';
|
|
2
|
-
declare const ExpandableCategoryElement: ({ item, onItemActivate, onGroupToggle, targetItem, isHighlighted, isExpanded, highlightItem, disabled, expandToViewport, variant, }: CategoryProps) => JSX.Element;
|
|
2
|
+
declare const ExpandableCategoryElement: ({ item, onItemActivate, onGroupToggle, targetItem, isHighlighted, isKeyboardHighlight, isExpanded, highlightItem, disabled, expandToViewport, variant, }: CategoryProps) => JSX.Element;
|
|
3
3
|
export default ExpandableCategoryElement;
|
|
4
4
|
//# sourceMappingURL=expandable-category-element.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expandable-category-element.d.ts","sourceRoot":"","sources":["../../../../src/button-dropdown/category-elements/expandable-category-element.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAK9C,QAAA,MAAM,yBAAyB,
|
|
1
|
+
{"version":3,"file":"expandable-category-element.d.ts","sourceRoot":"","sources":["../../../../src/button-dropdown/category-elements/expandable-category-element.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAK9C,QAAA,MAAM,yBAAyB,6JAY5B,aAAa,gBA2Gf,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
|
|
@@ -12,9 +12,10 @@ import Tooltip from '../tooltip.js';
|
|
|
12
12
|
import { getMenuItemProps } from '../utils/menu-item';
|
|
13
13
|
var ExpandableCategoryElement = function (_a) {
|
|
14
14
|
var _b, _c;
|
|
15
|
-
var item = _a.item, onItemActivate = _a.onItemActivate, onGroupToggle = _a.onGroupToggle, targetItem = _a.targetItem, isHighlighted = _a.isHighlighted, isExpanded = _a.isExpanded, highlightItem = _a.highlightItem, disabled = _a.disabled, expandToViewport = _a.expandToViewport, variant = _a.variant;
|
|
15
|
+
var item = _a.item, onItemActivate = _a.onItemActivate, onGroupToggle = _a.onGroupToggle, targetItem = _a.targetItem, isHighlighted = _a.isHighlighted, isKeyboardHighlight = _a.isKeyboardHighlight, isExpanded = _a.isExpanded, highlightItem = _a.highlightItem, disabled = _a.disabled, expandToViewport = _a.expandToViewport, variant = _a.variant;
|
|
16
16
|
var highlighted = isHighlighted(item);
|
|
17
17
|
var expanded = isExpanded(item);
|
|
18
|
+
var isKeyboardHighlighted = isKeyboardHighlight(item);
|
|
18
19
|
var triggerRef = React.useRef(null);
|
|
19
20
|
var ref = useRef(null);
|
|
20
21
|
useEffect(function () {
|
|
@@ -39,6 +40,7 @@ var ExpandableCategoryElement = function (_a) {
|
|
|
39
40
|
var trigger = item.text && (React.createElement("span", __assign({ className: clsx(styles.header, styles['expandable-header'], styles["variant-".concat(variant)], (_b = {},
|
|
40
41
|
_b[styles.disabled] = disabled,
|
|
41
42
|
_b[styles.highlighted] = highlighted,
|
|
43
|
+
_b[styles['is-focused']] = isKeyboardHighlighted,
|
|
42
44
|
_b)),
|
|
43
45
|
// We are using the roving tabindex technique to manage the focus state of the dropdown.
|
|
44
46
|
// The current element will always have tabindex=0 which means that it can be tabbed to,
|
|
@@ -60,7 +62,7 @@ var ExpandableCategoryElement = function (_a) {
|
|
|
60
62
|
}
|
|
61
63
|
else {
|
|
62
64
|
content = (React.createElement(Dropdown, { open: expanded, stretchWidth: false, interior: true, expandToViewport: expandToViewport, trigger: trigger }, item.items && expanded && (React.createElement("ul", { role: "menu", "aria-label": item.text, className: clsx(styles['items-list-container']) },
|
|
63
|
-
React.createElement(ItemsList, { items: item.items, onItemActivate: onItemActivate, onGroupToggle: onGroupToggle, targetItem: targetItem, isHighlighted: isHighlighted, isExpanded: isExpanded, highlightItem: highlightItem, variant: variant })))));
|
|
65
|
+
React.createElement(ItemsList, { items: item.items, onItemActivate: onItemActivate, onGroupToggle: onGroupToggle, targetItem: targetItem, isHighlighted: isHighlighted, isKeyboardHighlight: isKeyboardHighlight, isExpanded: isExpanded, highlightItem: highlightItem, variant: variant })))));
|
|
64
66
|
}
|
|
65
67
|
return (React.createElement("li", { className: clsx(styles.category, styles["variant-".concat(variant)], styles.expandable, (_c = {},
|
|
66
68
|
_c[styles.expanded] = expanded,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expandable-category-element.js","sourceRoot":"","sources":["../../../../src/button-dropdown/category-elements/expandable-category-element.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,YAAY,MAAM,qBAAqB,CAAC;AAC/C,OAAO,SAAS,MAAM,eAAe,CAAC;AACtC,OAAO,QAAQ,MAAM,oCAAoC,CAAC;AAE1D,OAAO,oBAAoB,MAAM,iCAAiC,CAAC;AACnE,OAAO,OAAO,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,IAAM,yBAAyB,GAAG,UAAC,
|
|
1
|
+
{"version":3,"file":"expandable-category-element.js","sourceRoot":"","sources":["../../../../src/button-dropdown/category-elements/expandable-category-element.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,YAAY,MAAM,qBAAqB,CAAC;AAC/C,OAAO,SAAS,MAAM,eAAe,CAAC;AACtC,OAAO,QAAQ,MAAM,oCAAoC,CAAC;AAE1D,OAAO,oBAAoB,MAAM,iCAAiC,CAAC;AACnE,OAAO,OAAO,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,IAAM,yBAAyB,GAAG,UAAC,EAYnB;;QAXd,IAAI,UAAA,EACJ,cAAc,oBAAA,EACd,aAAa,mBAAA,EACb,UAAU,gBAAA,EACV,aAAa,mBAAA,EAC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AAI,CACzB,4BAAI,IAAI,EAAC,MAAM,gBAAa,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC;YACpF,oBAAC,SAAS,IACR,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,EAC5B,mBAAmB,EAAE,mBAAmB,EACxC,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,OAAO,GAChB,CACC,CACN,CACQ,CACZ,CAAC;KACH;IAED,OAAO,CACL,4BACE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,kBAAW,OAAO,CAAE,CAAC,EAAE,MAAM,CAAC,UAAU;YAC9E,GAAC,MAAM,CAAC,QAAQ,IAAG,QAAQ;YAC3B,GAAC,MAAM,CAAC,QAAQ,IAAG,QAAQ;YAC3B,GAAC,MAAM,CAAC,WAAW,IAAG,WAAW;gBACjC,EACF,IAAI,EAAC,cAAc,iBACN,IAAI,CAAC,EAAE,EACpB,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,OAAO,EACrB,YAAY,EAAE,OAAO,IAEpB,OAAO,CACL,CACN,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,yBAAyB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef } from 'react';\nimport clsx from 'clsx';\nimport styles from './styles.css.js';\n\nimport InternalIcon from '../../icon/internal';\nimport ItemsList from '../items-list';\nimport Dropdown from '../../internal/components/dropdown';\nimport { CategoryProps } from '../interfaces';\nimport useHiddenDescription from '../utils/use-hidden-description';\nimport Tooltip from '../tooltip.js';\nimport { getMenuItemProps } from '../utils/menu-item';\n\nconst ExpandableCategoryElement = ({\n item,\n onItemActivate,\n onGroupToggle,\n targetItem,\n isHighlighted,\n isKeyboardHighlight,\n isExpanded,\n highlightItem,\n disabled,\n expandToViewport,\n variant,\n}: CategoryProps) => {\n const highlighted = isHighlighted(item);\n const expanded = isExpanded(item);\n const isKeyboardHighlighted = isKeyboardHighlight(item);\n const triggerRef = React.useRef<HTMLSpanElement>(null);\n const ref = useRef<HTMLLIElement>(null);\n\n useEffect(() => {\n if (triggerRef.current && highlighted && !expanded) {\n triggerRef.current.focus();\n }\n }, [expanded, highlighted]);\n\n const onClick: React.MouseEventHandler = event => {\n if (!disabled) {\n event.preventDefault();\n onGroupToggle(item, event);\n triggerRef.current?.focus();\n }\n };\n\n const onHover = (event: React.SyntheticEvent) => {\n event.preventDefault();\n highlightItem(item);\n };\n\n const isDisabledWithReason = !!item.disabledReason && item.disabled;\n const { targetProps, descriptionEl } = useHiddenDescription(item.disabledReason);\n const trigger = item.text && (\n <span\n className={clsx(styles.header, styles['expandable-header'], styles[`variant-${variant}`], {\n [styles.disabled]: disabled,\n [styles.highlighted]: highlighted,\n [styles['is-focused']]: isKeyboardHighlighted,\n })}\n // We are using the roving tabindex technique to manage the focus state of the dropdown.\n // The current element will always have tabindex=0 which means that it can be tabbed to,\n // while all other items have tabindex=-1 so we can focus them when necessary.\n tabIndex={highlighted ? 0 : -1}\n ref={triggerRef}\n {...getMenuItemProps({ parent: true, expanded, disabled })}\n {...(isDisabledWithReason ? targetProps : {})}\n >\n {item.text}\n <span className={clsx(styles['expand-icon'], styles['expand-icon-right'])}>\n <InternalIcon name=\"caret-down-filled\" />\n </span>\n </span>\n );\n\n let content: React.ReactNode;\n // If the category element is disabled, we do not render a dropdown.\n // Screenreaders are confused by additional sections\n if (isDisabledWithReason) {\n content = (\n <Tooltip content={item.disabledReason}>\n {trigger}\n {descriptionEl}\n </Tooltip>\n );\n } else if (disabled) {\n content = trigger;\n } else {\n content = (\n <Dropdown\n open={expanded}\n stretchWidth={false}\n interior={true}\n expandToViewport={expandToViewport}\n trigger={trigger}\n >\n {item.items && expanded && (\n <ul role=\"menu\" aria-label={item.text} className={clsx(styles['items-list-container'])}>\n <ItemsList\n items={item.items}\n onItemActivate={onItemActivate}\n onGroupToggle={onGroupToggle}\n targetItem={targetItem}\n isHighlighted={isHighlighted}\n isKeyboardHighlight={isKeyboardHighlight}\n isExpanded={isExpanded}\n highlightItem={highlightItem}\n variant={variant}\n />\n </ul>\n )}\n </Dropdown>\n );\n }\n\n return (\n <li\n className={clsx(styles.category, styles[`variant-${variant}`], styles.expandable, {\n [styles.expanded]: expanded,\n [styles.disabled]: disabled,\n [styles.highlighted]: highlighted,\n })}\n role=\"presentation\"\n data-testid={item.id}\n ref={ref}\n onClick={onClick}\n onMouseEnter={onHover}\n onTouchStart={onHover}\n >\n {content}\n </li>\n );\n};\n\nexport default ExpandableCategoryElement;\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { CategoryProps } from '../interfaces';
|
|
2
|
-
declare const MobileExpandableCategoryElement: ({ item, onItemActivate, onGroupToggle, targetItem, isHighlighted, isExpanded, highlightItem, disabled, variant, }: CategoryProps) => JSX.Element;
|
|
2
|
+
declare const MobileExpandableCategoryElement: ({ item, onItemActivate, onGroupToggle, targetItem, isHighlighted, isKeyboardHighlight, isExpanded, highlightItem, disabled, variant, }: CategoryProps) => JSX.Element;
|
|
3
3
|
export default MobileExpandableCategoryElement;
|
|
4
4
|
//# sourceMappingURL=mobile-expandable-category-element.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mobile-expandable-category-element.d.ts","sourceRoot":"","sources":["../../../../src/button-dropdown/category-elements/mobile-expandable-category-element.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAK9C,QAAA,MAAM,+BAA+B,
|
|
1
|
+
{"version":3,"file":"mobile-expandable-category-element.d.ts","sourceRoot":"","sources":["../../../../src/button-dropdown/category-elements/mobile-expandable-category-element.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAK9C,QAAA,MAAM,+BAA+B,2IAWlC,aAAa,gBAwGf,CAAC;AAEF,eAAe,+BAA+B,CAAC"}
|
|
@@ -12,9 +12,10 @@ import useHiddenDescription from '../utils/use-hidden-description.js';
|
|
|
12
12
|
import { getMenuItemProps } from '../utils/menu-item.js';
|
|
13
13
|
var MobileExpandableCategoryElement = function (_a) {
|
|
14
14
|
var _b, _c, _d;
|
|
15
|
-
var item = _a.item, onItemActivate = _a.onItemActivate, onGroupToggle = _a.onGroupToggle, targetItem = _a.targetItem, isHighlighted = _a.isHighlighted, isExpanded = _a.isExpanded, highlightItem = _a.highlightItem, disabled = _a.disabled, variant = _a.variant;
|
|
15
|
+
var item = _a.item, onItemActivate = _a.onItemActivate, onGroupToggle = _a.onGroupToggle, targetItem = _a.targetItem, isHighlighted = _a.isHighlighted, isKeyboardHighlight = _a.isKeyboardHighlight, isExpanded = _a.isExpanded, highlightItem = _a.highlightItem, disabled = _a.disabled, variant = _a.variant;
|
|
16
16
|
var highlighted = isHighlighted(item);
|
|
17
17
|
var expanded = isExpanded(item);
|
|
18
|
+
var isKeyboardHighlighted = isKeyboardHighlight(item);
|
|
18
19
|
var triggerRef = React.useRef(null);
|
|
19
20
|
useEffect(function () {
|
|
20
21
|
if (triggerRef.current && highlighted && !expanded) {
|
|
@@ -37,6 +38,7 @@ var MobileExpandableCategoryElement = function (_a) {
|
|
|
37
38
|
_b[styles.highlighted] = highlighted,
|
|
38
39
|
_b[styles['rolled-down']] = expanded,
|
|
39
40
|
_b[styles.disabled] = disabled,
|
|
41
|
+
_b[styles['is-focused']] = isKeyboardHighlighted,
|
|
40
42
|
_b)),
|
|
41
43
|
// We are using the roving tabindex technique to manage the focus state of the dropdown.
|
|
42
44
|
// The current element will always have tabindex=0 which means that it can be tabbed to,
|
|
@@ -58,7 +60,7 @@ var MobileExpandableCategoryElement = function (_a) {
|
|
|
58
60
|
}
|
|
59
61
|
else {
|
|
60
62
|
content = (React.createElement(MobileExpandableGroup, { open: expanded, trigger: trigger }, item.items && expanded && (React.createElement("ul", { role: "menu", "aria-label": item.text, className: clsx(styles['items-list-container']) },
|
|
61
|
-
React.createElement(ItemsList, { items: item.items, onItemActivate: onItemActivate, onGroupToggle: onGroupToggle, targetItem: targetItem, isHighlighted: isHighlighted, isExpanded: isExpanded, highlightItem: highlightItem, hasCategoryHeader: true, variant: variant })))));
|
|
63
|
+
React.createElement(ItemsList, { items: item.items, onItemActivate: onItemActivate, onGroupToggle: onGroupToggle, targetItem: targetItem, isHighlighted: isHighlighted, isKeyboardHighlight: isKeyboardHighlight, isExpanded: isExpanded, highlightItem: highlightItem, hasCategoryHeader: true, variant: variant })))));
|
|
62
64
|
}
|
|
63
65
|
return (React.createElement("li", { className: clsx(styles.category, styles["variant-".concat(variant)], styles.expandable, (_d = {},
|
|
64
66
|
_d[styles.expanded] = expanded,
|