simplesvelte 2.2.19 → 2.2.21
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/Modal.svelte +1 -1
- package/dist/Select.svelte +67 -19
- package/package.json +1 -1
package/dist/Modal.svelte
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
})
|
|
22
22
|
</script>
|
|
23
23
|
|
|
24
|
-
<dialog bind:this={dialogEl} onclose={() => (open = false)} class="modal modal-middle overflow-auto">
|
|
24
|
+
<dialog bind:this={dialogEl} onclose={() => (open = false)} {open} class="modal modal-middle overflow-auto">
|
|
25
25
|
<div class="modal-box pt-12 md:min-w-[32rem]">
|
|
26
26
|
<form method="dialog">
|
|
27
27
|
<button
|
package/dist/Select.svelte
CHANGED
|
@@ -135,6 +135,7 @@
|
|
|
135
135
|
const result: FlatListItem[] = []
|
|
136
136
|
const groups: Record<string, Option[]> = {}
|
|
137
137
|
const ungrouped: Option[] = []
|
|
138
|
+
|
|
138
139
|
for (const item of filteredItems) {
|
|
139
140
|
if (item.group) {
|
|
140
141
|
if (!groups[item.group]) groups[item.group] = []
|
|
@@ -143,17 +144,56 @@
|
|
|
143
144
|
ungrouped.push(item)
|
|
144
145
|
}
|
|
145
146
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
147
|
+
|
|
148
|
+
// In multiple mode, separate selected and unselected items
|
|
149
|
+
if (multiple && Array.isArray(normalizedValue) && normalizedValue.length > 0) {
|
|
150
|
+
const selectedUngrouped: Option[] = []
|
|
151
|
+
const unselectedUngrouped: Option[] = []
|
|
152
|
+
|
|
153
|
+
for (const item of ungrouped) {
|
|
154
|
+
if (normalizedValue.includes(item.value)) {
|
|
155
|
+
selectedUngrouped.push(item)
|
|
156
|
+
} else {
|
|
157
|
+
unselectedUngrouped.push(item)
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Add selected ungrouped items first
|
|
162
|
+
for (const item of selectedUngrouped) {
|
|
163
|
+
result.push({ type: 'option', item })
|
|
164
|
+
}
|
|
165
|
+
// Then unselected ungrouped items
|
|
166
|
+
for (const item of unselectedUngrouped) {
|
|
167
|
+
result.push({ type: 'option', item })
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Add grouped items with headers, also with selected first within each group
|
|
171
|
+
for (const groupName of Object.keys(groups)) {
|
|
172
|
+
const groupItems = groups[groupName]
|
|
173
|
+
const selectedGroupItems = groupItems.filter((item) => normalizedValue.includes(item.value))
|
|
174
|
+
const unselectedGroupItems = groupItems.filter((item) => !normalizedValue.includes(item.value))
|
|
175
|
+
|
|
176
|
+
result.push({ type: 'header', group: groupName })
|
|
177
|
+
for (const item of selectedGroupItems) {
|
|
178
|
+
result.push({ type: 'option', item })
|
|
179
|
+
}
|
|
180
|
+
for (const item of unselectedGroupItems) {
|
|
181
|
+
result.push({ type: 'option', item })
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
} else {
|
|
185
|
+
// Normal ordering when not in multiple mode or no selections
|
|
186
|
+
for (const item of ungrouped) {
|
|
154
187
|
result.push({ type: 'option', item })
|
|
155
188
|
}
|
|
189
|
+
for (const groupName of Object.keys(groups)) {
|
|
190
|
+
result.push({ type: 'header', group: groupName })
|
|
191
|
+
for (const item of groups[groupName]) {
|
|
192
|
+
result.push({ type: 'option', item })
|
|
193
|
+
}
|
|
194
|
+
}
|
|
156
195
|
}
|
|
196
|
+
|
|
157
197
|
return result
|
|
158
198
|
})
|
|
159
199
|
|
|
@@ -259,32 +299,40 @@
|
|
|
259
299
|
detailsOpen = false
|
|
260
300
|
}}>
|
|
261
301
|
<summary
|
|
262
|
-
class="select h-max min-h-10 w-full min-w-12 cursor-pointer
|
|
302
|
+
class="select h-max min-h-10 w-full min-w-12 cursor-pointer bg-none! pr-1"
|
|
263
303
|
onclick={() => {
|
|
264
304
|
searchEL?.focus()
|
|
265
305
|
filterInput = ''
|
|
266
306
|
}}>
|
|
267
307
|
{#if multiple}
|
|
268
|
-
<!-- Multi-select display with chips -->
|
|
308
|
+
<!-- Multi-select display with condensed chips -->
|
|
269
309
|
<div class="flex min-h-8 flex-wrap gap-1 p-1">
|
|
270
|
-
{#
|
|
271
|
-
|
|
272
|
-
|
|
310
|
+
{#if selectedItems.length > 0}
|
|
311
|
+
<!-- Show first selected item -->
|
|
312
|
+
<div class="badge badge-neutral bg-base-200 text-base-content gap-1">
|
|
313
|
+
<span class="max-w-[200px] truncate">{selectedItems[0].label}</span>
|
|
273
314
|
<button
|
|
274
315
|
type="button"
|
|
275
|
-
class="btn btn-xs btn-circle btn-ghost"
|
|
316
|
+
class="btn btn-xs btn-circle btn-ghost hover:bg-base-300"
|
|
276
317
|
onclick={(e) => {
|
|
277
318
|
e.stopPropagation()
|
|
278
|
-
removeSelectedItem(
|
|
319
|
+
removeSelectedItem(selectedItems[0].value)
|
|
279
320
|
}}>
|
|
280
321
|
✕
|
|
281
322
|
</button>
|
|
282
323
|
</div>
|
|
283
|
-
|
|
324
|
+
|
|
325
|
+
{#if selectedItems.length > 1}
|
|
326
|
+
<!-- Show count indicator for remaining items -->
|
|
327
|
+
<div class="badge badge-ghost text-base-content/70">
|
|
328
|
+
(+{selectedItems.length - 1} more)
|
|
329
|
+
</div>
|
|
330
|
+
{/if}
|
|
331
|
+
{/if}
|
|
284
332
|
<!-- Search input for filtering in multi-select -->
|
|
285
333
|
<input
|
|
286
334
|
type="text"
|
|
287
|
-
class="h-full outline-0 {detailsOpen ? 'cursor-text' : 'cursor-pointer'}"
|
|
335
|
+
class="h-full min-w-[120px] flex-1 outline-0 {detailsOpen ? 'cursor-text' : 'cursor-pointer'}"
|
|
288
336
|
bind:this={searchEL}
|
|
289
337
|
bind:value={filterInput}
|
|
290
338
|
onclick={() => {
|
|
@@ -373,7 +421,7 @@
|
|
|
373
421
|
<li style="height: {itemHeight}px;">
|
|
374
422
|
<button
|
|
375
423
|
class="flex h-full w-full items-center gap-2 {isSelected
|
|
376
|
-
? ' bg-primary text-primary-content hover
|
|
424
|
+
? ' bg-primary text-primary-content hover:bg-primary/70!'
|
|
377
425
|
: ''}"
|
|
378
426
|
type="button"
|
|
379
427
|
onclick={() => {
|
|
@@ -383,7 +431,7 @@
|
|
|
383
431
|
{#if multiple}
|
|
384
432
|
<input
|
|
385
433
|
type="checkbox"
|
|
386
|
-
class="checkbox checkbox-sm
|
|
434
|
+
class="checkbox checkbox-sm text-primary-content! pointer-events-none"
|
|
387
435
|
checked={isSelected}
|
|
388
436
|
readonly />
|
|
389
437
|
{/if}
|