@softwareone/spi-sv5-library 1.11.8 → 1.11.10

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.
@@ -1,12 +1,13 @@
1
1
  <script lang="ts">
2
- import { type Snippet } from 'svelte';
2
+ import { untrack, type Snippet } from 'svelte';
3
3
 
4
4
  import { Button, ErrorPage, type ProgressWizardStep } from '../index.js';
5
5
 
6
6
  interface ProgressWizardProps {
7
7
  steps: ProgressWizardStep[];
8
- readonly?: boolean;
9
8
  currentStep: number;
9
+ readonly?: boolean;
10
+ initialStep?: number;
10
11
  content: Snippet;
11
12
  additionalButtons: Snippet<[lastActiveStep: number]>;
12
13
  oncancel: VoidFunction;
@@ -16,6 +17,7 @@
16
17
  steps,
17
18
  readonly = false,
18
19
  currentStep = $bindable(0),
20
+ initialStep,
19
21
  content,
20
22
  additionalButtons,
21
23
  oncancel
@@ -25,6 +27,21 @@
25
27
  const firstActiveStep = $derived<number>(steps.findIndex((step) => !step.disabled) + 1);
26
28
  const lastActiveStep = $derived<number>(steps.findLastIndex((step) => !step.disabled) + 1);
27
29
 
30
+ const isValidInitialStep = (initialStep: number): boolean => {
31
+ const index = initialStep - 1;
32
+ if (index < 0 || index >= steps.length) return false;
33
+ return !steps[index].disabled;
34
+ };
35
+
36
+ const getInitialStep = (): number => {
37
+ if (allStepsDisabled) return -1;
38
+ return initialStep && isValidInitialStep(initialStep) ? initialStep : firstActiveStep;
39
+ };
40
+
41
+ const getInitialStepReadonlyMode = (): number => {
42
+ return allStepsDisabled ? -1 : steps.length;
43
+ };
44
+
28
45
  const onclickNext = () => {
29
46
  const nextStepIndex = steps.slice(currentStep).findIndex((step) => !step.disabled);
30
47
  currentStep = currentStep + nextStepIndex + 1;
@@ -39,18 +56,9 @@
39
56
  currentStep = currentStep - previousStepIndex - 1;
40
57
  };
41
58
 
42
- const stepToStart = (): number => {
43
- if (readonly && allStepsDisabled) return -1;
44
- if (readonly && !allStepsDisabled) return steps.length;
45
- return firstActiveStep;
46
- };
47
-
48
- currentStep = stepToStart();
49
-
50
59
  $effect(() => {
51
- if (!readonly) {
52
- currentStep = firstActiveStep;
53
- }
60
+ if (!readonly) currentStep = untrack(() => getInitialStep());
61
+ else currentStep = untrack(() => getInitialStepReadonlyMode());
54
62
  });
55
63
  </script>
56
64
 
@@ -2,8 +2,9 @@ import { type Snippet } from 'svelte';
2
2
  import { type ProgressWizardStep } from '../index.js';
3
3
  interface ProgressWizardProps {
4
4
  steps: ProgressWizardStep[];
5
- readonly?: boolean;
6
5
  currentStep: number;
6
+ readonly?: boolean;
7
+ initialStep?: number;
7
8
  content: Snippet;
8
9
  additionalButtons: Snippet<[lastActiveStep: number]>;
9
10
  oncancel: VoidFunction;
@@ -25,12 +25,14 @@
25
25
  dividerIndex !== -1 && dividerIndex !== actions.length - 1 && dividerIndex === index;
26
26
 
27
27
  const autoPosition: Attachment<HTMLElement> = (element: HTMLElement) => {
28
+ const MENU_GAP = 2;
29
+
28
30
  const updatePosition = () => {
29
31
  const rect = container.getBoundingClientRect();
30
32
  const showAbove = rect.bottom + element.offsetHeight > window.innerHeight;
31
33
 
32
34
  const left = rect.left + rect.width / 2 - element.offsetWidth / 2;
33
- const top = showAbove ? rect.top - element.offsetHeight + 14 : rect.bottom - 8;
35
+ const top = showAbove ? rect.top - element.offsetHeight + MENU_GAP : rect.bottom + MENU_GAP;
34
36
 
35
37
  element.style.setProperty('--menu-left', `${Math.max(0, left)}px`);
36
38
  element.style.setProperty('--menu-top', `${top}px`);
@@ -69,7 +71,6 @@
69
71
  <div
70
72
  role="menu"
71
73
  tabindex="-1"
72
- class="actions-group"
73
74
  bind:this={container}
74
75
  onmouseenter={toggleActionsMenu}
75
76
  onmouseleave={toggleActionsMenu}
@@ -126,15 +127,11 @@
126
127
  justify-content: center;
127
128
  }
128
129
 
129
- .actions-group {
130
- position: relative;
131
- }
132
-
133
130
  .actions-trigger {
134
131
  display: inline-block;
135
- margin-bottom: var(--spacing-sm);
136
132
  font-size: var(--font-size-2xl);
137
133
  font-weight: bold;
134
+ line-height: 0;
138
135
  cursor: default;
139
136
  }
140
137
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softwareone/spi-sv5-library",
3
- "version": "1.11.8",
3
+ "version": "1.11.10",
4
4
  "description": "Svelte components",
5
5
  "keywords": [
6
6
  "svelte",