@r2digisolutions/components 0.21.9 → 0.21.11
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/Input/Input.svelte +27 -4
- package/dist/components/atoms/Input/Input.svelte.d.ts +3 -0
- package/dist/components/atoms/SelectionBox/SelectionBox.svelte +4 -2
- package/dist/components/atoms/SelectionBox/SelectionBox.svelte.d.ts +1 -1
- package/dist/components/molecules/FormField/FormField.svelte +6 -0
- package/dist/components/molecules/FormField/FormField.svelte.d.ts +2 -0
- package/dist/components/molecules/FormTextarea/FormTextarea.svelte +1 -1
- package/dist/components/molecules/MultiSelect/MultiSelect.svelte +4 -6
- package/dist/components/molecules/Select/Select.svelte +8 -6
- package/dist/components/molecules/SelectCard/SelectCard.svelte +14 -6
- package/dist/components/molecules/SelectCard/SelectCard.svelte.d.ts +1 -1
- package/dist/components/molecules/Tabs/Tabs.svelte +1 -1
- package/dist/components/organisms/Dialog/Dialog.stories.js +1 -1
- package/dist/components/organisms/Dialog/Dialog.svelte +8 -4
- package/dist/components/organisms/Dialog/Dialog.svelte.d.ts +1 -1
- package/package.json +1 -1
|
@@ -26,6 +26,9 @@
|
|
|
26
26
|
min?: number;
|
|
27
27
|
max?: number;
|
|
28
28
|
step?: number;
|
|
29
|
+
maxLength?: number;
|
|
30
|
+
/** Show `n/max` counter (defaults on when `maxLength` is set). */
|
|
31
|
+
showCount?: boolean;
|
|
29
32
|
oninput?: (e: Event) => void;
|
|
30
33
|
onchange?: (e: Event) => void;
|
|
31
34
|
onfocus?: (e: FocusEvent) => void;
|
|
@@ -53,6 +56,8 @@
|
|
|
53
56
|
min,
|
|
54
57
|
max,
|
|
55
58
|
step,
|
|
59
|
+
maxLength,
|
|
60
|
+
showCount = maxLength != null,
|
|
56
61
|
size = 'md',
|
|
57
62
|
leadIcon,
|
|
58
63
|
trailIcon,
|
|
@@ -157,6 +162,7 @@
|
|
|
157
162
|
{min}
|
|
158
163
|
{max}
|
|
159
164
|
{step}
|
|
165
|
+
maxlength={maxLength}
|
|
160
166
|
{autocomplete}
|
|
161
167
|
aria-describedby={helperText ? helperId : undefined}
|
|
162
168
|
aria-invalid={status === 'error'}
|
|
@@ -184,6 +190,7 @@
|
|
|
184
190
|
{min}
|
|
185
191
|
{max}
|
|
186
192
|
{step}
|
|
193
|
+
maxlength={maxLength}
|
|
187
194
|
{autocomplete}
|
|
188
195
|
bind:value
|
|
189
196
|
aria-describedby={helperText ? helperId : undefined}
|
|
@@ -246,9 +253,25 @@
|
|
|
246
253
|
{/if}
|
|
247
254
|
</div>
|
|
248
255
|
|
|
249
|
-
{#if helperText}
|
|
250
|
-
<
|
|
251
|
-
{helperText}
|
|
252
|
-
|
|
256
|
+
{#if helperText || (showCount && maxLength != null)}
|
|
257
|
+
<div class="flex items-center justify-between gap-2 text-xs">
|
|
258
|
+
{#if helperText}
|
|
259
|
+
<p id={helperId} class={['leading-relaxed', statusTextClasses[status]]}>
|
|
260
|
+
{helperText}
|
|
261
|
+
</p>
|
|
262
|
+
{:else}
|
|
263
|
+
<span></span>
|
|
264
|
+
{/if}
|
|
265
|
+
{#if showCount && maxLength != null}
|
|
266
|
+
<span
|
|
267
|
+
class={[
|
|
268
|
+
'font-mono shrink-0 ml-auto tabular-nums',
|
|
269
|
+
value.length >= maxLength ? 'font-semibold text-amber-600 dark:text-amber-400' : 'text-muted'
|
|
270
|
+
]}
|
|
271
|
+
>
|
|
272
|
+
{value.length}/{maxLength}
|
|
273
|
+
</span>
|
|
274
|
+
{/if}
|
|
275
|
+
</div>
|
|
253
276
|
{/if}
|
|
254
277
|
</div>
|
|
@@ -22,6 +22,9 @@ interface InputProps {
|
|
|
22
22
|
min?: number;
|
|
23
23
|
max?: number;
|
|
24
24
|
step?: number;
|
|
25
|
+
maxLength?: number;
|
|
26
|
+
/** Show `n/max` counter (defaults on when `maxLength` is set). */
|
|
27
|
+
showCount?: boolean;
|
|
25
28
|
oninput?: (e: Event) => void;
|
|
26
29
|
onchange?: (e: Event) => void;
|
|
27
30
|
onfocus?: (e: FocusEvent) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
export type SelectionBoxSize = 'sm' | 'md' | 'lg';
|
|
3
|
-
export type SelectionBoxTone = 'brand' | 'primary' | 'success';
|
|
3
|
+
export type SelectionBoxTone = 'brand' | 'primary' | 'success' | 'neutral';
|
|
4
4
|
export type SelectionBoxRadius = 'sm' | 'md' | 'none';
|
|
5
5
|
|
|
6
6
|
interface SelectionBoxProps {
|
|
@@ -61,7 +61,9 @@
|
|
|
61
61
|
primary:
|
|
62
62
|
'checked:bg-primary checked:border-primary indeterminate:bg-primary indeterminate:border-primary hover:border-primary/60 focus-visible:ring-primary',
|
|
63
63
|
success:
|
|
64
|
-
'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'
|
|
64
|
+
'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',
|
|
65
|
+
neutral:
|
|
66
|
+
'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-200 dark:checked:border-neutral-200 dark:indeterminate:bg-neutral-200 dark:indeterminate:border-neutral-200 dark:hover:border-neutral-400 dark:focus-visible:ring-neutral-400'
|
|
65
67
|
};
|
|
66
68
|
|
|
67
69
|
function handleChange(e: Event) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type SelectionBoxSize = 'sm' | 'md' | 'lg';
|
|
2
|
-
export type SelectionBoxTone = 'brand' | 'primary' | 'success';
|
|
2
|
+
export type SelectionBoxTone = 'brand' | 'primary' | 'success' | 'neutral';
|
|
3
3
|
export type SelectionBoxRadius = 'sm' | 'md' | 'none';
|
|
4
4
|
interface SelectionBoxProps {
|
|
5
5
|
checked?: boolean;
|
|
@@ -52,6 +52,8 @@
|
|
|
52
52
|
required?: boolean;
|
|
53
53
|
clearable?: boolean;
|
|
54
54
|
size?: 'sm' | 'md' | 'lg';
|
|
55
|
+
maxLength?: number;
|
|
56
|
+
showCount?: boolean;
|
|
55
57
|
/**
|
|
56
58
|
* When true and inside `<Form>`, keep `value` in sync with `form.data[name]`.
|
|
57
59
|
* Uses the logical field name (strips Kit `/formId` when present).
|
|
@@ -90,6 +92,8 @@
|
|
|
90
92
|
required = false,
|
|
91
93
|
clearable = false,
|
|
92
94
|
size = 'md',
|
|
95
|
+
maxLength,
|
|
96
|
+
showCount = maxLength != null,
|
|
93
97
|
bindData = false,
|
|
94
98
|
inputName,
|
|
95
99
|
leadIcon,
|
|
@@ -184,6 +188,8 @@
|
|
|
184
188
|
{required}
|
|
185
189
|
{clearable}
|
|
186
190
|
{size}
|
|
191
|
+
{maxLength}
|
|
192
|
+
{showCount}
|
|
187
193
|
{leadIcon}
|
|
188
194
|
{trailIcon}
|
|
189
195
|
oninput={handleInput}
|
|
@@ -41,6 +41,8 @@ interface FormFieldProps {
|
|
|
41
41
|
required?: boolean;
|
|
42
42
|
clearable?: boolean;
|
|
43
43
|
size?: 'sm' | 'md' | 'lg';
|
|
44
|
+
maxLength?: number;
|
|
45
|
+
showCount?: boolean;
|
|
44
46
|
/**
|
|
45
47
|
* When true and inside `<Form>`, keep `value` in sync with `form.data[name]`.
|
|
46
48
|
* Uses the logical field name (strips Kit `/formId` when present).
|
|
@@ -368,7 +368,7 @@
|
|
|
368
368
|
!option.disabled &&
|
|
369
369
|
!blocked &&
|
|
370
370
|
(highlighted === index || isSelected
|
|
371
|
-
? 'bg-
|
|
371
|
+
? 'bg-neutral-800 text-white dark:bg-neutral-200 dark:text-neutral-900'
|
|
372
372
|
: 'text-primary hover:bg-surface-overlay')
|
|
373
373
|
]}
|
|
374
374
|
>
|
|
@@ -376,18 +376,16 @@
|
|
|
376
376
|
class={[
|
|
377
377
|
'flex h-4 w-4 shrink-0 items-center justify-center rounded border transition-colors',
|
|
378
378
|
isSelected
|
|
379
|
-
?
|
|
380
|
-
? 'border-white bg-white'
|
|
381
|
-
: 'border-brand-500 bg-brand-500'
|
|
379
|
+
? 'border-white bg-white dark:border-neutral-900 dark:bg-neutral-900'
|
|
382
380
|
: highlighted === index
|
|
383
|
-
? 'border-white/60'
|
|
381
|
+
? 'border-white/60 dark:border-neutral-900/50'
|
|
384
382
|
: 'border-border-strong'
|
|
385
383
|
]}
|
|
386
384
|
aria-hidden="true"
|
|
387
385
|
>
|
|
388
386
|
{#if isSelected}
|
|
389
387
|
<svg
|
|
390
|
-
class="h-2.5 w-2.5 text-
|
|
388
|
+
class="h-2.5 w-2.5 text-neutral-800 dark:text-neutral-100"
|
|
391
389
|
viewBox="0 0 24 24"
|
|
392
390
|
fill="none"
|
|
393
391
|
stroke="currentColor"
|
|
@@ -642,9 +642,9 @@
|
|
|
642
642
|
'transition-[background-color,color,box-shadow] duration-75',
|
|
643
643
|
option.disabled ? 'cursor-not-allowed opacity-40' : 'cursor-pointer',
|
|
644
644
|
isHighlighted && !option.disabled
|
|
645
|
-
? 'bg-
|
|
645
|
+
? 'bg-neutral-800 text-white shadow-sm dark:bg-neutral-200 dark:text-neutral-900'
|
|
646
646
|
: isSelected && !option.disabled
|
|
647
|
-
? 'bg-
|
|
647
|
+
? 'bg-neutral-100 font-medium text-primary dark:bg-neutral-800/70'
|
|
648
648
|
: 'text-primary hover:bg-surface-overlay'
|
|
649
649
|
]}
|
|
650
650
|
>
|
|
@@ -654,10 +654,10 @@
|
|
|
654
654
|
'h-4 w-4 flex shrink-0 items-center justify-center rounded-full border transition-colors duration-75',
|
|
655
655
|
isHighlighted && !option.disabled
|
|
656
656
|
? isSelected
|
|
657
|
-
? 'border-white bg-white'
|
|
658
|
-
: 'border-white/60 bg-transparent'
|
|
657
|
+
? 'border-white bg-white dark:border-neutral-900 dark:bg-neutral-900'
|
|
658
|
+
: 'border-white/60 bg-transparent dark:border-neutral-900/50'
|
|
659
659
|
: isSelected && !option.disabled
|
|
660
|
-
? 'border-
|
|
660
|
+
? 'border-neutral-800 bg-neutral-800 dark:border-neutral-200 dark:bg-neutral-200'
|
|
661
661
|
: 'border-border-strong bg-transparent'
|
|
662
662
|
]}
|
|
663
663
|
aria-hidden="true"
|
|
@@ -666,7 +666,9 @@
|
|
|
666
666
|
<svg
|
|
667
667
|
class={[
|
|
668
668
|
'h-2.5 w-2.5',
|
|
669
|
-
isHighlighted
|
|
669
|
+
isHighlighted
|
|
670
|
+
? 'text-neutral-800 dark:text-neutral-100'
|
|
671
|
+
: 'text-white dark:text-neutral-900'
|
|
670
672
|
]}
|
|
671
673
|
viewBox="0 0 24 24"
|
|
672
674
|
fill="none"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
layout?: SelectCardLayout;
|
|
20
20
|
/** box = SelectionBox · badge = check pill · none = border only */
|
|
21
21
|
check?: SelectCardCheck;
|
|
22
|
-
/** Accent when selected (default
|
|
22
|
+
/** Accent when selected (default neutral — works with data-theme="neutral") */
|
|
23
23
|
tone?: SelectCardTone;
|
|
24
24
|
class?: string;
|
|
25
25
|
leading?: Snippet;
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
disabled = false,
|
|
40
40
|
layout = 'media',
|
|
41
41
|
check = 'box',
|
|
42
|
-
tone = '
|
|
42
|
+
tone = 'neutral',
|
|
43
43
|
class: className = '',
|
|
44
44
|
leading,
|
|
45
45
|
children,
|
|
@@ -50,7 +50,8 @@
|
|
|
50
50
|
|
|
51
51
|
const selectedTone: Record<SelectCardTone, string> = {
|
|
52
52
|
brand: 'border-brand-500 bg-brand-50/50 ring-2 ring-brand-500/20 dark:bg-brand-950/30',
|
|
53
|
-
neutral:
|
|
53
|
+
neutral:
|
|
54
|
+
'border-neutral-400 bg-neutral-100/80 ring-2 ring-neutral-400/25 dark:border-neutral-500 dark:bg-neutral-800/60 dark:ring-neutral-500/30',
|
|
54
55
|
success:
|
|
55
56
|
'border-emerald-500 bg-emerald-50/70 ring-2 ring-emerald-500/20 dark:border-emerald-400 dark:bg-emerald-950/35',
|
|
56
57
|
error: 'border-red-500 bg-red-50/70 ring-2 ring-red-500/20 dark:border-red-400 dark:bg-red-950/35',
|
|
@@ -61,7 +62,7 @@
|
|
|
61
62
|
|
|
62
63
|
const hoverTone: Record<SelectCardTone, string> = {
|
|
63
64
|
brand: 'hover:border-brand-300 dark:hover:border-brand-700',
|
|
64
|
-
neutral: 'hover:border-border-
|
|
65
|
+
neutral: 'hover:border-neutral-400 dark:hover:border-neutral-500',
|
|
65
66
|
success: 'hover:border-emerald-300 dark:hover:border-emerald-700',
|
|
66
67
|
error: 'hover:border-red-300 dark:hover:border-red-700',
|
|
67
68
|
warning: 'hover:border-amber-300 dark:hover:border-amber-700',
|
|
@@ -70,7 +71,8 @@
|
|
|
70
71
|
|
|
71
72
|
const badgeTone: Record<SelectCardTone, string> = {
|
|
72
73
|
brand: 'border-brand-500 bg-brand-500 text-white',
|
|
73
|
-
neutral:
|
|
74
|
+
neutral:
|
|
75
|
+
'border-neutral-700 bg-neutral-800 text-white dark:border-neutral-300 dark:bg-neutral-200 dark:text-neutral-900',
|
|
74
76
|
success: 'border-emerald-500 bg-emerald-500 text-white',
|
|
75
77
|
error: 'border-red-500 bg-red-500 text-white',
|
|
76
78
|
warning: 'border-amber-500 bg-amber-500 text-white',
|
|
@@ -79,13 +81,17 @@
|
|
|
79
81
|
|
|
80
82
|
const focusTone: Record<SelectCardTone, string> = {
|
|
81
83
|
brand: 'focus-visible:ring-brand-500/30',
|
|
82
|
-
neutral: 'focus-visible:ring-
|
|
84
|
+
neutral: 'focus-visible:ring-neutral-400/40 dark:focus-visible:ring-neutral-500/40',
|
|
83
85
|
success: 'focus-visible:ring-emerald-500/30',
|
|
84
86
|
error: 'focus-visible:ring-red-500/30',
|
|
85
87
|
warning: 'focus-visible:ring-amber-500/30',
|
|
86
88
|
info: 'focus-visible:ring-sky-500/30'
|
|
87
89
|
};
|
|
88
90
|
|
|
91
|
+
const selectionBoxTone = $derived(
|
|
92
|
+
tone === 'brand' ? 'brand' : tone === 'success' ? 'success' : 'neutral'
|
|
93
|
+
);
|
|
94
|
+
|
|
89
95
|
const rootClass = $derived(
|
|
90
96
|
[
|
|
91
97
|
'group relative w-full text-left transition-all',
|
|
@@ -170,6 +176,7 @@
|
|
|
170
176
|
<SelectionBox
|
|
171
177
|
checked={selected}
|
|
172
178
|
size="sm"
|
|
179
|
+
tone={selectionBoxTone}
|
|
173
180
|
{disabled}
|
|
174
181
|
label={title ? `Select ${title}` : 'Select'}
|
|
175
182
|
onchange={handleCheck}
|
|
@@ -202,6 +209,7 @@
|
|
|
202
209
|
<SelectionBox
|
|
203
210
|
checked={selected}
|
|
204
211
|
size="md"
|
|
212
|
+
tone={selectionBoxTone}
|
|
205
213
|
{disabled}
|
|
206
214
|
label={title ? `Select ${title}` : 'Select'}
|
|
207
215
|
onchange={handleCheck}
|
|
@@ -14,7 +14,7 @@ interface SelectCardProps {
|
|
|
14
14
|
layout?: SelectCardLayout;
|
|
15
15
|
/** box = SelectionBox · badge = check pill · none = border only */
|
|
16
16
|
check?: SelectCardCheck;
|
|
17
|
-
/** Accent when selected (default
|
|
17
|
+
/** Accent when selected (default neutral — works with data-theme="neutral") */
|
|
18
18
|
tone?: SelectCardTone;
|
|
19
19
|
class?: string;
|
|
20
20
|
leading?: Snippet;
|
|
@@ -6,7 +6,7 @@ const meta = {
|
|
|
6
6
|
argTypes: {
|
|
7
7
|
title: { control: 'text' },
|
|
8
8
|
description: { control: 'text' },
|
|
9
|
-
size: { control: 'select', options: ['xs', 'sm', 'md', 'lg', 'xl', 'full'] },
|
|
9
|
+
size: { control: 'select', options: ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', 'full'] },
|
|
10
10
|
tone: { control: 'select', options: ['default', 'info', 'success', 'warning', 'danger'] },
|
|
11
11
|
position: { control: 'select', options: ['center', 'top'] },
|
|
12
12
|
closeOnBackdrop: { control: 'boolean' },
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import type { Snippet } from 'svelte';
|
|
7
7
|
import Button from '../../atoms/Button/Button.svelte';
|
|
8
8
|
|
|
9
|
-
type DialogSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
|
|
9
|
+
type DialogSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | 'full';
|
|
10
10
|
type DialogTone = 'default' | 'info' | 'success' | 'warning' | 'danger';
|
|
11
11
|
type FooterAlign = 'start' | 'center' | 'end' | 'between';
|
|
12
12
|
type DialogPosition = 'center' | 'top';
|
|
@@ -87,6 +87,8 @@
|
|
|
87
87
|
md: 'max-w-md',
|
|
88
88
|
lg: 'max-w-lg',
|
|
89
89
|
xl: 'max-w-2xl',
|
|
90
|
+
'2xl': 'max-w-4xl',
|
|
91
|
+
'3xl': 'max-w-5xl',
|
|
90
92
|
full: ''
|
|
91
93
|
};
|
|
92
94
|
|
|
@@ -284,9 +286,11 @@
|
|
|
284
286
|
scrollable &&
|
|
285
287
|
(size === 'full'
|
|
286
288
|
? 'overflow-auto'
|
|
287
|
-
: size === '
|
|
288
|
-
? 'max-h-[min(
|
|
289
|
-
:
|
|
289
|
+
: size === '3xl' || size === '2xl'
|
|
290
|
+
? 'max-h-[min(75vh,40rem)] overflow-y-auto'
|
|
291
|
+
: size === 'xl'
|
|
292
|
+
? 'max-h-[min(70vh,36rem)] overflow-y-auto'
|
|
293
|
+
: 'max-h-[min(60vh,28rem)] overflow-y-auto')
|
|
290
294
|
]}
|
|
291
295
|
>
|
|
292
296
|
{@render children()}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
type DialogSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
|
|
2
|
+
type DialogSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | 'full';
|
|
3
3
|
type DialogTone = 'default' | 'info' | 'success' | 'warning' | 'danger';
|
|
4
4
|
type FooterAlign = 'start' | 'center' | 'end' | 'between';
|
|
5
5
|
type DialogPosition = 'center' | 'top';
|