@loopr-ai/craft 0.9.0 → 0.10.0
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/dist/components/organ/Form/FormInput.d.ts +1 -0
- package/dist/components/organ/Form/FormInput.js +12 -10
- package/dist/components/organ/Form/TextfieldInput/index.d.ts +1 -0
- package/dist/components/organ/Form/TextfieldInput/index.js +151 -140
- package/dist/components/organ/Form/index.d.ts +3 -1
- package/dist/components/organ/Form/index.js +105 -103
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as c } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
const
|
|
2
|
+
import C from "./RadioInput/index.js";
|
|
3
|
+
import F from "./TextfieldInput/index.js";
|
|
4
|
+
const w = ({
|
|
5
5
|
name: t,
|
|
6
6
|
label: u,
|
|
7
7
|
type: o,
|
|
@@ -16,13 +16,14 @@ const v = ({
|
|
|
16
16
|
error: i,
|
|
17
17
|
helperText: m,
|
|
18
18
|
autofocus: x,
|
|
19
|
-
inputAdornments: a
|
|
19
|
+
inputAdornments: a,
|
|
20
|
+
authHeader: h
|
|
20
21
|
}) => {
|
|
21
|
-
function I(
|
|
22
|
-
d(t,
|
|
22
|
+
function I(j) {
|
|
23
|
+
d(t, j.target.value);
|
|
23
24
|
}
|
|
24
25
|
return o === "custom" ? null : o === "radio" ? /* @__PURE__ */ c(
|
|
25
|
-
|
|
26
|
+
C,
|
|
26
27
|
{
|
|
27
28
|
name: t,
|
|
28
29
|
label: u,
|
|
@@ -35,7 +36,7 @@ const v = ({
|
|
|
35
36
|
inputAdornments: a
|
|
36
37
|
}
|
|
37
38
|
) : /* @__PURE__ */ c(
|
|
38
|
-
|
|
39
|
+
F,
|
|
39
40
|
{
|
|
40
41
|
name: t,
|
|
41
42
|
label: u,
|
|
@@ -51,10 +52,11 @@ const v = ({
|
|
|
51
52
|
error: i,
|
|
52
53
|
helperText: m,
|
|
53
54
|
inputAdornments: a,
|
|
54
|
-
autofocus: x
|
|
55
|
+
autofocus: x,
|
|
56
|
+
authHeader: h
|
|
55
57
|
}
|
|
56
58
|
);
|
|
57
59
|
};
|
|
58
60
|
export {
|
|
59
|
-
|
|
61
|
+
w as default
|
|
60
62
|
};
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { r as
|
|
3
|
-
import * as
|
|
4
|
-
import { useState as
|
|
1
|
+
import te, { jsx as d, jsxs as q } from "react/jsx-runtime";
|
|
2
|
+
import { r as oe, i as se } from "../../../../createSvgIcon-59e7bc15.js";
|
|
3
|
+
import * as M from "react";
|
|
4
|
+
import { useState as ne, useMemo as V, useCallback as ae, useEffect as re } from "react";
|
|
5
5
|
import { customColors as O } from "../../../../global/colors.js";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { B as
|
|
11
|
-
import { L as B, T as
|
|
12
|
-
import { g as W, a as
|
|
13
|
-
import { g as j, s as
|
|
14
|
-
import { u as
|
|
15
|
-
import { M as
|
|
16
|
-
import { B as
|
|
6
|
+
import ie from "../ErrorMessage/index.js";
|
|
7
|
+
import le from "../Form.styles.js";
|
|
8
|
+
import ce from "../Label/index.js";
|
|
9
|
+
import P from "./TextfieldInput.styles.js";
|
|
10
|
+
import { B as de } from "../../../../Box-96e795c4.js";
|
|
11
|
+
import { L as B, T as pe } from "../../../../TextField-df89b641.js";
|
|
12
|
+
import { g as W, a as x, _ as K, P as t, b as R, f as N } from "../../../../createTheme-d2329909.js";
|
|
13
|
+
import { g as j, s as J, b as Q, c as w, e as X, r as ue } from "../../../../styled-8f7db30d.js";
|
|
14
|
+
import { u as me, F as fe } from "../../../../useFormControl-b25c5813.js";
|
|
15
|
+
import { M as be } from "../../../../index-ae3eb123.js";
|
|
16
|
+
import { B as ve } from "../../../../ButtonBase-46c20f20.js";
|
|
17
17
|
import { d as k } from "../../../../dividerClasses-9354a5c9.js";
|
|
18
|
-
import { c as
|
|
19
|
-
function
|
|
18
|
+
import { c as ge, u as ye } from "../../../../TransitionGroupContext-21923db7.js";
|
|
19
|
+
function Ie(e) {
|
|
20
20
|
return W("MuiInputAdornment", e);
|
|
21
21
|
}
|
|
22
|
-
const
|
|
22
|
+
const xe = j("MuiInputAdornment", ["root", "filled", "standard", "outlined", "positionStart", "positionEnd", "disablePointerEvents", "hiddenLabel", "sizeSmall"]), D = xe;
|
|
23
23
|
var z;
|
|
24
|
-
const
|
|
24
|
+
const Ce = ["children", "className", "component", "disablePointerEvents", "disableTypography", "position", "variant"], $e = (e, o) => {
|
|
25
25
|
const {
|
|
26
26
|
ownerState: s
|
|
27
27
|
} = e;
|
|
28
28
|
return [o.root, o[`position${R(s.position)}`], s.disablePointerEvents === !0 && o.disablePointerEvents, o[s.variant]];
|
|
29
|
-
},
|
|
29
|
+
}, he = (e) => {
|
|
30
30
|
const {
|
|
31
31
|
classes: o,
|
|
32
32
|
disablePointerEvents: s,
|
|
@@ -34,18 +34,18 @@ const xe = ["children", "className", "component", "disablePointerEvents", "disab
|
|
|
34
34
|
position: r,
|
|
35
35
|
size: l,
|
|
36
36
|
variant: c
|
|
37
|
-
} = e,
|
|
37
|
+
} = e, y = {
|
|
38
38
|
root: ["root", s && "disablePointerEvents", r && `position${R(r)}`, c, n && "hiddenLabel", l && `size${R(l)}`]
|
|
39
39
|
};
|
|
40
|
-
return
|
|
41
|
-
},
|
|
40
|
+
return X(y, Ie, o);
|
|
41
|
+
}, Me = J("div", {
|
|
42
42
|
name: "MuiInputAdornment",
|
|
43
43
|
slot: "Root",
|
|
44
|
-
overridesResolver:
|
|
44
|
+
overridesResolver: $e
|
|
45
45
|
})(({
|
|
46
46
|
theme: e,
|
|
47
47
|
ownerState: o
|
|
48
|
-
}) =>
|
|
48
|
+
}) => x({
|
|
49
49
|
display: "flex",
|
|
50
50
|
height: "0.01em",
|
|
51
51
|
// Fix IE11 flexbox alignment. To remove at some point.
|
|
@@ -67,41 +67,41 @@ const xe = ["children", "className", "component", "disablePointerEvents", "disab
|
|
|
67
67
|
}, o.disablePointerEvents === !0 && {
|
|
68
68
|
// Styles applied to the root element if `disablePointerEvents={true}`.
|
|
69
69
|
pointerEvents: "none"
|
|
70
|
-
})),
|
|
71
|
-
const n =
|
|
70
|
+
})), Y = /* @__PURE__ */ M.forwardRef(function(o, s) {
|
|
71
|
+
const n = Q({
|
|
72
72
|
props: o,
|
|
73
73
|
name: "MuiInputAdornment"
|
|
74
74
|
}), {
|
|
75
75
|
children: r,
|
|
76
76
|
className: l,
|
|
77
77
|
component: c = "div",
|
|
78
|
-
disablePointerEvents:
|
|
79
|
-
disableTypography:
|
|
80
|
-
position:
|
|
81
|
-
variant:
|
|
82
|
-
} = n, p = K(n,
|
|
83
|
-
let i =
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
hiddenLabel:
|
|
87
|
-
size:
|
|
88
|
-
disablePointerEvents:
|
|
89
|
-
position:
|
|
78
|
+
disablePointerEvents: y = !1,
|
|
79
|
+
disableTypography: u = !1,
|
|
80
|
+
position: m,
|
|
81
|
+
variant: g
|
|
82
|
+
} = n, p = K(n, Ce), f = me() || {};
|
|
83
|
+
let i = g;
|
|
84
|
+
g && f.variant && process.env.NODE_ENV !== "production" && g === f.variant && console.error("MUI: The `InputAdornment` variant infers the variant prop you do not have to provide one."), f && !i && (i = f.variant);
|
|
85
|
+
const C = x({}, n, {
|
|
86
|
+
hiddenLabel: f.hiddenLabel,
|
|
87
|
+
size: f.size,
|
|
88
|
+
disablePointerEvents: y,
|
|
89
|
+
position: m,
|
|
90
90
|
variant: i
|
|
91
|
-
}),
|
|
92
|
-
return /* @__PURE__ */ d(
|
|
91
|
+
}), I = he(C);
|
|
92
|
+
return /* @__PURE__ */ d(fe.Provider, {
|
|
93
93
|
value: null,
|
|
94
|
-
children: /* @__PURE__ */ d(
|
|
94
|
+
children: /* @__PURE__ */ d(Me, x({
|
|
95
95
|
as: c,
|
|
96
|
-
ownerState:
|
|
97
|
-
className: w(
|
|
96
|
+
ownerState: C,
|
|
97
|
+
className: w(I.root, l),
|
|
98
98
|
ref: s
|
|
99
99
|
}, p, {
|
|
100
|
-
children: typeof r == "string" && !
|
|
100
|
+
children: typeof r == "string" && !u ? /* @__PURE__ */ d(be, {
|
|
101
101
|
color: "text.secondary",
|
|
102
102
|
children: r
|
|
103
|
-
}) : /* @__PURE__ */ q(
|
|
104
|
-
children: [
|
|
103
|
+
}) : /* @__PURE__ */ q(M.Fragment, {
|
|
104
|
+
children: [m === "start" ? (
|
|
105
105
|
/* notranslate needed while Google Translate will not fix zero-width space issue */
|
|
106
106
|
z || (z = /* @__PURE__ */ d("span", {
|
|
107
107
|
className: "notranslate",
|
|
@@ -112,7 +112,7 @@ const xe = ["children", "className", "component", "disablePointerEvents", "disab
|
|
|
112
112
|
}))
|
|
113
113
|
});
|
|
114
114
|
});
|
|
115
|
-
process.env.NODE_ENV !== "production" && (
|
|
115
|
+
process.env.NODE_ENV !== "production" && (Y.propTypes = {
|
|
116
116
|
// ----------------------------- Warning --------------------------------
|
|
117
117
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
118
118
|
// | To update them edit the d.ts file and run "yarn proptypes" |
|
|
@@ -160,11 +160,11 @@ process.env.NODE_ENV !== "production" && (X.propTypes = {
|
|
|
160
160
|
*/
|
|
161
161
|
variant: t.oneOf(["filled", "outlined", "standard"])
|
|
162
162
|
});
|
|
163
|
-
const A =
|
|
164
|
-
function
|
|
163
|
+
const A = Y, Oe = j("MuiListItemIcon", ["root", "alignItemsFlexStart"]), U = Oe, Te = j("MuiListItemText", ["root", "multiline", "dense", "inset", "primary", "secondary"]), G = Te;
|
|
164
|
+
function Ee(e) {
|
|
165
165
|
return W("MuiMenuItem", e);
|
|
166
166
|
}
|
|
167
|
-
const
|
|
167
|
+
const Pe = j("MuiMenuItem", ["root", "focusVisible", "dense", "disabled", "divider", "gutters", "selected"]), T = Pe, Ne = ["autoFocus", "component", "dense", "divider", "disableGutters", "focusVisibleClassName", "role", "tabIndex", "className"], je = (e, o) => {
|
|
168
168
|
const {
|
|
169
169
|
ownerState: s
|
|
170
170
|
} = e;
|
|
@@ -177,19 +177,19 @@ const Ee = j("MuiMenuItem", ["root", "focusVisible", "dense", "disabled", "divid
|
|
|
177
177
|
disableGutters: r,
|
|
178
178
|
selected: l,
|
|
179
179
|
classes: c
|
|
180
|
-
} = e,
|
|
180
|
+
} = e, u = X({
|
|
181
181
|
root: ["root", s && "dense", o && "disabled", !r && "gutters", n && "divider", l && "selected"]
|
|
182
|
-
},
|
|
183
|
-
return
|
|
184
|
-
},
|
|
185
|
-
shouldForwardProp: (e) =>
|
|
182
|
+
}, Ee, c);
|
|
183
|
+
return x({}, c, u);
|
|
184
|
+
}, Le = J(ve, {
|
|
185
|
+
shouldForwardProp: (e) => ue(e) || e === "classes",
|
|
186
186
|
name: "MuiMenuItem",
|
|
187
187
|
slot: "Root",
|
|
188
|
-
overridesResolver:
|
|
188
|
+
overridesResolver: je
|
|
189
189
|
})(({
|
|
190
190
|
theme: e,
|
|
191
191
|
ownerState: o
|
|
192
|
-
}) =>
|
|
192
|
+
}) => x({}, e.typography.body1, {
|
|
193
193
|
display: "flex",
|
|
194
194
|
justifyContent: "flex-start",
|
|
195
195
|
alignItems: "center",
|
|
@@ -216,16 +216,16 @@ const Ee = j("MuiMenuItem", ["root", "focusVisible", "dense", "disabled", "divid
|
|
|
216
216
|
}
|
|
217
217
|
},
|
|
218
218
|
[`&.${T.selected}`]: {
|
|
219
|
-
backgroundColor: e.vars ? `rgba(${e.vars.palette.primary.mainChannel} / ${e.vars.palette.action.selectedOpacity})` :
|
|
219
|
+
backgroundColor: e.vars ? `rgba(${e.vars.palette.primary.mainChannel} / ${e.vars.palette.action.selectedOpacity})` : N(e.palette.primary.main, e.palette.action.selectedOpacity),
|
|
220
220
|
[`&.${T.focusVisible}`]: {
|
|
221
|
-
backgroundColor: e.vars ? `rgba(${e.vars.palette.primary.mainChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.focusOpacity}))` :
|
|
221
|
+
backgroundColor: e.vars ? `rgba(${e.vars.palette.primary.mainChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.focusOpacity}))` : N(e.palette.primary.main, e.palette.action.selectedOpacity + e.palette.action.focusOpacity)
|
|
222
222
|
}
|
|
223
223
|
},
|
|
224
224
|
[`&.${T.selected}:hover`]: {
|
|
225
|
-
backgroundColor: e.vars ? `rgba(${e.vars.palette.primary.mainChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.hoverOpacity}))` :
|
|
225
|
+
backgroundColor: e.vars ? `rgba(${e.vars.palette.primary.mainChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.hoverOpacity}))` : N(e.palette.primary.main, e.palette.action.selectedOpacity + e.palette.action.hoverOpacity),
|
|
226
226
|
// Reset on touch devices, it doesn't add specificity
|
|
227
227
|
"@media (hover: none)": {
|
|
228
|
-
backgroundColor: e.vars ? `rgba(${e.vars.palette.primary.mainChannel} / ${e.vars.palette.action.selectedOpacity})` :
|
|
228
|
+
backgroundColor: e.vars ? `rgba(${e.vars.palette.primary.mainChannel} / ${e.vars.palette.action.selectedOpacity})` : N(e.palette.primary.main, e.palette.action.selectedOpacity)
|
|
229
229
|
}
|
|
230
230
|
},
|
|
231
231
|
[`&.${T.focusVisible}`]: {
|
|
@@ -255,7 +255,7 @@ const Ee = j("MuiMenuItem", ["root", "focusVisible", "dense", "disabled", "divid
|
|
|
255
255
|
[e.breakpoints.up("sm")]: {
|
|
256
256
|
minHeight: "auto"
|
|
257
257
|
}
|
|
258
|
-
}, o.dense &&
|
|
258
|
+
}, o.dense && x({
|
|
259
259
|
minHeight: 32,
|
|
260
260
|
// https://m2.material.io/components/menus#specs > Dense
|
|
261
261
|
paddingTop: 4,
|
|
@@ -264,49 +264,49 @@ const Ee = j("MuiMenuItem", ["root", "focusVisible", "dense", "disabled", "divid
|
|
|
264
264
|
[`& .${U.root} svg`]: {
|
|
265
265
|
fontSize: "1.25rem"
|
|
266
266
|
}
|
|
267
|
-
}))),
|
|
268
|
-
const n =
|
|
267
|
+
}))), Z = /* @__PURE__ */ M.forwardRef(function(o, s) {
|
|
268
|
+
const n = Q({
|
|
269
269
|
props: o,
|
|
270
270
|
name: "MuiMenuItem"
|
|
271
271
|
}), {
|
|
272
272
|
autoFocus: r = !1,
|
|
273
273
|
component: l = "li",
|
|
274
274
|
dense: c = !1,
|
|
275
|
-
divider:
|
|
276
|
-
disableGutters:
|
|
277
|
-
focusVisibleClassName:
|
|
278
|
-
role:
|
|
275
|
+
divider: y = !1,
|
|
276
|
+
disableGutters: u = !1,
|
|
277
|
+
focusVisibleClassName: m,
|
|
278
|
+
role: g = "menuitem",
|
|
279
279
|
tabIndex: p,
|
|
280
|
-
className:
|
|
281
|
-
} = n, i = K(n,
|
|
282
|
-
dense: c ||
|
|
283
|
-
disableGutters:
|
|
284
|
-
}), [
|
|
285
|
-
|
|
286
|
-
r && (
|
|
280
|
+
className: f
|
|
281
|
+
} = n, i = K(n, Ne), C = M.useContext(B), I = M.useMemo(() => ({
|
|
282
|
+
dense: c || C.dense || !1,
|
|
283
|
+
disableGutters: u
|
|
284
|
+
}), [C.dense, c, u]), b = M.useRef(null);
|
|
285
|
+
ge(() => {
|
|
286
|
+
r && (b.current ? b.current.focus() : process.env.NODE_ENV !== "production" && console.error("MUI: Unable to set focus to a MenuItem whose component has not been rendered."));
|
|
287
287
|
}, [r]);
|
|
288
|
-
const
|
|
289
|
-
dense:
|
|
290
|
-
divider:
|
|
291
|
-
disableGutters:
|
|
292
|
-
}),
|
|
293
|
-
let
|
|
294
|
-
return n.disabled || (
|
|
295
|
-
value:
|
|
296
|
-
children: /* @__PURE__ */ d(
|
|
288
|
+
const S = x({}, n, {
|
|
289
|
+
dense: I.dense,
|
|
290
|
+
divider: y,
|
|
291
|
+
disableGutters: u
|
|
292
|
+
}), $ = Se(n), L = ye(b, s);
|
|
293
|
+
let E;
|
|
294
|
+
return n.disabled || (E = p !== void 0 ? p : -1), /* @__PURE__ */ d(B.Provider, {
|
|
295
|
+
value: I,
|
|
296
|
+
children: /* @__PURE__ */ d(Le, x({
|
|
297
297
|
ref: L,
|
|
298
|
-
role:
|
|
299
|
-
tabIndex:
|
|
298
|
+
role: g,
|
|
299
|
+
tabIndex: E,
|
|
300
300
|
component: l,
|
|
301
|
-
focusVisibleClassName: w(
|
|
302
|
-
className: w(
|
|
301
|
+
focusVisibleClassName: w($.focusVisible, m),
|
|
302
|
+
className: w($.root, f)
|
|
303
303
|
}, i, {
|
|
304
|
-
ownerState:
|
|
305
|
-
classes:
|
|
304
|
+
ownerState: S,
|
|
305
|
+
classes: $
|
|
306
306
|
}))
|
|
307
307
|
});
|
|
308
308
|
});
|
|
309
|
-
process.env.NODE_ENV !== "production" && (
|
|
309
|
+
process.env.NODE_ENV !== "production" && (Z.propTypes = {
|
|
310
310
|
// ----------------------------- Warning --------------------------------
|
|
311
311
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
312
312
|
// | To update them edit the d.ts file and run "yarn proptypes" |
|
|
@@ -381,16 +381,16 @@ process.env.NODE_ENV !== "production" && (Y.propTypes = {
|
|
|
381
381
|
*/
|
|
382
382
|
tabIndex: t.number
|
|
383
383
|
});
|
|
384
|
-
const
|
|
385
|
-
var F = {},
|
|
384
|
+
const Re = Z;
|
|
385
|
+
var F = {}, we = se;
|
|
386
386
|
Object.defineProperty(F, "__esModule", {
|
|
387
387
|
value: !0
|
|
388
388
|
});
|
|
389
|
-
var
|
|
389
|
+
var H = F.default = void 0, Fe = we(oe()), _e = te, Ve = (0, Fe.default)(/* @__PURE__ */ (0, _e.jsx)("path", {
|
|
390
390
|
d: "M8.12 9.29 12 13.17l3.88-3.88c.39-.39 1.02-.39 1.41 0 .39.39.39 1.02 0 1.41l-4.59 4.59c-.39.39-1.02.39-1.41 0L6.7 10.7a.9959.9959 0 0 1 0-1.41c.39-.38 1.03-.39 1.42 0z"
|
|
391
391
|
}), "KeyboardArrowDownRounded");
|
|
392
|
-
|
|
393
|
-
const
|
|
392
|
+
H = F.default = Ve;
|
|
393
|
+
const ot = ({
|
|
394
394
|
name: e,
|
|
395
395
|
label: o,
|
|
396
396
|
type: s,
|
|
@@ -398,16 +398,17 @@ const et = ({
|
|
|
398
398
|
handleInputChange: r,
|
|
399
399
|
placeholder: l,
|
|
400
400
|
required: c,
|
|
401
|
-
disabled:
|
|
402
|
-
options:
|
|
403
|
-
optionsResponseHandler:
|
|
404
|
-
api_endpoint:
|
|
401
|
+
disabled: y,
|
|
402
|
+
options: u,
|
|
403
|
+
optionsResponseHandler: m,
|
|
404
|
+
api_endpoint: g,
|
|
405
405
|
error: p,
|
|
406
|
-
helperText:
|
|
406
|
+
helperText: f,
|
|
407
407
|
inputAdornments: i,
|
|
408
|
-
autofocus:
|
|
408
|
+
autofocus: C,
|
|
409
|
+
authHeader: I
|
|
409
410
|
}) => {
|
|
410
|
-
const [
|
|
411
|
+
const [b, S] = ne([]), $ = V(
|
|
411
412
|
() => ({
|
|
412
413
|
"& .MuiSelect-select > span::before": {
|
|
413
414
|
content: `'${l || ""}'`,
|
|
@@ -415,9 +416,9 @@ const et = ({
|
|
|
415
416
|
}
|
|
416
417
|
}),
|
|
417
418
|
[l]
|
|
418
|
-
),
|
|
419
|
+
), L = V(
|
|
419
420
|
() => ({
|
|
420
|
-
...
|
|
421
|
+
...P.textfield,
|
|
421
422
|
"&.Mui-focused": {
|
|
422
423
|
"& fieldset": {
|
|
423
424
|
borderColor: p ? O.redLight : O.primary
|
|
@@ -429,28 +430,38 @@ const et = ({
|
|
|
429
430
|
"& input::placeholder": {
|
|
430
431
|
color: p ? O.redMedium : "grey"
|
|
431
432
|
},
|
|
432
|
-
...s === "select" &&
|
|
433
|
+
...s === "select" && $
|
|
433
434
|
}),
|
|
434
|
-
[p, s,
|
|
435
|
+
[p, s, $]
|
|
435
436
|
);
|
|
436
|
-
function
|
|
437
|
-
const
|
|
438
|
-
(
|
|
437
|
+
function E(a) {
|
|
438
|
+
const v = b == null ? void 0 : b.find(
|
|
439
|
+
(h) => typeof h == "object" ? h.value === a : h === a
|
|
439
440
|
);
|
|
440
|
-
return typeof
|
|
441
|
+
return typeof v == "object" ? v.name : v;
|
|
441
442
|
}
|
|
442
|
-
const
|
|
443
|
+
const ee = ae(async () => {
|
|
443
444
|
var a;
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
445
|
+
if (s !== "select")
|
|
446
|
+
return [];
|
|
447
|
+
if (u)
|
|
448
|
+
return u;
|
|
449
|
+
if (g && m) {
|
|
450
|
+
const v = {
|
|
451
|
+
"Content-Type": "application/json"
|
|
452
|
+
};
|
|
453
|
+
return I && (v.Authorization = I), (a = (await (await fetch(g, { headers: v })).json())[m.key]) == null ? void 0 : a.map((_) => ({
|
|
454
|
+
name: _[m.name],
|
|
455
|
+
value: _[m.value]
|
|
456
|
+
}));
|
|
457
|
+
}
|
|
458
|
+
return [];
|
|
459
|
+
}, [s, m, g, I]);
|
|
460
|
+
return re(() => {
|
|
461
|
+
ee().then((a) => S(a));
|
|
462
|
+
}, []), /* @__PURE__ */ q(de, { sx: le.inputWrapper, children: [
|
|
452
463
|
/* @__PURE__ */ d(
|
|
453
|
-
|
|
464
|
+
ce,
|
|
454
465
|
{
|
|
455
466
|
name: e,
|
|
456
467
|
label: o,
|
|
@@ -459,10 +470,10 @@ const et = ({
|
|
|
459
470
|
}
|
|
460
471
|
),
|
|
461
472
|
/* @__PURE__ */ d(
|
|
462
|
-
|
|
473
|
+
pe,
|
|
463
474
|
{
|
|
464
475
|
id: `form-input-${e}`,
|
|
465
|
-
autoFocus:
|
|
476
|
+
autoFocus: C,
|
|
466
477
|
name: e,
|
|
467
478
|
type: s,
|
|
468
479
|
select: s === "select",
|
|
@@ -470,14 +481,14 @@ const et = ({
|
|
|
470
481
|
onChange: r,
|
|
471
482
|
placeholder: l,
|
|
472
483
|
required: c,
|
|
473
|
-
disabled:
|
|
484
|
+
disabled: y,
|
|
474
485
|
error: p,
|
|
475
486
|
InputProps: {
|
|
476
487
|
startAdornment: /* @__PURE__ */ d(
|
|
477
488
|
A,
|
|
478
489
|
{
|
|
479
490
|
position: "start",
|
|
480
|
-
sx:
|
|
491
|
+
sx: P.inputAdornment,
|
|
481
492
|
children: i == null ? void 0 : i.beforeInput
|
|
482
493
|
}
|
|
483
494
|
),
|
|
@@ -485,41 +496,41 @@ const et = ({
|
|
|
485
496
|
A,
|
|
486
497
|
{
|
|
487
498
|
position: "end",
|
|
488
|
-
sx:
|
|
499
|
+
sx: P.inputAdornment,
|
|
489
500
|
children: i == null ? void 0 : i.afterInput
|
|
490
501
|
}
|
|
491
502
|
)
|
|
492
503
|
},
|
|
493
504
|
SelectProps: {
|
|
494
|
-
renderValue:
|
|
495
|
-
IconComponent:
|
|
505
|
+
renderValue: E,
|
|
506
|
+
IconComponent: H,
|
|
496
507
|
MenuProps: {
|
|
497
|
-
sx:
|
|
508
|
+
sx: P.selectDropdown
|
|
498
509
|
}
|
|
499
510
|
},
|
|
500
|
-
sx:
|
|
501
|
-
children: s === "select" && (
|
|
502
|
-
const
|
|
511
|
+
sx: L,
|
|
512
|
+
children: s === "select" && (b == null ? void 0 : b.map((a) => {
|
|
513
|
+
const v = typeof a == "object", h = {
|
|
503
514
|
display: "flex",
|
|
504
515
|
justifyContent: "space-between",
|
|
505
516
|
alignItems: "center",
|
|
506
517
|
gap: "1rem"
|
|
507
518
|
};
|
|
508
519
|
return /* @__PURE__ */ d(
|
|
509
|
-
|
|
520
|
+
Re,
|
|
510
521
|
{
|
|
511
|
-
value:
|
|
512
|
-
sx:
|
|
513
|
-
children:
|
|
522
|
+
value: v ? a.value : a,
|
|
523
|
+
sx: h,
|
|
524
|
+
children: v ? a.name : a
|
|
514
525
|
},
|
|
515
|
-
|
|
526
|
+
v ? a.name : a
|
|
516
527
|
);
|
|
517
528
|
}))
|
|
518
529
|
}
|
|
519
530
|
),
|
|
520
|
-
p && /* @__PURE__ */ d(
|
|
531
|
+
p && /* @__PURE__ */ d(ie, { message: f || "" })
|
|
521
532
|
] });
|
|
522
533
|
};
|
|
523
534
|
export {
|
|
524
|
-
|
|
535
|
+
ot as default
|
|
525
536
|
};
|
|
@@ -5,7 +5,7 @@ import { ConfigField, CustomFields, FormInputAdornments, InvalidData } from "./F
|
|
|
5
5
|
interface FormProps {
|
|
6
6
|
config: Array<ConfigField>;
|
|
7
7
|
submitText?: string;
|
|
8
|
-
handleSubmit: (data: any) => void;
|
|
8
|
+
handleSubmit: (data: any, authHeader?: string) => void;
|
|
9
9
|
handleInvalidData?: (data: Array<InvalidData>) => void;
|
|
10
10
|
cancelText?: string;
|
|
11
11
|
handleCancel?: () => void;
|
|
@@ -17,6 +17,7 @@ interface FormProps {
|
|
|
17
17
|
buttonWrapperStyles?: SxProps;
|
|
18
18
|
preFillValues?: any;
|
|
19
19
|
formAdornments?: FormInputAdornments;
|
|
20
|
+
authHeader?: string;
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
23
|
* Form component
|
|
@@ -34,6 +35,7 @@ interface FormProps {
|
|
|
34
35
|
* @param buttonWrapperStyles - Styles for button wrapper
|
|
35
36
|
* @param preFillValues - Object containing pre-fill values
|
|
36
37
|
* @param formAdornments - Object containing form adornments
|
|
38
|
+
* @param authHeader - Authentication header string (e.g., "Bearer token123")
|
|
37
39
|
*/
|
|
38
40
|
declare const Form: CraftFC<FormProps>;
|
|
39
41
|
export default Form;
|
|
@@ -1,158 +1,160 @@
|
|
|
1
|
-
import { jsx as l, jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
import { T as
|
|
1
|
+
import { jsx as l, jsxs as E } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Y, useState as O, useRef as _, useCallback as V, useEffect as Z, useImperativeHandle as K } from "react";
|
|
3
|
+
import A from "../../cell/Button/index.js";
|
|
4
|
+
import { T as C } from "../../../index-ae3eb123.js";
|
|
5
5
|
import y from "./Form.styles.js";
|
|
6
|
-
import { getLocalDateTime as
|
|
7
|
-
import
|
|
8
|
-
import { s as
|
|
6
|
+
import { getLocalDateTime as tt, createNestedObject as et, deepMergeObjects as st } from "./Form.utils.js";
|
|
7
|
+
import rt from "./FormInput.js";
|
|
8
|
+
import { s as nt } from "../../../styled-8f7db30d.js";
|
|
9
9
|
import { B as F } from "../../../Box-96e795c4.js";
|
|
10
|
-
const
|
|
10
|
+
const ot = nt("div")({
|
|
11
11
|
marginBottom: "1rem",
|
|
12
12
|
borderBottom: "1px solid #BBB"
|
|
13
|
-
}),
|
|
13
|
+
}), dt = Y(
|
|
14
14
|
({
|
|
15
15
|
config: p,
|
|
16
|
-
submitText:
|
|
17
|
-
handleSubmit:
|
|
16
|
+
submitText: T = "Submit",
|
|
17
|
+
handleSubmit: R,
|
|
18
18
|
handleInvalidData: h,
|
|
19
|
-
cancelText:
|
|
19
|
+
cancelText: k = "Cancel",
|
|
20
20
|
handleCancel: d,
|
|
21
21
|
onChange: u,
|
|
22
|
-
formStyles:
|
|
23
|
-
formWrapperStyles:
|
|
24
|
-
formFieldsWrapperStyles:
|
|
25
|
-
buttonWrapperStyles:
|
|
22
|
+
formStyles: I = {},
|
|
23
|
+
formWrapperStyles: M = {},
|
|
24
|
+
formFieldsWrapperStyles: N = {},
|
|
25
|
+
buttonWrapperStyles: w = {},
|
|
26
26
|
customFields: S = {},
|
|
27
27
|
preFillValues: x = {},
|
|
28
|
-
formAdornments:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
formAdornments: D = {},
|
|
29
|
+
authHeader: B
|
|
30
|
+
}, W) => {
|
|
31
|
+
const [c, b] = O({}), [q, g] = O([]), v = _(null), j = _(null);
|
|
32
|
+
function H(t, e) {
|
|
32
33
|
b((s) => ({
|
|
33
34
|
...s,
|
|
34
|
-
[
|
|
35
|
-
})), u == null || u(
|
|
35
|
+
[t]: e
|
|
36
|
+
})), u == null || u(t, e), g([]);
|
|
36
37
|
}
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
p == null || p.forEach((
|
|
40
|
-
if (
|
|
41
|
-
const s =
|
|
42
|
-
e
|
|
38
|
+
const P = V(() => {
|
|
39
|
+
const t = {};
|
|
40
|
+
p == null || p.forEach((e) => {
|
|
41
|
+
if (e.preFillWithDateTime && e.type === "text") {
|
|
42
|
+
const s = tt();
|
|
43
|
+
t[e.name] = s, u == null || u(e.name, s);
|
|
43
44
|
} else
|
|
44
|
-
e
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
t[e.name] = e.defaultValue || x[e.name] || "", u == null || u(
|
|
46
|
+
e.name,
|
|
47
|
+
e.defaultValue || x[e.name] || ""
|
|
47
48
|
);
|
|
48
|
-
}), b(
|
|
49
|
+
}), b(t), g([]);
|
|
49
50
|
}, [x]);
|
|
50
|
-
function
|
|
51
|
-
const
|
|
52
|
-
return p == null || p.forEach((
|
|
53
|
-
const { name: s, label: n, type: m, validation: r, required: i } =
|
|
51
|
+
function $() {
|
|
52
|
+
const t = [];
|
|
53
|
+
return p == null || p.forEach((e) => {
|
|
54
|
+
const { name: s, label: n, type: m, validation: r, required: i } = e, o = c[s], a = s;
|
|
54
55
|
if (r)
|
|
55
56
|
if (m === "number") {
|
|
56
57
|
const f = parseInt(o);
|
|
57
|
-
r.min && f < r.min &&
|
|
58
|
+
r.min && f < r.min && t.push({
|
|
58
59
|
field: a,
|
|
59
60
|
value: o,
|
|
60
61
|
message: r.invalid_message
|
|
61
|
-
}), r.max && f > r.max &&
|
|
62
|
+
}), r.max && f > r.max && t.push({
|
|
62
63
|
field: a,
|
|
63
64
|
value: o,
|
|
64
65
|
message: r.invalid_message
|
|
65
|
-
}), isNaN(f) &&
|
|
66
|
+
}), isNaN(f) && t.push({
|
|
66
67
|
field: a,
|
|
67
68
|
value: o,
|
|
68
69
|
message: "Invalid number"
|
|
69
70
|
});
|
|
70
71
|
} else
|
|
71
|
-
m === "text" && (r.min_length && o.length < r.min_length &&
|
|
72
|
+
m === "text" && (r.min_length && o.length < r.min_length && t.push({
|
|
72
73
|
field: a,
|
|
73
74
|
value: o,
|
|
74
75
|
message: r.invalid_message
|
|
75
|
-
}), r.max_length && o.length > r.max_length &&
|
|
76
|
+
}), r.max_length && o.length > r.max_length && t.push({
|
|
76
77
|
field: a,
|
|
77
78
|
value: o,
|
|
78
79
|
message: r.invalid_message
|
|
79
|
-
}), r.pattern && !new RegExp(r.pattern).test(o) &&
|
|
80
|
+
}), r.pattern && !new RegExp(r.pattern).test(o) && t.push({
|
|
80
81
|
field: a,
|
|
81
82
|
value: o,
|
|
82
83
|
message: r.invalid_message
|
|
83
84
|
}));
|
|
84
|
-
i && !o &&
|
|
85
|
+
i && !o && t.push({
|
|
85
86
|
field: a,
|
|
86
87
|
value: o,
|
|
87
88
|
message: `${n} is required`
|
|
88
89
|
});
|
|
89
|
-
}), g(
|
|
90
|
+
}), g(t), t.length && (h == null || h(t)), !t.length;
|
|
90
91
|
}
|
|
91
|
-
const
|
|
92
|
-
(
|
|
93
|
-
let
|
|
94
|
-
return
|
|
92
|
+
const L = V(
|
|
93
|
+
(t) => {
|
|
94
|
+
let e = {};
|
|
95
|
+
return t == null || t.forEach((s) => {
|
|
95
96
|
const { name: n, type: m, submitDataKey: r } = s, i = m === "number" ? parseInt(c[n]) : c[n];
|
|
96
97
|
function o(a) {
|
|
97
98
|
if (a.indexOf(".") !== -1) {
|
|
98
|
-
const f =
|
|
99
|
+
const f = et(
|
|
99
100
|
a,
|
|
100
101
|
m,
|
|
101
102
|
c[n]
|
|
102
103
|
);
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
e = st(
|
|
105
|
+
e,
|
|
105
106
|
f
|
|
106
107
|
);
|
|
107
108
|
} else
|
|
108
|
-
|
|
109
|
+
e[a] = i;
|
|
109
110
|
}
|
|
110
111
|
typeof r != "string" && (r != null && r.length) ? r.forEach((a) => {
|
|
111
112
|
o(a);
|
|
112
|
-
}) : typeof r == "string" && r ? o(r) :
|
|
113
|
-
}),
|
|
113
|
+
}) : typeof r == "string" && r ? o(r) : e[n] = i;
|
|
114
|
+
}), e;
|
|
114
115
|
},
|
|
115
116
|
[c]
|
|
116
117
|
);
|
|
117
|
-
function
|
|
118
|
-
if (
|
|
119
|
-
const s =
|
|
120
|
-
|
|
118
|
+
function z(t) {
|
|
119
|
+
if (t.preventDefault(), $()) {
|
|
120
|
+
const s = L(p);
|
|
121
|
+
R(s, B);
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
|
-
function
|
|
124
|
-
b((
|
|
125
|
-
const
|
|
126
|
-
return Object.keys(
|
|
127
|
-
|
|
128
|
-
}),
|
|
124
|
+
function G() {
|
|
125
|
+
b((t) => {
|
|
126
|
+
const e = { ...t };
|
|
127
|
+
return Object.keys(e).forEach((s) => {
|
|
128
|
+
e[s] = "";
|
|
129
|
+
}), e;
|
|
129
130
|
}), d == null || d();
|
|
130
131
|
}
|
|
131
|
-
function
|
|
132
|
-
const
|
|
133
|
-
(n) => n.field ===
|
|
132
|
+
function J(t) {
|
|
133
|
+
const e = q.find(
|
|
134
|
+
(n) => n.field === t.name
|
|
134
135
|
), s = {
|
|
135
|
-
...
|
|
136
|
-
value: c[
|
|
137
|
-
handleChange:
|
|
138
|
-
error: !!
|
|
139
|
-
helperText:
|
|
140
|
-
inputAdornments:
|
|
136
|
+
...t,
|
|
137
|
+
value: c[t.name],
|
|
138
|
+
handleChange: H,
|
|
139
|
+
error: !!e,
|
|
140
|
+
helperText: e == null ? void 0 : e.message,
|
|
141
|
+
inputAdornments: D[t.name] || t.inputAdornments,
|
|
142
|
+
authHeader: B
|
|
141
143
|
};
|
|
142
|
-
if (
|
|
144
|
+
if (t.hidden)
|
|
143
145
|
return null;
|
|
144
|
-
if (
|
|
145
|
-
const { component: n, props: m } = S[
|
|
146
|
+
if (t.type === "custom" && t.customComponent && S[t.customComponent]) {
|
|
147
|
+
const { component: n, props: m } = S[t.customComponent], r = n, i = {
|
|
146
148
|
...s,
|
|
147
149
|
...m
|
|
148
150
|
};
|
|
149
151
|
if (r && i)
|
|
150
|
-
return /* @__PURE__ */ l(r, { ...i },
|
|
152
|
+
return /* @__PURE__ */ l(r, { ...i }, t.name);
|
|
151
153
|
} else
|
|
152
|
-
return /* @__PURE__ */ l(
|
|
154
|
+
return /* @__PURE__ */ l(rt, { ...s }, t.name);
|
|
153
155
|
}
|
|
154
|
-
function
|
|
155
|
-
const
|
|
156
|
+
function Q() {
|
|
157
|
+
const t = p.reduce(
|
|
156
158
|
(s, n) => {
|
|
157
159
|
const { groupName: m } = n;
|
|
158
160
|
if (!s.length)
|
|
@@ -168,49 +170,49 @@ const ne = re("div")({
|
|
|
168
170
|
},
|
|
169
171
|
[]
|
|
170
172
|
);
|
|
171
|
-
function
|
|
172
|
-
return s.map((n) => typeof n == "string" ? /* @__PURE__ */ l(
|
|
173
|
+
function e(s) {
|
|
174
|
+
return s.map((n) => typeof n == "string" ? /* @__PURE__ */ l(C, { type: "headingSmall", sx: y.heading, children: n }, n) : J(n));
|
|
173
175
|
}
|
|
174
|
-
return
|
|
175
|
-
(s) => typeof s[0] == "string" ? /* @__PURE__ */ l(
|
|
176
|
+
return t.map(
|
|
177
|
+
(s) => typeof s[0] == "string" ? /* @__PURE__ */ l(ot, { children: e(s) }, `group-${s[0]}`) : e(s)
|
|
176
178
|
);
|
|
177
179
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
+
Z(() => {
|
|
181
|
+
P();
|
|
180
182
|
}, []);
|
|
181
|
-
const
|
|
183
|
+
const U = {
|
|
182
184
|
...y.alignVertical,
|
|
183
|
-
...
|
|
184
|
-
},
|
|
185
|
+
...I
|
|
186
|
+
}, X = {
|
|
185
187
|
...y.alignVertical,
|
|
186
188
|
marginTop: "1rem",
|
|
187
189
|
gap: "0.5rem",
|
|
188
|
-
...
|
|
190
|
+
...w
|
|
189
191
|
};
|
|
190
|
-
return
|
|
191
|
-
|
|
192
|
+
return K(
|
|
193
|
+
W,
|
|
192
194
|
() => ({
|
|
193
|
-
submitButtonRef:
|
|
194
|
-
cancelButtonRef:
|
|
195
|
+
submitButtonRef: v,
|
|
196
|
+
cancelButtonRef: j
|
|
195
197
|
}),
|
|
196
198
|
[]
|
|
197
|
-
), /* @__PURE__ */ l(F, { sx:
|
|
198
|
-
/* @__PURE__ */ l(F, { sx:
|
|
199
|
-
/* @__PURE__ */
|
|
199
|
+
), /* @__PURE__ */ l(F, { sx: M, children: /* @__PURE__ */ E("form", { style: U, children: [
|
|
200
|
+
/* @__PURE__ */ l(F, { sx: N, children: Object.keys(c).length && Q() }),
|
|
201
|
+
/* @__PURE__ */ E(F, { sx: X, children: [
|
|
200
202
|
/* @__PURE__ */ l(
|
|
201
|
-
|
|
203
|
+
A,
|
|
202
204
|
{
|
|
203
|
-
ref:
|
|
205
|
+
ref: v,
|
|
204
206
|
type: "submit",
|
|
205
|
-
onClick:
|
|
206
|
-
children:
|
|
207
|
+
onClick: z,
|
|
208
|
+
children: T
|
|
207
209
|
}
|
|
208
210
|
),
|
|
209
|
-
/* @__PURE__ */ l(
|
|
211
|
+
/* @__PURE__ */ l(A, { ref: j, onClick: G, children: k })
|
|
210
212
|
] })
|
|
211
213
|
] }) });
|
|
212
214
|
}
|
|
213
215
|
);
|
|
214
216
|
export {
|
|
215
|
-
|
|
217
|
+
dt as default
|
|
216
218
|
};
|