@cloudscape-design/components 3.0.581 → 3.0.583

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.
@@ -96,16 +96,16 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
96
96
  Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
97
97
  SPDX-License-Identifier: Apache-2.0
98
98
  */
99
- .awsui_placeholder_dwuol_jewio_99:not(#\9) {
99
+ .awsui_placeholder_dwuol_18z0d_99:not(#\9) {
100
100
  color: var(--color-text-input-placeholder-mx1ygd, #5f6b7a);
101
101
  font-style: italic;
102
102
  }
103
103
 
104
- .awsui_item_dwuol_jewio_104:not(#\9) {
104
+ .awsui_item_dwuol_18z0d_104:not(#\9) {
105
105
  display: flex;
106
106
  align-items: center;
107
107
  }
108
- .awsui_item_dwuol_jewio_104 > .awsui_checkbox_dwuol_jewio_108:not(#\9) {
108
+ .awsui_item_dwuol_18z0d_104 > .awsui_checkbox_dwuol_18z0d_108:not(#\9) {
109
109
  position: relative;
110
110
  min-block-size: var(--size-control-28i7hr, 16px);
111
111
  min-inline-size: var(--size-control-28i7hr, 16px);
@@ -114,43 +114,43 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
114
114
  margin-inline-end: var(--space-field-horizontal-gg19kw, 12px);
115
115
  }
116
116
 
117
- .awsui_filter_dwuol_jewio_117:not(#\9) {
117
+ .awsui_filter_dwuol_18z0d_117:not(#\9) {
118
118
  z-index: 4;
119
119
  flex-shrink: 0;
120
120
  }
121
121
 
122
- .awsui_trigger_dwuol_jewio_122:not(#\9) {
122
+ .awsui_trigger_dwuol_18z0d_122:not(#\9) {
123
123
  white-space: nowrap;
124
124
  overflow: hidden;
125
125
  text-overflow: ellipsis;
126
126
  }
127
127
 
128
- .awsui_layout-strut_dwuol_jewio_128:not(#\9) {
128
+ .awsui_layout-strut_dwuol_18z0d_128:not(#\9) {
129
129
  inline-size: 100%;
130
130
  position: relative;
131
131
  transform: translate3d(0, 0, 0);
132
132
  }
133
133
 
134
- .awsui_list-bottom_dwuol_jewio_134:not(#\9) {
134
+ .awsui_list-bottom_dwuol_18z0d_134:not(#\9) {
135
135
  /* used in unit-tests */
136
136
  }
137
137
 
138
- .awsui_selected-icon_dwuol_jewio_138:not(#\9) {
138
+ .awsui_selected-icon_dwuol_18z0d_138:not(#\9) {
139
139
  color: var(--color-border-item-focused-b2ntyl, #0972d3);
140
140
  }
141
141
 
142
- .awsui_show-label-tag_dwuol_jewio_142 > .awsui_selected-icon_dwuol_jewio_138:not(#\9) {
142
+ .awsui_show-label-tag_dwuol_18z0d_142 > .awsui_selected-icon_dwuol_18z0d_138:not(#\9) {
143
143
  padding-inline-start: var(--space-scaled-s-aqzyko, 12px);
144
144
  }
145
145
 
146
- .awsui_inline-token-trigger_dwuol_jewio_146:not(#\9) {
146
+ .awsui_inline-token-trigger_dwuol_18z0d_146:not(#\9) {
147
147
  display: flex;
148
148
  flex-wrap: nowrap;
149
149
  column-gap: var(--space-xxs-p8yyaw, 4px);
150
150
  inline-size: 100%;
151
151
  }
152
152
 
153
- .awsui_inline-token-list_dwuol_jewio_153:not(#\9) {
153
+ .awsui_inline-token-list_dwuol_18z0d_153:not(#\9) {
154
154
  display: flex;
155
155
  flex-wrap: nowrap;
156
156
  align-items: center;
@@ -160,7 +160,11 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
160
160
  -webkit-mask-image: linear-gradient(270deg, transparent, white 20px, white);
161
161
  mask-image: linear-gradient(270deg, transparent, white 20px, white);
162
162
  }
163
- .awsui_inline-token-list_dwuol_jewio_153 > .awsui_inline-token_dwuol_jewio_146:not(#\9) {
163
+ .awsui_inline-token-list_dwuol_18z0d_153:not(#\9):dir(rtl) {
164
+ -webkit-mask-image: linear-gradient(-270deg, transparent, white 20px, white);
165
+ mask-image: linear-gradient(-270deg, transparent, white 20px, white);
166
+ }
167
+ .awsui_inline-token-list_dwuol_18z0d_153 > .awsui_inline-token_dwuol_18z0d_146:not(#\9) {
164
168
  display: flex;
165
169
  align-items: center;
166
170
  min-inline-size: max-content;
@@ -177,24 +181,24 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
177
181
  color: var(--color-text-body-default-at06ol, #000716);
178
182
  }
179
183
 
180
- .awsui_visual-refresh_dwuol_jewio_179 > .awsui_inline-token-list_dwuol_jewio_153 > .awsui_inline-token_dwuol_jewio_146:not(#\9) {
184
+ .awsui_visual-refresh_dwuol_18z0d_182 > .awsui_inline-token-list_dwuol_18z0d_153 > .awsui_inline-token_dwuol_18z0d_146:not(#\9) {
181
185
  border-start-start-radius: var(--border-radius-badge-0z09dt, 4px);
182
186
  border-start-end-radius: var(--border-radius-badge-0z09dt, 4px);
183
187
  border-end-start-radius: var(--border-radius-badge-0z09dt, 4px);
184
188
  border-end-end-radius: var(--border-radius-badge-0z09dt, 4px);
185
189
  }
186
190
 
187
- .awsui_inline-token-hidden-placeholder_dwuol_jewio_186:not(#\9) {
191
+ .awsui_inline-token-hidden-placeholder_dwuol_18z0d_189:not(#\9) {
188
192
  position: absolute !important;
189
193
  inset-block-start: -9999px !important;
190
194
  inset-inline-start: -9999px !important;
191
195
  }
192
196
 
193
- .awsui_inline-token-counter_dwuol_jewio_192:not(#\9) {
197
+ .awsui_inline-token-counter_dwuol_18z0d_195:not(#\9) {
194
198
  white-space: nowrap;
195
199
  }
196
200
 
197
- .awsui_inline-token-trigger--disabled_dwuol_jewio_196 > .awsui_inline-token-list_dwuol_jewio_153 > .awsui_inline-token_dwuol_jewio_146:not(#\9) {
201
+ .awsui_inline-token-trigger--disabled_dwuol_18z0d_199 > .awsui_inline-token-list_dwuol_18z0d_153 > .awsui_inline-token_dwuol_18z0d_146:not(#\9) {
198
202
  border-color: var(--color-border-control-disabled-bv2kkn, #d1d5db);
199
203
  background-color: var(--color-background-container-content-4un1ap, #ffffff);
200
204
  color: var(--color-text-disabled-f4c52h, #9ba7b6);
@@ -2,21 +2,21 @@
2
2
  // es-module interop with Babel and Typescript
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  module.exports.default = {
5
- "placeholder": "awsui_placeholder_dwuol_jewio_99",
6
- "item": "awsui_item_dwuol_jewio_104",
7
- "checkbox": "awsui_checkbox_dwuol_jewio_108",
8
- "filter": "awsui_filter_dwuol_jewio_117",
9
- "trigger": "awsui_trigger_dwuol_jewio_122",
10
- "layout-strut": "awsui_layout-strut_dwuol_jewio_128",
11
- "list-bottom": "awsui_list-bottom_dwuol_jewio_134",
12
- "selected-icon": "awsui_selected-icon_dwuol_jewio_138",
13
- "show-label-tag": "awsui_show-label-tag_dwuol_jewio_142",
14
- "inline-token-trigger": "awsui_inline-token-trigger_dwuol_jewio_146",
15
- "inline-token-list": "awsui_inline-token-list_dwuol_jewio_153",
16
- "inline-token": "awsui_inline-token_dwuol_jewio_146",
17
- "visual-refresh": "awsui_visual-refresh_dwuol_jewio_179",
18
- "inline-token-hidden-placeholder": "awsui_inline-token-hidden-placeholder_dwuol_jewio_186",
19
- "inline-token-counter": "awsui_inline-token-counter_dwuol_jewio_192",
20
- "inline-token-trigger--disabled": "awsui_inline-token-trigger--disabled_dwuol_jewio_196"
5
+ "placeholder": "awsui_placeholder_dwuol_18z0d_99",
6
+ "item": "awsui_item_dwuol_18z0d_104",
7
+ "checkbox": "awsui_checkbox_dwuol_18z0d_108",
8
+ "filter": "awsui_filter_dwuol_18z0d_117",
9
+ "trigger": "awsui_trigger_dwuol_18z0d_122",
10
+ "layout-strut": "awsui_layout-strut_dwuol_18z0d_128",
11
+ "list-bottom": "awsui_list-bottom_dwuol_18z0d_134",
12
+ "selected-icon": "awsui_selected-icon_dwuol_18z0d_138",
13
+ "show-label-tag": "awsui_show-label-tag_dwuol_18z0d_142",
14
+ "inline-token-trigger": "awsui_inline-token-trigger_dwuol_18z0d_146",
15
+ "inline-token-list": "awsui_inline-token-list_dwuol_18z0d_153",
16
+ "inline-token": "awsui_inline-token_dwuol_18z0d_146",
17
+ "visual-refresh": "awsui_visual-refresh_dwuol_18z0d_182",
18
+ "inline-token-hidden-placeholder": "awsui_inline-token-hidden-placeholder_dwuol_18z0d_189",
19
+ "inline-token-counter": "awsui_inline-token-counter_dwuol_18z0d_195",
20
+ "inline-token-trigger--disabled": "awsui_inline-token-trigger--disabled_dwuol_18z0d_199"
21
21
  };
22
22
 
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
- import { DropdownOption, OptionDefinition } from '../../internal/components/option/interfaces';
3
- export declare const isChar: (keyCode: number) => boolean;
2
+ import type { DropdownOption, OptionDefinition } from '../../internal/components/option/interfaces';
4
3
  export declare const isRepeatedChar: (str: string) => boolean;
5
4
  interface UseNativeSearchProps {
6
5
  isEnabled: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"use-native-search.d.ts","sourceRoot":"","sources":["../../../../src/select/utils/use-native-search.ts"],"names":[],"mappings":"AAEA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAQtC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAe,MAAM,6CAA6C,CAAC;AAG5G,eAAO,MAAM,MAAM,YAAa,MAAM,KAAG,OAExC,CAAC;AAEF,eAAO,MAAM,cAAc,QAAS,MAAM,YAA2C,CAAC;AAEtF,UAAU,oBAAoB;IAC5B,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IACvC,eAAe,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IAClD,iBAAiB,EAAE,gBAAgB,GAAG,SAAS,GAAG,IAAI,CAAC;IACvD,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AA6CD,wBAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,OAAO,EACP,eAAe,EACf,iBAAiB,EACjB,oBAAoB,GACrB,EAAE,oBAAoB,WAKN,mBAAmB,UAkBnC"}
1
+ {"version":3,"file":"use-native-search.d.ts","sourceRoot":"","sources":["../../../../src/select/utils/use-native-search.ts"],"names":[],"mappings":"AAEA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAQtC,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAe,MAAM,6CAA6C,CAAC;AAGjH,eAAO,MAAM,cAAc,QAAS,MAAM,YAA2C,CAAC;AAEtF,UAAU,oBAAoB;IAC5B,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IACvC,eAAe,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IAClD,iBAAiB,EAAE,gBAAgB,GAAG,SAAS,GAAG,IAAI,CAAC;IACvD,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AA6CD,wBAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,OAAO,EACP,eAAe,EACf,iBAAiB,EACjB,oBAAoB,GACrB,EAAE,oBAAoB,WAKN,mBAAmB,UAoBnC"}
@@ -1,12 +1,8 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { useRef } from 'react';
4
- import { KeyCode } from '../../internal/keycode';
5
4
  import { filterOptions, isInteractive, isGroupInteractive, isGroup, } from '../../internal/components/option/utils/filter-options';
6
5
  import { useDebounceCallback } from '../../internal/hooks/use-debounce-callback';
7
- export const isChar = (keyCode) => {
8
- return [0, KeyCode.enter, KeyCode.space, KeyCode.tab].indexOf(keyCode) === -1;
9
- };
10
6
  export const isRepeatedChar = (str) => str.split('').every(c => c === str[0]);
11
7
  function findMatchingOption(options, searchText, currentHighlight, useInteractiveGroups) {
12
8
  const interactivityCheck = useInteractiveGroups ? isGroupInteractive : isInteractive;
@@ -46,12 +42,12 @@ export function useNativeSearch({ isEnabled, options, highlightOption, highlight
46
42
  if (!isEnabled) {
47
43
  return;
48
44
  }
49
- const { charCode } = event;
50
- if (!isChar(charCode)) {
45
+ const { key } = event;
46
+ if (!key || key.length !== 1) {
51
47
  return;
52
48
  }
53
49
  delayedResetValue();
54
- const newValue = value.current + String.fromCharCode(charCode);
50
+ const newValue = value.current + key;
55
51
  value.current = newValue;
56
52
  const nextHighlight = findMatchingOption(options, newValue, highlightedOption, useInteractiveGroups);
57
53
  if (nextHighlight) {
@@ -1 +1 @@
1
- {"version":3,"file":"use-native-search.js","sourceRoot":"","sources":["../../../../src/select/utils/use-native-search.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAc,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EACL,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,OAAO,GACR,MAAM,uDAAuD,CAAC;AAE/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AAEjF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,OAAe,EAAW,EAAE;IACjD,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AAChF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAUtF,SAAS,kBAAkB,CACzB,OAAsC,EACtC,UAAkB,EAClB,gBAAmE,EACnE,oBAA8B;IAE9B,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,aAAa,CAAC;IACrF,MAAM,MAAM,GAAG,CAAC,UAAkB,EAAE,EAAE,CACpC,aAAa,CAA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ACT,OAAO,EACP,eAAe,EACf,iBAAiB,EACjB,oBAAoB,GACC;IACrB,MAAM,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;IAEzB,MAAM,iBAAiB,GAAG,mBAAmB,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;IAE/E,OAAO,CAAC,KAA0B,EAAE,EAAE;QACpC,IAAI,CAAC,SAAS,EAAE;YACd,OAAO;SACR;QAED,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;QAC3B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;YACrB,OAAO;SACR;QACD,iBAAiB,EAAE,CAAC;QACpB,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC/D,KAAK,CAAC,OAAO,GAAG,QAAQ,CAAC;QAEzB,MAAM,aAAa,GAAG,kBAAkB,CAAC,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;QACrG,IAAI,aAAa,EAAE;YACjB,eAAe,CAAC,aAAa,CAAC,CAAC;SAChC;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\nimport { KeyCode } from '../../internal/keycode';\nimport {\n filterOptions,\n isInteractive,\n isGroupInteractive,\n isGroup,\n} from '../../internal/components/option/utils/filter-options';\nimport { DropdownOption, OptionDefinition, OptionGroup } from '../../internal/components/option/interfaces';\nimport { useDebounceCallback } from '../../internal/hooks/use-debounce-callback';\n\nexport const isChar = (keyCode: number): boolean => {\n return [0, KeyCode.enter, KeyCode.space, KeyCode.tab].indexOf(keyCode) === -1;\n};\n\nexport const isRepeatedChar = (str: string) => str.split('').every(c => c === str[0]);\n\ninterface UseNativeSearchProps {\n isEnabled: boolean;\n options: ReadonlyArray<DropdownOption>;\n highlightOption: (option: DropdownOption) => void;\n highlightedOption: OptionDefinition | undefined | null;\n useInteractiveGroups?: boolean;\n}\n\nfunction findMatchingOption(\n options: ReadonlyArray<DropdownOption>,\n searchText: string,\n currentHighlight: OptionDefinition | OptionGroup | undefined | null,\n useInteractiveGroups?: boolean\n) {\n const interactivityCheck = useInteractiveGroups ? isGroupInteractive : isInteractive;\n const filter = (searchText: string) =>\n filterOptions(options, searchText, true).filter(option => interactivityCheck(option));\n const matchingOptions = filter(searchText);\n\n if (matchingOptions.length === 1) {\n return matchingOptions[0];\n }\n\n // Hit the same char over and over, we assume they want to cycle through\n if (currentHighlight && searchText.length > 1 && isRepeatedChar(searchText)) {\n const matchingOptions = filter(searchText[0]);\n\n if (matchingOptions.length > 0) {\n //handling OptionGroups when useInteractiveGroups is set\n let active: number = isGroup(currentHighlight)\n ? matchingOptions.map(({ option }) => option).indexOf(currentHighlight)\n : matchingOptions\n .map(({ option }) => (option as OptionDefinition).value)\n .indexOf((currentHighlight as OptionDefinition).value);\n\n // Pick the next thing (if something with this prefix wasn't selected\n // we'll end up with the first option)\n active += 1;\n active = active % matchingOptions.length;\n return matchingOptions[active];\n }\n }\n\n // We have multiple things that start with this prefix. Based on the\n // behavior of native select, this is considered after the repeated case\n if (matchingOptions.length > 0) {\n return matchingOptions[0];\n }\n return null;\n}\n\nexport function useNativeSearch({\n isEnabled,\n options,\n highlightOption,\n highlightedOption,\n useInteractiveGroups,\n}: UseNativeSearchProps) {\n const value = useRef('');\n\n const delayedResetValue = useDebounceCallback(() => (value.current = ''), 500);\n\n return (event: React.KeyboardEvent) => {\n if (!isEnabled) {\n return;\n }\n\n const { charCode } = event;\n if (!isChar(charCode)) {\n return;\n }\n delayedResetValue();\n const newValue = value.current + String.fromCharCode(charCode);\n value.current = newValue;\n\n const nextHighlight = findMatchingOption(options, newValue, highlightedOption, useInteractiveGroups);\n if (nextHighlight) {\n highlightOption(nextHighlight);\n }\n };\n}\n"]}
1
+ {"version":3,"file":"use-native-search.js","sourceRoot":"","sources":["../../../../src/select/utils/use-native-search.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAc,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EACL,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,OAAO,GACR,MAAM,uDAAuD,CAAC;AAE/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AAEjF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAUtF,SAAS,kBAAkB,CACzB,OAAsC,EACtC,UAAkB,EAClB,gBAAmE,EACnE,oBAA8B;IAE9B,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,aAAa,CAAC;IACrF,MAAM,MAAM,GAAG,CAAC,UAAkB,EAAE,EAAE,CACpC,aAAa,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;IACxF,MAAM,eAAe,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IAE3C,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE;QAChC,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC;KAC3B;IAED,wEAAwE;IACxE,IAAI,gBAAgB,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,IAAI,cAAc,CAAC,UAAU,CAAC,EAAE;QAC3E,MAAM,eAAe,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAE9C,IAAI,eAAe,CAAC,MAAM,GAA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,QAAQ,GAAG,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC;QACrC,KAAK,CAAC,OAAO,GAAG,QAAQ,CAAC;QAEzB,MAAM,aAAa,GAAG,kBAAkB,CAAC,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;QACrG,IAAI,aAAa,EAAE;YACjB,eAAe,CAAC,aAAa,CAAC,CAAC;SAChC;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\n\nimport {\n filterOptions,\n isInteractive,\n isGroupInteractive,\n isGroup,\n} from '../../internal/components/option/utils/filter-options';\nimport type { DropdownOption, OptionDefinition, OptionGroup } from '../../internal/components/option/interfaces';\nimport { useDebounceCallback } from '../../internal/hooks/use-debounce-callback';\n\nexport const isRepeatedChar = (str: string) => str.split('').every(c => c === str[0]);\n\ninterface UseNativeSearchProps {\n isEnabled: boolean;\n options: ReadonlyArray<DropdownOption>;\n highlightOption: (option: DropdownOption) => void;\n highlightedOption: OptionDefinition | undefined | null;\n useInteractiveGroups?: boolean;\n}\n\nfunction findMatchingOption(\n options: ReadonlyArray<DropdownOption>,\n searchText: string,\n currentHighlight: OptionDefinition | OptionGroup | undefined | null,\n useInteractiveGroups?: boolean\n) {\n const interactivityCheck = useInteractiveGroups ? isGroupInteractive : isInteractive;\n const filter = (searchText: string) =>\n filterOptions(options, searchText, true).filter(option => interactivityCheck(option));\n const matchingOptions = filter(searchText);\n\n if (matchingOptions.length === 1) {\n return matchingOptions[0];\n }\n\n // Hit the same char over and over, we assume they want to cycle through\n if (currentHighlight && searchText.length > 1 && isRepeatedChar(searchText)) {\n const matchingOptions = filter(searchText[0]);\n\n if (matchingOptions.length > 0) {\n //handling OptionGroups when useInteractiveGroups is set\n let active: number = isGroup(currentHighlight)\n ? matchingOptions.map(({ option }) => option).indexOf(currentHighlight)\n : matchingOptions\n .map(({ option }) => (option as OptionDefinition).value)\n .indexOf((currentHighlight as OptionDefinition).value);\n\n // Pick the next thing (if something with this prefix wasn't selected\n // we'll end up with the first option)\n active += 1;\n active = active % matchingOptions.length;\n return matchingOptions[active];\n }\n }\n\n // We have multiple things that start with this prefix. Based on the\n // behavior of native select, this is considered after the repeated case\n if (matchingOptions.length > 0) {\n return matchingOptions[0];\n }\n return null;\n}\n\nexport function useNativeSearch({\n isEnabled,\n options,\n highlightOption,\n highlightedOption,\n useInteractiveGroups,\n}: UseNativeSearchProps) {\n const value = useRef('');\n\n const delayedResetValue = useDebounceCallback(() => (value.current = ''), 500);\n\n return (event: React.KeyboardEvent) => {\n if (!isEnabled) {\n return;\n }\n\n const { key } = event;\n\n if (!key || key.length !== 1) {\n return;\n }\n\n delayedResetValue();\n const newValue = value.current + key;\n value.current = newValue;\n\n const nextHighlight = findMatchingOption(options, newValue, highlightedOption, useInteractiveGroups);\n if (nextHighlight) {\n highlightOption(nextHighlight);\n }\n };\n}\n"]}
@@ -1,34 +1,34 @@
1
1
 
2
2
  import './styles.scoped.css';
3
3
  export default {
4
- "column-layout": "awsui_column-layout_vj6p7_akfg0_99",
5
- "grid": "awsui_grid_vj6p7_akfg0_134",
6
- "grid-no-gutters": "awsui_grid-no-gutters_vj6p7_akfg0_140",
7
- "grid-variant-text-grid": "awsui_grid-variant-text-grid_vj6p7_akfg0_144",
8
- "grid-breakpoint-default": "awsui_grid-breakpoint-default_vj6p7_akfg0_152",
9
- "grid-columns-1": "awsui_grid-columns-1_vj6p7_akfg0_155",
10
- "grid-breakpoint-xxs": "awsui_grid-breakpoint-xxs_vj6p7_akfg0_155",
11
- "grid-breakpoint-xs": "awsui_grid-breakpoint-xs_vj6p7_akfg0_158",
12
- "grid-columns-2": "awsui_grid-columns-2_vj6p7_akfg0_161",
13
- "grid-columns-3": "awsui_grid-columns-3_vj6p7_akfg0_167",
14
- "grid-columns-4": "awsui_grid-columns-4_vj6p7_akfg0_173",
15
- "grid-vertical-borders": "awsui_grid-vertical-borders_vj6p7_akfg0_189",
16
- "grid-horizontal-borders": "awsui_grid-horizontal-borders_vj6p7_akfg0_222",
17
- "root": "awsui_root_vj6p7_akfg0_276",
18
- "tile-container": "awsui_tile-container_vj6p7_akfg0_314",
19
- "refresh": "awsui_refresh_vj6p7_akfg0_329",
20
- "has-metadata": "awsui_has-metadata_vj6p7_akfg0_333",
21
- "selected": "awsui_selected_vj6p7_akfg0_339",
22
- "disabled": "awsui_disabled_vj6p7_akfg0_344",
23
- "columns": "awsui_columns_vj6p7_akfg0_360",
24
- "column-1": "awsui_column-1_vj6p7_akfg0_366",
25
- "breakpoint-xs": "awsui_breakpoint-xs_vj6p7_akfg0_374",
26
- "breakpoint-xxs": "awsui_breakpoint-xxs_vj6p7_akfg0_379",
27
- "column-2": "awsui_column-2_vj6p7_akfg0_384",
28
- "column-3": "awsui_column-3_vj6p7_akfg0_402",
29
- "column-4": "awsui_column-4_vj6p7_akfg0_420",
30
- "control": "awsui_control_vj6p7_akfg0_439",
31
- "no-image": "awsui_no-image_vj6p7_akfg0_443",
32
- "image": "awsui_image_vj6p7_akfg0_447"
4
+ "column-layout": "awsui_column-layout_vj6p7_147sx_99",
5
+ "grid": "awsui_grid_vj6p7_147sx_134",
6
+ "grid-no-gutters": "awsui_grid-no-gutters_vj6p7_147sx_140",
7
+ "grid-variant-text-grid": "awsui_grid-variant-text-grid_vj6p7_147sx_144",
8
+ "grid-breakpoint-default": "awsui_grid-breakpoint-default_vj6p7_147sx_152",
9
+ "grid-columns-1": "awsui_grid-columns-1_vj6p7_147sx_155",
10
+ "grid-breakpoint-xxs": "awsui_grid-breakpoint-xxs_vj6p7_147sx_155",
11
+ "grid-breakpoint-xs": "awsui_grid-breakpoint-xs_vj6p7_147sx_158",
12
+ "grid-columns-2": "awsui_grid-columns-2_vj6p7_147sx_161",
13
+ "grid-columns-3": "awsui_grid-columns-3_vj6p7_147sx_167",
14
+ "grid-columns-4": "awsui_grid-columns-4_vj6p7_147sx_173",
15
+ "grid-vertical-borders": "awsui_grid-vertical-borders_vj6p7_147sx_189",
16
+ "grid-horizontal-borders": "awsui_grid-horizontal-borders_vj6p7_147sx_222",
17
+ "root": "awsui_root_vj6p7_147sx_276",
18
+ "tile-container": "awsui_tile-container_vj6p7_147sx_314",
19
+ "refresh": "awsui_refresh_vj6p7_147sx_329",
20
+ "has-metadata": "awsui_has-metadata_vj6p7_147sx_333",
21
+ "selected": "awsui_selected_vj6p7_147sx_339",
22
+ "disabled": "awsui_disabled_vj6p7_147sx_344",
23
+ "columns": "awsui_columns_vj6p7_147sx_360",
24
+ "column-1": "awsui_column-1_vj6p7_147sx_366",
25
+ "breakpoint-xs": "awsui_breakpoint-xs_vj6p7_147sx_374",
26
+ "breakpoint-xxs": "awsui_breakpoint-xxs_vj6p7_147sx_379",
27
+ "column-2": "awsui_column-2_vj6p7_147sx_384",
28
+ "column-3": "awsui_column-3_vj6p7_147sx_402",
29
+ "column-4": "awsui_column-4_vj6p7_147sx_420",
30
+ "control": "awsui_control_vj6p7_147sx_439",
31
+ "no-image": "awsui_no-image_vj6p7_147sx_443",
32
+ "image": "awsui_image_vj6p7_147sx_447"
33
33
  };
34
34