@iroco/ui 1.10.2 → 1.10.3

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.
@@ -5,8 +5,12 @@
5
5
 
6
6
  https://github.com/shaozi/svelte-steps
7
7
  -->
8
- <script>
9
- export let stroke = 'currentColor';
8
+ <script lang="ts">
9
+ interface Props {
10
+ stroke?: string;
11
+ }
12
+
13
+ let { stroke = 'currentColor' }: Props = $props();
10
14
  </script>
11
15
 
12
16
  <svg
@@ -1,26 +1,6 @@
1
- export default Alert;
2
- type Alert = SvelteComponent<{
3
- stroke?: string | undefined;
4
- }, {
5
- [evt: string]: CustomEvent<any>;
6
- }, {}> & {
7
- $$bindings?: string | undefined;
8
- };
9
- declare const Alert: $$__sveltets_2_IsomorphicComponent<{
10
- stroke?: string | undefined;
11
- }, {
12
- [evt: string]: CustomEvent<any>;
13
- }, {}, {}, string>;
14
- interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
15
- new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
16
- $$bindings?: Bindings;
17
- } & Exports;
18
- (internal: unknown, props: Props & {
19
- $$events?: Events;
20
- $$slots?: Slots;
21
- }): Exports & {
22
- $set?: any;
23
- $on?: any;
24
- };
25
- z_$$bindings?: Bindings;
1
+ interface Props {
2
+ stroke?: string;
26
3
  }
4
+ declare const Alert: import("svelte").Component<Props, {}, "">;
5
+ type Alert = ReturnType<typeof Alert>;
6
+ export default Alert;
@@ -5,8 +5,12 @@
5
5
 
6
6
  https://github.com/shaozi/svelte-steps
7
7
  -->
8
- <script>
9
- export let stroke = 'currentColor';
8
+ <script lang="ts">
9
+ interface Props {
10
+ stroke?: string;
11
+ }
12
+
13
+ let { stroke = 'currentColor' }: Props = $props();
10
14
  </script>
11
15
 
12
16
  <svg
@@ -1,26 +1,6 @@
1
- export default Check;
2
- type Check = SvelteComponent<{
3
- stroke?: string | undefined;
4
- }, {
5
- [evt: string]: CustomEvent<any>;
6
- }, {}> & {
7
- $$bindings?: string | undefined;
8
- };
9
- declare const Check: $$__sveltets_2_IsomorphicComponent<{
10
- stroke?: string | undefined;
11
- }, {
12
- [evt: string]: CustomEvent<any>;
13
- }, {}, {}, string>;
14
- interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
15
- new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
16
- $$bindings?: Bindings;
17
- } & Exports;
18
- (internal: unknown, props: Props & {
19
- $$events?: Events;
20
- $$slots?: Slots;
21
- }): Exports & {
22
- $set?: any;
23
- $on?: any;
24
- };
25
- z_$$bindings?: Bindings;
1
+ interface Props {
2
+ stroke?: string;
26
3
  }
4
+ declare const Check: import("svelte").Component<Props, {}, "">;
5
+ type Check = ReturnType<typeof Check>;
6
+ export default Check;
@@ -53,6 +53,8 @@
53
53
 
54
54
  -->
55
55
  <script>
56
+ import { run } from 'svelte/legacy';
57
+
56
58
  // A bootstrap step component
57
59
  import { tweened } from 'svelte/motion';
58
60
  import { cubicOut } from 'svelte/easing';
@@ -61,25 +63,49 @@
61
63
  import Check from './Check.svelte';
62
64
  import Alert from './Alert.svelte';
63
65
 
