@@ -89,4 +95,10 @@ Set `preventChangeOnClick` to `true` to prevent this behavior.
### Skeleton
-
\ No newline at end of file
+Use the `count` prop to specify the number of progress steps to render.
+
+
+
+### Skeleton (vertical)
+
+
\ No newline at end of file
diff --git a/docs/src/pages/framed/ProgressIndicator/ProgrammaticProgressIndicator.svelte b/docs/src/pages/framed/ProgressIndicator/ProgrammaticProgressIndicator.svelte
new file mode 100644
index 00000000..f833e346
--- /dev/null
+++ b/docs/src/pages/framed/ProgressIndicator/ProgrammaticProgressIndicator.svelte
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+Current index: {currentIndex}
+
+Is the third step currently selected? {thirdStepCurrent}
diff --git a/src/ProgressIndicator/ProgressIndicator.svelte b/src/ProgressIndicator/ProgressIndicator.svelte
index a8e93b77..67d8881f 100644
--- a/src/ProgressIndicator/ProgressIndicator.svelte
+++ b/src/ProgressIndicator/ProgressIndicator.svelte
@@ -8,7 +8,7 @@
/** Set to `true` to specify whether the progress steps should be split equally in size in the div */
export let spaceEqually = false;
- /** Set to `true` to prevent updating `currentIndex` */
+ /** Set to `true` to prevent `currentIndex` from updating */
export let preventChangeOnClick = false;
import { createEventDispatcher, setContext } from "svelte";
@@ -24,28 +24,40 @@
steps,
stepsById,
add: (step) => {
- steps.update((_) => [
- ..._,
- {
- ...step,
- index: _.length,
- current: _.length === currentIndex,
- complete: _.length <= currentIndex,
- },
- ]);
+ steps.update((_) => {
+ if (step.id in $stepsById) {
+ return _.map((_step) => {
+ if (_step.id === step.id) return { ..._step, ...step };
+ return _step;
+ });
+ }
+
+ return [
+ ..._,
+ {
+ ...step,
+ index: _.length,
+ current: _.length === currentIndex,
+ complete: step.complete,
+ },
+ ];
+ });
},
change: (index) => {
if (preventChangeOnClick) return;
currentIndex = index;
- steps.update((_) =>
- [..._].map((step, i) => ({
- ...step,
- current: i === index,
- }))
- );
+
+ /** @event {number} change */
dispatch("change", index);
},
});
+
+ $: steps.update((_) =>
+ _.map((step, i) => ({
+ ...step,
+ current: i === currentIndex,
+ }))
+ );
{
+ if (value[id]) {
+ step = value[id];
+ current = step.current;
+ complete = step.complete;
+ }
+ });
+
+ onMount(() => {
+ return () => {
+ unsubscribe();
+ };
+ });
- ) => void): () => void;
$on(eventname: "click", cb: (event: WindowEventMap["click"]) => void): () => void;
$on(eventname: "mouseover", cb: (event: WindowEventMap["mouseover"]) => void): () => void;
$on(eventname: "mouseenter", cb: (event: WindowEventMap["mouseenter"]) => void): () => void;
$on(eventname: "mouseleave", cb: (event: WindowEventMap["mouseleave"]) => void): () => void;
- $on(eventname: "change", cb: (event: CustomEvent) => void): () => void;
$on(eventname: string, cb: (event: Event) => void): () => void;
}