@loopr-ai/craft 0.7.1 → 0.7.3

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 (42) hide show
  1. package/dist/{ButtonBase-fc1e48eb.js → ButtonBase-85c9347b.js} +3 -3
  2. package/dist/{TextField-a534df29.js → TextField-fded06e5.js} +7 -7
  3. package/dist/Tooltip-b926c320.js +2022 -0
  4. package/dist/{TransitionGroupContext-ba502e63.js → TransitionGroupContext-fe9a562f.js} +3 -3
  5. package/dist/ZoomControllers-36e39bb0.js +1432 -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 +5 -19
  12. package/dist/components/organ/Form/Form.interfaces.d.ts +8 -6
  13. package/dist/components/organ/Form/Form.styles.d.ts +99 -2
  14. package/dist/components/organ/Form/Form.styles.js +99 -4
  15. package/dist/components/organ/Form/Form.utils.d.ts +1 -0
  16. package/dist/components/organ/Form/Form.utils.js +20 -15
  17. package/dist/components/organ/Form/FormInput.js +517 -0
  18. package/dist/components/organ/Form/index.js +161 -108
  19. package/dist/components/organ/ZoomControlWithDrag/ZoomControllers.js +2 -2
  20. package/dist/components/organ/ZoomControlWithDrag/index.js +2 -2
  21. package/dist/{createSvgIcon-bb3d4825.js → createSvgIcon-58aa3adf.js} +5 -5
  22. package/dist/{Grow-a906cda2.js → createSvgIcon-f773ce57.js} +4020 -3944
  23. package/dist/{createTheme-ca1567c6.js → createTheme-a4db2989.js} +7 -7
  24. package/dist/{exactProp-3d9df1ae.js → exactProp-d79ccada.js} +1 -1
  25. package/dist/{extendSxProp-fc2654e5.js → extendSxProp-db8b9da5.js} +1 -1
  26. package/dist/global/colors.d.ts +5 -0
  27. package/dist/global/colors.js +11 -6
  28. package/dist/global/constants.d.ts +3 -0
  29. package/dist/global/constants.js +6 -1
  30. package/dist/global/theme.js +1 -1
  31. package/dist/{Typography-65e5f8a8.js → index-03287c17.js} +61 -45
  32. package/dist/main.js +10 -10
  33. package/dist/providers/CraftThemeProvider.js +2 -2
  34. package/dist/{styled-80b57810.js → styled-126c6a62.js} +49 -49
  35. package/dist/{useTheme-16446f25.js → useTheme-573c40a2.js} +1 -1
  36. package/package.json +1 -1
  37. package/dist/Box-8cd400c2.js +0 -58
  38. package/dist/ZoomControllers-8a147df0.js +0 -3390
  39. package/dist/components/organ/Form/FieldInput.js +0 -440
  40. package/dist/createSvgIcon-8e5d9dc7.js +0 -81
  41. package/dist/dividerClasses-0233db5a.js +0 -10
  42. /package/dist/components/organ/Form/{FieldInput.d.ts → FormInput.d.ts} +0 -0
