@oscarpalmer/oui 0.35.0 → 0.36.0

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.
Files changed (89) hide show
  1. package/dist/css/combobox.css +1 -1
  2. package/dist/css/listbox.css +152 -0
  3. package/dist/js/combobox/constants.combobox.d.mts +2 -2
  4. package/dist/js/combobox/constants.combobox.mjs +40 -33
  5. package/dist/js/combobox/dom.combobox.d.mts +8 -91
  6. package/dist/js/combobox/dom.combobox.mjs +204 -2
  7. package/dist/js/combobox/event.combobox.d.mts +14 -8
  8. package/dist/js/combobox/event.combobox.mjs +2 -2
  9. package/dist/js/combobox/index.d.mts +1 -1
  10. package/dist/js/combobox/index.mjs +20 -18
  11. package/dist/js/combobox/misc.combobox.d.mts +2 -2
  12. package/dist/js/combobox/misc.combobox.mjs +2 -2
  13. package/dist/js/combobox/models.combobox.d.mts +44 -2
  14. package/dist/js/combobox/state.combobox.d.mts +9 -10
  15. package/dist/js/combobox/state.combobox.mjs +2 -2
  16. package/dist/js/constants.combobox-DmRAMC64.d.mts +26 -0
  17. package/dist/js/constants.listbox-DRsXUxd3.d.mts +14 -0
  18. package/dist/js/index-EfkUSals.d.mts +139 -0
  19. package/dist/js/index.d.mts +4 -2
  20. package/dist/js/index.mjs +4 -2
  21. package/dist/js/internal/attributable.mjs +4 -3
  22. package/dist/js/internal/listbox/listbox.constants.d.mts +11 -0
  23. package/dist/js/internal/listbox/listbox.constants.mjs +23 -0
  24. package/dist/js/internal/listbox/listbox.data.d.mts +20 -0
  25. package/dist/js/internal/listbox/listbox.data.mjs +2 -0
  26. package/dist/js/internal/listbox/listbox.dom.d.mts +66 -0
  27. package/dist/js/internal/listbox/listbox.dom.mjs +2 -0
  28. package/dist/js/internal/listbox/listbox.event.d.mts +5 -0
  29. package/dist/js/internal/listbox/listbox.event.mjs +63 -0
  30. package/dist/js/internal/listbox/listbox.form.d.mts +6 -0
  31. package/dist/js/internal/listbox/listbox.form.mjs +52 -0
  32. package/dist/js/internal/listbox/listbox.misc.d.mts +12 -0
  33. package/dist/js/internal/listbox/listbox.misc.mjs +2 -0
  34. package/dist/js/internal/listbox/listbox.model.d.mts +2 -0
  35. package/dist/js/internal/listbox/listbox.model.mjs +1 -0
  36. package/dist/js/internal/listbox/listbox.state.d.mts +7 -0
  37. package/dist/js/internal/listbox/listbox.state.mjs +40 -0
  38. package/dist/js/internal/misc.d.mts +6 -0
  39. package/dist/js/internal/misc.mjs +13 -0
  40. package/dist/js/l10n-Bn-7RcwR.d.mts +20 -0
  41. package/dist/js/l10n.d.mts +2 -20
  42. package/dist/js/listbox/constants.listbox.d.mts +2 -0
  43. package/dist/js/listbox/constants.listbox.mjs +40 -0
  44. package/dist/js/listbox/event.listbox.d.mts +8 -0
  45. package/dist/js/listbox/event.listbox.mjs +2 -0
  46. package/dist/js/listbox/index.d.mts +116 -0
  47. package/dist/js/listbox/index.mjs +189 -0
  48. package/dist/js/listbox/misc.listbox.d.mts +2 -0
  49. package/dist/js/listbox/misc.listbox.mjs +2 -0
  50. package/dist/js/listbox/state.listbox.d.mts +11 -0
  51. package/dist/js/listbox/state.listbox.mjs +2 -0
  52. package/dist/js/listbox.data-BWd0PCy7.mjs +424 -0
  53. package/dist/js/listbox.model-CRReGOmu.d.mts +125 -0
  54. package/dist/js/misc.listbox-BI-XsTOf.mjs +197 -0
  55. package/dist/js/misc.listbox-gnoJhrTr.d.mts +20 -0
  56. package/dist/js/sortable/sortable.embedded.mjs +4 -2
  57. package/dist/js/state.combobox-4xq0FPCF.mjs +365 -0
  58. package/package.json +7 -3
  59. package/src/css/combobox.scss +1 -1
  60. package/src/css/listbox.scss +149 -0
  61. package/src/js/combobox/constants.combobox.ts +46 -25
  62. package/src/js/combobox/dom.combobox.ts +36 -454
  63. package/src/js/combobox/event.combobox.ts +129 -218
  64. package/src/js/combobox/index.ts +37 -30
  65. package/src/js/combobox/misc.combobox.ts +30 -114
  66. package/src/js/combobox/models.combobox.ts +7 -47
  67. package/src/js/combobox/state.combobox.ts +126 -127
  68. package/src/js/index.ts +1 -0
  69. package/src/js/internal/listbox/listbox.constants.ts +25 -0
  70. package/src/js/{combobox/data.combobox.ts → internal/listbox/listbox.data.ts} +94 -43
  71. package/src/js/internal/listbox/listbox.dom.ts +445 -0
  72. package/src/js/internal/listbox/listbox.event.ts +129 -0
  73. package/src/js/{combobox/form.combobox.ts → internal/listbox/listbox.form.ts} +12 -13
  74. package/src/js/internal/listbox/listbox.misc.ts +135 -0
  75. package/src/js/internal/listbox/listbox.model.ts +169 -0
  76. package/src/js/internal/listbox/listbox.state.ts +82 -0
  77. package/src/js/internal/misc.ts +27 -0
  78. package/src/js/l10n.ts +8 -8
  79. package/src/js/listbox/constants.listbox.ts +61 -0
  80. package/src/js/listbox/event.listbox.ts +106 -0
  81. package/src/js/listbox/index.ts +302 -0
  82. package/src/js/listbox/misc.listbox.ts +70 -0
  83. package/src/js/listbox/state.listbox.ts +196 -0
  84. package/dist/js/combobox/data.combobox.d.mts +0 -18
  85. package/dist/js/combobox/data.combobox.mjs +0 -2
  86. package/dist/js/combobox/form.combobox.d.mts +0 -6
  87. package/dist/js/combobox/form.combobox.mjs +0 -2
  88. package/dist/js/constants.combobox-h_kyDegw.d.mts +0 -248
  89. package/dist/js/data.combobox-B8HMkDOh.mjs +0 -1030
