@loopr-ai/craft 0.7.5 → 0.8.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 (32) hide show
  1. package/dist/{ButtonBase-85c9347b.js → ButtonBase-08b16b61.js} +3 -3
  2. package/dist/{TextField-fded06e5.js → TextField-f61d210a.js} +8 -7
  3. package/dist/{Tooltip-b926c320.js → Tooltip-e797a425.js} +6 -6
  4. package/dist/{TransitionGroupContext-fe9a562f.js → TransitionGroupContext-0e899f4c.js} +1 -1
  5. package/dist/{ZoomControllers-36e39bb0.js → ZoomControllers-d04c25f8.js} +5 -5
  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/Form.interfaces.d.ts +12 -4
  13. package/dist/components/organ/Form/Form.styles.d.ts +7 -2
  14. package/dist/components/organ/Form/Form.styles.js +9 -4
  15. package/dist/components/organ/Form/FormInput.d.ts +1 -0
  16. package/dist/components/organ/Form/FormInput.js +1284 -270
  17. package/dist/components/organ/Form/index.d.ts +3 -1
  18. package/dist/components/organ/Form/index.js +136 -128
  19. package/dist/components/organ/ZoomControlWithDrag/ZoomControllers.js +2 -2
  20. package/dist/components/organ/ZoomControlWithDrag/index.js +2 -2
  21. package/dist/{createSvgIcon-f773ce57.js → createSvgIcon-45340b5e.js} +17 -17
  22. package/dist/{createSvgIcon-58aa3adf.js → createSvgIcon-5aac746d.js} +2 -2
  23. package/dist/{createTheme-a4db2989.js → createTheme-759a022d.js} +507 -477
  24. package/dist/{exactProp-d79ccada.js → exactProp-23d6a154.js} +1 -1
  25. package/dist/{extendSxProp-db8b9da5.js → extendSxProp-cf8fd923.js} +1 -1
  26. package/dist/global/theme.js +1 -1
  27. package/dist/{index-03287c17.js → index-c9c32237.js} +3 -3
  28. package/dist/main.js +1 -1
  29. package/dist/providers/CraftThemeProvider.js +2 -2
  30. package/dist/{styled-126c6a62.js → styled-78608e1f.js} +16 -14
  31. package/dist/{useTheme-573c40a2.js → useTheme-8906bd79.js} +1 -1
  32. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { SxProps } from "@mui/material";
2
2
  import React from "react";
3
3
  import { CraftFC } from "../../../global/interfaces";
