@loopr-ai/craft 0.7.6 → 0.8.1

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 +11 -3
  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 +4 -2
  18. package/dist/components/organ/Form/index.js +74 -66
  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,20 +1,22 @@
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;
8
8
  handleSubmit: (data: any) => void;
9
9
  handleInvalidData?: (data: Array<InvalidData>) => void;
10
10
  cancelText?: string;
11
- handleCancel: () => void;
11
+ handleCancel?: () => void;
12
12
  onChange?: (key: string, value: string) => void;
13
13
  customFields?: CustomFields;
14
14
  formWrapperStyles?: SxProps;
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,46 +1,48 @@
1
- import { jsx as u, jsxs as v } from "react/jsx-runtime";
2
- import { useState as S, useCallback as H, useEffect as L } from "react";
3
- import j from "../../cell/Button/index.js";
4
- import { T as R } from "../../../index-03287c17.js";
5
- import d from "./Form.styles.js";
6
- import { getLocalDateTime as z, createNestedObject as G, deepMergeObjects as J } from "./Form.utils.js";
7
- import Q from "./FormInput.js";
8
- import { s as U } from "../../../styled-126c6a62.js";
9
- import { B as x } from "../../../Tooltip-b926c320.js";
10
- const X = U("div")({
1
+ import { jsx as u, jsxs as j } from "react/jsx-runtime";
2
+ import { useState as v, useCallback as E, useEffect as z } from "react";
3
+ import O from "../../cell/Button/index.js";
4
+ import { T as G } from "../../../index-c9c32237.js";
5
+ import y 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 b } from "../../../Tooltip-e797a425.js";
10
+ const Z = Y("div")({
11
11
  marginTop: "0.75rem"
12
- }), me = ({
12
+ }), ie = ({
13
13
  config: i,
14
- submitText: V = "Submit",
15
- handleSubmit: _,
14
+ submitText: _ = "Submit",
15
+ handleSubmit: V,
16
16
  handleInvalidData: h,
17
- cancelText: E = "Cancel",
18
- handleCancel: O,
17
+ cancelText: A = "Cancel",
18
+ handleCancel: g,
19
19
  onChange: f,
20
- formStyles: C = {},
21
- formWrapperStyles: T = {},
22
- formFieldsWrapperStyles: A = {},
23
- buttonWrapperStyles: B = {},
24
- customFields: y = {}
20
+ formStyles: T = {},
21
+ formWrapperStyles: B = {},
22
+ formFieldsWrapperStyles: k = {},
23
+ buttonWrapperStyles: M = {},
24
+ customFields: F = {},
25
+ preFillValues: S = {},
26
+ formAdornments: N = {}
25
27
  }) => {
26
- const [l, b] = S({}), [M, g] = S([]);
27
- function N(t, e) {
28
- b((n) => ({
28
+ const [l, x] = v({}), [C, d] = v([]);
29
+ function D(t, e) {
30
+ x((n) => ({
29
31
  ...n,
30
32
  [t]: e
31
- })), f == null || f(t, e), g([]);
33
+ })), f == null || f(t, e), d([]);
32
34
  }
33
- function F() {
35
+ const I = E(() => {
34
36
  const t = {};
35
37
  i == null || i.forEach((e) => {
36
38
  if (e.preFillWithDateTime && e.type === "text") {
37
- const n = z();
39
+ const n = J();
38
40
  t[e.name] = n;
39
41
  } else
40
- t[e.name] = e.defaultValue || "";
41
- }), b(t), g([]);
42
- }
43
- function k() {
42
+ t[e.name] = e.defaultValue || S[e.name] || "";
43
+ }), x(t), d([]);
44
+ }, [S]);
45
+ function W() {
44
46
  const t = [];
45
47
  return i == null || i.forEach((e) => {
46
48
  const { name: n, label: r, type: p, validation: s, required: a } = e, o = l[n], m = n;
@@ -79,21 +81,21 @@ const X = U("div")({
79
81
  value: o,
80
82
  message: `${r} is required`
81
83
  });
82
- }), g(t), t.length && (h == null || h(t)), !t.length;
84
+ }), d(t), t.length && (h == null || h(t)), !t.length;
83
85
  }
