@aleph-alpha/ui-library 2.9.0 → 2.11.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 (32) hide show
  1. package/config.js +10 -0
  2. package/dist/system/components/UiAutocomplete/UiAutocomplete.vue.d.ts +0 -1
  3. package/dist/system/components/UiAutocomplete/types.d.ts +2 -6
  4. package/dist/system/components/UiSelect/UiSelect.vue.d.ts +4 -5
  5. package/dist/system/components/UiSelect/UiSelectContent.vue.d.ts +0 -1
  6. package/dist/system/components/UiSelect/UiSelectItem.vue.d.ts +2 -9
  7. package/dist/system/components/UiSelect/UiSelectTrigger.vue.d.ts +0 -2
  8. package/dist/system/components/UiSelect/UiSelectValue.vue.d.ts +0 -3
  9. package/dist/system/components/UiSelect/types.d.ts +26 -6
  10. package/dist/system/lib.js +18370 -18530
  11. package/dist/system/patterns/UiDataTable/UiDataTableToolbar.vue.d.ts +2 -2
  12. package/docs/public-docs/component-lifecycle.md +177 -0
  13. package/docs/public-docs/quick-start.md +43 -4
  14. package/package.json +5 -3
  15. package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +1 -1
  16. package/src/components/UiAutocomplete/UiAutocomplete.vue +9 -9
  17. package/src/components/UiAutocomplete/__tests__/UiAutocomplete.test.ts +76 -5
  18. package/src/components/UiAutocomplete/types.ts +2 -6
  19. package/src/components/UiSelect/UiSelect.stories.ts +4 -90
  20. package/src/components/UiSelect/UiSelect.vue +66 -144
  21. package/src/components/UiSelect/UiSelectContent.vue +10 -21
  22. package/src/components/UiSelect/UiSelectItem.vue +0 -82
  23. package/src/components/UiSelect/UiSelectTrigger.vue +1 -62
  24. package/src/components/UiSelect/UiSelectValue.vue +1 -47
  25. package/src/components/UiSelect/__tests__/UiSelect.test.ts +47 -98
  26. package/src/components/UiSelect/__tests__/UiSelectContent.test.ts +36 -3
  27. package/src/components/UiSelect/__tests__/UiSelectItem.test.ts +1 -1
  28. package/src/components/UiSelect/__tests__/UiSelectTrigger.test.ts +2 -2
  29. package/src/components/UiSelect/types.ts +29 -6
  30. package/src/patterns/UiDataTable/UiDataTableToolbar.vue +1 -1
  31. package/dist/system/components/UiSelect/context.d.ts +0 -28
  32. package/src/components/UiSelect/context.ts +0 -42
@@ -218,6 +218,8 @@ describe('UiSelect', () => {
218
218
  });
219
219
 
