@daltonr/pathwrite-vue 0.1.1
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.
- package/LICENSE +22 -0
- package/README.md +70 -0
- package/dist/index.d.ts +150 -0
- package/dist/index.js +201 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Richard Dalton
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# @daltonr/pathwrite-vue
|
|
2
|
+
|
|
3
|
+
Vue 3 composable over `@daltonr/pathwrite-core`. Exposes path state as a reactive `shallowRef` that integrates seamlessly with Vue's reactivity system, templates, and `computed()`.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<script setup lang="ts">
|
|
9
|
+
import { usePath } from "@daltonr/pathwrite-vue";
|
|
10
|
+
import { computed } from "vue";
|
|
11
|
+
|
|
12
|
+
const { snapshot, start, next, previous, cancel, setData } = usePath({
|
|
13
|
+
onEvent(event) {
|
|
14
|
+
console.log(event);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const currentStep = computed(() => snapshot.value?.stepId ?? null);
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<div v-if="snapshot">
|
|
23
|
+
<h2>{{ snapshot.stepTitle ?? snapshot.stepId }}</h2>
|
|
24
|
+
<p>Step {{ snapshot.stepIndex + 1 }} of {{ snapshot.stepCount }}</p>
|
|
25
|
+
<button @click="previous" :disabled="snapshot.isNavigating">Back</button>
|
|
26
|
+
<button @click="next" :disabled="snapshot.isNavigating">
|
|
27
|
+
{{ snapshot.isLastStep ? "Finish" : "Next" }}
|
|
28
|
+
</button>
|
|
29
|
+
<button @click="cancel">Cancel</button>
|
|
30
|
+
</div>
|
|
31
|
+
<div v-else>
|
|
32
|
+
<button @click="start(myPath)">Start Path</button>
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## `usePath` API
|
|
38
|
+
|
|
39
|
+
### Options
|
|
40
|
+
|
|
41
|
+
| Option | Type | Description |
|
|
42
|
+
|--------|------|-------------|
|
|
43
|
+
| `onEvent` | `(event: PathEvent) => void` | Called for every engine event. |
|
|
44
|
+
|
|
45
|
+
### Return value
|
|
46
|
+
|
|
47
|
+
| Property | Type | Description |
|
|
48
|
+
|----------|------|-------------|
|
|
49
|
+
| `snapshot` | `DeepReadonly<Ref<PathSnapshot \| null>>` | Current snapshot. `null` when no path is active. Triggers Vue re-renders on change. |
|
|
50
|
+
| `start(definition, data?)` | `function` | Start or re-start a path. |
|
|
51
|
+
| `startSubPath(definition, data?)` | `function` | Push a sub-path. Requires an active path. |
|
|
52
|
+
| `next()` | `function` | Advance one step. Completes the path on the last step. |
|
|
53
|
+
| `previous()` | `function` | Go back one step. Cancels the path from the first step. |
|
|
54
|
+
| `cancel()` | `function` | Cancel the active path (or sub-path). |
|
|
55
|
+
| `goToStep(stepId)` | `function` | Jump directly to a step by ID. Calls `onLeave` / `onEnter` but bypasses guards and `shouldSkip`. |
|
|
56
|
+
| `setData(key, value)` | `function` | Update a single data value; triggers re-render via `stateChanged`. |
|
|
57
|
+
|
|
58
|
+
## Design notes
|
|
59
|
+
|
|
60
|
+
- **`shallowRef`** — the snapshot is stored in a `shallowRef` for performance. The engine produces a new snapshot object on every change, so shallow reactivity is sufficient.
|
|
61
|
+
- **`readonly`** — the returned ref is wrapped with `readonly()` to prevent accidental external mutation.
|
|
62
|
+
- **`onScopeDispose`** — the composable automatically unsubscribes from the engine when the calling component's effect scope is disposed (i.e. on unmount).
|
|
63
|
+
- **No RxJS** — unlike the Angular adapter, there is no RxJS dependency. The composable is pure Vue.
|
|
64
|
+
|
|
65
|
+
## Peer dependencies
|
|
66
|
+
|
|
67
|
+
| Package | Version |
|
|
68
|
+
|---------|---------|
|
|
69
|
+
| `vue` | `>=3.3.0` |
|
|
70
|
+
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { type Ref, type DeepReadonly, type PropType, type VNode } from "vue";
|
|
2
|
+
import { PathData, PathDefinition, PathEvent, PathSnapshot } from "@daltonr/pathwrite-core";
|
|
3
|
+
export interface UsePathOptions {
|
|
4
|
+
/** Called for every engine event (stateChanged, completed, cancelled, resumed). */
|
|
5
|
+
onEvent?: (event: PathEvent) => void;
|
|
6
|
+
}
|
|
7
|
+
export interface UsePathReturn {
|
|
8
|
+
/** Current path snapshot, or `null` when no path is active. Reactive — triggers Vue re-renders on change. */
|
|
9
|
+
snapshot: DeepReadonly<Ref<PathSnapshot | null>>;
|
|
10
|
+
/** Start (or restart) a path. */
|
|
11
|
+
start: (path: PathDefinition, initialData?: PathData) => Promise<void>;
|
|
12
|
+
/** Push a sub-path onto the stack. Requires an active path. */
|
|
13
|
+
startSubPath: (path: PathDefinition, initialData?: PathData) => Promise<void>;
|
|
14
|
+
/** Advance one step. Completes the path on the last step. */
|
|
15
|
+
next: () => Promise<void>;
|
|
16
|
+
/** Go back one step. Cancels the path from the first step. */
|
|
17
|
+
previous: () => Promise<void>;
|
|
18
|
+
/** Cancel the active path (or sub-path). */
|
|
19
|
+
cancel: () => Promise<void>;
|
|
20
|
+
/** Jump directly to a step by ID. Calls onLeave / onEnter but bypasses guards and shouldSkip. */
|
|
21
|
+
goToStep: (stepId: string) => Promise<void>;
|
|
22
|
+
/** Update a single data value; triggers a re-render via stateChanged. */
|
|
23
|
+
setData: (key: string, value: unknown) => Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export declare function usePath(options?: UsePathOptions): UsePathReturn;
|
|
26
|
+
export interface PathShellActions {
|
|
27
|
+
next: () => Promise<void>;
|
|
28
|
+
previous: () => Promise<void>;
|
|
29
|
+
cancel: () => Promise<void>;
|
|
30
|
+
goToStep: (stepId: string) => Promise<void>;
|
|
31
|
+
setData: (key: string, value: unknown) => Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* `<PathStep>` — slot wrapper that only renders its default slot content
|
|
35
|
+
* when the current step matches the given `id`.
|
|
36
|
+
*
|
|
37
|
+
* Used inside `<PathShell>`.
|
|
38
|
+
*/
|
|
39
|
+
export declare const PathStep: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
40
|
+
id: {
|
|
41
|
+
type: StringConstructor;
|
|
42
|
+
required: true;
|
|
43
|
+
};
|
|
44
|
+
}>, () => null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
45
|
+
id: {
|
|
46
|
+
type: StringConstructor;
|
|
47
|
+
required: true;
|
|
48
|
+
};
|
|
49
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
50
|
+
/**
|
|
51
|
+
* `<PathShell>` — default UI shell that renders a progress indicator,
|
|
52
|
+
* step content, and navigation buttons.
|
|
53
|
+
*
|
|
54
|
+
* ```vue
|
|
55
|
+
* <PathShell :path="myPath" :initial-data="{ name: '' }" @complete="handleDone">
|
|
56
|
+
* <PathStep id="details"><DetailsForm /></PathStep>
|
|
57
|
+
* <PathStep id="review"><ReviewPanel /></PathStep>
|
|
58
|
+
* </PathShell>
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare const PathShell: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
62
|
+
path: {
|
|
63
|
+
type: PropType<PathDefinition>;
|
|
64
|
+
required: true;
|
|
65
|
+
};
|
|
66
|
+
initialData: {
|
|
67
|
+
type: PropType<PathData>;
|
|
68
|
+
default: () => {};
|
|
69
|
+
};
|
|
70
|
+
autoStart: {
|
|
71
|
+
type: BooleanConstructor;
|
|
72
|
+
default: boolean;
|
|
73
|
+
};
|
|
74
|
+
backLabel: {
|
|
75
|
+
type: StringConstructor;
|
|
76
|
+
default: string;
|
|
77
|
+
};
|
|
78
|
+
nextLabel: {
|
|
79
|
+
type: StringConstructor;
|
|
80
|
+
default: string;
|
|
81
|
+
};
|
|
82
|
+
finishLabel: {
|
|
83
|
+
type: StringConstructor;
|
|
84
|
+
default: string;
|
|
85
|
+
};
|
|
86
|
+
cancelLabel: {
|
|
87
|
+
type: StringConstructor;
|
|
88
|
+
default: string;
|
|
89
|
+
};
|
|
90
|
+
hideCancel: {
|
|
91
|
+
type: BooleanConstructor;
|
|
92
|
+
default: boolean;
|
|
93
|
+
};
|
|
94
|
+
hideProgress: {
|
|
95
|
+
type: BooleanConstructor;
|
|
96
|
+
default: boolean;
|
|
97
|
+
};
|
|
98
|
+
}>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
99
|
+
[key: string]: any;
|
|
100
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("complete" | "cancel" | "event")[], "complete" | "cancel" | "event", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
101
|
+
path: {
|
|
102
|
+
type: PropType<PathDefinition>;
|
|
103
|
+
required: true;
|
|
104
|
+
};
|
|
105
|
+
initialData: {
|
|
106
|
+
type: PropType<PathData>;
|
|
107
|
+
default: () => {};
|
|
108
|
+
};
|
|
109
|
+
autoStart: {
|
|
110
|
+
type: BooleanConstructor;
|
|
111
|
+
default: boolean;
|
|
112
|
+
};
|
|
113
|
+
backLabel: {
|
|
114
|
+
type: StringConstructor;
|
|
115
|
+
default: string;
|
|
116
|
+
};
|
|
117
|
+
nextLabel: {
|
|
118
|
+
type: StringConstructor;
|
|
119
|
+
default: string;
|
|
120
|
+
};
|
|
121
|
+
finishLabel: {
|
|
122
|
+
type: StringConstructor;
|
|
123
|
+
default: string;
|
|
124
|
+
};
|
|
125
|
+
cancelLabel: {
|
|
126
|
+
type: StringConstructor;
|
|
127
|
+
default: string;
|
|
128
|
+
};
|
|
129
|
+
hideCancel: {
|
|
130
|
+
type: BooleanConstructor;
|
|
131
|
+
default: boolean;
|
|
132
|
+
};
|
|
133
|
+
hideProgress: {
|
|
134
|
+
type: BooleanConstructor;
|
|
135
|
+
default: boolean;
|
|
136
|
+
};
|
|
137
|
+
}>> & Readonly<{
|
|
138
|
+
onEvent?: ((...args: any[]) => any) | undefined;
|
|
139
|
+
onCancel?: ((...args: any[]) => any) | undefined;
|
|
140
|
+
onComplete?: ((...args: any[]) => any) | undefined;
|
|
141
|
+
}>, {
|
|
142
|
+
initialData: PathData;
|
|
143
|
+
autoStart: boolean;
|
|
144
|
+
backLabel: string;
|
|
145
|
+
nextLabel: string;
|
|
146
|
+
finishLabel: string;
|
|
147
|
+
cancelLabel: string;
|
|
148
|
+
hideCancel: boolean;
|
|
149
|
+
hideProgress: boolean;
|
|
150
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { ref, shallowRef, readonly, onScopeDispose, defineComponent, h, onMounted } from "vue";
|
|
2
|
+
import { PathEngine } from "@daltonr/pathwrite-core";
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// usePath composable
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
export function usePath(options) {
|
|
7
|
+
const engine = new PathEngine();
|
|
8
|
+
const _snapshot = shallowRef(null);
|
|
9
|
+
const unsubscribe = engine.subscribe((event) => {
|
|
10
|
+
if (event.type === "stateChanged" || event.type === "resumed") {
|
|
11
|
+
_snapshot.value = event.snapshot;
|
|
12
|
+
}
|
|
13
|
+
else if (event.type === "completed" || event.type === "cancelled") {
|
|
14
|
+
_snapshot.value = null;
|
|
15
|
+
}
|
|
16
|
+
options?.onEvent?.(event);
|
|
17
|
+
});
|
|
18
|
+
onScopeDispose(unsubscribe);
|
|
19
|
+
const snapshot = readonly(_snapshot);
|
|
20
|
+
const start = (path, initialData = {}) => engine.start(path, initialData);
|
|
21
|
+
const startSubPath = (path, initialData = {}) => engine.startSubPath(path, initialData);
|
|
22
|
+
const next = () => engine.next();
|
|
23
|
+
const previous = () => engine.previous();
|
|
24
|
+
const cancel = () => engine.cancel();
|
|
25
|
+
const goToStep = (stepId) => engine.goToStep(stepId);
|
|
26
|
+
const setData = (key, value) => engine.setData(key, value);
|
|
27
|
+
return { snapshot, start, startSubPath, next, previous, cancel, goToStep, setData };
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* `<PathStep>` — slot wrapper that only renders its default slot content
|
|
31
|
+
* when the current step matches the given `id`.
|
|
32
|
+
*
|
|
33
|
+
* Used inside `<PathShell>`.
|
|
34
|
+
*/
|
|
35
|
+
export const PathStep = defineComponent({
|
|
36
|
+
name: "PathStep",
|
|
37
|
+
props: {
|
|
38
|
+
id: { type: String, required: true }
|
|
39
|
+
},
|
|
40
|
+
setup(_props, { slots }) {
|
|
41
|
+
// PathStep never renders itself — PathShell reads its props and
|
|
42
|
+
// decides which slot to display. If rendered standalone it shows nothing.
|
|
43
|
+
return () => null;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* `<PathShell>` — default UI shell that renders a progress indicator,
|
|
48
|
+
* step content, and navigation buttons.
|
|
49
|
+
*
|
|
50
|
+
* ```vue
|
|
51
|
+
* <PathShell :path="myPath" :initial-data="{ name: '' }" @complete="handleDone">
|
|
52
|
+
* <PathStep id="details"><DetailsForm /></PathStep>
|
|
53
|
+
* <PathStep id="review"><ReviewPanel /></PathStep>
|
|
54
|
+
* </PathShell>
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export const PathShell = defineComponent({
|
|
58
|
+
name: "PathShell",
|
|
59
|
+
props: {
|
|
60
|
+
path: { type: Object, required: true },
|
|
61
|
+
initialData: { type: Object, default: () => ({}) },
|
|
62
|
+
autoStart: { type: Boolean, default: true },
|
|
63
|
+
backLabel: { type: String, default: "Back" },
|
|
64
|
+
nextLabel: { type: String, default: "Next" },
|
|
65
|
+
finishLabel: { type: String, default: "Finish" },
|
|
66
|
+
cancelLabel: { type: String, default: "Cancel" },
|
|
67
|
+
hideCancel: { type: Boolean, default: false },
|
|
68
|
+
hideProgress: { type: Boolean, default: false }
|
|
69
|
+
},
|
|
70
|
+
emits: ["complete", "cancel", "event"],
|
|
71
|
+
setup(props, { slots, emit }) {
|
|
72
|
+
const pathReturn = usePath({
|
|
73
|
+
onEvent(event) {
|
|
74
|
+
emit("event", event);
|
|
75
|
+
if (event.type === "completed")
|
|
76
|
+
emit("complete", event.data);
|
|
77
|
+
if (event.type === "cancelled")
|
|
78
|
+
emit("cancel", event.data);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
const { snapshot, start, next, previous, cancel, goToStep, setData } = pathReturn;
|
|
82
|
+
const started = ref(false);
|
|
83
|
+
onMounted(() => {
|
|
84
|
+
if (props.autoStart && !started.value) {
|
|
85
|
+
started.value = true;
|
|
86
|
+
start(props.path, props.initialData);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
const actions = { next, previous, cancel, goToStep, setData };
|
|
90
|
+
return () => {
|
|
91
|
+
const snap = snapshot.value;
|
|
92
|
+
if (!snap) {
|
|
93
|
+
return h("div", { class: "pw-shell" }, h("div", { class: "pw-shell__empty" }, [
|
|
94
|
+
h("p", "No active path."),
|
|
95
|
+
!props.autoStart
|
|
96
|
+
? h("button", {
|
|
97
|
+
type: "button",
|
|
98
|
+
class: "pw-shell__start-btn",
|
|
99
|
+
onClick: () => start(props.path, props.initialData)
|
|
100
|
+
}, "Start")
|
|
101
|
+
: null
|
|
102
|
+
]));
|
|
103
|
+
}
|
|
104
|
+
// Resolve step content from default slot children
|
|
105
|
+
const stepContent = resolveVueStepContent(slots, snap);
|
|
106
|
+
return h("div", { class: "pw-shell" }, [
|
|
107
|
+
// Header — progress
|
|
108
|
+
!props.hideProgress && (slots.header
|
|
109
|
+
? slots.header({ snapshot: snap })
|
|
110
|
+
: renderVueHeader(snap)),
|
|
111
|
+
// Body — step content
|
|
112
|
+
h("div", { class: "pw-shell__body" }, stepContent ?? []),
|
|
113
|
+
// Footer — navigation
|
|
114
|
+
slots.footer
|
|
115
|
+
? slots.footer({ snapshot: snap, actions })
|
|
116
|
+
: renderVueFooter(snap, actions, props)
|
|
117
|
+
]);
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
// ---------------------------------------------------------------------------
|
|
122
|
+
// Default header (progress indicator)
|
|
123
|
+
// ---------------------------------------------------------------------------
|
|
124
|
+
function renderVueHeader(snapshot) {
|
|
125
|
+
return h("div", { class: "pw-shell__header" }, [
|
|
126
|
+
h("div", { class: "pw-shell__steps" }, snapshot.steps.map((step, i) => h("div", {
|
|
127
|
+
key: step.id,
|
|
128
|
+
class: ["pw-shell__step", `pw-shell__step--${step.status}`]
|
|
129
|
+
}, [
|
|
130
|
+
h("span", { class: "pw-shell__step-dot" }, step.status === "completed" ? "✓" : String(i + 1)),
|
|
131
|
+
h("span", { class: "pw-shell__step-label" }, step.title ?? step.id)
|
|
132
|
+
]))),
|
|
133
|
+
h("div", { class: "pw-shell__track" }, h("div", {
|
|
134
|
+
class: "pw-shell__track-fill",
|
|
135
|
+
style: { width: `${snapshot.progress * 100}%` }
|
|
136
|
+
}))
|
|
137
|
+
]);
|
|
138
|
+
}
|
|
139
|
+
// ---------------------------------------------------------------------------
|
|
140
|
+
// Default footer (navigation buttons)
|
|
141
|
+
// ---------------------------------------------------------------------------
|
|
142
|
+
function renderVueFooter(snapshot, actions, props) {
|
|
143
|
+
return h("div", { class: "pw-shell__footer" }, [
|
|
144
|
+
h("div", { class: "pw-shell__footer-left" }, [
|
|
145
|
+
!snapshot.isFirstStep
|
|
146
|
+
? h("button", {
|
|
147
|
+
type: "button",
|
|
148
|
+
class: "pw-shell__btn pw-shell__btn--back",
|
|
149
|
+
disabled: snapshot.isNavigating,
|
|
150
|
+
onClick: actions.previous
|
|
151
|
+
}, props.backLabel)
|
|
152
|
+
: null
|
|
153
|
+
]),
|
|
154
|
+
h("div", { class: "pw-shell__footer-right" }, [
|
|
155
|
+
!props.hideCancel
|
|
156
|
+
? h("button", {
|
|
157
|
+
type: "button",
|
|
158
|
+
class: "pw-shell__btn pw-shell__btn--cancel",
|
|
159
|
+
disabled: snapshot.isNavigating,
|
|
160
|
+
onClick: actions.cancel
|
|
161
|
+
}, props.cancelLabel)
|
|
162
|
+
: null,
|
|
163
|
+
h("button", {
|
|
164
|
+
type: "button",
|
|
165
|
+
class: "pw-shell__btn pw-shell__btn--next",
|
|
166
|
+
disabled: snapshot.isNavigating,
|
|
167
|
+
onClick: actions.next
|
|
168
|
+
}, snapshot.isLastStep ? props.finishLabel : props.nextLabel)
|
|
169
|
+
])
|
|
170
|
+
]);
|
|
171
|
+
}
|
|
172
|
+
// ---------------------------------------------------------------------------
|
|
173
|
+
// Helpers
|
|
174
|
+
// ---------------------------------------------------------------------------
|
|
175
|
+
function resolveVueStepContent(slots, snapshot) {
|
|
176
|
+
// Look for a named slot matching the stepId
|
|
177
|
+
const namedSlot = slots[snapshot.stepId];
|
|
178
|
+
if (namedSlot)
|
|
179
|
+
return namedSlot({ snapshot });
|
|
180
|
+
// Fall back to scanning default slot children for <PathStep> with matching id
|
|
181
|
+
const defaultChildren = slots.default?.();
|
|
182
|
+
if (!defaultChildren)
|
|
183
|
+
return null;
|
|
184
|
+
for (const child of defaultChildren) {
|
|
185
|
+
if (child &&
|
|
186
|
+
typeof child === "object" &&
|
|
187
|
+
"type" in child &&
|
|
188
|
+
child.type === PathStep &&
|
|
189
|
+
child.props?.id === snapshot.stepId) {
|
|
190
|
+
// Return the PathStep's own children (its default slot)
|
|
191
|
+
const stepSlots = child.children?.default;
|
|
192
|
+
if (typeof stepSlots === "function")
|
|
193
|
+
return stepSlots();
|
|
194
|
+
if (Array.isArray(child.children))
|
|
195
|
+
return child.children;
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,UAAU,EACV,QAAQ,EACR,cAAc,EACd,eAAe,EACf,CAAC,EAED,SAAS,EAKV,MAAM,KAAK,CAAC;AACb,OAAO,EAGL,UAAU,EAGX,MAAM,yBAAyB,CAAC;AA8BjC,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAE9E,MAAM,UAAU,OAAO,CAAC,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,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;IAE9C,8EAA8E;IAC9E,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;IAC1C,IAAI,CAAC,eAAe;QAAE,OAAO,IAAI,CAAC;IAElC,KAAK,MAAM,KAAK,IAAI,eAAe,EAAE,CAAC;QACpC,IACE,KAAK;YACL,OAAO,KAAK,KAAK,QAAQ;YACzB,MAAM,IAAI,KAAK;YACf,KAAK,CAAC,IAAI,KAAK,QAAQ;YACvB,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,QAAQ,CAAC,MAAM,EACnC,CAAC;YACD,wDAAwD;YACxD,MAAM,SAAS,GAAI,KAAK,CAAC,QAAgB,EAAE,OAAO,CAAC;YACnD,IAAI,OAAO,SAAS,KAAK,UAAU;gBAAE,OAAO,SAAS,EAAE,CAAC;YACxD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC;gBAAE,OAAO,KAAK,CAAC,QAAmB,CAAC;YACpE,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@daltonr/pathwrite-vue",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"description": "Vue 3 adapter for @daltonr/pathwrite-core — composables with reactive refs, and optional <PathShell> default UI.",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/richardadalton/pathwrite.git",
|
|
10
|
+
"directory": "packages/vue-adapter"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"wizard",
|
|
14
|
+
"stepper",
|
|
15
|
+
"path",
|
|
16
|
+
"vue",
|
|
17
|
+
"vue3",
|
|
18
|
+
"composable",
|
|
19
|
+
"multi-step",
|
|
20
|
+
"workflow"
|
|
21
|
+
],
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"main": "dist/index.js",
|
|
30
|
+
"types": "dist/index.d.ts",
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"README.md",
|
|
34
|
+
"LICENSE"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc -p tsconfig.json",
|
|
38
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo",
|
|
39
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"vue": ">=3.3.0"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@daltonr/pathwrite-core": "^0.1.1"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@vue/test-utils": "^2.4.6",
|
|
49
|
+
"vue": "^3.5.13"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
}
|
|
54
|
+
}
|