@r2digisolutions/components 0.21.15 → 0.21.17
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/atoms/SelectionBox/SelectionBox.svelte +3 -5
- package/dist/components/molecules/MultiSelect/MultiSelect.svelte +8 -10
- package/dist/components/molecules/Select/Select.svelte +41 -36
- package/dist/components/molecules/SelectCard/SelectCard.svelte +12 -5
- package/dist/components/molecules/TagInput/TagInput.svelte +7 -4
- package/package.json +1 -1
|
@@ -72,14 +72,14 @@
|
|
|
72
72
|
success:
|
|
73
73
|
'checked:bg-green-500 checked:border-green-500 indeterminate:bg-green-500 indeterminate:border-green-500 hover:border-green-400 focus-visible:ring-green-500',
|
|
74
74
|
neutral:
|
|
75
|
-
'checked:bg-neutral-800 checked:border-neutral-800 indeterminate:bg-neutral-800 indeterminate:border-neutral-800 hover:border-neutral-500 focus-visible:ring-neutral-500 dark:checked:bg-neutral-
|
|
75
|
+
'checked:bg-neutral-800 checked:border-neutral-800 indeterminate:bg-neutral-800 indeterminate:border-neutral-800 hover:border-neutral-500 focus-visible:ring-neutral-500 dark:checked:bg-neutral-600 dark:checked:border-neutral-500 dark:indeterminate:bg-neutral-600 dark:indeterminate:border-neutral-500 dark:hover:border-neutral-400 dark:focus-visible:ring-neutral-400'
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
const toneIconColors: Record<SelectionBoxTone, string> = {
|
|
79
79
|
brand: 'text-white',
|
|
80
80
|
success: 'text-white',
|
|
81
81
|
primary: 'text-white dark:text-neutral-900',
|
|
82
|
-
neutral: 'text-white
|
|
82
|
+
neutral: 'text-white'
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
function handleChange(e: Event) {
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
{@attach setIndeterminate}
|
|
114
114
|
class={[
|
|
115
115
|
'absolute inset-0 cursor-pointer border-2 border-border bg-surface-elevated appearance-none transition-all duration-150',
|
|
116
|
-
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2',
|
|
116
|
+
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-surface',
|
|
117
117
|
'disabled:cursor-not-allowed disabled:opacity-50',
|
|
118
118
|
radiusClasses[radius],
|
|
119
119
|
toneChecked[tone]
|
|
@@ -139,7 +139,5 @@
|
|
|
139
139
|
</span>
|
|
140
140
|
{#if label && showLabel}
|
|
141
141
|
<span class={['font-medium text-primary', labelSizeClasses[size]]}>{label}</span>
|
|
142
|
-
{:else if label}
|
|
143
|
-
<span class="sr-only">{label}</span>
|
|
144
142
|
{/if}
|
|
145
143
|
</label>
|
|
@@ -345,7 +345,7 @@
|
|
|
345
345
|
/>
|
|
346
346
|
</div>
|
|
347
347
|
{/if}
|
|
348
|
-
<div class="min-h-0
|
|
348
|
+
<div class="min-h-0 overflow-y-auto overscroll-contain p-1.5">
|
|
349
349
|
{#if filtered.length === 0}
|
|
350
350
|
<div class="px-3 py-2.5 text-center text-xs text-muted">{emptyText}</div>
|
|
351
351
|
{:else}
|
|
@@ -367,25 +367,23 @@
|
|
|
367
367
|
(option.disabled || blocked) && 'cursor-not-allowed opacity-40',
|
|
368
368
|
!option.disabled &&
|
|
369
369
|
!blocked &&
|
|
370
|
-
(highlighted === index
|
|
371
|
-
? 'bg-
|
|
372
|
-
:
|
|
370
|
+
(highlighted === index
|
|
371
|
+
? 'bg-surface-overlay text-primary'
|
|
372
|
+
: isSelected
|
|
373
|
+
? 'bg-brand-500/10 font-medium text-primary'
|
|
374
|
+
: 'text-primary hover:bg-surface-overlay')
|
|
373
375
|
]}
|
|
374
376
|
>
|
|
375
377
|
<span
|
|
376
378
|
class={[
|
|
377
379
|
'flex h-4 w-4 shrink-0 items-center justify-center rounded border transition-colors',
|
|
378
|
-
isSelected
|
|
379
|
-
? 'border-white bg-white dark:border-neutral-900 dark:bg-neutral-900'
|
|
380
|
-
: highlighted === index
|
|
381
|
-
? 'border-white/60 dark:border-neutral-900/50'
|
|
382
|
-
: 'border-border-strong'
|
|
380
|
+
isSelected ? 'border-brand-500 bg-brand-500' : 'border-border-strong'
|
|
383
381
|
]}
|
|
384
382
|
aria-hidden="true"
|
|
385
383
|
>
|
|
386
384
|
{#if isSelected}
|
|
387
385
|
<svg
|
|
388
|
-
class="h-2.5 w-2.5 text-
|
|
386
|
+
class="h-2.5 w-2.5 text-white"
|
|
389
387
|
viewBox="0 0 24 24"
|
|
390
388
|
fill="none"
|
|
391
389
|
stroke="currentColor"
|
|
@@ -61,6 +61,8 @@
|
|
|
61
61
|
let searchInputEl = $state<HTMLInputElement | null>(null);
|
|
62
62
|
let optionsContainerEl = $state<HTMLDivElement | null>(null);
|
|
63
63
|
let listboxStyle = $state('');
|
|
64
|
+
let listOverflow = $state(false);
|
|
65
|
+
let listHeightCeiling = $state(240);
|
|
64
66
|
/** After keyboard nav, ignore hover until the mouse actually moves */
|
|
65
67
|
let ignoreHover = $state(false);
|
|
66
68
|
|
|
@@ -188,6 +190,18 @@
|
|
|
188
190
|
}
|
|
189
191
|
}
|
|
190
192
|
|
|
193
|
+
function syncListOverflow(ceiling: number) {
|
|
194
|
+
if (!listboxEl) {
|
|
195
|
+
listOverflow = false;
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const fits = listboxEl.scrollHeight <= ceiling;
|
|
199
|
+
listOverflow = !fits;
|
|
200
|
+
if (fits) {
|
|
201
|
+
listboxStyle = listboxStyle.replace(/max-height:[^;]+/, 'max-height:none');
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
191
205
|
function positionListbox() {
|
|
192
206
|
if (!triggerEl) return;
|
|
193
207
|
|
|
@@ -205,6 +219,8 @@
|
|
|
205
219
|
const spaceAbove = rect.top - viewTop - gap - margin;
|
|
206
220
|
const openUp = spaceBelow < Math.min(maxHeight, 160) && spaceAbove > spaceBelow;
|
|
207
221
|
const available = Math.max(120, openUp ? spaceAbove : spaceBelow);
|
|
222
|
+
const ceiling = Math.min(maxHeight, available);
|
|
223
|
+
listHeightCeiling = ceiling;
|
|
208
224
|
const maxWidth = Math.min(320, viewW - margin * 2);
|
|
209
225
|
let measured = rect.width;
|
|
210
226
|
if (listboxEl?.matches(':popover-open')) {
|
|
@@ -225,11 +241,13 @@
|
|
|
225
241
|
`bottom:${openUp ? `${viewTop + viewH - rect.top + gap}px` : 'auto'}`,
|
|
226
242
|
`left:${left}px`,
|
|
227
243
|
'right:auto',
|
|
228
|
-
`
|
|
229
|
-
|
|
244
|
+
`width:${width}px`,
|
|
245
|
+
`min-width:${Math.min(rect.width, maxWidth)}px`,
|
|
230
246
|
`max-width:${maxWidth}px`,
|
|
231
|
-
`max-height:${
|
|
247
|
+
`max-height:${ceiling}px`
|
|
232
248
|
].join('; ');
|
|
249
|
+
|
|
250
|
+
syncListOverflow(ceiling);
|
|
233
251
|
}
|
|
234
252
|
|
|
235
253
|
function openListbox() {
|
|
@@ -263,6 +281,7 @@
|
|
|
263
281
|
ignoreHover = true;
|
|
264
282
|
requestAnimationFrame(() => {
|
|
265
283
|
positionListbox();
|
|
284
|
+
syncListOverflow(listHeightCeiling);
|
|
266
285
|
if (searchable) searchInputEl?.focus();
|
|
267
286
|
else listboxEl?.focus();
|
|
268
287
|
scrollHighlightedIntoView();
|
|
@@ -566,7 +585,7 @@
|
|
|
566
585
|
aria-activedescendant={isOpen ? activeOptionId : undefined}
|
|
567
586
|
style={listboxStyle}
|
|
568
587
|
class={[
|
|
569
|
-
'select-listbox m-0 p-0 inset-auto overflow-hidden',
|
|
588
|
+
'select-listbox m-0 p-0 inset-auto overflow-x-hidden overflow-y-hidden',
|
|
570
589
|
'bg-surface-elevated border-border rounded-xl shadow-xl border',
|
|
571
590
|
'flex flex-col outline-none'
|
|
572
591
|
]}
|
|
@@ -610,7 +629,13 @@
|
|
|
610
629
|
<div class="border-border mx-1.5 mb-0.5 h-px border-b" role="separator"></div>
|
|
611
630
|
{/if}
|
|
612
631
|
|
|
613
|
-
<div
|
|
632
|
+
<div
|
|
633
|
+
bind:this={optionsContainerEl}
|
|
634
|
+
class={[
|
|
635
|
+
'p-1.5 min-h-0 overflow-x-hidden overscroll-contain',
|
|
636
|
+
listOverflow ? 'overflow-y-auto' : 'overflow-y-hidden'
|
|
637
|
+
]}
|
|
638
|
+
>
|
|
614
639
|
{#if visibleOptions.length === 0}
|
|
615
640
|
<div class="px-3 py-2.5 text-xs text-muted text-center">No options found</div>
|
|
616
641
|
{:else}
|
|
@@ -642,9 +667,9 @@
|
|
|
642
667
|
'transition-[background-color,color,box-shadow] duration-75',
|
|
643
668
|
option.disabled ? 'cursor-not-allowed opacity-40' : 'cursor-pointer',
|
|
644
669
|
isHighlighted && !option.disabled
|
|
645
|
-
? 'bg-
|
|
670
|
+
? 'bg-surface-overlay text-primary shadow-sm'
|
|
646
671
|
: isSelected && !option.disabled
|
|
647
|
-
? 'bg-
|
|
672
|
+
? 'bg-brand-500/10 font-medium text-primary'
|
|
648
673
|
: 'text-primary hover:bg-surface-overlay'
|
|
649
674
|
]}
|
|
650
675
|
>
|
|
@@ -652,24 +677,15 @@
|
|
|
652
677
|
<span
|
|
653
678
|
class={[
|
|
654
679
|
'h-4 w-4 flex shrink-0 items-center justify-center rounded-full border transition-colors duration-75',
|
|
655
|
-
|
|
656
|
-
?
|
|
657
|
-
|
|
658
|
-
: 'border-white/60 bg-transparent dark:border-neutral-900/50'
|
|
659
|
-
: isSelected && !option.disabled
|
|
660
|
-
? 'border-neutral-800 bg-neutral-800 dark:border-neutral-200 dark:bg-neutral-200'
|
|
661
|
-
: 'border-border-strong bg-transparent'
|
|
680
|
+
isSelected && !option.disabled
|
|
681
|
+
? 'border-brand-500 bg-brand-500'
|
|
682
|
+
: 'border-border-strong bg-transparent'
|
|
662
683
|
]}
|
|
663
684
|
aria-hidden="true"
|
|
664
685
|
>
|
|
665
686
|
{#if isSelected}
|
|
666
687
|
<svg
|
|
667
|
-
class=
|
|
668
|
-
'h-2.5 w-2.5',
|
|
669
|
-
isHighlighted
|
|
670
|
-
? 'text-neutral-800 dark:text-neutral-100'
|
|
671
|
-
: 'text-white dark:text-neutral-900'
|
|
672
|
-
]}
|
|
688
|
+
class="h-2.5 w-2.5 text-white"
|
|
673
689
|
viewBox="0 0 24 24"
|
|
674
690
|
fill="none"
|
|
675
691
|
stroke="currentColor"
|
|
@@ -682,16 +698,9 @@
|
|
|
682
698
|
{/if}
|
|
683
699
|
|
|
684
700
|
<span class="min-w-0 flex-1">
|
|
685
|
-
<span class="block
|
|
701
|
+
<span class="block break-words">{option.label}</span>
|
|
686
702
|
{#if secondary}
|
|
687
|
-
<span
|
|
688
|
-
class={[
|
|
689
|
-
'mt-0.5 block text-[11px] whitespace-nowrap',
|
|
690
|
-
isHighlighted && !option.disabled
|
|
691
|
-
? 'text-white/75'
|
|
692
|
-
: 'text-secondary'
|
|
693
|
-
]}
|
|
694
|
-
>
|
|
703
|
+
<span class="mt-0.5 block text-[11px] break-words text-secondary">
|
|
695
704
|
{secondary}
|
|
696
705
|
</span>
|
|
697
706
|
{/if}
|
|
@@ -699,12 +708,7 @@
|
|
|
699
708
|
|
|
700
709
|
{#if hasChildren}
|
|
701
710
|
<svg
|
|
702
|
-
class=
|
|
703
|
-
'h-4 w-4 shrink-0',
|
|
704
|
-
isHighlighted && !option.disabled
|
|
705
|
-
? 'text-white/80'
|
|
706
|
-
: 'text-secondary'
|
|
707
|
-
]}
|
|
711
|
+
class="h-4 w-4 shrink-0 text-secondary"
|
|
708
712
|
viewBox="0 0 24 24"
|
|
709
713
|
fill="none"
|
|
710
714
|
stroke="currentColor"
|
|
@@ -740,7 +744,8 @@
|
|
|
740
744
|
|
|
741
745
|
.select-listbox:popover-open {
|
|
742
746
|
display: flex;
|
|
743
|
-
overflow: hidden;
|
|
747
|
+
overflow-x: hidden;
|
|
748
|
+
overflow-y: hidden;
|
|
744
749
|
}
|
|
745
750
|
|
|
746
751
|
.select-listbox:not(:popover-open) {
|
|
@@ -205,7 +205,7 @@
|
|
|
205
205
|
{:else}
|
|
206
206
|
{#if check === 'box'}
|
|
207
207
|
<!-- svelte-ignore a11y_click_events_have_key_events a11y_no_static_element_interactions -->
|
|
208
|
-
<div class="shrink-0" onclick={(e) => e.stopPropagation()}>
|
|
208
|
+
<div class="flex shrink-0 items-center" onclick={(e) => e.stopPropagation()}>
|
|
209
209
|
<SelectionBox
|
|
210
210
|
checked={selected}
|
|
211
211
|
size="md"
|
|
@@ -228,7 +228,7 @@
|
|
|
228
228
|
{/if}
|
|
229
229
|
|
|
230
230
|
{#if image || leading}
|
|
231
|
-
<div class="shrink-0">
|
|
231
|
+
<div class="flex shrink-0 items-center">
|
|
232
232
|
{#if image}
|
|
233
233
|
<img src={image} alt={imageAlt} class="h-11 w-11 rounded-lg object-cover" />
|
|
234
234
|
{:else if leading}
|
|
@@ -237,15 +237,22 @@
|
|
|
237
237
|
</div>
|
|
238
238
|
{/if}
|
|
239
239
|
|
|
240
|
-
<div class="min-w-0 flex-1">
|
|
240
|
+
<div class="flex min-w-0 flex-1 flex-col justify-center">
|
|
241
241
|
{#if children}
|
|
242
242
|
{@render children()}
|
|
243
243
|
{:else}
|
|
244
244
|
{#if title}
|
|
245
|
-
<p
|
|
245
|
+
<p
|
|
246
|
+
class={[
|
|
247
|
+
'truncate text-sm font-medium text-primary',
|
|
248
|
+
!description && 'leading-none'
|
|
249
|
+
]}
|
|
250
|
+
>
|
|
251
|
+
{title}
|
|
252
|
+
</p>
|
|
246
253
|
{/if}
|
|
247
254
|
{#if description}
|
|
248
|
-
<p class="mt-0.5 truncate text-xs text-muted">{description}</p>
|
|
255
|
+
<p class="mt-0.5 truncate text-xs leading-snug text-muted">{description}</p>
|
|
249
256
|
{/if}
|
|
250
257
|
{/if}
|
|
251
258
|
</div>
|
|
@@ -25,14 +25,16 @@
|
|
|
25
25
|
|
|
26
26
|
function addMany(raw: string) {
|
|
27
27
|
if (disabled) return;
|
|
28
|
+
// Comma / semicolon / newline — keep spaces so multi-word tags work (e.g. keywords).
|
|
28
29
|
const parts = raw
|
|
29
|
-
.split(/[
|
|
30
|
+
.split(/[,;\n]+/)
|
|
30
31
|
.map((p) => p.trim())
|
|
31
32
|
.filter(Boolean);
|
|
32
33
|
if (!parts.length) return;
|
|
33
34
|
let next = [...value];
|
|
34
35
|
for (const part of parts) {
|
|
35
|
-
|
|
36
|
+
const exists = next.some((t) => t.toLowerCase() === part.toLowerCase());
|
|
37
|
+
if (exists) continue;
|
|
36
38
|
if (max !== undefined && next.length >= max) break;
|
|
37
39
|
next.push(part);
|
|
38
40
|
}
|
|
@@ -61,9 +63,10 @@
|
|
|
61
63
|
|
|
62
64
|
function onPaste(e: ClipboardEvent) {
|
|
63
65
|
const text = e.clipboardData?.getData('text') ?? '';
|
|
64
|
-
if (!/[,;\
|
|
66
|
+
if (!/[,;\n]/.test(text)) return;
|
|
65
67
|
e.preventDefault();
|
|
66
|
-
|
|
68
|
+
const prefix = draft.trim() ? `${draft.trim()}, ` : '';
|
|
69
|
+
addMany(`${prefix}${text}`);
|
|
67
70
|
}
|
|
68
71
|
</script>
|
|
69
72
|
|