64
- export let steps;
65
- export let current = 0;
66
- export let vertical = false;
67
- export let size = vertical ? '2rem' : '3rem';
68
- export let line = vertical ? '0.15rem' : '0.3rem';
69
- export let lineHeight = undefined;
70
- export let primary = 'var(--bs-primary, #3a86ff)';
71
- export let secondary = 'var(--bs-secondary, #bbbbc0)';
72
- export let light = 'var(--bs-light, white)';
73
- export let dark = 'var(--bs-dark, black)';
74
- export let borderRadius = '50%';
75
- export let fontFamily = '';
76
- export let reverse = false;
77
- export let clickable = true;
78
-
79
- export let checkIcon = Check;
80
- export let alertIcon = Alert;
81
- export let alertColor = 'var(--bs-danger, #dc3545)';
82
- export let htmlMode = false;
66
+ /**
67
+ * @typedef {Object} Props
68
+ * @property {any} steps
69
+ * @property {number} [current]
70
+ * @property {boolean} [vertical]
71
+ * @property {any} [size]
72
+ * @property {any} [line]
73
+ * @property {any} [lineHeight]
74
+ * @property {string} [primary]
75
+ * @property {string} [secondary]
76
+ * @property {string} [light]
77
+ * @property {string} [dark]
78
+ * @property {string} [borderRadius]
79
+ * @property {string} [fontFamily]
80
+ * @property {boolean} [reverse]
81
+ * @property {boolean} [clickable]
82
+ * @property {any} [checkIcon]
83
+ * @property {any} [alertIcon]
84
+ * @property {string} [alertColor]
85
+ * @property {boolean} [htmlMode]
86
+ */
87
+
88
+ /** @type {Props} */
89
+ let {
90
+ steps,
91
+ current = $bindable(0),
92
+ vertical = false,
93
+ size = vertical ? '2rem' : '3rem',
94
+ line = $bindable(vertical ? '0.15rem' : '0.3rem'),
95
+ lineHeight = undefined,
96
+ primary = 'var(--bs-primary, #3a86ff)',
97
+ secondary = 'var(--bs-secondary, #bbbbc0)',
98
+ light = 'var(--bs-light, white)',
99
+ dark = 'var(--bs-dark, black)',
100
+ borderRadius = '50%',
101
+ fontFamily = '',
102
+ reverse = false,
103
+ clickable = true,
104
+ checkIcon = Check,
105
+ alertIcon = Alert,
106
+ alertColor = 'var(--bs-danger, #dc3545)',
107
+ htmlMode = false
108
+ } = $props();
83
109
 
84
110
  const minStepSize = '5rem';
85
111
  const stepLabelSpace = '1rem';
@@ -92,7 +118,7 @@
92
118
  // each segment is half of the step size
93
119
 
94
120
  // @type { height: number; width: number }[]
95
- let segmentSizes = [];
121
+ let segmentSizes = $state([]);
96
122
  for (let i = 0; i < steps.length; i++) {
97
123
  segmentSizes.push({ height: 0, width: 0 });
98
124
  }
@@ -105,7 +131,7 @@
105
131
  }
106
132
 
107
133
  let progress = tweened(current, { duration: 400, easing: cubicOut });
108
- let total = 0;
134
+ let total = $state(0);
109
135
  let key = vertical ? 'height' : 'width';
110
136
 
111
137
  function f(p /*@type number*/) {
@@ -125,9 +151,9 @@
125
151
  return ret;
126
152
  }
127
153
 
128
- let fill = f(current);
154
+ let fill = $state(f(current));
129
155
 
