@aleph-alpha/ui-library 2.6.1 → 2.7.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 (24) hide show
  1. package/dist/system/components/UiAutocomplete/UiAutocomplete.vue.d.ts +86 -0
  2. package/dist/system/components/UiAutocomplete/UiAutocompleteItem.vue.d.ts +30 -0
  3. package/dist/system/components/UiAutocomplete/context.d.ts +19 -0
  4. package/dist/system/components/UiAutocomplete/index.d.ts +3 -0
  5. package/dist/system/components/UiAutocomplete/types.d.ts +122 -0
  6. package/dist/system/components/UiFileUploadBox/UiFileUploadBox.vue.d.ts +6 -6
  7. package/dist/system/components/UiFileUploadBox/types.d.ts +1 -1
  8. package/dist/system/components/core/native-select/NativeSelectOptGroup.vue.d.ts +4 -4
  9. package/dist/system/components/core/native-select/NativeSelectOption.vue.d.ts +4 -4
  10. package/dist/system/components/core/popover/PopoverContent.vue.d.ts +1 -1
  11. package/dist/system/components/index.d.ts +1 -0
  12. package/dist/system/lib.js +16171 -15717
  13. package/dist/system/patterns/UiFileUpload/UiFileUpload.vue.d.ts +6 -6
  14. package/package.json +1 -1
  15. package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +308 -0
  16. package/src/components/UiAutocomplete/UiAutocomplete.vue +481 -0
  17. package/src/components/UiAutocomplete/UiAutocompleteItem.vue +98 -0
  18. package/src/components/UiAutocomplete/__tests__/UiAutocomplete.test.ts +408 -0
  19. package/src/components/UiAutocomplete/context.ts +22 -0
  20. package/src/components/UiAutocomplete/index.ts +3 -0
  21. package/src/components/UiAutocomplete/types.ts +131 -0
  22. package/src/components/UiFileUploadBox/types.ts +1 -1
  23. package/src/components/UiItem/UiItem.stories.ts +1 -1
  24. package/src/components/index.ts +1 -0
