@placeholderco/placeholder-ui 1.0.3 → 1.0.6
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/LICENSE +26 -26
- package/README.md +179 -179
- package/dist/display/Alert.svelte +179 -179
- package/dist/display/Avatar.svelte +166 -166
- package/dist/display/LinkCollection.svelte +161 -161
- package/dist/display/Paper.svelte +118 -118
- package/dist/form/Autocomplete.svelte +223 -191
- package/dist/form/Autocomplete.svelte.d.ts +3 -1
- package/dist/form/AutocompleteMulti.svelte +356 -0
- package/dist/form/AutocompleteMulti.svelte.d.ts +28 -0
- package/dist/form/Checkbox.svelte +201 -201
- package/dist/form/Chips.svelte +128 -128
- package/dist/form/ComboBox.svelte +158 -158
- package/dist/form/ComboBox.svelte.d.ts +1 -1
- package/dist/form/ComboBoxItemBuilder.svelte +460 -460
- package/dist/form/ComboBoxMulti.svelte +197 -197
- package/dist/form/ComboBoxMulti.svelte.d.ts +1 -1
- package/dist/form/CronBuilder.svelte +693 -693
- package/dist/form/DatePicker.svelte +672 -672
- package/dist/form/DateTimePicker.svelte +712 -712
- package/dist/form/FileInput.svelte +235 -235
- package/dist/form/FormGroup.svelte +68 -68
- package/dist/form/Number.svelte +238 -238
- package/dist/form/PasswordInput.svelte +252 -252
- package/dist/form/RadioGroup.svelte +210 -210
- package/dist/form/Rating.svelte +235 -235
- package/dist/form/SegmentedControl.svelte +149 -149
- package/dist/form/Select.svelte +590 -590
- package/dist/form/Select.svelte.d.ts +1 -1
- package/dist/form/SelectMulti.svelte +613 -613
- package/dist/form/SelectMulti.svelte.d.ts +1 -1
- package/dist/form/Slider.svelte +358 -358
- package/dist/form/Switch.svelte +147 -147
- package/dist/form/TextArea.svelte +148 -148
- package/dist/form/Textbox.svelte +228 -228
- package/dist/form/TimePicker.svelte +267 -267
- package/dist/icon/Icon.svelte +52 -52
- package/dist/icon/alert-octagon.svg +5 -5
- package/dist/icon/alert-triangle.svg +5 -5
- package/dist/icon/archive.svg +1 -1
- package/dist/icon/arrow-down.svg +1 -1
- package/dist/icon/arrow-left.svg +1 -1
- package/dist/icon/arrow-right.svg +1 -1
- package/dist/icon/arrow-up.svg +1 -1
- package/dist/icon/at.svg +1 -1
- package/dist/icon/bell.svg +1 -1
- package/dist/icon/bookmark.svg +1 -1
- package/dist/icon/calendar.svg +1 -1
- package/dist/icon/camera.svg +1 -1
- package/dist/icon/chart-bar.svg +1 -1
- package/dist/icon/chart-line.svg +1 -1
- package/dist/icon/chart-pie.svg +1 -1
- package/dist/icon/checkbox.svg +1 -1
- package/dist/icon/checklist.svg +1 -1
- package/dist/icon/circle-check.svg +1 -1
- package/dist/icon/circle-x.svg +1 -1
- package/dist/icon/clock.svg +1 -1
- package/dist/icon/credit-card.svg +1 -1
- package/dist/icon/dots-vertical.svg +1 -1
- package/dist/icon/dots.svg +1 -1
- package/dist/icon/external-link.svg +1 -1
- package/dist/icon/eye-off.svg +1 -1
- package/dist/icon/eye.svg +1 -1
- package/dist/icon/filter.svg +1 -1
- package/dist/icon/fingerprint.svg +1 -1
- package/dist/icon/flag.svg +1 -1
- package/dist/icon/heart.svg +1 -1
- package/dist/icon/home.svg +1 -1
- package/dist/icon/key.svg +1 -1
- package/dist/icon/list-check.svg +1 -1
- package/dist/icon/login.svg +1 -1
- package/dist/icon/logout.svg +1 -1
- package/dist/icon/map-pin.svg +1 -1
- package/dist/icon/maximize.svg +1 -1
- package/dist/icon/microphone.svg +1 -1
- package/dist/icon/minimize.svg +1 -1
- package/dist/icon/note.svg +1 -1
- package/dist/icon/player-pause.svg +1 -1
- package/dist/icon/printer.svg +1 -1
- package/dist/icon/qrcode.svg +1 -1
- package/dist/icon/send.svg +1 -1
- package/dist/icon/settings.svg +1 -1
- package/dist/icon/share.svg +1 -1
- package/dist/icon/shopping-cart.svg +1 -1
- package/dist/icon/sort-ascending.svg +1 -1
- package/dist/icon/sort-descending.svg +1 -1
- package/dist/icon/star.svg +1 -1
- package/dist/icon/tag.svg +1 -1
- package/dist/icon/trending-down.svg +1 -1
- package/dist/icon/trending-up.svg +1 -1
- package/dist/icon/upload.svg +1 -1
- package/dist/icon/volume-off.svg +1 -1
- package/dist/icon/volume.svg +1 -1
- package/dist/icon/world.svg +1 -1
- package/dist/icon/zoom-in.svg +1 -1
- package/dist/icon/zoom-out.svg +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/layout/AppShell.svelte +169 -169
- package/dist/layout/CustomNavbar.svelte +61 -61
- package/dist/layout/Navbar.svelte +206 -206
- package/dist/layout/NavbarItemDisplay.svelte +29 -29
- package/dist/layout/Sidenav.svelte +712 -712
- package/dist/styles/components.css +199 -199
- package/dist/styles/dark.css +146 -146
- package/dist/styles/index.css +116 -116
- package/dist/styles/reset.css +110 -110
- package/dist/styles/semantic.css +86 -86
- package/dist/styles/tokens.css +203 -197
- package/dist/styles/utilities.css +523 -523
- package/dist/ui/Accordion.svelte +289 -289
- package/dist/ui/ActionIcon.svelte +76 -76
- package/dist/ui/Badge.svelte +329 -279
- package/dist/ui/Breadcrumbs.svelte +131 -131
- package/dist/ui/Button.svelte +432 -370
- package/dist/ui/ButtonVariant.d.ts +1 -1
- package/dist/ui/Dialog.svelte +307 -307
- package/dist/ui/Drawer.svelte +524 -524
- package/dist/ui/Dropdown.svelte +97 -97
- package/dist/ui/Dropzone.svelte +122 -122
- package/dist/ui/Link.svelte +32 -32
- package/dist/ui/Loader.svelte +70 -70
- package/dist/ui/LoadingOverlay.svelte +53 -53
- package/dist/ui/Pagination.svelte +135 -135
- package/dist/ui/Popover.svelte +225 -225
- package/dist/ui/Progress.svelte +191 -191
- package/dist/ui/RingProgress.svelte +141 -141
- package/dist/ui/Skeleton.svelte +85 -85
- package/dist/ui/Stepper.svelte +355 -355
- package/dist/ui/Table.svelte +345 -345
- package/dist/ui/Tabs.svelte +146 -146
- package/dist/ui/ThemeSwitcher.svelte +39 -39
- package/dist/ui/Timeline.svelte +225 -225
- package/dist/ui/Toaster.svelte +6 -6
- package/dist/ui/Tooltip.svelte +434 -434
- package/package.json +14 -14
package/dist/ui/Stepper.svelte
CHANGED
|
@@ -1,355 +1,355 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
3
|
-
import Icon from '../icon/Icon.svelte';
|
|
4
|
-
import { iconCheck } from '../icon/index.js';
|
|
5
|
-
|
|
6
|
-
interface StepItem {
|
|
7
|
-
label: string;
|
|
8
|
-
description?: string;
|
|
9
|
-
icon?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface Props {
|
|
13
|
-
active?: number;
|
|
14
|
-
steps?: StepItem[];
|
|
15
|
-
orientation?: 'horizontal' | 'vertical';
|
|
16
|
-
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
17
|
-
color?: 'primary' | 'secondary' | 'accent' | 'success';
|
|
18
|
-
iconSize?: number;
|
|
19
|
-
allowStepClick?: boolean;
|
|
20
|
-
allowStepSelect?: boolean;
|
|
21
|
-
completedIcon?: string;
|
|
22
|
-
class?: string;
|
|
23
|
-
onStepClick?: (step: number) => void;
|
|
24
|
-
stepContent?: Snippet<[number, StepItem]>;
|
|
25
|
-
children?: Snippet;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
let {
|
|
29
|
-
active = $bindable(0),
|
|
30
|
-
steps = [],
|
|
31
|
-
orientation = 'horizontal',
|
|
32
|
-
size = 'md',
|
|
33
|
-
color = 'primary',
|
|
34
|
-
iconSize = 24,
|
|
35
|
-
allowStepClick = false,
|
|
36
|
-
allowStepSelect = true,
|
|
37
|
-
completedIcon = undefined,
|
|
38
|
-
class: classes = '',
|
|
39
|
-
onStepClick,
|
|
40
|
-
stepContent,
|
|
41
|
-
children
|
|
42
|
-
}: Props = $props();
|
|
43
|
-
|
|
44
|
-
function handleStepClick(index: number) {
|
|
45
|
-
if (!allowStepClick && !allowStepSelect) return;
|
|
46
|
-
if (allowStepSelect && index <= active) {
|
|
47
|
-
active = index;
|
|
48
|
-
onStepClick?.(index);
|
|
49
|
-
} else if (allowStepClick) {
|
|
50
|
-
active = index;
|
|
51
|
-
onStepClick?.(index);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function getStepState(index: number): 'completed' | 'active' | 'pending' {
|
|
56
|
-
if (index < active) return 'completed';
|
|
57
|
-
if (index === active) return 'active';
|
|
58
|
-
return 'pending';
|
|
59
|
-
}
|
|
60
|
-
</script>
|
|
61
|
-
|
|
62
|
-
<div class="stepper orientation-{orientation} size-{size} color-{color} {classes}">
|
|
63
|
-
{#each steps as step, index (index)}
|
|
64
|
-
{@const state = getStepState(index)}
|
|
65
|
-
<div class="step {state}" class:clickable={allowStepClick || (allowStepSelect && index <= active)}>
|
|
66
|
-
<button
|
|
67
|
-
type="button"
|
|
68
|
-
class="step-button"
|
|
69
|
-
disabled={!allowStepClick && (!allowStepSelect || index > active)}
|
|
70
|
-
onclick={() => handleStepClick(index)}
|
|
71
|
-
aria-current={state === 'active' ? 'step' : undefined}
|
|
72
|
-
>
|
|
73
|
-
<div class="step-icon-wrapper">
|
|
74
|
-
<div class="step-icon">
|
|
75
|
-
{#if state === 'completed'}
|
|
76
|
-
{#if completedIcon}
|
|
77
|
-
<Icon svg={completedIcon} size="{iconSize * 0.6}px" />
|
|
78
|
-
{:else}
|
|
79
|
-
<Icon svg={iconCheck} size="{iconSize * 0.6}px" />
|
|
80
|
-
{/if}
|
|
81
|
-
{:else if step.icon}
|
|
82
|
-
<Icon svg={step.icon} size="{iconSize * 0.6}px" />
|
|
83
|
-
{:else}
|
|
84
|
-
<span class="step-number">{index + 1}</span>
|
|
85
|
-
{/if}
|
|
86
|
-
</div>
|
|
87
|
-
</div>
|
|
88
|
-
<div class="step-content">
|
|
89
|
-
<div class="step-label">{step.label}</div>
|
|
90
|
-
{#if step.description}
|
|
91
|
-
<div class="step-description">{step.description}</div>
|
|
92
|
-
{/if}
|
|
93
|
-
</div>
|
|
94
|
-
</button>
|
|
95
|
-
{#if index < steps.length - 1}
|
|
96
|
-
<div class="step-separator" class:completed={index < active}></div>
|
|
97
|
-
{/if}
|
|
98
|
-
</div>
|
|
99
|
-
{/each}
|
|
100
|
-
{#if children}
|
|
101
|
-
<div class="step-panel">
|
|
102
|
-
{@render children()}
|
|
103
|
-
</div>
|
|
104
|
-
{/if}
|
|
105
|
-
</div>
|
|
106
|
-
|
|
107
|
-
<style>
|
|
108
|
-
.stepper {
|
|
109
|
-
display: flex;
|
|
110
|
-
width: 100%;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/* Orientation */
|
|
114
|
-
.orientation-horizontal {
|
|
115
|
-
flex-direction: row;
|
|
116
|
-
align-items: flex-start;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
.orientation-vertical {
|
|
120
|
-
flex-direction: column;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
.step {
|
|
124
|
-
display: flex;
|
|
125
|
-
position: relative;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.orientation-horizontal .step {
|
|
129
|
-
flex: 1;
|
|
130
|
-
flex-direction: column;
|
|
131
|
-
align-items: center;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
.orientation-vertical .step {
|
|
135
|
-
flex-direction: row;
|
|
136
|
-
align-items: flex-start;
|
|
137
|
-
padding-bottom: var(--pui-spacing-6);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
.step-button {
|
|
141
|
-
display: flex;
|
|
142
|
-
background: none;
|
|
143
|
-
border: none;
|
|
144
|
-
cursor: default;
|
|
145
|
-
padding: 0;
|
|
146
|
-
text-align: center;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
.step.clickable .step-button {
|
|
150
|
-
cursor: pointer;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
.orientation-horizontal .step-button {
|
|
154
|
-
flex-direction: column;
|
|
155
|
-
align-items: center;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
.orientation-vertical .step-button {
|
|
159
|
-
flex-direction: row;
|
|
160
|
-
align-items: flex-start;
|
|
161
|
-
gap: var(--pui-spacing-3);
|
|
162
|
-
text-align: left;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
.step-icon-wrapper {
|
|
166
|
-
position: relative;
|
|
167
|
-
z-index: 1;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
.step-icon {
|
|
171
|
-
display: flex;
|
|
172
|
-
align-items: center;
|
|
173
|
-
justify-content: center;
|
|
174
|
-
border-radius: 50%;
|
|
175
|
-
background-color: var(--pui-color-gray-200);
|
|
176
|
-
color: var(--pui-color-gray-600);
|
|
177
|
-
transition: all var(--pui-transition-fast) var(--pui-ease-in-out);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
:global(.dark) .step-icon {
|
|
181
|
-
background-color: var(--pui-color-dark-border);
|
|
182
|
-
color: var(--pui-color-gray-400);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
.step.active .step-icon {
|
|
186
|
-
background-color: var(--step-color, var(--pui-color-primary));
|
|
187
|
-
color: var(--pui-color-white);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
.step.completed .step-icon {
|
|
191
|
-
background-color: var(--step-color, var(--pui-color-primary));
|
|
192
|
-
color: var(--pui-color-white);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/* Sizes */
|
|
196
|
-
.size-xs .step-icon {
|
|
197
|
-
width: 24px;
|
|
198
|
-
height: 24px;
|
|
199
|
-
font-size: var(--pui-font-size-xs);
|
|
200
|
-
}
|
|
201
|
-
.size-sm .step-icon {
|
|
202
|
-
width: 32px;
|
|
203
|
-
height: 32px;
|
|
204
|
-
font-size: var(--pui-font-size-sm);
|
|
205
|
-
}
|
|
206
|
-
.size-md .step-icon {
|
|
207
|
-
width: 40px;
|
|
208
|
-
height: 40px;
|
|
209
|
-
font-size: var(--pui-font-size-base);
|
|
210
|
-
}
|
|
211
|
-
.size-lg .step-icon {
|
|
212
|
-
width: 48px;
|
|
213
|
-
height: 48px;
|
|
214
|
-
font-size: var(--pui-font-size-md);
|
|
215
|
-
}
|
|
216
|
-
.size-xl .step-icon {
|
|
217
|
-
width: 56px;
|
|
218
|
-
height: 56px;
|
|
219
|
-
font-size: var(--pui-font-size-lg);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/* Colors */
|
|
223
|
-
.color-primary {
|
|
224
|
-
--step-color: var(--pui-color-primary);
|
|
225
|
-
}
|
|
226
|
-
.color-secondary {
|
|
227
|
-
--step-color: var(--pui-color-secondary);
|
|
228
|
-
}
|
|
229
|
-
.color-accent {
|
|
230
|
-
--step-color: var(--pui-color-accent);
|
|
231
|
-
}
|
|
232
|
-
.color-success {
|
|
233
|
-
--step-color: var(--pui-color-success);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
.step-number {
|
|
237
|
-
font-weight: var(--pui-font-weight-semibold);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
.step-content {
|
|
241
|
-
margin-top: var(--pui-spacing-2);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
.orientation-vertical .step-content {
|
|
245
|
-
margin-top: 0;
|
|
246
|
-
padding-top: var(--pui-spacing-1);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
.step-label {
|
|
250
|
-
font-weight: var(--pui-font-weight-medium);
|
|
251
|
-
color: var(--pui-color-gray-600);
|
|
252
|
-
font-size: var(--pui-font-size-sm);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
:global(.dark) .step-label {
|
|
256
|
-
color: var(--pui-color-gray-400);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
.step.active .step-label,
|
|
260
|
-
.step.completed .step-label {
|
|
261
|
-
color: var(--pui-color-gray-900);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
:global(.dark) .step.active .step-label,
|
|
265
|
-
:global(.dark) .step.completed .step-label {
|
|
266
|
-
color: var(--pui-color-gray-100);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
.step-description {
|
|
270
|
-
font-size: var(--pui-font-size-xs);
|
|
271
|
-
color: var(--pui-color-gray-500);
|
|
272
|
-
margin-top: var(--pui-spacing-0_5);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
:global(.dark) .step-description {
|
|
276
|
-
color: var(--pui-color-gray-500);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/* Separator */
|
|
280
|
-
.step-separator {
|
|
281
|
-
background-color: var(--pui-color-gray-300);
|
|
282
|
-
transition: background-color var(--pui-transition-fast) var(--pui-ease-in-out);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
:global(.dark) .step-separator {
|
|
286
|
-
background-color: var(--pui-color-dark-border);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
.step-separator.completed {
|
|
290
|
-
background-color: var(--step-color, var(--pui-color-primary));
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
.orientation-horizontal .step-separator {
|
|
294
|
-
position: absolute;
|
|
295
|
-
top: 20px;
|
|
296
|
-
left: calc(50% + 24px);
|
|
297
|
-
right: calc(-50% + 24px);
|
|
298
|
-
height: 2px;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
.size-xs.orientation-horizontal .step-separator {
|
|
302
|
-
top: 12px;
|
|
303
|
-
left: calc(50% + 16px);
|
|
304
|
-
right: calc(-50% + 16px);
|
|
305
|
-
}
|
|
306
|
-
.size-sm.orientation-horizontal .step-separator {
|
|
307
|
-
top: 16px;
|
|
308
|
-
left: calc(50% + 20px);
|
|
309
|
-
right: calc(-50% + 20px);
|
|
310
|
-
}
|
|
311
|
-
.size-lg.orientation-horizontal .step-separator {
|
|
312
|
-
top: 24px;
|
|
313
|
-
left: calc(50% + 28px);
|
|
314
|
-
right: calc(-50% + 28px);
|
|
315
|
-
}
|
|
316
|
-
.size-xl.orientation-horizontal .step-separator {
|
|
317
|
-
top: 28px;
|
|
318
|
-
left: calc(50% + 32px);
|
|
319
|
-
right: calc(-50% + 32px);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
.orientation-vertical .step-separator {
|
|
323
|
-
position: absolute;
|
|
324
|
-
left: 19px;
|
|
325
|
-
top: 44px;
|
|
326
|
-
bottom: 4px;
|
|
327
|
-
width: 2px;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
.size-xs.orientation-vertical .step-separator {
|
|
331
|
-
left: 11px;
|
|
332
|
-
top: 28px;
|
|
333
|
-
}
|
|
334
|
-
.size-sm.orientation-vertical .step-separator {
|
|
335
|
-
left: 15px;
|
|
336
|
-
top: 36px;
|
|
337
|
-
}
|
|
338
|
-
.size-lg.orientation-vertical .step-separator {
|
|
339
|
-
left: 23px;
|
|
340
|
-
top: 52px;
|
|
341
|
-
}
|
|
342
|
-
.size-xl.orientation-vertical .step-separator {
|
|
343
|
-
left: 27px;
|
|
344
|
-
top: 60px;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
.step-panel {
|
|
348
|
-
margin-top: var(--pui-spacing-6);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
.orientation-vertical .step-panel {
|
|
352
|
-
margin-top: 0;
|
|
353
|
-
margin-left: var(--pui-spacing-6);
|
|
354
|
-
}
|
|
355
|
-
</style>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import Icon from '../icon/Icon.svelte';
|
|
4
|
+
import { iconCheck } from '../icon/index.js';
|
|
5
|
+
|
|
6
|
+
interface StepItem {
|
|
7
|
+
label: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
icon?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface Props {
|
|
13
|
+
active?: number;
|
|
14
|
+
steps?: StepItem[];
|
|
15
|
+
orientation?: 'horizontal' | 'vertical';
|
|
16
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
17
|
+
color?: 'primary' | 'secondary' | 'accent' | 'success';
|
|
18
|
+
iconSize?: number;
|
|
19
|
+
allowStepClick?: boolean;
|
|
20
|
+
allowStepSelect?: boolean;
|
|
21
|
+
completedIcon?: string;
|
|
22
|
+
class?: string;
|
|
23
|
+
onStepClick?: (step: number) => void;
|
|
24
|
+
stepContent?: Snippet<[number, StepItem]>;
|
|
25
|
+
children?: Snippet;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let {
|
|
29
|
+
active = $bindable(0),
|
|
30
|
+
steps = [],
|
|
31
|
+
orientation = 'horizontal',
|
|
32
|
+
size = 'md',
|
|
33
|
+
color = 'primary',
|
|
34
|
+
iconSize = 24,
|
|
35
|
+
allowStepClick = false,
|
|
36
|
+
allowStepSelect = true,
|
|
37
|
+
completedIcon = undefined,
|
|
38
|
+
class: classes = '',
|
|
39
|
+
onStepClick,
|
|
40
|
+
stepContent,
|
|
41
|
+
children
|
|
42
|
+
}: Props = $props();
|
|
43
|
+
|
|
44
|
+
function handleStepClick(index: number) {
|
|
45
|
+
if (!allowStepClick && !allowStepSelect) return;
|
|
46
|
+
if (allowStepSelect && index <= active) {
|
|
47
|
+
active = index;
|
|
48
|
+
onStepClick?.(index);
|
|
49
|
+
} else if (allowStepClick) {
|
|
50
|
+
active = index;
|
|
51
|
+
onStepClick?.(index);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function getStepState(index: number): 'completed' | 'active' | 'pending' {
|
|
56
|
+
if (index < active) return 'completed';
|
|
57
|
+
if (index === active) return 'active';
|
|
58
|
+
return 'pending';
|
|
59
|
+
}
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<div class="stepper orientation-{orientation} size-{size} color-{color} {classes}">
|
|
63
|
+
{#each steps as step, index (index)}
|
|
64
|
+
{@const state = getStepState(index)}
|
|
65
|
+
<div class="step {state}" class:clickable={allowStepClick || (allowStepSelect && index <= active)}>
|
|
66
|
+
<button
|
|
67
|
+
type="button"
|
|
68
|
+
class="step-button"
|
|
69
|
+
disabled={!allowStepClick && (!allowStepSelect || index > active)}
|
|
70
|
+
onclick={() => handleStepClick(index)}
|
|
71
|
+
aria-current={state === 'active' ? 'step' : undefined}
|
|
72
|
+
>
|
|
73
|
+
<div class="step-icon-wrapper">
|
|
74
|
+
<div class="step-icon">
|
|
75
|
+
{#if state === 'completed'}
|
|
76
|
+
{#if completedIcon}
|
|
77
|
+
<Icon svg={completedIcon} size="{iconSize * 0.6}px" />
|
|
78
|
+
{:else}
|
|
79
|
+
<Icon svg={iconCheck} size="{iconSize * 0.6}px" />
|
|
80
|
+
{/if}
|
|
81
|
+
{:else if step.icon}
|
|
82
|
+
<Icon svg={step.icon} size="{iconSize * 0.6}px" />
|
|
83
|
+
{:else}
|
|
84
|
+
<span class="step-number">{index + 1}</span>
|
|
85
|
+
{/if}
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
<div class="step-content">
|
|
89
|
+
<div class="step-label">{step.label}</div>
|
|
90
|
+
{#if step.description}
|
|
91
|
+
<div class="step-description">{step.description}</div>
|
|
92
|
+
{/if}
|
|
93
|
+
</div>
|
|
94
|
+
</button>
|
|
95
|
+
{#if index < steps.length - 1}
|
|
96
|
+
<div class="step-separator" class:completed={index < active}></div>
|
|
97
|
+
{/if}
|
|
98
|
+
</div>
|
|
99
|
+
{/each}
|
|
100
|
+
{#if children}
|
|
101
|
+
<div class="step-panel">
|
|
102
|
+
{@render children()}
|
|
103
|
+
</div>
|
|
104
|
+
{/if}
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
<style>
|
|
108
|
+
.stepper {
|
|
109
|
+
display: flex;
|
|
110
|
+
width: 100%;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* Orientation */
|
|
114
|
+
.orientation-horizontal {
|
|
115
|
+
flex-direction: row;
|
|
116
|
+
align-items: flex-start;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.orientation-vertical {
|
|
120
|
+
flex-direction: column;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.step {
|
|
124
|
+
display: flex;
|
|
125
|
+
position: relative;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.orientation-horizontal .step {
|
|
129
|
+
flex: 1;
|
|
130
|
+
flex-direction: column;
|
|
131
|
+
align-items: center;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.orientation-vertical .step {
|
|
135
|
+
flex-direction: row;
|
|
136
|
+
align-items: flex-start;
|
|
137
|
+
padding-bottom: var(--pui-spacing-6);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.step-button {
|
|
141
|
+
display: flex;
|
|
142
|
+
background: none;
|
|
143
|
+
border: none;
|
|
144
|
+
cursor: default;
|
|
145
|
+
padding: 0;
|
|
146
|
+
text-align: center;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.step.clickable .step-button {
|
|
150
|
+
cursor: pointer;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.orientation-horizontal .step-button {
|
|
154
|
+
flex-direction: column;
|
|
155
|
+
align-items: center;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.orientation-vertical .step-button {
|
|
159
|
+
flex-direction: row;
|
|
160
|
+
align-items: flex-start;
|
|
161
|
+
gap: var(--pui-spacing-3);
|
|
162
|
+
text-align: left;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.step-icon-wrapper {
|
|
166
|
+
position: relative;
|
|
167
|
+
z-index: 1;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.step-icon {
|
|
171
|
+
display: flex;
|
|
172
|
+
align-items: center;
|
|
173
|
+
justify-content: center;
|
|
174
|
+
border-radius: 50%;
|
|
175
|
+
background-color: var(--pui-color-gray-200);
|
|
176
|
+
color: var(--pui-color-gray-600);
|
|
177
|
+
transition: all var(--pui-transition-fast) var(--pui-ease-in-out);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
:global(.dark) .step-icon {
|
|
181
|
+
background-color: var(--pui-color-dark-border);
|
|
182
|
+
color: var(--pui-color-gray-400);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.step.active .step-icon {
|
|
186
|
+
background-color: var(--step-color, var(--pui-color-primary));
|
|
187
|
+
color: var(--pui-color-white);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.step.completed .step-icon {
|
|
191
|
+
background-color: var(--step-color, var(--pui-color-primary));
|
|
192
|
+
color: var(--pui-color-white);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/* Sizes */
|
|
196
|
+
.size-xs .step-icon {
|
|
197
|
+
width: 24px;
|
|
198
|
+
height: 24px;
|
|
199
|
+
font-size: var(--pui-font-size-xs);
|
|
200
|
+
}
|
|
201
|
+
.size-sm .step-icon {
|
|
202
|
+
width: 32px;
|
|
203
|
+
height: 32px;
|
|
204
|
+
font-size: var(--pui-font-size-sm);
|
|
205
|
+
}
|
|
206
|
+
.size-md .step-icon {
|
|
207
|
+
width: 40px;
|
|
208
|
+
height: 40px;
|
|
209
|
+
font-size: var(--pui-font-size-base);
|
|
210
|
+
}
|
|
211
|
+
.size-lg .step-icon {
|
|
212
|
+
width: 48px;
|
|
213
|
+
height: 48px;
|
|
214
|
+
font-size: var(--pui-font-size-md);
|
|
215
|
+
}
|
|
216
|
+
.size-xl .step-icon {
|
|
217
|
+
width: 56px;
|
|
218
|
+
height: 56px;
|
|
219
|
+
font-size: var(--pui-font-size-lg);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/* Colors */
|
|
223
|
+
.color-primary {
|
|
224
|
+
--step-color: var(--pui-color-primary);
|
|
225
|
+
}
|
|
226
|
+
.color-secondary {
|
|
227
|
+
--step-color: var(--pui-color-secondary);
|
|
228
|
+
}
|
|
229
|
+
.color-accent {
|
|
230
|
+
--step-color: var(--pui-color-accent);
|
|
231
|
+
}
|
|
232
|
+
.color-success {
|
|
233
|
+
--step-color: var(--pui-color-success);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.step-number {
|
|
237
|
+
font-weight: var(--pui-font-weight-semibold);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.step-content {
|
|
241
|
+
margin-top: var(--pui-spacing-2);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.orientation-vertical .step-content {
|
|
245
|
+
margin-top: 0;
|
|
246
|
+
padding-top: var(--pui-spacing-1);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.step-label {
|
|
250
|
+
font-weight: var(--pui-font-weight-medium);
|
|
251
|
+
color: var(--pui-color-gray-600);
|
|
252
|
+
font-size: var(--pui-font-size-sm);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
:global(.dark) .step-label {
|
|
256
|
+
color: var(--pui-color-gray-400);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.step.active .step-label,
|
|
260
|
+
.step.completed .step-label {
|
|
261
|
+
color: var(--pui-color-gray-900);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
:global(.dark) .step.active .step-label,
|
|
265
|
+
:global(.dark) .step.completed .step-label {
|
|
266
|
+
color: var(--pui-color-gray-100);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.step-description {
|
|
270
|
+
font-size: var(--pui-font-size-xs);
|
|
271
|
+
color: var(--pui-color-gray-500);
|
|
272
|
+
margin-top: var(--pui-spacing-0_5);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
:global(.dark) .step-description {
|
|
276
|
+
color: var(--pui-color-gray-500);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/* Separator */
|
|
280
|
+
.step-separator {
|
|
281
|
+
background-color: var(--pui-color-gray-300);
|
|
282
|
+
transition: background-color var(--pui-transition-fast) var(--pui-ease-in-out);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
:global(.dark) .step-separator {
|
|
286
|
+
background-color: var(--pui-color-dark-border);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.step-separator.completed {
|
|
290
|
+
background-color: var(--step-color, var(--pui-color-primary));
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.orientation-horizontal .step-separator {
|
|
294
|
+
position: absolute;
|
|
295
|
+
top: 20px;
|
|
296
|
+
left: calc(50% + 24px);
|
|
297
|
+
right: calc(-50% + 24px);
|
|
298
|
+
height: 2px;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.size-xs.orientation-horizontal .step-separator {
|
|
302
|
+
top: 12px;
|
|
303
|
+
left: calc(50% + 16px);
|
|
304
|
+
right: calc(-50% + 16px);
|
|
305
|
+
}
|
|
306
|
+
.size-sm.orientation-horizontal .step-separator {
|
|
307
|
+
top: 16px;
|
|
308
|
+
left: calc(50% + 20px);
|
|
309
|
+
right: calc(-50% + 20px);
|
|
310
|
+
}
|
|
311
|
+
.size-lg.orientation-horizontal .step-separator {
|
|
312
|
+
top: 24px;
|
|
313
|
+
left: calc(50% + 28px);
|
|
314
|
+
right: calc(-50% + 28px);
|
|
315
|
+
}
|
|
316
|
+
.size-xl.orientation-horizontal .step-separator {
|
|
317
|
+
top: 28px;
|
|
318
|
+
left: calc(50% + 32px);
|
|
319
|
+
right: calc(-50% + 32px);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.orientation-vertical .step-separator {
|
|
323
|
+
position: absolute;
|
|
324
|
+
left: 19px;
|
|
325
|
+
top: 44px;
|
|
326
|
+
bottom: 4px;
|
|
327
|
+
width: 2px;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.size-xs.orientation-vertical .step-separator {
|
|
331
|
+
left: 11px;
|
|
332
|
+
top: 28px;
|
|
333
|
+
}
|
|
334
|
+
.size-sm.orientation-vertical .step-separator {
|
|
335
|
+
left: 15px;
|
|
336
|
+
top: 36px;
|
|
337
|
+
}
|
|
338
|
+
.size-lg.orientation-vertical .step-separator {
|
|
339
|
+
left: 23px;
|
|
340
|
+
top: 52px;
|
|
341
|
+
}
|
|
342
|
+
.size-xl.orientation-vertical .step-separator {
|
|
343
|
+
left: 27px;
|
|
344
|
+
top: 60px;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.step-panel {
|
|
348
|
+
margin-top: var(--pui-spacing-6);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
.orientation-vertical .step-panel {
|
|
352
|
+
margin-top: 0;
|
|
353
|
+
margin-left: var(--pui-spacing-6);
|
|
354
|
+
}
|
|
355
|
+
</style>
|