4
- import { ConfigField, CustomFields, InvalidData } from "./Form.interfaces";
4
+ import { ConfigField, CustomFields, FormInputAdornments, InvalidData } from "./Form.interfaces";
5
5
  interface FormProps {
6
6
  config: Array<ConfigField>;
7
7
  submitText?: string;
@@ -15,6 +15,8 @@ interface FormProps {
15
15
  formFieldsWrapperStyles?: SxProps;
16
16
  formStyles?: React.CSSProperties;
17
17
  buttonWrapperStyles?: SxProps;
18
+ preFillValues?: any;
19
+ formAdornments?: FormInputAdornments;
18
20
  }
19
21
  /**
20
22
  * Form component
@@ -1,192 +1,200 @@
1
- import { jsx as u, jsxs as j } from "react/jsx-runtime";
2
- import { useState as v, useCallback as H, useEffect as K } from "react";
3
- import S from "../../cell/Button/index.js";
4
- import { T as L } from "../../../index-03287c17.js";
5
- import f from "./Form.styles.js";
6
- import { createNestedObject as R, deepMergeObjects as z, getLocalDateTime as G } from "./Form.utils.js";
7
- import J from "./FormInput.js";
8
- import { s as Q } from "../../../styled-126c6a62.js";
9
- import { B as b } from "../../../Tooltip-b926c320.js";
10
- const U = Q("div")({
1
+ import { jsx as u, jsxs as v } from "react/jsx-runtime";
2
+ import { useState as S, useCallback as R, useEffect as z } from "react";
3
+ import j from "../../cell/Button/index.js";
4
+ import { T as G } from "../../../index-c9c32237.js";
5
+ import d from "./Form.styles.js";
6
+ import { getLocalDateTime as J, createNestedObject as Q, deepMergeObjects as U } from "./Form.utils.js";
7
+ import X from "./FormInput.js";
8
+ import { s as Y } from "../../../styled-78608e1f.js";
9
+ import { B as x } from "../../../Tooltip-e797a425.js";
10
+ const Z = Y("div")({
11
11
  marginTop: "0.75rem"
12
- }), oe = ({
13
- config: o,
12
+ }), ie = ({
13
+ config: i,
14
14
  submitText: V = "Submit",
15
15
  handleSubmit: _,
16
- handleInvalidData: c,
17
- cancelText: C = "Cancel",
18
- handleCancel: E,
19
- onChange: h,
20
- formStyles: O = {},
21
- formWrapperStyles: T = {},
22
- formFieldsWrapperStyles: A = {},
23
- buttonWrapperStyles: D = {},
24
- customFields: x = {}
16
+ handleInvalidData: h,
17
+ cancelText: E = "Cancel",
18
+ handleCancel: O,
19
+ onChange: g,
20
+ formStyles: A = {},
21
+ formWrapperStyles: C = {},
22
+ formFieldsWrapperStyles: T = {},
23
+ buttonWrapperStyles: B = {},
24
+ customFields: y = {},
25
+ preFillValues: M = {},
26
+ formAdornments: N = {}
25
27
  }) => {
26
- const [p, y] = v({}), [B, g] = v([]);
27
- function M(e, t) {
28
- y((n) => ({
28
+ const [l, b] = S({}), [k, f] = S([]);
29
+ function D(t, e) {
30
+ b((n) => ({
29
31
  ...n,
30
- [e]: t
31
- })), h == null || h(e, t), g([]);
32
+ [t]: e
33
+ })), g == null || g(t, e), f([]);
32
34
  }
33
35
  function F() {
34
- const e = {};
35
- o == null || o.forEach((t) => {
36
- if (t.preFillWithDateTime && t.type === "text") {
37
- const n = G();
38
- e[t.name] = n;
36
+ const t = {};
37
+ i == null || i.forEach((e) => {
38
+ if (e.preFillWithDateTime && e.type === "text") {
39
+ const n = J();
40
+ t[e.name] = n;
39
41
  } else
40
- e[t.name] = t.defaultValue || "";
41
- }), y(e), g([]);
42
+ t[e.name] = e.defaultValue || M[e.name] || "";
43
+ }), b(t), f([]);
42
44
  }
43
- function N() {
44
- const e = [];
45
- return o == null || o.forEach((t) => {
46
- const { name: n, label: r, type: a, validation: s, required: i } = t, m = p[n], l = n;
45
+ function I() {
46
+ const t = [];
47
+ return i == null || i.forEach((e) => {
48
+ const { name: n, label: r, type: p, validation: s, required: a } = e, o = l[n], m = n;
47
49
  if (s)
48
- if (a === "number") {
49
- const d = parseInt(m);
50
- s.min && d < s.min && e.push({
51
- field: l,
52
- value: m,
50
+ if (p === "number") {
51
+ const c = parseInt(o);
52
+ s.min && c < s.min && t.push({
53
+ field: m,
54
+ value: o,
53
55
  message: s.invalid_message
54
- }), s.max && d > s.max && e.push({
55
- field: l,
56
- value: m,
56
+ }), s.max && c > s.max && t.push({
57
+ field: m,
58
+ value: o,
57
59
  message: s.invalid_message
58
- }), isNaN(d) && e.push({
59
- field: l,
60
- value: m,
60
+ }), isNaN(c) && t.push({
61
+ field: m,
62
+ value: o,
61
63
  message: "Invalid number"
62
64
  });
63
65
  } else
64
- a === "text" && (s.min_length && m.length < s.min_length && e.push({
65
- field: l,
66
- value: m,
66
+ p === "text" && (s.min_length && o.length < s.min_length && t.push({
67
+ field: m,
68
+ value: o,
67
69
  message: s.invalid_message
68
- }), s.max_length && m.length > s.max_length && e.push({
69
- field: l,
70
- value: m,
70
+ }), s.max_length && o.length > s.max_length && t.push({
71
+ field: m,
72
+ value: o,
71
73
  message: s.invalid_message
72
- }), s.pattern && !new RegExp(s.pattern).test(m) && e.push({
73
- field: l,
74
- value: m,
74
+ }), s.pattern && !new RegExp(s.pattern).test(o) && t.push({
75
+ field: m,
76
+ value: o,
75
77
  message: s.invalid_message
76
78
  }));
77
- i && !m && e.push({
78
- field: l,
79
- value: m,
79
+ a && !o && t.push({
80
+ field: m,
81
+ value: o,
80
82
  message: `${r} is required`
81
83
  });
82
- }), g(e), e.length && (c == null || c(e)), !e.length;
84
+ }), f(t), t.length && (h == null || h(t)), !t.length;
83
85
  }
84
- const k = H(
85
- (e) => {
86
- let t = {};
87
- return e == null || e.forEach((n) => {
88
- const { name: r, type: a, submitDataKey: s } = n;
89
- if (s) {
90
- const i = R(
91
- s,
92
- a,
93
- p[r]
94
- );
95
- t = z(t, i);
96
- } else
97
- t[r] = a === "number" ? parseInt(p[r]) : p[r];
98
- }), t;
86
+ const W = R(
87
+ (t) => {
88
+ let e = {};
89
+ return t == null || t.forEach((n) => {
90
+ const { name: r, type: p, submitDataKey: s } = n, a = p === "number" ? parseInt(l[r]) : l[r];
91
+ function o(m) {
92
+ if (m.indexOf(".") !== -1) {
93
+ const c = Q(
94
+ m,
95
+ p,
96
+ l[r]
97
+ );
98
+ e = U(e, c);
99
+ } else
100
+ e[m] = a;
101
+ }
102
+ typeof s != "string" && (s != null && s.length) ? s.forEach((m) => {
103
+ o(m);
104
+ }) : typeof s == "string" && s ? o(s) : e[r] = a;
105
+ }), e;
99
106
  },
100
- [p]
107
+ [l]
101
108
  );
102
- function I(e) {
103
- if (e.preventDefault(), N()) {
104
- const n = k(o);
109
+ function q(t) {
110
+ if (t.preventDefault(), I()) {
111
+ const n = W(i);
105
112
  _(n);
106
113
  }
107
114
  }
108
- function W() {
109
- F(), E();
115
+ function P() {
116
+ F(), O();
110
117
  }
111
- function q(e) {
112
- const t = B.find(
113
- (r) => r.field === e.name
118
+ function $(t) {
119
+ const e = k.find(
120
+ (r) => r.field === t.name
114
121
  ), n = {
115
- ...e,
116
- value: p[e.name],
117
- handleChange: M,
118
- error: !!t,
119
- helperText: t == null ? void 0 : t.message
122
+ ...t,
123
+ value: l[t.name],
124
+ handleChange: D,
125
+ error: !!e,
126
+ helperText: e == null ? void 0 : e.message,
127
+ inputAdornments: N[t.name] || {}
120
128
  };
121
- if (e.hidden)
129
+ if (t.hidden)
122
130
  return null;
123
- if (e.type === "custom" && e.customComponent && x[e.customComponent]) {
124
- const { component: r, props: a } = x[e.customComponent], s = r, i = {
131
+ if (t.type === "custom" && t.customComponent && y[t.customComponent]) {
132
+ const { component: r, props: p } = y[t.customComponent], s = r, a = {
125
133
  ...n,
126
- ...a
134
+ ...p
127
135
  };
128
- if (s && i)
129
- return /* @__PURE__ */ u(s, { ...i }, e.name);
136
+ if (s && a)
137
+ return /* @__PURE__ */ u(s, { ...a }, t.name);
130
138
  } else
