@cloudparker/moldex.js 0.0.65 → 0.0.66
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/services/dialog/dialog-service.d.ts +11 -11
- package/dist/services/navigation/navigation-service.d.ts +17 -0
- package/dist/services/navigation/navigation-service.js +38 -0
- package/dist/services/utils/melody-service.d.ts +5 -0
- package/dist/services/utils/melody-service.js +41 -0
- package/dist/tailwind.css +1 -1
- package/dist/views/core/button/components/button/button.svelte +84 -133
- package/dist/views/core/button/components/button/button.svelte.d.ts +8 -7
- package/dist/views/core/button/components/button-back/button-back.svelte +16 -29
- package/dist/views/core/button/components/button-close/button-close.svelte +2 -4
- package/dist/views/core/button/components/button-close/button-close.svelte.d.ts +2 -2
- package/dist/views/core/button/components/button-close-icon/button-close-icon.svelte +16 -30
- package/dist/views/core/button/components/button-dropdown/button-dropdown.svelte +80 -0
- package/dist/views/core/button/components/button-dropdown/button-dropdown.svelte.d.ts +38 -0
- package/dist/views/core/button/components/button-list-item/button-list-item.svelte +65 -132
- package/dist/views/core/button/components/button-list-item/button-list-item.svelte.d.ts +22 -31
- package/dist/views/core/button/components/button-menu/button-menu.svelte +72 -235
- package/dist/views/core/button/components/button-menu/button-menu.svelte.d.ts +23 -43
- package/dist/views/core/button/components/button-ok/button-ok.svelte +2 -4
- package/dist/views/core/button/components/button-ok/button-ok.svelte.d.ts +2 -2
- package/dist/views/core/button/components/button-search/button-search.svelte +39 -0
- package/dist/views/core/button/components/button-search/button-search.svelte.d.ts +31 -0
- package/dist/views/core/button/index.d.ts +8 -5
- package/dist/views/core/button/index.js +4 -2
- package/dist/views/core/content-area/components/content-area.svelte +27 -40
- package/dist/views/core/dialog/components/cropper-dialog/cropper-dialog.svelte +33 -49
- package/dist/views/core/dialog/components/dialog/dialog.svelte +164 -263
- package/dist/views/core/dialog/components/dialog/dialog.svelte.d.ts +12 -12
- package/dist/views/core/dialog/components/list-dialog/list-picker-dialog.svelte +112 -158
- package/dist/views/core/dialog/components/loading-dialog/loading-dialog.svelte +18 -30
- package/dist/views/core/dialog/components/msg-dialog/msg-dialog.svelte +13 -22
- package/dist/views/core/dialog/components/text-field-dialog/text-field-dialog.svelte +35 -41
- package/dist/views/core/dialog/components/text-field-dialog/text-field-dialog.svelte.d.ts +2 -2
- package/dist/views/core/dialog/components/textarea-field-dialog/textarea-field-dialog.svelte +25 -40
- package/dist/views/core/dialog/components/textarea-field-dialog/textarea-field-dialog.svelte.d.ts +2 -2
- package/dist/views/core/dialog/index.d.ts +2 -2
- package/dist/views/core/drawer/components/drawer/drawer.svelte +35 -57
- package/dist/views/core/icon/components/icon/icon.svelte +14 -26
- package/dist/views/core/input/components/checkbox-field/checkbox-field.svelte +25 -44
- package/dist/views/core/input/components/color-field/color-field.svelte +69 -81
- package/dist/views/core/input/components/color-field/color-field.svelte.d.ts +2 -2
- package/dist/views/core/input/components/combobox-field/combobox-field.svelte +256 -331
- package/dist/views/core/input/components/combobox-field/combobox-field.svelte.d.ts +18 -17
- package/dist/views/core/input/components/date-field/date-field.svelte +30 -39
- package/dist/views/core/input/components/date-field/date-field.svelte.d.ts +2 -2
- package/dist/views/core/input/components/datetime-field/datetime-field.svelte +12 -18
- package/dist/views/core/input/components/datetime-field/datetime-field.svelte.d.ts +2 -2
- package/dist/views/core/input/components/email-field/email-field.svelte +12 -17
- package/dist/views/core/input/components/email-field/email-field.svelte.d.ts +2 -2
- package/dist/views/core/input/components/file-field/file-field.svelte +64 -78
- package/dist/views/core/input/components/file-field/file-field.svelte.d.ts +2 -2
- package/dist/views/core/input/components/input-field/input-field.svelte +159 -261
- package/dist/views/core/input/components/input-field/input-field.svelte.d.ts +8 -8
- package/dist/views/core/input/components/label/label.svelte +10 -24
- package/dist/views/core/input/components/number-field/number-field.svelte +12 -18
- package/dist/views/core/input/components/number-field/number-field.svelte.d.ts +2 -2
- package/dist/views/core/input/components/password-field/password-field.svelte +57 -70
- package/dist/views/core/input/components/password-field/password-field.svelte.d.ts +2 -2
- package/dist/views/core/input/components/phone-field/phone-field.svelte +118 -172
- package/dist/views/core/input/components/phone-field/phone-field.svelte.d.ts +2 -2
- package/dist/views/core/input/components/radio-field/radio-field.svelte +53 -84
- package/dist/views/core/input/components/radio-field/radio-field.svelte.d.ts +7 -7
- package/dist/views/core/input/components/range-field/range-field.svelte +42 -66
- package/dist/views/core/input/components/range-field/range-field.svelte.d.ts +2 -2
- package/dist/views/core/input/components/search-field/search-field.svelte +45 -62
- package/dist/views/core/input/components/search-field/search-field.svelte.d.ts +2 -2
- package/dist/views/core/input/components/text-field/text-field.svelte +16 -21
- package/dist/views/core/input/components/text-field/text-field.svelte.d.ts +2 -2
- package/dist/views/core/input/components/textarea-field/textarea-field.svelte +12 -17
- package/dist/views/core/input/components/textarea-field/textarea-field.svelte.d.ts +2 -2
- package/dist/views/core/input/components/time-field/time-field.svelte +12 -17
- package/dist/views/core/input/components/time-field/time-field.svelte.d.ts +2 -2
- package/dist/views/core/input/index.d.ts +4 -3
- package/dist/views/core/navbar/components/navbar/navbar.svelte +39 -77
- package/dist/views/core/no-data/components/no-data/no-data.svelte +20 -37
- package/dist/views/core/pagination/components/pagination/pagination.svelte +73 -102
- package/dist/views/core/progressbar/components/progressbar/progressbar.svelte +23 -37
- package/dist/views/core/ruler/components/vertical-ruler/verticcal-ruler.svelte +2 -6
- package/dist/views/core/screen-detector/components/screen-detector.svelte +9 -13
- package/dist/views/core/sidebar/components/sidebar.svelte +23 -36
- package/dist/views/core/spinner/components/spinner/spinner.svelte +2 -7
- package/dist/views/core/text/components/text-await/text-await.svelte +2 -8
- package/dist/views/core/text/components/text-copy/text-copy.svelte +17 -28
- package/dist/views/core/text/components/text-country/text-country.svelte +29 -41
- package/dist/views/core/text/components/text-country-state/text-country-state.svelte +29 -37
- package/dist/views/core/text/components/text-currency/text-currency.svelte +10 -21
- package/dist/views/core/text/components/text-date/text-date.svelte +21 -33
- package/dist/views/core/text/components/text-email/text-email.svelte +4 -13
- package/dist/views/core/text/components/text-html/text-html.svelte +2 -3
- package/dist/views/core/text/components/text-phone/text-phone.svelte +4 -13
- package/dist/views/core/toast/components/toast/toast.svelte +21 -44
- package/package.json +1 -1
|
@@ -1,333 +1,253 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
function toggleDropdown() {
|
|
253
|
-
if (isPlaced) {
|
|
254
|
-
closeDropdown();
|
|
255
|
-
} else {
|
|
256
|
-
openDropdown();
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
function closeDropdown() {
|
|
261
|
-
searchText = '';
|
|
262
|
-
isPlaced = false;
|
|
263
|
-
focus();
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function openDropdown() {
|
|
267
|
-
isPlaced = true;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
function handleInputClick() {
|
|
271
|
-
toggleDropdown();
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
function handleBackdropClick() {
|
|
275
|
-
toggleDropdown();
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
function handleKeyDown(event: KeyboardEvent) {
|
|
279
|
-
if (event.key === 'Escape') {
|
|
280
|
-
closeDropdown();
|
|
281
|
-
} else if (event.key === 'Enter' || event.key === ' ') {
|
|
282
|
-
event.preventDefault(); // Prevent default action for spacebar to avoid scrolling
|
|
283
|
-
toggleDropdown();
|
|
284
|
-
} else if (/^[a-zA-Z0-9]$/.test(event.key)) {
|
|
285
|
-
searchFieldRef && searchFieldRef.focus();
|
|
286
|
-
} else if (event.key === 'Backspace' || event.key === 'Delete') {
|
|
287
|
-
event.preventDefault(); // Prevent default action for these keys if necessary
|
|
288
|
-
selectedItemsSet.clear();
|
|
289
|
-
value = null;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
function handleDropdownKeyDown(event: KeyboardEvent) {
|
|
294
|
-
if (event.key === 'Escape') {
|
|
295
|
-
closeDropdown();
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
function handleSearch(value: string) {
|
|
300
|
-
searchText = value;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
function handleItemSelected(ev: MouseEvent, item: CustomListItemType, index: number) {
|
|
304
|
-
let id = item[idFieldSymbol];
|
|
305
|
-
if (multiple) {
|
|
306
|
-
if (selectedItemsSet.has(id)) {
|
|
307
|
-
selectedItemsSet.delete(id);
|
|
308
|
-
} else {
|
|
309
|
-
selectedItemsSet.add(id);
|
|
310
|
-
}
|
|
311
|
-
} else {
|
|
312
|
-
selectedItemsSet.clear();
|
|
313
|
-
selectedItemsSet.add(id);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
items = [...(items || [])];
|
|
317
|
-
|
|
318
|
-
let array = Array.from(selectedItemsSet);
|
|
319
|
-
if (array.length) {
|
|
320
|
-
value = multiple ? array : array[0];
|
|
321
|
-
} else {
|
|
322
|
-
value = null;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
if (!multiple) {
|
|
326
|
-
closeDropdown();
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
// console.log('handleItemSelected', selectedItemsSet, value);
|
|
330
|
-
}
|
|
1
|
+
<script module lang="ts"></script>
|
|
2
|
+
|
|
3
|
+
<script lang="ts">import ButtonListItem from "../../../button/components/button-list-item/button-list-item.svelte";
|
|
4
|
+
import Button from "../../../button/components/button/button.svelte";
|
|
5
|
+
import { mdiUnfoldMoreHorizontal } from "../../../icon";
|
|
6
|
+
import Icon from "../../../icon/components/icon/icon.svelte";
|
|
7
|
+
import NoData from "../../../no-data/components/no-data/no-data.svelte";
|
|
8
|
+
import InputField, {} from "../input-field/input-field.svelte";
|
|
9
|
+
import SearchField from "../search-field/search-field.svelte";
|
|
10
|
+
let {
|
|
11
|
+
appearance,
|
|
12
|
+
chipClassName,
|
|
13
|
+
className,
|
|
14
|
+
comboboxIconClassName,
|
|
15
|
+
comboboxIconPath = mdiUnfoldMoreHorizontal,
|
|
16
|
+
contentSnippet,
|
|
17
|
+
createButtonClassName,
|
|
18
|
+
createButtonLabel = "Add",
|
|
19
|
+
displayClassName,
|
|
20
|
+
displayFieldName,
|
|
21
|
+
displayItemsCount,
|
|
22
|
+
dropdownBodyClassName,
|
|
23
|
+
dropdownBodySnippet,
|
|
24
|
+
dropdownClassName,
|
|
25
|
+
dropdownFooterClassName,
|
|
26
|
+
dropdownFooterSnippet,
|
|
27
|
+
dropdownHeaderClassName,
|
|
28
|
+
dropdownHeaderSnippet,
|
|
29
|
+
emptyMessage = "No items exists!",
|
|
30
|
+
emptyMessageSnippet,
|
|
31
|
+
hasComboboxIcon = true,
|
|
32
|
+
hasDropdownFooter,
|
|
33
|
+
hasDropdownFooterCreateButton,
|
|
34
|
+
hasDropdownHeader,
|
|
35
|
+
hasDropdownHeaderSearch,
|
|
36
|
+
hasItemsCheckbox,
|
|
37
|
+
hasPrimitiveItemsData,
|
|
38
|
+
iconPathClassName,
|
|
39
|
+
iconPathFieldName,
|
|
40
|
+
id,
|
|
41
|
+
identityFieldName,
|
|
42
|
+
itemClassName,
|
|
43
|
+
items,
|
|
44
|
+
multiple,
|
|
45
|
+
name,
|
|
46
|
+
onCreateButtonClick,
|
|
47
|
+
onSearch,
|
|
48
|
+
searchClassName,
|
|
49
|
+
searchFieldName,
|
|
50
|
+
searchPlaceholder = "Search...",
|
|
51
|
+
showChip,
|
|
52
|
+
size,
|
|
53
|
+
itemSubtitleClassName,
|
|
54
|
+
itemSubtitleFieldName,
|
|
55
|
+
itemTitleClassName,
|
|
56
|
+
itemTitleFieldName,
|
|
57
|
+
value = $bindable(),
|
|
58
|
+
...props
|
|
59
|
+
} = $props();
|
|
60
|
+
let idFieldSymbol = Symbol("_id");
|
|
61
|
+
let searchFieldSymbol = Symbol("_search");
|
|
62
|
+
let searchFieldRef = $state(null);
|
|
63
|
+
let comboboxIconSizeClassName = $state("");
|
|
64
|
+
let isPlaced = $state(false);
|
|
65
|
+
let searchText = $state("");
|
|
66
|
+
let itemsIdentityMap = {};
|
|
67
|
+
let _value = $derived.by(() => {
|
|
68
|
+
return selectedItemsSet?.size ? " " : "";
|
|
69
|
+
});
|
|
70
|
+
let displayItems = $derived.by(() => {
|
|
71
|
+
let array = Array.from(selectedItemsSet);
|
|
72
|
+
let results = array.map((id2) => {
|
|
73
|
+
if (hasPrimitiveItemsData) {
|
|
74
|
+
return [id2];
|
|
75
|
+
} else {
|
|
76
|
+
let item = itemsIdentityMap[id2];
|
|
77
|
+
if (item) {
|
|
78
|
+
if (displayFieldName && item.hasOwnProperty(displayFieldName)) {
|
|
79
|
+
return item[displayFieldName];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return results;
|
|
85
|
+
});
|
|
86
|
+
let displayItemsTitle = $derived(displayItems.join(", "));
|
|
87
|
+
let displayText = $derived.by(() => {
|
|
88
|
+
let results = displayItems;
|
|
89
|
+
if (!showChip) {
|
|
90
|
+
if (results?.length) {
|
|
91
|
+
if (multiple) {
|
|
92
|
+
let res = results.join(", ");
|
|
93
|
+
if (displayItemsCount != null && displayItemsCount > 1) {
|
|
94
|
+
res = results.slice(0, displayItemsCount).join(", ");
|
|
95
|
+
if (results.length > displayItemsCount) {
|
|
96
|
+
res += `<span class="text-gray-400 px-2">+ ${results.length - displayItemsCount} </span>`;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return res;
|
|
100
|
+
} else {
|
|
101
|
+
return results[0] || "";
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return "";
|
|
106
|
+
});
|
|
107
|
+
let selectedItemsSet = $derived.by(() => {
|
|
108
|
+
let set = /* @__PURE__ */ new Set();
|
|
109
|
+
if (value != null) {
|
|
110
|
+
if (Array.isArray(value)) {
|
|
111
|
+
value.forEach((v) => set.add(v));
|
|
112
|
+
} else if (value) {
|
|
113
|
+
set.add(value);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return set;
|
|
117
|
+
});
|
|
118
|
+
let preparedItems = $derived.by(() => {
|
|
119
|
+
return (items || []).map((item, index) => {
|
|
120
|
+
let res = {};
|
|
121
|
+
if (hasPrimitiveItemsData) {
|
|
122
|
+
res.title = item;
|
|
123
|
+
res[idFieldSymbol] = item;
|
|
124
|
+
res[searchFieldSymbol] = ("" + item).toLowerCase().trim();
|
|
125
|
+
} else {
|
|
126
|
+
if (identityFieldName && item.hasOwnProperty(identityFieldName)) {
|
|
127
|
+
res[idFieldSymbol] = item[identityFieldName];
|
|
128
|
+
} else {
|
|
129
|
+
res[idFieldSymbol] = index;
|
|
130
|
+
}
|
|
131
|
+
itemsIdentityMap[res[idFieldSymbol]] = item;
|
|
132
|
+
if (itemTitleFieldName && item.hasOwnProperty(itemTitleFieldName)) {
|
|
133
|
+
res.title = item[itemTitleFieldName];
|
|
134
|
+
}
|
|
135
|
+
if (itemSubtitleFieldName && item.hasOwnProperty(itemSubtitleFieldName)) {
|
|
136
|
+
res.subtitle = item[itemSubtitleFieldName];
|
|
137
|
+
}
|
|
138
|
+
if (searchFieldName) {
|
|
139
|
+
if (item.hasOwnProperty(searchFieldName)) {
|
|
140
|
+
res[searchFieldSymbol] = (item[searchFieldName] || "").toLowerCase().trim();
|
|
141
|
+
}
|
|
142
|
+
} else {
|
|
143
|
+
res[searchFieldSymbol] = `${item.title || ""} ${item.subtitle || ""}`;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (selectedItemsSet.has(res[idFieldSymbol])) {
|
|
147
|
+
res.isChecked = true;
|
|
148
|
+
} else {
|
|
149
|
+
res.isChecked = false;
|
|
150
|
+
}
|
|
151
|
+
return res;
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
let filteredItems = $derived.by(() => {
|
|
155
|
+
if (searchText) {
|
|
156
|
+
return preparedItems.filter((item) => {
|
|
157
|
+
return item[searchFieldSymbol].indexOf(searchText) >= 0;
|
|
158
|
+
});
|
|
159
|
+
} else {
|
|
160
|
+
return [...preparedItems];
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
$effect(() => {
|
|
164
|
+
if (size) {
|
|
165
|
+
switch (size) {
|
|
166
|
+
case "lg":
|
|
167
|
+
comboboxIconSizeClassName = "!h-7 !w-7";
|
|
168
|
+
break;
|
|
169
|
+
case "md":
|
|
170
|
+
comboboxIconSizeClassName = "!h-6 !w-6";
|
|
171
|
+
break;
|
|
172
|
+
case "sm":
|
|
173
|
+
comboboxIconSizeClassName = "!h-5 !w-5";
|
|
174
|
+
break;
|
|
175
|
+
case "xs":
|
|
176
|
+
comboboxIconSizeClassName = "!h-4 !w-4";
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
let inputFieldRef = $state(null);
|
|
182
|
+
export function focus() {
|
|
183
|
+
inputFieldRef?.focus();
|
|
184
|
+
}
|
|
185
|
+
function toggleDropdown() {
|
|
186
|
+
if (isPlaced) {
|
|
187
|
+
closeDropdown();
|
|
188
|
+
} else {
|
|
189
|
+
openDropdown();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
function closeDropdown() {
|
|
193
|
+
searchText = "";
|
|
194
|
+
isPlaced = false;
|
|
195
|
+
focus();
|
|
196
|
+
}
|
|
197
|
+
function openDropdown() {
|
|
198
|
+
isPlaced = true;
|
|
199
|
+
}
|
|
200
|
+
function handleInputClick() {
|
|
201
|
+
toggleDropdown();
|
|
202
|
+
}
|
|
203
|
+
function handleBackdropClick() {
|
|
204
|
+
toggleDropdown();
|
|
205
|
+
}
|
|
206
|
+
function handleKeyDown(event) {
|
|
207
|
+
if (event.key === "Escape") {
|
|
208
|
+
closeDropdown();
|
|
209
|
+
} else if (event.key === "Enter" || event.key === " ") {
|
|
210
|
+
event.preventDefault();
|
|
211
|
+
toggleDropdown();
|
|
212
|
+
} else if (/^[a-zA-Z0-9]$/.test(event.key)) {
|
|
213
|
+
searchFieldRef && searchFieldRef.focus();
|
|
214
|
+
} else if (event.key === "Backspace" || event.key === "Delete") {
|
|
215
|
+
event.preventDefault();
|
|
216
|
+
selectedItemsSet.clear();
|
|
217
|
+
value = null;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
function handleDropdownKeyDown(event) {
|
|
221
|
+
if (event.key === "Escape") {
|
|
222
|
+
closeDropdown();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
function handleSearch(value2) {
|
|
226
|
+
searchText = value2;
|
|
227
|
+
}
|
|
228
|
+
function handleItemSelected(ev, item, index) {
|
|
229
|
+
let id2 = item[idFieldSymbol];
|
|
230
|
+
if (multiple) {
|
|
231
|
+
if (selectedItemsSet.has(id2)) {
|
|
232
|
+
selectedItemsSet.delete(id2);
|
|
233
|
+
} else {
|
|
234
|
+
selectedItemsSet.add(id2);
|
|
235
|
+
}
|
|
236
|
+
} else {
|
|
237
|
+
selectedItemsSet.clear();
|
|
238
|
+
selectedItemsSet.add(id2);
|
|
239
|
+
}
|
|
240
|
+
items = [...items || []];
|
|
241
|
+
let array = Array.from(selectedItemsSet);
|
|
242
|
+
if (array.length) {
|
|
243
|
+
value = multiple ? array : array[0];
|
|
244
|
+
} else {
|
|
245
|
+
value = null;
|
|
246
|
+
}
|
|
247
|
+
if (!multiple) {
|
|
248
|
+
closeDropdown();
|
|
249
|
+
}
|
|
250
|
+
}
|
|
331
251
|
</script>
|
|
332
252
|
|
|
333
253
|
{#snippet rightIcon()}
|
|
@@ -387,7 +307,12 @@
|
|
|
387
307
|
title={displayItemsTitle || ''}
|
|
388
308
|
/>
|
|
389
309
|
{#if isPlaced}
|
|
390
|
-
<button
|
|
310
|
+
<button
|
|
311
|
+
id="backdrop"
|
|
312
|
+
class="fixed inset-0 z-10"
|
|
313
|
+
onclick={handleBackdropClick}
|
|
314
|
+
tabindex="-1"
|
|
315
|
+
aria-label="backdrop"
|
|
391
316
|
></button>
|
|
392
317
|
<!-- svelte-ignore a11y_interactive_supports_focus -->
|
|
393
318
|
<div
|
|
@@ -1,19 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { type InputFieldPropsType } from '../input-field/input-field.svelte';
|
|
3
|
-
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
4
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
5
|
-
$$bindings?: Bindings;
|
|
6
|
-
} & Exports;
|
|
7
|
-
(internal: unknown, props: Props & {
|
|
8
|
-
$$events?: Events;
|
|
9
|
-
$$slots?: Slots;
|
|
10
|
-
}): Exports & {
|
|
11
|
-
$set?: any;
|
|
12
|
-
$on?: any;
|
|
13
|
-
};
|
|
14
|
-
z_$$bindings?: Bindings;
|
|
15
|
-
}
|
|
16
|
-
declare const ComboboxField: $$__sveltets_2_IsomorphicComponent<InputFieldPropsType & {
|
|
1
|
+
export type ComboboxFieldProps = {
|
|
17
2
|
chipClassName?: string;
|
|
18
3
|
comboboxIconClassName?: string;
|
|
19
4
|
comboboxIconPath?: string;
|
|
@@ -54,7 +39,23 @@ declare const ComboboxField: $$__sveltets_2_IsomorphicComponent<InputFieldPropsT
|
|
|
54
39
|
itemSubtitleFieldName?: string;
|
|
55
40
|
itemTitleClassName?: string;
|
|
56
41
|
itemTitleFieldName?: string;
|
|
57
|
-
}
|
|
42
|
+
};
|
|
43
|
+
import type { Snippet } from 'svelte';
|
|
44
|
+
import { type InputFieldProps } from '../input-field/input-field.svelte';
|
|
45
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
46
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
47
|
+
$$bindings?: Bindings;
|
|
48
|
+
} & Exports;
|
|
49
|
+
(internal: unknown, props: Props & {
|
|
50
|
+
$$events?: Events;
|
|
51
|
+
$$slots?: Slots;
|
|
52
|
+
}): Exports & {
|
|
53
|
+
$set?: any;
|
|
54
|
+
$on?: any;
|
|
55
|
+
};
|
|
56
|
+
z_$$bindings?: Bindings;
|
|
57
|
+
}
|
|
58
|
+
declare const ComboboxField: $$__sveltets_2_IsomorphicComponent<InputFieldProps & ComboboxFieldProps, {
|
|
58
59
|
[evt: string]: CustomEvent<any>;
|
|
59
60
|
}, {}, {
|
|
60
61
|
focus: () => void;
|