@loopr-ai/craft 0.7.3 → 0.7.4

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.
@@ -427,7 +427,7 @@ const Xe = ({
427
427
  };
428
428
  const te = {
429
429
  "& .MuiSelect-select > span::before": {
430
- content: `'${d}'`,
430
+ content: `'${d || ""}'`,
431
431
  color: u ? "rgba(254, 64, 76, 0.4)" : "rgba(153, 153, 153, 0.6)"
432
432
  }
433
433
  };
@@ -11,6 +11,8 @@ interface FormProps {
11
11
  handleCancel: () => void;
12
12
  onChange?: (key: string, value: string) => void;
13
13
  customFields?: CustomFields;
14
+ formWrapperStyles?: SxProps;
15
+ formFieldsWrapperStyles?: SxProps;
14
16
  formStyles?: React.CSSProperties;
15
17
  buttonWrapperStyles?: SxProps;
16
18
  }
@@ -1,134 +1,136 @@
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")({
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")({
11
11
  marginTop: "0.75rem"
12
- }), re = ({
12
+ }), oe = ({
13
13
  config: o,
14
- submitText: S = "Submit",
15
- handleSubmit: V,
14
+ submitText: V = "Submit",
15
+ handleSubmit: _,
16
16
  handleInvalidData: c,
17
- cancelText: _ = "Cancel",
18
- handleCancel: C,
17
+ cancelText: C = "Cancel",
18
+ handleCancel: E,
19
19
  onChange: h,
20
- formStyles: E = {},
21
- buttonWrapperStyles: O = {},
22
- customFields: b = {}
20
+ formStyles: O = {},
21
+ formWrapperStyles: T = {},
22
+ formFieldsWrapperStyles: A = {},
23
+ buttonWrapperStyles: D = {},
24
+ customFields: x = {}
23
25
  }) => {
24
- const [u, y] = j({}), [T, g] = j([]);
25
- function A(e, t) {
26
+ const [p, y] = v({}), [B, g] = v([]);
27
+ function M(e, t) {
26
28
  y((n) => ({
27
29
  ...n,
28
30
  [e]: t
29
31
  })), h == null || h(e, t), g([]);
30
32
  }
31
- function x() {
33
+ function F() {
32
34
  const e = {};
33
35
  o == null || o.forEach((t) => {
34
36
  if (t.preFillWithDateTime && t.type === "text") {
35
- const n = L();
37
+ const n = G();
36
38
  e[t.name] = n;
37
39
  } else
38
40
  e[t.name] = t.defaultValue || "";
39
41
  }), y(e), g([]);
40
42
  }
41
- function D() {
43
+ function N() {
42
44
  const e = [];
43
45
  return o == null || o.forEach((t) => {
44
- const { name: n, label: r, type: a, validation: s, required: i } = t, m = u[n], p = n;
46
+ const { name: n, label: r, type: a, validation: s, required: i } = t, m = p[n], l = n;
45
47
  if (s)
46
48
  if (a === "number") {
47
- const f = parseInt(m);
48
- s.min && f < s.min && e.push({
49
- field: p,
49
+ const d = parseInt(m);
50
+ s.min && d < s.min && e.push({
51
+ field: l,
50
52
  value: m,
51
53
  message: s.invalid_message
52
- }), s.max && f > s.max && e.push({
53
- field: p,
54
+ }), s.max && d > s.max && e.push({
55
+ field: l,
54
56
  value: m,
55
57
  message: s.invalid_message
56
- }), isNaN(f) && e.push({
57
- field: p,
58
+ }), isNaN(d) && e.push({
59
+ field: l,
58
60
  value: m,
59
61
  message: "Invalid number"
60
62
  });
61
63
  } else
62
64
  a === "text" && (s.min_length && m.length < s.min_length && e.push({
63
- field: p,
65
+ field: l,
64
66
  value: m,
65
67
  message: s.invalid_message
66
68
  }), s.max_length && m.length > s.max_length && e.push({
67
- field: p,
69
+ field: l,
68
70
  value: m,
69
71
  message: s.invalid_message
70
72
  }), s.pattern && !new RegExp(s.pattern).test(m) && e.push({
71
- field: p,
73
+ field: l,
72
74
  value: m,
73
75
  message: s.invalid_message
74
76
  }));
75
77
  i && !m && e.push({
76
- field: p,
78
+ field: l,
77
79
  value: m,
78
80
  message: `${r} is required`
79
81
  });
80
82
  }), g(e), e.length && (c == null || c(e)), !e.length;
81
83
  }
82
- const B = P(
84
+ const k = H(
83
85
  (e) => {
84
86
  let t = {};
85
87
  return e == null || e.forEach((n) => {
86
88
  const { name: r, type: a, submitDataKey: s } = n;
87
89
  if (s) {
88
- const i = H(
90
+ const i = R(
89
91
  s,
90
92
  a,
91
- u[r]
93
+ p[r]
92
94
  );
93
- t = K(t, i);
95
+ t = z(t, i);
94
96
  } else
95
- t[r] = a === "number" ? parseInt(u[r]) : u[r];
97
+ t[r] = a === "number" ? parseInt(p[r]) : p[r];
96
98
  }), t;
97
99
  },
98
- [u]
100
+ [p]
99
101
  );
100
- function M(e) {
101
- if (e.preventDefault(), D()) {
102
- const n = B(o);
103
- V(n);
102
+ function I(e) {
103
+ if (e.preventDefault(), N()) {
104
+ const n = k(o);
105
+ _(n);
104
106
  }
105
107
  }
106
- function N() {
107
- x(), C();
108
+ function W() {
109
+ F(), E();
108
110
  }
109
- function k(e) {
110
- const t = T.find(
111
+ function q(e) {
112
+ const t = B.find(
111
113
  (r) => r.field === e.name
112
114
  ), n = {
113
115
  ...e,
114
- value: u[e.name],
115
- handleChange: A,
116
+ value: p[e.name],
117
+ handleChange: M,
116
118
  error: !!t,
117
119
  helperText: t == null ? void 0 : t.message
118
120
  };
119
121
  if (e.hidden)
120
122
  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
+ if (e.type === "custom" && e.customComponent && x[e.customComponent]) {
124
+ const { component: r, props: a } = x[e.customComponent], s = r, i = {
123
125
  ...n,
124
126
  ...a
125
127
  };
126
128
  if (s && i)
127
- return /* @__PURE__ */ l(s, { ...i }, e.name);
129
+ return /* @__PURE__ */ u(s, { ...i }, e.name);
128
130
  } else
129
- return /* @__PURE__ */ l(R, { ...n }, e.name);
131
+ return /* @__PURE__ */ u(J, { ...n }, e.name);
130
132
  }
131
- function I() {
133
+ function P() {
132
134
  return o.reduce(
133
135
  (t, n) => {
134
136
  const { groupName: r } = n;
@@ -147,44 +149,44 @@ const J = z("div")({
147
149
  ).map(
148
150
  (t) => {
149
151
  const n = typeof t[0] == "string";
150
- return /* @__PURE__ */ l(
151
- J,
152
+ return /* @__PURE__ */ u(
153
+ U,
152
154
  {
153
- children: t.map((r) => typeof r == "string" ? /* @__PURE__ */ l(
154
- w,
155
+ children: t.map((r) => typeof r == "string" ? /* @__PURE__ */ u(
156
+ L,
155
157
  {
156
158
  type: "headingSmall",
157
- sx: d.heading,
159
+ sx: f.heading,
158
160
  children: r
159
161
  },
160
162
  r
161
- ) : k(r))
163
+ ) : q(r))
162
164
  },
163
165
  `group-${n ? t[0] : t[0].name}`
164
166
  );
165
167
  }
166
168
  );
167
169
  }
168
- $(() => {
169
- x();
170
+ K(() => {
171
+ F();
170
172
  }, []);
171
- const W = {
172
- ...d.alignVertical,
173
- ...E
174
- }, q = {
175
- ...d.alignVertical,
173
+ const $ = {
174
+ ...f.alignVertical,
175
+ ...O
176
+ }, w = {
177
+ ...f.alignVertical,
176
178
  marginTop: "1rem",
177
179
  gap: "0.5rem",
178
- ...O
180
+ ...D
179
181
  };
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: _ })
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 })
185
187
  ] })
186
- ] });
188
+ ] }) });
187
189
  };
188
190
  export {
189
- re as default
191
+ oe as default
190
192
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loopr-ai/craft",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "description": "Component library based out of Material UI customized to support Loopr AI products",
5
5
  "homepage": "https://loopr.ai",
6
6
  "author": {