@iroco/ui 1.10.1 → 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;
@@ -10,13 +10,11 @@ We plan to improve the following :
10
10
 
11
11
  - [x] Adapt npm package to our organization
12
12
  - [x] Keep credits to original author
13
- - [ ] Release with `release-it`
14
- - [ ] Add credit ourselves when modifying
15
- - [ ] Update to Svelte 5 peer dependencies
16
- - [ ] Update to node lts
17
- - [ ] Update vulnerable dependencies
13
+ - [x] Release with `release-it`
14
+ - [x] Add credit ourselves when modifying
15
+ - [x] Web accessibility: Treat as `role="progress"` aria
16
+ - [ ] Migrate to Svelte 5
18
17
  - [ ] Fix Svelte 5 warning : `WARNING: The following packages have a svelte field in their package.json but no exports condition for svelte.`
19
- - [ ] Web accessibility: Treat as `role="progress"` aria
20
18
 
21
19
  ## Previous task list
22
20
 
@@ -37,6 +37,14 @@
37
37
 
38
38
  ## Copyright
39
39
 
40
+ - 2025-08-07 : Use Iroco CSS var for steps label
41
+
42
+ Copyright (c) 2025, Iroco. All rights reserved.
43
+ Use of this source code is governed by a BSD-style license that can be found
44
+ in the LICENSE file.
45
+
46
+ ---
47
+
40
48
  Copyright (c) 2021, Jingshao Chen. All rights reserved.
41
49
  Use of this source code is governed by a BSD-style license that can be found
42
50
  in the LICENSE file.
@@ -45,6 +53,8 @@
45
53
 
46
54
  -->
47
55
  <script>
56
+ import { run } from 'svelte/legacy';
57
+
48
58
  // A bootstrap step component
49
59
  import { tweened } from 'svelte/motion';
50
60
  import { cubicOut } from 'svelte/easing';
@@ -52,25 +62,50 @@
52
62
  import { createEventDispatcher } from 'svelte';
53
63
  import Check from './Check.svelte';
54
64
  import Alert from './Alert.svelte';
55
- export let steps;
56
- export let current = 0;
57
- export let vertical = false;
58
- export let size = vertical ? '2rem' : '3rem';
59
- export let line = vertical ? '0.15rem' : '0.3rem';
60
- export let lineHeight = undefined;
61
- export let primary = 'var(--bs-primary, #3a86ff)';
62
- export let secondary = 'var(--bs-secondary, #bbbbc0)';
63
- export let light = 'var(--bs-light, white)';
64
- export let dark = 'var(--bs-dark, black)';
65
- export let borderRadius = '50%';
66
- export let fontFamily = '';
67
- export let reverse = false;
68
- export let clickable = true;
69
-
70
- export let checkIcon = Check;
71
- export let alertIcon = Alert;
72
- export let alertColor = 'var(--bs-danger, #dc3545)';
73
- export let htmlMode = false;
65
+
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();
74
109
 
75
110
  const minStepSize = '5rem';
76
111
  const stepLabelSpace = '1rem';
@@ -83,7 +118,7 @@
83
118
  // each segment is half of the step size
84
119
 
85
120
  // @type { height: number; width: number }[]
86
- let segmentSizes = [];
121
+ let segmentSizes = $state([]);
87
122
  for (let i = 0; i < steps.length; i++) {
88
123
  segmentSizes.push({ height: 0, width: 0 });
89
124
  }
@@ -96,7 +131,7 @@
96
131
  }
97
132
 
98
133
  let progress = tweened(current, { duration: 400, easing: cubicOut });
99
- let total = 0;
134
+ let total = $state(0);
100
135
  let key = vertical ? 'height' : 'width';
101
136
 
102
137
  function f(p /*@type number*/) {
@@ -116,9 +151,9 @@
116
151
  return ret;
117
152
  }
118
153
 
119
- let fill = f(current);
154
+ let fill = $state(f(current));
120
155
 