@@ -1,137 +1,190 @@
1
- import { jsxs as j, jsx as u } from "react/jsx-runtime";
2
- import { useState as y, useCallback as K, useEffect as P } from "react";
3
- import V from "../../cell/Button/index.js";
4
- import R from "./FieldInput.js";
5
- import _ from "./Form.styles.js";
6
- import { createNestedObject as T, deepMergeObjects as W } from "./Form.utils.js";
7
- import { B as $ } from "../../../Box-8cd400c2.js";
8
- const U = ({
9
- config: r,
10
- submitText: g = "Submit",
11
- handleSubmit: v,
12
- handleInvalidData: p,
13
- cancelText: F = "Cancel",
14
- handleCancel: S,
15
- onChange: c,
16
- formStyles: O = {},
17
- buttonWrapperStyles: C = {},
18
- customFields: B = {}
1
+ import { jsxs as F, jsx as l } from "react/jsx-runtime";
2
+ import { useState as j, useCallback as P, useEffect as $ } from "react";
3
+ import v from "../../cell/Button/index.js";
4
+ import { T as w } from "../../../index-03287c17.js";
5
+ import d from "./Form.styles.js";
6
+ import { createNestedObject as H, deepMergeObjects as K, getLocalDateTime as L } from "./Form.utils.js";
7
+ import R from "./FormInput.js";
8
+ import { s as z } from "../../../styled-126c6a62.js";
9
+ import { B as G } from "../../../Tooltip-b926c320.js";
10
+ const J = z("div")({
11
+ marginTop: "0.75rem"
12
+ }), re = ({
13
+ config: o,
14
+ submitText: S = "Submit",
15
+ handleSubmit: V,
16
+ handleInvalidData: c,
17
+ cancelText: _ = "Cancel",
18
+ handleCancel: C,
19
+ onChange: h,
20
+ formStyles: E = {},
21
+ buttonWrapperStyles: O = {},
22
+ customFields: b = {}
19
23
  }) => {
20
- const [o, d] = y({}), [E, f] = y([]);
21
- function M(e, s) {
22
- d((m) => ({
23
- ...m,
24
- [e]: s
25
- })), c == null || c(e, s);
24
+ const [u, y] = j({}), [T, g] = j([]);
25
+ function A(e, t) {
26
+ y((n) => ({
27
+ ...n,
28
+ [e]: t
29
+ })), h == null || h(e, t), g([]);
26
30
  }
27
31
  function x() {
28
32
  const e = {};
29
- r == null || r.forEach((s) => {
30
- e[s.name] = s.defaultValue || "";
31
- }), d(e), f([]);
33
+ o == null || o.forEach((t) => {
34
+ if (t.preFillWithDateTime && t.type === "text") {
35
+ const n = L();
36
+ e[t.name] = n;
37
+ } else
38
+ e[t.name] = t.defaultValue || "";
39
+ }), y(e), g([]);
32
40
  }
33
- function k() {
41
+ function D() {
34
42
  const e = [];
35
- return r == null || r.forEach((s) => {
36
- const { name: m, label: n, type: l, validation: t, required: b } = s, a = o[m], i = m;
37
- if (t)
38
- if (l === "number") {
39
- const h = parseInt(a);
40
- t.min && h < t.min && e.push({
41
- field: i,
42
- value: a,
43
- message: t.invalid_message
44
- }), t.max && h > t.max && e.push({
45
- field: i,
46
- value: a,
47
- message: t.invalid_message
48
- }), isNaN(h) && e.push({
49
- field: i,
50
- value: a,
43
+ return o == null || o.forEach((t) => {
44
+ const { name: n, label: r, type: a, validation: s, required: i } = t, m = u[n], p = n;
45
+ if (s)
46
+ if (a === "number") {
47
+ const f = parseInt(m);
48
+ s.min && f < s.min && e.push({
49
+ field: p,
50
+ value: m,
51
+ message: s.invalid_message
52
+ }), s.max && f > s.max && e.push({
53
+ field: p,
54
+ value: m,
55
+ message: s.invalid_message
56
+ }), isNaN(f) && e.push({
57
+ field: p,
58
+ value: m,
51
59
  message: "Invalid number"
52
60
  });
53
61
  } else
54
- l === "text" && (t.min_length && a.length < t.min_length && e.push({
55
- field: i,
56
- value: a,
57
- message: t.invalid_message
58
- }), t.max_length && a.length > t.max_length && e.push({
59
- field: i,
60
- value: a,
61
- message: t.invalid_message
62
- }), t.pattern && !new RegExp(t.pattern).test(a) && e.push({
63
- field: i,
64
- value: a,
65
- message: t.invalid_message
62
+ a === "text" && (s.min_length && m.length < s.min_length && e.push({
63
+ field: p,
64
+ value: m,
65
+ message: s.invalid_message
66
+ }), s.max_length && m.length > s.max_length && e.push({
67
+ field: p,
68
+ value: m,
69
+ message: s.invalid_message
70
+ }), s.pattern && !new RegExp(s.pattern).test(m) && e.push({
71
+ field: p,
72
+ value: m,
73
+ message: s.invalid_message
66
74
  }));
67
- b && !a && e.push({
68
- field: i,
69
- value: a,
70
- message: `${n} is required`
75
+ i && !m && e.push({
76
+ field: p,
77
+ value: m,
78
+ message: `${r} is required`
71
79
  });
72
- }), f(e), e.length && (p == null || p(e)), !e.length;
80
+ }), g(e), e.length && (c == null || c(e)), !e.length;
73
81
  }
74
- const D = K(
82
+ const B = P(
75
83
  (e) => {
76
- let s = {};
77
- return e == null || e.forEach((m) => {
78
- const { name: n, type: l, submitDataKey: t } = m;
79
- if (t) {
80
- const b = T(
81
- t,
82
- l,
83
- o[n]
84
+ let t = {};
85
+ return e == null || e.forEach((n) => {
86
+ const { name: r, type: a, submitDataKey: s } = n;
87
+ if (s) {
88
+ const i = H(
89
+ s,
90
+ a,
91
+ u[r]
84
92
  );
85
- s = W(s, b);
93
+ t = K(t, i);
86
94
  } else
87
- s[n] = l === "number" ? parseInt(o[n]) : o[n];
88
- }), s;
95
+ t[r] = a === "number" ? parseInt(u[r]) : u[r];
96
+ }), t;
89
97
  },
90
- [o]
98
+ [u]
91
99
  );
92
- function N(e) {
93
- if (e.preventDefault(), k()) {
94
- const m = D(r);
95
- v(m);
100
+ function M(e) {
101
+ if (e.preventDefault(), D()) {
102
+ const n = B(o);
103
+ V(n);
96
104
  }
97
105
  }
98
- function q() {
99
- x(), S();
106
+ function N() {
107
+ x(), C();
108
+ }
109
+ function k(e) {
110
+ const t = T.find(
111
+ (r) => r.field === e.name
112
+ ), n = {
113
+ ...e,
114
+ value: u[e.name],
115
+ handleChange: A,
116
+ error: !!t,
117
+ helperText: t == null ? void 0 : t.message
118
+ };
119
+ if (e.hidden)
120
+ return null;
121
+ if (e.type === "custom" && e.customComponent && b[e.customComponent]) {
122
+ const { component: r, props: a } = b[e.customComponent], s = r, i = {
123
+ ...n,
124
+ ...a
125
+ };
126
+ if (s && i)
127
+ return /* @__PURE__ */ l(s, { ...i }, e.name);
128
+ } else
129
+ return /* @__PURE__ */ l(R, { ...n }, e.name);
130
+ }
131
+ function I() {
132
+ return o.reduce(
133
+ (t, n) => {
134
+ const { groupName: r } = n;
135
+ if (!t.length)
136
+ t.push(r ? [r, n] : [n]);
137
+ else if (r) {
138
+ const s = t.findIndex((i) => i[0] === r);
139
+ s === -1 ? t.push([r, n]) : t[s].push(n);
140
+ } else {
141
+ const s = t[t.length - 1];
142
+ typeof s[0] == "string" ? t.push([n]) : s.push(n);
143
+ }
144
+ return t;
145
+ },
146
+ []
147
+ ).map(
148
+ (t) => {
149
+ const n = typeof t[0] == "string";
150
+ return /* @__PURE__ */ l(
151
+ J,
152
+ {
153
+ children: t.map((r) => typeof r == "string" ? /* @__PURE__ */ l(
154
+ w,
155
+ {
156
+ type: "headingSmall",
157
+ sx: d.heading,
158
+ children: r
159
+ },
160
+ r
161
+ ) : k(r))
162
+ },
163
+ `group-${n ? t[0] : t[0].name}`
164
+ );
165
+ }
166
+ );
100
167
  }
101
- P(() => {
168
+ $(() => {
102
169
  x();
103
170
  }, []);
104
- const w = {
105
- ..._.alignVertical,
171
+ const W = {
172
+ ...d.alignVertical,
173
+ ...E
174
+ }, q = {
175
+ ...d.alignVertical,
176
+ marginTop: "1rem",
177
+ gap: "0.5rem",
106
178
  ...O
107
- }, A = {
108
- ..._.alignVertical,
109
- ...C
110
179
  };
111
- return /* @__PURE__ */ j("form", { style: w, children: [
112
- Object.keys(o).length && (r == null ? void 0 : r.map((e) => {
113
- const s = E.find(
114
- (n) => n.field === e.name
115
- ), m = {
116
- ...e,
117
- value: o[e.name],
118
- handleChange: M,
119
- error: !!s,
120
- helperText: s == null ? void 0 : s.message
121
- };
122
- if (e.type === "custom" && e.customComponent) {
123
- const n = B[e.customComponent];
124
- if (n)
125
- return /* @__PURE__ */ u(n, { ...m }, e.name);
126
- } else
127
- return /* @__PURE__ */ u(R, { ...m }, e.name);
128
- })),
129
- /* @__PURE__ */ j($, { sx: A, children: [
130
- /* @__PURE__ */ u(V, { type: "submit", onClick: N, children: g }),
131
- /* @__PURE__ */ u(V, { onClick: q, children: F })
180
+ return /* @__PURE__ */ F("form", { style: W, children: [
181
+ Object.keys(u).length && I(),
182
+ /* @__PURE__ */ F(G, { sx: q, children: [
183
+ /* @__PURE__ */ l(v, { type: "submit", onClick: M, children: S }),
184
+ /* @__PURE__ */ l(v, { onClick: N, children: _ })
132
185
  ] })
133
186
  ] });
134
187
  };
135
188
  export {
136
- U as default
189
+ re as default
137
190
  };
@@ -1,6 +1,6 @@
1
1
  import "react/jsx-runtime";
2
- import { Z as p } from "../../../ZoomControllers-8a147df0.js";
3
- import "../../../Box-8cd400c2.js";
2
+ import { Z as p } from "../../../ZoomControllers-36e39bb0.js";
3
+ import "../../../Tooltip-b926c320.js";
4
4
  export {
5
5
  p as default
6
6
  };
@@ -1,7 +1,7 @@
1
1
  import { jsx as t, jsxs as y } from "react/jsx-runtime";
2
2
  import { useState as x, useEffect as n, useMemo as w } from "react";
3
- import { T as C, Z as S, a as W } from "../../../ZoomControllers-8a147df0.js";
4
- import { B as m } from "../../../Box-8cd400c2.js";
3
+ import { T as C, Z as S, a as W } from "../../../ZoomControllers-36e39bb0.js";
4
+ import { B as m } from "../../../Tooltip-b926c320.js";
5
5
  const D = {
6
6
  position: "relative",
7
7
  borderRadius: "1rem",
@@ -1,9 +1,9 @@
1
- import { g as I, b as h, _ as w, a as y, P as o } from "./createTheme-ca1567c6.js";
1
+ import { g as b, c as h, _ as w, a as y, P as o } from "./createTheme-a4db2989.js";
2
2
  import * as v from "react";
3
3
  import { jsxs as C, jsx as z } from "react/jsx-runtime";
4
- import { g as T, a as N, b as R, c as O, e as B } from "./styled-80b57810.js";
4
+ import { g as T, s as N, a as R, c as O, b as B } from "./styled-126c6a62.js";
5
5
  function j(e) {
6
- return I("MuiSvgIcon", e);
6
+ return b("MuiSvgIcon", e);
7
7
  }
8
8
  T("MuiSvgIcon", ["root", "colorPrimary", "colorSecondary", "colorAction", "colorError", "colorDisabled", "fontSizeInherit", "fontSizeSmall", "fontSizeMedium", "fontSizeLarge"]);
9
9
  const A = ["children", "className", "color", "component", "fontSize", "htmlColor", "inheritViewBox", "titleAccess", "viewBox"], E = (e) => {
@@ -78,10 +78,10 @@ const A = ["children", "className", "color", "component", "fontSize", "htmlColor
78
78
  hasSvgAsChild: l
79
79
  }), x = {};
80
80
  m || (x.viewBox = a);
81
- const b = E($);
81
+ const I = E($);
82
82
  return /* @__PURE__ */ C(V, y({
83
83
  as: c,
84
- className: O(b.root, d),
84
+ className: O(I.root, d),
85
85
  focusable: "false",
86
86
  color: u,
87
87
  "aria-hidden": s ? void 0 : !0,