220
220
  describe('multiple', () => {
221
+ const triggerRoleOptions = { hidden: true } as const;
222
+
221
223
  function renderMultiSelect(
222
224
  options: {
223
225
  placeholder?: string;
@@ -279,16 +281,16 @@ describe('UiSelect', () => {
279
281
  const { getByRole } = renderMultiSelect({
280
282
  placeholder: 'Pick some fruits',
281
283
  });
282
- const trigger = getByRole('button');
284
+ const trigger = getByRole('combobox', triggerRoleOptions);
283
285
  expect(trigger).toBeInTheDocument();
284
286
  expect(trigger).toHaveTextContent('Pick some fruits');
285
287
  });
286
288
 
287
- test('opens popover on trigger click', async () => {
289
+ test('opens dropdown on trigger click', async () => {
288
290
  const user = userEvent.setup();
289
291
  const { getByRole } = renderMultiSelect();
290
292
 
291
- await user.click(getByRole('button'));
293
+ await user.click(getByRole('combobox', triggerRoleOptions));
292
294
 
293
295
  await waitFor(() => {
294
296
  expect(getByRole('listbox')).toBeInTheDocument();
@@ -299,18 +301,22 @@ describe('UiSelect', () => {
299
301
  const user = userEvent.setup();
300
302
  const { getByRole } = renderMultiSelect();
301
303
 
302
- await user.click(getByRole('button'));
304
+ await user.click(getByRole('combobox', triggerRoleOptions));
303
305
  await waitFor(() => expect(getByRole('listbox')).toBeInTheDocument());
304
306
 
305
307
  await user.click(getByRole('option', { name: /apple/i }));
306
308
  await user.click(getByRole('option', { name: /orange/i }));
307
309
 
308
- // popover stays open across clicks
310
+ // multi-select stays open across clicks
309
311
  expect(getByRole('listbox')).toBeInTheDocument();
310
312
 
311
313
  await waitFor(() => {
312
- expect(getByRole('button')).toHaveTextContent(/apple/i);
313
- expect(getByRole('button')).toHaveTextContent(/orange/i);
314
+ expect(getByRole('combobox', triggerRoleOptions)).toHaveTextContent(
315
+ /apple/i,
316
+ );
317
+ expect(getByRole('combobox', triggerRoleOptions)).toHaveTextContent(
318
+ /orange/i,
319
+ );
314
320
  });
315
321
  });
316
322
 
@@ -318,19 +324,25 @@ describe('UiSelect', () => {
318
324
  const user = userEvent.setup();
319
325
  const { getByRole } = renderMultiSelect();
320
326
 
321
- await user.click(getByRole('button'));
327
+ await user.click(getByRole('combobox', triggerRoleOptions));
322
328
  await waitFor(() => expect(getByRole('listbox')).toBeInTheDocument());
323
329
 
324
330
  await user.click(getByRole('option', { name: /apple/i }));
325
331
  await waitFor(() =>
326
- expect(getByRole('button')).toHaveTextContent(/apple/i),
332
+ expect(getByRole('combobox', triggerRoleOptions)).toHaveTextContent(
333
+ /apple/i,
334
+ ),
327
335
  );
328
336
 
329
337
  await user.click(getByRole('option', { name: /apple/i }));
330
338
 
331
339
  await waitFor(() => {
332
- expect(getByRole('button')).not.toHaveTextContent(/apple/i);
333
- expect(getByRole('button')).toHaveTextContent(/select fruits/i);
340
+ expect(getByRole('combobox', triggerRoleOptions)).not.toHaveTextContent(
341
+ /apple/i,
342
+ );
343
+ expect(getByRole('combobox', triggerRoleOptions)).toHaveTextContent(
344
+ /select fruits/i,
345
+ );
334
346
  });
335
347
  });
336
348
 
@@ -362,7 +374,7 @@ describe('UiSelect', () => {
362
374
  },
363
375
  });
364
376
 
365
- await user.click(getByRole('button'));
377
+ await user.click(getByRole('combobox', triggerRoleOptions));
366
378
  await waitFor(() => expect(getByRole('listbox')).toBeInTheDocument());
367
379
 
368
380
  await user.click(getByRole('option', { name: 'A' }));
@@ -411,7 +423,7 @@ describe('UiSelect', () => {
411
423
 
412
424
  // Selecting a second item adds a second hidden input — same name,
413
425
  // additional value (mirrors native `<select multiple>` submission).
414
- await user.click(getByRole('button'));
426
+ await user.click(getByRole('combobox', triggerRoleOptions));
415
427
  await waitFor(() => expect(getByRole('listbox')).toBeInTheDocument());
416
428
  await user.click(getByRole('option', { name: /banana/i }));
417
429
 
@@ -564,7 +576,7 @@ describe('UiSelect', () => {
564
576
  });
565
577
 
566
578
  await waitFor(() => {
567
- const trigger = getByRole('button');
579
+ const trigger = getByRole('combobox', triggerRoleOptions);
568
580
  expect(trigger).toHaveTextContent(/alpha/i);
569
581
  expect(trigger).toHaveTextContent(/gamma/i);
570
582
  expect(trigger).not.toHaveTextContent(/beta/i);
@@ -607,10 +619,12 @@ describe('UiSelect', () => {
607
619
  });
608
620
 
609
621
  await waitFor(() => {
610
- expect(getByRole('button')).toHaveTextContent(/alpha/i);
622
+ expect(getByRole('combobox', triggerRoleOptions)).toHaveTextContent(
623
+ /alpha/i,
624
+ );
611
625
  });
612
626
 
613
- await user.click(getByRole('button'));
627
+ await user.click(getByRole('combobox', triggerRoleOptions));
614
628
  await waitFor(() => expect(getByRole('listbox')).toBeInTheDocument());
615
629
  await user.click(getByRole('option', { name: /beta/i }));
616
630
 
@@ -618,7 +632,7 @@ describe('UiSelect', () => {
618
632
 
619
633
  // Trigger should still reflect ONLY the parent-owned value.
620
634
  await waitFor(() => {
621
- const trigger = getByRole('button');
635
+ const trigger = getByRole('combobox', triggerRoleOptions);
622
636
  expect(trigger).toHaveTextContent(/alpha/i);
623
637
  expect(trigger).not.toHaveTextContent(/beta/i);
624
638
  });
@@ -669,7 +683,7 @@ describe('UiSelect', () => {
669
683
 
670
684
  // Click another option — parent doesn't update `value`, so
671
685
  // hidden inputs must stay frozen on the controlled value.
672
- await user.click(getByRole('button'));
686
+ await user.click(getByRole('combobox', triggerRoleOptions));
673
687
  await waitFor(() => expect(getByRole('listbox')).toBeInTheDocument());
674
688
  await user.click(getByRole('option', { name: /banana/i }));
675
689
 
@@ -706,87 +720,23 @@ describe('UiSelect', () => {
706
720
  });
707
721
 
708
722
  await waitFor(() =>
709
- expect(getByRole('button')).toHaveTextContent(/apple/i),
723
+ expect(getByRole('combobox', triggerRoleOptions)).toHaveTextContent(
724
+ /apple/i,
725
+ ),
710
726
  );
711
727
 
712
- await user.click(getByRole('button'));
728
+ await user.click(getByRole('combobox', triggerRoleOptions));
713
729
  await waitFor(() => expect(getByRole('listbox')).toBeInTheDocument());
714
730
  await user.click(getByRole('option', { name: /banana/i }));
715
731
 
716
732
  await waitFor(() => {
717
- const trigger = getByRole('button');
733
+ const trigger = getByRole('combobox', triggerRoleOptions);
718
734
  expect(trigger).toHaveTextContent(/apple/i);
719
735
  expect(trigger).toHaveTextContent(/banana/i);
720
736
  });
721
737
  });
722
738
 
723
- test('removes the stale label entry when an item value changes', async () => {
724
- // Regression: when `UiSelectItem`'s `:value` changes, the label
725
- // registry used to keep the OLD key indefinitely. That meant
726
- // selecting the old value (e.g. via a controlled `modelValue`)
727
- // would still resolve to the orphaned label, and the map could
728
- // grow unbounded for dynamic option lists.
729
- //
730
- // After the fix, the previous key is dropped before the new one
731
- // is registered. We can't read the registry directly (it's
732
- // internal context) so we observe its effects through the
733
- // trigger label — when a key is missing, `UiSelectValue` falls
734
- // back to rendering the raw value.
735
- const { getByRole, rerender } = render({
736
- components: {
737
- UiSelect,
738
- UiSelectTrigger,
739
- UiSelectContent,
740
- UiSelectItem,
741
- UiSelectValue,
742
- },
743
- props: {
744
- itemValue: { type: String, default: 'apple' },
745
- parentValue: { type: Array, default: () => ['apple'] },
746
- },
747
- template: `
748
- <UiSelect :multiple="true" :model-value="parentValue">
749
- <UiSelectTrigger>
750
- <UiSelectValue placeholder="Pick" />
751
- </UiSelectTrigger>
752
- <UiSelectContent>
753
- <UiSelectItem :value="itemValue">Apple</UiSelectItem>
754
- </UiSelectContent>
755
- </UiSelect>
756
- `,
757
- });
758
-
759
- // Initial: 'apple' resolves to the registered label "Apple".
760
- await waitFor(() => {
761
- expect(getByRole('button')).toHaveTextContent(/^Apple$/);
762
- });
763
-
764
- // Re-key the item from 'apple' -> 'pear'. The registry must
765
- // drop 'apple' before adding 'pear'.
766
- await rerender({ itemValue: 'pear', parentValue: ['apple'] });
767
-
768
- // 'apple' is no longer in the registry, so the trigger renders
769
- // the raw value string (the displayText fallback). Without the
770
- // fix this would still render "Apple" because the stale entry
771
- // survived the value change.
772
- await waitFor(() => {
773
- const trigger = getByRole('button');
774
- expect(trigger).toHaveTextContent(/^apple$/);
775
- });
776
-
777
- // And the new key 'pear' resolves to the same rendered label.
778
- await rerender({ itemValue: 'pear', parentValue: ['pear'] });
779
- await waitFor(() => {
780
- expect(getByRole('button')).toHaveTextContent(/^Apple$/);
781
- });
782
- });
783
-
784
- test('reactive mode: toggling :multiple switches the rendered branch', async () => {
785
- // The provided context exposes `mode` via a getter so descendants
786
- // re-evaluate which branch to render whenever `props.multiple`
787
- // changes. Without that, `ctx.mode` would be a stale snapshot
788
- // captured at setup time and toggling `:multiple` would leave
789
- // children stuck on the original branch.
739
+ test('reactive mode: toggling :multiple keeps the core select branch', async () => {
790
740
  const { getByRole, queryByRole, rerender } = render({
791
741
  components: {
792
742
  UiSelect,
@@ -809,24 +759,21 @@ describe('UiSelect', () => {
809
759
  `,
810
760
  });
811
761
 
812
- // Single-select branch renders the native `combobox` role and
813
- // there is no plain `button` trigger.
762
+ // Both modes now render through the same core Select trigger.
814
763
  expect(getByRole('combobox')).toBeInTheDocument();
815
764
  expect(queryByRole('button')).not.toBeInTheDocument();
816
765
 
817
766
  await rerender({ multiple: true });
818
767
 
819
- // Multi-select branch renders the popover trigger as a `button`
820
- // and tears down the `combobox` from the single-select branch.
768
+ // Multi-select keeps the same core Select trigger semantics.
821
769
  await waitFor(() => {
822
- expect(getByRole('button')).toBeInTheDocument();
823
- expect(queryByRole('combobox')).not.toBeInTheDocument();
770
+ expect(getByRole('combobox')).toBeInTheDocument();
771
+ expect(queryByRole('button')).not.toBeInTheDocument();
824
772
  });
825
773
 
826
774
  await rerender({ multiple: false });
827
775
 
828
- // And back the other way — proves the getter is re-read in both
829
- // directions, not just on the first toggle.
776
+ // And back the other way — both modes keep the same trigger role.
830
777
  await waitFor(() => {
831
778
  expect(getByRole('combobox')).toBeInTheDocument();
832
779
  expect(queryByRole('button')).not.toBeInTheDocument();
@@ -857,13 +804,15 @@ describe('UiSelect', () => {
857
804
  });
858
805
 
859
806
  await waitFor(() =>
860
- expect(getByRole('button')).toHaveTextContent(/apple/i),
807
+ expect(getByRole('combobox', triggerRoleOptions)).toHaveTextContent(
808
+ /apple/i,
809
+ ),
861
810
  );
862
811
 
863
812
  await rerender({ value: ['banana'] });
864
813
 
865
814
  await waitFor(() => {
866
- const trigger = getByRole('button');
815
+ const trigger = getByRole('combobox', triggerRoleOptions);
867
816
  expect(trigger).toHaveTextContent(/banana/i);
868
817
  expect(trigger).not.toHaveTextContent(/apple/i);
869
818
  });
@@ -40,7 +40,7 @@ describe('UiSelectContent', () => {
40
40
  });
41
41
  });
42
42
 
43
- test('hides multi-select content while closed without losing selected label', async () => {
43
+ test('does not mount multi-select content while closed or lose selected label', async () => {
44
44
  const { container, getByRole } = render({
45
45
  components: {
46
46
  UiSelect,
@@ -62,12 +62,45 @@ describe('UiSelectContent', () => {
62
62
  });
63
63
 
64
64
  await waitFor(() => {
65
- expect(getByRole('button')).toHaveTextContent('Option A');
65
+ expect(getByRole('combobox')).toHaveTextContent('Option A');
66
66
  });
67
67
  expect(
68
68
  container.ownerDocument.body.querySelector(
69
69
  '[data-slot="select-content"]',
70
70
  ),
71
- ).toHaveClass('data-[state=closed]:hidden');
71
+ ).not.toBeInTheDocument();
72
+ });
73
+
74
+ test('ports multi-select content through the select portal', async () => {
75
+ const user = userEvent.setup();
76
+ const { container, getByRole } = render({
77
+ components: {
78
+ UiSelect,
79
+ UiSelectTrigger,
80
+ UiSelectContent,
81
+ UiSelectItem,
82
+ UiSelectValue,
83
+ },
84
+ template: `
85
+ <UiSelect :multiple="true">
86
+ <UiSelectTrigger>
87
+ <UiSelectValue placeholder="Select" />
88
+ </UiSelectTrigger>
89
+ <UiSelectContent class="max-h-[200px]">
90
+ <UiSelectItem value="a">Option A</UiSelectItem>
91
+ </UiSelectContent>
92
+ </UiSelect>
93
+ `,
94
+ });
95
+
96
+ await user.click(getByRole('combobox'));
97
+
98
+ await waitFor(() => {
99
+ const content = container.ownerDocument.body.querySelector(
100
+ '[data-slot="select-content"]',
101
+ );
102
+ expect(content).toHaveClass('max-h-[200px]');
103
+ expect(container).not.toContainElement(content as HTMLElement);
104
+ });
72
105
  });
73
106
  });
@@ -172,7 +172,7 @@ describe('UiSelectItem', () => {
172
172
  `,
173
173
  });
174
174
 
175
- await user.click(getByRole('button', { name: 'a' }));
175
+ await user.click(getByRole('combobox'));
176
176
 
177
177
  const option = getByRole('option', { name: 'Option A' });
178
178
  const end = option.querySelector('[data-slot="select-item-end"]');
@@ -118,7 +118,7 @@ describe('UiSelectTrigger', () => {
118
118
  `,
119
119
  });
120
120
 
121
- const trigger = getByRole('button');
121
+ const trigger = getByRole('combobox');
122
122
 
123
123
  expect(trigger).toHaveClass('focus:border-border-surface-focus-ring');
124
124
  expect(trigger).toHaveClass(
@@ -185,7 +185,7 @@ describe('UiSelectTrigger', () => {
185
185
  });
186
186
 
187
187
  await waitFor(() => {
188
- const trigger = getByRole('button');
188
+ const trigger = getByRole('combobox');
189
189
  expect(trigger).not.toHaveAttribute('data-placeholder');
190
190
  expect(trigger).toHaveTextContent('Option 1');
191
191
  expect(trigger).toHaveClass(
@@ -1,3 +1,26 @@
1
+ import type { HTMLAttributes } from 'vue';
2
+
3
+ /**
4
+ * Selected value shape used by `UiSelect`.
5
+ *
6
+ * - Single-select mode uses a string value.
7
+ * - Multi-select mode uses an array of string values.
8
+ *
9
+ * This type represents an actual selection payload, so it intentionally does
10
+ * not include `undefined`. Optional props such as `modelValue` and
11
+ * `defaultValue` become `undefined` through the optional property itself.
12
+ */
13
+ export type UiSelectValue = string | string[];
14
+
15
+ /**
16
+ * Optional selected value accepted by internal normalization helpers.
17
+ *
18
+ * Use this when code needs to handle the absence of a select value explicitly,
19
+ * for example while forwarding optional `modelValue` or `defaultValue` props
20
+ * to the underlying select primitive.
21
+ */
22
+ export type UiSelectOptionalValue = UiSelectValue | undefined;
23
+
1
24
  /**
2
25
  * A dropdown select for choosing from a list of options. Use for
3
26
  * form fields where users must pick one value from many.
@@ -12,9 +35,9 @@ export type UiSelectProps = {
12
35
  * - In single-select (default): a `string`.
13
36
  * - In multi-select (`multiple: true`): a `string[]`.
14
37
  */
15
- modelValue?: string | string[];
38
+ modelValue?: UiSelectValue;
16
39
  /** The value when initially rendered (uncontrolled). Same shape as `modelValue`. */
17
- defaultValue?: string | string[];
40
+ defaultValue?: UiSelectValue;
18
41
  /** Whether the select is open by default. */
19
42
  defaultOpen?: boolean;
20
43
  /** Controlled open state. */
@@ -39,7 +62,7 @@ export type UiSelectProps = {
39
62
  /** Reading direction. */
40
63
  dir?: 'ltr' | 'rtl';
41
64
  /**
42
- * When true, allows selecting multiple items. The popover stays open on
65
+ * When true, allows selecting multiple items. The dropdown stays open on
43
66
  * click and the trigger renders the selected values as a comma-separated
44
67
  * list. `modelValue` becomes a `string[]`.
45
68
  */
@@ -54,7 +77,7 @@ export type UiSelectEmits = {
54
77
  * Emitted when the selected value changes.
55
78
  * Payload is `string` in single-select and `string[]` in multi-select.
56
79
  */
57
- 'update:modelValue': [value: string | string[]];
80
+ 'update:modelValue': [value: UiSelectValue];
58
81
  /** Emitted when the open state changes. */
59
82
  'update:open': [value: boolean];
60
83
  };
@@ -67,14 +90,14 @@ export type UiSelectTriggerProps = {
67
90
  ariaLabel?: string;
68
91
  /** Whether the trigger is disabled. */
69
92
  disabled?: boolean;
70
- /** Size of the trigger. */
71
- size?: 'default' | 'sm';
72
93
  };
73
94
 
74
95
  /**
75
96
  * Props for the UiSelectContent component.
76
97
  */
77
98
  export type UiSelectContentProps = {
99
+ /** Additional classes for the floating content. */
100
+ class?: HTMLAttributes['class'];
78
101
  /** Preferred side of the trigger. */
79
102
  side?: 'top' | 'right' | 'bottom' | 'left';
80
103
  /** Distance from the trigger in pixels. */
@@ -7,7 +7,7 @@ defineSlots<{
7
7
  /** Primary controls, usually search and column filters. */
8
8
  default(): unknown;
9
9
  /** Trailing controls, usually view options or reset actions. */
10
- actions(): unknown;
10
+ actions?(): unknown;
11
11
  }>();
12
12
  </script>
13
13
 
@@ -1,28 +0,0 @@
1
- import { Ref } from 'vue';
2
- /**
3
- * Internal context used by `UiSelect` and its subcomponents to coordinate
4
- * single vs. multi-select rendering paths and to share the label registry
5
- * needed to render selected values in the trigger.
6
- *
7
- * Not part of the public API — do not export from the package index.
8
- */
9
- export type UiSelectMode = 'single' | 'multiple';
10
- export type UiSelectMultipleContext = {
11
- /** Currently selected values (multi-select). */
12
- selectedValues: Ref<string[]>;
13
- /** Reactive map of `value -> rendered label` populated by `UiSelectItem`. */
14
- itemLabels: Ref<Map<string, string>>;
15
- };
16
- export type UiSelectContext = {
17
- /** Whether the parent UiSelect is in single or multiple selection mode. */
18
- mode: UiSelectMode;
19
- /** Present only when `mode === 'multiple'`. */
20
- multiple?: UiSelectMultipleContext;
21
- };
22
- /**
23
- * Provide the context from `UiSelect` to its descendant subcomponents.
24
- * @param ctx The context value to expose to children.
25
- */
26
- export declare function provideUiSelectContext(ctx: UiSelectContext): void;
27
- /** Inject the context inside a UiSelect subcomponent. Falls back to single-mode. */
28
- export declare function useUiSelectContext(): UiSelectContext;
@@ -1,42 +0,0 @@
1
- import type { InjectionKey, Ref } from 'vue';
2
- import { inject, provide } from 'vue';
3
-
4
- /**
5
- * Internal context used by `UiSelect` and its subcomponents to coordinate
6
- * single vs. multi-select rendering paths and to share the label registry
7
- * needed to render selected values in the trigger.
8
- *
9
- * Not part of the public API — do not export from the package index.
10
- */
11
- export type UiSelectMode = 'single' | 'multiple';
12
-
13
- export type UiSelectMultipleContext = {
14
- /** Currently selected values (multi-select). */
15
- selectedValues: Ref<string[]>;
16
- /** Reactive map of `value -> rendered label` populated by `UiSelectItem`. */
17
- itemLabels: Ref<Map<string, string>>;
18
- };
19
-
20
- export type UiSelectContext = {
21
- /** Whether the parent UiSelect is in single or multiple selection mode. */
22
- mode: UiSelectMode;
23
- /** Present only when `mode === 'multiple'`. */
24
- multiple?: UiSelectMultipleContext;
25
- };
26
-
27
- /** Internal injection key for the UiSelect context. */
28
- const UI_SELECT_CONTEXT_KEY: InjectionKey<UiSelectContext> =
29
- Symbol('UiSelectContext');
30
-
31
- /**
32
- * Provide the context from `UiSelect` to its descendant subcomponents.
33
- * @param ctx The context value to expose to children.
34
- */
35
- export function provideUiSelectContext(ctx: UiSelectContext): void {
36
- provide(UI_SELECT_CONTEXT_KEY, ctx);
37
- }
38
-
39
- /** Inject the context inside a UiSelect subcomponent. Falls back to single-mode. */
40
- export function useUiSelectContext(): UiSelectContext {
41
- return inject(UI_SELECT_CONTEXT_KEY, { mode: 'single' });
42
- }