121
- $: {
156
+ run(() => {
122
157
  total = 0;
123
158
  if (segmentSizes[0][key] > 0) {
124
159
  for (let i = 0; i < steps.length; i++) {
@@ -127,10 +162,10 @@
127
162
  total -= (segmentSizes[0][key] + segmentSizes[segmentSizes.length - 1][key]) / 2;
128
163
  }
129
164
  fill = f($progress);
130
- }
131
- $: {
165
+ });
166
+ run(() => {
132
167
  $progress = current;
133
- }
168
+ });
134
169
  const dispatch = createEventDispatcher();
135
170
  let onClick = (i /*: number*/) => {
136
171
  if (clickable) {
@@ -144,7 +179,12 @@
144
179
 
145
180
  <div
146
181
  class="steps-container"
147
- style={`--size: ${size};
182
+ role="progressbar"
183
+ aria-valuemin="1"
184
+ aria-valuemax={`${(steps?.length ?? 0) + 1}`}
185
+ aria-valuenow={`${(current ?? 0) + 1}`}
186
+ aria-valuetext={`${steps[current]?.text}`}
187
+ style={`--size: ${size};
148
188
  --line-thickness: ${line};
149
189
  --primary: ${primary};
150
190
  --secondary: ${secondary};
@@ -169,7 +209,7 @@
169
209
  <div
170
210
  style:width={vertical ? line : `${segmentSizes[0].width / 2}px`}
171
211
  style:height={vertical ? `${segmentSizes[0].height / 2}px` : line}
172
- />
212
+ ></div>
173
213
  <div
174
214
  style:width={vertical ? line : `${total}px`}
175
215
  style:height={vertical ? `${total}px` : line}
@@ -181,16 +221,16 @@
181
221
  class="bg-primary"
182
222
  style:width={vertical ? line : `${fill}px`}
183
223
  style:height={vertical ? `${fill}px` : line}
184
- />
224
+ ></div>
185
225
  {#if line != size}
186
226
  <!-- the progress indicator -->
187
- <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>
188
228
  {/if}
189
229
  </div>
190
230
  <div
191
231
  style:width={vertical ? line : `${segmentSizes[0].width / 2}px`}
192
232
  style:height={vertical ? `${segmentSizes[0].height / 2}px` : line}
193
- />
233
+ ></div>
194
234
  </div>
195
235
  <!-- progress line end -->
196
236
  <div
@@ -223,7 +263,7 @@
223
263
  "
224
264
  class:hover-highlight={clickable}
225
265
  class:shadow={i == current}
226
- on:click={() => {
266
+ onclick={() => {
227
267
  onClick(i);
228
268
  }}
229
269
  >
@@ -231,33 +271,37 @@
231
271
  {#if i < $progress}
232
272
  {#if step.alert}
233
273
  {#if alertIcon}
234
- <svelte:component this={alertIcon} />
274
+ {@const SvelteComponent = alertIcon}
275
+ <SvelteComponent />
235
276
  {:else if step.iconProps}
236
- <svelte:component this={step.icon} {...step.iconProps} />
277
+ <step.icon {...step.iconProps} />
237
278
  {:else}
238
- <svelte:component this={step.icon} />
279
+ <step.icon />
239
280
  {/if}
240
281
  {:else if checkIcon}
241
- <svelte:component this={checkIcon} />
282
+ {@const SvelteComponent_1 = checkIcon}
283
+ <SvelteComponent_1 />
242
284
  {:else if step.iconProps}
243
- <svelte:component this={step.icon} {...step.iconProps} />
285
+ <step.icon {...step.iconProps} />
244
286
  {:else}
245
- <svelte:component this={step.icon} />
287
+ <step.icon />
246
288
  {/if}
247
289
  {:else if step.iconProps}
248
- <svelte:component this={step.icon} {...step.iconProps} />
290
+ <step.icon {...step.iconProps} />
249
291
  {:else}
250
- <svelte:component this={step.icon} />
292
+ <step.icon />
251
293
  {/if}
252
294
  {:else if i < $progress}
253
295
  {#if step.alert}
254
296
  {#if alertIcon}
255
- <svelte:component this={alertIcon} />
297
+ {@const SvelteComponent_2 = alertIcon}
298
+ <SvelteComponent_2 />
256
299
  {:else}
257
300
  <span class="steps__number">{i + 1}</span>
258
301
  {/if}
259
302
  {:else if checkIcon}
260
- <svelte:component this={checkIcon} />
303
+ {@const SvelteComponent_3 = checkIcon}
304
+ <SvelteComponent_3 />
261
305
  {:else}
262
306
  <span class="steps__number">{i + 1}</span>
263
307
  {/if}
@@ -274,7 +318,7 @@
274
318
  style:margin-right={vertical ? (reverse ? stepLabelSpace : null) : null}
275
319
  style:margin-top={vertical ? null : stepLabelSpace}
276
320
  style:text-align={vertical ? (reverse ? 'right' : 'left') : 'center'}
277
- on:click={() => {
321
+ onclick={() => {
278
322
  onClick(i);
279
323
  }}
280
324
  >
@@ -314,11 +358,13 @@
314
358
  min-height: var(--size);
315
359
  font-size: calc(var(--size) * 0.5);
316
360
  }
361
+
317
362
  .hover-highlight:hover {
318
363
  cursor: pointer;
319
364
  filter: brightness(85%);
320
365
  box-sizing: border-box;
321
366
  }
367
+
322
368
  .steps__label {
323
369
  border-width: 0;
324
370
  background-color: transparent;
@@ -330,18 +376,23 @@
330
376
  .text-primary {
331
377
  color: var(--primary) !important;
332
378
  }
379
+
333
380
  .text-light {
334
381
  color: var(--light) !important;
335
382
  }
383
+
336
384
  .bg-secondary {
337
385
  background-color: var(--secondary) !important;
338
386
  }
387
+
339
388
  .bg-primary {
340
389
  background-color: var(--primary) !important;
341
390
  }
391
+
342
392
  .bg-danger {
343
393
  background-color: var(--danger) !important;
344
394
  }
395
+
345
396
  .shadow {
346
397
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
347
398
  }
@@ -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.1",
3
+ "version": "1.10.3",
4
4
  "description": "Iroco design system based on Svelte",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {