@cloudparker/moldex.js 0.0.28 → 0.0.30
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 +16 -0
- package/dist/services/dialog/dialog-service.js +23 -1
- package/dist/services/utils/utils-service.d.ts +3 -0
- package/dist/services/utils/utils-service.js +26 -0
- package/dist/tailwind.css +1 -1
- package/dist/views/core/button/components/button/button.svelte +57 -34
- package/dist/views/core/button/components/button/button.svelte.d.ts +19 -18
- package/dist/views/core/button/components/button-back/button-back.svelte +44 -0
- package/dist/views/core/button/components/button-back/button-back.svelte.d.ts +24 -0
- package/dist/views/core/button/components/button-close/button-close.svelte +7 -0
- package/dist/views/core/button/components/button-close/button-close.svelte.d.ts +19 -0
- package/dist/views/core/button/components/button-close-icon/button-close-icon.svelte +47 -0
- package/dist/views/core/button/components/button-close-icon/button-close-icon.svelte.d.ts +25 -0
- package/dist/views/core/button/components/button-list-item/button-list-item.svelte +94 -42
- package/dist/views/core/button/components/button-list-item/button-list-item.svelte.d.ts +11 -11
- package/dist/views/core/button/components/button-menu/button-menu.svelte +155 -103
- package/dist/views/core/button/components/button-menu/button-menu.svelte.d.ts +7 -7
- package/dist/views/core/button/components/button-ok/button-ok.svelte +7 -0
- package/dist/views/core/button/components/button-ok/button-ok.svelte.d.ts +19 -0
- package/dist/views/core/button/index.d.ts +5 -1
- package/dist/views/core/button/index.js +10 -1
- package/dist/views/core/dialog/components/dialog/dialog.svelte +328 -231
- package/dist/views/core/dialog/components/dialog/dialog.svelte.d.ts +6 -10
- package/dist/views/core/dialog/components/list-dialog/list-picker-dialog.svelte +189 -0
- package/dist/views/core/dialog/components/list-dialog/list-picker-dialog.svelte.d.ts +41 -0
- 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 +25 -12
- package/dist/views/core/icon/components/icon/icon.svelte.d.ts +1 -0
- package/dist/views/core/icon/services/icon-path-service.d.ts +6 -0
- package/dist/views/core/icon/services/icon-path-service.js +6 -0
- package/dist/views/core/index.d.ts +2 -0
- package/dist/views/core/index.js +2 -0
- package/dist/views/core/input/components/color-field/color-field.svelte +114 -0
- package/dist/views/core/input/components/color-field/color-field.svelte.d.ts +23 -0
- package/dist/views/core/input/components/combobox-field/combobox-field.svelte +467 -0
- package/dist/views/core/input/components/combobox-field/combobox-field.svelte.d.ts +63 -0
- package/dist/views/core/input/components/date-field/date-field.svelte +13 -0
- package/dist/views/core/input/components/date-field/date-field.svelte.d.ts +21 -0
- package/dist/views/core/input/components/datetime-field/datetime-field.svelte +13 -0
- package/dist/views/core/input/components/datetime-field/datetime-field.svelte.d.ts +21 -0
- package/dist/views/core/input/components/email-field/email-field.svelte +12 -0
- package/dist/views/core/input/components/email-field/email-field.svelte.d.ts +21 -0
- package/dist/views/core/input/components/file-field/file-field.svelte +92 -0
- package/dist/views/core/input/components/file-field/file-field.svelte.d.ts +25 -0
- package/dist/views/core/input/components/input-field/input-field.svelte +382 -0
- package/dist/views/core/{form → input}/components/input-field/input-field.svelte.d.ts +51 -35
- package/dist/views/core/input/components/label/label.svelte +46 -0
- package/dist/views/core/input/components/number-field/number-field.svelte +13 -0
- package/dist/views/core/input/components/number-field/number-field.svelte.d.ts +21 -0
- package/dist/views/core/input/components/password-field/password-field.svelte +83 -0
- package/dist/views/core/input/components/password-field/password-field.svelte.d.ts +24 -0
- package/dist/views/core/input/components/phone-field/phone-field.svelte +90 -0
- package/dist/views/core/input/components/phone-field/phone-field.svelte.d.ts +24 -0
- package/dist/views/core/input/components/range-field/range-field.svelte +72 -0
- package/dist/views/core/input/components/range-field/range-field.svelte.d.ts +31 -0
- package/dist/views/core/input/components/search-field/search-field.svelte +67 -0
- package/dist/views/core/input/components/search-field/search-field.svelte.d.ts +24 -0
- package/dist/views/core/input/components/text-field/text-field.svelte +12 -0
- package/dist/views/core/input/components/text-field/text-field.svelte.d.ts +21 -0
- package/dist/views/core/input/components/textarea-field/textarea-field.svelte +12 -0
- package/dist/views/core/input/components/textarea-field/textarea-field.svelte.d.ts +21 -0
- package/dist/views/core/input/components/time-field/time-field.svelte +12 -0
- package/dist/views/core/input/components/time-field/time-field.svelte.d.ts +21 -0
- package/dist/views/core/input/index.d.ts +19 -0
- package/dist/views/core/input/index.js +19 -0
- package/dist/views/core/navbar/components/navbar/navbar.svelte +71 -39
- package/dist/views/core/navbar/components/navbar/navbar.svelte.d.ts +3 -3
- package/dist/views/core/no-data/components/no-data/no-data.svelte +51 -0
- package/dist/views/core/no-data/components/no-data/no-data.svelte.d.ts +27 -0
- package/dist/views/core/no-data/index.d.ts +2 -0
- package/dist/views/core/no-data/index.js +2 -0
- 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 +42 -29
- package/dist/views/core/text/components/text-country-state/text-country-state.svelte +38 -30
- 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 +2 -2
- package/dist/views/core/form/components/input-field/input-field.svelte +0 -233
- package/dist/views/core/form/components/label/label.svelte +0 -32
- package/dist/views/core/form/index.d.ts +0 -3
- package/dist/views/core/form/index.js +0 -3
- /package/dist/views/core/{form → input}/components/label/label.svelte.d.ts +0 -0
|
@@ -0,0 +1,467 @@
|
|
|
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
|
+
hasPrimitiveData?: 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
|
+
hasPrimitiveData,
|
|
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 (hasPrimitiveData) {
|
|
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 (hasPrimitiveData) {
|
|
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
|
+
}
|
|
331
|
+
</script>
|
|
332
|
+
|
|
333
|
+
{#snippet rightIcon()}
|
|
334
|
+
<div class="px-1">
|
|
335
|
+
{#if hasComboboxIcon}
|
|
336
|
+
<Icon
|
|
337
|
+
path={comboboxIconPath}
|
|
338
|
+
className=" text-gray-500 {comboboxIconSizeClassName} {comboboxIconClassName}"
|
|
339
|
+
/>
|
|
340
|
+
{/if}
|
|
341
|
+
</div>
|
|
342
|
+
{/snippet}
|
|
343
|
+
|
|
344
|
+
{#snippet comboboxContentSnippet()}
|
|
345
|
+
{#if contentSnippet}
|
|
346
|
+
{@render contentSnippet()}
|
|
347
|
+
{:else if showChip}
|
|
348
|
+
<div class="flex items-center {displayClassName}" title={displayItemsTitle}>
|
|
349
|
+
{#each displayItems?.slice(0, displayItemsCount) as item, index}
|
|
350
|
+
<div
|
|
351
|
+
class="inline-flex items-center bg-gray-200 text-gray-700 text-sm font-medium px-2 mx-1 rounded-full text-nowrap {chipClassName}"
|
|
352
|
+
>
|
|
353
|
+
{item}
|
|
354
|
+
</div>
|
|
355
|
+
{/each}
|
|
356
|
+
{#if displayItemsCount && displayItems?.length > (displayItemsCount || 1)}
|
|
357
|
+
<div class="px-2 text-gray-400">+ {displayItems?.length - (displayItemsCount || 1)}</div>
|
|
358
|
+
{/if}
|
|
359
|
+
</div>
|
|
360
|
+
{:else}
|
|
361
|
+
<div class="flex items-center {displayClassName}" title={displayItemsTitle}>
|
|
362
|
+
{@html displayText}
|
|
363
|
+
</div>
|
|
364
|
+
{/if}
|
|
365
|
+
{/snippet}
|
|
366
|
+
|
|
367
|
+
<div class="relative">
|
|
368
|
+
<InputField
|
|
369
|
+
bind:this={inputFieldRef}
|
|
370
|
+
{...props}
|
|
371
|
+
value={_value}
|
|
372
|
+
type="text"
|
|
373
|
+
role="combobox"
|
|
374
|
+
onclick={handleInputClick}
|
|
375
|
+
className="pr-8 text-transparent {className}"
|
|
376
|
+
rightSnippet={rightIcon}
|
|
377
|
+
rightSnippetContainerClassName="pointer-events-none"
|
|
378
|
+
readonly
|
|
379
|
+
{id}
|
|
380
|
+
{name}
|
|
381
|
+
{size}
|
|
382
|
+
{appearance}
|
|
383
|
+
ariaControls="options"
|
|
384
|
+
ariaExpanded={isPlaced}
|
|
385
|
+
onkeydown={handleKeyDown}
|
|
386
|
+
contentSnippet={comboboxContentSnippet}
|
|
387
|
+
title={displayItemsTitle || ''}
|
|
388
|
+
/>
|
|
389
|
+
{#if isPlaced}
|
|
390
|
+
<button id="backdrop" class="fixed inset-0 z-10" onclick={handleBackdropClick} tabindex="-1"
|
|
391
|
+
></button>
|
|
392
|
+
<!-- svelte-ignore a11y_interactive_supports_focus -->
|
|
393
|
+
<div
|
|
394
|
+
class="absolute z-10 mt-1 max-h-80 w-full flex flex-col rounded-md bg-white text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm {hasDropdownHeader
|
|
395
|
+
? ''
|
|
396
|
+
: 'pt-1'} {hasDropdownFooter ? '' : 'pb-1'} {dropdownClassName}"
|
|
397
|
+
id="options"
|
|
398
|
+
role="listbox"
|
|
399
|
+
onkeydown={handleDropdownKeyDown}
|
|
400
|
+
>
|
|
401
|
+
{#if hasDropdownHeader}
|
|
402
|
+
<div
|
|
403
|
+
id="dropdown-header"
|
|
404
|
+
class=" flex items-center p-2 px-3 my-1 w-full {dropdownHeaderClassName}"
|
|
405
|
+
>
|
|
406
|
+
{#if dropdownHeaderSnippet}
|
|
407
|
+
{@render dropdownHeaderSnippet()}
|
|
408
|
+
{:else if hasDropdownHeaderSearch}
|
|
409
|
+
<SearchField
|
|
410
|
+
bind:this={searchFieldRef}
|
|
411
|
+
value={searchText}
|
|
412
|
+
name="search"
|
|
413
|
+
placeholder={searchPlaceholder}
|
|
414
|
+
className="w-full {searchClassName}"
|
|
415
|
+
onSearch={handleSearch}
|
|
416
|
+
/>
|
|
417
|
+
{/if}
|
|
418
|
+
</div>
|
|
419
|
+
{/if}
|
|
420
|
+
<div id="dropdown-body" class="flex-grow overflow-y-auto max-h-full {dropdownBodyClassName}">
|
|
421
|
+
{#if dropdownBodySnippet}
|
|
422
|
+
{@render dropdownBodySnippet()}
|
|
423
|
+
{:else if filteredItems?.length}
|
|
424
|
+
<ul>
|
|
425
|
+
{#each filteredItems as item, index}
|
|
426
|
+
<li
|
|
427
|
+
class="select-none"
|
|
428
|
+
id="item-{index}"
|
|
429
|
+
role="option"
|
|
430
|
+
tabindex="-1"
|
|
431
|
+
aria-selected={item.isChecked}
|
|
432
|
+
>
|
|
433
|
+
<ButtonListItem
|
|
434
|
+
{item}
|
|
435
|
+
{index}
|
|
436
|
+
hasCheckbox={hasItemsCheckbox}
|
|
437
|
+
className=" {itemClassName}"
|
|
438
|
+
titleClassName=" {itemTitleClassName}"
|
|
439
|
+
subtitleClassName=" {itemSubtitleClassName}"
|
|
440
|
+
onClick={(ev) => handleItemSelected(ev, item, index)}
|
|
441
|
+
/>
|
|
442
|
+
</li>
|
|
443
|
+
{/each}
|
|
444
|
+
</ul>
|
|
445
|
+
{:else if emptyMessageSnippet}
|
|
446
|
+
{@render emptyMessageSnippet()}
|
|
447
|
+
{:else}
|
|
448
|
+
<NoData message={emptyMessage} />
|
|
449
|
+
{/if}
|
|
450
|
+
</div>
|
|
451
|
+
|
|
452
|
+
{#if hasDropdownFooter}
|
|
453
|
+
<div id="dropdown-footer" class="flex justify-end gap-3 p-2 px-3 {dropdownFooterClassName}">
|
|
454
|
+
{#if dropdownFooterSnippet}
|
|
455
|
+
{@render dropdownFooterSnippet()}
|
|
456
|
+
{:else if hasDropdownFooterCreateButton}
|
|
457
|
+
<Button
|
|
458
|
+
label={createButtonLabel}
|
|
459
|
+
className="px-3 py-1 {createButtonClassName}"
|
|
460
|
+
onClick={onCreateButtonClick}
|
|
461
|
+
></Button>
|
|
462
|
+
{/if}
|
|
463
|
+
</div>
|
|
464
|
+
{/if}
|
|
465
|
+
</div>
|
|
466
|
+
{/if}
|
|
467
|
+
</div>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
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 & {
|
|
17
|
+
chipClassName?: string;
|
|
18
|
+
comboboxIconClassName?: string;
|
|
19
|
+
comboboxIconPath?: string;
|
|
20
|
+
createButtonClassName?: string;
|
|
21
|
+
createButtonLabel?: string;
|
|
22
|
+
displayClassName?: string;
|
|
23
|
+
displayFieldName?: string;
|
|
24
|
+
displayItemsCount?: number;
|
|
25
|
+
dropdownBodyClassName?: string;
|
|
26
|
+
dropdownBodySnippet?: Snippet;
|
|
27
|
+
dropdownClassName?: string;
|
|
28
|
+
dropdownFooterClassName?: string;
|
|
29
|
+
dropdownFooterSnippet?: Snippet;
|
|
30
|
+
dropdownHeaderClassName?: string;
|
|
31
|
+
dropdownHeaderSnippet?: Snippet;
|
|
32
|
+
emptyMessage?: string;
|
|
33
|
+
emptyMessageSnippet?: Snippet;
|
|
34
|
+
hasComboboxIcon?: boolean;
|
|
35
|
+
hasDropdownFooter?: boolean;
|
|
36
|
+
hasDropdownFooterCreateButton?: boolean;
|
|
37
|
+
hasDropdownHeader?: boolean;
|
|
38
|
+
hasDropdownHeaderSearch?: boolean;
|
|
39
|
+
hasItemsCheckbox?: boolean;
|
|
40
|
+
hasPrimitiveData?: boolean;
|
|
41
|
+
iconPathClassName?: string;
|
|
42
|
+
iconPathFieldName?: string;
|
|
43
|
+
identityFieldName?: string;
|
|
44
|
+
itemClassName?: string;
|
|
45
|
+
items?: any[];
|
|
46
|
+
multiple?: boolean;
|
|
47
|
+
onCreateButtonClick?: (ev: MouseEvent) => void;
|
|
48
|
+
onSearch?: (value: string) => void;
|
|
49
|
+
searchClassName?: string;
|
|
50
|
+
searchFieldName?: string;
|
|
51
|
+
searchPlaceholder?: string;
|
|
52
|
+
showChip?: boolean;
|
|
53
|
+
itemSubtitleClassName?: string;
|
|
54
|
+
itemSubtitleFieldName?: string;
|
|
55
|
+
itemTitleClassName?: string;
|
|
56
|
+
itemTitleFieldName?: string;
|
|
57
|
+
}, {
|
|
58
|
+
[evt: string]: CustomEvent<any>;
|
|
59
|
+
}, {}, {
|
|
60
|
+
focus: () => void;
|
|
61
|
+
}, "value">;
|
|
62
|
+
type ComboboxField = InstanceType<typeof ComboboxField>;
|
|
63
|
+
export default ComboboxField;
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
}
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<InputField bind:this={inputFieldRef} {...props} type="date" />
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type InputFieldPropsType } from '../input-field/input-field.svelte';
|
|
2
|
+
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> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const DateField: $$__sveltets_2_IsomorphicComponent<InputFieldPropsType, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {
|
|
18
|
+
focus: () => void;
|
|
19
|
+
}, "">;
|
|
20
|
+
type DateField = InstanceType<typeof DateField>;
|
|
21
|
+
export default DateField;
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
}
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<InputField bind:this={inputFieldRef} {...props} type="datetime-local" />
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type InputFieldPropsType } from '../input-field/input-field.svelte';
|
|
2
|
+
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> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const DatetimeField: $$__sveltets_2_IsomorphicComponent<InputFieldPropsType, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {
|
|
18
|
+
focus: () => void;
|
|
19
|
+
}, "">;
|
|
20
|
+
type DatetimeField = InstanceType<typeof DatetimeField>;
|
|
21
|
+
export default DatetimeField;
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
}
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<InputField bind:this={inputFieldRef} {...props} type="email" maxlength={props?.maxlength || 80} />
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type InputFieldPropsType } from '../input-field/input-field.svelte';
|
|
2
|
+
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> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const EmailField: $$__sveltets_2_IsomorphicComponent<InputFieldPropsType, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {
|
|
18
|
+
focus: () => void;
|
|
19
|
+
}, "">;
|
|
20
|
+
type EmailField = InstanceType<typeof EmailField>;
|
|
21
|
+
export default EmailField;
|