jcicl 3.0.1 → 4.0.2
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.
|
@@ -7,18 +7,22 @@ export type StepProps = {
|
|
|
7
7
|
export declare const Step: React.FC<PropsWithChildren<StepProps>>;
|
|
8
8
|
/** Imperative handle for driving the stepper from a parent (e.g. jumping to a step with errors). */
|
|
9
9
|
export type DesktopStepperHandle = {
|
|
10
|
-
/** Animate to the given step index (clamped to the valid range). */
|
|
10
|
+
/** Animate to the given step index unless validation errors are found during onNext (clamped to the valid range). */
|
|
11
11
|
goToStep: (index: number) => void;
|
|
12
12
|
};
|
|
13
13
|
export type DesktopStepperProps = {
|
|
14
14
|
onNext?: (step?: number) => boolean;
|
|
15
15
|
onFinish: () => Promise<void>;
|
|
16
16
|
onBack?: () => void;
|
|
17
|
+
/** Determines which step titles are clickable. 'next' allows clicking on the next and all previous steps, 'back' allows clicking on previous steps (default), 'all' allows clicking on all steps, and 'none' disables clicking. */
|
|
18
|
+
clickVariant?: 'next' | 'back' | 'all' | 'none';
|
|
19
|
+
submitButtonLabel?: string;
|
|
17
20
|
/** If true, the stepper will maintain the height of the tallest step. */
|
|
18
21
|
staticHeight?: boolean;
|
|
19
22
|
/** Optional imperative handle exposing `goToStep` for programmatic navigation. */
|
|
20
23
|
ref?: React.Ref<DesktopStepperHandle>;
|
|
21
24
|
children: React.ReactElement<StepProps>[];
|
|
25
|
+
className?: string;
|
|
22
26
|
};
|
|
23
|
-
declare const DesktopStepper: ({ onNext, onBack, onFinish, staticHeight, ref, children, }: PropsWithChildren<DesktopStepperProps>) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
declare const DesktopStepper: ({ onNext, onBack, onFinish, staticHeight, clickVariant, submitButtonLabel, ref, children, className, }: PropsWithChildren<DesktopStepperProps>) => import("react/jsx-runtime").JSX.Element;
|
|
24
28
|
export default DesktopStepper;
|
|
@@ -1,204 +1,245 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { flushSync as
|
|
4
|
-
import { cn as
|
|
5
|
-
import { Button as
|
|
6
|
-
import { Flex as
|
|
7
|
-
import { SlideOut as
|
|
8
|
-
import { useThemeColors as
|
|
9
|
-
import
|
|
10
|
-
import { useIsMobile as
|
|
11
|
-
import { C as
|
|
12
|
-
const
|
|
13
|
-
const
|
|
1
|
+
import { jsx as l, jsxs as h, Fragment as X } from "react/jsx-runtime";
|
|
2
|
+
import { useState as C, useRef as x, Children as ae, isValidElement as ue, useLayoutEffect as me, useEffect as de, useCallback as L, useImperativeHandle as fe } from "react";
|
|
3
|
+
import { flushSync as Y } from "react-dom";
|
|
4
|
+
import { cn as n } from "../cn.js";
|
|
5
|
+
import { Button as Z } from "../Button/Button.js";
|
|
6
|
+
import { Flex as _ } from "../Flex/Flex.js";
|
|
7
|
+
import { SlideOut as he, SlideIn as pe, SlideInReverse as V, SlideOutReverse as be } from "../animation/Slide/Slide.js";
|
|
8
|
+
import { useThemeColors as A } from "../ThemeContext.js";
|
|
9
|
+
import g from "../theme.js";
|
|
10
|
+
import { useIsMobile as ee } from "../utils.js";
|
|
11
|
+
import { C as ve } from "../.chunks/check.js";
|
|
12
|
+
const _e = ({ children: s, className: i }) => /* @__PURE__ */ l("div", { className: n("p-2.5 w-full", i), children: s }), Ce = ({ label: s, number: i, completed: u, active: c, onClick: m }) => {
|
|
13
|
+
const b = A(), j = ee(), N = {
|
|
14
14
|
"--item-circle-transition-delay": c ? "0.3s" : "0s",
|
|
15
|
-
"--item-circle-border":
|
|
16
|
-
"--item-circle-bg": c ||
|
|
17
|
-
"--item-circle-color": c ||
|
|
18
|
-
"--label-color":
|
|
19
|
-
"--label-opacity": c ? 1 : 0.
|
|
15
|
+
"--item-circle-border": b.themeColor,
|
|
16
|
+
"--item-circle-bg": c || u ? b.themeColor : "transparent",
|
|
17
|
+
"--item-circle-color": c || u ? g.colors.white : b.themeColor,
|
|
18
|
+
"--label-color": b.themeColor,
|
|
19
|
+
"--label-opacity": c ? 1 : 0.8,
|
|
20
|
+
"--label-weight": c ? "500" : "400"
|
|
20
21
|
};
|
|
21
|
-
return /* @__PURE__ */
|
|
22
|
-
/* @__PURE__ */
|
|
23
|
-
|
|
22
|
+
return /* @__PURE__ */ l("div", { style: N, className: n("stepperTitleItem font-medium justify-center items-center"), children: /* @__PURE__ */ h(_, { column: !0, alignItems: "center", gap: "4px", children: [
|
|
23
|
+
/* @__PURE__ */ l(
|
|
24
|
+
"button",
|
|
25
|
+
{
|
|
26
|
+
type: "button",
|
|
27
|
+
className: n("itemCircle", "font-[inherit] font-medium! justify-center flex box-border items-center select-none transition-all duration-300 delay-(--item-circle-transition-delay) ease-in-out w-[35px] h-[35px] mx-[8px] rounded-full border-[2px] border-(--item-circle-border) bg-(--item-circle-bg) text-(--item-circle-color)", m && "cursor-pointer"),
|
|
28
|
+
onClick: m,
|
|
29
|
+
disabled: !m,
|
|
30
|
+
children: u ? /* @__PURE__ */ l(ve, { size: 18, strokeWidth: 3 }) : i
|
|
31
|
+
}
|
|
32
|
+
),
|
|
33
|
+
/* @__PURE__ */ l(
|
|
34
|
+
"div",
|
|
35
|
+
{
|
|
36
|
+
className: n("label", "cursor-default text-sm mx-1 text-(--label-color) text-center opacity-(--label-opacity) font-(--label-weight) transition-[all_0.5s_ease]", j && "px-[5px]", m && "cursor-pointer"),
|
|
37
|
+
onClick: m,
|
|
38
|
+
children: s
|
|
39
|
+
}
|
|
40
|
+
)
|
|
24
41
|
] }) });
|
|
25
|
-
},
|
|
26
|
-
const
|
|
27
|
-
"--title-slider-active-color":
|
|
28
|
-
"--title-slider-active-percent":
|
|
29
|
-
"--title-slider-inactive-color":
|
|
30
|
-
"--title-slider-position":
|
|
42
|
+
}, ge = ({ activated: s }) => {
|
|
43
|
+
const i = A(), u = {
|
|
44
|
+
"--title-slider-active-color": i.themeColor,
|
|
45
|
+
"--title-slider-active-percent": s ? "50%" : "49%",
|
|
46
|
+
"--title-slider-inactive-color": i.themeLightA,
|
|
47
|
+
"--title-slider-position": s ? "left bottom" : "right bottom"
|
|
31
48
|
};
|
|
32
|
-
return /* @__PURE__ */
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
49
|
+
return /* @__PURE__ */ l(
|
|
50
|
+
"div",
|
|
51
|
+
{
|
|
52
|
+
className: n(
|
|
53
|
+
"absolute top-4 left-[calc(50%+25px)] h-0.75 w-[calc(100%-50px)] rounded-sm bg-size-[200%_100%] duration-500 ease-in-out",
|
|
54
|
+
"bg-[linear-gradient(to_right,var(--title-slider-active-color)_var(--title-slider-active-percent),var(--title-slider-inactive-color)_50%)] bg-position-(--title-slider-position)"
|
|
55
|
+
),
|
|
56
|
+
style: u
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
}, Se = "relative w-full h-full flex items-center justify-between flex-col gap-[15px] m-0 bg-transparent overflow-hidden", F = "absolute top-0 w-full h-full", ye = "relative w-full [&_.jcSlideContainer]:justify-items-center", we = "will-change-[height] transition-[height] duration-500 ease-[cubic-bezier(0.2,0,0,1)]", Ae = ({
|
|
60
|
+
onNext: s = () => !0,
|
|
61
|
+
onBack: i,
|
|
62
|
+
onFinish: u,
|
|
37
63
|
staticHeight: c = !1,
|
|
38
|
-
|
|
39
|
-
|
|
64
|
+
clickVariant: m = "back",
|
|
65
|
+
submitButtonLabel: b,
|
|
66
|
+
ref: j,
|
|
67
|
+
children: N,
|
|
68
|
+
className: D
|
|
40
69
|
}) => {
|
|
41
|
-
const [e,
|
|
42
|
-
(
|
|
43
|
-
), E = a.map((
|
|
70
|
+
const [e, te] = C(0), [S, H] = C("forward"), [W, k] = C(null), [T, R] = C(!1), [B, $] = C(!1), q = x(null), G = x([]), M = x(null), O = x(0), d = A(), J = ee(), a = ae.toArray(N).filter(
|
|
71
|
+
(t) => ue(t)
|
|
72
|
+
), E = a.map((t) => t.props.title || ""), re = E.some((t) => t !== ""), y = a.length, p = e === y - 1, le = {
|
|
44
73
|
"--progress-bar-bg": d.themeLightA,
|
|
45
74
|
"--progress-bar-border": d.themeColor,
|
|
46
75
|
"--progress-bar-color": d.themeColor
|
|
47
76
|
};
|
|
48
|
-
|
|
77
|
+
me(() => {
|
|
49
78
|
if (c) {
|
|
50
|
-
const
|
|
51
|
-
let
|
|
52
|
-
|
|
53
|
-
if (
|
|
54
|
-
const
|
|
55
|
-
|
|
79
|
+
const I = G.current, P = () => {
|
|
80
|
+
let f = 0;
|
|
81
|
+
I.forEach((v) => {
|
|
82
|
+
if (v) {
|
|
83
|
+
const U = v.getBoundingClientRect().height;
|
|
84
|
+
U > f && (f = U);
|
|
56
85
|
}
|
|
57
|
-
}),
|
|
86
|
+
}), k(f ? Math.ceil(f) : null);
|
|
58
87
|
};
|
|
59
|
-
if (
|
|
60
|
-
const
|
|
61
|
-
return
|
|
62
|
-
if (
|
|
63
|
-
const
|
|
64
|
-
|
|
88
|
+
if (P(), typeof ResizeObserver > "u") return;
|
|
89
|
+
const Q = [];
|
|
90
|
+
return I.forEach((f) => {
|
|
91
|
+
if (f) {
|
|
92
|
+
const v = new ResizeObserver(P);
|
|
93
|
+
v.observe(f), Q.push(v);
|
|
65
94
|
}
|
|
66
|
-
}), () =>
|
|
95
|
+
}), () => Q.forEach((f) => f.disconnect());
|
|
67
96
|
}
|
|
68
|
-
const
|
|
69
|
-
if (!
|
|
97
|
+
const t = q.current;
|
|
98
|
+
if (!t) return;
|
|
70
99
|
const r = () => {
|
|
71
|
-
|
|
100
|
+
k(Math.ceil(t.getBoundingClientRect().height));
|
|
72
101
|
};
|
|
73
102
|
if (r(), typeof ResizeObserver > "u") return;
|
|
74
|
-
const
|
|
75
|
-
return
|
|
76
|
-
}, [e,
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
103
|
+
const o = new ResizeObserver(r);
|
|
104
|
+
return o.observe(t), () => o.disconnect();
|
|
105
|
+
}, [e, y, c]), de(() => () => clearTimeout(M.current ?? void 0), []);
|
|
106
|
+
const K = L(() => {
|
|
107
|
+
$(!0), clearTimeout(M.current ?? void 0), M.current = setTimeout(() => {
|
|
108
|
+
$(!1);
|
|
80
109
|
}, 550);
|
|
81
|
-
}, []),
|
|
82
|
-
|
|
83
|
-
|
|
110
|
+
}, []), w = L(
|
|
111
|
+
(t, r) => {
|
|
112
|
+
K(), O.current = e, Y(() => H("none")), Y(() => H(t)), te(r);
|
|
113
|
+
},
|
|
114
|
+
[K, e]
|
|
115
|
+
), se = async () => {
|
|
116
|
+
if (p) {
|
|
117
|
+
R(!0);
|
|
84
118
|
try {
|
|
85
|
-
await (
|
|
119
|
+
await (u == null ? void 0 : u());
|
|
86
120
|
} finally {
|
|
87
|
-
|
|
121
|
+
R(!1);
|
|
88
122
|
}
|
|
89
123
|
} else {
|
|
90
|
-
if (!(
|
|
91
|
-
|
|
124
|
+
if (!(s == null ? void 0 : s(e))) {
|
|
125
|
+
R(!1);
|
|
92
126
|
return;
|
|
93
127
|
}
|
|
94
|
-
|
|
128
|
+
w("forward", e + 1);
|
|
95
129
|
}
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
},
|
|
99
|
-
(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
130
|
+
}, ie = () => {
|
|
131
|
+
w("reverse", e - 1), i == null || i();
|
|
132
|
+
}, z = L(
|
|
133
|
+
(t) => {
|
|
134
|
+
let r = Math.max(0, Math.min(t, y - 1));
|
|
135
|
+
for (let o = e; o > r; o--)
|
|
136
|
+
i == null || i();
|
|
137
|
+
for (let o = e; o < r; o++)
|
|
138
|
+
if (!(s == null ? void 0 : s(o))) {
|
|
139
|
+
r = o;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
r !== e && w(r > e ? "forward" : "reverse", r);
|
|
105
143
|
},
|
|
106
|
-
[e,
|
|
144
|
+
[e, y, w, s, i]
|
|
107
145
|
);
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
146
|
+
fe(j, () => ({ goToStep: z }), [z]);
|
|
147
|
+
const oe = () => /* @__PURE__ */ l(
|
|
148
|
+
Z,
|
|
111
149
|
{
|
|
112
150
|
variant: "custom",
|
|
113
|
-
onClick:
|
|
114
|
-
backgroundColor:
|
|
115
|
-
hoverColor:
|
|
116
|
-
textColor:
|
|
117
|
-
disabled:
|
|
118
|
-
children:
|
|
151
|
+
onClick: se,
|
|
152
|
+
backgroundColor: p ? g.colors.gold : d.themeColor,
|
|
153
|
+
hoverColor: p ? g.colors.goldHover : d.themeDark,
|
|
154
|
+
textColor: p ? g.colors.black : g.colors.white,
|
|
155
|
+
disabled: T,
|
|
156
|
+
children: p ? T ? "Submitting..." : b || "Submit" : "Next"
|
|
119
157
|
}
|
|
120
|
-
),
|
|
121
|
-
|
|
158
|
+
), ne = () => /* @__PURE__ */ l(
|
|
159
|
+
Z,
|
|
122
160
|
{
|
|
123
161
|
variant: "custom",
|
|
124
|
-
onClick:
|
|
162
|
+
onClick: ie,
|
|
125
163
|
backgroundColor: d.themeLight,
|
|
126
164
|
borderColor: d.themeColor,
|
|
127
165
|
hoverColor: d.themeMediumB,
|
|
128
166
|
textColor: d.themeColor,
|
|
129
167
|
children: "Back"
|
|
130
168
|
}
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
169
|
+
), ce = (t) => {
|
|
170
|
+
if (!T && !(m === "none" || t === e) && !(m === "back" && t > e) && !(m === "next" && t > e + 1))
|
|
171
|
+
return () => z(t);
|
|
172
|
+
};
|
|
173
|
+
return /* @__PURE__ */ h(_, { column: !0, justifyContent: "center", gap: "10px", className: n("jcStep", D), children: [
|
|
174
|
+
/* @__PURE__ */ l("ol", { className: "m-0 mb-1 flex w-full list-none items-start p-0", children: E.map((t, r) => /* @__PURE__ */ h("li", { className: "relative flex min-w-0 flex-1 flex-col items-center", children: [
|
|
175
|
+
/* @__PURE__ */ l(
|
|
176
|
+
Ce,
|
|
136
177
|
{
|
|
137
|
-
label:
|
|
178
|
+
label: t,
|
|
138
179
|
number: r + 1,
|
|
139
180
|
completed: r < e,
|
|
140
|
-
active: r === e
|
|
141
|
-
|
|
142
|
-
|
|
181
|
+
active: r === e,
|
|
182
|
+
onClick: ce(r)
|
|
183
|
+
}
|
|
143
184
|
),
|
|
144
|
-
r < E.length - 1 && (
|
|
185
|
+
r < E.length - 1 && (J !== re || !J) && /* @__PURE__ */ l(ge, { activated: r < e })
|
|
145
186
|
] }, r)) }),
|
|
146
|
-
/* @__PURE__ */
|
|
147
|
-
/* @__PURE__ */
|
|
187
|
+
/* @__PURE__ */ h("div", { className: n("jcStep", Se), style: le, children: [
|
|
188
|
+
/* @__PURE__ */ h(
|
|
148
189
|
"div",
|
|
149
190
|
{
|
|
150
|
-
className:
|
|
191
|
+
className: n(ye, B && we),
|
|
151
192
|
style: {
|
|
152
|
-
height: c ||
|
|
193
|
+
height: c || W != null && B ? `${W}px` : "auto"
|
|
153
194
|
},
|
|
154
195
|
children: [
|
|
155
|
-
c ? /* @__PURE__ */
|
|
196
|
+
c ? /* @__PURE__ */ l(
|
|
156
197
|
"div",
|
|
157
198
|
{
|
|
158
199
|
"aria-hidden": "true",
|
|
159
200
|
className: "jcStepperMeasure pointer-events-none absolute left-0 top-0 invisible w-full",
|
|
160
|
-
children: a.map((
|
|
201
|
+
children: a.map((t, r) => /* @__PURE__ */ l(
|
|
161
202
|
"div",
|
|
162
203
|
{
|
|
163
|
-
ref: (
|
|
164
|
-
|
|
204
|
+
ref: (o) => {
|
|
205
|
+
G.current[r] = o;
|
|
165
206
|
},
|
|
166
207
|
className: "w-full",
|
|
167
|
-
children:
|
|
208
|
+
children: t
|
|
168
209
|
},
|
|
169
210
|
r
|
|
170
211
|
))
|
|
171
212
|
}
|
|
172
|
-
) : /* @__PURE__ */
|
|
213
|
+
) : /* @__PURE__ */ l(
|
|
173
214
|
"div",
|
|
174
215
|
{
|
|
175
|
-
ref:
|
|
216
|
+
ref: q,
|
|
176
217
|
"aria-hidden": "true",
|
|
177
218
|
className: "jcStepperMeasure pointer-events-none absolute left-0 top-0 invisible w-full",
|
|
178
219
|
children: a[e] ?? null
|
|
179
220
|
}
|
|
180
221
|
),
|
|
181
|
-
e === 0 &&
|
|
182
|
-
e !== 0 &&
|
|
183
|
-
/* @__PURE__ */
|
|
184
|
-
/* @__PURE__ */
|
|
222
|
+
e === 0 && S === "forward" && /* @__PURE__ */ l("div", { className: n("jcSlideContainer"), children: a[e] ?? null }),
|
|
223
|
+
e !== 0 && S === "forward" && /* @__PURE__ */ h(X, { children: [
|
|
224
|
+
/* @__PURE__ */ l("div", { className: n("jcSlideOutContainer", F), children: /* @__PURE__ */ l(he, { className: "jcSlideContainer", children: a[O.current] ?? null }) }),
|
|
225
|
+
/* @__PURE__ */ l(pe, { className: "jcSlideContainer", children: a[e] ?? null })
|
|
185
226
|
] }),
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
/* @__PURE__ */
|
|
189
|
-
/* @__PURE__ */
|
|
227
|
+
p && S === "reverse" && /* @__PURE__ */ l(V, { className: "jcSlideContainer", children: a[e] ?? null }),
|
|
228
|
+
!p && S === "reverse" && /* @__PURE__ */ h(X, { children: [
|
|
229
|
+
/* @__PURE__ */ l("div", { className: n("jcSlideOutContainer", F), children: /* @__PURE__ */ l(be, { className: "jcSlideContainer", children: a[O.current] ?? null }) }),
|
|
230
|
+
/* @__PURE__ */ l(V, { className: "jcSlideContainer", children: a[e] ?? null })
|
|
190
231
|
] })
|
|
191
232
|
]
|
|
192
233
|
}
|
|
193
234
|
),
|
|
194
|
-
/* @__PURE__ */
|
|
195
|
-
e !== 0 &&
|
|
196
|
-
|
|
235
|
+
/* @__PURE__ */ h(_, { gap: "10px", className: "self-end mb-[5px] mr-[5px]", children: [
|
|
236
|
+
e !== 0 && ne(),
|
|
237
|
+
oe()
|
|
197
238
|
] })
|
|
198
239
|
] })
|
|
199
240
|
] });
|
|
200
241
|
};
|
|
201
242
|
export {
|
|
202
|
-
|
|
203
|
-
|
|
243
|
+
_e as Step,
|
|
244
|
+
Ae as default
|
|
204
245
|
};
|