jcicl 2.0.2 → 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.
- package/DesktopStepper/DesktopStepper.d.ts +6 -2
- package/DesktopStepper/DesktopStepper.js +166 -125
- package/FormFields/FormFields.js +4 -3
- package/FormInput/FormInput.d.ts +21 -0
- package/FormInput/FormInput.js +44 -33
- package/FormInput/index.d.ts +1 -1
- package/FormInput/index.js +3 -2
- package/LabeledCurrencyInput/LabeledCurrencyInput.d.ts +2 -4
- package/LabeledDateInput/LabeledDateInput.d.ts +13 -0
- package/LabeledDateInput/LabeledDateInput.js +75 -0
- package/LabeledDateInput/index.d.ts +1 -0
- package/LabeledDateInput/index.js +4 -0
- package/LabeledFormattedInput/LabeledFormattedInput.d.ts +2 -4
- package/LabeledFormattedInput/LabeledFormattedInput.js +52 -57
- package/LabeledInput/LabeledInput.d.ts +8 -4
- package/LabeledInput/LabeledInput.js +40 -26
- package/README.md +20 -0
- package/assets/style.css +1 -1
- package/assets/tailwind.css +1 -1
- package/index.d.ts +1 -0
- package/index.js +73 -71
- package/labeledFieldStyles.d.ts +18 -0
- package/labeledFieldStyles.js +12 -0
- package/package.json +1 -1
- package/utils.d.ts +1 -1
- package/utils.js +16 -14
- package/validators.d.ts +2 -0
- package/validators.js +24 -16
|
@@ -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
|
};
|
package/FormFields/FormFields.js
CHANGED
|
@@ -20,7 +20,8 @@ import "react-dom";
|
|
|
20
20
|
import "../Accordion/Accordion.js";
|
|
21
21
|
import "../ErrorBoundary/ErrorBoundary.js";
|
|
22
22
|
import "../InfoCard/InfoCard.js";
|
|
23
|
-
import "../
|
|
23
|
+
import "../theme.js";
|
|
24
|
+
import "../labeledFieldStyles.js";
|
|
24
25
|
import "../List/List.js";
|
|
25
26
|
import "../LogoLoop/LogoLoop.js";
|
|
26
27
|
import "../Pagination/Pagination.js";
|
|
@@ -35,7 +36,7 @@ import "../Nav/Nav.js";
|
|
|
35
36
|
import "../AuthContext/AuthProvider.js";
|
|
36
37
|
import "../AppContainer/AppContainer.js";
|
|
37
38
|
import "../DefaultTemplate/DefaultTemplate.js";
|
|
38
|
-
const
|
|
39
|
+
const Fo = ({
|
|
39
40
|
title: h,
|
|
40
41
|
fields: a,
|
|
41
42
|
columns: w,
|
|
@@ -104,5 +105,5 @@ const xo = ({
|
|
|
104
105
|
] });
|
|
105
106
|
};
|
|
106
107
|
export {
|
|
107
|
-
|
|
108
|
+
Fo as default
|
|
108
109
|
};
|
package/FormInput/FormInput.d.ts
CHANGED
|
@@ -22,5 +22,26 @@ export type FormInputProps = Partial<Omit<AllInputProps, ConflictingKeys | 'type
|
|
|
22
22
|
overrideValidation?: boolean;
|
|
23
23
|
customValidation?: InputValidationFunction;
|
|
24
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* The field's validation message, or undefined when it passes. Pure and module-level so it can be
|
|
27
|
+
* exercised directly, and so the component doesn't have to hold it in state: validation is a
|
|
28
|
+
* function of the props, and the useEffect form it replaced cost a second render on every
|
|
29
|
+
* keystroke — callers routinely pass a fresh `customValidation` closure each render, which no
|
|
30
|
+
* dependency array can compare usefully. Computing it inline also lands the error on the same
|
|
31
|
+
* commit as the value rather than one render later.
|
|
32
|
+
*
|
|
33
|
+
* checkbox/radio wrap MUI Checkbox/Radio, which have no helper-text slot, so there's nowhere to
|
|
34
|
+
* surface a message — they're skipped entirely.
|
|
35
|
+
*/
|
|
36
|
+
export declare const resolveValidationError: ({ type, value, required, label, showError, overrideValidation, customValidation, }: {
|
|
37
|
+
type: FormInputType;
|
|
38
|
+
value: unknown;
|
|
39
|
+
required?: boolean;
|
|
40
|
+
label?: string;
|
|
41
|
+
showError?: boolean;
|
|
42
|
+
/** Skip the required and type-based rules, applying only `customValidation`. */
|
|
43
|
+
overrideValidation?: boolean;
|
|
44
|
+
customValidation?: InputValidationFunction;
|
|
45
|
+
}) => string | undefined;
|
|
25
46
|
export declare const FormInput: React.FC<FormInputProps>;
|
|
26
47
|
export default FormInput;
|
package/FormInput/FormInput.js
CHANGED
|
@@ -1,42 +1,53 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { LabeledCurrencyInput as
|
|
5
|
-
import { LabeledCheckbox as
|
|
6
|
-
import { LabeledRadio as
|
|
7
|
-
import { LabeledDropdown as
|
|
8
|
-
import { LabeledTextArea as
|
|
9
|
-
import { LabeledFormattedInput as
|
|
10
|
-
import { formattedOrMaskedTypes as
|
|
11
|
-
import { inputValidatorsByType as
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { LabeledInput as s } from "../LabeledInput/LabeledInput.js";
|
|
3
|
+
import { LabeledDateInput as u } from "../LabeledDateInput/LabeledDateInput.js";
|
|
4
|
+
import { LabeledCurrencyInput as c } from "../LabeledCurrencyInput/LabeledCurrencyInput.js";
|
|
5
|
+
import { LabeledCheckbox as b } from "../LabeledCheckbox/LabeledCheckbox.js";
|
|
6
|
+
import { LabeledRadio as x } from "../LabeledRadio/LabeledRadio.js";
|
|
7
|
+
import { LabeledDropdown as h } from "../LabeledDropdown/LabeledDropdown.js";
|
|
8
|
+
import { LabeledTextArea as L } from "../LabeledTextArea/LabeledTextArea.js";
|
|
9
|
+
import { LabeledFormattedInput as T } from "../LabeledFormattedInput/LabeledFormattedInput.js";
|
|
10
|
+
import { formattedOrMaskedTypes as v } from "../utils.js";
|
|
11
|
+
import { inputValidatorsByType as E } from "../validators.js";
|
|
12
|
+
const I = ({
|
|
13
|
+
type: o,
|
|
14
|
+
value: r,
|
|
15
|
+
required: m,
|
|
16
|
+
label: a,
|
|
17
|
+
showError: p,
|
|
18
|
+
overrideValidation: f = !1,
|
|
19
|
+
customValidation: d
|
|
20
|
+
}) => {
|
|
21
|
+
if (!p || o === "checkbox" || o === "radio") return;
|
|
22
|
+
const n = r === void 0 || r === "";
|
|
23
|
+
if (m && !f && n) return `${a ?? "This field"} is required.`;
|
|
24
|
+
if (n) return;
|
|
25
|
+
const e = f ? void 0 : E[o];
|
|
26
|
+
return (e == null ? void 0 : e(r)) ?? (d == null ? void 0 : d(r));
|
|
27
|
+
}, H = (o) => {
|
|
28
|
+
const { type: r = "text", required: m, label: a, value: p } = o, { customValidation: f, showError: d, overrideValidation: n = !1, ...e } = o, l = I({
|
|
29
|
+
type: r,
|
|
30
|
+
value: p,
|
|
31
|
+
required: m,
|
|
32
|
+
label: a,
|
|
33
|
+
showError: d,
|
|
34
|
+
overrideValidation: n,
|
|
35
|
+
customValidation: f
|
|
36
|
+
}), i = {
|
|
37
|
+
error: !!l || o.error,
|
|
38
|
+
helperText: l ?? o.helperText
|
|
29
39
|
};
|
|
30
|
-
return r === "dropdown" || r === "multiDropdown" ? /* @__PURE__ */
|
|
31
|
-
|
|
40
|
+
return r === "dropdown" || r === "multiDropdown" ? /* @__PURE__ */ t(h, { ...e, ...i }) : r === "checkbox" ? /* @__PURE__ */ t(b, { ...e }) : r === "radio" ? /* @__PURE__ */ t(x, { ...e }) : r === "currency" ? /* @__PURE__ */ t(c, { ...e, ...i }) : r === "textarea" ? /* @__PURE__ */ t(L, { ...e, ...i }) : r === "date" ? /* @__PURE__ */ t(u, { ...e, ...i }) : v.has(r) ? /* @__PURE__ */ t(
|
|
41
|
+
T,
|
|
32
42
|
{
|
|
33
43
|
...e,
|
|
34
44
|
type: r,
|
|
35
45
|
...i
|
|
36
46
|
}
|
|
37
|
-
) : /* @__PURE__ */
|
|
47
|
+
) : /* @__PURE__ */ t(s, { ...e, type: r, ...i });
|
|
38
48
|
};
|
|
39
49
|
export {
|
|
40
|
-
|
|
41
|
-
|
|
50
|
+
H as FormInput,
|
|
51
|
+
H as default,
|
|
52
|
+
I as resolveValidationError
|
|
42
53
|
};
|
package/FormInput/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default, type FormInputProps, type FormInputType } from './FormInput.tsx';
|
|
1
|
+
export { default, resolveValidationError, type FormInputProps, type FormInputType } from './FormInput.tsx';
|
package/FormInput/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { InputProps } from '../Input';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
displayMode?: boolean;
|
|
5
|
-
}
|
|
2
|
+
import { StyleProps } from '../labeledFieldStyles';
|
|
3
|
+
export type { StyleProps };
|
|
6
4
|
export type LabeledCurrencyInputProps = InputProps & StyleProps & {
|
|
7
5
|
label: string;
|
|
8
6
|
noLabel?: boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { InputProps } from '../Input';
|
|
2
|
+
import { StyleProps } from '../labeledFieldStyles';
|
|
3
|
+
export type { StyleProps };
|
|
4
|
+
export type LabeledDateInputProps = InputProps & StyleProps & {
|
|
5
|
+
label?: string;
|
|
6
|
+
noLabel?: boolean;
|
|
7
|
+
/** Earliest selectable date. Takes the `YYYY-MM-DD` a date input expects; widened to match LabeledInput. */
|
|
8
|
+
min?: string | number;
|
|
9
|
+
/** Latest selectable date. Takes the `YYYY-MM-DD` a date input expects; widened to match LabeledInput. */
|
|
10
|
+
max?: string | number;
|
|
11
|
+
};
|
|
12
|
+
export declare const LabeledDateInput: React.FC<LabeledDateInputProps>;
|
|
13
|
+
export default LabeledDateInput;
|