@softwareone/spi-sv5-library 1.11.8 → 1.11.9
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
|
-
|
|
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;
|