react-wizard-engine 0.1.7 → 0.1.8
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/CHANGELOG.md +6 -0
- package/README.md +2 -5
- package/dist/chunk-RBC55LQI.js +2 -0
- package/dist/chunk-S2FOYHDE.cjs +2 -0
- package/dist/index.cjs +1 -2188
- package/dist/index.js +1 -2188
- package/dist/shadcn/index.cjs +1 -219
- package/dist/shadcn/index.js +1 -219
- package/package.json +1 -7
- package/dist/chunk-5BUIFXZY.cjs +0 -90
- package/dist/chunk-5BUIFXZY.cjs.map +0 -1
- package/dist/chunk-VXJ5MZUG.js +0 -90
- package/dist/chunk-VXJ5MZUG.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/shadcn/index.cjs.map +0 -1
- package/dist/shadcn/index.js.map +0 -1
package/dist/shadcn/index.cjs
CHANGED
|
@@ -1,220 +1,2 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var _chunk5BUIFXZYcjs = require('../chunk-5BUIFXZY.cjs');
|
|
8
|
-
|
|
9
|
-
// src/shadcn/default-back-arrow-icon.tsx
|
|
10
|
-
var _jsxruntime = require('react/jsx-runtime');
|
|
11
|
-
function defaultBackArrowIcon({ className, ...rest }) {
|
|
12
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
13
|
-
"svg",
|
|
14
|
-
{
|
|
15
|
-
className: _chunk5BUIFXZYcjs.cn.call(void 0,
|
|
16
|
-
"h-4 w-4 transition-transform duration-150 group-hover:-translate-x-0.5",
|
|
17
|
-
className
|
|
18
|
-
),
|
|
19
|
-
fill: "none",
|
|
20
|
-
stroke: "currentColor",
|
|
21
|
-
strokeWidth: 1.75,
|
|
22
|
-
strokeLinecap: "round",
|
|
23
|
-
strokeLinejoin: "round",
|
|
24
|
-
viewBox: "0 0 16 16",
|
|
25
|
-
"aria-hidden": true,
|
|
26
|
-
...rest,
|
|
27
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M10 4 L6 8 L10 12" })
|
|
28
|
-
}
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// src/shadcn/default-button.tsx
|
|
33
|
-
var _reactslot = require('@radix-ui/react-slot');
|
|
34
|
-
var _classvarianceauthority = require('class-variance-authority');
|
|
35
|
-
var _react = require('react');
|
|
36
|
-
|
|
37
|
-
var buttonVariants = _classvarianceauthority.cva.call(void 0,
|
|
38
|
-
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
39
|
-
{
|
|
40
|
-
variants: {
|
|
41
|
-
variant: {
|
|
42
|
-
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
43
|
-
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
44
|
-
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground"
|
|
45
|
-
},
|
|
46
|
-
size: {
|
|
47
|
-
default: "h-9 px-4 py-2",
|
|
48
|
-
"icon-sm": "h-8 w-8"
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
defaultVariants: {
|
|
52
|
-
variant: "default",
|
|
53
|
-
size: "default"
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
);
|
|
57
|
-
var defaultButton = _react.forwardRef.call(void 0, function DefaultButton({ asChild, className, size, variant, type, ...rest }, ref) {
|
|
58
|
-
const Comp = asChild ? _reactslot.Slot : "button";
|
|
59
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
60
|
-
Comp,
|
|
61
|
-
{
|
|
62
|
-
ref,
|
|
63
|
-
type: asChild ? void 0 : _nullishCoalesce(type, () => ( "button")),
|
|
64
|
-
className: _chunk5BUIFXZYcjs.cn.call(void 0, buttonVariants({ size, variant }), className),
|
|
65
|
-
...rest
|
|
66
|
-
}
|
|
67
|
-
);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
// src/shadcn/components-provider-with-defaults.tsx
|
|
71
|
-
|
|
72
|
-
function WizardComponentsProviderWithDefaults({ children }) {
|
|
73
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk5BUIFXZYcjs.WizardComponentsProvider, { Button: defaultButton, BackArrowIcon: defaultBackArrowIcon, children });
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// src/shadcn/wizard-layout.tsx
|
|
77
|
-
var _reactdialog = require('@radix-ui/react-dialog'); var Dialog = _interopRequireWildcard(_reactdialog);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
// src/shadcn/wizard-layout.context.ts
|
|
81
|
-
|
|
82
|
-
var WizardLayoutContext = _react.createContext.call(void 0, null);
|
|
83
|
-
|
|
84
|
-
// src/shadcn/wizard-layout.tsx
|
|
85
|
-
|
|
86
|
-
var WizardLayout = _react.forwardRef.call(void 0, function WizardLayout2(props, ref) {
|
|
87
|
-
const { children, className, defaultRailTitle = "Wizard steps", rail, railTitle, topBar } = props;
|
|
88
|
-
const [mobileSheetOpen, setMobileSheetOpen] = _react.useState.call(void 0, false);
|
|
89
|
-
const closeMobileSheet = () => setMobileSheetOpen(false);
|
|
90
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, WizardLayoutContext.Provider, { value: { mobileSheetOpen, setMobileSheetOpen }, children: [
|
|
91
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: _chunk5BUIFXZYcjs.cn.call(void 0, "flex h-full min-h-0 w-full flex-1 bg-sidebar", className), "data-slot": "wizard-layout-outer", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
92
|
-
"div",
|
|
93
|
-
{
|
|
94
|
-
className: "flex flex-1 overflow-hidden bg-background text-foreground shadow-sm ring-1 ring-foreground/10 md:rounded-xl",
|
|
95
|
-
"data-slot": "wizard-layout",
|
|
96
|
-
children: [
|
|
97
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
98
|
-
"aside",
|
|
99
|
-
{
|
|
100
|
-
className: "hidden w-[280px] shrink-0 flex-col gap-4 border-r border-border px-4 py-6 md:flex",
|
|
101
|
-
"data-slot": "wizard-layout-rail",
|
|
102
|
-
children: [
|
|
103
|
-
railTitle && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "px-3 text-base font-semibold text-foreground", children: railTitle }),
|
|
104
|
-
rail
|
|
105
|
-
]
|
|
106
|
-
}
|
|
107
|
-
),
|
|
108
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
109
|
-
topBar,
|
|
110
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
111
|
-
"div",
|
|
112
|
-
{
|
|
113
|
-
className: "min-h-0 flex-1 overflow-y-auto px-4 py-6 sm:px-8",
|
|
114
|
-
"data-slot": "wizard-layout-scroll",
|
|
115
|
-
ref,
|
|
116
|
-
children
|
|
117
|
-
}
|
|
118
|
-
)
|
|
119
|
-
] })
|
|
120
|
-
]
|
|
121
|
-
}
|
|
122
|
-
) }),
|
|
123
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Dialog.Root, { onOpenChange: setMobileSheetOpen, open: mobileSheetOpen, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Dialog.Portal, { children: [
|
|
124
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Dialog.Overlay, { className: "fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0" }),
|
|
125
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
126
|
-
Dialog.Content,
|
|
127
|
-
{
|
|
128
|
-
"aria-describedby": void 0,
|
|
129
|
-
className: "fixed inset-y-0 left-0 z-50 flex w-3/4 max-w-sm flex-col gap-4 border-r border-border bg-background px-4 py-6 shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left",
|
|
130
|
-
children: [
|
|
131
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Dialog.Title, { className: "px-3 text-base font-semibold", children: _nullishCoalesce(railTitle, () => ( defaultRailTitle)) }),
|
|
132
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { onClickCapture: closeMobileSheet, children: rail })
|
|
133
|
-
]
|
|
134
|
-
}
|
|
135
|
-
)
|
|
136
|
-
] }) })
|
|
137
|
-
] });
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
// src/shadcn/wizard-top-bar.tsx
|
|
141
|
-
var _lucidereact = require('lucide-react');
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
function WizardTopBar(props) {
|
|
145
|
-
const { backLabel, className, closeLabel, disabled, extraActions, finishLabel, menuLabel, nextLabel, onClose } = props;
|
|
146
|
-
const wizard = _chunk5BUIFXZYcjs.useWizard.call(void 0, );
|
|
147
|
-
const layout = _react.useContext.call(void 0, WizardLayoutContext);
|
|
148
|
-
const { Button, BackArrowIcon } = _chunk5BUIFXZYcjs.useWizardComponents.call(void 0, );
|
|
149
|
-
const config = wizard.configOptions;
|
|
150
|
-
const tree = wizard.tree;
|
|
151
|
-
const isFirstStep = tree.activeBranch.prevCategory == null && tree.activeCategory.prevStep == null;
|
|
152
|
-
const isLastStep = tree.activeBranch.nextCategory == null && tree.activeCategory.nextStep == null;
|
|
153
|
-
const resolvedBackLabel = _nullishCoalesce(backLabel, () => ( config.backBtnText));
|
|
154
|
-
const resolvedFinishLabel = _nullishCoalesce(finishLabel, () => ( config.finishText));
|
|
155
|
-
const resolvedNextLabel = _nullishCoalesce(nextLabel, () => ( config.nextBtnText));
|
|
156
|
-
const resolvedMenuLabel = _nullishCoalesce(menuLabel, () => ( "Open wizard steps"));
|
|
157
|
-
const resolvedCloseLabel = _nullishCoalesce(closeLabel, () => ( "Close"));
|
|
158
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
159
|
-
"div",
|
|
160
|
-
{
|
|
161
|
-
className: _chunk5BUIFXZYcjs.cn.call(void 0, "flex h-14 items-center gap-3 border-b border-border bg-background px-4 sm:px-6", className),
|
|
162
|
-
"data-slot": "wizard-top-bar",
|
|
163
|
-
children: [
|
|
164
|
-
layout && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
165
|
-
Button,
|
|
166
|
-
{
|
|
167
|
-
"aria-label": resolvedMenuLabel,
|
|
168
|
-
className: "md:hidden",
|
|
169
|
-
onClick: () => layout.setMobileSheetOpen(true),
|
|
170
|
-
size: "icon-sm",
|
|
171
|
-
type: "button",
|
|
172
|
-
variant: "ghost",
|
|
173
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.MenuIcon, {})
|
|
174
|
-
}
|
|
175
|
-
),
|
|
176
|
-
!isFirstStep && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
177
|
-
"button",
|
|
178
|
-
{
|
|
179
|
-
"aria-label": typeof resolvedBackLabel === "string" ? resolvedBackLabel : void 0,
|
|
180
|
-
className: "group inline-flex items-center gap-1 rounded-md py-1 pr-2.5 pl-3.5 text-sm font-normal text-muted-foreground transition-colors duration-150 hover:bg-muted hover:text-foreground",
|
|
181
|
-
onClick: () => {
|
|
182
|
-
void wizard.back();
|
|
183
|
-
},
|
|
184
|
-
type: "button",
|
|
185
|
-
children: [
|
|
186
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BackArrowIcon, {}),
|
|
187
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: resolvedBackLabel })
|
|
188
|
-
]
|
|
189
|
-
}
|
|
190
|
-
),
|
|
191
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-1 items-center justify-end gap-2", children: [
|
|
192
|
-
extraActions,
|
|
193
|
-
isLastStep ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Button, { disabled, type: "submit", variant: "default", children: resolvedFinishLabel }, "wizard-finish") : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
194
|
-
Button,
|
|
195
|
-
{
|
|
196
|
-
disabled,
|
|
197
|
-
onClick: () => {
|
|
198
|
-
void wizard.next();
|
|
199
|
-
},
|
|
200
|
-
type: "button",
|
|
201
|
-
variant: "default",
|
|
202
|
-
children: resolvedNextLabel
|
|
203
|
-
},
|
|
204
|
-
"wizard-next"
|
|
205
|
-
),
|
|
206
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Button, { "aria-label": resolvedCloseLabel, onClick: onClose, size: "icon-sm", type: "button", variant: "ghost", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.XIcon, {}) })
|
|
207
|
-
] })
|
|
208
|
-
]
|
|
209
|
-
}
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
exports.WizardComponentsProviderWithDefaults = WizardComponentsProviderWithDefaults; exports.WizardLayout = WizardLayout; exports.WizardLayoutContext = WizardLayoutContext; exports.WizardTopBar = WizardTopBar; exports.defaultBackArrowIcon = defaultBackArrowIcon; exports.defaultButton = defaultButton;
|
|
220
|
-
//# sourceMappingURL=index.cjs.map
|
|
2
|
+
var _chunkS2FOYHDEcjs = require('../chunk-S2FOYHDE.cjs');var _jsxruntime = require('react/jsx-runtime');function C({className:n,...t}){return _jsxruntime.jsx.call(void 0, "svg",{className:_chunkS2FOYHDEcjs.i.call(void 0, "h-4 w-4 transition-transform duration-150 group-hover:-translate-x-0.5",n),fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 16 16","aria-hidden":!0,...t,children:_jsxruntime.jsx.call(void 0, "path",{d:"M10 4 L6 8 L10 12"})})}var _reactslot = require('@radix-ui/react-slot');var _classvarianceauthority = require('class-variance-authority');var _react = require('react');var E=_classvarianceauthority.cva.call(void 0, "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",ghost:"hover:bg-accent hover:text-accent-foreground",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 px-4 py-2","icon-sm":"h-8 w-8"}},defaultVariants:{variant:"default",size:"default"}}),L= exports.defaultButton =_react.forwardRef.call(void 0, function({asChild:t,className:p,size:u,variant:s,type:f,...d},i){return _jsxruntime.jsx.call(void 0, t?_reactslot.Slot:"button",{ref:i,type:t?void 0:_nullishCoalesce(f, () => ("button")),className:_chunkS2FOYHDEcjs.i.call(void 0, E({size:u,variant:s}),p),...d})});function H({children:n}){return _jsxruntime.jsx.call(void 0, _chunkS2FOYHDEcjs.e,{Button:L,BackArrowIcon:C,children:n})}var _reactdialog = require('@radix-ui/react-dialog'); var e = _interopRequireWildcard(_reactdialog);var m=_react.createContext.call(void 0, null);var K=_react.forwardRef.call(void 0, function(t,p){let{children:u,className:s,defaultRailTitle:f="Wizard steps",rail:d,railTitle:i,topBar:b}=t,[x,o]=_react.useState.call(void 0, !1),v=()=>o(!1);return _jsxruntime.jsxs.call(void 0, m.Provider,{value:{mobileSheetOpen:x,setMobileSheetOpen:o},children:[_jsxruntime.jsx.call(void 0, "div",{className:_chunkS2FOYHDEcjs.i.call(void 0, "flex h-full min-h-0 w-full flex-1 bg-sidebar",s),"data-slot":"wizard-layout-outer",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-1 overflow-hidden bg-background text-foreground shadow-sm ring-1 ring-foreground/10 md:rounded-xl","data-slot":"wizard-layout",children:[_jsxruntime.jsxs.call(void 0, "aside",{className:"hidden w-[280px] shrink-0 flex-col gap-4 border-r border-border px-4 py-6 md:flex","data-slot":"wizard-layout-rail",children:[i&&_jsxruntime.jsx.call(void 0, "div",{className:"px-3 text-base font-semibold text-foreground",children:i}),d]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex min-w-0 flex-1 flex-col",children:[b,_jsxruntime.jsx.call(void 0, "div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-6 sm:px-8","data-slot":"wizard-layout-scroll",ref:p,children:u})]})]})}),_jsxruntime.jsx.call(void 0, e.Root,{onOpenChange:o,open:x,children:_jsxruntime.jsxs.call(void 0, e.Portal,{children:[_jsxruntime.jsx.call(void 0, e.Overlay,{className:"fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"}),_jsxruntime.jsxs.call(void 0, e.Content,{"aria-describedby":void 0,className:"fixed inset-y-0 left-0 z-50 flex w-3/4 max-w-sm flex-col gap-4 border-r border-border bg-background px-4 py-6 shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left",children:[_jsxruntime.jsx.call(void 0, e.Title,{className:"px-3 text-base font-semibold",children:_nullishCoalesce(i, () => (f))}),_jsxruntime.jsx.call(void 0, "div",{onClickCapture:v,children:d})]})]})})]})});var _lucidereact = require('lucide-react');function Z(n){let{backLabel:t,className:p,closeLabel:u,disabled:s,extraActions:f,finishLabel:d,menuLabel:i,nextLabel:b,onClose:x}=n,o=_chunkS2FOYHDEcjs.h.call(void 0, ),v=_react.useContext.call(void 0, m),{Button:g,BackArrowIcon:P}=_chunkS2FOYHDEcjs.f.call(void 0, ),h=o.configOptions,y=o.tree,R=y.activeBranch.prevCategory==null&&y.activeCategory.prevStep==null,I=y.activeBranch.nextCategory==null&&y.activeCategory.nextStep==null,z=_nullishCoalesce(t, () => (h.backBtnText)),T=_nullishCoalesce(d, () => (h.finishText)),D=_nullishCoalesce(b, () => (h.nextBtnText)),S=_nullishCoalesce(i, () => ("Open wizard steps")),O=_nullishCoalesce(u, () => ("Close"));return _jsxruntime.jsxs.call(void 0, "div",{className:_chunkS2FOYHDEcjs.i.call(void 0, "flex h-14 items-center gap-3 border-b border-border bg-background px-4 sm:px-6",p),"data-slot":"wizard-top-bar",children:[v&&_jsxruntime.jsx.call(void 0, g,{"aria-label":S,className:"md:hidden",onClick:()=>v.setMobileSheetOpen(!0),size:"icon-sm",type:"button",variant:"ghost",children:_jsxruntime.jsx.call(void 0, _lucidereact.MenuIcon,{})}),!R&&_jsxruntime.jsxs.call(void 0, "button",{"aria-label":typeof z=="string"?z:void 0,className:"group inline-flex items-center gap-1 rounded-md py-1 pr-2.5 pl-3.5 text-sm font-normal text-muted-foreground transition-colors duration-150 hover:bg-muted hover:text-foreground",onClick:()=>{o.back()},type:"button",children:[_jsxruntime.jsx.call(void 0, P,{}),_jsxruntime.jsx.call(void 0, "span",{children:z})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-1 items-center justify-end gap-2",children:[f,I?_jsxruntime.jsx.call(void 0, g,{disabled:s,type:"submit",variant:"default",children:T},"wizard-finish"):_jsxruntime.jsx.call(void 0, g,{disabled:s,onClick:()=>{o.next()},type:"button",variant:"default",children:D},"wizard-next"),_jsxruntime.jsx.call(void 0, g,{"aria-label":O,onClick:x,size:"icon-sm",type:"button",variant:"ghost",children:_jsxruntime.jsx.call(void 0, _lucidereact.XIcon,{})})]})]})}exports.WizardComponentsProviderWithDefaults = H; exports.WizardLayout = K; exports.WizardLayoutContext = m; exports.WizardTopBar = Z; exports.defaultBackArrowIcon = C; exports.defaultButton = L;
|
package/dist/shadcn/index.js
CHANGED
|
@@ -1,220 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
WizardComponentsProvider,
|
|
4
|
-
cn,
|
|
5
|
-
useWizard,
|
|
6
|
-
useWizardComponents
|
|
7
|
-
} from "../chunk-VXJ5MZUG.js";
|
|
8
|
-
|
|
9
|
-
// src/shadcn/default-back-arrow-icon.tsx
|
|
10
|
-
import { jsx } from "react/jsx-runtime";
|
|
11
|
-
function defaultBackArrowIcon({ className, ...rest }) {
|
|
12
|
-
return /* @__PURE__ */ jsx(
|
|
13
|
-
"svg",
|
|
14
|
-
{
|
|
15
|
-
className: cn(
|
|
16
|
-
"h-4 w-4 transition-transform duration-150 group-hover:-translate-x-0.5",
|
|
17
|
-
className
|
|
18
|
-
),
|
|
19
|
-
fill: "none",
|
|
20
|
-
stroke: "currentColor",
|
|
21
|
-
strokeWidth: 1.75,
|
|
22
|
-
strokeLinecap: "round",
|
|
23
|
-
strokeLinejoin: "round",
|
|
24
|
-
viewBox: "0 0 16 16",
|
|
25
|
-
"aria-hidden": true,
|
|
26
|
-
...rest,
|
|
27
|
-
children: /* @__PURE__ */ jsx("path", { d: "M10 4 L6 8 L10 12" })
|
|
28
|
-
}
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// src/shadcn/default-button.tsx
|
|
33
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
34
|
-
import { cva } from "class-variance-authority";
|
|
35
|
-
import { forwardRef } from "react";
|
|
36
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
37
|
-
var buttonVariants = cva(
|
|
38
|
-
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
39
|
-
{
|
|
40
|
-
variants: {
|
|
41
|
-
variant: {
|
|
42
|
-
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
43
|
-
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
44
|
-
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground"
|
|
45
|
-
},
|
|
46
|
-
size: {
|
|
47
|
-
default: "h-9 px-4 py-2",
|
|
48
|
-
"icon-sm": "h-8 w-8"
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
defaultVariants: {
|
|
52
|
-
variant: "default",
|
|
53
|
-
size: "default"
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
);
|
|
57
|
-
var defaultButton = forwardRef(function DefaultButton({ asChild, className, size, variant, type, ...rest }, ref) {
|
|
58
|
-
const Comp = asChild ? Slot : "button";
|
|
59
|
-
return /* @__PURE__ */ jsx2(
|
|
60
|
-
Comp,
|
|
61
|
-
{
|
|
62
|
-
ref,
|
|
63
|
-
type: asChild ? void 0 : type ?? "button",
|
|
64
|
-
className: cn(buttonVariants({ size, variant }), className),
|
|
65
|
-
...rest
|
|
66
|
-
}
|
|
67
|
-
);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
// src/shadcn/components-provider-with-defaults.tsx
|
|
71
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
72
|
-
function WizardComponentsProviderWithDefaults({ children }) {
|
|
73
|
-
return /* @__PURE__ */ jsx3(WizardComponentsProvider, { Button: defaultButton, BackArrowIcon: defaultBackArrowIcon, children });
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// src/shadcn/wizard-layout.tsx
|
|
77
|
-
import * as Dialog from "@radix-ui/react-dialog";
|
|
78
|
-
import { forwardRef as forwardRef2, useState } from "react";
|
|
79
|
-
|
|
80
|
-
// src/shadcn/wizard-layout.context.ts
|
|
81
|
-
import { createContext } from "react";
|
|
82
|
-
var WizardLayoutContext = createContext(null);
|
|
83
|
-
|
|
84
|
-
// src/shadcn/wizard-layout.tsx
|
|
85
|
-
import { jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
86
|
-
var WizardLayout = forwardRef2(function WizardLayout2(props, ref) {
|
|
87
|
-
const { children, className, defaultRailTitle = "Wizard steps", rail, railTitle, topBar } = props;
|
|
88
|
-
const [mobileSheetOpen, setMobileSheetOpen] = useState(false);
|
|
89
|
-
const closeMobileSheet = () => setMobileSheetOpen(false);
|
|
90
|
-
return /* @__PURE__ */ jsxs(WizardLayoutContext.Provider, { value: { mobileSheetOpen, setMobileSheetOpen }, children: [
|
|
91
|
-
/* @__PURE__ */ jsx4("div", { className: cn("flex h-full min-h-0 w-full flex-1 bg-sidebar", className), "data-slot": "wizard-layout-outer", children: /* @__PURE__ */ jsxs(
|
|
92
|
-
"div",
|
|
93
|
-
{
|
|
94
|
-
className: "flex flex-1 overflow-hidden bg-background text-foreground shadow-sm ring-1 ring-foreground/10 md:rounded-xl",
|
|
95
|
-
"data-slot": "wizard-layout",
|
|
96
|
-
children: [
|
|
97
|
-
/* @__PURE__ */ jsxs(
|
|
98
|
-
"aside",
|
|
99
|
-
{
|
|
100
|
-
className: "hidden w-[280px] shrink-0 flex-col gap-4 border-r border-border px-4 py-6 md:flex",
|
|
101
|
-
"data-slot": "wizard-layout-rail",
|
|
102
|
-
children: [
|
|
103
|
-
railTitle && /* @__PURE__ */ jsx4("div", { className: "px-3 text-base font-semibold text-foreground", children: railTitle }),
|
|
104
|
-
rail
|
|
105
|
-
]
|
|
106
|
-
}
|
|
107
|
-
),
|
|
108
|
-
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
109
|
-
topBar,
|
|
110
|
-
/* @__PURE__ */ jsx4(
|
|
111
|
-
"div",
|
|
112
|
-
{
|
|
113
|
-
className: "min-h-0 flex-1 overflow-y-auto px-4 py-6 sm:px-8",
|
|
114
|
-
"data-slot": "wizard-layout-scroll",
|
|
115
|
-
ref,
|
|
116
|
-
children
|
|
117
|
-
}
|
|
118
|
-
)
|
|
119
|
-
] })
|
|
120
|
-
]
|
|
121
|
-
}
|
|
122
|
-
) }),
|
|
123
|
-
/* @__PURE__ */ jsx4(Dialog.Root, { onOpenChange: setMobileSheetOpen, open: mobileSheetOpen, children: /* @__PURE__ */ jsxs(Dialog.Portal, { children: [
|
|
124
|
-
/* @__PURE__ */ jsx4(Dialog.Overlay, { className: "fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0" }),
|
|
125
|
-
/* @__PURE__ */ jsxs(
|
|
126
|
-
Dialog.Content,
|
|
127
|
-
{
|
|
128
|
-
"aria-describedby": void 0,
|
|
129
|
-
className: "fixed inset-y-0 left-0 z-50 flex w-3/4 max-w-sm flex-col gap-4 border-r border-border bg-background px-4 py-6 shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left",
|
|
130
|
-
children: [
|
|
131
|
-
/* @__PURE__ */ jsx4(Dialog.Title, { className: "px-3 text-base font-semibold", children: railTitle ?? defaultRailTitle }),
|
|
132
|
-
/* @__PURE__ */ jsx4("div", { onClickCapture: closeMobileSheet, children: rail })
|
|
133
|
-
]
|
|
134
|
-
}
|
|
135
|
-
)
|
|
136
|
-
] }) })
|
|
137
|
-
] });
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
// src/shadcn/wizard-top-bar.tsx
|
|
141
|
-
import { MenuIcon, XIcon } from "lucide-react";
|
|
142
|
-
import { useContext } from "react";
|
|
143
|
-
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
144
|
-
function WizardTopBar(props) {
|
|
145
|
-
const { backLabel, className, closeLabel, disabled, extraActions, finishLabel, menuLabel, nextLabel, onClose } = props;
|
|
146
|
-
const wizard = useWizard();
|
|
147
|
-
const layout = useContext(WizardLayoutContext);
|
|
148
|
-
const { Button, BackArrowIcon } = useWizardComponents();
|
|
149
|
-
const config = wizard.configOptions;
|
|
150
|
-
const tree = wizard.tree;
|
|
151
|
-
const isFirstStep = tree.activeBranch.prevCategory == null && tree.activeCategory.prevStep == null;
|
|
152
|
-
const isLastStep = tree.activeBranch.nextCategory == null && tree.activeCategory.nextStep == null;
|
|
153
|
-
const resolvedBackLabel = backLabel ?? config.backBtnText;
|
|
154
|
-
const resolvedFinishLabel = finishLabel ?? config.finishText;
|
|
155
|
-
const resolvedNextLabel = nextLabel ?? config.nextBtnText;
|
|
156
|
-
const resolvedMenuLabel = menuLabel ?? "Open wizard steps";
|
|
157
|
-
const resolvedCloseLabel = closeLabel ?? "Close";
|
|
158
|
-
return /* @__PURE__ */ jsxs2(
|
|
159
|
-
"div",
|
|
160
|
-
{
|
|
161
|
-
className: cn("flex h-14 items-center gap-3 border-b border-border bg-background px-4 sm:px-6", className),
|
|
162
|
-
"data-slot": "wizard-top-bar",
|
|
163
|
-
children: [
|
|
164
|
-
layout && /* @__PURE__ */ jsx5(
|
|
165
|
-
Button,
|
|
166
|
-
{
|
|
167
|
-
"aria-label": resolvedMenuLabel,
|
|
168
|
-
className: "md:hidden",
|
|
169
|
-
onClick: () => layout.setMobileSheetOpen(true),
|
|
170
|
-
size: "icon-sm",
|
|
171
|
-
type: "button",
|
|
172
|
-
variant: "ghost",
|
|
173
|
-
children: /* @__PURE__ */ jsx5(MenuIcon, {})
|
|
174
|
-
}
|
|
175
|
-
),
|
|
176
|
-
!isFirstStep && /* @__PURE__ */ jsxs2(
|
|
177
|
-
"button",
|
|
178
|
-
{
|
|
179
|
-
"aria-label": typeof resolvedBackLabel === "string" ? resolvedBackLabel : void 0,
|
|
180
|
-
className: "group inline-flex items-center gap-1 rounded-md py-1 pr-2.5 pl-3.5 text-sm font-normal text-muted-foreground transition-colors duration-150 hover:bg-muted hover:text-foreground",
|
|
181
|
-
onClick: () => {
|
|
182
|
-
void wizard.back();
|
|
183
|
-
},
|
|
184
|
-
type: "button",
|
|
185
|
-
children: [
|
|
186
|
-
/* @__PURE__ */ jsx5(BackArrowIcon, {}),
|
|
187
|
-
/* @__PURE__ */ jsx5("span", { children: resolvedBackLabel })
|
|
188
|
-
]
|
|
189
|
-
}
|
|
190
|
-
),
|
|
191
|
-
/* @__PURE__ */ jsxs2("div", { className: "flex flex-1 items-center justify-end gap-2", children: [
|
|
192
|
-
extraActions,
|
|
193
|
-
isLastStep ? /* @__PURE__ */ jsx5(Button, { disabled, type: "submit", variant: "default", children: resolvedFinishLabel }, "wizard-finish") : /* @__PURE__ */ jsx5(
|
|
194
|
-
Button,
|
|
195
|
-
{
|
|
196
|
-
disabled,
|
|
197
|
-
onClick: () => {
|
|
198
|
-
void wizard.next();
|
|
199
|
-
},
|
|
200
|
-
type: "button",
|
|
201
|
-
variant: "default",
|
|
202
|
-
children: resolvedNextLabel
|
|
203
|
-
},
|
|
204
|
-
"wizard-next"
|
|
205
|
-
),
|
|
206
|
-
/* @__PURE__ */ jsx5(Button, { "aria-label": resolvedCloseLabel, onClick: onClose, size: "icon-sm", type: "button", variant: "ghost", children: /* @__PURE__ */ jsx5(XIcon, {}) })
|
|
207
|
-
] })
|
|
208
|
-
]
|
|
209
|
-
}
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
export {
|
|
213
|
-
WizardComponentsProviderWithDefaults,
|
|
214
|
-
WizardLayout,
|
|
215
|
-
WizardLayoutContext,
|
|
216
|
-
WizardTopBar,
|
|
217
|
-
defaultBackArrowIcon,
|
|
218
|
-
defaultButton
|
|
219
|
-
};
|
|
220
|
-
//# sourceMappingURL=index.js.map
|
|
2
|
+
import{e as w,f as B,h as W,i as a}from"../chunk-RBC55LQI.js";import{jsx as k}from"react/jsx-runtime";function C({className:n,...t}){return k("svg",{className:a("h-4 w-4 transition-transform duration-150 group-hover:-translate-x-0.5",n),fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 16 16","aria-hidden":!0,...t,children:k("path",{d:"M10 4 L6 8 L10 12"})})}import{Slot as M}from"@radix-ui/react-slot";import{cva as A}from"class-variance-authority";import{forwardRef as V}from"react";import{jsx as F}from"react/jsx-runtime";var E=A("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",ghost:"hover:bg-accent hover:text-accent-foreground",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 px-4 py-2","icon-sm":"h-8 w-8"}},defaultVariants:{variant:"default",size:"default"}}),L=V(function({asChild:t,className:p,size:u,variant:s,type:f,...d},i){return F(t?M:"button",{ref:i,type:t?void 0:f??"button",className:a(E({size:u,variant:s}),p),...d})});import{jsx as X}from"react/jsx-runtime";function H({children:n}){return X(w,{Button:L,BackArrowIcon:C,children:n})}import*as e from"@radix-ui/react-dialog";import{forwardRef as G,useState as J}from"react";import{createContext as q}from"react";var m=q(null);import{jsx as l,jsxs as c}from"react/jsx-runtime";var K=G(function(t,p){let{children:u,className:s,defaultRailTitle:f="Wizard steps",rail:d,railTitle:i,topBar:b}=t,[x,o]=J(!1),v=()=>o(!1);return c(m.Provider,{value:{mobileSheetOpen:x,setMobileSheetOpen:o},children:[l("div",{className:a("flex h-full min-h-0 w-full flex-1 bg-sidebar",s),"data-slot":"wizard-layout-outer",children:c("div",{className:"flex flex-1 overflow-hidden bg-background text-foreground shadow-sm ring-1 ring-foreground/10 md:rounded-xl","data-slot":"wizard-layout",children:[c("aside",{className:"hidden w-[280px] shrink-0 flex-col gap-4 border-r border-border px-4 py-6 md:flex","data-slot":"wizard-layout-rail",children:[i&&l("div",{className:"px-3 text-base font-semibold text-foreground",children:i}),d]}),c("div",{className:"flex min-w-0 flex-1 flex-col",children:[b,l("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-6 sm:px-8","data-slot":"wizard-layout-scroll",ref:p,children:u})]})]})}),l(e.Root,{onOpenChange:o,open:x,children:c(e.Portal,{children:[l(e.Overlay,{className:"fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"}),c(e.Content,{"aria-describedby":void 0,className:"fixed inset-y-0 left-0 z-50 flex w-3/4 max-w-sm flex-col gap-4 border-r border-border bg-background px-4 py-6 shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left",children:[l(e.Title,{className:"px-3 text-base font-semibold",children:i??f}),l("div",{onClickCapture:v,children:d})]})]})})]})});import{MenuIcon as Q,XIcon as U}from"lucide-react";import{useContext as Y}from"react";import{jsx as r,jsxs as N}from"react/jsx-runtime";function Z(n){let{backLabel:t,className:p,closeLabel:u,disabled:s,extraActions:f,finishLabel:d,menuLabel:i,nextLabel:b,onClose:x}=n,o=W(),v=Y(m),{Button:g,BackArrowIcon:P}=B(),h=o.configOptions,y=o.tree,R=y.activeBranch.prevCategory==null&&y.activeCategory.prevStep==null,I=y.activeBranch.nextCategory==null&&y.activeCategory.nextStep==null,z=t??h.backBtnText,T=d??h.finishText,D=b??h.nextBtnText,S=i??"Open wizard steps",O=u??"Close";return N("div",{className:a("flex h-14 items-center gap-3 border-b border-border bg-background px-4 sm:px-6",p),"data-slot":"wizard-top-bar",children:[v&&r(g,{"aria-label":S,className:"md:hidden",onClick:()=>v.setMobileSheetOpen(!0),size:"icon-sm",type:"button",variant:"ghost",children:r(Q,{})}),!R&&N("button",{"aria-label":typeof z=="string"?z:void 0,className:"group inline-flex items-center gap-1 rounded-md py-1 pr-2.5 pl-3.5 text-sm font-normal text-muted-foreground transition-colors duration-150 hover:bg-muted hover:text-foreground",onClick:()=>{o.back()},type:"button",children:[r(P,{}),r("span",{children:z})]}),N("div",{className:"flex flex-1 items-center justify-end gap-2",children:[f,I?r(g,{disabled:s,type:"submit",variant:"default",children:T},"wizard-finish"):r(g,{disabled:s,onClick:()=>{o.next()},type:"button",variant:"default",children:D},"wizard-next"),r(g,{"aria-label":O,onClick:x,size:"icon-sm",type:"button",variant:"ghost",children:r(U,{})})]})]})}export{H as WizardComponentsProviderWithDefaults,K as WizardLayout,m as WizardLayoutContext,Z as WizardTopBar,C as defaultBackArrowIcon,L as defaultButton};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-wizard-engine",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Multi-step flow engine for React: steps, categories, branches, pluggable strategies, async navigation with cancellation.",
|
|
6
6
|
"keywords": [
|
|
@@ -12,12 +12,6 @@
|
|
|
12
12
|
"flow",
|
|
13
13
|
"headless"
|
|
14
14
|
],
|
|
15
|
-
"repository": {
|
|
16
|
-
"type": "git",
|
|
17
|
-
"url": "git+https://github.com/knazark/react-wizard-engine.git"
|
|
18
|
-
},
|
|
19
|
-
"bugs": "https://github.com/knazark/react-wizard-engine/issues",
|
|
20
|
-
"homepage": "https://github.com/knazark/react-wizard-engine#readme",
|
|
21
15
|
"author": "Nazarii Kovtun",
|
|
22
16
|
"type": "module",
|
|
23
17
|
"sideEffects": false,
|
package/dist/chunk-5BUIFXZY.cjs
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class; var _class2; var _class3; var _class4;"use client";
|
|
2
|
-
|
|
3
|
-
// src/core/errors/wizard.error.ts
|
|
4
|
-
var WizardError = (_class = class extends Error {
|
|
5
|
-
__init() {this.name = "WizardError"}
|
|
6
|
-
constructor(message) {
|
|
7
|
-
super(message);_class.prototype.__init.call(this);;
|
|
8
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
9
|
-
}
|
|
10
|
-
}, _class);
|
|
11
|
-
var WizardInitializationError = (_class2 = class extends WizardError {constructor(...args) { super(...args); _class2.prototype.__init2.call(this); }
|
|
12
|
-
__init2() {this.name = "WizardInitializationError"}
|
|
13
|
-
}, _class2);
|
|
14
|
-
var WizardNavigationError = (_class3 = class extends WizardError {constructor(...args2) { super(...args2); _class3.prototype.__init3.call(this); }
|
|
15
|
-
__init3() {this.name = "WizardNavigationError"}
|
|
16
|
-
}, _class3);
|
|
17
|
-
var WizardResolverError = (_class4 = class extends WizardError {constructor(...args3) { super(...args3); _class4.prototype.__init4.call(this); }
|
|
18
|
-
__init4() {this.name = "WizardResolverError"}
|
|
19
|
-
}, _class4);
|
|
20
|
-
|
|
21
|
-
// src/react/components-provider.tsx
|
|
22
|
-
var _react = require('react');
|
|
23
|
-
var _jsxruntime = require('react/jsx-runtime');
|
|
24
|
-
var FallbackButton = ({
|
|
25
|
-
children,
|
|
26
|
-
className,
|
|
27
|
-
disabled,
|
|
28
|
-
onClick,
|
|
29
|
-
type,
|
|
30
|
-
"aria-label": ariaLabel
|
|
31
|
-
}) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
32
|
-
"button",
|
|
33
|
-
{
|
|
34
|
-
"aria-label": ariaLabel,
|
|
35
|
-
className,
|
|
36
|
-
disabled,
|
|
37
|
-
onClick,
|
|
38
|
-
type: _nullishCoalesce(type, () => ( "button")),
|
|
39
|
-
children
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
var FallbackBackArrowIcon = ({ className }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className, width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M10 4 L6 8 L10 12", stroke: "currentColor", strokeWidth: "1.5", fill: "none" }) });
|
|
43
|
-
var defaults = { Button: FallbackButton, BackArrowIcon: FallbackBackArrowIcon };
|
|
44
|
-
var WizardComponentsContext = _react.createContext.call(void 0, defaults);
|
|
45
|
-
function WizardComponentsProvider(props) {
|
|
46
|
-
const { Button, BackArrowIcon, children } = props;
|
|
47
|
-
const value = {
|
|
48
|
-
Button: _nullishCoalesce(Button, () => ( defaults.Button)),
|
|
49
|
-
BackArrowIcon: _nullishCoalesce(BackArrowIcon, () => ( defaults.BackArrowIcon))
|
|
50
|
-
};
|
|
51
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WizardComponentsContext.Provider, { value, children });
|
|
52
|
-
}
|
|
53
|
-
function useWizardComponents() {
|
|
54
|
-
return _react.useContext.call(void 0, WizardComponentsContext);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// src/react/context.ts
|
|
58
|
-
|
|
59
|
-
var WizardEngineContext = _react.createContext.call(void 0, null);
|
|
60
|
-
|
|
61
|
-
// src/react/use-wizard.ts
|
|
62
|
-
|
|
63
|
-
function useWizard() {
|
|
64
|
-
const engine = _react.useContext.call(void 0, WizardEngineContext);
|
|
65
|
-
if (!engine) {
|
|
66
|
-
throw new WizardError("useWizard must be used inside <WizardProvider>");
|
|
67
|
-
}
|
|
68
|
-
_react.useSyncExternalStore.call(void 0, engine.subscribe, engine.getTreeSnapshot, engine.getTreeSnapshot);
|
|
69
|
-
return engine;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// src/utils/cn.ts
|
|
73
|
-
var _clsx = require('clsx');
|
|
74
|
-
var _tailwindmerge = require('tailwind-merge');
|
|
75
|
-
function cn(...inputs) {
|
|
76
|
-
return _tailwindmerge.twMerge.call(void 0, _clsx.clsx.call(void 0, ...inputs));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
exports.WizardError = WizardError; exports.WizardInitializationError = WizardInitializationError; exports.WizardNavigationError = WizardNavigationError; exports.WizardResolverError = WizardResolverError; exports.WizardComponentsProvider = WizardComponentsProvider; exports.useWizardComponents = useWizardComponents; exports.WizardEngineContext = WizardEngineContext; exports.useWizard = useWizard; exports.cn = cn;
|
|
90
|
-
//# sourceMappingURL=chunk-5BUIFXZY.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/knazark/work/extract-tmp/perks-extract/dist/chunk-5BUIFXZY.cjs","../src/core/errors/wizard.error.ts","../src/react/components-provider.tsx","../src/react/context.ts","../src/react/use-wizard.ts","../src/utils/cn.ts"],"names":["createContext","useContext"],"mappings":"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","file":"/Users/knazark/work/extract-tmp/perks-extract/dist/chunk-5BUIFXZY.cjs","sourcesContent":[null,"export class WizardError extends Error {\n\tpublic override readonly name: string = 'WizardError';\n\n\tconstructor(message?: string) {\n\t\tsuper(message);\n\t\tObject.setPrototypeOf(this, new.target.prototype);\n\t}\n}\n\nexport class WizardInitializationError extends WizardError {\n\tpublic override readonly name: string = 'WizardInitializationError';\n}\n\nexport class WizardNavigationError extends WizardError {\n\tpublic override readonly name: string = 'WizardNavigationError';\n}\n\nexport class WizardResolverError extends WizardError {\n\tpublic override readonly name: string = 'WizardResolverError';\n}\n","'use client';\n\nimport { type ComponentType, createContext, type ReactNode, useContext } from 'react';\n\nexport interface IWizardButtonProps {\n\tasChild?: boolean;\n\tchildren?: ReactNode;\n\tclassName?: string;\n\tdisabled?: boolean;\n\tonClick?: () => void;\n\ttype?: 'button' | 'submit';\n\tvariant?: 'default' | 'ghost' | 'outline';\n\tsize?: 'default' | 'icon-sm';\n\t'aria-label'?: string;\n}\n\nexport interface IWizardBackArrowIconProps {\n\tclassName?: string;\n}\n\nexport interface IWizardComponents {\n\tButton: ComponentType<IWizardButtonProps>;\n\tBackArrowIcon: ComponentType<IWizardBackArrowIconProps>;\n}\n\nconst FallbackButton: ComponentType<IWizardButtonProps> = ({\n\tchildren,\n\tclassName,\n\tdisabled,\n\tonClick,\n\ttype,\n\t'aria-label': ariaLabel,\n}) => (\n\t<button\n\t\taria-label={ariaLabel}\n\t\tclassName={className}\n\t\tdisabled={disabled}\n\t\tonClick={onClick}\n\t\ttype={type ?? 'button'}\n\t>\n\t\t{children}\n\t</button>\n);\n\nconst FallbackBackArrowIcon: ComponentType<IWizardBackArrowIconProps> = ({ className }) => (\n\t<svg className={className} width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"currentColor\" aria-hidden>\n\t\t<path d=\"M10 4 L6 8 L10 12\" stroke=\"currentColor\" strokeWidth=\"1.5\" fill=\"none\" />\n\t</svg>\n);\n\nconst defaults: IWizardComponents = { Button: FallbackButton, BackArrowIcon: FallbackBackArrowIcon };\n\nconst WizardComponentsContext = createContext<IWizardComponents>(defaults);\n\nexport function WizardComponentsProvider(props: {\n\tButton?: ComponentType<IWizardButtonProps>;\n\tBackArrowIcon?: ComponentType<IWizardBackArrowIconProps>;\n\tchildren: ReactNode;\n}) {\n\tconst { Button, BackArrowIcon, children } = props;\n\tconst value: IWizardComponents = {\n\t\tButton: Button ?? defaults.Button,\n\t\tBackArrowIcon: BackArrowIcon ?? defaults.BackArrowIcon,\n\t};\n\treturn <WizardComponentsContext.Provider value={value}>{children}</WizardComponentsContext.Provider>;\n}\n\nexport function useWizardComponents(): IWizardComponents {\n\treturn useContext(WizardComponentsContext);\n}\n","'use client';\n\nimport { createContext } from 'react';\n\nimport type { WizardEngine } from '../core/wizard-engine';\n\n/**\n * React context exposing the active `WizardEngine` instance to descendants.\n * `null` outside a `<WizardProvider>` — `useWizard()` throws a clear error.\n */\nexport const WizardEngineContext = createContext<null | WizardEngine<string, string, string>>(null);\n","'use client';\n\nimport { useContext, useSyncExternalStore } from 'react';\n\nimport type { WizardEngine } from '../core/wizard-engine';\n\nimport { WizardError } from '../core/errors';\nimport { WizardEngineContext } from './context';\n\n/**\n * Returns the active `WizardEngine` instance and re-renders the consumer on\n * every tree change. Throws if used outside a `<WizardProvider>`.\n *\n * Engine identity is stable across renders.\n */\nexport function useWizard<Step extends string, Category extends string, Branch extends string = string>(): WizardEngine<\n\tStep,\n\tCategory,\n\tBranch\n> {\n\tconst engine = useContext(WizardEngineContext) as null | WizardEngine<Step, Category, Branch>;\n\tif (!engine) {\n\t\tthrow new WizardError('useWizard must be used inside <WizardProvider>');\n\t}\n\tuseSyncExternalStore(engine.subscribe, engine.getTreeSnapshot, engine.getTreeSnapshot);\n\treturn engine;\n}\n","import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]): string {\n return twMerge(clsx(...inputs));\n}\n"]}
|