@loopr-ai/craft 0.8.0 → 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.
@@ -8,7 +8,7 @@ interface FormProps {
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;
@@ -1,48 +1,48 @@
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";
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
4
  import { T as G } from "../../../index-c9c32237.js";
5
- import d from "./Form.styles.js";
5
+ import y from "./Form.styles.js";
6
6
  import { getLocalDateTime as J, createNestedObject as Q, deepMergeObjects as U } from "./Form.utils.js";
7
7
  import X from "./FormInput.js";
8
8
  import { s as Y } from "../../../styled-78608e1f.js";
9
- import { B as x } from "../../../Tooltip-e797a425.js";
9
+ import { B as b } from "../../../Tooltip-e797a425.js";
10
10
  const Z = Y("div")({
11
11
  marginTop: "0.75rem"
12
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,
19
- onChange: g,
20
- formStyles: A = {},
21
- formWrapperStyles: C = {},
22
- formFieldsWrapperStyles: T = {},
23
- buttonWrapperStyles: B = {},
24
- customFields: y = {},
25
- preFillValues: M = {},
17
+ cancelText: A = "Cancel",
18
+ handleCancel: g,
19
+ onChange: f,
20
+ formStyles: T = {},
21
+ formWrapperStyles: B = {},
22
+ formFieldsWrapperStyles: k = {},
23
+ buttonWrapperStyles: M = {},
24
+ customFields: F = {},
25
+ preFillValues: S = {},
26
26
  formAdornments: N = {}
27
27
  }) => {
28
- const [l, b] = S({}), [k, f] = S([]);
28
+ const [l, x] = v({}), [C, d] = v([]);
29
29
  function D(t, e) {
30
- b((n) => ({
30
+ x((n) => ({
31
31
  ...n,
32
32
  [t]: e
33
- })), g == null || g(t, e), f([]);
33
+ })), f == null || f(t, e), d([]);
34
34
  }
35
- function F() {
35
+ const I = E(() => {
36
36
  const t = {};
37
37
  i == null || i.forEach((e) => {
38
38
  if (e.preFillWithDateTime && e.type === "text") {
39
39
  const n = J();
40
40
  t[e.name] = n;
41
41
  } else
42
- t[e.name] = e.defaultValue || M[e.name] || "";
43
- }), b(t), f([]);
44
- }
45
- function I() {
42
+ t[e.name] = e.defaultValue || S[e.name] || "";
43
+ }), x(t), d([]);
44
+ }, [S]);
45
+ function W() {
46
46
  const t = [];
47
47
  return i == null || i.forEach((e) => {
48
48
  const { name: n, label: r, type: p, validation: s, required: a } = e, o = l[n], m = n;
@@ -81,9 +81,9 @@ const Z = Y("div")({
81
81
  value: o,
82
82
  message: `${r} is required`
83
83
  });
84
- }), f(t), t.length && (h == null || h(t)), !t.length;
84
+ }), d(t), t.length && (h == null || h(t)), !t.length;
85
85
  }
86
- const W = R(
86
+ const q = E(
87
87
  (t) => {
88
88
  let e = {};
89
89
  return t == null || t.forEach((n) => {
@@ -106,17 +106,22 @@ const Z = Y("div")({
106
106
  },
107
107
  [l]
108
108
  );
109
- function q(t) {
110
- if (t.preventDefault(), I()) {
111
- const n = W(i);
112
- _(n);
109
+ function w(t) {
110
+ if (t.preventDefault(), W()) {
111
+ const n = q(i);
112
+ V(n);
113
113
  }
114
114
  }
115
115
  function P() {
116
- F(), O();
116
+ x((t) => {
117
+ const e = { ...t };
118
+ return Object.keys(e).forEach((n) => {
119
+ e[n] = "";
120
+ }), e;
121
+ }), g == null || g();
117
122
  }
118
123
  function $(t) {
119
- const e = k.find(
124
+ const e = C.find(
120
125
  (r) => r.field === t.name
121
126
  ), n = {
122
127
  ...t,
@@ -128,8 +133,8 @@ const Z = Y("div")({
128
133
  };
129
134
  if (t.hidden)
130
135
  return null;
131
- if (t.type === "custom" && t.customComponent && y[t.customComponent]) {
132
- 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 = {
133
138
  ...n,
134
139
  ...p
135
140
  };
@@ -138,7 +143,7 @@ const Z = Y("div")({
138
143
  } else
139
144
  return /* @__PURE__ */ u(X, { ...n }, t.name);
140
145
  }
141
- function w() {
146
+ function H() {
142
147
  return i.reduce(
143
148
  (e, n) => {
144
149
  const { groupName: r } = n;
@@ -164,7 +169,7 @@ const Z = Y("div")({
164
169
  G,
165
170
  {
166
171
  type: "headingSmall",
167
- sx: d.heading,
172
+ sx: y.heading,
168
173
  children: r
169
174
  },
170
175
  r
@@ -176,22 +181,22 @@ const Z = Y("div")({
176
181
  );
177
182
  }
178
183
  z(() => {
179
- F();
184
+ I();
180
185
  }, []);
181
- const H = {
182
- ...d.alignVertical,
183
- ...A
184
- }, L = {
185
- ...d.alignVertical,
186
+ const L = {
187
+ ...y.alignVertical,
188
+ ...T
189
+ }, R = {
190
+ ...y.alignVertical,
186
191
  marginTop: "1rem",
187
192
  gap: "0.5rem",
188
- ...B
193
+ ...M
189
194
  };
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 })
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 })
195
200
  ] })
196
201
  ] }) });
197
202
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loopr-ai/craft",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
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": {