130
- $: {
156
+ run(() => {
131
157
  total = 0;
132
158
  if (segmentSizes[0][key] > 0) {
133
159
  for (let i = 0; i < steps.length; i++) {
@@ -136,10 +162,10 @@
136
162
  total -= (segmentSizes[0][key] + segmentSizes[segmentSizes.length - 1][key]) / 2;
137
163
  }
138
164
  fill = f($progress);
139
- }
140
- $: {
165
+ });
166
+ run(() => {
141
167
  $progress = current;
142
- }
168
+ });
143
169
  const dispatch = createEventDispatcher();
144
170
  let onClick = (i /*: number*/) => {
145
171
  if (clickable) {
@@ -183,7 +209,7 @@
183
209
  <div
184
210
  style:width={vertical ? line : `${segmentSizes[0].width / 2}px`}
185
211
  style:height={vertical ? `${segmentSizes[0].height / 2}px` : line}
186
- />
212
+ ></div>
187
213
  <div
188
214
  style:width={vertical ? line : `${total}px`}
189
215
  style:height={vertical ? `${total}px` : line}
@@ -195,16 +221,16 @@
195
221
  class="bg-primary"
196
222
  style:width={vertical ? line : `${fill}px`}
197
223
  style:height={vertical ? `${fill}px` : line}
198
- />
224
+ ></div>
199
225
  {#if line != size}
200
226
  <!-- the progress indicator -->
201
- <div class="bg-primary" style="width:8px; height:8px; border-radius: 50%;" />
227
+ <div class="bg-primary" style="width:8px; height:8px; border-radius: 50%;"></div>
202
228
  {/if}
203
229
  </div>
204
230
  <div
205
231
  style:width={vertical ? line : `${segmentSizes[0].width / 2}px`}
206
232
  style:height={vertical ? `${segmentSizes[0].height / 2}px` : line}
207
- />
233
+ ></div>
208
234
  </div>
209
235
  <!-- progress line end -->
210
236
  <div
@@ -237,7 +263,7 @@
237
263
  "
238
264
  class:hover-highlight={clickable}
239
265
  class:shadow={i == current}
240
- on:click={() => {
266
+ onclick={() => {
241
267
  onClick(i);
242
268
  }}
243
269
  >
@@ -245,33 +271,37 @@
245
271
  {#if i < $progress}
246
272
  {#if step.alert}
247
273
  {#if alertIcon}
248
- <svelte:component this={alertIcon} />
274
+ {@const SvelteComponent = alertIcon}
275
+ <SvelteComponent />
249
276
  {:else if step.iconProps}
250
- <svelte:component this={step.icon} {...step.iconProps} />
277
+ <step.icon {...step.iconProps} />
251
278
  {:else}
252
- <svelte:component this={step.icon} />
279
+ <step.icon />
253
280
  {/if}
254
281
  {:else if checkIcon}
255
- <svelte:component this={checkIcon} />
282
+ {@const SvelteComponent_1 = checkIcon}
283
+ <SvelteComponent_1 />
256
284
  {:else if step.iconProps}
257
- <svelte:component this={step.icon} {...step.iconProps} />
285
+ <step.icon {...step.iconProps} />
258
286
  {:else}
259
- <svelte:component this={step.icon} />
287
+ <step.icon />
260
288
  {/if}
261
289
  {:else if step.iconProps}
262
- <svelte:component this={step.icon} {...step.iconProps} />
290
+ <step.icon {...step.iconProps} />
263
291
  {:else}
264
- <svelte:component this={step.icon} />
292
+ <step.icon />
265
293
  {/if}
266
294
  {:else if i < $progress}
267
295
  {#if step.alert}
268
296
  {#if alertIcon}
269
- <svelte:component this={alertIcon} />
297
+ {@const SvelteComponent_2 = alertIcon}
298
+ <SvelteComponent_2 />
270
299
  {:else}
271
300
  <span class="steps__number">{i + 1}</span>
272
301
  {/if}
273
302
  {:else if checkIcon}
274
- <svelte:component this={checkIcon} />
303
+ {@const SvelteComponent_3 = checkIcon}
304
+ <SvelteComponent_3 />
275
305
  {:else}
276
306
  <span class="steps__number">{i + 1}</span>
277
307
  {/if}
@@ -288,7 +318,7 @@
288
318
  style:margin-right={vertical ? (reverse ? stepLabelSpace : null) : null}
289
319
  style:margin-top={vertical ? null : stepLabelSpace}
290
320
  style:text-align={vertical ? (reverse ? 'right' : 'left') : 'center'}
291
- on:click={() => {
321
+ onclick={() => {
292
322
  onClick(i);
293
323
  }}
294
324
  >
@@ -0,0 +1,115 @@
1
+ export default Steps;
2
+ type Steps = SvelteComponent<Props, {
3
+ click: CustomEvent<any>;
4
+ } & {
5
+ [evt: string]: CustomEvent<any>;
6
+ }, {}> & {
7
+ $$bindings?: "line" | "current" | undefined;
8
+ };
9
+ /**
10
+ * # svelte-steps
11
+ *
12
+ * ## props
13
+ *
14
+ * - `steps`:
15
+ * - Array of object. Length has to be more than 1
16
+ * - Required
17
+ * - Each item is a step object that can have:
18
+ * - `text`: The text displayed below each steps.
19
+ * - `icon`: A svelte component displayed inside each steps.
20
+ * - `iconProps`: An object that will be passed as props to the `icon` component.
21
+ * - `current`: current step index. Number. Default `0`
22
+ * - `size`: size of the step buttons. String. Default `"3rem"`
23
+ * - `line`: thickness of the connecting lines between the step buttons. String. Default `"0.3rem"`
24
+ * - `primary`: Primary color of passed and current steps. String. Default `'var(--bs-primary, #3a86ff)'`
25
+ * - `secondary`: Secondary color of future steps. String. Default `'var(--bs-secondary, #bbbbc0)'`
26
+ * - `light`: Primary color of text color in passed anc current steps. String. Default `'var(--bs-light, white)'`
27
+ * - `dark`: Secondary color of text color in future steps. String. Default `'var(--bs-dark, black)'`
28
+ * - `borderRadius`: Border radius of the step buttons. String. Default `'50%'` (circle)
29
+ * - `fontFamily`: Font family of the component. String. Default `"'Helvetica Neue', Helvetica, Arial, sans-serif"`
30
+ * - `vertical`: Vertical steps
31
+ * - `reverse`: For horizontal steps, reverse the step from right to the left; for vertical steps, reverse puts text labels to the left. Default `false`
32
+ * - `clickable`: When set to `false`, Clicking icons and labels will not change step. You have to change `current` to change step. Default `true`
33
+ * - `checkIcon`: User defined check icon for passed steps. If not specified, use the default check mark. Set to `null` if you don't want a check icon.
34
+ * - `alertIcon`: User defined alert icon for passed steps that has truthful `alert` property. If not specified, use the default alert icon. Set to `null` if you don't want an alert icon.
35
+ * - `alertColor`: User defined bg color for passed steps that has truthful `alert` property. Default 'var(--bs-danger, #dc3545)'
36
+ *
37
+ * ## events
38
+ *
39
+ * - `on:click(e)`: click event. Event detail object has two keys:
40
+ * - `e.detail.current`: the index of current step
41
+ * - `e.detail.last`: the index of last step
42
+ *
43
+ * ## Copyright
44
+ *
45
+ * - 2025-08-07 : Use Iroco CSS var for steps label
46
+ *
47
+ * Copyright (c) 2025, Iroco. All rights reserved.
48
+ * Use of this source code is governed by a BSD-style license that can be found
49
+ * in the LICENSE file.
50
+ *
51
+ * ---
52
+ *
53
+ * Copyright (c) 2021, Jingshao Chen. All rights reserved.
54
+ * Use of this source code is governed by a BSD-style license that can be found
55
+ * in the LICENSE file.
56
+ *
57
+ * https://github.com/shaozi/svelte-steps
58
+ */
59
+ declare const Steps: $$__sveltets_2_IsomorphicComponent<{
60
+ steps: any;
61
+ current?: number | undefined;
62
+ vertical?: boolean | undefined;
63
+ size?: any;
64
+ line?: any;
65
+ lineHeight?: any;
66
+ primary?: string | undefined;
67
+ secondary?: string | undefined;
68
+ light?: string | undefined;
69
+ dark?: string | undefined;
70
+ borderRadius?: string | undefined;
71
+ fontFamily?: string | undefined;
72
+ reverse?: boolean | undefined;
73
+ clickable?: boolean | undefined;
74
+ checkIcon?: any;
75
+ alertIcon?: any;
76
+ alertColor?: string | undefined;
77
+ htmlMode?: boolean | undefined;
78
+ }, {
79
+ click: CustomEvent<any>;
80
+ } & {
81
+ [evt: string]: CustomEvent<any>;
82
+ }, {}, {}, "line" | "current">;
83
+ type Props = {
84
+ steps: any;
85
+ current?: number | undefined;
86
+ vertical?: boolean | undefined;
87
+ size?: any;
88
+ line?: any;
89
+ lineHeight?: any;
90
+ primary?: string | undefined;
91
+ secondary?: string | undefined;
92
+ light?: string | undefined;
93
+ dark?: string | undefined;
94
+ borderRadius?: string | undefined;
95
+ fontFamily?: string | undefined;
96
+ reverse?: boolean | undefined;
97
+ clickable?: boolean | undefined;
98
+ checkIcon?: any;
99
+ alertIcon?: any;
100
+ alertColor?: string | undefined;
101
+ htmlMode?: boolean | undefined;
102
+ };
103
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
104
+ new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
105
+ $$bindings?: Bindings;
106
+ } & Exports;
107
+ (internal: unknown, props: Props & {
108
+ $$events?: Events;
109
+ $$slots?: Slots;
110
+ }): Exports & {
111
+ $set?: any;
112
+ $on?: any;
113
+ };
114
+ z_$$bindings?: Bindings;
115
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iroco/ui",
3
- "version": "1.10.2",
3
+ "version": "1.10.3",
4
4
  "description": "Iroco design system based on Svelte",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {