@r2digisolutions/components 0.21.10 → 0.21.12
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 +4 -2
- package/dist/components/atoms/SelectionBox/SelectionBox.svelte.d.ts +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/organisms/Sidebar/Sidebar.stories.d.ts +2 -0
- package/dist/components/organisms/Sidebar/Sidebar.stories.js +1 -0
- package/dist/components/organisms/Sidebar/Sidebar.svelte +40 -6
- package/dist/components/organisms/Sidebar/Sidebar.svelte.d.ts +4 -0
- package/dist/components/organisms/Sidebar/SidebarStory.svelte +26 -2
- package/dist/components/organisms/Sidebar/SidebarStory.svelte.d.ts +1 -0
- package/package.json +1 -1
|
@@ -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;
|
|
@@ -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;
|
|
@@ -3,6 +3,7 @@ declare const meta: {
|
|
|
3
3
|
title: string;
|
|
4
4
|
component: import("svelte").Component<{
|
|
5
5
|
collapsed?: boolean;
|
|
6
|
+
wizard?: boolean;
|
|
6
7
|
}, {}, "">;
|
|
7
8
|
tags: string[];
|
|
8
9
|
argTypes: {
|
|
@@ -18,3 +19,4 @@ export default meta;
|
|
|
18
19
|
type Story = StoryObj<typeof meta>;
|
|
19
20
|
export declare const Default: Story;
|
|
20
21
|
export declare const Collapsed: Story;
|
|
22
|
+
export declare const WizardStepper: Story;
|
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
href?: string;
|
|
16
16
|
icon?: SidebarIcon;
|
|
17
17
|
disabled?: boolean;
|
|
18
|
+
/** Completed step (wizard / stepper). Shows a check when not active. */
|
|
19
|
+
done?: boolean;
|
|
20
|
+
/** Optional short hint (e.g. warning). */
|
|
21
|
+
hint?: string;
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
export interface SidebarGroup {
|
|
@@ -55,24 +59,47 @@
|
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
function itemClass(item: SidebarItem) {
|
|
62
|
+
const active = value === item.id;
|
|
58
63
|
return [
|
|
59
64
|
'relative flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-sm transition-colors',
|
|
60
65
|
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-500/30',
|
|
61
|
-
|
|
66
|
+
active
|
|
62
67
|
? 'bg-surface-overlay font-medium text-primary'
|
|
63
|
-
:
|
|
68
|
+
: item.done
|
|
69
|
+
? 'text-secondary hover:bg-surface-overlay hover:text-primary'
|
|
70
|
+
: 'text-secondary hover:bg-surface-overlay hover:text-primary',
|
|
64
71
|
item.disabled && 'pointer-events-none cursor-not-allowed opacity-40',
|
|
65
72
|
collapsed && 'justify-center'
|
|
66
73
|
];
|
|
67
74
|
}
|
|
68
75
|
</script>
|
|
69
76
|
|
|
77
|
+
{#snippet checkIcon()}
|
|
78
|
+
<svg
|
|
79
|
+
class="text-brand-600 dark:text-brand-400 h-4 w-4 shrink-0"
|
|
80
|
+
viewBox="0 0 24 24"
|
|
81
|
+
fill="none"
|
|
82
|
+
stroke="currentColor"
|
|
83
|
+
stroke-width="2.25"
|
|
84
|
+
aria-hidden="true"
|
|
85
|
+
>
|
|
86
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7" />
|
|
87
|
+
</svg>
|
|
88
|
+
{/snippet}
|
|
89
|
+
|
|
70
90
|
{#snippet itemGlyph(item: SidebarItem)}
|
|
71
|
-
{#if item.
|
|
91
|
+
{#if item.done && value !== item.id}
|
|
92
|
+
{@render checkIcon()}
|
|
93
|
+
{:else if item.icon}
|
|
72
94
|
<item.icon class="h-4 w-4 shrink-0" strokeWidth={1.75} />
|
|
73
95
|
{:else}
|
|
74
96
|
<span
|
|
75
|
-
class=
|
|
97
|
+
class={[
|
|
98
|
+
'h-6 w-6 rounded-md font-semibold flex shrink-0 items-center justify-center text-[11px]',
|
|
99
|
+
item.done
|
|
100
|
+
? 'bg-brand-500/15 text-brand-700 dark:text-brand-300'
|
|
101
|
+
: 'bg-surface-overlay'
|
|
102
|
+
]}
|
|
76
103
|
>
|
|
77
104
|
{item.label.slice(0, 1)}
|
|
78
105
|
</span>
|
|
@@ -91,7 +118,10 @@
|
|
|
91
118
|
<RailMark active={value === item.id} side="right" length="short" inset="sm" />
|
|
92
119
|
{@render itemGlyph(item)}
|
|
93
120
|
{#if !collapsed}
|
|
94
|
-
<span class="truncate">{item.label}</span>
|
|
121
|
+
<span class="min-w-0 flex-1 truncate">{item.label}</span>
|
|
122
|
+
{#if item.hint}
|
|
123
|
+
<span class="text-amber-600 dark:text-amber-400 shrink-0 text-[10px]">{item.hint}</span>
|
|
124
|
+
{/if}
|
|
95
125
|
{/if}
|
|
96
126
|
</a>
|
|
97
127
|
{:else}
|
|
@@ -100,13 +130,17 @@
|
|
|
100
130
|
disabled={item.disabled}
|
|
101
131
|
title={collapsed ? item.label : undefined}
|
|
102
132
|
aria-current={value === item.id ? 'page' : undefined}
|
|
133
|
+
aria-checked={item.done ? 'true' : undefined}
|
|
103
134
|
class={itemClass(item)}
|
|
104
135
|
onclick={() => select(item.id, item.disabled)}
|
|
105
136
|
>
|
|
106
137
|
<RailMark active={value === item.id} side="right" length="short" inset="sm" />
|
|
107
138
|
{@render itemGlyph(item)}
|
|
108
139
|
{#if !collapsed}
|
|
109
|
-
<span class="truncate">{item.label}</span>
|
|
140
|
+
<span class="min-w-0 flex-1 truncate">{item.label}</span>
|
|
141
|
+
{#if item.hint}
|
|
142
|
+
<span class="text-amber-600 dark:text-amber-400 shrink-0 text-[10px]">{item.hint}</span>
|
|
143
|
+
{/if}
|
|
110
144
|
{/if}
|
|
111
145
|
</button>
|
|
112
146
|
{/if}
|
|
@@ -10,6 +10,10 @@ export interface SidebarItem {
|
|
|
10
10
|
href?: string;
|
|
11
11
|
icon?: SidebarIcon;
|
|
12
12
|
disabled?: boolean;
|
|
13
|
+
/** Completed step (wizard / stepper). Shows a check when not active. */
|
|
14
|
+
done?: boolean;
|
|
15
|
+
/** Optional short hint (e.g. warning). */
|
|
16
|
+
hint?: string;
|
|
13
17
|
}
|
|
14
18
|
export interface SidebarGroup {
|
|
15
19
|
id: string;
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
let props = $props<{
|
|
6
6
|
collapsed?: boolean;
|
|
7
|
+
wizard?: boolean;
|
|
7
8
|
}>();
|
|
8
9
|
|
|
9
|
-
const
|
|
10
|
+
const defaultGroups: SidebarGroup[] = [
|
|
10
11
|
{
|
|
11
12
|
id: 'main',
|
|
12
13
|
label: 'Workspace',
|
|
@@ -26,7 +27,30 @@
|
|
|
26
27
|
}
|
|
27
28
|
];
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
const wizardGroups: SidebarGroup[] = [
|
|
31
|
+
{
|
|
32
|
+
id: 'business',
|
|
33
|
+
label: 'Onboarding',
|
|
34
|
+
items: [{ id: 'business', label: 'Empresa', done: true }]
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'campaign',
|
|
38
|
+
label: 'Crea tu campaña',
|
|
39
|
+
items: [
|
|
40
|
+
{ id: 'themes', label: 'Temas de búsqueda', done: true },
|
|
41
|
+
{ id: 'ads', label: 'Crear anuncios' },
|
|
42
|
+
{ id: 'bidding', label: 'Estrategia de puja' },
|
|
43
|
+
{ id: 'budget', label: 'Presupuesto' }
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: 'payment',
|
|
48
|
+
items: [{ id: 'payment', label: 'Detalles del pago' }]
|
|
49
|
+
}
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
const groups = $derived(props.wizard ? wizardGroups : defaultGroups);
|
|
53
|
+
let value = $state(props.wizard ? 'ads' : 'projects');
|
|
30
54
|
let collapsed = $state(props.collapsed ?? false);
|
|
31
55
|
</script>
|
|
32
56
|
|