131
- return /* @__PURE__ */ u(J, { ...n }, e.name);
139
+ return /* @__PURE__ */ u(X, { ...n }, t.name);
132
140
  }
133
- function P() {
134
- return o.reduce(
135
- (t, n) => {
141
+ function w() {
142
+ return i.reduce(
143
+ (e, n) => {
136
144
  const { groupName: r } = n;
137
- if (!t.length)
138
- t.push(r ? [r, n] : [n]);
145
+ if (!e.length)
146
+ e.push(r ? [r, n] : [n]);
139
147
  else if (r) {
140
- const s = t.findIndex((i) => i[0] === r);
141
- s === -1 ? t.push([r, n]) : t[s].push(n);
148
+ const s = e.findIndex((a) => a[0] === r);
149
+ s === -1 ? e.push([r, n]) : e[s].push(n);
142
150
  } else {
143
- const s = t[t.length - 1];
144
- typeof s[0] == "string" ? t.push([n]) : s.push(n);
151
+ const s = e[e.length - 1];
152
+ typeof s[0] == "string" ? e.push([n]) : s.push(n);
145
153
  }
146
- return t;
154
+ return e;
147
155
  },
148
156
  []
149
157
  ).map(
150
- (t) => {
151
- const n = typeof t[0] == "string";
158
+ (e) => {
159
+ const n = typeof e[0] == "string";
152
160
  return /* @__PURE__ */ u(
153
- U,
161
+ Z,
154
162
  {
155
- children: t.map((r) => typeof r == "string" ? /* @__PURE__ */ u(
156
- L,
163
+ children: e.map((r) => typeof r == "string" ? /* @__PURE__ */ u(
164
+ G,
157
165
  {
158
166
  type: "headingSmall",
159
- sx: f.heading,
167
+ sx: d.heading,
160
168
  children: r
161
169
  },
162
170
  r
163
- ) : q(r))
171
+ ) : $(r))
164
172
  },
165
- `group-${n ? t[0] : t[0].name}`
173
+ `group-${n ? e[0] : e[0].name}`
166
174
  );
167
175
  }
168
176
  );
169
177
  }
170
- K(() => {
178
+ z(() => {
171
179
  F();
172
180
  }, []);
173
- const $ = {
174
- ...f.alignVertical,
175
- ...O
176
- }, w = {
177
- ...f.alignVertical,
181
+ const H = {
182
+ ...d.alignVertical,
183
+ ...A
184
+ }, L = {
185
+ ...d.alignVertical,
178
186
  marginTop: "1rem",
179
187
  gap: "0.5rem",
180
- ...D
188
+ ...B
181
189
  };
182
- return /* @__PURE__ */ u(b, { sx: T, children: /* @__PURE__ */ j("form", { style: $, children: [
183
- /* @__PURE__ */ u(b, { sx: A, children: Object.keys(p).length && P() }),
184
- /* @__PURE__ */ j(b, { sx: w, children: [
185
- /* @__PURE__ */ u(S, { type: "submit", onClick: I, children: V }),
186
- /* @__PURE__ */ u(S, { onClick: W, children: C })
190
+ return /* @__PURE__ */ u(x, { sx: C, children: /* @__PURE__ */ v("form", { style: H, children: [
191
+ /* @__PURE__ */ u(x, { sx: T, children: Object.keys(l).length && w() }),
192
+ /* @__PURE__ */ v(x, { sx: L, children: [
193
+ /* @__PURE__ */ u(j, { type: "submit", onClick: q, children: V }),
194
+ /* @__PURE__ */ u(j, { onClick: P, children: E })
187
195
  ] })
188
196
  ] }) });
189
197
  };
190
198
  export {
191
- oe as default
199
+ ie as default
192
200
  };
@@ -1,6 +1,6 @@
1
1
  import "react/jsx-runtime";
2
- import { Z as p } from "../../../ZoomControllers-36e39bb0.js";
3
- import "../../../Tooltip-b926c320.js";
2
+ import { Z as p } from "../../../ZoomControllers-d04c25f8.js";
3
+ import "../../../Tooltip-e797a425.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-36e39bb0.js";
4
- import { B as m } from "../../../Tooltip-b926c320.js";
3
+ import { T as C, Z as S, a as W } from "../../../ZoomControllers-d04c25f8.js";
4
+ import { B as m } from "../../../Tooltip-e797a425.js";
5
5
  const D = {
6
6
  position: "relative",
7
7
  borderRadius: "1rem",
@@ -1,13 +1,13 @@
1
- import { P as ce, a as fa, C as pb, c as vb, j as hb, _ as x0, k as mb } from "./createTheme-a4db2989.js";
2
- import { c as lT } from "./styled-126c6a62.js";
3
- import { s as y0, c as g0, b as yb, u as Lm, a as gb, _ as Sb, T as gT } from "./TransitionGroupContext-fe9a562f.js";
1
+ import { P as ce, a as fa, C as pb, c as vb, p as hb, _ as x0, q as mb } from "./createTheme-759a022d.js";
2
+ import { c as lT } from "./styled-78608e1f.js";
3
+ import { s as y0, c as g0, b as yb, u as Lm, a as gb, _ as Sb, T as gT } from "./TransitionGroupContext-0e899f4c.js";
4
4
  import * as Vt from "react";
5
5
  import rf from "react";
6
6
  import { jsx as S0 } from "react/jsx-runtime";
7
- import { e as Eb } from "./exactProp-d79ccada.js";
8
- import { u as Cb } from "./useTheme-573c40a2.js";
7
+ import { e as Eb } from "./exactProp-23d6a154.js";
8
+ import { u as Cb } from "./useTheme-8906bd79.js";
9
9
  import { c as ST } from "./chainPropTypes-004bf492.js";
10
- import { c as Tb } from "./createSvgIcon-58aa3adf.js";
10
+ import { c as Tb } from "./createSvgIcon-5aac746d.js";
11
11
  import { u as Rb } from "./unsupportedProp-3dbf01f6.js";
12
12
  function xb(O) {
13
13
  const {
@@ -20385,21 +20385,21 @@ export {
20385
20385
  Db as H,
20386
20386
  T0 as P,
20387
20387
  Yb as T,
20388
- Ob as a,
20389
- Wb as b,
20388
+ zb as a,
20389
+ Ob as b,
20390
20390
  kb as c,
20391
- bb as d,
20391
+ Wb as d,
20392
20392
  wb as e,
20393
- wT as f,
20394
- Ib as g,
20395
- Qb as h,
20393
+ bb as f,
20394
+ wT as g,
20395
+ Ib as h,
20396
20396
  y_ as i,
20397
- hT as j,
20398
- Nb as k,
20399
- Ub as l,
20400
- zb as m,
20397
+ Qb as j,
20398
+ hT as k,
20399
+ h_ as l,
20400
+ Nb as m,
20401
20401
  Gb as n,
20402
20402
  TT as o,
20403
20403
  g_ as r,
20404
- h_ as u
20404
+ Ub as u
20405
20405
  };
@@ -1,7 +1,7 @@
1
- import { g as b, c as h, _ as w, a as y, P as o } from "./createTheme-a4db2989.js";
1
+ import { g as b, c as h, _ as w, a as y, P as o } from "./createTheme-759a022d.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, s as N, a as R, c as O, b as B } from "./styled-126c6a62.js";
4
+ import { g as T, s as N, a as R, c as O, b as B } from "./styled-78608e1f.js";
5
5
  function j(e) {
6
6
  return b("MuiSvgIcon", e);
7
7
  }