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