@loopr-ai/craft 0.8.3 → 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/Box-96e795c4.js +58 -0
- package/dist/{ButtonBase-08b16b61.js → ButtonBase-46c20f20.js} +3 -3
- package/dist/{TextField-f61d210a.js → TextField-df89b641.js} +373 -387
- package/dist/{TransitionGroupContext-0e899f4c.js → TransitionGroupContext-21923db7.js} +1 -1
- package/dist/ZoomControllers-657c8b74.js +3383 -0
- package/dist/components/cell/AvatarGroup/index.js +3 -3
- package/dist/components/cell/Button/index.js +3 -3
- package/dist/components/cell/Chip/index.js +5 -5
- package/dist/components/cell/ProgressBar/index.js +3 -3
- package/dist/components/cell/Search/index.js +2 -2
- package/dist/components/cell/Typography/index.js +1 -1
- package/dist/components/organ/Form/ErrorMessage/ErrorMessage.styles.d.ts +14 -0
- package/dist/components/organ/Form/ErrorMessage/ErrorMessage.styles.js +16 -0
- package/dist/components/organ/Form/ErrorMessage/index.d.ts +6 -0
- package/dist/components/organ/Form/ErrorMessage/index.js +14 -0
- package/dist/components/organ/Form/Form.interfaces.d.ts +4 -2
- package/dist/components/organ/Form/Form.styles.d.ts +6 -99
- package/dist/components/organ/Form/Form.styles.js +8 -102
- package/dist/components/organ/Form/FormInput.d.ts +1 -0
- package/dist/components/organ/Form/FormInput.js +57 -1525
- package/dist/components/organ/Form/Label/Label.styles.d.ts +14 -0
- package/dist/components/organ/Form/Label/Label.styles.js +16 -0
- package/dist/components/organ/Form/Label/index.d.ts +10 -0
- package/dist/components/organ/Form/Label/index.js +17 -0
- package/dist/components/organ/Form/RadioInput/RadioInput.styles.d.ts +17 -0
- package/dist/components/organ/Form/RadioInput/RadioInput.styles.js +20 -0
- package/dist/components/organ/Form/RadioInput/index.d.ts +16 -0
- package/dist/components/organ/Form/RadioInput/index.js +1053 -0
- package/dist/components/organ/Form/TextfieldInput/TextfieldInput.styles.d.ts +75 -0
- package/dist/components/organ/Form/TextfieldInput/TextfieldInput.styles.js +66 -0
- package/dist/components/organ/Form/TextfieldInput/index.d.ts +24 -0
- package/dist/components/organ/Form/TextfieldInput/index.js +536 -0
- package/dist/components/organ/Form/index.d.ts +3 -1
- package/dist/components/organ/Form/index.js +139 -149
- package/dist/components/organ/ZoomControlWithDrag/ZoomControllers.js +2 -2
- package/dist/components/organ/ZoomControlWithDrag/index.js +2 -2
- package/dist/{createSvgIcon-45340b5e.js → createSvgIcon-59e7bc15.js} +3195 -3245
- package/dist/{createSvgIcon-5aac746d.js → createSvgIcon-b444ce70.js} +5 -5
- package/dist/{createTheme-759a022d.js → createTheme-d2329909.js} +4 -4
- package/dist/dividerClasses-9354a5c9.js +10 -0
- package/dist/{exactProp-23d6a154.js → exactProp-3ee21234.js} +1 -1
- package/dist/{extendSxProp-cf8fd923.js → extendSxProp-f6cb682b.js} +1 -1
- package/dist/global/colors.d.ts +1 -0
- package/dist/global/colors.js +5 -4
- package/dist/global/theme.js +1 -1
- package/dist/{index-c9c32237.js → index-ae3eb123.js} +8 -8
- package/dist/main.js +1 -1
- package/dist/providers/CraftThemeProvider.js +2 -2
- package/dist/{styled-78608e1f.js → styled-8f7db30d.js} +39 -39
- package/dist/useControlled-4e337b2f.js +54 -0
- package/dist/useFormControl-b25c5813.js +19 -0
- package/dist/{useTheme-8906bd79.js → useTheme-21caf71b.js} +1 -1
- package/package.json +1 -1
- package/dist/Tooltip-e797a425.js +0 -2022
- package/dist/ZoomControllers-d04c25f8.js +0 -1432
|
@@ -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,228 +1,218 @@
|
|
|
1
1
|
import { jsx as l, jsxs as E } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as
|
|
2
|
+
import { forwardRef as Y, useState as O, useRef as _, useCallback as V, useEffect as Z, useImperativeHandle as K } from "react";
|
|
3
3
|
import A from "../../cell/Button/index.js";
|
|
4
|
-
import { T as
|
|
5
|
-
import
|
|
6
|
-
import { getLocalDateTime as
|
|
7
|
-
import
|
|
8
|
-
import { s as
|
|
9
|
-
import { B as
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
import { T as C } from "../../../index-ae3eb123.js";
|
|
5
|
+
import y from "./Form.styles.js";
|
|
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
|
+
import { B as F } from "../../../Box-96e795c4.js";
|
|
10
|
+
const ot = nt("div")({
|
|
11
|
+
marginBottom: "1rem",
|
|
12
|
+
borderBottom: "1px solid #BBB"
|
|
13
|
+
}), dt = Y(
|
|
13
14
|
({
|
|
14
|
-
config:
|
|
15
|
-
submitText:
|
|
16
|
-
handleSubmit:
|
|
15
|
+
config: p,
|
|
16
|
+
submitText: T = "Submit",
|
|
17
|
+
handleSubmit: R,
|
|
17
18
|
handleInvalidData: h,
|
|
18
|
-
cancelText:
|
|
19
|
-
handleCancel:
|
|
20
|
-
onChange:
|
|
21
|
-
formStyles:
|
|
22
|
-
formWrapperStyles:
|
|
23
|
-
formFieldsWrapperStyles:
|
|
24
|
-
buttonWrapperStyles:
|
|
25
|
-
customFields:
|
|
19
|
+
cancelText: k = "Cancel",
|
|
20
|
+
handleCancel: d,
|
|
21
|
+
onChange: u,
|
|
22
|
+
formStyles: I = {},
|
|
23
|
+
formWrapperStyles: M = {},
|
|
24
|
+
formFieldsWrapperStyles: N = {},
|
|
25
|
+
buttonWrapperStyles: w = {},
|
|
26
|
+
customFields: S = {},
|
|
26
27
|
preFillValues: x = {},
|
|
27
|
-
formAdornments:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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) {
|
|
33
|
+
b((s) => ({
|
|
34
|
+
...s,
|
|
33
35
|
[t]: e
|
|
34
|
-
})),
|
|
36
|
+
})), u == null || u(t, e), g([]);
|
|
35
37
|
}
|
|
36
|
-
const
|
|
38
|
+
const P = V(() => {
|
|
37
39
|
const t = {};
|
|
38
|
-
|
|
40
|
+
p == null || p.forEach((e) => {
|
|
39
41
|
if (e.preFillWithDateTime && e.type === "text") {
|
|
40
|
-
const
|
|
41
|
-
t[e.name] =
|
|
42
|
+
const s = tt();
|
|
43
|
+
t[e.name] = s, u == null || u(e.name, s);
|
|
42
44
|
} else
|
|
43
|
-
t[e.name] = e.defaultValue || x[e.name] || "",
|
|
45
|
+
t[e.name] = e.defaultValue || x[e.name] || "", u == null || u(
|
|
44
46
|
e.name,
|
|
45
47
|
e.defaultValue || x[e.name] || ""
|
|
46
48
|
);
|
|
47
|
-
}), b(t),
|
|
49
|
+
}), b(t), g([]);
|
|
48
50
|
}, [x]);
|
|
49
|
-
function
|
|
51
|
+
function $() {
|
|
50
52
|
const t = [];
|
|
51
|
-
return
|
|
52
|
-
const { name:
|
|
53
|
-
if (
|
|
54
|
-
if (
|
|
55
|
-
const f = parseInt(
|
|
56
|
-
|
|
57
|
-
field:
|
|
58
|
-
value:
|
|
59
|
-
message:
|
|
60
|
-
}),
|
|
61
|
-
field:
|
|
62
|
-
value:
|
|
63
|
-
message:
|
|
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;
|
|
55
|
+
if (r)
|
|
56
|
+
if (m === "number") {
|
|
57
|
+
const f = parseInt(o);
|
|
58
|
+
r.min && f < r.min && t.push({
|
|
59
|
+
field: a,
|
|
60
|
+
value: o,
|
|
61
|
+
message: r.invalid_message
|
|
62
|
+
}), r.max && f > r.max && t.push({
|
|
63
|
+
field: a,
|
|
64
|
+
value: o,
|
|
65
|
+
message: r.invalid_message
|
|
64
66
|
}), isNaN(f) && t.push({
|
|
65
|
-
field:
|
|
66
|
-
value:
|
|
67
|
+
field: a,
|
|
68
|
+
value: o,
|
|
67
69
|
message: "Invalid number"
|
|
68
70
|
});
|
|
69
71
|
} else
|
|
70
|
-
|
|
71
|
-
field:
|
|
72
|
-
value:
|
|
73
|
-
message:
|
|
74
|
-
}),
|
|
75
|
-
field:
|
|
76
|
-
value:
|
|
77
|
-
message:
|
|
78
|
-
}),
|
|
79
|
-
field:
|
|
80
|
-
value:
|
|
81
|
-
message:
|
|
72
|
+
m === "text" && (r.min_length && o.length < r.min_length && t.push({
|
|
73
|
+
field: a,
|
|
74
|
+
value: o,
|
|
75
|
+
message: r.invalid_message
|
|
76
|
+
}), r.max_length && o.length > r.max_length && t.push({
|
|
77
|
+
field: a,
|
|
78
|
+
value: o,
|
|
79
|
+
message: r.invalid_message
|
|
80
|
+
}), r.pattern && !new RegExp(r.pattern).test(o) && t.push({
|
|
81
|
+
field: a,
|
|
82
|
+
value: o,
|
|
83
|
+
message: r.invalid_message
|
|
82
84
|
}));
|
|
83
|
-
|
|
84
|
-
field:
|
|
85
|
-
value:
|
|
85
|
+
i && !o && t.push({
|
|
86
|
+
field: a,
|
|
87
|
+
value: o,
|
|
86
88
|
message: `${n} is required`
|
|
87
89
|
});
|
|
88
|
-
}),
|
|
90
|
+
}), g(t), t.length && (h == null || h(t)), !t.length;
|
|
89
91
|
}
|
|
90
|
-
const
|
|
92
|
+
const L = V(
|
|
91
93
|
(t) => {
|
|
92
94
|
let e = {};
|
|
93
|
-
return t == null || t.forEach((
|
|
94
|
-
const { name: n, type:
|
|
95
|
-
function
|
|
96
|
-
if (
|
|
97
|
-
const f =
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
return t == null || t.forEach((s) => {
|
|
96
|
+
const { name: n, type: m, submitDataKey: r } = s, i = m === "number" ? parseInt(c[n]) : c[n];
|
|
97
|
+
function o(a) {
|
|
98
|
+
if (a.indexOf(".") !== -1) {
|
|
99
|
+
const f = et(
|
|
100
|
+
a,
|
|
101
|
+
m,
|
|
100
102
|
c[n]
|
|
101
103
|
);
|
|
102
|
-
e =
|
|
104
|
+
e = st(
|
|
103
105
|
e,
|
|
104
106
|
f
|
|
105
107
|
);
|
|
106
108
|
} else
|
|
107
|
-
e[
|
|
109
|
+
e[a] = i;
|
|
108
110
|
}
|
|
109
|
-
typeof
|
|
110
|
-
|
|
111
|
-
}) : typeof
|
|
111
|
+
typeof r != "string" && (r != null && r.length) ? r.forEach((a) => {
|
|
112
|
+
o(a);
|
|
113
|
+
}) : typeof r == "string" && r ? o(r) : e[n] = i;
|
|
112
114
|
}), e;
|
|
113
115
|
},
|
|
114
116
|
[c]
|
|
115
117
|
);
|
|
116
|
-
function
|
|
117
|
-
if (t.preventDefault(),
|
|
118
|
-
const
|
|
119
|
-
|
|
118
|
+
function z(t) {
|
|
119
|
+
if (t.preventDefault(), $()) {
|
|
120
|
+
const s = L(p);
|
|
121
|
+
R(s, B);
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
|
-
function
|
|
124
|
+
function G() {
|
|
123
125
|
b((t) => {
|
|
124
126
|
const e = { ...t };
|
|
125
|
-
return Object.keys(e).forEach((
|
|
126
|
-
e[
|
|
127
|
+
return Object.keys(e).forEach((s) => {
|
|
128
|
+
e[s] = "";
|
|
127
129
|
}), e;
|
|
128
|
-
}),
|
|
130
|
+
}), d == null || d();
|
|
129
131
|
}
|
|
130
|
-
function
|
|
131
|
-
const e =
|
|
132
|
+
function J(t) {
|
|
133
|
+
const e = q.find(
|
|
132
134
|
(n) => n.field === t.name
|
|
133
|
-
),
|
|
135
|
+
), s = {
|
|
134
136
|
...t,
|
|
135
137
|
value: c[t.name],
|
|
136
|
-
handleChange:
|
|
138
|
+
handleChange: H,
|
|
137
139
|
error: !!e,
|
|
138
140
|
helperText: e == null ? void 0 : e.message,
|
|
139
|
-
inputAdornments:
|
|
141
|
+
inputAdornments: D[t.name] || t.inputAdornments,
|
|
142
|
+
authHeader: B
|
|
140
143
|
};
|
|
141
144
|
if (t.hidden)
|
|
142
145
|
return null;
|
|
143
|
-
if (t.type === "custom" && t.customComponent &&
|
|
144
|
-
const { component: n, props:
|
|
145
|
-
...
|
|
146
|
-
...
|
|
146
|
+
if (t.type === "custom" && t.customComponent && S[t.customComponent]) {
|
|
147
|
+
const { component: n, props: m } = S[t.customComponent], r = n, i = {
|
|
148
|
+
...s,
|
|
149
|
+
...m
|
|
147
150
|
};
|
|
148
|
-
if (
|
|
149
|
-
return /* @__PURE__ */ l(
|
|
151
|
+
if (r && i)
|
|
152
|
+
return /* @__PURE__ */ l(r, { ...i }, t.name);
|
|
150
153
|
} else
|
|
151
|
-
return /* @__PURE__ */ l(
|
|
154
|
+
return /* @__PURE__ */ l(rt, { ...s }, t.name);
|
|
152
155
|
}
|
|
153
|
-
function
|
|
154
|
-
|
|
155
|
-
(
|
|
156
|
-
const { groupName:
|
|
157
|
-
if (!
|
|
158
|
-
|
|
159
|
-
else if (
|
|
160
|
-
const
|
|
161
|
-
|
|
156
|
+
function Q() {
|
|
157
|
+
const t = p.reduce(
|
|
158
|
+
(s, n) => {
|
|
159
|
+
const { groupName: m } = n;
|
|
160
|
+
if (!s.length)
|
|
161
|
+
s.push(m ? [m, n] : [n]);
|
|
162
|
+
else if (m) {
|
|
163
|
+
const i = s.findIndex((o) => o[0] === m);
|
|
164
|
+
i === -1 ? s.push([m, n]) : s[i].push(n);
|
|
162
165
|
} else {
|
|
163
|
-
const
|
|
164
|
-
typeof
|
|
166
|
+
const i = s[s.length - 1];
|
|
167
|
+
typeof i[0] == "string" ? s.push([n]) : i.push(n);
|
|
165
168
|
}
|
|
166
|
-
return
|
|
169
|
+
return s;
|
|
167
170
|
},
|
|
168
171
|
[]
|
|
169
|
-
)
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
children: e.map((n) => typeof n == "string" ? /* @__PURE__ */ l(
|
|
176
|
-
K,
|
|
177
|
-
{
|
|
178
|
-
type: "headingSmall",
|
|
179
|
-
sx: d.heading,
|
|
180
|
-
children: n
|
|
181
|
-
},
|
|
182
|
-
n
|
|
183
|
-
) : G(n))
|
|
184
|
-
},
|
|
185
|
-
`group-${r ? e[0] : e[0].name}`
|
|
186
|
-
);
|
|
187
|
-
}
|
|
172
|
+
);
|
|
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));
|
|
175
|
+
}
|
|
176
|
+
return t.map(
|
|
177
|
+
(s) => typeof s[0] == "string" ? /* @__PURE__ */ l(ot, { children: e(s) }, `group-${s[0]}`) : e(s)
|
|
188
178
|
);
|
|
189
179
|
}
|
|
190
|
-
|
|
191
|
-
|
|
180
|
+
Z(() => {
|
|
181
|
+
P();
|
|
192
182
|
}, []);
|
|
193
|
-
const
|
|
194
|
-
...
|
|
195
|
-
...
|
|
196
|
-
},
|
|
197
|
-
...
|
|
183
|
+
const U = {
|
|
184
|
+
...y.alignVertical,
|
|
185
|
+
...I
|
|
186
|
+
}, X = {
|
|
187
|
+
...y.alignVertical,
|
|
198
188
|
marginTop: "1rem",
|
|
199
189
|
gap: "0.5rem",
|
|
200
|
-
...
|
|
190
|
+
...w
|
|
201
191
|
};
|
|
202
|
-
return
|
|
203
|
-
|
|
192
|
+
return K(
|
|
193
|
+
W,
|
|
204
194
|
() => ({
|
|
205
|
-
submitButtonRef:
|
|
195
|
+
submitButtonRef: v,
|
|
206
196
|
cancelButtonRef: j
|
|
207
197
|
}),
|
|
208
198
|
[]
|
|
209
|
-
), /* @__PURE__ */ l(
|
|
210
|
-
/* @__PURE__ */ l(
|
|
211
|
-
/* @__PURE__ */ E(
|
|
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: [
|
|
212
202
|
/* @__PURE__ */ l(
|
|
213
203
|
A,
|
|
214
204
|
{
|
|
215
|
-
ref:
|
|
205
|
+
ref: v,
|
|
216
206
|
type: "submit",
|
|
217
|
-
onClick:
|
|
218
|
-
children:
|
|
207
|
+
onClick: z,
|
|
208
|
+
children: T
|
|
219
209
|
}
|
|
220
210
|
),
|
|
221
|
-
/* @__PURE__ */ l(A, { ref: j, onClick:
|
|
211
|
+
/* @__PURE__ */ l(A, { ref: j, onClick: G, children: k })
|
|
222
212
|
] })
|
|
223
213
|
] }) });
|
|
224
214
|
}
|
|
225
215
|
);
|
|
226
216
|
export {
|
|
227
|
-
|
|
217
|
+
dt as default
|
|
228
218
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
|
-
import { Z as p } from "../../../ZoomControllers-
|
|
3
|
-
import "../../../
|
|
2
|
+
import { Z as p } from "../../../ZoomControllers-657c8b74.js";
|
|
3
|
+
import "../../../Box-96e795c4.js";
|
|
4
4
|
export {
|
|
5
5
|
p as default
|
|
6
6
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as t, jsxs as x } from "react/jsx-runtime";
|
|
2
2
|
import { useState as y, useEffect as n, useMemo as w } from "react";
|
|
3
|
-
import { T as C, Z as S, a as W } from "../../../ZoomControllers-
|
|
4
|
-
import { B as m } from "../../../
|
|
3
|
+
import { T as C, Z as S, a as W } from "../../../ZoomControllers-657c8b74.js";
|
|
4
|
+
import { B as m } from "../../../Box-96e795c4.js";
|
|
5
5
|
const D = {
|
|
6
6
|
position: "relative",
|
|
7
7
|
borderRadius: "1rem",
|