@getmicdrop/svelte-components 5.6.0 → 5.6.1
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/components/Layout/__tests__/AppShell.test.d.ts +2 -0
- package/dist/components/Layout/__tests__/AppShell.test.d.ts.map +1 -0
- package/dist/components/Layout/__tests__/AppShell.test.js +95 -0
- package/dist/components/Layout/__tests__/ContentSection.test.d.ts +2 -0
- package/dist/components/Layout/__tests__/ContentSection.test.d.ts.map +1 -0
- package/dist/components/Layout/__tests__/ContentSection.test.js +112 -0
- package/dist/components/Layout/__tests__/PageContainer.test.d.ts +2 -0
- package/dist/components/Layout/__tests__/PageContainer.test.d.ts.map +1 -0
- package/dist/components/Layout/__tests__/PageContainer.test.js +133 -0
- package/dist/components/Layout/__tests__/Responsive.test.d.ts +2 -0
- package/dist/components/Layout/__tests__/Responsive.test.d.ts.map +1 -0
- package/dist/components/Layout/__tests__/Responsive.test.js +123 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +41 -40
- package/dist/patterns/navigation/BottomNav.svelte +18 -8
- package/dist/patterns/navigation/BottomNav.svelte.d.ts.map +1 -1
- package/dist/primitives/Accordion/AccordionItemWrapper.test.svelte +107 -107
- package/dist/primitives/Accordion/AccordionItemWrapper.test.svelte.d.ts +2 -2
- package/dist/primitives/Accordion/AccordionItemWrapper.test.svelte.d.ts.map +1 -1
- package/dist/primitives/Checkbox/Checkbox.svelte +3 -3
- package/dist/primitives/Dropdown/DropdownDivider.svelte +9 -0
- package/dist/primitives/Dropdown/DropdownDivider.svelte.d.ts +7 -0
- package/dist/primitives/Dropdown/DropdownDivider.svelte.d.ts.map +1 -0
- package/dist/primitives/Helper/Helper.svelte +33 -0
- package/dist/primitives/Helper/Helper.svelte.d.ts +18 -0
- package/dist/primitives/Helper/Helper.svelte.d.ts.map +1 -0
- package/dist/primitives/Input/Input.svelte +416 -417
- package/dist/primitives/Input/Input.svelte.d.ts +2 -4
- package/dist/primitives/Input/Input.svelte.d.ts.map +1 -1
- package/dist/primitives/Modal/Modal.svelte +157 -158
- package/dist/primitives/Modal/Modal.svelte.d.ts +6 -8
- package/dist/primitives/Modal/Modal.svelte.d.ts.map +1 -1
- package/dist/primitives/NumberInput/NumberInput.svelte +105 -106
- package/dist/primitives/NumberInput/NumberInput.svelte.d.ts +0 -2
- package/dist/primitives/NumberInput/NumberInput.svelte.d.ts.map +1 -1
- package/dist/primitives/Toggle.svelte +70 -71
- package/dist/primitives/Toggle.svelte.d.ts +2 -4
- package/dist/primitives/Toggle.svelte.d.ts.map +1 -1
- package/dist/primitives/Tooltip/Tooltip.svelte +83 -0
- package/dist/primitives/Tooltip/Tooltip.svelte.d.ts +15 -0
- package/dist/primitives/Tooltip/Tooltip.svelte.d.ts.map +1 -0
- package/dist/primitives/index.d.ts +3 -0
- package/dist/primitives/index.js +7 -0
- package/dist/recipes/ImageUploader/ImageUploader.spec.js +6 -5
- package/dist/recipes/inputs/MultiSelect.svelte +277 -256
- package/dist/recipes/inputs/MultiSelect.svelte.d.ts +54 -21
- package/dist/recipes/inputs/MultiSelect.svelte.d.ts.map +1 -1
- package/dist/recipes/inputs/PlaceAutocomplete/PlaceAutocomplete.spec.js +9 -4
- package/dist/recipes/inputs/PlaceAutocomplete/PlaceAutocomplete.svelte +332 -327
- package/dist/recipes/inputs/PlaceAutocomplete/PlaceAutocomplete.svelte.d.ts +12 -1
- package/dist/recipes/inputs/PlaceAutocomplete/PlaceAutocomplete.svelte.d.ts.map +1 -1
- package/dist/stores/auth.js +8 -0
- package/dist/stores/auth.svelte.d.ts +39 -0
- package/dist/stores/auth.svelte.d.ts.map +1 -0
- package/dist/stores/auth.svelte.js +60 -0
- package/dist/stores/formDataStore.d.ts.map +1 -1
- package/dist/stores/formDataStore.js +8 -0
- package/dist/stores/formDataStore.svelte.d.ts +47 -0
- package/dist/stores/formDataStore.svelte.d.ts.map +1 -0
- package/dist/stores/formDataStore.svelte.js +84 -0
- package/dist/stores/formSave.d.ts.map +1 -1
- package/dist/stores/formSave.js +8 -0
- package/dist/stores/formSave.svelte.d.ts +33 -0
- package/dist/stores/formSave.svelte.d.ts.map +1 -0
- package/dist/stores/formSave.svelte.js +113 -0
- package/dist/stores/navigation.d.ts.map +1 -1
- package/dist/stores/navigation.js +8 -0
- package/dist/stores/navigation.svelte.d.ts +35 -0
- package/dist/stores/navigation.svelte.d.ts.map +1 -0
- package/dist/stores/navigation.svelte.js +69 -0
- package/dist/telemetry.server.spec.js +11 -8
- package/dist/telemetry.spec.js +75 -50
- package/dist/utils/imageValidation.spec.js +62 -59
- package/dist/utils/logger.d.ts +19 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +47 -0
- package/package.json +296 -292
|
@@ -1,256 +1,277 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { CloseOutline, ChevronDownOutline } from "../../primitives/Icons";
|
|
3
|
-
import { typography } from '../../tokens/typography';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
let
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
1
|
+
<script>
|
|
2
|
+
import { CloseOutline, ChevronDownOutline } from "../../primitives/Icons";
|
|
3
|
+
import { typography } from '../../tokens/typography';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {Object} SelectItem
|
|
8
|
+
* @property {string} name - Display name for the item
|
|
9
|
+
* @property {string | number} value - Value of the item
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** @type {{
|
|
13
|
+
value?: (string | number)[],
|
|
14
|
+
items?: SelectItem[],
|
|
15
|
+
placeholder?: string,
|
|
16
|
+
label?: string,
|
|
17
|
+
required?: boolean,
|
|
18
|
+
disabled?: boolean,
|
|
19
|
+
error?: string,
|
|
20
|
+
hideClear?: boolean,
|
|
21
|
+
hideCheckboxes?: boolean,
|
|
22
|
+
singleSelect?: boolean,
|
|
23
|
+
name?: string,
|
|
24
|
+
id?: string,
|
|
25
|
+
size?: 'sm' | 'md' | 'lg',
|
|
26
|
+
animateFocus?: boolean,
|
|
27
|
+
onchange?: (detail: { value: (string | number)[], items: SelectItem[] }) => void
|
|
28
|
+
}} */
|
|
29
|
+
let {
|
|
30
|
+
value = $bindable([]),
|
|
31
|
+
items = [],
|
|
32
|
+
placeholder = "Select options",
|
|
33
|
+
label = "",
|
|
34
|
+
required = false,
|
|
35
|
+
disabled = false,
|
|
36
|
+
error = "",
|
|
37
|
+
hideClear = false,
|
|
38
|
+
hideCheckboxes = false,
|
|
39
|
+
singleSelect = false,
|
|
40
|
+
name = "",
|
|
41
|
+
id = "",
|
|
42
|
+
size = "md",
|
|
43
|
+
animateFocus = true,
|
|
44
|
+
onchange,
|
|
45
|
+
} = $props();
|
|
46
|
+
|
|
47
|
+
let isOpen = $state(false);
|
|
48
|
+
let triggerElement = $state();
|
|
49
|
+
let dropdownElement = $state();
|
|
50
|
+
let focusedIndex = $state(-1);
|
|
51
|
+
|
|
52
|
+
// Ensure value is always an array (initialize immediately)
|
|
53
|
+
if (!Array.isArray(value)) {
|
|
54
|
+
value = [];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Keep value as array
|
|
58
|
+
$effect(() => {
|
|
59
|
+
if (!Array.isArray(value)) {
|
|
60
|
+
value = [];
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
let selectedItems = $derived(items.filter((item) => value.includes(item.value)));
|
|
65
|
+
let hasSelection = $derived(selectedItems.length > 0);
|
|
66
|
+
|
|
67
|
+
// Size classes matching Input component
|
|
68
|
+
const sizeClasses = {
|
|
69
|
+
sm: "min-h-9 py-2 px-2.5 text-sm",
|
|
70
|
+
md: "min-h-10 py-2.5 px-3 text-sm",
|
|
71
|
+
lg: "min-h-12 py-3 px-3.5 text-base"
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
let sizeClass = $derived(sizeClasses[size] || sizeClasses.md);
|
|
75
|
+
|
|
76
|
+
function toggle() {
|
|
77
|
+
if (disabled) return;
|
|
78
|
+
isOpen = !isOpen;
|
|
79
|
+
if (isOpen) {
|
|
80
|
+
focusedIndex = 0;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function close() {
|
|
85
|
+
isOpen = false;
|
|
86
|
+
focusedIndex = -1;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function toggleItem(item) {
|
|
90
|
+
const index = value.indexOf(item.value);
|
|
91
|
+
if (index === -1) {
|
|
92
|
+
value = [...value, item.value];
|
|
93
|
+
} else {
|
|
94
|
+
value = value.filter((v) => v !== item.value);
|
|
95
|
+
}
|
|
96
|
+
onchange?.({ value, items: selectedItems });
|
|
97
|
+
// Close dropdown after selection in single-select mode
|
|
98
|
+
if (singleSelect) {
|
|
99
|
+
close();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function removeItem(item, event) {
|
|
104
|
+
event.stopPropagation();
|
|
105
|
+
value = value.filter((v) => v !== item.value);
|
|
106
|
+
onchange?.({ value, items: selectedItems });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function clearAll(event) {
|
|
110
|
+
event.stopPropagation();
|
|
111
|
+
value = [];
|
|
112
|
+
onchange?.({ value: [], items: [] });
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function handleKeydown(event) {
|
|
116
|
+
if (disabled) return;
|
|
117
|
+
|
|
118
|
+
switch (event.key) {
|
|
119
|
+
case "Enter":
|
|
120
|
+
case " ":
|
|
121
|
+
event.preventDefault();
|
|
122
|
+
if (isOpen && focusedIndex >= 0) {
|
|
123
|
+
toggleItem(items[focusedIndex]);
|
|
124
|
+
} else {
|
|
125
|
+
toggle();
|
|
126
|
+
}
|
|
127
|
+
break;
|
|
128
|
+
case "ArrowDown":
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
if (!isOpen) {
|
|
131
|
+
isOpen = true;
|
|
132
|
+
focusedIndex = 0;
|
|
133
|
+
} else {
|
|
134
|
+
focusedIndex = Math.min(focusedIndex + 1, items.length - 1);
|
|
135
|
+
}
|
|
136
|
+
break;
|
|
137
|
+
case "ArrowUp":
|
|
138
|
+
event.preventDefault();
|
|
139
|
+
if (isOpen) {
|
|
140
|
+
focusedIndex = Math.max(focusedIndex - 1, 0);
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
case "Escape":
|
|
144
|
+
event.preventDefault();
|
|
145
|
+
close();
|
|
146
|
+
break;
|
|
147
|
+
case "Tab":
|
|
148
|
+
close();
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function handleClickOutside(event) {
|
|
154
|
+
if (
|
|
155
|
+
triggerElement &&
|
|
156
|
+
!triggerElement.contains(event.target) &&
|
|
157
|
+
dropdownElement &&
|
|
158
|
+
!dropdownElement.contains(event.target)
|
|
159
|
+
) {
|
|
160
|
+
close();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
$effect(() => {
|
|
165
|
+
document.addEventListener("click", handleClickOutside);
|
|
166
|
+
return () => {
|
|
167
|
+
document.removeEventListener("click", handleClickOutside);
|
|
168
|
+
};
|
|
169
|
+
});
|
|
170
|
+
</script>
|
|
171
|
+
|
|
172
|
+
<div class="flex flex-col gap-2 w-full">
|
|
173
|
+
{#if label}
|
|
174
|
+
<div class="flex justify-start items-center gap-1">
|
|
175
|
+
<label for={id || name} class={`${typography.label} leading-tight`}>
|
|
176
|
+
{label}{#if required}<span class="text-red-500 font-medium text-sm ml-0.5">*</span>{/if}
|
|
177
|
+
</label>
|
|
178
|
+
</div>
|
|
179
|
+
{/if}
|
|
180
|
+
|
|
181
|
+
<div class="relative w-full">
|
|
182
|
+
<button
|
|
183
|
+
type="button"
|
|
184
|
+
bind:this={triggerElement}
|
|
185
|
+
{id}
|
|
186
|
+
{name}
|
|
187
|
+
class="flex items-center justify-between gap-2 w-full {sizeClass} bg-gray-50 dark:bg-gray-800 border rounded-lg cursor-pointer text-left transition-all focus:outline-none focus:ring-4 focus:ring-blue-300 dark:focus:ring-blue-800
|
|
188
|
+
{error ? 'border-red-500 dark:border-red-500' : 'border-gray-300 dark:border-gray-600 hover:border-blue-500 dark:hover:border-blue-500 focus:border-blue-500 dark:focus:border-blue-500'}
|
|
189
|
+
{disabled ? 'opacity-50 cursor-not-allowed' : ''}
|
|
190
|
+
{animateFocus ? 'multiselect-animate-focus' : ''}"
|
|
191
|
+
{disabled}
|
|
192
|
+
aria-haspopup="listbox"
|
|
193
|
+
aria-expanded={isOpen}
|
|
194
|
+
aria-labelledby={label ? `${id || name}-label` : undefined}
|
|
195
|
+
onclick={toggle}
|
|
196
|
+
onkeydown={handleKeydown}
|
|
197
|
+
>
|
|
198
|
+
<div class="flex-1 min-w-0">
|
|
199
|
+
{#if hasSelection}
|
|
200
|
+
<div class="flex flex-wrap gap-1.5">
|
|
201
|
+
{#each selectedItems as item}
|
|
202
|
+
<span class="inline-flex items-center px-2 py-1 bg-blue-100 rounded dark:bg-blue-900">
|
|
203
|
+
<span class={`${typography.sm} overflow-hidden text-ellipsis whitespace-nowrap`} style="color-scheme: light dark;">{item.name}</span>
|
|
204
|
+
<button
|
|
205
|
+
type="button"
|
|
206
|
+
class="inline-flex items-center p-0.5 ms-1.5 text-sm text-blue-400 bg-transparent rounded-sm hover:bg-blue-200 hover:text-blue-900 dark:hover:bg-blue-800 dark:hover:text-blue-300"
|
|
207
|
+
onclick={(e) => removeItem(item, e)}
|
|
208
|
+
aria-label="Remove {item.name}"
|
|
209
|
+
>
|
|
210
|
+
<CloseOutline class="w-3 h-3" />
|
|
211
|
+
</button>
|
|
212
|
+
</span>
|
|
213
|
+
{/each}
|
|
214
|
+
</div>
|
|
215
|
+
{:else}
|
|
216
|
+
<span class={typography.smMuted}>{placeholder}</span>
|
|
217
|
+
{/if}
|
|
218
|
+
</div>
|
|
219
|
+
|
|
220
|
+
<div class="flex items-center gap-1 flex-shrink-0">
|
|
221
|
+
{#if hasSelection && !hideClear}
|
|
222
|
+
<button
|
|
223
|
+
type="button"
|
|
224
|
+
class="flex items-center justify-center w-5 h-5 p-0 bg-transparent border-none cursor-pointer text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 rounded"
|
|
225
|
+
onclick={clearAll}
|
|
226
|
+
aria-label="Clear all"
|
|
227
|
+
>
|
|
228
|
+
<CloseOutline class="w-3.5 h-3.5" />
|
|
229
|
+
</button>
|
|
230
|
+
{/if}
|
|
231
|
+
<ChevronDownOutline class={`w-4 h-4 shrink-0 ${typography.iconMuted} transition-transform duration-200 ${isOpen ? 'rotate-180' : ''}`} />
|
|
232
|
+
</div>
|
|
233
|
+
</button>
|
|
234
|
+
|
|
235
|
+
{#if isOpen}
|
|
236
|
+
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
237
|
+
<ul
|
|
238
|
+
bind:this={dropdownElement}
|
|
239
|
+
class="absolute top-full left-0 right-0 z-50 mt-1 bg-white dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-lg shadow-lg max-h-60 overflow-y-auto list-none m-0 py-1"
|
|
240
|
+
role="listbox"
|
|
241
|
+
tabindex="-1"
|
|
242
|
+
aria-multiselectable="true"
|
|
243
|
+
aria-activedescendant={focusedIndex >= 0
|
|
244
|
+
? `${id || name}-option-${focusedIndex}`
|
|
245
|
+
: undefined}
|
|
246
|
+
>
|
|
247
|
+
{#each items as item, index}
|
|
248
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
249
|
+
<li
|
|
250
|
+
id="{id || name}-option-{index}"
|
|
251
|
+
class="flex items-center gap-2 px-3 py-2 cursor-pointer transition-colors {typography.sm}
|
|
252
|
+
{index === focusedIndex || value.includes(item.value) ? 'bg-gray-100 dark:bg-gray-600' : 'hover:bg-gray-100 dark:hover:bg-gray-600'}"
|
|
253
|
+
role="option"
|
|
254
|
+
aria-selected={value.includes(item.value)}
|
|
255
|
+
onclick={() => toggleItem(item)}
|
|
256
|
+
onmouseenter={() => (focusedIndex = index)}
|
|
257
|
+
>
|
|
258
|
+
{#if !hideCheckboxes}
|
|
259
|
+
<input
|
|
260
|
+
type="checkbox"
|
|
261
|
+
checked={value.includes(item.value)}
|
|
262
|
+
class="multiselect-checkbox w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-700 dark:focus:ring-offset-gray-700 focus:ring-2 dark:bg-gray-600 dark:border-gray-500 {value.includes(item.value) ? 'multiselect-checkbox-checked' : ''}"
|
|
263
|
+
tabindex="-1"
|
|
264
|
+
onclick={(e) => { e.stopPropagation(); toggleItem(item); }}
|
|
265
|
+
/>
|
|
266
|
+
{/if}
|
|
267
|
+
<span class="flex-1">{item.name}</span>
|
|
268
|
+
</li>
|
|
269
|
+
{/each}
|
|
270
|
+
</ul>
|
|
271
|
+
{/if}
|
|
272
|
+
</div>
|
|
273
|
+
|
|
274
|
+
{#if error}
|
|
275
|
+
<p class={`${typography.sm} text-red-500 dark:text-red-400`}>{error}</p>
|
|
276
|
+
{/if}
|
|
277
|
+
</div>
|
|
@@ -1,11 +1,39 @@
|
|
|
1
1
|
export default MultiSelect;
|
|
2
2
|
type MultiSelect = {
|
|
3
3
|
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
-
$set?(props: Partial
|
|
4
|
+
$set?(props: Partial<{
|
|
5
|
+
value?: (string | number)[] | undefined;
|
|
6
|
+
items?: SelectItem[] | undefined;
|
|
7
|
+
placeholder?: string | undefined;
|
|
8
|
+
label?: string | undefined;
|
|
9
|
+
required?: boolean | undefined;
|
|
10
|
+
disabled?: boolean | undefined;
|
|
11
|
+
error?: string | undefined;
|
|
12
|
+
hideClear?: boolean | undefined;
|
|
13
|
+
hideCheckboxes?: boolean | undefined;
|
|
14
|
+
singleSelect?: boolean | undefined;
|
|
15
|
+
name?: string | undefined;
|
|
16
|
+
id?: string | undefined;
|
|
17
|
+
size?: "sm" | "md" | "lg" | undefined;
|
|
18
|
+
animateFocus?: boolean | undefined;
|
|
19
|
+
onchange?: ((detail: {
|
|
20
|
+
value: (string | number)[];
|
|
21
|
+
items: SelectItem[];
|
|
22
|
+
}) => void) | undefined;
|
|
23
|
+
}>): void;
|
|
5
24
|
};
|
|
6
25
|
declare const MultiSelect: import("svelte").Component<{
|
|
7
|
-
value?:
|
|
8
|
-
items?:
|
|
26
|
+
value?: (string | number)[];
|
|
27
|
+
items?: {
|
|
28
|
+
/**
|
|
29
|
+
* - Display name for the item
|
|
30
|
+
*/
|
|
31
|
+
name: string;
|
|
32
|
+
/**
|
|
33
|
+
* - Value of the item
|
|
34
|
+
*/
|
|
35
|
+
value: string | number;
|
|
36
|
+
}[];
|
|
9
37
|
placeholder?: string;
|
|
10
38
|
label?: string;
|
|
11
39
|
required?: boolean;
|
|
@@ -16,25 +44,30 @@ declare const MultiSelect: import("svelte").Component<{
|
|
|
16
44
|
singleSelect?: boolean;
|
|
17
45
|
name?: string;
|
|
18
46
|
id?: string;
|
|
19
|
-
size?:
|
|
47
|
+
size?: "sm" | "md" | "lg";
|
|
20
48
|
animateFocus?: boolean;
|
|
21
|
-
onchange:
|
|
49
|
+
onchange?: (detail: {
|
|
50
|
+
value: (string | number)[];
|
|
51
|
+
items: {
|
|
52
|
+
/**
|
|
53
|
+
* - Display name for the item
|
|
54
|
+
*/
|
|
55
|
+
name: string;
|
|
56
|
+
/**
|
|
57
|
+
* - Value of the item
|
|
58
|
+
*/
|
|
59
|
+
value: string | number;
|
|
60
|
+
}[];
|
|
61
|
+
}) => void;
|
|
22
62
|
}, {}, "value">;
|
|
23
|
-
type
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
hideCheckboxes?: boolean;
|
|
33
|
-
singleSelect?: boolean;
|
|
34
|
-
name?: string;
|
|
35
|
-
id?: string;
|
|
36
|
-
size?: string;
|
|
37
|
-
animateFocus?: boolean;
|
|
38
|
-
onchange: any;
|
|
63
|
+
type SelectItem = {
|
|
64
|
+
/**
|
|
65
|
+
* - Display name for the item
|
|
66
|
+
*/
|
|
67
|
+
name: string;
|
|
68
|
+
/**
|
|
69
|
+
* - Value of the item
|
|
70
|
+
*/
|
|
71
|
+
value: string | number;
|
|
39
72
|
};
|
|
40
73
|
//# sourceMappingURL=MultiSelect.svelte.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelect.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/recipes/inputs/MultiSelect.svelte.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MultiSelect.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/recipes/inputs/MultiSelect.svelte.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoQA;YAhBY,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE;YACnB;;;;cAxOI,MAAM;;;;eACN,MAAM,GAAG,MAAM;OAuOP;kBACN,MAAM;YACZ,MAAM;eACH,OAAO;eACP,OAAO;YACV,MAAM;gBACF,OAAO;qBACF,OAAO;mBACT,OAAO;WACf,MAAM;SACR,MAAM;WACJ,IAAI,GAAG,IAAI,GAAG,IAAI;mBACV,OAAO;eACX,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;QAAC,KAAK,EAAE;;;;kBArP7C,MAAM;;;;mBACN,MAAM,GAAG,MAAM;WAoP0C,CAAA;KAAE,KAAK,IAAI;gBAE1B;;;;;UAvP1C,MAAM;;;;WACN,MAAM,GAAG,MAAM"}
|