@aleph-alpha/ui-library 2.10.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.
- package/dist/system/components/UiAutocomplete/UiAutocomplete.vue.d.ts +0 -1
- package/dist/system/components/UiAutocomplete/types.d.ts +0 -2
- package/dist/system/components/UiSelect/UiSelect.vue.d.ts +4 -5
- package/dist/system/components/UiSelect/UiSelectContent.vue.d.ts +0 -1
- package/dist/system/components/UiSelect/UiSelectItem.vue.d.ts +2 -9
- package/dist/system/components/UiSelect/UiSelectTrigger.vue.d.ts +0 -2
- package/dist/system/components/UiSelect/UiSelectValue.vue.d.ts +0 -3
- package/dist/system/components/UiSelect/types.d.ts +26 -6
- package/dist/system/lib.js +18370 -18530
- package/package.json +1 -1
- package/src/components/UiAutocomplete/UiAutocomplete.vue +9 -9
- package/src/components/UiAutocomplete/__tests__/UiAutocomplete.test.ts +76 -5
- package/src/components/UiAutocomplete/types.ts +0 -2
- package/src/components/UiSelect/UiSelect.stories.ts +4 -90
- package/src/components/UiSelect/UiSelect.vue +66 -144
- package/src/components/UiSelect/UiSelectContent.vue +10 -21
- package/src/components/UiSelect/UiSelectItem.vue +0 -82
- package/src/components/UiSelect/UiSelectTrigger.vue +1 -62
- package/src/components/UiSelect/UiSelectValue.vue +1 -47
- package/src/components/UiSelect/__tests__/UiSelect.test.ts +47 -98
- package/src/components/UiSelect/__tests__/UiSelectContent.test.ts +36 -3
- package/src/components/UiSelect/__tests__/UiSelectItem.test.ts +1 -1
- package/src/components/UiSelect/__tests__/UiSelectTrigger.test.ts +2 -2
- package/src/components/UiSelect/types.ts +29 -6
- package/dist/system/components/UiSelect/context.d.ts +0 -28
- package/src/components/UiSelect/context.ts +0 -42
|
@@ -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?:
|
|
38
|
+
modelValue?: UiSelectValue;
|
|
16
39
|
/** The value when initially rendered (uncontrolled). Same shape as `modelValue`. */
|
|
17
|
-
defaultValue?:
|
|
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
|
|
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:
|
|
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. */
|
|
@@ -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
|
-
}
|