@cloudscape-design/components 3.0.14 → 3.0.17
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/alert/styles.css.js +19 -19
- package/alert/styles.scoped.css +33 -35
- package/alert/styles.selectors.js +19 -19
- package/annotation-context/annotation/styles.css.js +24 -24
- package/annotation-context/annotation/styles.scoped.css +30 -31
- package/annotation-context/annotation/styles.selectors.js +24 -24
- package/app-layout/toggles/styles.css.js +3 -3
- package/app-layout/toggles/styles.scoped.css +12 -12
- package/app-layout/toggles/styles.selectors.js +3 -3
- package/app-layout/visual-refresh/styles.css.js +59 -59
- package/app-layout/visual-refresh/styles.scoped.css +152 -152
- package/app-layout/visual-refresh/styles.selectors.js +59 -59
- package/area-chart/styles.scoped.css +0 -1
- package/attribute-editor/styles.scoped.css +0 -1
- package/autosuggest/internal.d.ts.map +1 -1
- package/autosuggest/internal.js +19 -33
- package/autosuggest/internal.js.map +1 -1
- package/autosuggest/options-list.d.ts +19 -0
- package/autosuggest/options-list.d.ts.map +1 -0
- package/autosuggest/options-list.js +37 -0
- package/autosuggest/options-list.js.map +1 -0
- package/autosuggest/plain-list.d.ts +3 -5
- package/autosuggest/plain-list.d.ts.map +1 -1
- package/autosuggest/plain-list.js +7 -7
- package/autosuggest/plain-list.js.map +1 -1
- package/autosuggest/virtual-list.d.ts +2 -6
- package/autosuggest/virtual-list.d.ts.map +1 -1
- package/autosuggest/virtual-list.js +7 -7
- package/autosuggest/virtual-list.js.map +1 -1
- package/badge/styles.css.js +5 -5
- package/badge/styles.scoped.css +6 -7
- package/badge/styles.selectors.js +5 -5
- package/breadcrumb-group/item/styles.css.js +7 -7
- package/breadcrumb-group/item/styles.scoped.css +16 -16
- package/breadcrumb-group/item/styles.selectors.js +7 -7
- package/breadcrumb-group/styles.scoped.css +0 -2
- package/button/styles.css.js +18 -18
- package/button/styles.scoped.css +164 -165
- package/button/styles.selectors.js +18 -18
- package/button-dropdown/category-elements/styles.css.js +12 -12
- package/button-dropdown/category-elements/styles.scoped.css +23 -23
- package/button-dropdown/category-elements/styles.selectors.js +12 -12
- package/button-dropdown/item-element/styles.css.js +13 -13
- package/button-dropdown/item-element/styles.scoped.css +18 -18
- package/button-dropdown/item-element/styles.selectors.js +13 -13
- package/button-dropdown/mobile-expandable-group/styles.scoped.css +0 -2
- package/cards/styles.css.js +37 -37
- package/cards/styles.scoped.css +46 -47
- package/cards/styles.selectors.js +37 -37
- package/checkbox/styles.css.js +3 -3
- package/checkbox/styles.scoped.css +7 -8
- package/checkbox/styles.selectors.js +3 -3
- package/code-editor/styles.css.js +33 -33
- package/code-editor/styles.scoped.css +134 -135
- package/code-editor/styles.selectors.js +33 -33
- package/column-layout/styles.scoped.css +0 -1
- package/container/styles.css.js +15 -15
- package/container/styles.scoped.css +26 -27
- package/container/styles.selectors.js +15 -15
- package/date-picker/styles.css.js +24 -24
- package/date-picker/styles.scoped.css +46 -48
- package/date-picker/styles.selectors.js +24 -24
- package/date-range-picker/calendar/grids/day/styles.css.js +21 -21
- package/date-range-picker/calendar/grids/day/styles.scoped.css +50 -50
- package/date-range-picker/calendar/grids/day/styles.selectors.js +21 -21
- package/date-range-picker/calendar/header/button/index.d.ts +1 -2
- package/date-range-picker/calendar/header/button/index.d.ts.map +1 -1
- package/date-range-picker/calendar/header/button/index.js +2 -3
- package/date-range-picker/calendar/header/button/index.js.map +1 -1
- package/date-range-picker/calendar/header/index.d.ts +1 -2
- package/date-range-picker/calendar/header/index.d.ts.map +1 -1
- package/date-range-picker/calendar/header/index.js +3 -3
- package/date-range-picker/calendar/header/index.js.map +1 -1
- package/date-range-picker/calendar/index.js +1 -1
- package/date-range-picker/calendar/index.js.map +1 -1
- package/date-range-picker/styles.css.js +42 -42
- package/date-range-picker/styles.scoped.css +53 -56
- package/date-range-picker/styles.selectors.js +42 -42
- package/expandable-section/styles.css.js +20 -20
- package/expandable-section/styles.scoped.css +42 -43
- package/expandable-section/styles.selectors.js +20 -20
- package/flashbar/styles.css.js +22 -22
- package/flashbar/styles.scoped.css +87 -88
- package/flashbar/styles.selectors.js +22 -22
- package/form/styles.scoped.css +0 -1
- package/form-field/styles.scoped.css +0 -1
- package/grid/styles.scoped.css +0 -1
- package/header/styles.scoped.css +0 -1
- package/help-panel/styles.css.js +4 -4
- package/help-panel/styles.scoped.css +59 -60
- package/help-panel/styles.selectors.js +4 -4
- package/input/styles.css.js +13 -13
- package/input/styles.scoped.css +36 -37
- package/input/styles.selectors.js +13 -13
- package/internal/base-component/styles.scoped.css +15 -13
- package/internal/components/abstract-switch/styles.scoped.css +0 -1
- package/internal/components/button-trigger/styles.css.js +9 -9
- package/internal/components/button-trigger/styles.scoped.css +26 -27
- package/internal/components/button-trigger/styles.selectors.js +9 -9
- package/internal/components/chart-filter/styles.scoped.css +0 -1
- package/internal/components/chart-legend/styles.css.js +7 -7
- package/internal/components/chart-legend/styles.scoped.css +16 -17
- package/internal/components/chart-legend/styles.selectors.js +7 -7
- package/internal/components/chart-popover/styles.scoped.css +0 -1
- package/internal/components/chart-series-details/styles.scoped.css +0 -2
- package/internal/components/chart-series-marker/styles.scoped.css +0 -1
- package/internal/components/dropdown/styles.css.js +20 -20
- package/internal/components/dropdown/styles.scoped.css +38 -40
- package/internal/components/dropdown/styles.selectors.js +20 -20
- package/internal/components/dropdown-footer/styles.scoped.css +0 -1
- package/internal/components/dropdown-status/styles.scoped.css +0 -1
- package/internal/components/filtering-token/styles.css.js +7 -7
- package/internal/components/filtering-token/styles.scoped.css +15 -15
- package/internal/components/filtering-token/styles.selectors.js +7 -7
- package/internal/components/menu-dropdown/styles.css.js +7 -7
- package/internal/components/menu-dropdown/styles.scoped.css +14 -15
- package/internal/components/menu-dropdown/styles.selectors.js +7 -7
- package/internal/components/option/styles.scoped.css +0 -1
- package/internal/components/options-list/styles.css.js +2 -2
- package/internal/components/options-list/styles.scoped.css +3 -4
- package/internal/components/options-list/styles.selectors.js +2 -2
- package/internal/components/selectable-item/styles.css.js +16 -16
- package/internal/components/selectable-item/styles.scoped.css +28 -28
- package/internal/components/selectable-item/styles.selectors.js +16 -16
- package/internal/environment.js +1 -1
- package/internal/generated/theming/index.cjs +45 -39
- package/internal/generated/theming/index.js +45 -39
- package/link/styles.css.js +18 -18
- package/link/styles.scoped.css +70 -71
- package/link/styles.selectors.js +18 -18
- package/mixed-line-bar-chart/styles.scoped.css +0 -1
- package/modal/styles.css.js +22 -22
- package/modal/styles.scoped.css +42 -44
- package/modal/styles.selectors.js +22 -22
- package/multiselect/styles.scoped.css +0 -1
- package/package.json +1 -1
- package/pagination/styles.css.js +9 -9
- package/pagination/styles.scoped.css +24 -25
- package/pagination/styles.selectors.js +9 -9
- package/pie-chart/styles.scoped.css +0 -1
- package/popover/styles.css.js +48 -48
- package/popover/styles.scoped.css +64 -66
- package/popover/styles.selectors.js +48 -48
- package/progress-bar/styles.scoped.css +0 -1
- package/property-filter/styles.scoped.css +0 -1
- package/radio-group/styles.css.js +9 -9
- package/radio-group/styles.scoped.css +17 -18
- package/radio-group/styles.selectors.js +9 -9
- package/segmented-control/styles.css.js +14 -14
- package/segmented-control/styles.scoped.css +36 -43
- package/segmented-control/styles.selectors.js +14 -14
- package/select/styles.scoped.css +0 -1
- package/side-navigation/styles.css.js +22 -22
- package/side-navigation/styles.scoped.css +33 -34
- package/side-navigation/styles.selectors.js +22 -22
- package/split-panel/styles.css.js +58 -58
- package/split-panel/styles.scoped.css +81 -83
- package/split-panel/styles.selectors.js +58 -58
- package/table/body-cell/styles.css.js +7 -7
- package/table/body-cell/styles.scoped.css +20 -20
- package/table/body-cell/styles.selectors.js +7 -7
- package/table/header-cell/styles.css.js +14 -14
- package/table/header-cell/styles.scoped.css +26 -26
- package/table/header-cell/styles.selectors.js +14 -14
- package/table/resizer/styles.scoped.css +0 -1
- package/table/styles.css.js +32 -32
- package/table/styles.scoped.css +40 -40
- package/table/styles.selectors.js +32 -32
- package/tabs/styles.css.js +21 -21
- package/tabs/styles.scoped.css +39 -40
- package/tabs/styles.selectors.js +21 -21
- package/tag-editor/styles.css.js +3 -3
- package/tag-editor/styles.scoped.css +11 -11
- package/tag-editor/styles.selectors.js +3 -3
- package/text-content/styles.css.js +1 -1
- package/text-content/styles.scoped.css +61 -62
- package/text-content/styles.selectors.js +1 -1
- package/text-filter/styles.scoped.css +0 -1
- package/textarea/styles.css.js +4 -4
- package/textarea/styles.scoped.css +14 -26
- package/textarea/styles.selectors.js +4 -4
- package/tiles/styles.css.js +28 -28
- package/tiles/styles.scoped.css +69 -71
- package/tiles/styles.selectors.js +28 -28
- package/toggle/styles.css.js +8 -8
- package/toggle/styles.scoped.css +15 -16
- package/toggle/styles.selectors.js +8 -8
- package/token-group/styles.css.js +7 -7
- package/token-group/styles.scoped.css +25 -27
- package/token-group/styles.selectors.js +7 -7
- package/top-navigation/1.0-beta/styles.css.js +25 -25
- package/top-navigation/1.0-beta/styles.scoped.css +43 -44
- package/top-navigation/1.0-beta/styles.selectors.js +25 -25
- package/top-navigation/styles.css.js +47 -47
- package/top-navigation/styles.scoped.css +68 -71
- package/top-navigation/styles.selectors.js +47 -47
- package/tutorial-panel/components/tutorial-detail-view/styles.scoped.css +0 -1
- package/tutorial-panel/components/tutorial-list/styles.css.js +18 -18
- package/tutorial-panel/components/tutorial-list/styles.scoped.css +30 -33
- package/tutorial-panel/components/tutorial-list/styles.selectors.js +18 -18
- package/tutorial-panel/styles.scoped.css +0 -1
- package/wizard/styles.css.js +31 -31
- package/wizard/styles.scoped.css +60 -61
- package/wizard/styles.selectors.js +31 -31
- package/autosuggest/hooks/a11y.d.ts +0 -5
- package/autosuggest/hooks/a11y.d.ts.map +0 -1
- package/autosuggest/hooks/a11y.js +0 -24
- package/autosuggest/hooks/a11y.js.map +0 -1
|
@@ -2,64 +2,64 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"appbar": "
|
|
6
|
-
"appbar-nav": "awsui_appbar-
|
|
7
|
-
"breadcrumbs": "
|
|
8
|
-
"appbar-tools": "awsui_appbar-
|
|
9
|
-
"has-breadcrumbs": "awsui_has-
|
|
10
|
-
"has-notifications-content": "awsui_has-notifications-
|
|
11
|
-
"has-header": "awsui_has-
|
|
12
|
-
"has-dynamic-overlap-height": "awsui_has-dynamic-overlap-
|
|
13
|
-
"content-type-wizard": "awsui_content-type-
|
|
14
|
-
"content-type-cards": "awsui_content-type-
|
|
15
|
-
"content-type-table": "awsui_content-type-
|
|
16
|
-
"background": "
|
|
17
|
-
"notifications-appbar-header": "awsui_notifications-appbar-
|
|
18
|
-
"sticky-notifications": "awsui_sticky-
|
|
19
|
-
"overlap": "
|
|
20
|
-
"content": "
|
|
21
|
-
"layout": "
|
|
22
|
-
"has-max-content-width": "awsui_has-max-content-
|
|
23
|
-
"is-overlap-disabled": "awsui_is-overlap-
|
|
24
|
-
"disable-body-scroll": "awsui_disable-body-
|
|
25
|
-
"has-sticky-notifications": "awsui_has-sticky-
|
|
26
|
-
"has-split-panel": "awsui_has-split-
|
|
27
|
-
"split-panel-position-bottom": "awsui_split-panel-position-
|
|
28
|
-
"has-content-gap-left": "awsui_has-content-gap-
|
|
29
|
-
"has-content-gap-right": "awsui_has-content-gap-
|
|
30
|
-
"block-body-scroll": "awsui_block-body-
|
|
31
|
-
"container": "
|
|
32
|
-
"disable-content-paddings": "awsui_disable-content-
|
|
33
|
-
"is-navigation-open": "awsui_is-navigation-
|
|
34
|
-
"is-tools-open": "awsui_is-tools-
|
|
35
|
-
"is-split-panel-open": "awsui_is-split-panel-
|
|
36
|
-
"split-panel-position-side": "awsui_split-panel-position-
|
|
37
|
-
"content-type-default": "awsui_content-type-
|
|
38
|
-
"content-type-form": "awsui_content-type-
|
|
39
|
-
"unfocusable": "
|
|
40
|
-
"navigation-container": "awsui_navigation-
|
|
41
|
-
"show-navigation": "awsui_show-
|
|
42
|
-
"animating": "
|
|
43
|
-
"showButtons": "
|
|
44
|
-
"navigation": "
|
|
45
|
-
"openNavigation": "
|
|
46
|
-
"animated-content": "awsui_animated-
|
|
47
|
-
"hide-navigation": "awsui_hide-
|
|
48
|
-
"notifications": "
|
|
49
|
-
"split-panel-bottom": "awsui_split-panel-
|
|
50
|
-
"position-bottom": "awsui_position-
|
|
51
|
-
"openSplitPanelBottom": "
|
|
52
|
-
"split-panel-side": "awsui_split-panel-
|
|
53
|
-
"position-side": "awsui_position-
|
|
54
|
-
"openSplitPanelSide": "
|
|
55
|
-
"tools-container": "awsui_tools-
|
|
56
|
-
"tools": "
|
|
57
|
-
"openTools": "
|
|
58
|
-
"has-tools-form-persistence": "awsui_has-tools-form-
|
|
59
|
-
"hide-tools": "awsui_hide-
|
|
60
|
-
"show-tools": "awsui_show-
|
|
61
|
-
"has-tools-form": "awsui_has-tools-
|
|
62
|
-
"trigger": "
|
|
63
|
-
"selected": "
|
|
5
|
+
"appbar": "awsui_appbar_hyvsj_blfh0_93",
|
|
6
|
+
"appbar-nav": "awsui_appbar-nav_hyvsj_blfh0_117",
|
|
7
|
+
"breadcrumbs": "awsui_breadcrumbs_hyvsj_blfh0_121",
|
|
8
|
+
"appbar-tools": "awsui_appbar-tools_hyvsj_blfh0_125",
|
|
9
|
+
"has-breadcrumbs": "awsui_has-breadcrumbs_hyvsj_blfh0_160",
|
|
10
|
+
"has-notifications-content": "awsui_has-notifications-content_hyvsj_blfh0_167",
|
|
11
|
+
"has-header": "awsui_has-header_hyvsj_blfh0_173",
|
|
12
|
+
"has-dynamic-overlap-height": "awsui_has-dynamic-overlap-height_hyvsj_blfh0_173",
|
|
13
|
+
"content-type-wizard": "awsui_content-type-wizard_hyvsj_blfh0_174",
|
|
14
|
+
"content-type-cards": "awsui_content-type-cards_hyvsj_blfh0_177",
|
|
15
|
+
"content-type-table": "awsui_content-type-table_hyvsj_blfh0_178",
|
|
16
|
+
"background": "awsui_background_hyvsj_blfh0_213",
|
|
17
|
+
"notifications-appbar-header": "awsui_notifications-appbar-header_hyvsj_blfh0_216",
|
|
18
|
+
"sticky-notifications": "awsui_sticky-notifications_hyvsj_blfh0_228",
|
|
19
|
+
"overlap": "awsui_overlap_hyvsj_blfh0_234",
|
|
20
|
+
"content": "awsui_content_hyvsj_blfh0_174",
|
|
21
|
+
"layout": "awsui_layout_hyvsj_blfh0_322",
|
|
22
|
+
"has-max-content-width": "awsui_has-max-content-width_hyvsj_blfh0_404",
|
|
23
|
+
"is-overlap-disabled": "awsui_is-overlap-disabled_hyvsj_blfh0_431",
|
|
24
|
+
"disable-body-scroll": "awsui_disable-body-scroll_hyvsj_blfh0_434",
|
|
25
|
+
"has-sticky-notifications": "awsui_has-sticky-notifications_hyvsj_blfh0_438",
|
|
26
|
+
"has-split-panel": "awsui_has-split-panel_hyvsj_blfh0_452",
|
|
27
|
+
"split-panel-position-bottom": "awsui_split-panel-position-bottom_hyvsj_blfh0_452",
|
|
28
|
+
"has-content-gap-left": "awsui_has-content-gap-left_hyvsj_blfh0_464",
|
|
29
|
+
"has-content-gap-right": "awsui_has-content-gap-right_hyvsj_blfh0_467",
|
|
30
|
+
"block-body-scroll": "awsui_block-body-scroll_hyvsj_blfh0_482",
|
|
31
|
+
"container": "awsui_container_hyvsj_blfh0_490",
|
|
32
|
+
"disable-content-paddings": "awsui_disable-content-paddings_hyvsj_blfh0_507",
|
|
33
|
+
"is-navigation-open": "awsui_is-navigation-open_hyvsj_blfh0_512",
|
|
34
|
+
"is-tools-open": "awsui_is-tools-open_hyvsj_blfh0_515",
|
|
35
|
+
"is-split-panel-open": "awsui_is-split-panel-open_hyvsj_blfh0_515",
|
|
36
|
+
"split-panel-position-side": "awsui_split-panel-position-side_hyvsj_blfh0_515",
|
|
37
|
+
"content-type-default": "awsui_content-type-default_hyvsj_blfh0_535",
|
|
38
|
+
"content-type-form": "awsui_content-type-form_hyvsj_blfh0_535",
|
|
39
|
+
"unfocusable": "awsui_unfocusable_hyvsj_blfh0_576",
|
|
40
|
+
"navigation-container": "awsui_navigation-container_hyvsj_blfh0_584",
|
|
41
|
+
"show-navigation": "awsui_show-navigation_hyvsj_blfh0_608",
|
|
42
|
+
"animating": "awsui_animating_hyvsj_blfh0_630",
|
|
43
|
+
"showButtons": "awsui_showButtons_hyvsj_blfh0_1",
|
|
44
|
+
"navigation": "awsui_navigation_hyvsj_blfh0_584",
|
|
45
|
+
"openNavigation": "awsui_openNavigation_hyvsj_blfh0_1",
|
|
46
|
+
"animated-content": "awsui_animated-content_hyvsj_blfh0_690",
|
|
47
|
+
"hide-navigation": "awsui_hide-navigation_hyvsj_blfh0_699",
|
|
48
|
+
"notifications": "awsui_notifications_hyvsj_blfh0_216",
|
|
49
|
+
"split-panel-bottom": "awsui_split-panel-bottom_hyvsj_blfh0_766",
|
|
50
|
+
"position-bottom": "awsui_position-bottom_hyvsj_blfh0_801",
|
|
51
|
+
"openSplitPanelBottom": "awsui_openSplitPanelBottom_hyvsj_blfh0_1",
|
|
52
|
+
"split-panel-side": "awsui_split-panel-side_hyvsj_blfh0_830",
|
|
53
|
+
"position-side": "awsui_position-side_hyvsj_blfh0_857",
|
|
54
|
+
"openSplitPanelSide": "awsui_openSplitPanelSide_hyvsj_blfh0_1",
|
|
55
|
+
"tools-container": "awsui_tools-container_hyvsj_blfh0_894",
|
|
56
|
+
"tools": "awsui_tools_hyvsj_blfh0_894",
|
|
57
|
+
"openTools": "awsui_openTools_hyvsj_blfh0_1",
|
|
58
|
+
"has-tools-form-persistence": "awsui_has-tools-form-persistence_hyvsj_blfh0_977",
|
|
59
|
+
"hide-tools": "awsui_hide-tools_hyvsj_blfh0_987",
|
|
60
|
+
"show-tools": "awsui_show-tools_hyvsj_blfh0_999",
|
|
61
|
+
"has-tools-form": "awsui_has-tools-form_hyvsj_blfh0_977",
|
|
62
|
+
"trigger": "awsui_trigger_hyvsj_blfh0_1056",
|
|
63
|
+
"selected": "awsui_selected_hyvsj_blfh0_1094"
|
|
64
64
|
};
|
|
65
65
|
|
|
@@ -125,7 +125,6 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
125
125
|
font-stretch: normal;
|
|
126
126
|
line-height: normal;
|
|
127
127
|
-webkit-hyphens: none;
|
|
128
|
-
-ms-hyphens: none;
|
|
129
128
|
hyphens: none;
|
|
130
129
|
letter-spacing: normal;
|
|
131
130
|
list-style: disc outside none;
|
|
@@ -133,7 +133,6 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
133
133
|
font-stretch: normal;
|
|
134
134
|
line-height: normal;
|
|
135
135
|
-webkit-hyphens: none;
|
|
136
|
-
-ms-hyphens: none;
|
|
137
136
|
hyphens: none;
|
|
138
137
|
letter-spacing: normal;
|
|
139
138
|
list-style: disc outside none;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAwD,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAwD,MAAM,OAAO,CAAC;AAG7E,OAAO,EAAmB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAUjE,OAAO,EAA0B,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAGpF,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAKjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAIlF,MAAM,WAAW,wBAAyB,SAAQ,gBAAgB,EAAE,0BAA0B;IAC5F,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,sBAAsB,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAClE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,EAAE,sBAAsB,CAAC,IAAI,CAAC,CAAC;CACzC;AA6BD,QAAA,MAAM,mBAAmB,iGAoOvB,CAAC;AAEH,eAAe,mBAAmB,CAAC"}
|
package/autosuggest/internal.js
CHANGED
|
@@ -3,16 +3,13 @@ import { __assign, __rest } from "tslib";
|
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
6
|
-
import { useAutosuggestItems, useFilteredItems, useKeyboardHandler
|
|
7
|
-
import { useDropdownA11yProps } from './hooks/a11y';
|
|
8
|
-
import VirtualList from './virtual-list';
|
|
9
|
-
import PlainList from './plain-list';
|
|
6
|
+
import { useAutosuggestItems, useFilteredItems, useKeyboardHandler } from './controller';
|
|
10
7
|
import Dropdown from '../internal/components/dropdown';
|
|
11
8
|
import { useDropdownStatus } from '../internal/components/dropdown-status';
|
|
12
9
|
import DropdownFooter from '../internal/components/dropdown-footer';
|
|
13
10
|
import { useFormFieldContext } from '../internal/context/form-field-context';
|
|
14
11
|
import { getBaseProps } from '../internal/base-component';
|
|
15
|
-
import { useUniqueId } from '../internal/hooks/use-unique-id';
|
|
12
|
+
import { generateUniqueId, useUniqueId } from '../internal/hooks/use-unique-id';
|
|
16
13
|
import useForwardFocus from '../internal/hooks/forward-focus';
|
|
17
14
|
import { fireNonCancelableEvent } from '../internal/events';
|
|
18
15
|
import { createHighlightedOptionHook } from '../internal/components/options-list/utils/use-highlight-option';
|
|
@@ -21,8 +18,8 @@ import styles from './styles.css.js';
|
|
|
21
18
|
import { checkOptionValueField } from '../select/utils/check-option-value-field';
|
|
22
19
|
import checkControlled from '../internal/hooks/check-controlled';
|
|
23
20
|
import { fireCancelableEvent } from '../internal/events/index';
|
|
24
|
-
import { useAnnouncement } from '../select/utils/use-announcement';
|
|
25
21
|
import TabTrap from '../internal/components/tab-trap';
|
|
22
|
+
import AutosuggestOptionsList from './options-list';
|
|
26
23
|
var isInteractive = function (option) {
|
|
27
24
|
return !!option && !option.disabled && option.type !== 'parent';
|
|
28
25
|
};
|
|
@@ -30,13 +27,6 @@ var isHighlightable = function (option) {
|
|
|
30
27
|
return !!option && option.type !== 'parent';
|
|
31
28
|
};
|
|
32
29
|
var useHighlightedOption = createHighlightedOptionHook({ isHighlightable: isHighlightable });
|
|
33
|
-
var createMouseEventHandler = function (handler, usingMouse) { return function (itemIndex) {
|
|
34
|
-
// prevent mouse events to avoid losing focus from the input
|
|
35
|
-
usingMouse.current = true;
|
|
36
|
-
if (itemIndex > -1) {
|
|
37
|
-
handler(itemIndex);
|
|
38
|
-
}
|
|
39
|
-
}; };
|
|
40
30
|
var useLoadMoreItems = function (onLoadItems) {
|
|
41
31
|
var lastFilteringText = useRef(null);
|
|
42
32
|
return useCallback(function (firstPage, samePage, filteringText) {
|
|
@@ -106,10 +96,6 @@ var InternalAutosuggest = React.forwardRef(function (props, ref) {
|
|
|
106
96
|
resetHighlight();
|
|
107
97
|
onChange && onChange(e);
|
|
108
98
|
};
|
|
109
|
-
var highlightVisibleOption = useHighlightVisibleOption(filteredItems, setHighlightedIndex, isHighlightable);
|
|
110
|
-
var selectVisibleOption = useSelectVisibleOption(filteredItems, selectOption, isInteractive);
|
|
111
|
-
var handleMouseUp = createMouseEventHandler(selectVisibleOption, usingMouse);
|
|
112
|
-
var handleMouseMove = createMouseEventHandler(highlightVisibleOption, usingMouse);
|
|
113
99
|
var handleKeyDown = useKeyboardHandler(moveHighlight, openDropdown, selectHighlighted, usingMouse, open, onKeyDown);
|
|
114
100
|
var handleLoadMore = useCallback(function () {
|
|
115
101
|
options && options.length && statusType === 'pending' && fireLoadMore(false, false);
|
|
@@ -130,8 +116,21 @@ var InternalAutosuggest = React.forwardRef(function (props, ref) {
|
|
|
130
116
|
var listId = useUniqueId('list');
|
|
131
117
|
// From an a11y point of view we only count the dropdown as 'expanded' if there are items that a user can dropdown into
|
|
132
118
|
var expanded = open && filteredItems.length > 1;
|
|
133
|
-
var
|
|
134
|
-
var nativeAttributes =
|
|
119
|
+
var highlightedOptionId = highlightedOption ? generateUniqueId() : undefined;
|
|
120
|
+
var nativeAttributes = {
|
|
121
|
+
name: name,
|
|
122
|
+
placeholder: placeholder,
|
|
123
|
+
autoFocus: autoFocus,
|
|
124
|
+
onClick: openDropdown,
|
|
125
|
+
role: 'combobox',
|
|
126
|
+
'aria-autocomplete': 'list',
|
|
127
|
+
'aria-expanded': expanded,
|
|
128
|
+
'aria-controls': listId,
|
|
129
|
+
// 'aria-owns' needed for safari+vo to announce activedescendant content
|
|
130
|
+
'aria-owns': listId,
|
|
131
|
+
'aria-label': ariaLabel,
|
|
132
|
+
'aria-activedescendant': highlightedOptionId
|
|
133
|
+
};
|
|
135
134
|
var handleInputFocus = function (e) {
|
|
136
135
|
!__disableShowAll && setShowAll(true);
|
|
137
136
|
var openPrevented = fireCancelableEvent(__onOpen, null);
|
|
@@ -148,30 +147,17 @@ var InternalAutosuggest = React.forwardRef(function (props, ref) {
|
|
|
148
147
|
var isEmpty = !value && !filteredItems.length;
|
|
149
148
|
var showRecoveryLink = open && statusType === 'error' && props.recoveryText;
|
|
150
149
|
var dropdownStatus = useDropdownStatus(__assign(__assign({}, props), { isEmpty: isEmpty, onRecoveryClick: handleRecoveryClick }));
|
|
151
|
-
var ListComponent = virtualScroll ? VirtualList : PlainList;
|
|
152
150
|
var handleMouseDown = function (event) {
|
|
153
151
|
// prevent currently focused element from losing it
|
|
154
152
|
event.preventDefault();
|
|
155
153
|
};
|
|
156
|
-
var announcement = useAnnouncement({
|
|
157
|
-
announceSelected: true,
|
|
158
|
-
highlightedOption: highlightedOption,
|
|
159
|
-
getParent: function (option) { var _a; return (_a = getParentGroup(option)) === null || _a === void 0 ? void 0 : _a.option; },
|
|
160
|
-
selectedAriaLabel: selectedAriaLabel,
|
|
161
|
-
renderHighlightedAriaLive: renderHighlightedAriaLive
|
|
162
|
-
});
|
|
163
154
|
return (React.createElement("div", __assign({}, baseProps, { className: clsx(styles.root, baseProps.className), ref: __internalRootRef, onBlur: handleBlur }),
|
|
164
155
|
React.createElement(Dropdown, { minWidth: __dropdownWidth, stretchWidth: !__dropdownWidth, trigger: React.createElement(React.Fragment, null,
|
|
165
156
|
React.createElement(InternalInput, __assign({ type: "search", value: value, onChange: handleInputChange, __onDelayedInput: function (event) { return fireLoadMore(true, false, event.detail.value); }, onFocus: handleInputFocus, onKeyDown: handleKeyDown, onKeyUp: onKeyUp, disabled: disabled, disableBrowserAutocorrect: disableBrowserAutocorrect, readOnly: readOnly, ariaRequired: ariaRequired, ref: inputRef, autoComplete: false, __nativeAttributes: nativeAttributes }, formFieldContext, { controlId: controlId })),
|
|
166
157
|
React.createElement(TabTrap, { focusNextCallback: function () { return dropdownStatus.focusRecoveryLink(); }, disabled: !open || !showRecoveryLink })), onMouseDown: handleMouseDown, open: open, dropdownId: dropdownId, footer: dropdownStatus.isSticky ? (React.createElement("div", { ref: dropdownFooterRef, className: styles['dropdown-footer'] },
|
|
167
158
|
React.createElement(TabTrap, { focusNextCallback: function () { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); }, disabled: !showRecoveryLink }),
|
|
168
159
|
React.createElement(DropdownFooter, { content: dropdownStatus.content, hasItems: filteredItems.length >= 1 }),
|
|
169
|
-
React.createElement(TabTrap, { focusNextCallback: function () { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); }, disabled: !showRecoveryLink }))) : null, expandToViewport: expandToViewport, hasContent: filteredItems.length >= 1 || dropdownStatus.content !== null }, open && (React.createElement(
|
|
170
|
-
id: listId,
|
|
171
|
-
onMouseUp: handleMouseUp,
|
|
172
|
-
onMouseMove: handleMouseMove,
|
|
173
|
-
ariaLabelledby: controlId
|
|
174
|
-
}, screenReaderContent: announcement })))));
|
|
160
|
+
React.createElement(TabTrap, { focusNextCallback: function () { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); }, disabled: !showRecoveryLink }))) : null, expandToViewport: expandToViewport, hasContent: filteredItems.length >= 1 || dropdownStatus.content !== null }, open && (React.createElement(AutosuggestOptionsList, { options: filteredItems, highlightedOption: highlightedOption, selectOption: selectOption, highlightedIndex: highlightedIndex, setHighlightedIndex: setHighlightedIndex, highlightedOptionId: highlightedOptionId, highlightText: filterText, listId: listId, controlId: controlId, enteredTextLabel: enteredTextLabel, handleLoadMore: handleLoadMore, hasDropdownStatus: dropdownStatus.content !== null, virtualScroll: virtualScroll, selectedAriaLabel: selectedAriaLabel, renderHighlightedAriaLive: renderHighlightedAriaLive, listBottom: !dropdownStatus.isSticky ? React.createElement(DropdownFooter, { content: dropdownStatus.content }) : null, usingMouse: usingMouse })))));
|
|
175
161
|
});
|
|
176
162
|
export default InternalAutosuggest;
|
|
177
163
|
//# sourceMappingURL=internal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/autosuggest/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAO,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE7E,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,yBAAyB,EACzB,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAAO,QAAQ,MAAM,iCAAiC,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,cAAc,MAAM,wCAAwC,CAAC;AAEpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,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E,IAAI,IAAI,CACP,oBAAC,aAAa,IACZ,UAAU,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,oBAAC,cAAc,IAAC,OAAO,EAAE,cAAc,CAAC,OAAO,GAAI,CAAC,CAAC,CAAC,IAAI,EACjG,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,UAAU,EACzB,UAAU,EAAE,UAAU,EACtB,iBAAiB,EAAE,iBAAiB,EACpC,gBAAgB,EAAE,gBAAgB,EAClC,GAAG,EAAE,aAAa,EAClB,oBAAoB,EAAE,oBAAoB,EAC1C,iBAAiB,EAAE,cAAc,CAAC,OAAO,KAAK,IAAI,EAClD,SAAS,EAAE;gBACT,EAAE,EAAE,MAAM;gBACV,SAAS,EAAE,aAAa;gBACxB,WAAW,EAAE,eAAe;gBAC5B,cAAc,EAAE,SAAS;aAC1B,EACD,mBAAmB,EAAE,YAAY,GACjC,CACH,CACQ,CACP,CACP,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,mBAAmB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React, { Ref, useCallback, useEffect, useRef, useState } from 'react';\n\nimport {\n useAutosuggestItems,\n useFilteredItems,\n useKeyboardHandler,\n useSelectVisibleOption,\n useHighlightVisibleOption,\n getParentGroup,\n} from './controller';\nimport { useDropdownA11yProps } from './hooks/a11y';\nimport { AutosuggestItem, AutosuggestProps } from './interfaces';\nimport VirtualList from './virtual-list';\nimport PlainList from './plain-list';\n\nimport Dropdown from '../internal/components/dropdown';\nimport { useDropdownStatus } from '../internal/components/dropdown-status';\nimport DropdownFooter from '../internal/components/dropdown-footer';\n\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { getBaseProps } from '../internal/base-component';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { fireNonCancelableEvent, CancelableEventHandler } from '../internal/events';\nimport { createHighlightedOptionHook } from '../internal/components/options-list/utils/use-highlight-option';\nimport InternalInput from '../input/internal';\nimport { InputProps } from '../input/interfaces';\nimport styles from './styles.css.js';\nimport { checkOptionValueField } from '../select/utils/check-option-value-field';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { fireCancelableEvent } from '../internal/events/index';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useAnnouncement } from '../select/utils/use-announcement';\nimport { OptionGroup } from '../internal/components/option/interfaces';\nimport TabTrap from '../internal/components/tab-trap';\n\nexport interface InternalAutosuggestProps extends AutosuggestProps, InternalBaseComponentProps {\n __filterText?: string;\n __dropdownWidth?: number;\n __onOptionClick?: CancelableEventHandler<AutosuggestProps.Option>;\n __disableShowAll?: boolean;\n __hideEnteredTextOption?: boolean;\n __onOpen?: CancelableEventHandler<null>;\n}\n\nconst isInteractive = (option?: AutosuggestItem) => {\n return !!option && !option.disabled && option.type !== 'parent';\n};\n\nconst isHighlightable = (option?: AutosuggestItem) => {\n return !!option && option.type !== 'parent';\n};\n\nconst useHighlightedOption = createHighlightedOptionHook({ isHighlightable: isHighlightable });\n\nconst createMouseEventHandler =\n (handler: (index: number) => void, usingMouse: React.MutableRefObject<boolean>) => (itemIndex: number) => {\n // prevent mouse events to avoid losing focus from the input\n usingMouse.current = true;\n if (itemIndex > -1) {\n handler(itemIndex);\n }\n };\n\nconst useLoadMoreItems = (onLoadItems: AutosuggestProps['onLoadItems']) => {\n const lastFilteringText = useRef<string | null>(null);\n return useCallback(\n (firstPage: boolean, samePage: boolean, filteringText?: string) => {\n if (samePage || !firstPage || filteringText === undefined || lastFilteringText.current !== filteringText) {\n if (filteringText !== undefined) {\n lastFilteringText.current = filteringText;\n }\n if (lastFilteringText.current !== null && onLoadItems) {\n fireNonCancelableEvent(onLoadItems, { filteringText: lastFilteringText.current, firstPage, samePage });\n }\n }\n },\n [onLoadItems]\n );\n};\n\nconst InternalAutosuggest = React.forwardRef((props: InternalAutosuggestProps, ref: Ref<InputProps.Ref>) => {\n const {\n value,\n onChange,\n onBlur,\n onFocus,\n onKeyUp,\n onLoadItems,\n options,\n filteringType = 'auto',\n statusType = 'finished',\n placeholder,\n name,\n disabled,\n disableBrowserAutocorrect = false,\n autoFocus,\n readOnly,\n ariaLabel,\n ariaRequired,\n enteredTextLabel,\n onKeyDown,\n virtualScroll,\n expandToViewport,\n onSelect,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n __dropdownWidth,\n __onOptionClick,\n __disableShowAll,\n __hideEnteredTextOption,\n __onOpen,\n __internalRootRef,\n ...rest\n } = props;\n let { __filterText: filterText } = rest;\n filterText = filterText === undefined ? value : filterText;\n\n checkControlled('Autosuggest', 'value', value, 'onChange', onChange);\n checkOptionValueField('Autosuggest', 'options', options);\n\n const usingMouse = useRef(true);\n const [showAll, setShowAll] = useState(false);\n const [open, setOpen] = useState(false);\n const autosuggestItems = useAutosuggestItems(options);\n const filteredItems = useFilteredItems(\n autosuggestItems,\n value,\n filterText,\n filteringType,\n showAll,\n __hideEnteredTextOption\n );\n const openDropdown = () => !readOnly && setOpen(true);\n const scrollToIndex = useRef<(index: number) => void>(null);\n const { highlightedOption, highlightedIndex, moveHighlight, resetHighlight, setHighlightedIndex } =\n useHighlightedOption(filteredItems);\n const closeDropdown = () => {\n setOpen(false);\n resetHighlight();\n };\n const handleBlur: React.FocusEventHandler = event => {\n if (event.currentTarget.contains(event.relatedTarget) || dropdownFooterRef.current?.contains(event.relatedTarget)) {\n return;\n }\n closeDropdown();\n fireNonCancelableEvent(onBlur);\n };\n const selectOption = (option: AutosuggestItem) => {\n const value = option.value || '';\n fireNonCancelableEvent(onChange, { value });\n const selectedCancelled = fireCancelableEvent(__onOptionClick, option);\n if (!selectedCancelled) {\n closeDropdown();\n } else {\n resetHighlight();\n }\n fireNonCancelableEvent(onSelect, { value });\n };\n const selectHighlighted = () => {\n if (highlightedOption) {\n if (isInteractive(highlightedOption)) {\n selectOption(highlightedOption);\n }\n } else {\n closeDropdown();\n }\n };\n\n const fireLoadMore = useLoadMoreItems(onLoadItems);\n\n const handleInputChange: InputProps['onChange'] = e => {\n openDropdown();\n setShowAll(false);\n resetHighlight();\n onChange && onChange(e);\n };\n\n const highlightVisibleOption = useHighlightVisibleOption(filteredItems, setHighlightedIndex, isHighlightable);\n const selectVisibleOption = useSelectVisibleOption(filteredItems, selectOption, isInteractive);\n const handleMouseUp = createMouseEventHandler(selectVisibleOption, usingMouse);\n const handleMouseMove = createMouseEventHandler(highlightVisibleOption, usingMouse);\n const handleKeyDown = useKeyboardHandler(moveHighlight, openDropdown, selectHighlighted, usingMouse, open, onKeyDown);\n const handleLoadMore = useCallback(() => {\n options && options.length && statusType === 'pending' && fireLoadMore(false, false);\n }, [fireLoadMore, options, statusType]);\n const handleRecoveryClick = useCallback(() => {\n fireLoadMore(false, true);\n inputRef.current?.focus();\n }, [fireLoadMore]);\n\n const formFieldContext = useFormFieldContext(rest);\n const baseProps = getBaseProps(rest);\n const inputRef = useRef<HTMLInputElement>(null);\n const dropdownFooterRef = useRef<HTMLDivElement>(null);\n useForwardFocus(ref, inputRef);\n\n const selfControlId = useUniqueId('input');\n const controlId = formFieldContext.controlId ?? selfControlId;\n const dropdownId = useUniqueId('dropdown');\n const listId = useUniqueId('list');\n\n // From an a11y point of view we only count the dropdown as 'expanded' if there are items that a user can dropdown into\n const expanded = open && filteredItems.length > 1;\n const [inputA11yProps, highlightedA11yProps] = useDropdownA11yProps(listId, expanded, ariaLabel, highlightedOption);\n\n const nativeAttributes = {\n name,\n placeholder,\n autoFocus,\n onClick: openDropdown,\n ...inputA11yProps,\n };\n const handleInputFocus: InputProps['onFocus'] = e => {\n !__disableShowAll && setShowAll(true);\n const openPrevented = fireCancelableEvent(__onOpen, null);\n if (!openPrevented) {\n openDropdown();\n fireLoadMore(true, false, '');\n }\n onFocus?.(e);\n };\n\n useEffect(() => {\n scrollToIndex.current?.(highlightedIndex);\n }, [highlightedIndex]);\n\n const isEmpty = !value && !filteredItems.length;\n const showRecoveryLink = open && statusType === 'error' && props.recoveryText;\n const dropdownStatus = useDropdownStatus({ ...props, isEmpty, onRecoveryClick: handleRecoveryClick });\n const ListComponent = virtualScroll ? VirtualList : PlainList;\n\n const handleMouseDown = (event: React.MouseEvent) => {\n // prevent currently focused element from losing it\n event.preventDefault();\n };\n\n const announcement = useAnnouncement({\n announceSelected: true,\n highlightedOption,\n getParent: option => getParentGroup(option)?.option as undefined | OptionGroup,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n });\n\n return (\n <div {...baseProps} className={clsx(styles.root, baseProps.className)} ref={__internalRootRef} onBlur={handleBlur}>\n <Dropdown\n minWidth={__dropdownWidth}\n stretchWidth={!__dropdownWidth}\n trigger={\n <>\n <InternalInput\n type=\"search\"\n value={value}\n onChange={handleInputChange}\n __onDelayedInput={event => fireLoadMore(true, false, event.detail.value)}\n onFocus={handleInputFocus}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n disabled={disabled}\n disableBrowserAutocorrect={disableBrowserAutocorrect}\n readOnly={readOnly}\n ariaRequired={ariaRequired}\n ref={inputRef}\n autoComplete={false}\n __nativeAttributes={nativeAttributes}\n {...formFieldContext}\n controlId={controlId}\n />\n <TabTrap\n focusNextCallback={() => dropdownStatus.focusRecoveryLink()}\n disabled={!open || !showRecoveryLink}\n />\n </>\n }\n onMouseDown={handleMouseDown}\n open={open}\n dropdownId={dropdownId}\n footer={\n dropdownStatus.isSticky ? (\n <div ref={dropdownFooterRef} className={styles['dropdown-footer']}>\n <TabTrap focusNextCallback={() => inputRef.current?.focus()} disabled={!showRecoveryLink} />\n <DropdownFooter content={dropdownStatus.content} hasItems={filteredItems.length >= 1} />\n <TabTrap focusNextCallback={() => inputRef.current?.focus()} disabled={!showRecoveryLink} />\n </div>\n ) : null\n }\n expandToViewport={expandToViewport}\n hasContent={filteredItems.length >= 1 || dropdownStatus.content !== null}\n >\n {open && (\n <ListComponent\n listBottom={!dropdownStatus.isSticky ? <DropdownFooter content={dropdownStatus.content} /> : null}\n handleLoadMore={handleLoadMore}\n filteredItems={filteredItems}\n highlightText={filterText}\n usingMouse={usingMouse}\n highlightedOption={highlightedOption}\n enteredTextLabel={enteredTextLabel}\n ref={scrollToIndex}\n highlightedA11yProps={highlightedA11yProps}\n hasDropdownStatus={dropdownStatus.content !== null}\n menuProps={{\n id: listId,\n onMouseUp: handleMouseUp,\n onMouseMove: handleMouseMove,\n ariaLabelledby: controlId,\n }}\n screenReaderContent={announcement}\n />\n )}\n </Dropdown>\n </div>\n );\n});\n\nexport default InternalAutosuggest;\n"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/autosuggest/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAO,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE7E,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGzF,OAAO,QAAQ,MAAM,iCAAiC,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,cAAc,MAAM,wCAAwC,CAAC;AAEpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAA0B,MAAM,oBAAoB,CAAC;AACpF,OAAO,EAAE,2BAA2B,EAAE,MAAM,gEAAgE,CAAC;AAC7G,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAE9C,OAAO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AAE,QAAQ,EAAE,CAAC,gBAAgB,GAAI,CACxF,CACP,CAAC,CAAC,CAAC,IAAI,EAEV,gBAAgB,EAAE,gBAAgB,EAClC,UAAU,EAAE,aAAa,CAAC,MAAM,IAAI,CAAC,IAAI,cAAc,CAAC,OAAO,KAAK,IAAI,IAEvE,IAAI,IAAI,CACP,oBAAC,sBAAsB,IACrB,OAAO,EAAE,aAAa,EACtB,iBAAiB,EAAE,iBAAiB,EACpC,YAAY,EAAE,YAAY,EAC1B,gBAAgB,EAAE,gBAAgB,EAClC,mBAAmB,EAAE,mBAAmB,EACxC,mBAAmB,EAAE,mBAAmB,EACxC,aAAa,EAAE,UAAU,EACzB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,gBAAgB,EAClC,cAAc,EAAE,cAAc,EAC9B,iBAAiB,EAAE,cAAc,CAAC,OAAO,KAAK,IAAI,EAClD,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,iBAAiB,EACpC,yBAAyB,EAAE,yBAAyB,EACpD,UAAU,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,oBAAC,cAAc,IAAC,OAAO,EAAE,cAAc,CAAC,OAAO,GAAI,CAAC,CAAC,CAAC,IAAI,EACjG,UAAU,EAAE,UAAU,GACtB,CACH,CACQ,CACP,CACP,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,mBAAmB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React, { Ref, useCallback, useEffect, useRef, useState } from 'react';\n\nimport { useAutosuggestItems, useFilteredItems, useKeyboardHandler } from './controller';\nimport { AutosuggestItem, AutosuggestProps } from './interfaces';\n\nimport Dropdown from '../internal/components/dropdown';\nimport { useDropdownStatus } from '../internal/components/dropdown-status';\nimport DropdownFooter from '../internal/components/dropdown-footer';\n\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { getBaseProps } from '../internal/base-component';\nimport { generateUniqueId, useUniqueId } from '../internal/hooks/use-unique-id';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { fireNonCancelableEvent, CancelableEventHandler } from '../internal/events';\nimport { createHighlightedOptionHook } from '../internal/components/options-list/utils/use-highlight-option';\nimport InternalInput from '../input/internal';\nimport { InputProps } from '../input/interfaces';\nimport styles from './styles.css.js';\nimport { checkOptionValueField } from '../select/utils/check-option-value-field';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { fireCancelableEvent } from '../internal/events/index';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport TabTrap from '../internal/components/tab-trap';\nimport AutosuggestOptionsList from './options-list';\n\nexport interface InternalAutosuggestProps extends AutosuggestProps, InternalBaseComponentProps {\n __filterText?: string;\n __dropdownWidth?: number;\n __onOptionClick?: CancelableEventHandler<AutosuggestProps.Option>;\n __disableShowAll?: boolean;\n __hideEnteredTextOption?: boolean;\n __onOpen?: CancelableEventHandler<null>;\n}\n\nconst isInteractive = (option?: AutosuggestItem) => {\n return !!option && !option.disabled && option.type !== 'parent';\n};\n\nconst isHighlightable = (option?: AutosuggestItem) => {\n return !!option && option.type !== 'parent';\n};\n\nconst useHighlightedOption = createHighlightedOptionHook({ isHighlightable: isHighlightable });\n\nconst useLoadMoreItems = (onLoadItems: AutosuggestProps['onLoadItems']) => {\n const lastFilteringText = useRef<string | null>(null);\n return useCallback(\n (firstPage: boolean, samePage: boolean, filteringText?: string) => {\n if (samePage || !firstPage || filteringText === undefined || lastFilteringText.current !== filteringText) {\n if (filteringText !== undefined) {\n lastFilteringText.current = filteringText;\n }\n if (lastFilteringText.current !== null && onLoadItems) {\n fireNonCancelableEvent(onLoadItems, { filteringText: lastFilteringText.current, firstPage, samePage });\n }\n }\n },\n [onLoadItems]\n );\n};\n\nconst InternalAutosuggest = React.forwardRef((props: InternalAutosuggestProps, ref: Ref<InputProps.Ref>) => {\n const {\n value,\n onChange,\n onBlur,\n onFocus,\n onKeyUp,\n onLoadItems,\n options,\n filteringType = 'auto',\n statusType = 'finished',\n placeholder,\n name,\n disabled,\n disableBrowserAutocorrect = false,\n autoFocus,\n readOnly,\n ariaLabel,\n ariaRequired,\n enteredTextLabel,\n onKeyDown,\n virtualScroll,\n expandToViewport,\n onSelect,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n __dropdownWidth,\n __onOptionClick,\n __disableShowAll,\n __hideEnteredTextOption,\n __onOpen,\n __internalRootRef,\n ...rest\n } = props;\n let { __filterText: filterText } = rest;\n filterText = filterText === undefined ? value : filterText;\n\n checkControlled('Autosuggest', 'value', value, 'onChange', onChange);\n checkOptionValueField('Autosuggest', 'options', options);\n\n const usingMouse = useRef(true);\n const [showAll, setShowAll] = useState(false);\n const [open, setOpen] = useState(false);\n const autosuggestItems = useAutosuggestItems(options);\n const filteredItems = useFilteredItems(\n autosuggestItems,\n value,\n filterText,\n filteringType,\n showAll,\n __hideEnteredTextOption\n );\n const openDropdown = () => !readOnly && setOpen(true);\n const scrollToIndex = useRef<(index: number) => void>(null);\n const { highlightedOption, highlightedIndex, moveHighlight, resetHighlight, setHighlightedIndex } =\n useHighlightedOption(filteredItems);\n const closeDropdown = () => {\n setOpen(false);\n resetHighlight();\n };\n const handleBlur: React.FocusEventHandler = event => {\n if (event.currentTarget.contains(event.relatedTarget) || dropdownFooterRef.current?.contains(event.relatedTarget)) {\n return;\n }\n closeDropdown();\n fireNonCancelableEvent(onBlur);\n };\n const selectOption = (option: AutosuggestItem) => {\n const value = option.value || '';\n fireNonCancelableEvent(onChange, { value });\n const selectedCancelled = fireCancelableEvent(__onOptionClick, option);\n if (!selectedCancelled) {\n closeDropdown();\n } else {\n resetHighlight();\n }\n fireNonCancelableEvent(onSelect, { value });\n };\n const selectHighlighted = () => {\n if (highlightedOption) {\n if (isInteractive(highlightedOption)) {\n selectOption(highlightedOption);\n }\n } else {\n closeDropdown();\n }\n };\n\n const fireLoadMore = useLoadMoreItems(onLoadItems);\n\n const handleInputChange: InputProps['onChange'] = e => {\n openDropdown();\n setShowAll(false);\n resetHighlight();\n onChange && onChange(e);\n };\n\n const handleKeyDown = useKeyboardHandler(moveHighlight, openDropdown, selectHighlighted, usingMouse, open, onKeyDown);\n const handleLoadMore = useCallback(() => {\n options && options.length && statusType === 'pending' && fireLoadMore(false, false);\n }, [fireLoadMore, options, statusType]);\n const handleRecoveryClick = useCallback(() => {\n fireLoadMore(false, true);\n inputRef.current?.focus();\n }, [fireLoadMore]);\n\n const formFieldContext = useFormFieldContext(rest);\n const baseProps = getBaseProps(rest);\n const inputRef = useRef<HTMLInputElement>(null);\n const dropdownFooterRef = useRef<HTMLDivElement>(null);\n useForwardFocus(ref, inputRef);\n\n const selfControlId = useUniqueId('input');\n const controlId = formFieldContext.controlId ?? selfControlId;\n const dropdownId = useUniqueId('dropdown');\n const listId = useUniqueId('list');\n\n // From an a11y point of view we only count the dropdown as 'expanded' if there are items that a user can dropdown into\n const expanded = open && filteredItems.length > 1;\n const highlightedOptionId = highlightedOption ? generateUniqueId() : undefined;\n const nativeAttributes = {\n name,\n placeholder,\n autoFocus,\n onClick: openDropdown,\n role: 'combobox',\n 'aria-autocomplete': 'list',\n 'aria-expanded': expanded,\n 'aria-controls': listId,\n // 'aria-owns' needed for safari+vo to announce activedescendant content\n 'aria-owns': listId,\n 'aria-label': ariaLabel,\n 'aria-activedescendant': highlightedOptionId,\n };\n\n const handleInputFocus: InputProps['onFocus'] = e => {\n !__disableShowAll && setShowAll(true);\n const openPrevented = fireCancelableEvent(__onOpen, null);\n if (!openPrevented) {\n openDropdown();\n fireLoadMore(true, false, '');\n }\n onFocus?.(e);\n };\n\n useEffect(() => {\n scrollToIndex.current?.(highlightedIndex);\n }, [highlightedIndex]);\n\n const isEmpty = !value && !filteredItems.length;\n const showRecoveryLink = open && statusType === 'error' && props.recoveryText;\n const dropdownStatus = useDropdownStatus({ ...props, isEmpty, onRecoveryClick: handleRecoveryClick });\n\n const handleMouseDown = (event: React.MouseEvent) => {\n // prevent currently focused element from losing it\n event.preventDefault();\n };\n\n return (\n <div {...baseProps} className={clsx(styles.root, baseProps.className)} ref={__internalRootRef} onBlur={handleBlur}>\n <Dropdown\n minWidth={__dropdownWidth}\n stretchWidth={!__dropdownWidth}\n trigger={\n <>\n <InternalInput\n type=\"search\"\n value={value}\n onChange={handleInputChange}\n __onDelayedInput={event => fireLoadMore(true, false, event.detail.value)}\n onFocus={handleInputFocus}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n disabled={disabled}\n disableBrowserAutocorrect={disableBrowserAutocorrect}\n readOnly={readOnly}\n ariaRequired={ariaRequired}\n ref={inputRef}\n autoComplete={false}\n __nativeAttributes={nativeAttributes}\n {...formFieldContext}\n controlId={controlId}\n />\n <TabTrap\n focusNextCallback={() => dropdownStatus.focusRecoveryLink()}\n disabled={!open || !showRecoveryLink}\n />\n </>\n }\n onMouseDown={handleMouseDown}\n open={open}\n dropdownId={dropdownId}\n footer={\n dropdownStatus.isSticky ? (\n <div ref={dropdownFooterRef} className={styles['dropdown-footer']}>\n <TabTrap focusNextCallback={() => inputRef.current?.focus()} disabled={!showRecoveryLink} />\n <DropdownFooter content={dropdownStatus.content} hasItems={filteredItems.length >= 1} />\n <TabTrap focusNextCallback={() => inputRef.current?.focus()} disabled={!showRecoveryLink} />\n </div>\n ) : null\n }\n expandToViewport={expandToViewport}\n hasContent={filteredItems.length >= 1 || dropdownStatus.content !== null}\n >\n {open && (\n <AutosuggestOptionsList\n options={filteredItems}\n highlightedOption={highlightedOption}\n selectOption={selectOption}\n highlightedIndex={highlightedIndex}\n setHighlightedIndex={setHighlightedIndex}\n highlightedOptionId={highlightedOptionId}\n highlightText={filterText}\n listId={listId}\n controlId={controlId}\n enteredTextLabel={enteredTextLabel}\n handleLoadMore={handleLoadMore}\n hasDropdownStatus={dropdownStatus.content !== null}\n virtualScroll={virtualScroll}\n selectedAriaLabel={selectedAriaLabel}\n renderHighlightedAriaLive={renderHighlightedAriaLive}\n listBottom={!dropdownStatus.isSticky ? <DropdownFooter content={dropdownStatus.content} /> : null}\n usingMouse={usingMouse}\n />\n )}\n </Dropdown>\n </div>\n );\n});\n\nexport default InternalAutosuggest;\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AutosuggestItem, AutosuggestProps } from './interfaces';
|
|
3
|
+
export interface AutosuggestOptionsListProps extends Pick<AutosuggestProps, 'enteredTextLabel' | 'virtualScroll' | 'selectedAriaLabel' | 'renderHighlightedAriaLive'> {
|
|
4
|
+
options: AutosuggestItem[];
|
|
5
|
+
highlightedOption?: AutosuggestItem;
|
|
6
|
+
selectOption: (option: AutosuggestItem) => void;
|
|
7
|
+
highlightedIndex: number;
|
|
8
|
+
setHighlightedIndex: (index: number) => void;
|
|
9
|
+
highlightedOptionId?: string;
|
|
10
|
+
highlightText: string;
|
|
11
|
+
listId: string;
|
|
12
|
+
controlId: string;
|
|
13
|
+
handleLoadMore: () => void;
|
|
14
|
+
hasDropdownStatus?: boolean;
|
|
15
|
+
listBottom?: React.ReactNode;
|
|
16
|
+
usingMouse: React.MutableRefObject<boolean>;
|
|
17
|
+
}
|
|
18
|
+
export default function AutosuggestOptionsList({ options, highlightedOption, selectOption, highlightedIndex, setHighlightedIndex, highlightedOptionId, highlightText, listId, controlId, enteredTextLabel, handleLoadMore, hasDropdownStatus, virtualScroll, selectedAriaLabel, renderHighlightedAriaLive, listBottom, usingMouse, }: AutosuggestOptionsListProps): JSX.Element;
|
|
19
|
+
//# sourceMappingURL=options-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options-list.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/options-list.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAOjE,MAAM,WAAW,2BACf,SAAQ,IAAI,CACV,gBAAgB,EAChB,kBAAkB,GAAG,eAAe,GAAG,mBAAmB,GAAG,2BAA2B,CACzF;IACD,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,iBAAiB,CAAC,EAAE,eAAe,CAAC;IACpC,YAAY,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IAChD,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B,UAAU,EAAE,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;CAC7C;AAmBD,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAC7C,OAAO,EACP,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,MAAM,EACN,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EACzB,UAAU,EACV,UAAU,GACX,EAAE,2BAA2B,eAgC7B"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { useSelectVisibleOption, useHighlightVisibleOption, getParentGroup } from './controller';
|
|
5
|
+
import VirtualList from './virtual-list';
|
|
6
|
+
import PlainList from './plain-list';
|
|
7
|
+
import { useAnnouncement } from '../select/utils/use-announcement';
|
|
8
|
+
var isInteractive = function (option) {
|
|
9
|
+
return !!option && !option.disabled && option.type !== 'parent';
|
|
10
|
+
};
|
|
11
|
+
var isHighlightable = function (option) {
|
|
12
|
+
return !!option && option.type !== 'parent';
|
|
13
|
+
};
|
|
14
|
+
var createMouseEventHandler = function (handler, usingMouse) { return function (itemIndex) {
|
|
15
|
+
// prevent mouse events to avoid losing focus from the input
|
|
16
|
+
usingMouse.current = true;
|
|
17
|
+
if (itemIndex > -1) {
|
|
18
|
+
handler(itemIndex);
|
|
19
|
+
}
|
|
20
|
+
}; };
|
|
21
|
+
export default function AutosuggestOptionsList(_a) {
|
|
22
|
+
var options = _a.options, highlightedOption = _a.highlightedOption, selectOption = _a.selectOption, highlightedIndex = _a.highlightedIndex, setHighlightedIndex = _a.setHighlightedIndex, highlightedOptionId = _a.highlightedOptionId, highlightText = _a.highlightText, listId = _a.listId, controlId = _a.controlId, enteredTextLabel = _a.enteredTextLabel, handleLoadMore = _a.handleLoadMore, hasDropdownStatus = _a.hasDropdownStatus, virtualScroll = _a.virtualScroll, selectedAriaLabel = _a.selectedAriaLabel, renderHighlightedAriaLive = _a.renderHighlightedAriaLive, listBottom = _a.listBottom, usingMouse = _a.usingMouse;
|
|
23
|
+
var highlightVisibleOption = useHighlightVisibleOption(options, setHighlightedIndex, isHighlightable);
|
|
24
|
+
var selectVisibleOption = useSelectVisibleOption(options, selectOption, isInteractive);
|
|
25
|
+
var handleMouseUp = createMouseEventHandler(selectVisibleOption, usingMouse);
|
|
26
|
+
var handleMouseMove = createMouseEventHandler(highlightVisibleOption, usingMouse);
|
|
27
|
+
var ListComponent = virtualScroll ? VirtualList : PlainList;
|
|
28
|
+
var announcement = useAnnouncement({
|
|
29
|
+
announceSelected: true,
|
|
30
|
+
highlightedOption: highlightedOption,
|
|
31
|
+
getParent: function (option) { var _a; return (_a = getParentGroup(option)) === null || _a === void 0 ? void 0 : _a.option; },
|
|
32
|
+
selectedAriaLabel: selectedAriaLabel,
|
|
33
|
+
renderHighlightedAriaLive: renderHighlightedAriaLive
|
|
34
|
+
});
|
|
35
|
+
return (React.createElement(ListComponent, { listBottom: listBottom, handleLoadMore: handleLoadMore, filteredItems: options, highlightText: highlightText, usingMouse: usingMouse, highlightedOption: highlightedOption, highlightedIndex: highlightedIndex, enteredTextLabel: enteredTextLabel, highlightedA11yProps: highlightedOptionId ? { id: highlightedOptionId } : {}, hasDropdownStatus: hasDropdownStatus, menuProps: { id: listId, ariaLabelledby: controlId, onMouseUp: handleMouseUp, onMouseMove: handleMouseMove }, screenReaderContent: announcement }));
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=options-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options-list.js","sourceRoot":"","sources":["../../../src/autosuggest/options-list.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEjG,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAuBnE,IAAM,aAAa,GAAG,UAAC,MAAwB;IAC7C,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;AAClE,CAAC,CAAC;AAEF,IAAM,eAAe,GAAG,UAAC,MAAwB;IAC/C,OAAO,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC9C,CAAC,CAAC;AAEF,IAAM,uBAAuB,GAC3B,UAAC,OAAgC,EAAE,UAA2C,IAAK,OAAA,UAAC,SAAiB;IACnG,4DAA4D;IAC5D,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;IAC1B,IAAI,SAAS,GAAG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ACtB,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,UAAU,EACtB,iBAAiB,EAAE,iBAAiB,EACpC,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,oBAAoB,EAAE,mBAAmB,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,mBAAmB,EAAE,CAAC,CAAC,CAAC,EAAE,EAC5E,iBAAiB,EAAE,iBAAiB,EACpC,SAAS,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,eAAe,EAAE,EAC5G,mBAAmB,EAAE,YAAY,GACjC,CACH,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { useSelectVisibleOption, useHighlightVisibleOption, getParentGroup } from './controller';\nimport { AutosuggestItem, AutosuggestProps } from './interfaces';\nimport VirtualList from './virtual-list';\nimport PlainList from './plain-list';\n\nimport { useAnnouncement } from '../select/utils/use-announcement';\nimport { OptionGroup } from '../internal/components/option/interfaces';\n\nexport interface AutosuggestOptionsListProps\n extends Pick<\n AutosuggestProps,\n 'enteredTextLabel' | 'virtualScroll' | 'selectedAriaLabel' | 'renderHighlightedAriaLive'\n > {\n options: AutosuggestItem[];\n highlightedOption?: AutosuggestItem;\n selectOption: (option: AutosuggestItem) => void;\n highlightedIndex: number;\n setHighlightedIndex: (index: number) => void;\n highlightedOptionId?: string;\n highlightText: string;\n listId: string;\n controlId: string;\n handleLoadMore: () => void;\n hasDropdownStatus?: boolean;\n listBottom?: React.ReactNode;\n usingMouse: React.MutableRefObject<boolean>;\n}\n\nconst isInteractive = (option?: AutosuggestItem) => {\n return !!option && !option.disabled && option.type !== 'parent';\n};\n\nconst isHighlightable = (option?: AutosuggestItem) => {\n return !!option && option.type !== 'parent';\n};\n\nconst createMouseEventHandler =\n (handler: (index: number) => void, usingMouse: React.MutableRefObject<boolean>) => (itemIndex: number) => {\n // prevent mouse events to avoid losing focus from the input\n usingMouse.current = true;\n if (itemIndex > -1) {\n handler(itemIndex);\n }\n };\n\nexport default function AutosuggestOptionsList({\n options,\n highlightedOption,\n selectOption,\n highlightedIndex,\n setHighlightedIndex,\n highlightedOptionId,\n highlightText,\n listId,\n controlId,\n enteredTextLabel,\n handleLoadMore,\n hasDropdownStatus,\n virtualScroll,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n listBottom,\n usingMouse,\n}: AutosuggestOptionsListProps) {\n const highlightVisibleOption = useHighlightVisibleOption(options, setHighlightedIndex, isHighlightable);\n const selectVisibleOption = useSelectVisibleOption(options, selectOption, isInteractive);\n const handleMouseUp = createMouseEventHandler(selectVisibleOption, usingMouse);\n const handleMouseMove = createMouseEventHandler(highlightVisibleOption, usingMouse);\n\n const ListComponent = virtualScroll ? VirtualList : PlainList;\n\n const announcement = useAnnouncement({\n announceSelected: true,\n highlightedOption,\n getParent: option => getParentGroup(option)?.option as undefined | OptionGroup,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n });\n\n return (\n <ListComponent\n listBottom={listBottom}\n handleLoadMore={handleLoadMore}\n filteredItems={options}\n highlightText={highlightText}\n usingMouse={usingMouse}\n highlightedOption={highlightedOption}\n highlightedIndex={highlightedIndex}\n enteredTextLabel={enteredTextLabel}\n highlightedA11yProps={highlightedOptionId ? { id: highlightedOptionId } : {}}\n hasDropdownStatus={hasDropdownStatus}\n menuProps={{ id: listId, ariaLabelledby: controlId, onMouseUp: handleMouseUp, onMouseMove: handleMouseMove }}\n screenReaderContent={announcement}\n />\n );\n}\n"]}
|
|
@@ -7,6 +7,7 @@ export interface ListProps {
|
|
|
7
7
|
filteredItems: AutosuggestItem[];
|
|
8
8
|
usingMouse: React.MutableRefObject<boolean>;
|
|
9
9
|
highlightedOption?: AutosuggestItem;
|
|
10
|
+
highlightedIndex: number;
|
|
10
11
|
enteredTextLabel: AutosuggestProps.EnteredTextLabel;
|
|
11
12
|
highlightedA11yProps: Record<string, string | number | boolean>;
|
|
12
13
|
hasDropdownStatus?: boolean;
|
|
@@ -14,15 +15,12 @@ export interface ListProps {
|
|
|
14
15
|
listBottom?: React.ReactNode;
|
|
15
16
|
screenReaderContent?: string;
|
|
16
17
|
}
|
|
17
|
-
declare namespace PlainListProps {
|
|
18
|
-
type PlainListRef = (index: number) => void;
|
|
19
|
-
}
|
|
20
18
|
export declare const getOptionProps: (index: number, item: AutosuggestItem, filteredItems: AutosuggestItem[], highlightedA11yProps: ListProps['highlightedA11yProps'], highlightedOption?: ListProps['highlightedOption'], hasDropdownStatus?: boolean | undefined) => {
|
|
21
19
|
className?: string | undefined;
|
|
22
20
|
id?: string | undefined;
|
|
23
21
|
nativeAttributes: Record<string, string | number | boolean>;
|
|
24
22
|
padBottom: boolean;
|
|
25
23
|
};
|
|
26
|
-
declare const
|
|
27
|
-
export default
|
|
24
|
+
declare const PlainList: ({ handleLoadMore, filteredItems, usingMouse, menuProps, highlightedOption, highlightedIndex, enteredTextLabel, highlightedA11yProps, hasDropdownStatus, highlightText, listBottom, screenReaderContent, }: ListProps) => JSX.Element;
|
|
25
|
+
export default PlainList;
|
|
28
26
|
//# sourceMappingURL=plain-list.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plain-list.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/plain-list.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"plain-list.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/plain-list.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,OAAoB,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAKpF,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGjE,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;IAC9C,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,aAAa,EAAE,eAAe,EAAE,CAAC;IACjC,UAAU,EAAE,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC5C,iBAAiB,CAAC,EAAE,eAAe,CAAC;IACpC,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,gBAAgB,CAAC,gBAAgB,CAAC;IACpD,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;IAChE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,eAAO,MAAM,cAAc,UAClB,MAAM,QACP,eAAe,iBACN,eAAe,EAAE,wBACV,SAAS,CAAC,sBAAsB,CAAC,sBACnC,SAAS,CAAC,mBAAmB,CAAC;;;;;CAUnD,CAAC;AAEF,QAAA,MAAM,SAAS,8MAaZ,SAAS,gBAiDX,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __assign } from "tslib";
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
import React, {
|
|
4
|
+
import React, { useEffect, useRef } from 'react';
|
|
5
5
|
import OptionsList from '../internal/components/options-list';
|
|
6
6
|
import { scrollUntilVisible } from '../internal/utils/scrollable-containers';
|
|
7
7
|
import { getBaseProps } from '../internal/base-component';
|
|
@@ -15,16 +15,16 @@ export var getOptionProps = function (index, item, filteredItems, highlightedA11
|
|
|
15
15
|
var padBottom = !hasDropdownStatus && isNotEnteredTextItem && isLastItem;
|
|
16
16
|
return __assign({ nativeAttributes: nativeAttributes, padBottom: padBottom }, baseOptionProps);
|
|
17
17
|
};
|
|
18
|
-
var PlainList = function (_a
|
|
19
|
-
var handleLoadMore = _a.handleLoadMore, filteredItems = _a.filteredItems, usingMouse = _a.usingMouse, menuProps = _a.menuProps, highlightedOption = _a.highlightedOption, enteredTextLabel = _a.enteredTextLabel, highlightedA11yProps = _a.highlightedA11yProps, hasDropdownStatus = _a.hasDropdownStatus, highlightText = _a.highlightText, listBottom = _a.listBottom, screenReaderContent = _a.screenReaderContent;
|
|
18
|
+
var PlainList = function (_a) {
|
|
19
|
+
var handleLoadMore = _a.handleLoadMore, filteredItems = _a.filteredItems, usingMouse = _a.usingMouse, menuProps = _a.menuProps, highlightedOption = _a.highlightedOption, highlightedIndex = _a.highlightedIndex, enteredTextLabel = _a.enteredTextLabel, highlightedA11yProps = _a.highlightedA11yProps, hasDropdownStatus = _a.hasDropdownStatus, highlightText = _a.highlightText, listBottom = _a.listBottom, screenReaderContent = _a.screenReaderContent;
|
|
20
20
|
var listRef = useRef(null);
|
|
21
|
-
|
|
21
|
+
useEffect(function () {
|
|
22
22
|
var _a;
|
|
23
|
-
var item = (_a = listRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("[data-mouse-target=\"".concat(
|
|
23
|
+
var item = (_a = listRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("[data-mouse-target=\"".concat(highlightedIndex, "\"]"));
|
|
24
24
|
if (!usingMouse.current && item) {
|
|
25
25
|
scrollUntilVisible(item);
|
|
26
26
|
}
|
|
27
|
-
}
|
|
27
|
+
}, [usingMouse, highlightedIndex]);
|
|
28
28
|
return (React.createElement(OptionsList, __assign({}, menuProps, { onLoadMore: handleLoadMore, open: true, ref: listRef,
|
|
29
29
|
// to prevent closing the list when clicking the scrollbar on IE11
|
|
30
30
|
nativeAttributes: { unselectable: 'on' } }),
|
|
@@ -34,5 +34,5 @@ var PlainList = function (_a, ref) {
|
|
|
34
34
|
}),
|
|
35
35
|
listBottom ? (React.createElement("li", { role: "option", className: styles['list-bottom'] }, listBottom)) : null));
|
|
36
36
|
};
|
|
37
|
-
export default
|
|
37
|
+
export default PlainList;
|
|
38
38
|
//# sourceMappingURL=plain-list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plain-list.js","sourceRoot":"","sources":["../../../src/autosuggest/plain-list.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"plain-list.js","sourceRoot":"","sources":["../../../src/autosuggest/plain-list.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,WAAiC,MAAM,qCAAqC,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AAErD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAiBrC,MAAM,CAAC,IAAM,cAAc,GAAG,UAC5B,KAAa,EACb,IAAqB,EACrB,aAAgC,EAChC,oBAAuD,EACvD,iBAAkD,EAClD,iBAA2B;IAE3B,IAAM,gBAAgB,GAAG,IAAI,KAAK,iBAAiB,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;IAChF,IAAM,eAAe,GAAG,YAAY,CAAC,gBAAgB,CAAC,CAAC;IACvD,IAAM,UAAU,GAAG,KAAK,KAAK,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;IACtD,IAAM,oBAAoB,GAAG,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;IACtD,IAAM,SAAS,GAAG,CAAC,iBAAiB,IAAI,oBAAoB,IAAI,UAAU,CAAC;IAE3E,kBAAS,gBAAgB,kBAAA,EAAE,SAAS,WAAA,IAAK,eAAe,E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;QACJ,CAAC,CAAC;QACD,UAAU,CAAC,CAAC,CAAC,CACZ,4BAAI,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAE,MAAM,CAAC,aAAa,CAAC,IAC/C,UAAU,CACR,CACN,CAAC,CAAC,CAAC,IAAI,CACI,CACf,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef } from 'react';\n\nimport OptionsList, { OptionsListProps } from '../internal/components/options-list';\nimport { scrollUntilVisible } from '../internal/utils/scrollable-containers';\nimport { getBaseProps } from '../internal/base-component';\n\nimport AutosuggestOption from './autosuggest-option';\nimport { AutosuggestProps, AutosuggestItem } from './interfaces';\nimport styles from './styles.css.js';\n\nexport interface ListProps {\n menuProps: Omit<OptionsListProps, 'children'>;\n handleLoadMore: () => void;\n filteredItems: AutosuggestItem[];\n usingMouse: React.MutableRefObject<boolean>;\n highlightedOption?: AutosuggestItem;\n highlightedIndex: number;\n enteredTextLabel: AutosuggestProps.EnteredTextLabel;\n highlightedA11yProps: Record<string, string | number | boolean>;\n hasDropdownStatus?: boolean;\n highlightText: string;\n listBottom?: React.ReactNode;\n screenReaderContent?: string;\n}\n\nexport const getOptionProps = (\n index: number,\n item: AutosuggestItem,\n filteredItems: AutosuggestItem[],\n highlightedA11yProps: ListProps['highlightedA11yProps'],\n highlightedOption?: ListProps['highlightedOption'],\n hasDropdownStatus?: boolean\n) => {\n const nativeAttributes = item === highlightedOption ? highlightedA11yProps : {};\n const baseOptionProps = getBaseProps(nativeAttributes);\n const isLastItem = index === filteredItems.length - 1;\n const isNotEnteredTextItem = filteredItems.length > 1;\n const padBottom = !hasDropdownStatus && isNotEnteredTextItem && isLastItem;\n\n return { nativeAttributes, padBottom, ...baseOptionProps };\n};\n\nconst PlainList = ({\n handleLoadMore,\n filteredItems,\n usingMouse,\n menuProps,\n highlightedOption,\n highlightedIndex,\n enteredTextLabel,\n highlightedA11yProps,\n hasDropdownStatus,\n highlightText,\n listBottom,\n screenReaderContent,\n}: ListProps) => {\n const listRef = useRef<HTMLUListElement>(null);\n\n useEffect(() => {\n const item = listRef.current?.querySelector(`[data-mouse-target=\"${highlightedIndex}\"]`);\n if (!usingMouse.current && item) {\n scrollUntilVisible(item as HTMLElement);\n }\n }, [usingMouse, highlightedIndex]);\n\n return (\n <OptionsList\n {...menuProps}\n onLoadMore={handleLoadMore}\n open={true}\n ref={listRef}\n // to prevent closing the list when clicking the scrollbar on IE11\n nativeAttributes={{ unselectable: 'on' }}\n >\n {filteredItems.map((item, index) => {\n const optionProps = getOptionProps(\n index,\n item,\n filteredItems,\n highlightedA11yProps,\n highlightedOption,\n hasDropdownStatus\n );\n\n return (\n <AutosuggestOption\n highlightText={highlightText}\n option={item}\n highlighted={item === highlightedOption}\n key={index}\n data-mouse-target={index}\n enteredTextLabel={enteredTextLabel}\n screenReaderContent={screenReaderContent}\n {...optionProps}\n />\n );\n })}\n {listBottom ? (\n <li role=\"option\" className={styles['list-bottom']}>\n {listBottom}\n </li>\n ) : null}\n </OptionsList>\n );\n};\n\nexport default PlainList;\n"]}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { ListProps } from './plain-list';
|
|
3
|
-
declare
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
declare const _default: React.ForwardRefExoticComponent<ListProps & React.RefAttributes<VirtualListProps.VirtualListRef>>;
|
|
7
|
-
export default _default;
|
|
2
|
+
declare const VirtualList: ({ handleLoadMore, filteredItems, usingMouse, menuProps, highlightedOption, highlightedIndex, enteredTextLabel, highlightedA11yProps, hasDropdownStatus, highlightText, listBottom, screenReaderContent, }: ListProps) => JSX.Element;
|
|
3
|
+
export default VirtualList;
|
|
8
4
|
//# sourceMappingURL=virtual-list.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-list.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/virtual-list.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"virtual-list.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/virtual-list.tsx"],"names":[],"mappings":"AASA,OAAO,EAAkB,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzD,QAAA,MAAM,WAAW,8MAad,SAAS,gBA0EX,CAAC;AAEF,eAAe,WAAW,CAAC"}
|