@@ -2,34 +2,27 @@ import {setAria} from '@oscarpalmer/toretto/aria';
2
2
  import {setAttribute} from '@oscarpalmer/toretto/attribute';
3
3
  import {createElement} from '@oscarpalmer/toretto/create';
4
4
  import {getData} from '@oscarpalmer/toretto/data';
5
+ import {
6
+ createListboxFilter,
7
+ createListboxInput,
8
+ createListboxList,
9
+ createListboxMessage,
10
+ createListboxValueLabel,
11
+ type CreateListboxContent,
12
+ type CreateListboxContentParameters,
13
+ } from '../internal/listbox/listbox.dom';
14
+ import type {OuiListboxPreview} from '../internal/listbox/listbox.model';
15
+ import {getLocalization, localize} from '../l10n';
5
16
  import {
6
17
  COMBOBOX_ATTRIBUTE_ANCHOR,
7
- COMBOBOX_ATTRIBUTE_CONTENT,
8
- COMBOBOX_ATTRIBUTE_FILTER,
9
- COMBOBOX_ATTRIBUTE_FILTER_INPUT,
10
- COMBOBOX_ATTRIBUTE_HEADER,
11
- COMBOBOX_ATTRIBUTE_HIDDEN,
12
- COMBOBOX_ATTRIBUTE_LIST,
13
- COMBOBOX_ATTRIBUTE_MESSAGE,
14
- COMBOBOX_ATTRIBUTE_OPTION,
15
- COMBOBOX_ATTRIBUTE_OPTION_ACTIVE,
16
18
  COMBOBOX_ATTRIBUTE_SELECTION,
17
19
  COMBOBOX_ATTRIBUTE_SELECTION_ITEM,
18
- comboboxScrollOptions,
19
20
  } from './constants.combobox';
