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