sv5ui 1.6.0 → 1.8.0
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/Banner/Banner.svelte +162 -0
- package/dist/Banner/Banner.svelte.d.ts +5 -0
- package/dist/Banner/banner.types.d.ts +148 -0
- package/dist/Banner/banner.types.js +1 -0
- package/dist/Banner/banner.variants.d.ts +293 -0
- package/dist/Banner/banner.variants.js +86 -0
- package/dist/Banner/index.d.ts +2 -0
- package/dist/Banner/index.js +1 -0
- package/dist/Calendar/Calendar.svelte +48 -6
- package/dist/Calendar/calendar.types.d.ts +19 -0
- package/dist/Calendar/calendar.variants.js +2 -1
- package/dist/Carousel/Carousel.svelte +279 -0
- package/dist/Carousel/Carousel.svelte.d.ts +26 -0
- package/dist/Carousel/carousel.types.d.ts +242 -0
- package/dist/Carousel/carousel.types.js +1 -0
- package/dist/Carousel/carousel.variants.d.ts +408 -0
- package/dist/Carousel/carousel.variants.js +88 -0
- package/dist/Carousel/index.d.ts +2 -0
- package/dist/Carousel/index.js +1 -0
- package/dist/Editor/Editor.svelte +738 -0
- package/dist/Editor/Editor.svelte.d.ts +6 -0
- package/dist/Editor/EditorUrlPrompt.svelte +111 -0
- package/dist/Editor/EditorUrlPrompt.svelte.d.ts +15 -0
- package/dist/Editor/SlashPopup.svelte +67 -0
- package/dist/Editor/SlashPopup.svelte.d.ts +9 -0
- package/dist/Editor/editor.extensions.d.ts +23 -0
- package/dist/Editor/editor.extensions.js +123 -0
- package/dist/Editor/editor.schemas.d.ts +4 -0
- package/dist/Editor/editor.schemas.js +3 -0
- package/dist/Editor/editor.slash.svelte.d.ts +34 -0
- package/dist/Editor/editor.slash.svelte.js +273 -0
- package/dist/Editor/editor.suggestion.d.ts +7 -0
- package/dist/Editor/editor.suggestion.js +142 -0
- package/dist/Editor/editor.toolbar.d.ts +11 -0
- package/dist/Editor/editor.toolbar.js +212 -0
- package/dist/Editor/editor.types.d.ts +347 -0
- package/dist/Editor/editor.types.js +1 -0
- package/dist/Editor/editor.variants.d.ts +308 -0
- package/dist/Editor/editor.variants.js +150 -0
- package/dist/Editor/index.d.ts +53 -0
- package/dist/Editor/index.js +52 -0
- package/dist/FileUpload/FileUpload.svelte +81 -10
- package/dist/FileUpload/file-upload.types.d.ts +39 -0
- package/dist/FileUpload/index.d.ts +1 -1
- package/dist/Modal/Modal.svelte +14 -3
- package/dist/Modal/modal.types.d.ts +15 -4
- package/dist/Modal/modal.variants.d.ts +110 -20
- package/dist/Modal/modal.variants.js +27 -9
- package/dist/PinInput/PinInput.svelte +18 -4
- package/dist/PinInput/pin-input.types.d.ts +11 -0
- package/dist/Select/Select.svelte +98 -28
- package/dist/Select/select.types.d.ts +44 -2
- package/dist/SelectMenu/SelectMenu.svelte +210 -25
- package/dist/SelectMenu/select-menu.types.d.ts +62 -1
- package/dist/SelectMenu/select-menu.variants.d.ts +26 -0
- package/dist/SelectMenu/select-menu.variants.js +34 -6
- package/dist/Slideover/Slideover.svelte +13 -2
- package/dist/Slideover/slideover.types.d.ts +14 -3
- package/dist/Slideover/slideover.variants.d.ts +85 -5
- package/dist/Slideover/slideover.variants.js +42 -12
- package/dist/Stepper/Stepper.svelte +292 -0
- package/dist/Stepper/Stepper.svelte.d.ts +5 -0
- package/dist/Stepper/index.d.ts +2 -0
- package/dist/Stepper/index.js +1 -0
- package/dist/Stepper/stepper.types.d.ts +223 -0
- package/dist/Stepper/stepper.types.js +1 -0
- package/dist/Stepper/stepper.variants.d.ts +428 -0
- package/dist/Stepper/stepper.variants.js +204 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/package.json +102 -1
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { type VariantProps } from 'tailwind-variants';
|
|
2
2
|
export declare const slideoverVariants: import("tailwind-variants").TVReturnType<{
|
|
3
3
|
transition: {
|
|
4
|
-
|
|
4
|
+
none: {};
|
|
5
|
+
fade: {
|
|
6
|
+
overlay: string;
|
|
7
|
+
content: string;
|
|
8
|
+
};
|
|
9
|
+
slide: {
|
|
10
|
+
overlay: string;
|
|
11
|
+
};
|
|
12
|
+
scale: {
|
|
5
13
|
overlay: string;
|
|
14
|
+
content: string;
|
|
6
15
|
};
|
|
7
16
|
};
|
|
8
17
|
side: {
|
|
@@ -19,6 +28,13 @@ export declare const slideoverVariants: import("tailwind-variants").TVReturnType
|
|
|
19
28
|
content: string;
|
|
20
29
|
};
|
|
21
30
|
};
|
|
31
|
+
size: {
|
|
32
|
+
sm: {};
|
|
33
|
+
md: {};
|
|
34
|
+
lg: {};
|
|
35
|
+
xl: {};
|
|
36
|
+
full: {};
|
|
37
|
+
};
|
|
22
38
|
inset: {
|
|
23
39
|
true: {};
|
|
24
40
|
false: {
|
|
@@ -43,9 +59,18 @@ export declare const slideoverVariants: import("tailwind-variants").TVReturnType
|
|
|
43
59
|
close: string;
|
|
44
60
|
}, undefined, {
|
|
45
61
|
transition: {
|
|
46
|
-
|
|
62
|
+
none: {};
|
|
63
|
+
fade: {
|
|
64
|
+
overlay: string;
|
|
65
|
+
content: string;
|
|
66
|
+
};
|
|
67
|
+
slide: {
|
|
47
68
|
overlay: string;
|
|
48
69
|
};
|
|
70
|
+
scale: {
|
|
71
|
+
overlay: string;
|
|
72
|
+
content: string;
|
|
73
|
+
};
|
|
49
74
|
};
|
|
50
75
|
side: {
|
|
51
76
|
top: {
|
|
@@ -61,6 +86,13 @@ export declare const slideoverVariants: import("tailwind-variants").TVReturnType
|
|
|
61
86
|
content: string;
|
|
62
87
|
};
|
|
63
88
|
};
|
|
89
|
+
size: {
|
|
90
|
+
sm: {};
|
|
91
|
+
md: {};
|
|
92
|
+
lg: {};
|
|
93
|
+
xl: {};
|
|
94
|
+
full: {};
|
|
95
|
+
};
|
|
64
96
|
inset: {
|
|
65
97
|
true: {};
|
|
66
98
|
false: {
|
|
@@ -85,9 +117,18 @@ export declare const slideoverVariants: import("tailwind-variants").TVReturnType
|
|
|
85
117
|
close: string;
|
|
86
118
|
}, import("tailwind-variants").TVReturnType<{
|
|
87
119
|
transition: {
|
|
88
|
-
|
|
120
|
+
none: {};
|
|
121
|
+
fade: {
|
|
122
|
+
overlay: string;
|
|
123
|
+
content: string;
|
|
124
|
+
};
|
|
125
|
+
slide: {
|
|
89
126
|
overlay: string;
|
|
90
127
|
};
|
|
128
|
+
scale: {
|
|
129
|
+
overlay: string;
|
|
130
|
+
content: string;
|
|
131
|
+
};
|
|
91
132
|
};
|
|
92
133
|
side: {
|
|
93
134
|
top: {
|
|
@@ -103,6 +144,13 @@ export declare const slideoverVariants: import("tailwind-variants").TVReturnType
|
|
|
103
144
|
content: string;
|
|
104
145
|
};
|
|
105
146
|
};
|
|
147
|
+
size: {
|
|
148
|
+
sm: {};
|
|
149
|
+
md: {};
|
|
150
|
+
lg: {};
|
|
151
|
+
xl: {};
|
|
152
|
+
full: {};
|
|
153
|
+
};
|
|
106
154
|
inset: {
|
|
107
155
|
true: {};
|
|
108
156
|
false: {
|
|
@@ -131,8 +179,17 @@ export type SlideoverSlots = keyof ReturnType<typeof slideoverVariants>;
|
|
|
131
179
|
export declare const slideoverDefaults: {
|
|
132
180
|
defaultVariants: import("tailwind-variants").TVDefaultVariants<{
|
|
133
181
|
transition: {
|
|
134
|
-
|
|
182
|
+
none: {};
|
|
183
|
+
fade: {
|
|
184
|
+
overlay: string;
|
|
185
|
+
content: string;
|
|
186
|
+
};
|
|
187
|
+
slide: {
|
|
188
|
+
overlay: string;
|
|
189
|
+
};
|
|
190
|
+
scale: {
|
|
135
191
|
overlay: string;
|
|
192
|
+
content: string;
|
|
136
193
|
};
|
|
137
194
|
};
|
|
138
195
|
side: {
|
|
@@ -149,6 +206,13 @@ export declare const slideoverDefaults: {
|
|
|
149
206
|
content: string;
|
|
150
207
|
};
|
|
151
208
|
};
|
|
209
|
+
size: {
|
|
210
|
+
sm: {};
|
|
211
|
+
md: {};
|
|
212
|
+
lg: {};
|
|
213
|
+
xl: {};
|
|
214
|
+
full: {};
|
|
215
|
+
};
|
|
152
216
|
inset: {
|
|
153
217
|
true: {};
|
|
154
218
|
false: {
|
|
@@ -173,9 +237,18 @@ export declare const slideoverDefaults: {
|
|
|
173
237
|
close: string;
|
|
174
238
|
}, {
|
|
175
239
|
transition: {
|
|
176
|
-
|
|
240
|
+
none: {};
|
|
241
|
+
fade: {
|
|
242
|
+
overlay: string;
|
|
243
|
+
content: string;
|
|
244
|
+
};
|
|
245
|
+
slide: {
|
|
177
246
|
overlay: string;
|
|
178
247
|
};
|
|
248
|
+
scale: {
|
|
249
|
+
overlay: string;
|
|
250
|
+
content: string;
|
|
251
|
+
};
|
|
179
252
|
};
|
|
180
253
|
side: {
|
|
181
254
|
top: {
|
|
@@ -191,6 +264,13 @@ export declare const slideoverDefaults: {
|
|
|
191
264
|
content: string;
|
|
192
265
|
};
|
|
193
266
|
};
|
|
267
|
+
size: {
|
|
268
|
+
sm: {};
|
|
269
|
+
md: {};
|
|
270
|
+
lg: {};
|
|
271
|
+
xl: {};
|
|
272
|
+
full: {};
|
|
273
|
+
};
|
|
194
274
|
inset: {
|
|
195
275
|
true: {};
|
|
196
276
|
false: {
|
|
@@ -14,24 +14,40 @@ export const slideoverVariants = tv({
|
|
|
14
14
|
},
|
|
15
15
|
variants: {
|
|
16
16
|
transition: {
|
|
17
|
-
|
|
17
|
+
none: {},
|
|
18
|
+
fade: {
|
|
19
|
+
overlay: 'data-[state=open]:animate-[fade-in_200ms_ease-out] data-[state=closed]:animate-[fade-out_150ms_ease-in]',
|
|
20
|
+
content: 'data-[state=open]:animate-[fade-in_200ms_ease-out] data-[state=closed]:animate-[fade-out_150ms_ease-in]'
|
|
21
|
+
},
|
|
22
|
+
slide: {
|
|
18
23
|
overlay: 'data-[state=open]:animate-[fade-in_200ms_ease-out] data-[state=closed]:animate-[fade-out_150ms_ease-in]'
|
|
24
|
+
},
|
|
25
|
+
scale: {
|
|
26
|
+
overlay: 'data-[state=open]:animate-[fade-in_200ms_ease-out] data-[state=closed]:animate-[fade-out_150ms_ease-in]',
|
|
27
|
+
content: 'data-[state=open]:animate-[scale-in_200ms_cubic-bezier(0.32,0.72,0,1)] data-[state=closed]:animate-[scale-out_150ms_cubic-bezier(0.32,0.72,0,1)]'
|
|
19
28
|
}
|
|
20
29
|
},
|
|
21
30
|
side: {
|
|
22
31
|
top: {
|
|
23
|
-
content: 'fixed top-0 inset-x-0
|
|
32
|
+
content: 'fixed top-0 inset-x-0'
|
|
24
33
|
},
|
|
25
34
|
right: {
|
|
26
|
-
content: 'fixed right-0 inset-y-0 w-full
|
|
35
|
+
content: 'fixed right-0 inset-y-0 w-full'
|
|
27
36
|
},
|
|
28
37
|
bottom: {
|
|
29
|
-
content: 'fixed bottom-0 inset-x-0
|
|
38
|
+
content: 'fixed bottom-0 inset-x-0'
|
|
30
39
|
},
|
|
31
40
|
left: {
|
|
32
|
-
content: 'fixed left-0 inset-y-0 w-full
|
|
41
|
+
content: 'fixed left-0 inset-y-0 w-full'
|
|
33
42
|
}
|
|
34
43
|
},
|
|
44
|
+
size: {
|
|
45
|
+
sm: {},
|
|
46
|
+
md: {},
|
|
47
|
+
lg: {},
|
|
48
|
+
xl: {},
|
|
49
|
+
full: {}
|
|
50
|
+
},
|
|
35
51
|
inset: {
|
|
36
52
|
true: {},
|
|
37
53
|
false: {
|
|
@@ -45,39 +61,52 @@ export const slideoverVariants = tv({
|
|
|
45
61
|
}
|
|
46
62
|
},
|
|
47
63
|
compoundVariants: [
|
|
64
|
+
// Side-specific slide animations
|
|
48
65
|
{
|
|
49
|
-
transition:
|
|
66
|
+
transition: 'slide',
|
|
50
67
|
side: 'top',
|
|
51
68
|
class: {
|
|
52
69
|
content: 'data-[state=open]:animate-[slide-in-full-top_200ms_ease-out,fade-in_200ms_ease-out] data-[state=closed]:animate-[slide-out-full-top_150ms_ease-in,fade-out_150ms_ease-in]'
|
|
53
70
|
}
|
|
54
71
|
},
|
|
55
72
|
{
|
|
56
|
-
transition:
|
|
73
|
+
transition: 'slide',
|
|
57
74
|
side: 'right',
|
|
58
75
|
class: {
|
|
59
76
|
content: 'data-[state=open]:animate-[slide-in-full-right_200ms_ease-out,fade-in_200ms_ease-out] data-[state=closed]:animate-[slide-out-full-right_150ms_ease-in,fade-out_150ms_ease-in]'
|
|
60
77
|
}
|
|
61
78
|
},
|
|
62
79
|
{
|
|
63
|
-
transition:
|
|
80
|
+
transition: 'slide',
|
|
64
81
|
side: 'bottom',
|
|
65
82
|
class: {
|
|
66
83
|
content: 'data-[state=open]:animate-[slide-in-full-bottom_200ms_ease-out,fade-in_200ms_ease-out] data-[state=closed]:animate-[slide-out-full-bottom_150ms_ease-in,fade-out_150ms_ease-in]'
|
|
67
84
|
}
|
|
68
85
|
},
|
|
69
86
|
{
|
|
70
|
-
transition:
|
|
87
|
+
transition: 'slide',
|
|
71
88
|
side: 'left',
|
|
72
89
|
class: {
|
|
73
90
|
content: 'data-[state=open]:animate-[slide-in-full-left_200ms_ease-out,fade-in_200ms_ease-out] data-[state=closed]:animate-[slide-out-full-left_150ms_ease-in,fade-out_150ms_ease-in]'
|
|
74
91
|
}
|
|
75
92
|
},
|
|
93
|
+
// Sizes — left/right control width, top/bottom control height
|
|
94
|
+
{ side: ['left', 'right'], size: 'sm', class: { content: 'max-w-sm' } },
|
|
95
|
+
{ side: ['left', 'right'], size: 'md', class: { content: 'max-w-md' } },
|
|
96
|
+
{ side: ['left', 'right'], size: 'lg', class: { content: 'max-w-lg' } },
|
|
97
|
+
{ side: ['left', 'right'], size: 'xl', class: { content: 'max-w-xl' } },
|
|
98
|
+
{ side: ['left', 'right'], size: 'full', class: { content: 'max-w-full' } },
|
|
99
|
+
{ side: ['top', 'bottom'], size: 'sm', class: { content: 'max-h-[40dvh]' } },
|
|
100
|
+
{ side: ['top', 'bottom'], size: 'md', class: { content: 'max-h-[60dvh]' } },
|
|
101
|
+
{ side: ['top', 'bottom'], size: 'lg', class: { content: 'max-h-[75dvh]' } },
|
|
102
|
+
{ side: ['top', 'bottom'], size: 'xl', class: { content: 'max-h-[90dvh]' } },
|
|
103
|
+
{ side: ['top', 'bottom'], size: 'full', class: { content: 'max-h-full' } },
|
|
104
|
+
// Inset positioning + rounded corners + shadow ring per side
|
|
76
105
|
{
|
|
77
106
|
inset: true,
|
|
78
107
|
side: 'top',
|
|
79
108
|
class: {
|
|
80
|
-
content: 'top-4 inset-x-4
|
|
109
|
+
content: 'top-4 inset-x-4 rounded-xl shadow-lg ring ring-outline-variant'
|
|
81
110
|
}
|
|
82
111
|
},
|
|
83
112
|
{
|
|
@@ -91,7 +120,7 @@ export const slideoverVariants = tv({
|
|
|
91
120
|
inset: true,
|
|
92
121
|
side: 'bottom',
|
|
93
122
|
class: {
|
|
94
|
-
content: 'bottom-4 inset-x-4
|
|
123
|
+
content: 'bottom-4 inset-x-4 rounded-xl shadow-lg ring ring-outline-variant'
|
|
95
124
|
}
|
|
96
125
|
},
|
|
97
126
|
{
|
|
@@ -103,8 +132,9 @@ export const slideoverVariants = tv({
|
|
|
103
132
|
}
|
|
104
133
|
],
|
|
105
134
|
defaultVariants: {
|
|
106
|
-
transition:
|
|
135
|
+
transition: 'slide',
|
|
107
136
|
side: 'right',
|
|
137
|
+
size: 'md',
|
|
108
138
|
inset: false,
|
|
109
139
|
overlay: true
|
|
110
140
|
}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { StepperProps } from './stepper.types.js'
|
|
3
|
+
|
|
4
|
+
export type Props = StepperProps
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
import type { ClassNameValue } from 'tailwind-merge'
|
|
9
|
+
import { untrack } from 'svelte'
|
|
10
|
+
import { stepperVariants, stepperDefaults } from './stepper.variants.js'
|
|
11
|
+
import type { StepperItem, StepperItemState, StepperApi } from './stepper.types.js'
|
|
12
|
+
import { getComponentConfig } from '../config.js'
|
|
13
|
+
import Icon from '../Icon/Icon.svelte'
|
|
14
|
+
|
|
15
|
+
const config = getComponentConfig('stepper', stepperDefaults)
|
|
16
|
+
|
|
17
|
+
let {
|
|
18
|
+
ref = $bindable(null),
|
|
19
|
+
as = 'div',
|
|
20
|
+
items = [],
|
|
21
|
+
value = $bindable(),
|
|
22
|
+
defaultValue,
|
|
23
|
+
onValueChange,
|
|
24
|
+
api = $bindable(),
|
|
25
|
+
linear = true,
|
|
26
|
+
disabled = false,
|
|
27
|
+
orientation = config.defaultVariants.orientation ?? 'horizontal',
|
|
28
|
+
size = config.defaultVariants.size ?? 'md',
|
|
29
|
+
color = config.defaultVariants.color ?? 'primary',
|
|
30
|
+
content: showContent = true,
|
|
31
|
+
class: className,
|
|
32
|
+
ui,
|
|
33
|
+
indicator: indicatorSlot,
|
|
34
|
+
titleSlot,
|
|
35
|
+
descriptionSlot,
|
|
36
|
+
body,
|
|
37
|
+
...restProps
|
|
38
|
+
}: Props = $props()
|
|
39
|
+
|
|
40
|
+
if (value === undefined) {
|
|
41
|
+
value = untrack(() => defaultValue ?? items[0]?.value ?? 0)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let triggers: (HTMLButtonElement | null)[] = $state([])
|
|
45
|
+
|
|
46
|
+
function getItemValue(item: StepperItem, index: number): string | number {
|
|
47
|
+
return item.value ?? index
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const activeIndex = $derived(items.findIndex((item, i) => getItemValue(item, i) === value))
|
|
51
|
+
|
|
52
|
+
function getState(index: number): StepperItemState {
|
|
53
|
+
if (activeIndex === -1) return 'pending'
|
|
54
|
+
if (index === activeIndex) return 'active'
|
|
55
|
+
return index < activeIndex ? 'completed' : 'pending'
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function canActivate(index: number): boolean {
|
|
59
|
+
if (disabled || items[index]?.disabled) return false
|
|
60
|
+
if (!linear) return true
|
|
61
|
+
return index <= activeIndex + 1
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function setValue(next: string | number) {
|
|
65
|
+
if (next === value) return
|
|
66
|
+
value = next
|
|
67
|
+
onValueChange?.(next)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function handleClick(item: StepperItem, index: number) {
|
|
71
|
+
if (!canActivate(index)) return
|
|
72
|
+
setValue(getItemValue(item, index))
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function findEnabled(start: number, dir: 1 | -1): number {
|
|
76
|
+
for (let i = start; i >= 0 && i < items.length; i += dir) {
|
|
77
|
+
if (!items[i]?.disabled) return i
|
|
78
|
+
}
|
|
79
|
+
return -1
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function handleKeydown(e: KeyboardEvent, index: number) {
|
|
83
|
+
const horizontal = orientation === 'horizontal'
|
|
84
|
+
const nextKey = horizontal ? 'ArrowRight' : 'ArrowDown'
|
|
85
|
+
const prevKey = horizontal ? 'ArrowLeft' : 'ArrowUp'
|
|
86
|
+
|
|
87
|
+
let target = -1
|
|
88
|
+
if (e.key === nextKey) target = findEnabled(index + 1, 1)
|
|
89
|
+
else if (e.key === prevKey) target = findEnabled(index - 1, -1)
|
|
90
|
+
else if (e.key === 'Home') target = findEnabled(0, 1)
|
|
91
|
+
else if (e.key === 'End') target = findEnabled(items.length - 1, -1)
|
|
92
|
+
else return
|
|
93
|
+
|
|
94
|
+
e.preventDefault()
|
|
95
|
+
if (target >= 0) triggers[target]?.focus()
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const apiInstance: StepperApi = {
|
|
99
|
+
next() {
|
|
100
|
+
if (activeIndex >= items.length - 1) return
|
|
101
|
+
const target = items[activeIndex + 1]
|
|
102
|
+
if (!target) return
|
|
103
|
+
setValue(getItemValue(target, activeIndex + 1))
|
|
104
|
+
},
|
|
105
|
+
prev() {
|
|
106
|
+
if (activeIndex <= 0) return
|
|
107
|
+
const target = items[activeIndex - 1]
|
|
108
|
+
if (!target) return
|
|
109
|
+
setValue(getItemValue(target, activeIndex - 1))
|
|
110
|
+
},
|
|
111
|
+
goTo(next) {
|
|
112
|
+
setValue(next)
|
|
113
|
+
},
|
|
114
|
+
get hasNext() {
|
|
115
|
+
return activeIndex >= 0 && activeIndex < items.length - 1
|
|
116
|
+
},
|
|
117
|
+
get hasPrev() {
|
|
118
|
+
return activeIndex > 0
|
|
119
|
+
},
|
|
120
|
+
get activeIndex() {
|
|
121
|
+
return activeIndex
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
$effect.pre(() => {
|
|
126
|
+
api = apiInstance
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
const variantSlots = $derived(stepperVariants({ orientation, size, color }))
|
|
130
|
+
|
|
131
|
+
type ItemUi = StepperItem['ui']
|
|
132
|
+
|
|
133
|
+
const classes = $derived.by(() => {
|
|
134
|
+
const c = config.slots
|
|
135
|
+
const slots = variantSlots
|
|
136
|
+
const u = ui ?? {}
|
|
137
|
+
|
|
138
|
+
const _item = slots.item({ class: [c.item, u.item] })
|
|
139
|
+
const _trigger = slots.trigger({ class: [c.trigger, u.trigger] })
|
|
140
|
+
const _container = slots.container({ class: [c.container, u.container] })
|
|
141
|
+
const _indicator = slots.indicator({ class: [c.indicator, u.indicator] })
|
|
142
|
+
const _separator = slots.separator({ class: [c.separator, u.separator] })
|
|
143
|
+
const _wrapper = slots.wrapper({ class: [c.wrapper, u.wrapper] })
|
|
144
|
+
const _title = slots.title({ class: [c.title, u.title] })
|
|
145
|
+
const _description = slots.description({ class: [c.description, u.description] })
|
|
146
|
+
const _content = slots.content({ class: [c.content, u.content] })
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
root: slots.root({ class: [c.root, className, u.root] }),
|
|
150
|
+
list: slots.list({ class: [c.list, u.list] }),
|
|
151
|
+
item: (itemClass?: ClassNameValue, itemUi?: ItemUi) =>
|
|
152
|
+
itemClass || itemUi
|
|
153
|
+
? slots.item({ class: [c.item, u.item, itemUi?.item, itemClass] })
|
|
154
|
+
: _item,
|
|
155
|
+
trigger: (itemUi?: ItemUi) =>
|
|
156
|
+
itemUi
|
|
157
|
+
? slots.trigger({ class: [c.trigger, u.trigger, itemUi.trigger] })
|
|
158
|
+
: _trigger,
|
|
159
|
+
container: (itemUi?: ItemUi) =>
|
|
160
|
+
itemUi
|
|
161
|
+
? slots.container({ class: [c.container, u.container, itemUi.container] })
|
|
162
|
+
: _container,
|
|
163
|
+
indicator: (itemUi?: ItemUi) =>
|
|
164
|
+
itemUi
|
|
165
|
+
? slots.indicator({ class: [c.indicator, u.indicator, itemUi.indicator] })
|
|
166
|
+
: _indicator,
|
|
167
|
+
separator: (itemUi?: ItemUi) =>
|
|
168
|
+
itemUi
|
|
169
|
+
? slots.separator({ class: [c.separator, u.separator, itemUi.separator] })
|
|
170
|
+
: _separator,
|
|
171
|
+
wrapper: (itemUi?: ItemUi) =>
|
|
172
|
+
itemUi
|
|
173
|
+
? slots.wrapper({ class: [c.wrapper, u.wrapper, itemUi.wrapper] })
|
|
174
|
+
: _wrapper,
|
|
175
|
+
title: (itemUi?: ItemUi) =>
|
|
176
|
+
itemUi ? slots.title({ class: [c.title, u.title, itemUi.title] }) : _title,
|
|
177
|
+
description: (itemUi?: ItemUi) =>
|
|
178
|
+
itemUi
|
|
179
|
+
? slots.description({
|
|
180
|
+
class: [c.description, u.description, itemUi.description]
|
|
181
|
+
})
|
|
182
|
+
: _description,
|
|
183
|
+
content: (itemUi?: ItemUi) =>
|
|
184
|
+
itemUi ? slots.content({ class: [c.content, u.content, itemUi.content] }) : _content
|
|
185
|
+
}
|
|
186
|
+
})
|
|
187
|
+
</script>
|
|
188
|
+
|
|
189
|
+
<svelte:element
|
|
190
|
+
this={as}
|
|
191
|
+
bind:this={ref}
|
|
192
|
+
class={classes.root}
|
|
193
|
+
data-orientation={orientation}
|
|
194
|
+
{...restProps}
|
|
195
|
+
>
|
|
196
|
+
<ol class={classes.list}>
|
|
197
|
+
{#each items as item, index (item.value ?? index)}
|
|
198
|
+
{@const state = getState(index)}
|
|
199
|
+
{@const number = index + 1}
|
|
200
|
+
{@const active = state === 'active'}
|
|
201
|
+
{@const itemDisabled = disabled || item.disabled || !canActivate(index)}
|
|
202
|
+
{@const slotProps = { item, index, number, state, active }}
|
|
203
|
+
{@const hasVisibleText = !!(
|
|
204
|
+
titleSlot ||
|
|
205
|
+
descriptionSlot ||
|
|
206
|
+
item.title ||
|
|
207
|
+
item.description
|
|
208
|
+
)}
|
|
209
|
+
<li
|
|
210
|
+
class={classes.item(item.class, item.ui)}
|
|
211
|
+
data-state={state}
|
|
212
|
+
data-orientation={orientation}
|
|
213
|
+
data-stepper-item=""
|
|
214
|
+
>
|
|
215
|
+
<button
|
|
216
|
+
type="button"
|
|
217
|
+
bind:this={triggers[index]}
|
|
218
|
+
class={classes.trigger(item.ui)}
|
|
219
|
+
disabled={itemDisabled}
|
|
220
|
+
aria-current={active ? 'step' : undefined}
|
|
221
|
+
aria-label={hasVisibleText ? undefined : `Step ${number}`}
|
|
222
|
+
tabindex={active ? 0 : -1}
|
|
223
|
+
onclick={() => handleClick(item, index)}
|
|
224
|
+
onkeydown={(e) => handleKeydown(e, index)}
|
|
225
|
+
>
|
|
226
|
+
<span class={classes.container(item.ui)}>
|
|
227
|
+
{#if indicatorSlot}
|
|
228
|
+
{@render indicatorSlot(slotProps)}
|
|
229
|
+
{:else}
|
|
230
|
+
<span
|
|
231
|
+
class={classes.indicator(item.ui)}
|
|
232
|
+
data-stepper-indicator=""
|
|
233
|
+
aria-hidden="true"
|
|
234
|
+
>
|
|
235
|
+
{#if item.icon}
|
|
236
|
+
<Icon name={item.icon} />
|
|
237
|
+
{:else if state === 'completed'}
|
|
238
|
+
<Icon name="lucide:check" />
|
|
239
|
+
{:else}
|
|
240
|
+
{number}
|
|
241
|
+
{/if}
|
|
242
|
+
</span>
|
|
243
|
+
{/if}
|
|
244
|
+
|
|
245
|
+
{#if index < items.length - 1}
|
|
246
|
+
<span
|
|
247
|
+
class={classes.separator(item.ui)}
|
|
248
|
+
data-stepper-separator=""
|
|
249
|
+
aria-hidden="true"
|
|
250
|
+
></span>
|
|
251
|
+
{/if}
|
|
252
|
+
</span>
|
|
253
|
+
|
|
254
|
+
{#if hasVisibleText}
|
|
255
|
+
<span class={classes.wrapper(item.ui)}>
|
|
256
|
+
{#if titleSlot}
|
|
257
|
+
{@render titleSlot(slotProps)}
|
|
258
|
+
{:else if item.title}
|
|
259
|
+
<span class={classes.title(item.ui)}>{item.title}</span>
|
|
260
|
+
{/if}
|
|
261
|
+
|
|
262
|
+
{#if descriptionSlot}
|
|
263
|
+
{@render descriptionSlot(slotProps)}
|
|
264
|
+
{:else if item.description}
|
|
265
|
+
<span class={classes.description(item.ui)}>
|
|
266
|
+
{item.description}
|
|
267
|
+
</span>
|
|
268
|
+
{/if}
|
|
269
|
+
</span>
|
|
270
|
+
{/if}
|
|
271
|
+
</button>
|
|
272
|
+
</li>
|
|
273
|
+
{/each}
|
|
274
|
+
</ol>
|
|
275
|
+
|
|
276
|
+
{#if showContent}
|
|
277
|
+
{#each items as item, index (item.value ?? index)}
|
|
278
|
+
{@const state = getState(index)}
|
|
279
|
+
{#if state === 'active' && (body || item.content !== undefined)}
|
|
280
|
+
{@const number = index + 1}
|
|
281
|
+
{@const slotProps = { item, index, number, state, active: true }}
|
|
282
|
+
<div class={classes.content(item.ui)} role="region" data-stepper-content="">
|
|
283
|
+
{#if body}
|
|
284
|
+
{@render body(slotProps)}
|
|
285
|
+
{:else}
|
|
286
|
+
{item.content}
|
|
287
|
+
{/if}
|
|
288
|
+
</div>
|
|
289
|
+
{/if}
|
|
290
|
+
{/each}
|
|
291
|
+
{/if}
|
|
292
|
+
</svelte:element>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Stepper } from './Stepper.svelte';
|