@@ -12,6 +12,9 @@ declare function __VLS_template(): {
12
12
  type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
13
13
  declare const __VLS_component: import('vue').DefineComponent<import('../../components/UiFileUploadBox').UiFileUploadBoxProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
14
14
  click: (event: MouseEvent) => any;
15
+ focus: (event: FocusEvent) => any;
16
+ blur: (event: FocusEvent) => any;
17
+ keydown: (event: KeyboardEvent) => any;
15
18
  error: (payload: import('../../components/UiFileUploadBox').UiFileUploadBoxErrorPayload) => any;
16
19
  change: (event: Event) => any;
17
20
  "update:files": (files: File[]) => any;
@@ -19,12 +22,12 @@ declare const __VLS_component: import('vue').DefineComponent<import('../../compo
19
22
  dragleave: (event: DragEvent) => any;
20
23
  dragover: (event: DragEvent) => any;
21
24
  drop: (event: DragEvent) => any;
22
- keydown: (event: KeyboardEvent) => any;
23
- focus: (event: FocusEvent) => any;
24
- blur: (event: FocusEvent) => any;
25
25
  pickerOpen: () => any;
26
26
  }, string, import('vue').PublicProps, Readonly<import('../../components/UiFileUploadBox').UiFileUploadBoxProps> & Readonly<{
27
27
  onClick?: ((event: MouseEvent) => any) | undefined;
28
+ onFocus?: ((event: FocusEvent) => any) | undefined;
29
+ onBlur?: ((event: FocusEvent) => any) | undefined;
30
+ onKeydown?: ((event: KeyboardEvent) => any) | undefined;
28
31
  onError?: ((payload: import('../../components/UiFileUploadBox').UiFileUploadBoxErrorPayload) => any) | undefined;
29
32
  onChange?: ((event: Event) => any) | undefined;
30
33
  "onUpdate:files"?: ((files: File[]) => any) | undefined;
@@ -32,9 +35,6 @@ declare const __VLS_component: import('vue').DefineComponent<import('../../compo
32
35
  onDragleave?: ((event: DragEvent) => any) | undefined;
33
36
  onDragover?: ((event: DragEvent) => any) | undefined;
34
37
  onDrop?: ((event: DragEvent) => any) | undefined;
35
- onKeydown?: ((event: KeyboardEvent) => any) | undefined;
36
- onFocus?: ((event: FocusEvent) => any) | undefined;
37
- onBlur?: ((event: FocusEvent) => any) | undefined;
38
38
  onPickerOpen?: (() => any) | undefined;
39
39
  }>, {
40
40
  disabled: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aleph-alpha/ui-library",
3
- "version": "2.6.1",
3
+ "version": "2.7.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/system/lib.js",
@@ -0,0 +1,308 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
+ import { ref } from 'vue';
3
+ import { UiBadge } from '@/components/UiBadge';
4
+ import { UiCheckbox } from '@/components/UiCheckbox';
5
+ import UiAutocomplete from './UiAutocomplete.vue';
6
+ import UiAutocompleteItem from './UiAutocompleteItem.vue';
7
+
8
+ const fruits = [
9
+ { value: 'apple', label: 'Apple' },
10
+ { value: 'banana', label: 'Banana' },
11
+ { value: 'orange', label: 'Orange' },
12
+ { value: 'grape', label: 'Grape' },
13
+ { value: 'mango', label: 'Mango' },
14
+ { value: 'pear', label: 'Pear' },
15
+ ];
16
+
17
+ const fruitsWithMeta = [
18
+ { value: 'apple', label: 'Apple', group: 'Pome', status: 'Popular' },
19
+ { value: 'banana', label: 'Banana', group: 'Tropical', status: 'Fresh' },
20
+ { value: 'orange', label: 'Orange', group: 'Citrus', status: 'Vitamin C' },
21
+ { value: 'grape', label: 'Grape', group: 'Berry', status: 'Seedless' },
22
+ { value: 'mango', label: 'Mango', group: 'Tropical', status: 'Seasonal' },
23
+ { value: 'pear', label: 'Pear', group: 'Pome', status: 'Ripe' },
24
+ ];
25
+
26
+ /**
27
+ * UiAutocomplete is a searchable select input. It supports single and multiple
28
+ * selection, custom input and item slots, and truncates selected labels when
29
+ * they exceed the input width.
30
+ */
31
+ const meta: Meta<typeof UiAutocomplete> = {
32
+ title: 'Components/UiAutocomplete',
33
+ component: UiAutocomplete,
34
+ tags: ['autodocs', 'beta'],
35
+ argTypes: {
36
+ multiple: {
37
+ control: 'boolean',
38
+ description: 'Allow multiple selected options',
39
+ },
40
+ disabled: {
41
+ control: 'boolean',
42
+ description: 'Disable the autocomplete',
43
+ },
44
+ },
45
+ args: {
46
+ multiple: false,
47
+ disabled: false,
48
+ },
49
+ };
50
+
51
+ export default meta;
52
+
53
+ type Story = StoryObj<typeof UiAutocomplete>;
54
+
55
+ const defaultTemplateSource = `<script setup lang="ts">
56
+ import { ref } from 'vue'
57
+ import { UiAutocomplete } from '@aleph-alpha/ui-library'
58
+
59
+ const value = ref('')
60
+ const options = [
61
+ { value: 'apple', label: 'Apple' },
62
+ { value: 'banana', label: 'Banana' },
63
+ { value: 'orange', label: 'Orange' },
64
+ ]
65
+ </script>
66
+
67
+ <template>
68
+ <UiAutocomplete v-model="value" :options="options" placeholder="Search fruit" class="w-[260px]" />
69
+ </template>`;
70
+
71
+ export const Default: Story = {
72
+ render: (args) => ({
73
+ components: { UiAutocomplete },
74
+ setup() {
75
+ const value = ref('');
76
+ return { args, value, fruits };
77
+ },
78
+ template: `
79
+ <UiAutocomplete
80
+ v-model="value"
81
+ v-bind="args"
82
+ :options="fruits"
83
+ placeholder="Search fruit"
84
+ start-icon="search"
85
+ class="w-[260px]"
86
+ />
87
+ `,
88
+ }),
89
+ parameters: {
90
+ docs: {
91
+ description: {
92
+ story:
93
+ 'Basic searchable autocomplete using the `options` prop. Typing filters the dropdown, and selecting an option updates `v-model`.',
94
+ },
95
+ source: {
96
+ code: defaultTemplateSource,
97
+ },
98
+ },
99
+ },
100
+ };
101
+
102
+ const multipleTemplateSource = `<script setup lang="ts">
103
+ import { ref } from 'vue'
104
+ import { UiAutocomplete } from '@aleph-alpha/ui-library'
105
+
106
+ const value = ref<string[]>(['apple', 'banana', 'orange', 'grape'])
107
+ const options = [
108
+ { value: 'apple', label: 'Apple' },
109
+ { value: 'banana', label: 'Banana' },
110
+ { value: 'orange', label: 'Orange' },
111
+ { value: 'grape', label: 'Grape' },
112
+ ]
113
+ </script>
114
+
115
+ <template>
116
+ <UiAutocomplete
117
+ v-model="value"
118
+ multiple
119
+ :options="options"
120
+ placeholder="Search fruits"
121
+ class="w-[220px]"
122
+ />
123
+ </template>`;
124
+
125
+ export const Multiple: Story = {
126
+ render: () => ({
127
+ components: { UiAutocomplete },
128
+ setup() {
129
+ const value = ref(['apple', 'banana', 'orange', 'grape']);
130
+ return { value, fruits };
131
+ },
132
+ template: `
133
+ <div class="flex flex-col gap-3">
134
+ <UiAutocomplete
135
+ v-model="value"
136
+ multiple
137
+ :options="fruits"
138
+ placeholder="Search fruits"
139
+ class="w-[220px]"
140
+ />
141
+ <div class="text-xs text-content-on-surface-secondary">
142
+ Selected: {{ value.join(', ') || 'None' }}
143
+ </div>
144
+ </div>
145
+ `,
146
+ }),
147
+ parameters: {
148
+ docs: {
149
+ description: {
150
+ story:
151
+ 'Multi-select autocomplete. Selected labels are rendered in the input and truncate with an ellipsis when they exceed the available width.',
152
+ },
153
+ source: {
154
+ code: multipleTemplateSource,
155
+ },
156
+ },
157
+ },
158
+ };
159
+
160
+ export const WithSlots: Story = {
161
+ render: () => ({
162
+ components: { UiAutocomplete },
163
+ setup() {
164
+ const value = ref('');
165
+ return { value, fruits };
166
+ },
167
+ template: `
168
+ <UiAutocomplete
169
+ v-model="value"
170
+ :options="fruits"
171
+ placeholder="Search fruit"
172
+ start-icon="search"
173
+ class="w-[300px]"
174
+ >
175
+ <template #item="{ option, selected }">
176
+ <div class="flex min-w-0 flex-1 items-center justify-between gap-2">
177
+ <span class="truncate">{{ option.label }}</span>
178
+ <span v-if="selected" class="text-xs text-muted-foreground">Selected</span>
179
+ </div>
180
+ </template>
181
+ </UiAutocomplete>
182
+ `,
183
+ }),
184
+ parameters: {
185
+ docs: {
186
+ description: {
187
+ story:
188
+ 'Customizes option rows with the `item` slot while keeping the built-in filtering, keyboard navigation, and selection behavior.',
189
+ },
190
+ },
191
+ },
192
+ };
193
+
194
+ export const WithBadges: Story = {
195
+ render: () => ({
196
+ components: { UiAutocomplete, UiBadge },
197
+ setup() {
198
+ const value = ref('');
199
+ return { value, fruitsWithMeta };
200
+ },
201
+ template: `
202
+ <UiAutocomplete
203
+ v-model="value"
204
+ :options="fruitsWithMeta"
205
+ placeholder="Search fruit"
206
+ start-icon="search"
207
+ class="w-[340px]"
208
+ >
209
+ <template #item="{ option }">
210
+ <div class="flex min-w-0 flex-1 items-center justify-between gap-3">
211
+ <span class="truncate">{{ option.label }}</span>
212
+ <div class="flex shrink-0 items-center gap-1.5">
213
+ <UiBadge variant="secondary" size="small">
214
+ {{ option.group }}
215
+ </UiBadge>
216
+ <UiBadge variant="outline" size="small">
217
+ {{ option.status }}
218
+ </UiBadge>
219
+ </div>
220
+ </div>
221
+ </template>
222
+ </UiAutocomplete>
223
+ `,
224
+ }),
225
+ parameters: {
226
+ docs: {
227
+ description: {
228
+ story:
229
+ 'Uses the `item` slot to render richer option content with metadata badges next to each result.',
230
+ },
231
+ },
232
+ },
233
+ };
234
+
235
+ export const WithCheckboxes: Story = {
236
+ render: () => ({
237
+ components: { UiAutocomplete, UiCheckbox },
238
+ setup() {
239
+ const value = ref<string[]>(['apple', 'orange']);
240
+ return { value, fruits };
241
+ },
242
+ template: `
243
+ <UiAutocomplete
244
+ v-model="value"
245
+ multiple
246
+ :options="fruits"
247
+ placeholder="Search fruits"
248
+ :show-indicator="false"
249
+ class="w-[280px]"
250
+ >
251
+ <template #item="{ option, selected }">
252
+ <div class="flex min-w-0 flex-1 items-center gap-2">
253
+ <UiCheckbox
254
+ name="fruit-selection"
255
+ :model-value="selected"
256
+ class="pointer-events-none"
257
+ tabindex="-1"
258
+ />
259
+ <span class="truncate">{{ option.label }}</span>
260
+ </div>
261
+ </template>
262
+ </UiAutocomplete>
263
+ `,
264
+ }),
265
+ parameters: {
266
+ docs: {
267
+ description: {
268
+ story:
269
+ 'Shows a checkbox-style multi-select row. The checkbox mirrors the selected state, and the default right-side check indicator is hidden.',
270
+ },
271
+ },
272
+ },
273
+ };
274
+
275
+ export const WithExternalItems: Story = {
276
+ render: () => ({
277
+ components: { UiAutocomplete, UiAutocompleteItem },
278
+ setup() {
279
+ const value = ref('');
280
+ const visibleFruits = ref(fruits);
281
+ return { value, visibleFruits };
282
+ },
283
+ template: `
284
+ <UiAutocomplete
285
+ v-model="value"
286
+ placeholder="Search fruit"
287
+ start-icon="search"
288
+ class="w-[260px]"
289
+ >
290
+ <UiAutocompleteItem
291
+ v-for="fruit in visibleFruits"
292
+ :key="fruit.value"
293
+ :value="fruit.value"
294
+ >
295
+ {{ fruit.label }}
296
+ </UiAutocompleteItem>
297
+ </UiAutocomplete>
298
+ `,
299
+ }),
300
+ parameters: {
301
+ docs: {
302
+ description: {
303
+ story:
304
+ 'Renders options as external `UiAutocompleteItem` children instead of using the `options` prop. Use this when item rendering or filtering is owned by the parent.',
305
+ },
306
+ },
307
+ },
308
+ };