@cloudparker/moldex.js 0.0.29 → 0.0.31
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/tailwind.css +1 -1
- package/dist/views/core/button/components/button/button.svelte +54 -33
- package/dist/views/core/button/components/button-back/button-back.svelte +26 -14
- package/dist/views/core/button/components/button-close/button-close.svelte +4 -2
- package/dist/views/core/button/components/button-close-icon/button-close-icon.svelte +29 -15
- package/dist/views/core/button/components/button-list-item/button-list-item.svelte +78 -30
- package/dist/views/core/button/components/button-menu/button-menu.svelte +143 -90
- package/dist/views/core/button/components/button-ok/button-ok.svelte +4 -2
- package/dist/views/core/dialog/components/dialog/dialog.svelte +245 -158
- package/dist/views/core/dialog/components/dialog/dialog.svelte.d.ts +2 -7
- package/dist/views/core/dialog/components/list-dialog/list-picker-dialog.svelte +152 -108
- package/dist/views/core/dialog/components/msg-dialog/msg-dialog.svelte +22 -13
- package/dist/views/core/dialog/index.d.ts +4 -2
- package/dist/views/core/dialog/index.js +2 -2
- package/dist/views/core/drawer/components/drawer/drawer.svelte +52 -34
- package/dist/views/core/icon/components/icon/icon.svelte +24 -13
- package/dist/views/core/input/components/color-field/color-field.svelte +71 -61
- package/dist/views/core/input/components/combobox-field/combobox-field.svelte +330 -248
- package/dist/views/core/input/components/combobox-field/combobox-field.svelte.d.ts +1 -1
- package/dist/views/core/input/components/date-field/date-field.svelte +10 -6
- package/dist/views/core/input/components/datetime-field/datetime-field.svelte +10 -6
- package/dist/views/core/input/components/email-field/email-field.svelte +9 -6
- package/dist/views/core/input/components/file-field/file-field.svelte +69 -57
- package/dist/views/core/input/components/input-field/input-field.svelte +251 -151
- package/dist/views/core/input/components/label/label.svelte +24 -10
- package/dist/views/core/input/components/number-field/number-field.svelte +10 -6
- package/dist/views/core/input/components/password-field/password-field.svelte +59 -48
- package/dist/views/core/input/components/phone-field/phone-field.svelte +62 -48
- package/dist/views/core/input/components/radio-field/radio-field.svelte +120 -0
- package/dist/views/core/input/components/radio-field/radio-field.svelte.d.ts +45 -0
- package/dist/views/core/input/components/range-field/range-field.svelte +51 -32
- package/dist/views/core/input/components/search-field/search-field.svelte +52 -38
- package/dist/views/core/input/components/text-field/text-field.svelte +9 -6
- package/dist/views/core/input/components/textarea-field/textarea-field.svelte +9 -6
- package/dist/views/core/input/components/time-field/time-field.svelte +9 -6
- package/dist/views/core/input/index.d.ts +4 -2
- package/dist/views/core/input/index.js +2 -2
- package/dist/views/core/navbar/components/navbar/navbar.svelte +63 -31
- package/dist/views/core/no-data/components/no-data/no-data.svelte +37 -20
- package/dist/views/core/no-data/components/no-data/no-data.svelte.d.ts +1 -1
- package/dist/views/core/pagination/components/pagination/pagination.svelte +100 -71
- package/dist/views/core/progressbar/components/progressbar/progressbar.svelte +37 -23
- package/dist/views/core/referrer/components/referrer.svelte +15 -13
- package/dist/views/core/ruler/components/vertical-ruler/verticcal-ruler.svelte +6 -2
- package/dist/views/core/screen-detector/components/screen-detector.svelte +13 -9
- package/dist/views/core/spinner/components/spinner/spinner.svelte +7 -2
- package/dist/views/core/text/components/text-await/text-await.svelte +8 -2
- package/dist/views/core/text/components/text-copy/text-copy.svelte +28 -17
- package/dist/views/core/text/components/text-country/text-country.svelte +41 -29
- package/dist/views/core/text/components/text-country-state/text-country-state.svelte +37 -29
- package/dist/views/core/text/components/text-currency/text-currency.svelte +21 -10
- package/dist/views/core/text/components/text-date/text-date.svelte +33 -21
- package/dist/views/core/text/components/text-email/text-email.svelte +13 -4
- package/dist/views/core/text/components/text-html/text-html.svelte +3 -2
- package/dist/views/core/text/components/text-phone/text-phone.svelte +13 -4
- package/dist/views/core/toast/components/toast/toast.svelte +44 -21
- package/package.json +1 -1
|
@@ -1,251 +1,333 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
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
|
-
let
|
|
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
|
-
let
|
|
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
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ListItemType } from '../../../button/components/button-list-item/button-list-item.svelte';
|
|
3
|
+
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 type { Snippet } from 'svelte';
|
|
9
|
+
import InputField, { type InputFieldPropsType } from '../input-field/input-field.svelte';
|
|
10
|
+
import SearchField from '../search-field/search-field.svelte';
|
|
11
|
+
|
|
12
|
+
type PropsType = {
|
|
13
|
+
chipClassName?: string;
|
|
14
|
+
comboboxIconClassName?: string;
|
|
15
|
+
comboboxIconPath?: string;
|
|
16
|
+
createButtonClassName?: string;
|
|
17
|
+
createButtonLabel?: string;
|
|
18
|
+
displayClassName?: string;
|
|
19
|
+
displayFieldName?: string;
|
|
20
|
+
displayItemsCount?: number;
|
|
21
|
+
dropdownBodyClassName?: string;
|
|
22
|
+
dropdownBodySnippet?: Snippet;
|
|
23
|
+
dropdownClassName?: string;
|
|
24
|
+
dropdownFooterClassName?: string;
|
|
25
|
+
dropdownFooterSnippet?: Snippet;
|
|
26
|
+
dropdownHeaderClassName?: string;
|
|
27
|
+
dropdownHeaderSnippet?: Snippet;
|
|
28
|
+
emptyMessage?: string;
|
|
29
|
+
emptyMessageSnippet?: Snippet;
|
|
30
|
+
hasComboboxIcon?: boolean;
|
|
31
|
+
hasDropdownFooter?: boolean;
|
|
32
|
+
hasDropdownFooterCreateButton?: boolean;
|
|
33
|
+
hasDropdownHeader?: boolean;
|
|
34
|
+
hasDropdownHeaderSearch?: boolean;
|
|
35
|
+
hasItemsCheckbox?: boolean;
|
|
36
|
+
hasPrimitiveItemsData?: boolean;
|
|
37
|
+
iconPathClassName?: string;
|
|
38
|
+
iconPathFieldName?: string;
|
|
39
|
+
identityFieldName?: string;
|
|
40
|
+
itemClassName?: string;
|
|
41
|
+
items?: any[];
|
|
42
|
+
multiple?: boolean;
|
|
43
|
+
onCreateButtonClick?: (ev: MouseEvent) => void;
|
|
44
|
+
onSearch?: (value: string) => void;
|
|
45
|
+
searchClassName?: string;
|
|
46
|
+
searchFieldName?: string;
|
|
47
|
+
searchPlaceholder?: string;
|
|
48
|
+
showChip?: boolean;
|
|
49
|
+
itemSubtitleClassName?: string;
|
|
50
|
+
itemSubtitleFieldName?: string;
|
|
51
|
+
itemTitleClassName?: string;
|
|
52
|
+
itemTitleFieldName?: string;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
let {
|
|
56
|
+
appearance,
|
|
57
|
+
chipClassName,
|
|
58
|
+
className,
|
|
59
|
+
comboboxIconClassName,
|
|
60
|
+
comboboxIconPath = mdiUnfoldMoreHorizontal,
|
|
61
|
+
contentSnippet,
|
|
62
|
+
createButtonClassName,
|
|
63
|
+
createButtonLabel = 'Add',
|
|
64
|
+
displayClassName,
|
|
65
|
+
displayFieldName,
|
|
66
|
+
displayItemsCount,
|
|
67
|
+
dropdownBodyClassName,
|
|
68
|
+
dropdownBodySnippet,
|
|
69
|
+
dropdownClassName,
|
|
70
|
+
dropdownFooterClassName,
|
|
71
|
+
dropdownFooterSnippet,
|
|
72
|
+
dropdownHeaderClassName,
|
|
73
|
+
dropdownHeaderSnippet,
|
|
74
|
+
emptyMessage = 'No items exists!',
|
|
75
|
+
emptyMessageSnippet,
|
|
76
|
+
hasComboboxIcon = true,
|
|
77
|
+
hasDropdownFooter,
|
|
78
|
+
hasDropdownFooterCreateButton,
|
|
79
|
+
hasDropdownHeader,
|
|
80
|
+
hasDropdownHeaderSearch,
|
|
81
|
+
hasItemsCheckbox,
|
|
82
|
+
hasPrimitiveItemsData,
|
|
83
|
+
iconPathClassName,
|
|
84
|
+
iconPathFieldName,
|
|
85
|
+
id,
|
|
86
|
+
identityFieldName,
|
|
87
|
+
itemClassName,
|
|
88
|
+
items,
|
|
89
|
+
multiple,
|
|
90
|
+
name,
|
|
91
|
+
onCreateButtonClick,
|
|
92
|
+
onSearch,
|
|
93
|
+
searchClassName,
|
|
94
|
+
searchFieldName,
|
|
95
|
+
searchPlaceholder = 'Search...',
|
|
96
|
+
showChip,
|
|
97
|
+
size,
|
|
98
|
+
itemSubtitleClassName,
|
|
99
|
+
itemSubtitleFieldName,
|
|
100
|
+
itemTitleClassName,
|
|
101
|
+
itemTitleFieldName,
|
|
102
|
+
value = $bindable(),
|
|
103
|
+
...props
|
|
104
|
+
}: InputFieldPropsType & PropsType = $props();
|
|
105
|
+
type CustomListItemType = ListItemType & {
|
|
106
|
+
[key: symbol]: string | number;
|
|
107
|
+
};
|
|
108
|
+
let idFieldSymbol = Symbol('_id');
|
|
109
|
+
let searchFieldSymbol = Symbol('_search');
|
|
110
|
+
|
|
111
|
+
let searchFieldRef: SearchField | null = $state(null);
|
|
112
|
+
|
|
113
|
+
let comboboxIconSizeClassName = $state('');
|
|
114
|
+
|
|
115
|
+
let isPlaced = $state(false);
|
|
116
|
+
let searchText: string = $state('');
|
|
117
|
+
|
|
118
|
+
let itemsIdentityMap: any = {};
|
|
119
|
+
|
|
120
|
+
let _value = $derived.by(() => {
|
|
121
|
+
return selectedItemsSet?.size ? ' ' : '';
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
let displayItems: string[] = $derived.by(() => {
|
|
125
|
+
let array = Array.from(selectedItemsSet);
|
|
126
|
+
let results = array.map((id) => {
|
|
127
|
+
if (hasPrimitiveItemsData) {
|
|
128
|
+
return [id];
|
|
129
|
+
} else {
|
|
130
|
+
let item = itemsIdentityMap[id];
|
|
131
|
+
if (item) {
|
|
132
|
+
if (displayFieldName && item.hasOwnProperty(displayFieldName)) {
|
|
133
|
+
return item[displayFieldName];
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
return results;
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
let displayItemsTitle = $derived(displayItems.join(', '));
|
|
142
|
+
|
|
143
|
+
let displayText: string = $derived.by(() => {
|
|
144
|
+
let results: string[] = displayItems;
|
|
145
|
+
if (!showChip) {
|
|
146
|
+
if (results?.length) {
|
|
147
|
+
if (multiple) {
|
|
148
|
+
let res: string = results.join(', ');
|
|
149
|
+
if (displayItemsCount != null && displayItemsCount > 1) {
|
|
150
|
+
res = results.slice(0, displayItemsCount).join(', ');
|
|
151
|
+
if (results.length > displayItemsCount) {
|
|
152
|
+
res += `<span class="text-gray-400 px-2">+ ${results.length - displayItemsCount} </span>`;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return res;
|
|
156
|
+
} else {
|
|
157
|
+
return results[0] || '';
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return '';
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
let selectedItemsSet: Set<any> = $derived.by(() => {
|
|
166
|
+
let set = new Set<any>();
|
|
167
|
+
if (value != null) {
|
|
168
|
+
if (Array.isArray(value)) {
|
|
169
|
+
value.forEach((v) => set.add(v));
|
|
170
|
+
} else if (value) {
|
|
171
|
+
set.add(value);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return set;
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
let preparedItems: CustomListItemType[] = $derived.by(() => {
|
|
178
|
+
return (items || []).map((item, index) => {
|
|
179
|
+
let res: CustomListItemType = {};
|
|
180
|
+
if (hasPrimitiveItemsData) {
|
|
181
|
+
res.title = item;
|
|
182
|
+
res[idFieldSymbol] = item;
|
|
183
|
+
res[searchFieldSymbol] = ('' + item).toLowerCase().trim();
|
|
184
|
+
} else {
|
|
185
|
+
if (identityFieldName && item.hasOwnProperty(identityFieldName)) {
|
|
186
|
+
res[idFieldSymbol] = item[identityFieldName];
|
|
187
|
+
} else {
|
|
188
|
+
res[idFieldSymbol] = index;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
itemsIdentityMap[res[idFieldSymbol]] = item;
|
|
192
|
+
|
|
193
|
+
if (itemTitleFieldName && item.hasOwnProperty(itemTitleFieldName)) {
|
|
194
|
+
res.title = item[itemTitleFieldName];
|
|
195
|
+
}
|
|
196
|
+
if (itemSubtitleFieldName && item.hasOwnProperty(itemSubtitleFieldName)) {
|
|
197
|
+
res.subtitle = item[itemSubtitleFieldName];
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (searchFieldName) {
|
|
201
|
+
if (item.hasOwnProperty(searchFieldName)) {
|
|
202
|
+
res[searchFieldSymbol] = (item[searchFieldName] || '').toLowerCase().trim();
|
|
203
|
+
}
|
|
204
|
+
} else {
|
|
205
|
+
res[searchFieldSymbol] = `${item.title || ''} ${item.subtitle || ''}`;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (selectedItemsSet.has(res[idFieldSymbol])) {
|
|
209
|
+
res.isChecked = true;
|
|
210
|
+
} else {
|
|
211
|
+
res.isChecked = false;
|
|
212
|
+
}
|
|
213
|
+
return res;
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
let filteredItems: CustomListItemType[] = $derived.by(() => {
|
|
218
|
+
if (searchText) {
|
|
219
|
+
return preparedItems.filter((item: any) => {
|
|
220
|
+
return item[searchFieldSymbol].indexOf(searchText) >= 0;
|
|
221
|
+
});
|
|
222
|
+
} else {
|
|
223
|
+
return [...preparedItems];
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
$effect(() => {
|
|
228
|
+
if (size) {
|
|
229
|
+
switch (size) {
|
|
230
|
+
case 'lg':
|
|
231
|
+
comboboxIconSizeClassName = '!h-7 !w-7';
|
|
232
|
+
break;
|
|
233
|
+
case 'md':
|
|
234
|
+
comboboxIconSizeClassName = '!h-6 !w-6';
|
|
235
|
+
break;
|
|
236
|
+
case 'sm':
|
|
237
|
+
comboboxIconSizeClassName = '!h-5 !w-5';
|
|
238
|
+
break;
|
|
239
|
+
case 'xs':
|
|
240
|
+
comboboxIconSizeClassName = '!h-4 !w-4';
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
let inputFieldRef: InputField | null = $state(null);
|
|
247
|
+
|
|
248
|
+
export function focus() {
|
|
249
|
+
inputFieldRef?.focus();
|
|
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
|
+
}
|
|
249
331
|
</script>
|
|
250
332
|
|
|
251
333
|
{#snippet rightIcon()}
|
|
@@ -37,7 +37,7 @@ declare const ComboboxField: $$__sveltets_2_IsomorphicComponent<InputFieldPropsT
|
|
|
37
37
|
hasDropdownHeader?: boolean;
|
|
38
38
|
hasDropdownHeaderSearch?: boolean;
|
|
39
39
|
hasItemsCheckbox?: boolean;
|
|
40
|
-
|
|
40
|
+
hasPrimitiveItemsData?: boolean;
|
|
41
41
|
iconPathClassName?: string;
|
|
42
42
|
iconPathFieldName?: string;
|
|
43
43
|
identityFieldName?: string;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import InputField, { type InputFieldPropsType } from '../input-field/input-field.svelte';
|
|
3
|
+
|
|
4
|
+
let props: InputFieldPropsType = $props();
|
|
5
|
+
|
|
6
|
+
let inputFieldRef: InputField | null = $state(null);
|
|
7
|
+
|
|
8
|
+
export function focus() {
|
|
9
|
+
inputFieldRef?.focus();
|
|
10
|
+
}
|
|
7
11
|
</script>
|
|
8
12
|
|
|
9
13
|
<InputField bind:this={inputFieldRef} {...props} type="date" />
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import InputField, { type InputFieldPropsType } from '../input-field/input-field.svelte';
|
|
3
|
+
|
|
4
|
+
let props: InputFieldPropsType = $props();
|
|
5
|
+
|
|
6
|
+
let inputFieldRef: InputField | null = $state(null);
|
|
7
|
+
|
|
8
|
+
export function focus() {
|
|
9
|
+
inputFieldRef?.focus();
|
|
10
|
+
}
|
|
7
11
|
</script>
|
|
8
12
|
|
|
9
13
|
<InputField bind:this={inputFieldRef} {...props} type="datetime-local" />
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import InputField, { type InputFieldPropsType } from '../input-field/input-field.svelte';
|
|
3
|
+
|
|
4
|
+
let props: InputFieldPropsType = $props();
|
|
5
|
+
let inputFieldRef: InputField | null = $state(null);
|
|
6
|
+
|
|
7
|
+
export function focus() {
|
|
8
|
+
inputFieldRef?.focus();
|
|
9
|
+
}
|
|
7
10
|
</script>
|
|
8
11
|
|
|
9
12
|
<InputField bind:this={inputFieldRef} {...props} type="email" maxlength={props?.maxlength || 80} />
|