@cloudscape-design/components 3.0.1190 → 3.0.1191
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/autosuggest/autosuggest-option.d.ts +1 -11
- package/autosuggest/autosuggest-option.d.ts.map +1 -1
- package/autosuggest/autosuggest-option.js +2 -71
- package/autosuggest/autosuggest-option.js.map +1 -1
- package/autosuggest/index.d.ts.map +1 -1
- package/autosuggest/index.js +2 -2
- package/autosuggest/index.js.map +1 -1
- package/autosuggest/interfaces.d.ts +1 -63
- package/autosuggest/interfaces.d.ts.map +1 -1
- package/autosuggest/interfaces.js.map +1 -1
- package/autosuggest/internal.d.ts.map +1 -1
- package/autosuggest/internal.js +2 -2
- package/autosuggest/internal.js.map +1 -1
- package/autosuggest/options-controller.js +0 -1
- package/autosuggest/options-controller.js.map +1 -1
- package/autosuggest/options-list.d.ts +1 -3
- package/autosuggest/options-list.d.ts.map +1 -1
- package/autosuggest/options-list.js +2 -2
- package/autosuggest/options-list.js.map +1 -1
- package/autosuggest/plain-list.d.ts +2 -4
- package/autosuggest/plain-list.d.ts.map +1 -1
- package/autosuggest/plain-list.js +2 -6
- package/autosuggest/plain-list.js.map +1 -1
- package/autosuggest/virtual-list.d.ts +1 -2
- package/autosuggest/virtual-list.d.ts.map +1 -1
- package/autosuggest/virtual-list.js +2 -6
- package/autosuggest/virtual-list.js.map +1 -1
- package/internal/base-component/styles.scoped.css +15 -15
- package/internal/environment.js +2 -2
- package/internal/environment.json +2 -2
- package/internal/generated/styles/tokens.d.ts +2 -0
- package/internal/generated/styles/tokens.js +4 -2
- package/internal/generated/theming/index.cjs +64 -2
- package/internal/generated/theming/index.js +64 -2
- package/internal/manifest.json +1 -1
- package/package.json +1 -1
- package/progress-bar/interfaces.d.ts +1 -1
- package/progress-bar/interfaces.js.map +1 -1
- package/progress-bar/internal.d.ts.map +1 -1
- package/progress-bar/internal.js +1 -1
- package/progress-bar/internal.js.map +1 -1
- package/progress-bar/styles.css.js +19 -18
- package/progress-bar/styles.scoped.css +42 -30
- package/progress-bar/styles.selectors.js +19 -18
- package/autosuggest/utils/parent-props.d.ts +0 -10
- package/autosuggest/utils/parent-props.d.ts.map +0 -1
- package/autosuggest/utils/parent-props.js +0 -28
- package/autosuggest/utils/parent-props.js.map +0 -1
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { BaseComponentProps } from '../internal/base-component';
|
|
3
3
|
import { HighlightType } from '../internal/components/options-list/utils/use-highlight-option';
|
|
4
|
-
import { AutosuggestItem
|
|
4
|
+
import { AutosuggestItem } from './interfaces';
|
|
5
5
|
interface AutosuggestOptionProps extends BaseComponentProps {
|
|
6
|
-
index: number;
|
|
7
|
-
virtualIndex?: number;
|
|
8
6
|
nativeAttributes?: React.HTMLAttributes<HTMLDivElement>;
|
|
9
7
|
highlightText: string;
|
|
10
8
|
option: AutosuggestItem;
|
|
@@ -16,14 +14,6 @@ interface AutosuggestOptionProps extends BaseComponentProps {
|
|
|
16
14
|
screenReaderContent?: string;
|
|
17
15
|
ariaSetsize?: number;
|
|
18
16
|
ariaPosinset?: number;
|
|
19
|
-
renderOption?: AutosuggestProps.ItemRenderer;
|
|
20
|
-
parentProps?: AutosuggestRenderItemParentProps;
|
|
21
|
-
}
|
|
22
|
-
export interface AutosuggestRenderItemParentProps {
|
|
23
|
-
index: number;
|
|
24
|
-
virtualIndex?: number;
|
|
25
|
-
option: AutosuggestItem;
|
|
26
|
-
disabled: boolean;
|
|
27
17
|
}
|
|
28
18
|
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<AutosuggestOptionProps & React.RefAttributes<HTMLDivElement>>>;
|
|
29
19
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autosuggest-option.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/autosuggest-option.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,kBAAkB,EAAgB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"autosuggest-option.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/autosuggest-option.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,kBAAkB,EAAgB,MAAM,4BAA4B,CAAC;AAG9E,OAAO,EAAE,aAAa,EAAE,MAAM,gEAAgE,CAAC;AAE/F,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAI/C,UAAU,sBAAuB,SAAQ,kBAAkB;IACzD,gBAAgB,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;IACxD,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,eAAe,CAAC;IACxB,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;;AAyED,wBAA+D"}
|
|
@@ -6,42 +6,7 @@ import OptionComponent from '../internal/components/option';
|
|
|
6
6
|
import { getTestOptionIndexes } from '../internal/components/options-list/utils/test-indexes';
|
|
7
7
|
import SelectableItem from '../internal/components/selectable-item';
|
|
8
8
|
import styles from './styles.css.js';
|
|
9
|
-
const
|
|
10
|
-
var _a;
|
|
11
|
-
return {
|
|
12
|
-
type: 'group',
|
|
13
|
-
index: (_a = props.virtualIndex) !== null && _a !== void 0 ? _a : props.index,
|
|
14
|
-
option: props.option.option,
|
|
15
|
-
disabled: props.disabled,
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
const toAutosuggestOptionItem = (props) => {
|
|
19
|
-
var _a;
|
|
20
|
-
return {
|
|
21
|
-
type: 'item',
|
|
22
|
-
index: (_a = props.virtualIndex) !== null && _a !== void 0 ? _a : props.index,
|
|
23
|
-
option: props.option.option,
|
|
24
|
-
selected: props.selected,
|
|
25
|
-
highlighted: props.highlighted,
|
|
26
|
-
disabled: props.disabled,
|
|
27
|
-
parent: props.parentProps
|
|
28
|
-
? toAutosuggestOptionGroupItem({
|
|
29
|
-
index: props.parentProps.index,
|
|
30
|
-
virtualIndex: props.parentProps.virtualIndex,
|
|
31
|
-
option: props.parentProps.option,
|
|
32
|
-
disabled: props.disabled,
|
|
33
|
-
})
|
|
34
|
-
: null,
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
const toAutosuggestUseEnteredItem = (props) => {
|
|
38
|
-
return {
|
|
39
|
-
type: 'entered-text',
|
|
40
|
-
option: props.option.option,
|
|
41
|
-
highlighted: props.highlighted,
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
const AutosuggestOption = ({ index, virtualIndex, nativeAttributes = {}, highlightText, option, highlighted, highlightType, current, virtualPosition, padBottom, screenReaderContent, ariaSetsize, ariaPosinset, renderOption, parentProps, ...rest }, ref) => {
|
|
9
|
+
const AutosuggestOption = ({ nativeAttributes = {}, highlightText, option, highlighted, highlightType, current, virtualPosition, padBottom, screenReaderContent, ariaSetsize, ariaPosinset, ...rest }, ref) => {
|
|
45
10
|
const baseProps = getBaseProps(rest);
|
|
46
11
|
const useEntered = 'type' in option && option.type === 'use-entered';
|
|
47
12
|
const isParent = 'type' in option && option.type === 'parent';
|
|
@@ -65,41 +30,7 @@ const AutosuggestOption = ({ index, virtualIndex, nativeAttributes = {}, highlig
|
|
|
65
30
|
optionContent = (React.createElement("div", { ...a11yProperties },
|
|
66
31
|
React.createElement(OptionComponent, { option: option, highlightedOption: highlighted, highlightText: highlightText })));
|
|
67
32
|
}
|
|
68
|
-
|
|
69
|
-
if (option.type === 'parent') {
|
|
70
|
-
return toAutosuggestOptionGroupItem({
|
|
71
|
-
option: option,
|
|
72
|
-
index: index,
|
|
73
|
-
virtualIndex: virtualIndex,
|
|
74
|
-
disabled: !!option.disabled,
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
else if (option.type === 'use-entered') {
|
|
78
|
-
return toAutosuggestUseEnteredItem({
|
|
79
|
-
option: option,
|
|
80
|
-
highlighted: highlighted,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
return toAutosuggestOptionItem({
|
|
85
|
-
option: option,
|
|
86
|
-
index: index,
|
|
87
|
-
virtualIndex: virtualIndex,
|
|
88
|
-
disabled: !!option.disabled,
|
|
89
|
-
highlighted: highlighted,
|
|
90
|
-
selected: current,
|
|
91
|
-
parentProps: parentProps,
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
const renderOptionWrapper = (option) => {
|
|
96
|
-
if (!renderOption) {
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
return renderOption({ item: getAutosuggestItemProps(option), filterText: highlightText });
|
|
100
|
-
};
|
|
101
|
-
const renderResult = renderOptionWrapper(option);
|
|
102
|
-
return (React.createElement(SelectableItem, { ...baseProps, disableContentStyling: !!renderResult, className: styles.option, ariaSelected: current, highlighted: highlighted, disabled: option.disabled, hasBackground: useEntered, isParent: isParent, isChild: isChild, virtualPosition: virtualPosition, "data-test-index": throughIndex, "data-in-group-index": inGroupIndex, "data-group-index": groupIndex, ref: ref, padBottom: padBottom, screenReaderContent: screenReaderContent, ariaSetsize: ariaSetsize, ariaPosinset: ariaPosinset, highlightType: highlightType.type, value: option.value }, !renderResult ? optionContent : renderResult));
|
|
33
|
+
return (React.createElement(SelectableItem, { ...baseProps, className: styles.option, ariaSelected: current, highlighted: highlighted, disabled: option.disabled, hasBackground: useEntered, isParent: isParent, isChild: isChild, virtualPosition: virtualPosition, "data-test-index": throughIndex, "data-in-group-index": inGroupIndex, "data-group-index": groupIndex, ref: ref, padBottom: padBottom, screenReaderContent: screenReaderContent, ariaSetsize: ariaSetsize, ariaPosinset: ariaPosinset, highlightType: highlightType.type, value: option.value }, optionContent));
|
|
103
34
|
};
|
|
104
35
|
export default React.memo(React.forwardRef(AutosuggestOption));
|
|
105
36
|
//# sourceMappingURL=autosuggest-option.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autosuggest-option.js","sourceRoot":"","sources":["../../../src/autosuggest/autosuggest-option.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAsB,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,eAAe,MAAM,+BAA+B,CAAC;AAE5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AAE9F,OAAO,cAAc,MAAM,wCAAwC,CAAC;AAGpE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AA2BrC,MAAM,4BAA4B,GAAG,CACnC,KAAuC,EACC,EAAE;;IAC1C,OAAO;QACL,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,MAAA,KAAK,CAAC,YAAY,mCAAI,KAAK,CAAC,KAAK;QACxC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAqB;QAC1C,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACzB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,uBAAuB,GAAG,CAAC,KAQhC,EAAqC,EAAE;;IACtC,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,MAAA,KAAK,CAAC,YAAY,mCAAI,KAAK,CAAC,KAAK;QACxC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAA0B;QAC/C,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,MAAM,EAAE,KAAK,CAAC,WAAW;YACvB,CAAC,CAAC,4BAA4B,C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;QACL,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,mBAAmB,GAAG,CAAC,MAAuB,EAAE,EAAE;QACtD,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,YAAY,CAAC,EAAE,IAAI,EAAE,uBAAuB,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC,CAAC;IAC5F,CAAC,CAAC;IACF,MAAM,YAAY,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAEjD,OAAO,CACL,oBAAC,cAAc,OACT,SAAS,EACb,qBAAqB,EAAE,CAAC,CAAC,YAAY,EACrC,SAAS,EAAE,MAAM,CAAC,MAAM,EACxB,YAAY,EAAE,OAAO,EACrB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,MAAM,CAAC,QAAQ,EACzB,aAAa,EAAE,UAAU,EACzB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,eAAe,qBACf,YAAY,yBACR,YAAY,sBACf,UAAU,EAC5B,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,mBAAmB,EAAE,mBAAmB,EACxC,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,CAAC,IAAI,EACjC,KAAK,EAAE,MAAM,CAAC,KAAK,IAElB,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAC9B,CAClB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,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 { BaseComponentProps, getBaseProps } from '../internal/base-component';\nimport OptionComponent from '../internal/components/option';\nimport { OptionDefinition, OptionGroup } from '../internal/components/option/interfaces';\nimport { getTestOptionIndexes } from '../internal/components/options-list/utils/test-indexes';\nimport { HighlightType } from '../internal/components/options-list/utils/use-highlight-option';\nimport SelectableItem from '../internal/components/selectable-item';\nimport { AutosuggestItem, AutosuggestProps } from './interfaces';\n\nimport styles from './styles.css.js';\n\ninterface AutosuggestOptionProps extends BaseComponentProps {\n index: number;\n virtualIndex?: number;\n nativeAttributes?: React.HTMLAttributes<HTMLDivElement>;\n highlightText: string;\n option: AutosuggestItem;\n highlighted: boolean;\n highlightType: HighlightType;\n current: boolean;\n virtualPosition?: number;\n padBottom?: boolean;\n screenReaderContent?: string;\n ariaSetsize?: number;\n ariaPosinset?: number;\n renderOption?: AutosuggestProps.ItemRenderer;\n parentProps?: AutosuggestRenderItemParentProps;\n}\n\nexport interface AutosuggestRenderItemParentProps {\n index: number;\n virtualIndex?: number;\n option: AutosuggestItem;\n disabled: boolean;\n}\n\nconst toAutosuggestOptionGroupItem = (\n props: AutosuggestRenderItemParentProps\n): AutosuggestProps.OptionGroupRenderItem => {\n return {\n type: 'group',\n index: props.virtualIndex ?? props.index,\n option: props.option.option as OptionGroup,\n disabled: props.disabled,\n };\n};\n\nconst toAutosuggestOptionItem = (props: {\n index: number;\n virtualIndex?: number;\n option: AutosuggestItem;\n disabled: boolean;\n selected: boolean;\n highlighted: boolean;\n parentProps?: AutosuggestRenderItemParentProps;\n}): AutosuggestProps.OptionRenderItem => {\n return {\n type: 'item',\n index: props.virtualIndex ?? props.index,\n option: props.option.option as OptionDefinition,\n selected: props.selected,\n highlighted: props.highlighted,\n disabled: props.disabled,\n parent: props.parentProps\n ? toAutosuggestOptionGroupItem({\n index: props.parentProps.index,\n virtualIndex: props.parentProps.virtualIndex,\n option: props.parentProps.option,\n disabled: props.disabled,\n })\n : null,\n };\n};\n\nconst toAutosuggestUseEnteredItem = (props: {\n option: AutosuggestItem;\n highlighted: boolean;\n}): AutosuggestProps.EnteredTextRenderItem => {\n return {\n type: 'entered-text',\n option: props.option.option as OptionDefinition,\n highlighted: props.highlighted,\n };\n};\n\nconst AutosuggestOption = (\n {\n index,\n virtualIndex,\n nativeAttributes = {},\n highlightText,\n option,\n highlighted,\n highlightType,\n current,\n virtualPosition,\n padBottom,\n screenReaderContent,\n ariaSetsize,\n ariaPosinset,\n renderOption,\n parentProps,\n ...rest\n }: AutosuggestOptionProps,\n ref: React.Ref<HTMLDivElement>\n) => {\n const baseProps = getBaseProps(rest);\n const useEntered = 'type' in option && option.type === 'use-entered';\n const isParent = 'type' in option && option.type === 'parent';\n const isChild = 'type' in option && option.type === 'child';\n const { throughIndex, inGroupIndex, groupIndex } = getTestOptionIndexes(option) || {};\n\n let optionContent;\n if (useEntered) {\n optionContent = option.label;\n // we don't want fancy generated content for screenreader for the \"Use...\" option,\n // just the visible text is fine\n screenReaderContent = undefined;\n } else if (isParent) {\n optionContent = option.label;\n } else {\n const a11yProperties: AutosuggestOptionProps['nativeAttributes'] = {};\n if (nativeAttributes['aria-label']) {\n a11yProperties['aria-label'] = nativeAttributes['aria-label'];\n }\n\n optionContent = (\n <div {...a11yProperties}>\n <OptionComponent option={option} highlightedOption={highlighted} highlightText={highlightText} />\n </div>\n );\n }\n\n const getAutosuggestItemProps = (option: AutosuggestItem) => {\n if (option.type === 'parent') {\n return toAutosuggestOptionGroupItem({\n option: option,\n index: index,\n virtualIndex: virtualIndex,\n disabled: !!option.disabled,\n });\n } else if (option.type === 'use-entered') {\n return toAutosuggestUseEnteredItem({\n option: option,\n highlighted: highlighted,\n });\n } else {\n return toAutosuggestOptionItem({\n option: option,\n index: index,\n virtualIndex: virtualIndex,\n disabled: !!option.disabled,\n highlighted: highlighted,\n selected: current,\n parentProps: parentProps,\n });\n }\n };\n\n const renderOptionWrapper = (option: AutosuggestItem) => {\n if (!renderOption) {\n return null;\n }\n\n return renderOption({ item: getAutosuggestItemProps(option), filterText: highlightText });\n };\n const renderResult = renderOptionWrapper(option);\n\n return (\n <SelectableItem\n {...baseProps}\n disableContentStyling={!!renderResult}\n className={styles.option}\n ariaSelected={current}\n highlighted={highlighted}\n disabled={option.disabled}\n hasBackground={useEntered}\n isParent={isParent}\n isChild={isChild}\n virtualPosition={virtualPosition}\n data-test-index={throughIndex}\n data-in-group-index={inGroupIndex}\n data-group-index={groupIndex}\n ref={ref}\n padBottom={padBottom}\n screenReaderContent={screenReaderContent}\n ariaSetsize={ariaSetsize}\n ariaPosinset={ariaPosinset}\n highlightType={highlightType.type}\n value={option.value}\n >\n {!renderResult ? optionContent : renderResult}\n </SelectableItem>\n );\n};\n\nexport default React.memo(React.forwardRef(AutosuggestOption));\n"]}
|
|
1
|
+
{"version":3,"file":"autosuggest-option.js","sourceRoot":"","sources":["../../../src/autosuggest/autosuggest-option.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAsB,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,eAAe,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AAE9F,OAAO,cAAc,MAAM,wCAAwC,CAAC;AAGpE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAgBrC,MAAM,iBAAiB,GAAG,CACxB,EACE,gBAAgB,GAAG,EAAE,EACrB,aAAa,EACb,MAAM,EACN,WAAW,EACX,aAAa,EACb,OAAO,EACP,eAAe,EACf,SAAS,EACT,mBAAmB,EACnB,WAAW,EACX,YAAY,EACZ,GAAG,IAAI,EACgB,EACzB,GAA8B,EAC9B,EAAE;IACF,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,UAAU,GAAG,MAAM,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,aAAa,CAAC;IACrE,MAAM,QAAQ,GAAG,MAAM,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;IAC9D,MAAM,OAA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I,EACjC,KAAK,EAAE,MAAM,CAAC,KAAK,IAElB,aAAa,CACC,CAClB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,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 { BaseComponentProps, getBaseProps } from '../internal/base-component';\nimport OptionComponent from '../internal/components/option';\nimport { getTestOptionIndexes } from '../internal/components/options-list/utils/test-indexes';\nimport { HighlightType } from '../internal/components/options-list/utils/use-highlight-option';\nimport SelectableItem from '../internal/components/selectable-item';\nimport { AutosuggestItem } from './interfaces';\n\nimport styles from './styles.css.js';\n\ninterface AutosuggestOptionProps extends BaseComponentProps {\n nativeAttributes?: React.HTMLAttributes<HTMLDivElement>;\n highlightText: string;\n option: AutosuggestItem;\n highlighted: boolean;\n highlightType: HighlightType;\n current: boolean;\n virtualPosition?: number;\n padBottom?: boolean;\n screenReaderContent?: string;\n ariaSetsize?: number;\n ariaPosinset?: number;\n}\n\nconst AutosuggestOption = (\n {\n nativeAttributes = {},\n highlightText,\n option,\n highlighted,\n highlightType,\n current,\n virtualPosition,\n padBottom,\n screenReaderContent,\n ariaSetsize,\n ariaPosinset,\n ...rest\n }: AutosuggestOptionProps,\n ref: React.Ref<HTMLDivElement>\n) => {\n const baseProps = getBaseProps(rest);\n const useEntered = 'type' in option && option.type === 'use-entered';\n const isParent = 'type' in option && option.type === 'parent';\n const isChild = 'type' in option && option.type === 'child';\n const { throughIndex, inGroupIndex, groupIndex } = getTestOptionIndexes(option) || {};\n\n let optionContent;\n if (useEntered) {\n optionContent = option.label;\n // we don't want fancy generated content for screenreader for the \"Use...\" option,\n // just the visible text is fine\n screenReaderContent = undefined;\n } else if (isParent) {\n optionContent = option.label;\n } else {\n const a11yProperties: AutosuggestOptionProps['nativeAttributes'] = {};\n if (nativeAttributes['aria-label']) {\n a11yProperties['aria-label'] = nativeAttributes['aria-label'];\n }\n\n optionContent = (\n <div {...a11yProperties}>\n <OptionComponent option={option} highlightedOption={highlighted} highlightText={highlightText} />\n </div>\n );\n }\n\n return (\n <SelectableItem\n {...baseProps}\n className={styles.option}\n ariaSelected={current}\n highlighted={highlighted}\n disabled={option.disabled}\n hasBackground={useEntered}\n isParent={isParent}\n isChild={isChild}\n virtualPosition={virtualPosition}\n data-test-index={throughIndex}\n data-in-group-index={inGroupIndex}\n data-group-index={groupIndex}\n ref={ref}\n padBottom={padBottom}\n screenReaderContent={screenReaderContent}\n ariaSetsize={ariaSetsize}\n ariaPosinset={ariaPosinset}\n highlightType={highlightType.type}\n value={option.value}\n >\n {optionContent}\n </SelectableItem>\n );\n};\n\nexport default React.memo(React.forwardRef(AutosuggestOption));\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,QAAA,MAAM,WAAW,+
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,QAAA,MAAM,WAAW,+FA8ChB,CAAC;AAGF,eAAe,WAAW,CAAC"}
|
package/autosuggest/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import useBaseComponent from '../internal/hooks/use-base-component';
|
|
|
7
7
|
import { applyDisplayName } from '../internal/utils/apply-display-name';
|
|
8
8
|
import { getExternalProps } from '../internal/utils/external-props';
|
|
9
9
|
import InternalAutosuggest from './internal';
|
|
10
|
-
const Autosuggest = React.forwardRef(({ filteringType = 'auto', statusType = 'finished', disableBrowserAutocorrect = false, hideEnteredTextOption = false,
|
|
10
|
+
const Autosuggest = React.forwardRef(({ filteringType = 'auto', statusType = 'finished', disableBrowserAutocorrect = false, hideEnteredTextOption = false, ...props }, ref) => {
|
|
11
11
|
const baseComponentProps = useBaseComponent('Autosuggest', {
|
|
12
12
|
props: {
|
|
13
13
|
autoFocus: props.autoFocus,
|
|
@@ -28,7 +28,7 @@ const Autosuggest = React.forwardRef(({ filteringType = 'auto', statusType = 'fi
|
|
|
28
28
|
},
|
|
29
29
|
};
|
|
30
30
|
const externalProps = getExternalProps(props);
|
|
31
|
-
return (React.createElement(InternalAutosuggest, {
|
|
31
|
+
return (React.createElement(InternalAutosuggest, { filteringType: filteringType, statusType: statusType, disableBrowserAutocorrect: disableBrowserAutocorrect, hideEnteredTextOption: hideEnteredTextOption, ...externalProps, ...baseComponentProps, ref: ref, ...getAnalyticsMetadataAttribute({ component: componentAnalyticsMetadata }) }));
|
|
32
32
|
});
|
|
33
33
|
applyDisplayName(Autosuggest, 'Autosuggest');
|
|
34
34
|
export default Autosuggest;
|
package/autosuggest/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/autosuggest/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,YAAY,CAAC;AACb,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,6BAA6B,EAAE,MAAM,kEAAkE,CAAC;AAEjH,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGpE,OAAO,mBAAmB,MAAM,YAAY,CAAC;AAI7C,MAAM,WAAW,GAAG,KAAK,CAAC,UAAU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;IAEF,MAAM,aAAa,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC9C,OAAO,CACL,oBAAC,mBAAmB,IAClB,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,UAAU,EACtB,yBAAyB,EAAE,yBAAyB,EACpD,qBAAqB,EAAE,qBAAqB,KACxC,aAAa,KACb,kBAAkB,EACtB,GAAG,EAAE,GAAG,KACJ,6BAA6B,CAAC,EAAE,SAAS,EAAE,0BAA0B,EAAE,CAAC,GAC5E,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;AAC7C,eAAe,WAAW,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n'use client';\nimport React from 'react';\n\nimport { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { getExternalProps } from '../internal/utils/external-props';\nimport { GeneratedAnalyticsMetadataAutosuggestComponent } from './analytics-metadata/interfaces';\nimport { AutosuggestProps } from './interfaces';\nimport InternalAutosuggest from './internal';\n\nexport { AutosuggestProps };\n\nconst Autosuggest = React.forwardRef(\n (\n {\n filteringType = 'auto',\n statusType = 'finished',\n disableBrowserAutocorrect = false,\n hideEnteredTextOption = false,\n ...props\n }: AutosuggestProps,\n ref: React.Ref<AutosuggestProps.Ref>\n ) => {\n const baseComponentProps = useBaseComponent('Autosuggest', {\n props: {\n autoFocus: props.autoFocus,\n disableBrowserAutocorrect,\n expandToViewport: props.expandToViewport,\n filteringType,\n readOnly: props.readOnly,\n virtualScroll: props.virtualScroll,\n hideEnteredTextOption,\n },\n });\n\n const componentAnalyticsMetadata: GeneratedAnalyticsMetadataAutosuggestComponent = {\n name: 'awsui.Autosuggest',\n label: 'input',\n properties: {\n disabled: `${!!props.disabled}`,\n value: props.value || '',\n },\n };\n\n const externalProps = getExternalProps(props);\n return (\n <InternalAutosuggest\n filteringType={filteringType}\n statusType={statusType}\n disableBrowserAutocorrect={disableBrowserAutocorrect}\n hideEnteredTextOption={hideEnteredTextOption}\n {...externalProps}\n {...baseComponentProps}\n ref={ref}\n {...getAnalyticsMetadataAttribute({ component: componentAnalyticsMetadata })}\n />\n );\n }\n);\n\napplyDisplayName(Autosuggest, 'Autosuggest');\nexport default Autosuggest;\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { BaseInputProps, InputAutoCorrect, InputClearLabel, InputKeyEvents, InputProps } from '../input/interfaces';
|
|
3
3
|
import { BaseComponentProps } from '../internal/base-component';
|
|
4
4
|
import { BaseDropdownHostProps, OptionsFilteringType, OptionsLoadItemsDetail } from '../internal/components/dropdown/interfaces';
|
|
@@ -40,42 +40,6 @@ export interface AutosuggestProps extends BaseComponentProps, BaseInputProps, In
|
|
|
40
40
|
* on your own.
|
|
41
41
|
**/
|
|
42
42
|
options?: AutosuggestProps.Options;
|
|
43
|
-
/**
|
|
44
|
-
* Specifies a render function to render custom options in the dropdown menu.
|
|
45
|
-
*
|
|
46
|
-
* The item inside the props has a different shape depending on its type:
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* ### item
|
|
50
|
-
*
|
|
51
|
-
* - `type` ('item') - The item type.
|
|
52
|
-
* - `index` (number) - The item's absolute position in the dropdown.
|
|
53
|
-
* - `option` (Option) - The original option configuration.
|
|
54
|
-
* - `disabled` (boolean) - Whether the item is disabled.
|
|
55
|
-
* - `highlighted` (boolean) - Whether the item is currently highlighted.
|
|
56
|
-
* - `selected` (boolean) - Whether the item is selected.
|
|
57
|
-
* - `parent` (OptionGroupRenderItem | null) - The parent group item, if any.
|
|
58
|
-
*
|
|
59
|
-
* ### group
|
|
60
|
-
*
|
|
61
|
-
* - `type` ('group') - The item type.
|
|
62
|
-
* - `index` (number) - The item's absolute position in the dropdown.
|
|
63
|
-
* - `option` (OptionGroup) - The original option configuration.
|
|
64
|
-
* - `disabled` (boolean) - Whether the item is disabled.
|
|
65
|
-
*
|
|
66
|
-
* ### entered-text
|
|
67
|
-
*
|
|
68
|
-
* - `type` ('entered-text') - The item type.
|
|
69
|
-
* - `option` (Option) - The entered-text option configuration.
|
|
70
|
-
*
|
|
71
|
-
* When providing a custom `renderOption` implementation, it fully replaces the default visual rendering and content for that item.
|
|
72
|
-
* The component still manages focus, keyboard interactions, and selection state, but it no longer applies its default item layout or typography.
|
|
73
|
-
*
|
|
74
|
-
* When returning `null`, the default rendering will be applied for that item.
|
|
75
|
-
*
|
|
76
|
-
* @awsuiSystem core
|
|
77
|
-
*/
|
|
78
|
-
renderOption?: AutosuggestProps.ItemRenderer;
|
|
79
43
|
/**
|
|
80
44
|
* Determines how filtering is applied to the list of `options`:
|
|
81
45
|
*
|
|
@@ -164,31 +128,6 @@ export declare namespace AutosuggestProps {
|
|
|
164
128
|
interface ContainingOptionAndGroupString {
|
|
165
129
|
(option: Option, group?: OptionGroup): string;
|
|
166
130
|
}
|
|
167
|
-
interface OptionRenderItem {
|
|
168
|
-
type: 'item';
|
|
169
|
-
index: number;
|
|
170
|
-
option: Option;
|
|
171
|
-
disabled: boolean;
|
|
172
|
-
highlighted: boolean;
|
|
173
|
-
selected: boolean;
|
|
174
|
-
parent: OptionGroupRenderItem | null;
|
|
175
|
-
}
|
|
176
|
-
interface OptionGroupRenderItem {
|
|
177
|
-
type: 'group';
|
|
178
|
-
index: number;
|
|
179
|
-
option: OptionGroup;
|
|
180
|
-
disabled: boolean;
|
|
181
|
-
}
|
|
182
|
-
interface EnteredTextRenderItem {
|
|
183
|
-
type: 'entered-text';
|
|
184
|
-
option: Option;
|
|
185
|
-
highlighted: boolean;
|
|
186
|
-
}
|
|
187
|
-
type RenderItem = OptionRenderItem | OptionGroupRenderItem | EnteredTextRenderItem;
|
|
188
|
-
type ItemRenderer = (props: {
|
|
189
|
-
item: RenderItem;
|
|
190
|
-
filterText?: string;
|
|
191
|
-
}) => ReactNode | null;
|
|
192
131
|
interface Ref {
|
|
193
132
|
/**
|
|
194
133
|
* Sets input focus onto the UI control.
|
|
@@ -247,5 +186,4 @@ export declare namespace AutosuggestProps {
|
|
|
247
186
|
export type AutosuggestItem = (AutosuggestProps.Option | AutosuggestProps.OptionGroup) & {
|
|
248
187
|
type?: 'parent' | 'child' | 'use-entered';
|
|
249
188
|
option: OptionDefinition | OptionGroup;
|
|
250
|
-
parent?: OptionGroup;
|
|
251
189
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,eAAe,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACpH,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAE,+BAA+B,EAAE,MAAM,wCAAwC,CAAC;AACzF,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,MAAM,WAAW,gBACf,SAAQ,kBAAkB,EACxB,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,+BAA+B,EAC/B,mBAAmB;IACrB;;;;;;;;;;;;;;;;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AK,CAAC,EAAE,MAAM,CAAC;gBACf,KAAK,CAAC,EAAE,MAAM,CAAC;gBACf,QAAQ,CAAC,EAAE,MAAM,CAAC;aACnB,CAAC;YACF,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,UAAU,CAAC,EAAE,MAAM,CAAC;YACpB,YAAY,CAAC,EAAE,MAAM,CAAC;YACtB,aAAa,CAAC,EAAE,MAAM,CAAC;SACxB,CAAC;QACF,WAAW,CAAC,EAAE;YACZ,KAAK,CAAC,EAAE,MAAM,CAAC;YACf,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,UAAU,CAAC,EAAE,MAAM,CAAC;SACrB,CAAC;KACH;CACF;AAGD,MAAM,MAAM,eAAe,GAAG,CAAC,gBAAgB,CAAC,MAAM,GAAG,gBAAgB,CAAC,WAAW,CAAC,GAAG;IACvF,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,aAAa,CAAC;IAC1C,MAAM,EAAE,gBAAgB,GAAG,WAAW,CAAC;CACxC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/autosuggest/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { ReactNode } from 'react';\n\nimport { BaseInputProps, InputAutoCorrect, InputClearLabel, InputKeyEvents, InputProps } from '../input/interfaces';\nimport { BaseComponentProps } from '../internal/base-component';\nimport {\n BaseDropdownHostProps,\n OptionsFilteringType,\n OptionsLoadItemsDetail,\n} from '../internal/components/dropdown/interfaces';\nimport { DropdownStatusProps } from '../internal/components/dropdown-status';\nimport { OptionDefinition, OptionGroup } from '../internal/components/option/interfaces';\nimport { FormFieldValidationControlProps } from '../internal/context/form-field-context';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface AutosuggestProps\n extends BaseComponentProps,\n BaseInputProps,\n InputAutoCorrect,\n BaseDropdownHostProps,\n InputKeyEvents,\n InputClearLabel,\n FormFieldValidationControlProps,\n DropdownStatusProps {\n /**\n * Specifies an array of options that are displayed to the user as a dropdown list.\n * The options can be grouped using `OptionGroup` objects.\n *\n * #### Option\n * - `value` (string) - The returned value of the option when selected.\n * - `label` (string) - (Optional) Option text displayed to the user.\n * - `lang` (string) - (Optional) The language of the option, provided as a BCP 47 language tag.\n * - `description` (string) - (Optional) Further information about the option that appears below the label.\n * - `disabled` (boolean) - (Optional) Determines whether the option is disabled.\n * - `labelTag` (string) - (Optional) A label tag that provides additional guidance, shown next to the label.\n * - `tags` [string[]] - (Optional) A list of tags giving further guidance about the option.\n * - `filteringTags` [string[]] - (Optional) A list of additional tags used for automatic filtering.\n * - `iconName` (string) - (Optional) Specifies the name of an [icon](/components/icon/) to display in the option.\n * - `iconAriaLabel` (string) - (Optional) Specifies alternate text for the icon. We recommend that you provide this for accessibility.\n * - `iconAlt` (string) - (Optional) **Deprecated**, replaced by \\`iconAriaLabel\\`. Specifies alternate text for a custom icon, for use with `iconUrl`.\n * - `iconUrl` (string) - (Optional) URL of a custom icon.\n * - `iconSvg` (ReactNode) - (Optional) Custom SVG icon. Equivalent to the `svg` slot of the [icon component](/components/icon/).\n *\n * #### OptionGroup\n * - `label` (string) - Option group text displayed to the user.\n * - `disabled` (boolean) - (Optional) Determines whether the option group is disabled.\n * - `options` (Option[]) - (Optional) The options under this group.\n *\n * Note: Only one level of option nesting is supported.\n *\n * If you want to use the built-in filtering capabilities of this component, provide\n * a list of all valid options here and they will be automatically filtered based on the user's filtering input.\n *\n * Alternatively, you can listen to the `onChange` or `onLoadItems` event and set new options\n * on your own.\n **/\n options?: AutosuggestProps.Options;\n\n /**\n * Specifies a render function to render custom options in the dropdown menu.\n *\n * The item inside the props has a different shape depending on its type:\n *\n *\n * ### item\n *\n * - `type` ('item') - The item type.\n * - `index` (number) - The item's absolute position in the dropdown.\n * - `option` (Option) - The original option configuration.\n * - `disabled` (boolean) - Whether the item is disabled.\n * - `highlighted` (boolean) - Whether the item is currently highlighted.\n * - `selected` (boolean) - Whether the item is selected.\n * - `parent` (OptionGroupRenderItem | null) - The parent group item, if any.\n *\n * ### group\n *\n * - `type` ('group') - The item type.\n * - `index` (number) - The item's absolute position in the dropdown.\n * - `option` (OptionGroup) - The original option configuration.\n * - `disabled` (boolean) - Whether the item is disabled.\n *\n * ### entered-text\n *\n * - `type` ('entered-text') - The item type.\n * - `option` (Option) - The entered-text option configuration.\n *\n * When providing a custom `renderOption` implementation, it fully replaces the default visual rendering and content for that item.\n * The component still manages focus, keyboard interactions, and selection state, but it no longer applies its default item layout or typography.\n *\n * When returning `null`, the default rendering will be applied for that item.\n *\n * @awsuiSystem core\n */\n renderOption?: AutosuggestProps.ItemRenderer;\n\n /**\n * Determines how filtering is applied to the list of `options`:\n *\n * * `auto` - The component will automatically filter options based on user input.\n * * `manual` - You will set up `onChange` or `onLoadItems` event listeners and filter options on your side or request\n * them from server.\n *\n * By default the component will filter the provided `options` based on the value of the filtering input field.\n * Only options that have a `value`, `label`, `description` or `labelTag` that contains the input value as a substring\n * are displayed in the list of options.\n *\n * If you set this property to `manual`, this default filtering mechanism is disabled and all provided `options` are\n * displayed in the dropdown list. In that case make sure that you use the `onChange` or `onLoadItems` events in order\n * to set the `options` property to the options that are relevant for the user, given the filtering input value.\n *\n * Note: Manual filtering doesn't disable match highlighting.\n **/\n filteringType?: OptionsFilteringType;\n\n /**\n * Specifies a function that generates the custom value indicator (for example, `Use \"${value}\"`).\n * @i18n\n */\n enteredTextLabel?: AutosuggestProps.EnteredTextLabel;\n\n /**\n * Defines whether entered text option is shown as the first option in the dropdown when value is non-empty.\n */\n hideEnteredTextOption?: boolean;\n\n /**\n * Specifies the text to display with the number of matches at the bottom of the dropdown menu while filtering.\n *\n * Note that the `matchesCount` includes the `enteredTextLabel` (\"Use ${value}\") item, so in most cases you\n * should subtract 1 from `matchesCount`. If using manual filtering, you should provide your own value for `totalCount`.\n */\n filteringResultsText?: (matchesCount: number, totalCount: number) => string;\n\n /**\n * Specifies the text that's displayed when there aren't any suggestions to display.\n * This is displayed when `statusType` is set to `finished` or it's not set at all.\n */\n empty?: React.ReactNode;\n\n /**\n * Called whenever a user selects an option in the dropdown. Don't use this event as the only way to handle user input.\n * Instead, use `onSelect` in combination with the `onChange` handler only as an optional convenience for the user.\n */\n onSelect?: NonCancelableEventHandler<AutosuggestProps.SelectDetail>;\n\n /**\n * Specifies the localized string that describes an option as being selected.\n * This is required to provide a good screen reader experience. For more information, see the\n * [accessibility guidelines](/components/autosuggest/?tabId=usage#accessibility-guidelines).\n * @i18n\n */\n selectedAriaLabel?: string;\n /**\n * Overrides the element that is announced to screen readers\n * when the highlighted option changes. By default, this announces\n * the option's name and properties, and its selected state if\n * the `selectedAriaLabel` property is defined.\n * The highlighted option is provided, and its group (if groups\n * are used and it differs from the group of the previously highlighted option).\n *\n * For more information, see the\n * [accessibility guidelines](/components/autosuggest/?tabId=usage#accessibility-guidelines).\n */\n renderHighlightedAriaLive?: AutosuggestProps.ContainingOptionAndGroupString;\n\n /**\n * @awsuiSystem core\n */\n style?: AutosuggestProps.Style;\n}\n\nexport namespace AutosuggestProps {\n export type ChangeDetail = InputProps.ChangeDetail;\n export type KeyDetail = InputProps.KeyDetail;\n export type FilteringType = OptionsFilteringType;\n export type Option = OptionDefinition;\n export type Options = ReadonlyArray<Option | OptionGroup>;\n export type EnteredTextLabel = (value: string) => string;\n export interface OptionGroup extends Option {\n label?: string;\n options: ReadonlyArray<Option>;\n }\n export type LoadItemsDetail = OptionsLoadItemsDetail;\n export type StatusType = DropdownStatusProps.StatusType;\n export interface SelectDetail {\n value: string;\n selectedOption?: Option;\n }\n\n export interface ContainingOptionAndGroupString {\n (option: Option, group?: OptionGroup): string;\n }\n\n export interface OptionRenderItem {\n type: 'item';\n index: number;\n option: Option;\n disabled: boolean;\n highlighted: boolean;\n selected: boolean;\n parent: OptionGroupRenderItem | null;\n }\n export interface OptionGroupRenderItem {\n type: 'group';\n index: number;\n option: OptionGroup;\n disabled: boolean;\n }\n export interface EnteredTextRenderItem {\n type: 'entered-text';\n option: Option;\n highlighted: boolean;\n }\n export type RenderItem = OptionRenderItem | OptionGroupRenderItem | EnteredTextRenderItem;\n export type ItemRenderer = (props: { item: RenderItem; filterText?: string }) => ReactNode | null;\n\n export interface Ref {\n /**\n * Sets input focus onto the UI control.\n */\n focus(): void;\n\n /**\n * Selects all text in the input control.\n */\n select(): void;\n }\n\n export interface Style {\n root?: {\n backgroundColor?: {\n default?: string;\n disabled?: string;\n focus?: string;\n hover?: string;\n readonly?: string;\n };\n borderColor?: {\n default?: string;\n disabled?: string;\n focus?: string;\n hover?: string;\n readonly?: string;\n };\n borderRadius?: string;\n borderWidth?: string;\n boxShadow?: {\n default?: string;\n disabled?: string;\n focus?: string;\n hover?: string;\n readonly?: string;\n };\n color?: {\n default?: string;\n disabled?: string;\n focus?: string;\n hover?: string;\n readonly?: string;\n };\n fontSize?: string;\n fontWeight?: string;\n paddingBlock?: string;\n paddingInline?: string;\n };\n placeholder?: {\n color?: string;\n fontSize?: string;\n fontStyle?: string;\n fontWeight?: string;\n };\n }\n}\n\n// TODO: use DropdownOption type same as in select and multiselect\nexport type AutosuggestItem = (AutosuggestProps.Option | AutosuggestProps.OptionGroup) & {\n type?: 'parent' | 'child' | 'use-entered';\n option: OptionDefinition | OptionGroup;\n parent?: OptionGroup;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/autosuggest/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { BaseInputProps, InputAutoCorrect, InputClearLabel, InputKeyEvents, InputProps } from '../input/interfaces';\nimport { BaseComponentProps } from '../internal/base-component';\nimport {\n BaseDropdownHostProps,\n OptionsFilteringType,\n OptionsLoadItemsDetail,\n} from '../internal/components/dropdown/interfaces';\nimport { DropdownStatusProps } from '../internal/components/dropdown-status';\nimport { OptionDefinition, OptionGroup } from '../internal/components/option/interfaces';\nimport { FormFieldValidationControlProps } from '../internal/context/form-field-context';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface AutosuggestProps\n extends BaseComponentProps,\n BaseInputProps,\n InputAutoCorrect,\n BaseDropdownHostProps,\n InputKeyEvents,\n InputClearLabel,\n FormFieldValidationControlProps,\n DropdownStatusProps {\n /**\n * Specifies an array of options that are displayed to the user as a dropdown list.\n * The options can be grouped using `OptionGroup` objects.\n *\n * #### Option\n * - `value` (string) - The returned value of the option when selected.\n * - `label` (string) - (Optional) Option text displayed to the user.\n * - `lang` (string) - (Optional) The language of the option, provided as a BCP 47 language tag.\n * - `description` (string) - (Optional) Further information about the option that appears below the label.\n * - `disabled` (boolean) - (Optional) Determines whether the option is disabled.\n * - `labelTag` (string) - (Optional) A label tag that provides additional guidance, shown next to the label.\n * - `tags` [string[]] - (Optional) A list of tags giving further guidance about the option.\n * - `filteringTags` [string[]] - (Optional) A list of additional tags used for automatic filtering.\n * - `iconName` (string) - (Optional) Specifies the name of an [icon](/components/icon/) to display in the option.\n * - `iconAriaLabel` (string) - (Optional) Specifies alternate text for the icon. We recommend that you provide this for accessibility.\n * - `iconAlt` (string) - (Optional) **Deprecated**, replaced by \\`iconAriaLabel\\`. Specifies alternate text for a custom icon, for use with `iconUrl`.\n * - `iconUrl` (string) - (Optional) URL of a custom icon.\n * - `iconSvg` (ReactNode) - (Optional) Custom SVG icon. Equivalent to the `svg` slot of the [icon component](/components/icon/).\n *\n * #### OptionGroup\n * - `label` (string) - Option group text displayed to the user.\n * - `disabled` (boolean) - (Optional) Determines whether the option group is disabled.\n * - `options` (Option[]) - (Optional) The options under this group.\n *\n * Note: Only one level of option nesting is supported.\n *\n * If you want to use the built-in filtering capabilities of this component, provide\n * a list of all valid options here and they will be automatically filtered based on the user's filtering input.\n *\n * Alternatively, you can listen to the `onChange` or `onLoadItems` event and set new options\n * on your own.\n **/\n options?: AutosuggestProps.Options;\n /**\n * Determines how filtering is applied to the list of `options`:\n *\n * * `auto` - The component will automatically filter options based on user input.\n * * `manual` - You will set up `onChange` or `onLoadItems` event listeners and filter options on your side or request\n * them from server.\n *\n * By default the component will filter the provided `options` based on the value of the filtering input field.\n * Only options that have a `value`, `label`, `description` or `labelTag` that contains the input value as a substring\n * are displayed in the list of options.\n *\n * If you set this property to `manual`, this default filtering mechanism is disabled and all provided `options` are\n * displayed in the dropdown list. In that case make sure that you use the `onChange` or `onLoadItems` events in order\n * to set the `options` property to the options that are relevant for the user, given the filtering input value.\n *\n * Note: Manual filtering doesn't disable match highlighting.\n **/\n filteringType?: OptionsFilteringType;\n\n /**\n * Specifies a function that generates the custom value indicator (for example, `Use \"${value}\"`).\n * @i18n\n */\n enteredTextLabel?: AutosuggestProps.EnteredTextLabel;\n\n /**\n * Defines whether entered text option is shown as the first option in the dropdown when value is non-empty.\n */\n hideEnteredTextOption?: boolean;\n\n /**\n * Specifies the text to display with the number of matches at the bottom of the dropdown menu while filtering.\n *\n * Note that the `matchesCount` includes the `enteredTextLabel` (\"Use ${value}\") item, so in most cases you\n * should subtract 1 from `matchesCount`. If using manual filtering, you should provide your own value for `totalCount`.\n */\n filteringResultsText?: (matchesCount: number, totalCount: number) => string;\n\n /**\n * Specifies the text that's displayed when there aren't any suggestions to display.\n * This is displayed when `statusType` is set to `finished` or it's not set at all.\n */\n empty?: React.ReactNode;\n\n /**\n * Called whenever a user selects an option in the dropdown. Don't use this event as the only way to handle user input.\n * Instead, use `onSelect` in combination with the `onChange` handler only as an optional convenience for the user.\n */\n onSelect?: NonCancelableEventHandler<AutosuggestProps.SelectDetail>;\n\n /**\n * Specifies the localized string that describes an option as being selected.\n * This is required to provide a good screen reader experience. For more information, see the\n * [accessibility guidelines](/components/autosuggest/?tabId=usage#accessibility-guidelines).\n * @i18n\n */\n selectedAriaLabel?: string;\n /**\n * Overrides the element that is announced to screen readers\n * when the highlighted option changes. By default, this announces\n * the option's name and properties, and its selected state if\n * the `selectedAriaLabel` property is defined.\n * The highlighted option is provided, and its group (if groups\n * are used and it differs from the group of the previously highlighted option).\n *\n * For more information, see the\n * [accessibility guidelines](/components/autosuggest/?tabId=usage#accessibility-guidelines).\n */\n renderHighlightedAriaLive?: AutosuggestProps.ContainingOptionAndGroupString;\n\n /**\n * @awsuiSystem core\n */\n style?: AutosuggestProps.Style;\n}\n\nexport namespace AutosuggestProps {\n export type ChangeDetail = InputProps.ChangeDetail;\n export type KeyDetail = InputProps.KeyDetail;\n export type FilteringType = OptionsFilteringType;\n export type Option = OptionDefinition;\n export type Options = ReadonlyArray<Option | OptionGroup>;\n export type EnteredTextLabel = (value: string) => string;\n export interface OptionGroup extends Option {\n label?: string;\n options: ReadonlyArray<Option>;\n }\n export type LoadItemsDetail = OptionsLoadItemsDetail;\n export type StatusType = DropdownStatusProps.StatusType;\n export interface SelectDetail {\n value: string;\n selectedOption?: Option;\n }\n\n export interface ContainingOptionAndGroupString {\n (option: Option, group?: OptionGroup): string;\n }\n\n export interface Ref {\n /**\n * Sets input focus onto the UI control.\n */\n focus(): void;\n\n /**\n * Selects all text in the input control.\n */\n select(): void;\n }\n\n export interface Style {\n root?: {\n backgroundColor?: {\n default?: string;\n disabled?: string;\n focus?: string;\n hover?: string;\n readonly?: string;\n };\n borderColor?: {\n default?: string;\n disabled?: string;\n focus?: string;\n hover?: string;\n readonly?: string;\n };\n borderRadius?: string;\n borderWidth?: string;\n boxShadow?: {\n default?: string;\n disabled?: string;\n focus?: string;\n hover?: string;\n readonly?: string;\n };\n color?: {\n default?: string;\n disabled?: string;\n focus?: string;\n hover?: string;\n readonly?: string;\n };\n fontSize?: string;\n fontWeight?: string;\n paddingBlock?: string;\n paddingInline?: string;\n };\n placeholder?: {\n color?: string;\n fontSize?: string;\n fontStyle?: string;\n fontWeight?: string;\n };\n }\n}\n\n// TODO: use DropdownOption type same as in select and multiselect\nexport type AutosuggestItem = (AutosuggestProps.Option | AutosuggestProps.OptionGroup) & {\n type?: 'parent' | 'child' | 'use-entered';\n option: OptionDefinition | OptionGroup;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAmBhE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAElF,OAAO,EAAmB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAOjE,UAAU,wBAAyB,SAAQ,gBAAgB,EAAE,0BAA0B;CAAG;AAE1F,QAAA,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAmBhE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAElF,OAAO,EAAmB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAOjE,UAAU,wBAAyB,SAAQ,gBAAgB,EAAE,0BAA0B;CAAG;AAE1F,QAAA,MAAM,mBAAmB,uGA8OvB,CAAC;AAEH,eAAe,mBAAmB,CAAC"}
|
package/autosuggest/internal.js
CHANGED
|
@@ -17,7 +17,7 @@ import AutosuggestOptionsList from './options-list';
|
|
|
17
17
|
import styles from './styles.css.js';
|
|
18
18
|
const InternalAutosuggest = React.forwardRef((props, ref) => {
|
|
19
19
|
var _a, _b;
|
|
20
|
-
const { value, onChange, onBlur, onFocus, onKeyUp, onLoadItems, options, filteringType = 'auto', statusType = 'finished', placeholder, clearAriaLabel, name, disabled, disableBrowserAutocorrect = false, autoFocus, readOnly, ariaLabel, ariaRequired, enteredTextLabel, hideEnteredTextOption, filteringResultsText, onKeyDown, virtualScroll, expandToViewport, onSelect, renderHighlightedAriaLive, style,
|
|
20
|
+
const { value, onChange, onBlur, onFocus, onKeyUp, onLoadItems, options, filteringType = 'auto', statusType = 'finished', placeholder, clearAriaLabel, name, disabled, disableBrowserAutocorrect = false, autoFocus, readOnly, ariaLabel, ariaRequired, enteredTextLabel, hideEnteredTextOption, filteringResultsText, onKeyDown, virtualScroll, expandToViewport, onSelect, renderHighlightedAriaLive, style, __internalRootRef, ...restProps } = props;
|
|
21
21
|
checkControlled('Autosuggest', 'value', value, 'onChange', onChange);
|
|
22
22
|
checkOptionValueField('Autosuggest', 'options', options);
|
|
23
23
|
const autosuggestInputRef = useRef(null);
|
|
@@ -128,7 +128,7 @@ const InternalAutosuggest = React.forwardRef((props, ref) => {
|
|
|
128
128
|
const shouldRenderDropdownContent = autosuggestItemsState.items.length !== 0 || !!dropdownStatus.content || (!hideEnteredTextOption && !!value);
|
|
129
129
|
const hasItems = useRef(autosuggestItemsState.items.length > 0);
|
|
130
130
|
hasItems.current = hasItems.current || autosuggestItemsState.items.length > 0;
|
|
131
|
-
return (React.createElement(AutosuggestInput, { ...restProps, className: clsx(styles.root, restProps.className), ref: autosuggestInputRef, __internalRootRef: __internalRootRef, value: value, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyUp: handleKeyUp, onKeyDown: handleKeyDown, name: name, controlId: controlId, placeholder: placeholder, disabled: disabled, readOnly: readOnly, autoFocus: autoFocus, ariaLabel: ariaLabel, ariaRequired: ariaRequired, clearAriaLabel: clearAriaLabel, disableBrowserAutocorrect: disableBrowserAutocorrect, expandToViewport: expandToViewport, ariaControls: listId, ariaActivedescendant: highlightedOptionId, dropdownExpanded: shouldRenderDropdownContent, style: style, dropdownContent: shouldRenderDropdownContent && (React.createElement(AutosuggestOptionsList, {
|
|
131
|
+
return (React.createElement(AutosuggestInput, { ...restProps, className: clsx(styles.root, restProps.className), ref: autosuggestInputRef, __internalRootRef: __internalRootRef, value: value, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyUp: handleKeyUp, onKeyDown: handleKeyDown, name: name, controlId: controlId, placeholder: placeholder, disabled: disabled, readOnly: readOnly, autoFocus: autoFocus, ariaLabel: ariaLabel, ariaRequired: ariaRequired, clearAriaLabel: clearAriaLabel, disableBrowserAutocorrect: disableBrowserAutocorrect, expandToViewport: expandToViewport, ariaControls: listId, ariaActivedescendant: highlightedOptionId, dropdownExpanded: shouldRenderDropdownContent, style: style, dropdownContent: shouldRenderDropdownContent && (React.createElement(AutosuggestOptionsList, { statusType: statusType, autosuggestItemsState: autosuggestItemsState, autosuggestItemsHandlers: autosuggestItemsHandlers, highlightedOptionId: highlightedOptionId, highlightText: value, listId: listId, controlId: controlId, handleLoadMore: autosuggestLoadMoreHandlers.fireLoadMoreOnScroll, hasDropdownStatus: dropdownStatus.content !== null, virtualScroll: virtualScroll, selectedAriaLabel: selectedAriaLabel, renderHighlightedAriaLive: renderHighlightedAriaLive, listBottom: !dropdownStatus.isSticky ? React.createElement(DropdownFooter, { content: dropdownStatus.content, id: footerControlId }) : null, ariaDescribedby: dropdownStatus.content ? footerControlId : undefined })), dropdownFooter: dropdownStatus.isSticky && dropdownStatus.content ? (React.createElement(DropdownFooter, { id: footerControlId, content: dropdownStatus.content, hasItems: autosuggestItemsState.items.length >= 1 })) : null,
|
|
132
132
|
// Forces dropdown position recalculation when new options are loaded
|
|
133
133
|
dropdownContentKey: hasItems.current.toString(), loopFocus: dropdownStatus.hasRecoveryButton, onCloseDropdown: handleCloseDropdown, onDelayedInput: handleDelayedInput, onPressArrowDown: handlePressArrowDown, onPressArrowUp: handlePressArrowUp, onPressEnter: handlePressEnter }));
|
|
134
134
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/autosuggest/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAO,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OA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AAc,CAAC,OAAO,KAAK,IAAI,EAClD,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,iBAAiB,EACpC,yBAAyB,EAAE,yBAAyB,EACpD,UAAU,EACR,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,oBAAC,cAAc,IAAC,OAAO,EAAE,cAAc,CAAC,OAAO,EAAE,EAAE,EAAE,eAAe,GAAI,CAAC,CAAC,CAAC,IAAI,EAE5G,eAAe,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,GACrE,CACH,EAEH,cAAc,EACZ,cAAc,CAAC,QAAQ,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAClD,oBAAC,cAAc,IACb,EAAE,EAAE,eAAe,EACnB,OAAO,EAAE,cAAc,CAAC,OAAO,EAC/B,QAAQ,EAAE,qBAAqB,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,GACjD,CACH,CAAC,CAAC,CAAC,IAAI;QAEV,qEAAqE;QACrE,kBAAkB,EAAE,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,EAC/C,SAAS,EAAE,cAAc,CAAC,iBAAiB,EAC3C,eAAe,EAAE,mBAAmB,EACpC,cAAc,EAAE,kBAAkB,EAClC,gBAAgB,EAAE,oBAAoB,EACtC,cAAc,EAAE,kBAAkB,EAClC,YAAY,EAAE,gBAAgB,GAC9B,CACH,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\n\nimport React, { Ref, useImperativeHandle, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useUniqueId, warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useFormFieldContext } from '../contexts/form-field';\nimport { useInternalI18n } from '../i18n/context';\nimport { BaseChangeDetail } from '../input/interfaces';\nimport AutosuggestInput, { AutosuggestInputRef } from '../internal/components/autosuggest-input';\nimport { OptionsLoadItemsDetail } from '../internal/components/dropdown/interfaces';\nimport DropdownFooter from '../internal/components/dropdown-footer';\nimport { useDropdownStatus } from '../internal/components/dropdown-status';\nimport {\n BaseKeyDetail,\n fireCancelableEvent,\n fireNonCancelableEvent,\n NonCancelableCustomEvent,\n} from '../internal/events';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { checkOptionValueField } from '../select/utils/check-option-value-field';\nimport { AutosuggestItem, AutosuggestProps } from './interfaces';\nimport { useAutosuggestLoadMore } from './load-more-controller';\nimport { useAutosuggestItems } from './options-controller';\nimport AutosuggestOptionsList from './options-list';\n\nimport styles from './styles.css.js';\n\ninterface InternalAutosuggestProps extends AutosuggestProps, InternalBaseComponentProps {}\n\nconst InternalAutosuggest = React.forwardRef((props: InternalAutosuggestProps, ref: Ref<AutosuggestProps.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 clearAriaLabel,\n name,\n disabled,\n disableBrowserAutocorrect = false,\n autoFocus,\n readOnly,\n ariaLabel,\n ariaRequired,\n enteredTextLabel,\n hideEnteredTextOption,\n filteringResultsText,\n onKeyDown,\n virtualScroll,\n expandToViewport,\n onSelect,\n renderHighlightedAriaLive,\n style,\n renderOption,\n __internalRootRef,\n ...restProps\n } = props;\n\n checkControlled('Autosuggest', 'value', value, 'onChange', onChange);\n checkOptionValueField('Autosuggest', 'options', options);\n\n const autosuggestInputRef = useRef<AutosuggestInputRef>(null);\n useImperativeHandle(\n ref,\n () => ({\n focus: () => autosuggestInputRef.current?.focus(),\n select: () => autosuggestInputRef.current?.select(),\n }),\n []\n );\n\n const i18n = useInternalI18n('autosuggest');\n const errorIconAriaLabel = i18n('errorIconAriaLabel', restProps.errorIconAriaLabel);\n const selectedAriaLabel = i18n('selectedAriaLabel', restProps.selectedAriaLabel);\n const recoveryText = i18n('recoveryText', restProps.recoveryText);\n\n if (restProps.recoveryText && !onLoadItems) {\n warnOnce('Autosuggest', '`onLoadItems` must be provided for `recoveryText` to be displayed.');\n }\n\n const [autosuggestItemsState, autosuggestItemsHandlers] = useAutosuggestItems({\n options: options || [],\n filterValue: value,\n filterText: value,\n filteringType,\n enteredTextLabel,\n hideEnteredTextLabel: hideEnteredTextOption,\n onSelectItem: (option: AutosuggestItem) => {\n const value = option.value || '';\n fireNonCancelableEvent(onChange, { value });\n fireNonCancelableEvent(onSelect, {\n value,\n selectedOption: option.type !== 'use-entered' ? option.option : undefined,\n });\n autosuggestInputRef.current?.close();\n },\n });\n\n const autosuggestLoadMoreHandlers = useAutosuggestLoadMore({\n options,\n statusType,\n onLoadItems: (detail: OptionsLoadItemsDetail) => fireNonCancelableEvent(onLoadItems, detail),\n });\n\n const handleChange = (event: NonCancelableCustomEvent<BaseChangeDetail>) => {\n autosuggestItemsHandlers.setShowAll(false);\n autosuggestItemsHandlers.resetHighlightWithKeyboard();\n fireNonCancelableEvent(onChange, event.detail);\n };\n\n const handleDelayedInput = (event: NonCancelableCustomEvent<BaseChangeDetail>) => {\n autosuggestLoadMoreHandlers.fireLoadMoreOnInputChange(event.detail.value);\n };\n\n const handleBlur = () => {\n fireNonCancelableEvent(onBlur, null);\n };\n\n const handleFocus = () => {\n autosuggestItemsHandlers.setShowAll(true);\n autosuggestLoadMoreHandlers.fireLoadMoreOnInputFocus();\n fireNonCancelableEvent(onFocus, null);\n };\n\n const handleKeyUp = (event: CustomEvent<BaseKeyDetail>) => {\n fireCancelableEvent(onKeyUp, event.detail, event);\n };\n\n const handleKeyDown = (event: CustomEvent<BaseKeyDetail>) => {\n fireCancelableEvent(onKeyDown, event.detail, event);\n };\n\n const handlePressArrowDown = () => {\n if (autosuggestItemsState.items.length - 1 === autosuggestItemsState.highlightedIndex) {\n autosuggestItemsHandlers.goHomeWithKeyboard();\n return;\n }\n\n autosuggestItemsHandlers.moveHighlightWithKeyboard(1);\n };\n\n const handlePressArrowUp = () => {\n if (\n (autosuggestItemsState.highlightedOption?.type === 'child' && autosuggestItemsState.highlightedIndex === 1) ||\n autosuggestItemsState.highlightedIndex === 0\n ) {\n autosuggestItemsHandlers.goEndWithKeyboard();\n return;\n }\n\n autosuggestItemsHandlers.moveHighlightWithKeyboard(-1);\n };\n\n const handlePressEnter = () => {\n return autosuggestItemsHandlers.selectHighlightedOptionWithKeyboard();\n };\n\n const handleCloseDropdown = () => {\n autosuggestItemsHandlers.resetHighlightWithKeyboard();\n };\n\n const handleRecoveryClick = () => {\n autosuggestLoadMoreHandlers.fireLoadMoreOnRecoveryClick();\n autosuggestInputRef.current?.focus();\n };\n\n const formFieldContext = useFormFieldContext(restProps);\n const selfControlId = useUniqueId('input');\n const footerControlId = useUniqueId('footer');\n const controlId = formFieldContext.controlId ?? selfControlId;\n const listId = useUniqueId('list');\n const highlightedOptionIdSource = useUniqueId();\n const highlightedOptionId = autosuggestItemsState.highlightedOption ? highlightedOptionIdSource : undefined;\n\n const isEmpty = !value && !autosuggestItemsState.items.length;\n const isFiltered = !!value && value.length !== 0 && !(filteringType === 'auto' && autosuggestItemsState.showAll);\n const filteredText = isFiltered\n ? filteringResultsText?.(autosuggestItemsState.items.length, options?.length ?? 0)\n : undefined;\n const dropdownStatus = useDropdownStatus({\n ...props,\n isEmpty,\n recoveryText,\n errorIconAriaLabel,\n onRecoveryClick: handleRecoveryClick,\n filteringResultsText: filteredText,\n hasRecoveryCallback: !!onLoadItems,\n });\n\n const shouldRenderDropdownContent =\n autosuggestItemsState.items.length !== 0 || !!dropdownStatus.content || (!hideEnteredTextOption && !!value);\n\n const hasItems = useRef(autosuggestItemsState.items.length > 0);\n hasItems.current = hasItems.current || autosuggestItemsState.items.length > 0;\n\n return (\n <AutosuggestInput\n {...restProps}\n className={clsx(styles.root, restProps.className)}\n ref={autosuggestInputRef}\n __internalRootRef={__internalRootRef}\n value={value}\n onChange={handleChange}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyUp={handleKeyUp}\n onKeyDown={handleKeyDown}\n name={name}\n controlId={controlId}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readOnly}\n autoFocus={autoFocus}\n ariaLabel={ariaLabel}\n ariaRequired={ariaRequired}\n clearAriaLabel={clearAriaLabel}\n disableBrowserAutocorrect={disableBrowserAutocorrect}\n expandToViewport={expandToViewport}\n ariaControls={listId}\n ariaActivedescendant={highlightedOptionId}\n dropdownExpanded={shouldRenderDropdownContent}\n style={style}\n dropdownContent={\n shouldRenderDropdownContent && (\n <AutosuggestOptionsList\n renderOption={renderOption}\n statusType={statusType}\n autosuggestItemsState={autosuggestItemsState}\n autosuggestItemsHandlers={autosuggestItemsHandlers}\n highlightedOptionId={highlightedOptionId}\n highlightText={value}\n listId={listId}\n controlId={controlId}\n handleLoadMore={autosuggestLoadMoreHandlers.fireLoadMoreOnScroll}\n hasDropdownStatus={dropdownStatus.content !== null}\n virtualScroll={virtualScroll}\n selectedAriaLabel={selectedAriaLabel}\n renderHighlightedAriaLive={renderHighlightedAriaLive}\n listBottom={\n !dropdownStatus.isSticky ? <DropdownFooter content={dropdownStatus.content} id={footerControlId} /> : null\n }\n ariaDescribedby={dropdownStatus.content ? footerControlId : undefined}\n />\n )\n }\n dropdownFooter={\n dropdownStatus.isSticky && dropdownStatus.content ? (\n <DropdownFooter\n id={footerControlId}\n content={dropdownStatus.content}\n hasItems={autosuggestItemsState.items.length >= 1}\n />\n ) : null\n }\n // Forces dropdown position recalculation when new options are loaded\n dropdownContentKey={hasItems.current.toString()}\n loopFocus={dropdownStatus.hasRecoveryButton}\n onCloseDropdown={handleCloseDropdown}\n onDelayedInput={handleDelayedInput}\n onPressArrowDown={handlePressArrowDown}\n onPressArrowUp={handlePressArrowUp}\n onPressEnter={handlePressEnter}\n />\n );\n});\n\nexport default InternalAutosuggest;\n"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/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mBAAmB,EACxC,aAAa,EAAE,KAAK,EACpB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,2BAA2B,CAAC,oBAAoB,EAChE,iBAAiB,EAAE,cAAc,CAAC,OAAO,KAAK,IAAI,EAClD,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,iBAAiB,EACpC,yBAAyB,EAAE,yBAAyB,EACpD,UAAU,EACR,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,oBAAC,cAAc,IAAC,OAAO,EAAE,cAAc,CAAC,OAAO,EAAE,EAAE,EAAE,eAAe,GAAI,CAAC,CAAC,CAAC,IAAI,EAE5G,eAAe,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,GACrE,CACH,EAEH,cAAc,EACZ,cAAc,CAAC,QAAQ,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAClD,oBAAC,cAAc,IACb,EAAE,EAAE,eAAe,EACnB,OAAO,EAAE,cAAc,CAAC,OAAO,EAC/B,QAAQ,EAAE,qBAAqB,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,GACjD,CACH,CAAC,CAAC,CAAC,IAAI;QAEV,qEAAqE;QACrE,kBAAkB,EAAE,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,EAC/C,SAAS,EAAE,cAAc,CAAC,iBAAiB,EAC3C,eAAe,EAAE,mBAAmB,EACpC,cAAc,EAAE,kBAAkB,EAClC,gBAAgB,EAAE,oBAAoB,EACtC,cAAc,EAAE,kBAAkB,EAClC,YAAY,EAAE,gBAAgB,GAC9B,CACH,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\n\nimport React, { Ref, useImperativeHandle, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useUniqueId, warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useFormFieldContext } from '../contexts/form-field';\nimport { useInternalI18n } from '../i18n/context';\nimport { BaseChangeDetail } from '../input/interfaces';\nimport AutosuggestInput, { AutosuggestInputRef } from '../internal/components/autosuggest-input';\nimport { OptionsLoadItemsDetail } from '../internal/components/dropdown/interfaces';\nimport DropdownFooter from '../internal/components/dropdown-footer';\nimport { useDropdownStatus } from '../internal/components/dropdown-status';\nimport {\n BaseKeyDetail,\n fireCancelableEvent,\n fireNonCancelableEvent,\n NonCancelableCustomEvent,\n} from '../internal/events';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { checkOptionValueField } from '../select/utils/check-option-value-field';\nimport { AutosuggestItem, AutosuggestProps } from './interfaces';\nimport { useAutosuggestLoadMore } from './load-more-controller';\nimport { useAutosuggestItems } from './options-controller';\nimport AutosuggestOptionsList from './options-list';\n\nimport styles from './styles.css.js';\n\ninterface InternalAutosuggestProps extends AutosuggestProps, InternalBaseComponentProps {}\n\nconst InternalAutosuggest = React.forwardRef((props: InternalAutosuggestProps, ref: Ref<AutosuggestProps.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 clearAriaLabel,\n name,\n disabled,\n disableBrowserAutocorrect = false,\n autoFocus,\n readOnly,\n ariaLabel,\n ariaRequired,\n enteredTextLabel,\n hideEnteredTextOption,\n filteringResultsText,\n onKeyDown,\n virtualScroll,\n expandToViewport,\n onSelect,\n renderHighlightedAriaLive,\n style,\n __internalRootRef,\n ...restProps\n } = props;\n\n checkControlled('Autosuggest', 'value', value, 'onChange', onChange);\n checkOptionValueField('Autosuggest', 'options', options);\n\n const autosuggestInputRef = useRef<AutosuggestInputRef>(null);\n useImperativeHandle(\n ref,\n () => ({\n focus: () => autosuggestInputRef.current?.focus(),\n select: () => autosuggestInputRef.current?.select(),\n }),\n []\n );\n\n const i18n = useInternalI18n('autosuggest');\n const errorIconAriaLabel = i18n('errorIconAriaLabel', restProps.errorIconAriaLabel);\n const selectedAriaLabel = i18n('selectedAriaLabel', restProps.selectedAriaLabel);\n const recoveryText = i18n('recoveryText', restProps.recoveryText);\n\n if (restProps.recoveryText && !onLoadItems) {\n warnOnce('Autosuggest', '`onLoadItems` must be provided for `recoveryText` to be displayed.');\n }\n\n const [autosuggestItemsState, autosuggestItemsHandlers] = useAutosuggestItems({\n options: options || [],\n filterValue: value,\n filterText: value,\n filteringType,\n enteredTextLabel,\n hideEnteredTextLabel: hideEnteredTextOption,\n onSelectItem: (option: AutosuggestItem) => {\n const value = option.value || '';\n fireNonCancelableEvent(onChange, { value });\n fireNonCancelableEvent(onSelect, {\n value,\n selectedOption: option.type !== 'use-entered' ? option.option : undefined,\n });\n autosuggestInputRef.current?.close();\n },\n });\n\n const autosuggestLoadMoreHandlers = useAutosuggestLoadMore({\n options,\n statusType,\n onLoadItems: (detail: OptionsLoadItemsDetail) => fireNonCancelableEvent(onLoadItems, detail),\n });\n\n const handleChange = (event: NonCancelableCustomEvent<BaseChangeDetail>) => {\n autosuggestItemsHandlers.setShowAll(false);\n autosuggestItemsHandlers.resetHighlightWithKeyboard();\n fireNonCancelableEvent(onChange, event.detail);\n };\n\n const handleDelayedInput = (event: NonCancelableCustomEvent<BaseChangeDetail>) => {\n autosuggestLoadMoreHandlers.fireLoadMoreOnInputChange(event.detail.value);\n };\n\n const handleBlur = () => {\n fireNonCancelableEvent(onBlur, null);\n };\n\n const handleFocus = () => {\n autosuggestItemsHandlers.setShowAll(true);\n autosuggestLoadMoreHandlers.fireLoadMoreOnInputFocus();\n fireNonCancelableEvent(onFocus, null);\n };\n\n const handleKeyUp = (event: CustomEvent<BaseKeyDetail>) => {\n fireCancelableEvent(onKeyUp, event.detail, event);\n };\n\n const handleKeyDown = (event: CustomEvent<BaseKeyDetail>) => {\n fireCancelableEvent(onKeyDown, event.detail, event);\n };\n\n const handlePressArrowDown = () => {\n if (autosuggestItemsState.items.length - 1 === autosuggestItemsState.highlightedIndex) {\n autosuggestItemsHandlers.goHomeWithKeyboard();\n return;\n }\n\n autosuggestItemsHandlers.moveHighlightWithKeyboard(1);\n };\n\n const handlePressArrowUp = () => {\n if (\n (autosuggestItemsState.highlightedOption?.type === 'child' && autosuggestItemsState.highlightedIndex === 1) ||\n autosuggestItemsState.highlightedIndex === 0\n ) {\n autosuggestItemsHandlers.goEndWithKeyboard();\n return;\n }\n\n autosuggestItemsHandlers.moveHighlightWithKeyboard(-1);\n };\n\n const handlePressEnter = () => {\n return autosuggestItemsHandlers.selectHighlightedOptionWithKeyboard();\n };\n\n const handleCloseDropdown = () => {\n autosuggestItemsHandlers.resetHighlightWithKeyboard();\n };\n\n const handleRecoveryClick = () => {\n autosuggestLoadMoreHandlers.fireLoadMoreOnRecoveryClick();\n autosuggestInputRef.current?.focus();\n };\n\n const formFieldContext = useFormFieldContext(restProps);\n const selfControlId = useUniqueId('input');\n const footerControlId = useUniqueId('footer');\n const controlId = formFieldContext.controlId ?? selfControlId;\n const listId = useUniqueId('list');\n const highlightedOptionIdSource = useUniqueId();\n const highlightedOptionId = autosuggestItemsState.highlightedOption ? highlightedOptionIdSource : undefined;\n\n const isEmpty = !value && !autosuggestItemsState.items.length;\n const isFiltered = !!value && value.length !== 0 && !(filteringType === 'auto' && autosuggestItemsState.showAll);\n const filteredText = isFiltered\n ? filteringResultsText?.(autosuggestItemsState.items.length, options?.length ?? 0)\n : undefined;\n const dropdownStatus = useDropdownStatus({\n ...props,\n isEmpty,\n recoveryText,\n errorIconAriaLabel,\n onRecoveryClick: handleRecoveryClick,\n filteringResultsText: filteredText,\n hasRecoveryCallback: !!onLoadItems,\n });\n\n const shouldRenderDropdownContent =\n autosuggestItemsState.items.length !== 0 || !!dropdownStatus.content || (!hideEnteredTextOption && !!value);\n\n const hasItems = useRef(autosuggestItemsState.items.length > 0);\n hasItems.current = hasItems.current || autosuggestItemsState.items.length > 0;\n\n return (\n <AutosuggestInput\n {...restProps}\n className={clsx(styles.root, restProps.className)}\n ref={autosuggestInputRef}\n __internalRootRef={__internalRootRef}\n value={value}\n onChange={handleChange}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyUp={handleKeyUp}\n onKeyDown={handleKeyDown}\n name={name}\n controlId={controlId}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readOnly}\n autoFocus={autoFocus}\n ariaLabel={ariaLabel}\n ariaRequired={ariaRequired}\n clearAriaLabel={clearAriaLabel}\n disableBrowserAutocorrect={disableBrowserAutocorrect}\n expandToViewport={expandToViewport}\n ariaControls={listId}\n ariaActivedescendant={highlightedOptionId}\n dropdownExpanded={shouldRenderDropdownContent}\n style={style}\n dropdownContent={\n shouldRenderDropdownContent && (\n <AutosuggestOptionsList\n statusType={statusType}\n autosuggestItemsState={autosuggestItemsState}\n autosuggestItemsHandlers={autosuggestItemsHandlers}\n highlightedOptionId={highlightedOptionId}\n highlightText={value}\n listId={listId}\n controlId={controlId}\n handleLoadMore={autosuggestLoadMoreHandlers.fireLoadMoreOnScroll}\n hasDropdownStatus={dropdownStatus.content !== null}\n virtualScroll={virtualScroll}\n selectedAriaLabel={selectedAriaLabel}\n renderHighlightedAriaLive={renderHighlightedAriaLive}\n listBottom={\n !dropdownStatus.isSticky ? <DropdownFooter content={dropdownStatus.content} id={footerControlId} /> : null\n }\n ariaDescribedby={dropdownStatus.content ? footerControlId : undefined}\n />\n )\n }\n dropdownFooter={\n dropdownStatus.isSticky && dropdownStatus.content ? (\n <DropdownFooter\n id={footerControlId}\n content={dropdownStatus.content}\n hasItems={autosuggestItemsState.items.length >= 1}\n />\n ) : null\n }\n // Forces dropdown position recalculation when new options are loaded\n dropdownContentKey={hasItems.current.toString()}\n loopFocus={dropdownStatus.hasRecoveryButton}\n onCloseDropdown={handleCloseDropdown}\n onDelayedInput={handleDelayedInput}\n onPressArrowDown={handlePressArrowDown}\n onPressArrowUp={handlePressArrowUp}\n onPressEnter={handlePressEnter}\n />\n );\n});\n\nexport default InternalAutosuggest;\n"]}
|
|
@@ -1 +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;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wDAAwD,CAAC;AAC7F,OAAO,EAGL,oBAAoB,GACrB,MAAM,gEAAgE,CAAC;AAExE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AA2B9C,MAAM,eAAe,GAAG,CAAC,MAAwB,EAAE,EAAE;IACnD,OAAO,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC9C,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,MAAwB,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;AAE7G,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAClC,OAAO,EACP,WAAW,EACX,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,GACa,EAAqD,EAAE;IAChF,MAAM,IAAI,GAAG,eAAe,CAAC,aAAa,CAAC,CAAC;IAC5C,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE9C,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC,OAA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AC,QAAQ,IAAI,uBAAuB,CAAC;QAEjE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,OAAO,CAAC,aAAsC;IACrD,OAAO,SAAS,IAAI,aAAa,CAAC;AACpC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useMemo, useState } from 'react';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useInternalI18n } from '../i18n/context';\nimport { generateTestIndexes } from '../internal/components/options-list/utils/test-indexes';\nimport {\n HighlightedOptionHandlers,\n HighlightedOptionState,\n useHighlightedOption,\n} from '../internal/components/options-list/utils/use-highlight-option';\nimport { AutosuggestItem, AutosuggestProps } from './interfaces';\nimport { filterOptions } from './utils/utils';\n\ntype Options = AutosuggestProps.Options;\n\nexport interface UseAutosuggestItemsProps {\n options: Options;\n filterValue: string;\n filterText: string;\n filteringType: AutosuggestProps.FilteringType;\n enteredTextLabel?: AutosuggestProps.EnteredTextLabel;\n hideEnteredTextLabel?: boolean;\n onSelectItem: (option: AutosuggestItem) => void;\n}\n\nexport interface AutosuggestItemsState extends HighlightedOptionState<AutosuggestItem> {\n items: readonly AutosuggestItem[];\n showAll: boolean;\n getItemGroup: (item: AutosuggestItem) => undefined | AutosuggestProps.OptionGroup;\n}\n\nexport interface AutosuggestItemsHandlers extends HighlightedOptionHandlers<AutosuggestItem> {\n setShowAll(value: boolean): void;\n selectHighlightedOptionWithKeyboard(): boolean;\n highlightVisibleOptionWithMouse(index: number): void;\n selectVisibleOptionWithMouse(index: number): void;\n}\n\nconst isHighlightable = (option?: AutosuggestItem) => {\n return !!option && option.type !== 'parent';\n};\n\nconst isInteractive = (option?: AutosuggestItem) => !!option && !option.disabled && option.type !== 'parent';\n\nexport const useAutosuggestItems = ({\n options,\n filterValue,\n filterText,\n filteringType,\n enteredTextLabel,\n hideEnteredTextLabel,\n onSelectItem,\n}: UseAutosuggestItemsProps): [AutosuggestItemsState, AutosuggestItemsHandlers] => {\n const i18n = useInternalI18n('autosuggest');\n const [showAll, setShowAll] = useState(false);\n\n const { items, getItemGroup, getItemParent } = useMemo(() => createItems(options), [options]);\n\n const enteredItemLabel = i18n('enteredTextLabel', enteredTextLabel?.(filterValue), format =>\n format({ value: filterValue })\n );\n\n if (!enteredItemLabel) {\n warnOnce('Autosuggest', 'A value for enteredTextLabel must be provided.');\n }\n\n const filteredItems = useMemo(() => {\n const filteredItems = filteringType === 'auto' && !showAll ? filterOptions(items, filterText) : [...items];\n if (filterValue && !hideEnteredTextLabel) {\n filteredItems.unshift({\n value: filterValue,\n type: 'use-entered',\n label: enteredItemLabel,\n option: { value: filterValue },\n });\n }\n generateTestIndexes(filteredItems, getItemParent);\n return filteredItems;\n }, [filteringType, showAll, items, filterText, filterValue, hideEnteredTextLabel, getItemParent, enteredItemLabel]);\n\n const [highlightedOptionState, highlightedOptionHandlers] = useHighlightedOption({\n options: filteredItems,\n isHighlightable,\n });\n\n const selectHighlightedOptionWithKeyboard = () => {\n if (highlightedOptionState.highlightedOption && !isInteractive(highlightedOptionState.highlightedOption)) {\n // skip selection when a non-interactive item is active\n return false;\n }\n onSelectItem(\n highlightedOptionState.highlightedOption ?? {\n // put use-entered item as a fallback\n value: filterValue,\n type: 'use-entered',\n option: { value: filterValue },\n }\n );\n return true;\n };\n\n const highlightVisibleOptionWithMouse = (index: number) => {\n if (filteredItems[index] && isHighlightable(filteredItems[index])) {\n highlightedOptionHandlers.setHighlightedIndexWithMouse(index);\n }\n };\n\n const selectVisibleOptionWithMouse = (index: number) => {\n if (filteredItems[index] && isInteractive(filteredItems[index])) {\n onSelectItem(filteredItems[index]);\n }\n };\n\n return [\n { ...highlightedOptionState, items: filteredItems, showAll, getItemGroup },\n {\n ...highlightedOptionHandlers,\n setShowAll,\n selectHighlightedOptionWithKeyboard,\n highlightVisibleOptionWithMouse,\n selectVisibleOptionWithMouse,\n },\n ];\n};\n\nfunction createItems(options: Options) {\n const items: AutosuggestItem[] = [];\n const itemToGroup = new WeakMap<AutosuggestItem, AutosuggestItem>();\n const getItemParent = (item: AutosuggestItem) => itemToGroup.get(item);\n const getItemGroup = (item: AutosuggestItem) => getItemParent(item)?.option as AutosuggestProps.OptionGroup;\n\n for (const option of options) {\n if (isGroup(option)) {\n for (const item of flattenGroup(option)) {\n items.push(item);\n }\n } else {\n items.push({ ...option, option });\n }\n }\n\n function flattenGroup(group: AutosuggestProps.OptionGroup) {\n const { options, ...rest } = group;\n\n let hasOnlyDisabledChildren = true;\n\n const groupItem: AutosuggestItem = { ...rest, type: 'parent', option: group };\n\n const items: AutosuggestItem[] = [groupItem];\n\n for (const option of options) {\n if (!option.disabled) {\n hasOnlyDisabledChildren = false;\n }\n\n const childOption: AutosuggestItem = {\n ...option,\n type: 'child',\n disabled: option.disabled || rest.disabled,\n option,\n parent: group,\n };\n\n items.push(childOption);\n\n itemToGroup.set(childOption, groupItem);\n }\n\n items[0].disabled = items[0].disabled || hasOnlyDisabledChildren;\n\n return items;\n }\n\n return { items, getItemGroup, getItemParent };\n}\n\nfunction isGroup(optionOrGroup: AutosuggestProps.Option): optionOrGroup is AutosuggestProps.OptionGroup {\n return 'options' in optionOrGroup;\n}\n"]}
|
|
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;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wDAAwD,CAAC;AAC7F,OAAO,EAGL,oBAAoB,GACrB,MAAM,gEAAgE,CAAC;AAExE,OAA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I,EAAE,GAAG,KAAK,CAAC;QAEnC,IAAI,uBAAuB,GAAG,IAAI,CAAC;QAEnC,MAAM,SAAS,GAAoB,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QAE9E,MAAM,KAAK,GAAsB,CAAC,SAAS,CAAC,CAAC;QAE7C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACrB,uBAAuB,GAAG,KAAK,CAAC;YAClC,CAAC;YAED,MAAM,WAAW,GAAoB;gBACnC,GAAG,MAAM;gBACT,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ;gBAC1C,MAAM;aACP,CAAC;YAEF,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAExB,WAAW,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QAC1C,CAAC;QAED,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,IAAI,uBAAuB,CAAC;QAEjE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,OAAO,CAAC,aAAsC;IACrD,OAAO,SAAS,IAAI,aAAa,CAAC;AACpC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useMemo, useState } from 'react';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useInternalI18n } from '../i18n/context';\nimport { generateTestIndexes } from '../internal/components/options-list/utils/test-indexes';\nimport {\n HighlightedOptionHandlers,\n HighlightedOptionState,\n useHighlightedOption,\n} from '../internal/components/options-list/utils/use-highlight-option';\nimport { AutosuggestItem, AutosuggestProps } from './interfaces';\nimport { filterOptions } from './utils/utils';\n\ntype Options = AutosuggestProps.Options;\n\nexport interface UseAutosuggestItemsProps {\n options: Options;\n filterValue: string;\n filterText: string;\n filteringType: AutosuggestProps.FilteringType;\n enteredTextLabel?: AutosuggestProps.EnteredTextLabel;\n hideEnteredTextLabel?: boolean;\n onSelectItem: (option: AutosuggestItem) => void;\n}\n\nexport interface AutosuggestItemsState extends HighlightedOptionState<AutosuggestItem> {\n items: readonly AutosuggestItem[];\n showAll: boolean;\n getItemGroup: (item: AutosuggestItem) => undefined | AutosuggestProps.OptionGroup;\n}\n\nexport interface AutosuggestItemsHandlers extends HighlightedOptionHandlers<AutosuggestItem> {\n setShowAll(value: boolean): void;\n selectHighlightedOptionWithKeyboard(): boolean;\n highlightVisibleOptionWithMouse(index: number): void;\n selectVisibleOptionWithMouse(index: number): void;\n}\n\nconst isHighlightable = (option?: AutosuggestItem) => {\n return !!option && option.type !== 'parent';\n};\n\nconst isInteractive = (option?: AutosuggestItem) => !!option && !option.disabled && option.type !== 'parent';\n\nexport const useAutosuggestItems = ({\n options,\n filterValue,\n filterText,\n filteringType,\n enteredTextLabel,\n hideEnteredTextLabel,\n onSelectItem,\n}: UseAutosuggestItemsProps): [AutosuggestItemsState, AutosuggestItemsHandlers] => {\n const i18n = useInternalI18n('autosuggest');\n const [showAll, setShowAll] = useState(false);\n\n const { items, getItemGroup, getItemParent } = useMemo(() => createItems(options), [options]);\n\n const enteredItemLabel = i18n('enteredTextLabel', enteredTextLabel?.(filterValue), format =>\n format({ value: filterValue })\n );\n\n if (!enteredItemLabel) {\n warnOnce('Autosuggest', 'A value for enteredTextLabel must be provided.');\n }\n\n const filteredItems = useMemo(() => {\n const filteredItems = filteringType === 'auto' && !showAll ? filterOptions(items, filterText) : [...items];\n if (filterValue && !hideEnteredTextLabel) {\n filteredItems.unshift({\n value: filterValue,\n type: 'use-entered',\n label: enteredItemLabel,\n option: { value: filterValue },\n });\n }\n generateTestIndexes(filteredItems, getItemParent);\n return filteredItems;\n }, [filteringType, showAll, items, filterText, filterValue, hideEnteredTextLabel, getItemParent, enteredItemLabel]);\n\n const [highlightedOptionState, highlightedOptionHandlers] = useHighlightedOption({\n options: filteredItems,\n isHighlightable,\n });\n\n const selectHighlightedOptionWithKeyboard = () => {\n if (highlightedOptionState.highlightedOption && !isInteractive(highlightedOptionState.highlightedOption)) {\n // skip selection when a non-interactive item is active\n return false;\n }\n onSelectItem(\n highlightedOptionState.highlightedOption ?? {\n // put use-entered item as a fallback\n value: filterValue,\n type: 'use-entered',\n option: { value: filterValue },\n }\n );\n return true;\n };\n\n const highlightVisibleOptionWithMouse = (index: number) => {\n if (filteredItems[index] && isHighlightable(filteredItems[index])) {\n highlightedOptionHandlers.setHighlightedIndexWithMouse(index);\n }\n };\n\n const selectVisibleOptionWithMouse = (index: number) => {\n if (filteredItems[index] && isInteractive(filteredItems[index])) {\n onSelectItem(filteredItems[index]);\n }\n };\n\n return [\n { ...highlightedOptionState, items: filteredItems, showAll, getItemGroup },\n {\n ...highlightedOptionHandlers,\n setShowAll,\n selectHighlightedOptionWithKeyboard,\n highlightVisibleOptionWithMouse,\n selectVisibleOptionWithMouse,\n },\n ];\n};\n\nfunction createItems(options: Options) {\n const items: AutosuggestItem[] = [];\n const itemToGroup = new WeakMap<AutosuggestItem, AutosuggestItem>();\n const getItemParent = (item: AutosuggestItem) => itemToGroup.get(item);\n const getItemGroup = (item: AutosuggestItem) => getItemParent(item)?.option as AutosuggestProps.OptionGroup;\n\n for (const option of options) {\n if (isGroup(option)) {\n for (const item of flattenGroup(option)) {\n items.push(item);\n }\n } else {\n items.push({ ...option, option });\n }\n }\n\n function flattenGroup(group: AutosuggestProps.OptionGroup) {\n const { options, ...rest } = group;\n\n let hasOnlyDisabledChildren = true;\n\n const groupItem: AutosuggestItem = { ...rest, type: 'parent', option: group };\n\n const items: AutosuggestItem[] = [groupItem];\n\n for (const option of options) {\n if (!option.disabled) {\n hasOnlyDisabledChildren = false;\n }\n\n const childOption: AutosuggestItem = {\n ...option,\n type: 'child',\n disabled: option.disabled || rest.disabled,\n option,\n };\n\n items.push(childOption);\n\n itemToGroup.set(childOption, groupItem);\n }\n\n items[0].disabled = items[0].disabled || hasOnlyDisabledChildren;\n\n return items;\n }\n\n return { items, getItemGroup, getItemParent };\n}\n\nfunction isGroup(optionOrGroup: AutosuggestProps.Option): optionOrGroup is AutosuggestProps.OptionGroup {\n return 'options' in optionOrGroup;\n}\n"]}
|
|
@@ -13,7 +13,6 @@ interface AutosuggestOptionsListProps extends Pick<AutosuggestProps, 'virtualScr
|
|
|
13
13
|
hasDropdownStatus?: boolean;
|
|
14
14
|
listBottom?: React.ReactNode;
|
|
15
15
|
ariaDescribedby?: string;
|
|
16
|
-
renderOption?: AutosuggestProps.ItemRenderer;
|
|
17
16
|
}
|
|
18
17
|
export default function AutosuggestOptionsList({
|
|
19
18
|
statusType,
|
|
@@ -29,7 +28,6 @@ export default function AutosuggestOptionsList({
|
|
|
29
28
|
selectedAriaLabel,
|
|
30
29
|
renderHighlightedAriaLive,
|
|
31
30
|
listBottom,
|
|
32
|
-
ariaDescribedby
|
|
33
|
-
renderOption
|
|
31
|
+
ariaDescribedby
|
|
34
32
|
}: AutosuggestOptionsListProps): JSX.Element;
|
|
35
33
|
export {};
|
|
@@ -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;AAG1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAIvF,UAAU,2BACR,SAAQ,IAAI,CAAC,gBAAgB,EAAE,eAAe,GAAG,mBAAmB,GAAG,2BAA2B,CAAC;IACnG,UAAU,EAAE,gBAAgB,CAAC,UAAU,CAAC;IACxC,qB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SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EACzB,UAAU,EACV,eAAe,GAChB,EAAE,2BAA2B,eAkC7B"}
|
|
@@ -10,7 +10,7 @@ const createMouseEventHandler = (handler) => (itemIndex) => {
|
|
|
10
10
|
handler(itemIndex);
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
|
-
export default function AutosuggestOptionsList({ statusType, autosuggestItemsState, autosuggestItemsHandlers, highlightedOptionId, highlightText, listId, controlId, handleLoadMore, hasDropdownStatus, virtualScroll, selectedAriaLabel, renderHighlightedAriaLive, listBottom, ariaDescribedby,
|
|
13
|
+
export default function AutosuggestOptionsList({ statusType, autosuggestItemsState, autosuggestItemsHandlers, highlightedOptionId, highlightText, listId, controlId, handleLoadMore, hasDropdownStatus, virtualScroll, selectedAriaLabel, renderHighlightedAriaLive, listBottom, ariaDescribedby, }) {
|
|
14
14
|
var _a;
|
|
15
15
|
const handleMouseUp = createMouseEventHandler(autosuggestItemsHandlers.selectVisibleOptionWithMouse);
|
|
16
16
|
const handleMouseMove = createMouseEventHandler(autosuggestItemsHandlers.highlightVisibleOptionWithMouse);
|
|
@@ -23,7 +23,7 @@ export default function AutosuggestOptionsList({ statusType, autosuggestItemsSta
|
|
|
23
23
|
selectedAriaLabel,
|
|
24
24
|
renderHighlightedAriaLive,
|
|
25
25
|
});
|
|
26
|
-
return (React.createElement(ListComponent, {
|
|
26
|
+
return (React.createElement(ListComponent, { listBottom: listBottom, handleLoadMore: handleLoadMore, autosuggestItemsState: autosuggestItemsState, highlightText: highlightText, highlightedA11yProps: highlightedOptionId ? { id: highlightedOptionId } : {}, hasDropdownStatus: hasDropdownStatus, menuProps: {
|
|
27
27
|
id: listId,
|
|
28
28
|
ariaLabelledby: controlId,
|
|
29
29
|
onMouseUp: handleMouseUp,
|