20
- import {updateComboboxValidity} from './form.combobox';
21
21
  import type {
22
- OuiComboboxAutoComplete,
23
- OuiComboboxAutoCompleteType,
24
- OuiComboboxGroup,
25
- OuiComboboxPreview,
26
22
  OuiComboboxSelection,
27
23
  OuiComboboxSelectionItem,
28
24
  OuiComboboxState,
29
- OuiComboboxType,
30
25
  } from './models.combobox';
31
- import {getLocalization, localize} from '../l10n';
32
- import {comboboxLocalizations} from './state.combobox';
33
26
 
34
27
  // #region Types
35
28
 
@@ -39,88 +32,6 @@ type CreateAnchor = {
39
32
  selection?: OuiComboboxSelection;
40
33
  };
41
34
 
42
- type CreatAnchorParameters = {
43
- autocomplete: OuiComboboxAutoComplete;
44
- id: string;
45
- label: HTMLLabelElement;
46
- multiple: boolean;
47
- select: HTMLSelectElement;
48
- type: OuiComboboxType;
49
- };
50
-
51
- type CreateContent = {
52
- element: HTMLElement;
53
- filter?: CreateFilter;
54
- list: CreateList;
55
- message: HTMLElement;
56
- };
57
-
58
- type CreateContentParameters = {
59
- autocomplete: OuiComboboxAutoComplete;
60
- id: string;
61
- label: HTMLLabelElement;
62
- multiple: boolean;
63
- select: HTMLSelectElement;
64
- type: OuiComboboxType;
65
- };
66
-
67
- type CreateFilter = {
68
- container: HTMLElement;
69
- element: HTMLInputElement;
70
- };
71
-
72
- type CreateFilterParameters = {
73
- autocomplete: OuiComboboxAutoCompleteType;
74
- id: string;
75
- label: HTMLLabelElement;
76
- type: OuiComboboxType;
77
- };
78
-
79
- type CreateGroupParameters = {
80
- autocomplete: OuiComboboxAutoComplete;
81
- group: HTMLOptGroupElement;
82
- groupOptions: HTMLOptionElement[];
83
- selected: HTMLElement[];
84
- };
85
-
86
- type CreateInputParameters = {
87
- autocomplete: OuiComboboxAutoCompleteType;
88
- id: string;
89
- label: HTMLLabelElement;
90
- type: OuiComboboxType;
91
- value: string;
92
- };
93
-
94
- type CreateList = {
95
- element: HTMLElement;
96
- groups?: OuiComboboxGroup[];
97
- options: HTMLElement[];
98
- selected: HTMLElement[];
99
- };
100
-
101
- type CreateListParameters = {
102
- autocomplete: OuiComboboxAutoComplete;
103
- id: string;
104
- label: HTMLLabelElement;
105
- multiple: boolean;
106
- select: HTMLSelectElement;
107
- };
108
-
109
- type CreateOptionParameters = {
110
- autocomplete: OuiComboboxAutoComplete;
111
- group?: string;
112
- index: number;
113
- option: HTMLOptionElement;
114
- };
115
-
116
- type CreateOptionsParameters = {
117
- autocomplete: OuiComboboxAutoComplete;
118
- group?: string;
119
- list: HTMLElement;
120
- options: HTMLOptionElement[];
121
- selected: HTMLElement[];
122
- };
123
-
124
35
  type CreateSelectionItemsParameters = {
125
36
  container: HTMLElement;
126
37
  items: OuiComboboxSelectionItem[];
@@ -132,21 +43,15 @@ type CreateSelectionItemsParameters = {
132
43
 
133
44
  // #region Functions
134
45
 
135
- export function createComboboxAnchor(parameters: CreatAnchorParameters): CreateAnchor {
136
- const {autocomplete, id, label, select, type} = parameters;
46
+ export function createComboboxAnchor(parameters: CreateListboxContentParameters): CreateAnchor {
47
+ const {select} = parameters;
137
48
 
138
49
  let container: HTMLElement | undefined;
139
50
  let element: HTMLElement;
140
51
  let selection: OuiComboboxSelection | undefined;
141
52
 
142
53
  if (parameters.type === 'autocomplete') {
143
- element = createComboboxInput({
144
- id,
145
- label,
146
- type,
147
- autocomplete: autocomplete.value,
148
- value: select.selectedOptions[0]?.textContent ?? '',
149
- });
54
+ element = createListboxInput(parameters, select.selectedOptions[0]?.textContent ?? '');
150
55
  } else {
151
56
  ({container, element, selection} = createComboboxButton(parameters));
152
57
  }
@@ -156,7 +61,7 @@ export function createComboboxAnchor(parameters: CreatAnchorParameters): CreateA
156
61
  return {container, element, selection};
157
62
  }
158
63
 
159
- export function createComboboxButton(parameters: CreatAnchorParameters): CreateAnchor {
64
+ export function createComboboxButton(parameters: CreateListboxContentParameters): CreateAnchor {
160
65
  const {id, label, multiple, select} = parameters;
161
66
 
162
67
  const element = createElement('button', {
@@ -164,7 +69,7 @@ export function createComboboxButton(parameters: CreatAnchorParameters): CreateA
164
69
  controls: `${id}_content`,
165
70
  expanded: false,
166
71
  haspopup: 'listbox',
167
- labelledby: `${label.id} ${id}`,
72
+ labelledby: `${label.id} ${id}_value`, // Non-input anchor, so no implicit value label, so we need to explicitly reference the value label
168
73
  },
169
74
  property: {
170
75
  textContent: multiple ? '' : (select.selectedOptions[0]?.textContent ?? ''),
@@ -183,15 +88,17 @@ export function createComboboxButton(parameters: CreatAnchorParameters): CreateA
183
88
  return {container, element, selection};
184
89
  }
185
90
 
186
- export function createComboboxContent(parameters: CreateContentParameters): CreateContent {
187
- const {autocomplete, id, label, multiple, select, type} = parameters;
91
+ export function createComboboxContent(
92
+ parameters: CreateListboxContentParameters,
93
+ ): CreateListboxContent {
94
+ const {id, label} = parameters;
188
95
 
189
96
  const element = createElement('div', {
190
97
  aria: {
191
98
  labelledby: label.id,
192
99
  },
193
100
  attribute: {
194
- [COMBOBOX_ATTRIBUTE_CONTENT]: '',
101
+ [parameters.attributes.content]: '',
195
102
  popover: '',
196
103
  },
197
104
  property: {
@@ -200,241 +107,18 @@ export function createComboboxContent(parameters: CreateContentParameters): Crea
200
107
  },
201
108
  });
202
109
 
203
- const filter = createComboboxFilter({id, label, type, autocomplete: autocomplete.value});
204
- const list = createComboboxList({autocomplete, id, label, multiple, select});
205
- const message = createComboboxMessage();
110
+ const filter = createListboxFilter(parameters);
111
+ const list = createListboxList(parameters);
112
+ const message = createListboxMessage(parameters.attributes.message);
113
+ const value = createListboxValueLabel(parameters.id);
206
114
 
207
115
  if (filter != null) {
208
116
  element.append(filter.container);
209
117
  }
210
118
 
211
- element.append(list.element, message);
212
-
213
- return {element, filter, list, message};
214
- }
215
-
216
- export function createComboboxFilter(parameters: CreateFilterParameters): CreateFilter | undefined {
217
- const {autocomplete, id, label, type} = parameters;
218
-
219
- if (type === 'autocomplete') {
220
- return;
221
- }
222
-
223
- const container = createElement('div', {
224
- attribute: {
225
- [COMBOBOX_ATTRIBUTE_FILTER]: '',
226
- },
227
- });
228
-
229
- const element = createComboboxInput({autocomplete, id, label, type, value: ''});
230
-
231
- setAttribute(element, COMBOBOX_ATTRIBUTE_FILTER_INPUT, '');
232
-
233
- container.append(element);
234
-
235
- return {container, element};
236
- }
237
-
238
- export function createComboboxGroup(parameters: CreateGroupParameters): OuiComboboxGroup {
239
- const {autocomplete, group, groupOptions, selected} = parameters;
240
-
241
- const element = createElement('li', {
242
- aria: {
243
- label: group.label,
244
- },
245
- property: {
246
- role: 'group',
247
- },
248
- });
249
-
250
- const list = createElement('ul', {
251
- property: {
252
- role: 'none',
253
- },
254
- });
255
-
256
- const header = createComboboxHeader(group);
257
-
258
- element.append(header, list);
259
-
260
- return {
261
- element,
262
- header,
263
- options: createComboboxOptions({
264
- autocomplete,
265
- list,
266
- selected,
267
- group: header.id,
268
- options: groupOptions,
269
- }),
270
- };
271
- }
272
-
273
- export function createComboboxHeader(group: HTMLOptGroupElement): HTMLElement {
274
- return createElement('div', {
275
- aria: {
276
- hidden: true,
277
- },
278
- attribute: {
279
- [COMBOBOX_ATTRIBUTE_HEADER]: '',
280
- },
281
- property: {
282
- id: group.id,
283
- textContent: group.label,
284
- },
285
- });
286
- }
287
-
288
- export function createComboboxInput(parameters: CreateInputParameters): HTMLInputElement {
289
- const {autocomplete, id, label, type, value} = parameters;
290
-
291
- return createElement('input', {
292
- aria: {
293
- autocomplete: autocomplete,
294
- controls: `${id}_list`,
295
- expanded: type === 'select',
296
- haspopup: 'listbox',
297
- labelledby: label.id,
298
- },
299
- attribute: {
300
- autocorrect: 'off',
301
- autocomplete: 'off',
302
- form: '',
303
- spellcheck: 'false',
304
- type: 'text',
305
- },
306
- property: {
307
- id,
308
- value,
309
- role: 'combobox',
310
- },
311
- });
312
- }
313
-
314
- export function createComboboxList(parameters: CreateListParameters): CreateList {
315
- const {autocomplete, id, label, multiple, select} = parameters;
316
-
317
- const element = createElement('ul', {
318
- aria: {
319
- labelledby: label.id,
320
- multiselectable: multiple,
321
- },
322
- attribute: {
323
- [COMBOBOX_ATTRIBUTE_LIST]: '',
324
- tabindex: -1,
325
- },
326
- property: {
327
- id: `${id}_list`,
328
- role: 'listbox',
329
- },
330
- });
331
-
332
- const children = [...select.children];
333
- const childrenLength = children.length;
334
-
335
- const options: HTMLElement[] = [];
336
- const selected: HTMLElement[] = [];
337
-
338
- let groups: OuiComboboxGroup[] | undefined;
339
-
340
- for (let childIndex = 0; childIndex < childrenLength; childIndex += 1) {
341
- const child = children[childIndex];
342
-
343
- if (child instanceof HTMLOptionElement) {
344
- const option = createComboboxOption({
345
- autocomplete,
346
- index: childIndex,
347
- option: child,
348
- });
349
-
350
- element.append(option);
351
- options.push(option);
352
-
353
- if (child.selected) {
354
- selected.push(option);
355
- }
356
-
357
- continue;
358
- }
359
-
360
- if (!(child instanceof HTMLOptGroupElement)) {
361
- continue;
362
- }
363
-
364
- const group = createComboboxGroup({
365
- autocomplete,
366
- selected,
367
- group: child,
368
- groupOptions: [...child.children] as HTMLOptionElement[],
369
- });
370
-
371
- groups ??= [];
372
-
373
- element.append(group.element, ...group.options);
374
- groups.push(group);
375
- options.push(...group.options);
376
- }
377
-
378
- return {element, groups, options, selected};
379
- }
119
+ element.append(list.element, message, value);
380
120
 
381
- export function createComboboxMessage(): HTMLElement {
382
- return createElement('div', {
383
- aria: {
384
- live: 'polite',
385
- },
386
- attribute: {
387
- [COMBOBOX_ATTRIBUTE_MESSAGE]: '',
388
- },
389
- property: {
390
- hidden: true,
391
- role: 'status',
392
- },
393
- });
394
- }
395
-
396
- export function createComboboxOption(parameters: CreateOptionParameters): HTMLElement {
397
- const {autocomplete, group, option} = parameters;
398
-
399
- return createElement('li', {
400
- aria: {
401
- selected: !autocomplete.none && option.selected,
402
- },
403
- attribute: {
404
- [COMBOBOX_ATTRIBUTE_OPTION]: '',
405
- },
406
- data: {
407
- group,
408
- value: option.value,
409
- },
410
- property: {
411
- id: option.id,
412
- role: 'option',
413
- textContent: option.textContent,
414
- },
415
- });
416
- }
417
-
418
- export function createComboboxOptions(parameters: CreateOptionsParameters): HTMLElement[] {
419
- const {autocomplete, group, list, options, selected} = parameters;
420
-
421
- const items: HTMLElement[] = [];
422
-
423
- for (let index = 0; index < options.length; index += 1) {
424
- const option = options[index];
425
-
426
- const item = createComboboxOption({autocomplete, group, index, option});
427
-
428
- items.push(item);
429
-
430
- if (option.selected) {
431
- selected.push(item);
432
- }
433
-
434
- list.append(item);
435
- }
436
-
437
- return items;
121
+ return {element, filter, list, message, value};
438
122
  }
439
123
 
440
124
  export function createComboboxSelection(
@@ -480,7 +164,12 @@ export function createComboboxSelectionItem(
480
164
  const localization =
481
165
  state == null
482
166
  ? option.textContent
483
- : getLocalization(comboboxLocalizations, state.host, 'remove', state.localizations);
167
+ : getLocalization(
168
+ state.localizations.global,
169
+ state.host,
170
+ 'remove',
171
+ state.localizations.component,
172
+ );
484
173
 
485
174
  const button = createElement('button', {
486
175
  aria: {
@@ -541,44 +230,6 @@ export function createComboboxSelectionItems(parameters: CreateSelectionItemsPar
541
230
  }
542
231
  }
543
232
 
544
- export function setComboboxDisabled(state: OuiComboboxState, value: boolean): void {
545
- state.filter.element.readOnly = state.readonly || value;
546
-
547
- setProperties('disabled', state, value);
548
- }
549
-
550
- function setProperties(
551
- key: 'disabled' | 'readonly' | 'required',
552
- state: OuiComboboxState,
553
- value: boolean,
554
- ): void {
555
- state[key] = value;
556
-
557
- const elements = [state.host, state.anchor.element, state.filter.element];
558
- const {length} = elements;
559
-
560
- for (let index = 0; index < length; index += 1) {
561
- const element = elements[index];
562
-
563
- setAria(
564
- element,
565
- key,
566
- key !== 'readonly' || !(element instanceof HTMLButtonElement) ? value : undefined,
567
- );
568
- }
569
- }
570
-
571
- export function setComboboxReadonly(state: OuiComboboxState, value: boolean): void {
572
- state.filter.element.readOnly = state.disabled || value;
573
-
574
- setProperties('readonly', state, value);
575
- }
576
-
577
- export function setComboboxRequired(state: OuiComboboxState, value: boolean): void {
578
- setProperties('required', state, value);
579
- updateComboboxValidity(state);
580
- }
581
-
582
233
  export function updateComboboxTabindices(state: OuiComboboxState, active?: HTMLElement): void {
583
234
  if (active == null || state.selection == null) {
584
235
  return;
@@ -603,25 +254,8 @@ export function updateComboboxTabindices(state: OuiComboboxState, active?: HTMLE
603
254
  next.button.focus();
604
255
  }
605
256
 
606
- export function updateComboboxAnchor(state: OuiComboboxState): void {
607
- if (!state.multiple) {
608
- return;
609
- }
610
-
611
- const localization = getLocalization(
612
- comboboxLocalizations,
613
- state.host,
614
- 'selected',
615
- state.localizations,
616
- );
617
-
618
- const {length} = state.options.selected;
619
-
620
- setAria(state.anchor.element, 'label', localize(localization, {amount: length}, [length]));
621
- }
622
-
623
257
  export function updateComboboxAutocomplete(
624
- preview: OuiComboboxPreview,
258
+ preview: OuiListboxPreview,
625
259
  state: OuiComboboxState,
626
260
  active?: HTMLElement,
627
261
  ): void {
@@ -655,58 +289,6 @@ export function updateComboboxAutocomplete(
655
289
  }
656
290
  }
657
291
 
658
- export function updateComboboxMessage(state: OuiComboboxState, visible: number): void {
659
- setAttribute(state.message, COMBOBOX_ATTRIBUTE_HIDDEN, visible > 0 ? '' : undefined);
660
-
661
- if (visible === 0) {
662
- const localization = getLocalization(
663
- comboboxLocalizations,
664
- state.host,
665
- 'empty',
666
- state.localizations,
667
- );
668
-
669
- state.message.textContent = localize(localization, {}, []);
670
- } else {
671
- const localization = getLocalization(
672
- comboboxLocalizations,
673
- state.host,
674
- 'results',
675
- state.localizations,
676
- );
677
-
678
- state.message.textContent = localize(localization, {amount: visible}, [visible]);
679
- }
680
-
681
- state.message.hidden = false;
682
- }
683
-
684
- export function updateComboboxPreview(
685
- preview: OuiComboboxPreview,
686
- state: OuiComboboxState,
687
- active?: HTMLElement,
688
- ): void {
689
- const {length} = state.options.all;
690
-
691
- for (let index = 0; index < length; index += 1) {
692
- const option = state.options.all[index];
693
-
694
- setAttribute(option, COMBOBOX_ATTRIBUTE_OPTION_ACTIVE, option === active ? '' : undefined);
695
- }
696
-
697
- state.active = active;
698
-
699
- setAria(state.filter.element, 'activedescendant', state.floatable.open ? active?.id : undefined);
700
-
701
- if (state.floatable.open) {
702
- active?.scrollIntoView(comboboxScrollOptions);
703
- }
704
-
705
- if (preview !== 'none') {
706
- updateComboboxAutocomplete(preview, state, active);
707
- }
708
- }
709
-
710
292
  export function updateComboboxSelection(
711
293
  state: OuiComboboxState,
712
294
  active: HTMLElement | undefined,
@@ -785,10 +367,10 @@ export function updateComboboxSelectionItems(state: OuiComboboxState): void {
785
367
  }
786
368
 
787
369
  const localization = getLocalization(
788
- comboboxLocalizations,
370
+ state.localizations.global,
789
371
  state.host,
790
372
  'remove',
791
- state.localizations,
373
+ state.localizations.component,
792
374
  );
793
375
 
794
376
  const {length} = state.selection.items;