84
- const D = H(
86
+ const q = E(
85
87
  (t) => {
86
88
  let e = {};
87
89
  return t == null || t.forEach((n) => {
88
90
  const { name: r, type: p, submitDataKey: s } = n, a = p === "number" ? parseInt(l[r]) : l[r];
89
91
  function o(m) {
90
92
  if (m.indexOf(".") !== -1) {
91
- const c = G(
93
+ const c = Q(
92
94
  m,
93
95
  p,
94
96
  l[r]
95
97
  );
96
- e = J(e, c);
98
+ e = U(e, c);
97
99
  } else
98
100
  e[m] = a;
99
101
  }
@@ -104,38 +106,44 @@ const X = U("div")({
104
106
  },
105
107
  [l]
106
108
  );
107
- function I(t) {
108
- if (t.preventDefault(), k()) {
109
- const n = D(i);
110
- _(n);
109
+ function w(t) {
110
+ if (t.preventDefault(), W()) {
111
+ const n = q(i);
112
+ V(n);
111
113
  }
112
114
  }
113
- function W() {
114
- F(), O();
115
+ function P() {
116
+ x((t) => {
117
+ const e = { ...t };
118
+ return Object.keys(e).forEach((n) => {
119
+ e[n] = "";
120
+ }), e;
121
+ }), g == null || g();
115
122
  }
116
- function q(t) {
117
- const e = M.find(
123
+ function $(t) {
124
+ const e = C.find(
118
125
  (r) => r.field === t.name
119
126
  ), n = {
120
127
  ...t,
121
128
  value: l[t.name],
122
- handleChange: N,
129
+ handleChange: D,
123
130
  error: !!e,
124
- helperText: e == null ? void 0 : e.message
131
+ helperText: e == null ? void 0 : e.message,
132
+ inputAdornments: N[t.name] || {}
125
133
  };
126
134
  if (t.hidden)
127
135
  return null;
128
- if (t.type === "custom" && t.customComponent && y[t.customComponent]) {
129
- const { component: r, props: p } = y[t.customComponent], s = r, a = {
136
+ if (t.type === "custom" && t.customComponent && F[t.customComponent]) {
137
+ const { component: r, props: p } = F[t.customComponent], s = r, a = {
130
138
  ...n,
131
139
  ...p
132
140
  };
133
141
  if (s && a)
134
142
  return /* @__PURE__ */ u(s, { ...a }, t.name);
135
143
  } else
136
- return /* @__PURE__ */ u(Q, { ...n }, t.name);
144
+ return /* @__PURE__ */ u(X, { ...n }, t.name);
137
145
  }
138
- function P() {
146
+ function H() {
139
147
  return i.reduce(
140
148
  (e, n) => {
141
149
  const { groupName: r } = n;
@@ -155,43 +163,43 @@ const X = U("div")({
155
163
  (e) => {
156
164
  const n = typeof e[0] == "string";
157
165
  return /* @__PURE__ */ u(
158
- X,
166
+ Z,
159
167
  {
160
168
  children: e.map((r) => typeof r == "string" ? /* @__PURE__ */ u(
161
- R,
169
+ G,
162
170
  {
163
171
  type: "headingSmall",
164
- sx: d.heading,
172
+ sx: y.heading,
165
173
  children: r
166
174
  },
167
175
  r
168
- ) : q(r))
176
+ ) : $(r))
169
177
  },
170
178
  `group-${n ? e[0] : e[0].name}`
171
179
  );
172
180
  }
173
181
  );
174
182
  }
175
- L(() => {
176
- F();
183
+ z(() => {
184
+ I();
177
185
  }, []);
178
- const $ = {
179
- ...d.alignVertical,
180
- ...C
181
- }, w = {
182
- ...d.alignVertical,
186
+ const L = {
187
+ ...y.alignVertical,
188
+ ...T
189
+ }, R = {
190
+ ...y.alignVertical,
183
191
  marginTop: "1rem",
184
192
  gap: "0.5rem",
185
- ...B
193
+ ...M
186
194
  };
187
- return /* @__PURE__ */ u(x, { sx: T, children: /* @__PURE__ */ v("form", { style: $, children: [
188
- /* @__PURE__ */ u(x, { sx: A, children: Object.keys(l).length && P() }),
189
- /* @__PURE__ */ v(x, { sx: w, children: [
190
- /* @__PURE__ */ u(j, { type: "submit", onClick: I, children: V }),
191
- /* @__PURE__ */ u(j, { onClick: W, children: E })
195
+ return /* @__PURE__ */ u(b, { sx: B, children: /* @__PURE__ */ j("form", { style: L, children: [
196
+ /* @__PURE__ */ u(b, { sx: k, children: Object.keys(l).length && H() }),
197
+ /* @__PURE__ */ j(b, { sx: R, children: [
198
+ /* @__PURE__ */ u(O, { type: "submit", onClick: w, children: _ }),
199
+ /* @__PURE__ */ u(O, { onClick: P, children: A })
192
200
  ] })
193
201
  ] }) });
194
202
  };
195
203
  export {
196
- me as default
204
+ ie as default
197
205
  };
@@ -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
  }