@loopr-ai/craft 0.9.0 → 0.10.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.
@@ -4,6 +4,7 @@ export interface FormInputProps extends SelectField {
4
4
  value: string;
5
5
  handleChange: (name: string, value: string) => void;
6
6
  error?: boolean;
7
+ authHeader?: string;
7
8
  }
8
9
  /**
9
10
  * Form input field
@@ -1,7 +1,7 @@
1
1
  import { jsx as c } from "react/jsx-runtime";
2
- import j from "./RadioInput/index.js";
3
- import C from "./TextfieldInput/index.js";
4
- const v = ({
2
+ import C from "./RadioInput/index.js";
3
+ import F from "./TextfieldInput/index.js";
4
+ const w = ({
5
5
  name: t,
6
6
  label: u,
7
7
  type: o,
@@ -16,13 +16,14 @@ const v = ({
16
16
  error: i,
17
17
  helperText: m,
18
18
  autofocus: x,
19
- inputAdornments: a
19
+ inputAdornments: a,
20
+ authHeader: h
20
21
  }) => {
21
- function I(h) {
22
- d(t, h.target.value);
22
+ function I(j) {
23
+ d(t, j.target.value);
23
24
  }
24
25
  return o === "custom" ? null : o === "radio" ? /* @__PURE__ */ c(
25
- j,
26
+ C,
26
27
  {
27
28
  name: t,
28
29
  label: u,
@@ -35,7 +36,7 @@ const v = ({
35
36
  inputAdornments: a
36
37
  }
37
38
  ) : /* @__PURE__ */ c(
38
- C,
39
+ F,
39
40
  {
40
41
  name: t,
41
42
  label: u,
@@ -51,10 +52,11 @@ const v = ({
51
52
  error: i,
52
53
  helperText: m,
53
54
  inputAdornments: a,
54
- autofocus: x
55
+ autofocus: x,
56
+ authHeader: h
55
57
  }
56
58
  );
57
59
  };
58
60
  export {
59
- v as default
61
+ w as default
60
62
  };
@@ -18,6 +18,7 @@ interface TextfieldInputProps {
18
18
  helperText?: string;
19
19
  inputAdornments?: InputAdornments;
20
20
  autofocus?: boolean;
21
+ authHeader?: string;
21
22
  }
22
23
  declare const TextfieldInput: CraftFC<TextfieldInputProps>;
23
24
  export default TextfieldInput;
@@ -1,32 +1,32 @@
1
- import ee, { jsx as d, jsxs as q } from "react/jsx-runtime";
2
- import { r as te, i as oe } from "../../../../createSvgIcon-59e7bc15.js";
3
- import * as $ from "react";
4
- import { useState as se, useMemo as V, useCallback as ne, useEffect as ae } from "react";
1
+ import te, { jsx as d, jsxs as q } from "react/jsx-runtime";
2
+ import { r as oe, i as se } from "../../../../createSvgIcon-59e7bc15.js";
3
+ import * as M from "react";
4
+ import { useState as ne, useMemo as V, useCallback as ae, useEffect as re } from "react";
5
5
  import { customColors as O } from "../../../../global/colors.js";
6
- import re from "../ErrorMessage/index.js";
7
- import ie from "../Form.styles.js";
8
- import le from "../Label/index.js";
9
- import N from "./TextfieldInput.styles.js";
10
- import { B as ce } from "../../../../Box-96e795c4.js";
11
- import { L as B, T as de } from "../../../../TextField-df89b641.js";
12
- import { g as W, a as I, _ as K, P as t, b as R, f as S } from "../../../../createTheme-d2329909.js";
13
- import { g as j, s as H, b as J, c as w, e as Q, r as pe } from "../../../../styled-8f7db30d.js";
14
- import { u as ue, F as me } from "../../../../useFormControl-b25c5813.js";
15
- import { M as fe } from "../../../../index-ae3eb123.js";
16
- import { B as be } from "../../../../ButtonBase-46c20f20.js";
6
+ import ie from "../ErrorMessage/index.js";
7
+ import le from "../Form.styles.js";
8
+ import ce from "../Label/index.js";
9
+ import P from "./TextfieldInput.styles.js";
10
+ import { B as de } from "../../../../Box-96e795c4.js";
11
+ import { L as B, T as pe } from "../../../../TextField-df89b641.js";
12
+ import { g as W, a as x, _ as K, P as t, b as R, f as N } from "../../../../createTheme-d2329909.js";
13
+ import { g as j, s as J, b as Q, c as w, e as X, r as ue } from "../../../../styled-8f7db30d.js";
14
+ import { u as me, F as fe } from "../../../../useFormControl-b25c5813.js";
15
+ import { M as be } from "../../../../index-ae3eb123.js";
16
+ import { B as ve } from "../../../../ButtonBase-46c20f20.js";
17
17
  import { d as k } from "../../../../dividerClasses-9354a5c9.js";
18
- import { c as ve, u as ge } from "../../../../TransitionGroupContext-21923db7.js";
19
- function ye(e) {
18
+ import { c as ge, u as ye } from "../../../../TransitionGroupContext-21923db7.js";
19
+ function Ie(e) {
20
20
  return W("MuiInputAdornment", e);
21
21
  }
22
- const Ie = j("MuiInputAdornment", ["root", "filled", "standard", "outlined", "positionStart", "positionEnd", "disablePointerEvents", "hiddenLabel", "sizeSmall"]), D = Ie;
22
+ const xe = j("MuiInputAdornment", ["root", "filled", "standard", "outlined", "positionStart", "positionEnd", "disablePointerEvents", "hiddenLabel", "sizeSmall"]), D = xe;
23
23
  var z;
24
- const xe = ["children", "className", "component", "disablePointerEvents", "disableTypography", "position", "variant"], Ce = (e, o) => {
24
+ const Ce = ["children", "className", "component", "disablePointerEvents", "disableTypography", "position", "variant"], $e = (e, o) => {
25
25
  const {
26
26
  ownerState: s
27
27
  } = e;
28
28
  return [o.root, o[`position${R(s.position)}`], s.disablePointerEvents === !0 && o.disablePointerEvents, o[s.variant]];
29
- }, $e = (e) => {
29
+ }, he = (e) => {
30
30
  const {
31
31
  classes: o,
32
32
  disablePointerEvents: s,
@@ -34,18 +34,18 @@ const xe = ["children", "className", "component", "disablePointerEvents", "disab
34
34
  position: r,
35
35
  size: l,
36
36
  variant: c
37
- } = e, g = {
37
+ } = e, y = {
38
38
  root: ["root", s && "disablePointerEvents", r && `position${R(r)}`, c, n && "hiddenLabel", l && `size${R(l)}`]
39
39
  };
40
- return Q(g, ye, o);
41
- }, he = H("div", {
40
+ return X(y, Ie, o);
41
+ }, Me = J("div", {
42
42
  name: "MuiInputAdornment",
43
43
  slot: "Root",
44
- overridesResolver: Ce
44
+ overridesResolver: $e
45
45
  })(({
46
46
  theme: e,
47
47
  ownerState: o
48
- }) => I({
48
+ }) => x({
49
49
  display: "flex",
50
50
  height: "0.01em",
51
51
  // Fix IE11 flexbox alignment. To remove at some point.
@@ -67,41 +67,41 @@ const xe = ["children", "className", "component", "disablePointerEvents", "disab
67
67
  }, o.disablePointerEvents === !0 && {
68
68
  // Styles applied to the root element if `disablePointerEvents={true}`.
69
69
  pointerEvents: "none"
70
- })), X = /* @__PURE__ */ $.forwardRef(function(o, s) {
71
- const n = J({
70
+ })), Y = /* @__PURE__ */ M.forwardRef(function(o, s) {
71
+ const n = Q({
72
72
  props: o,
73
73
  name: "MuiInputAdornment"
74
74
  }), {
75
75
  children: r,
76
76
  className: l,
77
77
  component: c = "div",
78
- disablePointerEvents: g = !1,
79
- disableTypography: m = !1,
80
- position: f,
81
- variant: v
82
- } = n, p = K(n, xe), b = ue() || {};
83
- let i = v;
84
- v && b.variant && process.env.NODE_ENV !== "production" && v === b.variant && console.error("MUI: The `InputAdornment` variant infers the variant prop you do not have to provide one."), b && !i && (i = b.variant);
85
- const x = I({}, n, {
86
- hiddenLabel: b.hiddenLabel,
87
- size: b.size,
88
- disablePointerEvents: g,
89
- position: f,
78
+ disablePointerEvents: y = !1,
79
+ disableTypography: u = !1,
80
+ position: m,
81
+ variant: g
82
+ } = n, p = K(n, Ce), f = me() || {};
83
+ let i = g;
84
+ g && f.variant && process.env.NODE_ENV !== "production" && g === f.variant && console.error("MUI: The `InputAdornment` variant infers the variant prop you do not have to provide one."), f && !i && (i = f.variant);
85
+ const C = x({}, n, {
86
+ hiddenLabel: f.hiddenLabel,
87
+ size: f.size,
88
+ disablePointerEvents: y,
89
+ position: m,
90
90
  variant: i
91
- }), u = $e(x);
92
- return /* @__PURE__ */ d(me.Provider, {
91
+ }), I = he(C);
92
+ return /* @__PURE__ */ d(fe.Provider, {
93
93
  value: null,
94
- children: /* @__PURE__ */ d(he, I({
94
+ children: /* @__PURE__ */ d(Me, x({
95
95
  as: c,
96
- ownerState: x,
97
- className: w(u.root, l),
96
+ ownerState: C,
97
+ className: w(I.root, l),
98
98
  ref: s
99
99
  }, p, {
100
- children: typeof r == "string" && !m ? /* @__PURE__ */ d(fe, {
100
+ children: typeof r == "string" && !u ? /* @__PURE__ */ d(be, {
101
101
  color: "text.secondary",
102
102
  children: r
103
- }) : /* @__PURE__ */ q($.Fragment, {
104
- children: [f === "start" ? (
103
+ }) : /* @__PURE__ */ q(M.Fragment, {
104
+ children: [m === "start" ? (
105
105
  /* notranslate needed while Google Translate will not fix zero-width space issue */
106
106
  z || (z = /* @__PURE__ */ d("span", {
107
107
  className: "notranslate",
@@ -112,7 +112,7 @@ const xe = ["children", "className", "component", "disablePointerEvents", "disab
112
112
  }))
113
113
  });
114
114
  });
115
- process.env.NODE_ENV !== "production" && (X.propTypes = {
115
+ process.env.NODE_ENV !== "production" && (Y.propTypes = {
116
116
  // ----------------------------- Warning --------------------------------
117
117
  // | These PropTypes are generated from the TypeScript type definitions |
118
118
  // | To update them edit the d.ts file and run "yarn proptypes" |
@@ -160,11 +160,11 @@ process.env.NODE_ENV !== "production" && (X.propTypes = {
160
160
  */
161
161
  variant: t.oneOf(["filled", "outlined", "standard"])
162
162
  });
163
- const A = X, Me = j("MuiListItemIcon", ["root", "alignItemsFlexStart"]), U = Me, Oe = j("MuiListItemText", ["root", "multiline", "dense", "inset", "primary", "secondary"]), G = Oe;
164
- function Te(e) {
163
+ const A = Y, Oe = j("MuiListItemIcon", ["root", "alignItemsFlexStart"]), U = Oe, Te = j("MuiListItemText", ["root", "multiline", "dense", "inset", "primary", "secondary"]), G = Te;
164
+ function Ee(e) {
165
165
  return W("MuiMenuItem", e);
166
166
  }
167
- const Ee = j("MuiMenuItem", ["root", "focusVisible", "dense", "disabled", "divider", "gutters", "selected"]), T = Ee, Pe = ["autoFocus", "component", "dense", "divider", "disableGutters", "focusVisibleClassName", "role", "tabIndex", "className"], Ne = (e, o) => {
167
+ const Pe = j("MuiMenuItem", ["root", "focusVisible", "dense", "disabled", "divider", "gutters", "selected"]), T = Pe, Ne = ["autoFocus", "component", "dense", "divider", "disableGutters", "focusVisibleClassName", "role", "tabIndex", "className"], je = (e, o) => {
168
168
  const {
169
169
  ownerState: s
170
170
  } = e;
@@ -177,19 +177,19 @@ const Ee = j("MuiMenuItem", ["root", "focusVisible", "dense", "disabled", "divid
177
177
  disableGutters: r,
178
178
  selected: l,
179
179
  classes: c
180
- } = e, m = Q({
180
+ } = e, u = X({
181
181
  root: ["root", s && "dense", o && "disabled", !r && "gutters", n && "divider", l && "selected"]
182
- }, Te, c);
183
- return I({}, c, m);
184
- }, je = H(be, {
185
- shouldForwardProp: (e) => pe(e) || e === "classes",
182
+ }, Ee, c);
183
+ return x({}, c, u);
184
+ }, Le = J(ve, {
185
+ shouldForwardProp: (e) => ue(e) || e === "classes",
186
186
  name: "MuiMenuItem",
187
187
  slot: "Root",
188
- overridesResolver: Ne
188
+ overridesResolver: je
189
189
  })(({
190
190
  theme: e,
191
191
  ownerState: o
192
- }) => I({}, e.typography.body1, {
192
+ }) => x({}, e.typography.body1, {
193
193
  display: "flex",
194
194
  justifyContent: "flex-start",
195
195
  alignItems: "center",
@@ -216,16 +216,16 @@ const Ee = j("MuiMenuItem", ["root", "focusVisible", "dense", "disabled", "divid
216
216
  }
217
217
  },
218
218
  [`&.${T.selected}`]: {
219
- backgroundColor: e.vars ? `rgba(${e.vars.palette.primary.mainChannel} / ${e.vars.palette.action.selectedOpacity})` : S(e.palette.primary.main, e.palette.action.selectedOpacity),
219
+ backgroundColor: e.vars ? `rgba(${e.vars.palette.primary.mainChannel} / ${e.vars.palette.action.selectedOpacity})` : N(e.palette.primary.main, e.palette.action.selectedOpacity),
220
220
  [`&.${T.focusVisible}`]: {
221
- backgroundColor: e.vars ? `rgba(${e.vars.palette.primary.mainChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.focusOpacity}))` : S(e.palette.primary.main, e.palette.action.selectedOpacity + e.palette.action.focusOpacity)
221
+ backgroundColor: e.vars ? `rgba(${e.vars.palette.primary.mainChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.focusOpacity}))` : N(e.palette.primary.main, e.palette.action.selectedOpacity + e.palette.action.focusOpacity)
222
222
  }
223
223
  },
224
224
  [`&.${T.selected}:hover`]: {
225
- backgroundColor: e.vars ? `rgba(${e.vars.palette.primary.mainChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.hoverOpacity}))` : S(e.palette.primary.main, e.palette.action.selectedOpacity + e.palette.action.hoverOpacity),
225
+ backgroundColor: e.vars ? `rgba(${e.vars.palette.primary.mainChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.hoverOpacity}))` : N(e.palette.primary.main, e.palette.action.selectedOpacity + e.palette.action.hoverOpacity),
226
226
  // Reset on touch devices, it doesn't add specificity
227
227
  "@media (hover: none)": {
228
- backgroundColor: e.vars ? `rgba(${e.vars.palette.primary.mainChannel} / ${e.vars.palette.action.selectedOpacity})` : S(e.palette.primary.main, e.palette.action.selectedOpacity)
228
+ backgroundColor: e.vars ? `rgba(${e.vars.palette.primary.mainChannel} / ${e.vars.palette.action.selectedOpacity})` : N(e.palette.primary.main, e.palette.action.selectedOpacity)
229
229
  }
230
230
  },
231
231
  [`&.${T.focusVisible}`]: {
@@ -255,7 +255,7 @@ const Ee = j("MuiMenuItem", ["root", "focusVisible", "dense", "disabled", "divid
255
255
  [e.breakpoints.up("sm")]: {
256
256
  minHeight: "auto"
257
257
  }
258
- }, o.dense && I({
258
+ }, o.dense && x({
259
259
  minHeight: 32,
260
260
  // https://m2.material.io/components/menus#specs > Dense
261
261
  paddingTop: 4,
@@ -264,49 +264,49 @@ const Ee = j("MuiMenuItem", ["root", "focusVisible", "dense", "disabled", "divid
264
264
  [`& .${U.root} svg`]: {
265
265
  fontSize: "1.25rem"
266
266
  }
267
- }))), Y = /* @__PURE__ */ $.forwardRef(function(o, s) {
268
- const n = J({
267
+ }))), Z = /* @__PURE__ */ M.forwardRef(function(o, s) {
268
+ const n = Q({
269
269
  props: o,
270
270
  name: "MuiMenuItem"
271
271
  }), {
272
272
  autoFocus: r = !1,
273
273
  component: l = "li",
274
274
  dense: c = !1,
275
- divider: g = !1,
276
- disableGutters: m = !1,
277
- focusVisibleClassName: f,
278
- role: v = "menuitem",
275
+ divider: y = !1,
276
+ disableGutters: u = !1,
277
+ focusVisibleClassName: m,
278
+ role: g = "menuitem",
279
279
  tabIndex: p,
280
- className: b
281
- } = n, i = K(n, Pe), x = $.useContext(B), u = $.useMemo(() => ({
282
- dense: c || x.dense || !1,
283
- disableGutters: m
284
- }), [x.dense, c, m]), h = $.useRef(null);
285
- ve(() => {
286
- r && (h.current ? h.current.focus() : process.env.NODE_ENV !== "production" && console.error("MUI: Unable to set focus to a MenuItem whose component has not been rendered."));
280
+ className: f
281
+ } = n, i = K(n, Ne), C = M.useContext(B), I = M.useMemo(() => ({
282
+ dense: c || C.dense || !1,
283
+ disableGutters: u
284
+ }), [C.dense, c, u]), b = M.useRef(null);
285
+ ge(() => {
286
+ r && (b.current ? b.current.focus() : process.env.NODE_ENV !== "production" && console.error("MUI: Unable to set focus to a MenuItem whose component has not been rendered."));
287
287
  }, [r]);
288
- const E = I({}, n, {
289
- dense: u.dense,
290
- divider: g,
291
- disableGutters: m
292
- }), M = Se(n), L = ge(h, s);
293
- let P;
294
- return n.disabled || (P = p !== void 0 ? p : -1), /* @__PURE__ */ d(B.Provider, {
295
- value: u,
296
- children: /* @__PURE__ */ d(je, I({
288
+ const S = x({}, n, {
289
+ dense: I.dense,
290
+ divider: y,
291
+ disableGutters: u
292
+ }), $ = Se(n), L = ye(b, s);
293
+ let E;
294
+ return n.disabled || (E = p !== void 0 ? p : -1), /* @__PURE__ */ d(B.Provider, {
295
+ value: I,
296
+ children: /* @__PURE__ */ d(Le, x({
297
297
  ref: L,
298
- role: v,
299
- tabIndex: P,
298
+ role: g,
299
+ tabIndex: E,
300
300
  component: l,
301
- focusVisibleClassName: w(M.focusVisible, f),
302
- className: w(M.root, b)
301
+ focusVisibleClassName: w($.focusVisible, m),
302
+ className: w($.root, f)
303
303
  }, i, {
304
- ownerState: E,
305
- classes: M
304
+ ownerState: S,
305
+ classes: $
306
306
  }))
307
307
  });
308
308
  });
309
- process.env.NODE_ENV !== "production" && (Y.propTypes = {
309
+ process.env.NODE_ENV !== "production" && (Z.propTypes = {
310
310
  // ----------------------------- Warning --------------------------------
311
311
  // | These PropTypes are generated from the TypeScript type definitions |
312
312
  // | To update them edit the d.ts file and run "yarn proptypes" |
@@ -381,16 +381,16 @@ process.env.NODE_ENV !== "production" && (Y.propTypes = {
381
381
  */
382
382
  tabIndex: t.number
383
383
  });
384
- const Le = Y;
385
- var F = {}, Re = oe;
384
+ const Re = Z;
385
+ var F = {}, we = se;
386
386
  Object.defineProperty(F, "__esModule", {
387
387
  value: !0
388
388
  });
389
- var Z = F.default = void 0, we = Re(te()), Fe = ee, _e = (0, we.default)(/* @__PURE__ */ (0, Fe.jsx)("path", {
389
+ var H = F.default = void 0, Fe = we(oe()), _e = te, Ve = (0, Fe.default)(/* @__PURE__ */ (0, _e.jsx)("path", {
390
390
  d: "M8.12 9.29 12 13.17l3.88-3.88c.39-.39 1.02-.39 1.41 0 .39.39.39 1.02 0 1.41l-4.59 4.59c-.39.39-1.02.39-1.41 0L6.7 10.7a.9959.9959 0 0 1 0-1.41c.39-.38 1.03-.39 1.42 0z"
391
391
  }), "KeyboardArrowDownRounded");
392
- Z = F.default = _e;
393
- const et = ({
392
+ H = F.default = Ve;
393
+ const ot = ({
394
394
  name: e,
395
395
  label: o,
396
396
  type: s,
@@ -398,16 +398,17 @@ const et = ({
398
398
  handleInputChange: r,
399
399
  placeholder: l,
400
400
  required: c,
401
- disabled: g,
402
- options: m,
403
- optionsResponseHandler: f,
404
- api_endpoint: v,
401
+ disabled: y,
402
+ options: u,
403
+ optionsResponseHandler: m,
404
+ api_endpoint: g,
405
405
  error: p,
406
- helperText: b,
406
+ helperText: f,
407
407
  inputAdornments: i,
408
- autofocus: x
408
+ autofocus: C,
409
+ authHeader: I
409
410
  }) => {
410
- const [u, h] = se([]), E = V(
411
+ const [b, S] = ne([]), $ = V(
411
412
  () => ({
412
413
  "& .MuiSelect-select > span::before": {
413
414
  content: `'${l || ""}'`,
@@ -415,9 +416,9 @@ const et = ({
415
416
  }
416
417
  }),
417
418
  [l]
418
- ), M = V(
419
+ ), L = V(
419
420
  () => ({
420
- ...N.textfield,
421
+ ...P.textfield,
421
422
  "&.Mui-focused": {
422
423
  "& fieldset": {
423
424
  borderColor: p ? O.redLight : O.primary
@@ -429,28 +430,38 @@ const et = ({
429
430
  "& input::placeholder": {
430
431
  color: p ? O.redMedium : "grey"
431
432
  },
432
- ...s === "select" && E
433
+ ...s === "select" && $
433
434
  }),
434
- [p, s, E]
435
+ [p, s, $]
435
436
  );
436
- function L(a) {
437
- const y = u == null ? void 0 : u.find(
438
- (C) => typeof C == "object" ? C.value === a : C === a
437
+ function E(a) {
438
+ const v = b == null ? void 0 : b.find(
439
+ (h) => typeof h == "object" ? h.value === a : h === a
439
440
  );
440
- return typeof y == "object" ? y.name : y;
441
+ return typeof v == "object" ? v.name : v;
441
442
  }
442
- const P = ne(async () => {
443
+ const ee = ae(async () => {
443
444
  var a;
444
- return s !== "select" ? [] : m || (v && f ? (a = (await (await fetch(v)).json())[f.key]) == null ? void 0 : a.map((_) => ({
445
- name: _[f.name],
446
- value: _[f.value]
447
- })) : []);
448
- }, [s, f, v]);
449
- return ae(() => {
450
- P().then((a) => h(a));
451
- }, []), /* @__PURE__ */ q(ce, { sx: ie.inputWrapper, children: [
445
+ if (s !== "select")
446
+ return [];
447
+ if (u)
448
+ return u;
449
+ if (g && m) {
450
+ const v = {
451
+ "Content-Type": "application/json"
452
+ };
453
+ return I && (v.Authorization = I), (a = (await (await fetch(g, { headers: v })).json())[m.key]) == null ? void 0 : a.map((_) => ({
454
+ name: _[m.name],
455
+ value: _[m.value]
456
+ }));
457
+ }
458
+ return [];
459
+ }, [s, m, g, I]);
460
+ return re(() => {
461
+ ee().then((a) => S(a));
462
+ }, []), /* @__PURE__ */ q(de, { sx: le.inputWrapper, children: [
452
463
  /* @__PURE__ */ d(
453
- le,
464
+ ce,
454
465
  {
455
466
  name: e,
456
467
  label: o,
@@ -459,10 +470,10 @@ const et = ({
459
470
  }
460
471
  ),
461
472
  /* @__PURE__ */ d(
462
- de,
473
+ pe,
463
474
  {
464
475
  id: `form-input-${e}`,
465
- autoFocus: x,
476
+ autoFocus: C,
466
477
  name: e,
467
478
  type: s,
468
479
  select: s === "select",
@@ -470,14 +481,14 @@ const et = ({
470
481
  onChange: r,
471
482
  placeholder: l,
472
483
  required: c,
473
- disabled: g,
484
+ disabled: y,
474
485
  error: p,
475
486
  InputProps: {
476
487
  startAdornment: /* @__PURE__ */ d(
477
488
  A,
478
489
  {
479
490
  position: "start",
480
- sx: N.inputAdornment,
491
+ sx: P.inputAdornment,
481
492
  children: i == null ? void 0 : i.beforeInput
482
493
  }
483
494
  ),
@@ -485,41 +496,41 @@ const et = ({
485
496
  A,
486
497
  {
487
498
  position: "end",
488
- sx: N.inputAdornment,
499
+ sx: P.inputAdornment,
489
500
  children: i == null ? void 0 : i.afterInput
490
501
  }
491
502
  )
492
503
  },
493
504
  SelectProps: {
494
- renderValue: L,
495
- IconComponent: Z,
505
+ renderValue: E,
506
+ IconComponent: H,
496
507
  MenuProps: {
497
- sx: N.selectDropdown
508
+ sx: P.selectDropdown
498
509
  }
499
510
  },
500
- sx: M,
501
- children: s === "select" && (u == null ? void 0 : u.map((a) => {
502
- const y = typeof a == "object", C = {
511
+ sx: L,
512
+ children: s === "select" && (b == null ? void 0 : b.map((a) => {
513
+ const v = typeof a == "object", h = {
503
514
  display: "flex",
504
515
  justifyContent: "space-between",
505
516
  alignItems: "center",
506
517
  gap: "1rem"
507
518
  };
508
519
  return /* @__PURE__ */ d(
509
- Le,
520
+ Re,
510
521
  {
511
- value: y ? a.value : a,
512
- sx: C,
513
- children: y ? a.name : a
522
+ value: v ? a.value : a,
523
+ sx: h,
524
+ children: v ? a.name : a
514
525
  },
515
- y ? a.name : a
526
+ v ? a.name : a
516
527
  );
517
528
  }))
518
529
  }
519
530
  ),
520
- p && /* @__PURE__ */ d(re, { message: b || "" })
531
+ p && /* @__PURE__ */ d(ie, { message: f || "" })
521
532
  ] });
522
533
  };
523
534
  export {
524
- et as default
535
+ ot as default
525
536
  };
@@ -5,7 +5,7 @@ import { ConfigField, CustomFields, FormInputAdornments, InvalidData } from "./F
5
5
  interface FormProps {
6
6
  config: Array<ConfigField>;
7
7
  submitText?: string;
8
- handleSubmit: (data: any) => void;
8
+ handleSubmit: (data: any, authHeader?: string) => void;
9
9
  handleInvalidData?: (data: Array<InvalidData>) => void;
10
10
  cancelText?: string;
11
11
  handleCancel?: () => void;
@@ -17,6 +17,7 @@ interface FormProps {
17
17
  buttonWrapperStyles?: SxProps;
18
18
  preFillValues?: any;
19
19
  formAdornments?: FormInputAdornments;
20
+ authHeader?: string;
20
21
  }
21
22
  /**
22
23
  * Form component
@@ -34,6 +35,7 @@ interface FormProps {
34
35
  * @param buttonWrapperStyles - Styles for button wrapper
35
36
  * @param preFillValues - Object containing pre-fill values
36
37
  * @param formAdornments - Object containing form adornments
38
+ * @param authHeader - Authentication header string (e.g., "Bearer token123")
37
39
  */
38
40
  declare const Form: CraftFC<FormProps>;
39
41
  export default Form;
@@ -1,158 +1,160 @@
1
- import { jsx as l, jsxs as j } from "react/jsx-runtime";
2
- import { forwardRef as X, useState as E, useRef as O, useCallback as _, useEffect as Y, useImperativeHandle as Z } from "react";
3
- import V from "../../cell/Button/index.js";
4
- import { T as K } from "../../../index-ae3eb123.js";
1
+ import { jsx as l, jsxs as E } from "react/jsx-runtime";
2
+ import { forwardRef as Y, useState as O, useRef as _, useCallback as V, useEffect as Z, useImperativeHandle as K } from "react";
3
+ import A from "../../cell/Button/index.js";
4
+ import { T as C } from "../../../index-ae3eb123.js";
5
5
  import y from "./Form.styles.js";
6
- import { getLocalDateTime as C, createNestedObject as ee, deepMergeObjects as te } from "./Form.utils.js";
7
- import se from "./FormInput.js";
8
- import { s as re } from "../../../styled-8f7db30d.js";
6
+ import { getLocalDateTime as tt, createNestedObject as et, deepMergeObjects as st } from "./Form.utils.js";
7
+ import rt from "./FormInput.js";
8
+ import { s as nt } from "../../../styled-8f7db30d.js";
9
9
  import { B as F } from "../../../Box-96e795c4.js";
10
- const ne = re("div")({
10
+ const ot = nt("div")({
11
11
  marginBottom: "1rem",
12
12
  borderBottom: "1px solid #BBB"
13
- }), he = X(
13
+ }), dt = Y(
14
14
  ({
15
15
  config: p,
16
- submitText: A = "Submit",
17
- handleSubmit: T,
16
+ submitText: T = "Submit",
17
+ handleSubmit: R,
18
18
  handleInvalidData: h,
19
- cancelText: R = "Cancel",
19
+ cancelText: k = "Cancel",
20
20
  handleCancel: d,
21
21
  onChange: u,
22
- formStyles: k = {},
23
- formWrapperStyles: I = {},
24
- formFieldsWrapperStyles: M = {},
25
- buttonWrapperStyles: N = {},
22
+ formStyles: I = {},
23
+ formWrapperStyles: M = {},
24
+ formFieldsWrapperStyles: N = {},
25
+ buttonWrapperStyles: w = {},
26
26
  customFields: S = {},
27
27
  preFillValues: x = {},
28
- formAdornments: w = {}
29
- }, D) => {
30
- const [c, b] = E({}), [H, g] = E([]), B = O(null), v = O(null);
31
- function W(e, t) {
28
+ formAdornments: D = {},
29
+ authHeader: B
30
+ }, W) => {
31
+ const [c, b] = O({}), [q, g] = O([]), v = _(null), j = _(null);
32
+ function H(t, e) {
32
33
  b((s) => ({
33
34
  ...s,
34
- [e]: t
35
- })), u == null || u(e, t), g([]);
35
+ [t]: e
36
+ })), u == null || u(t, e), g([]);
36
37
  }
37
- const q = _(() => {
38
- const e = {};
39
- p == null || p.forEach((t) => {
40
- if (t.preFillWithDateTime && t.type === "text") {
41
- const s = C();
42
- e[t.name] = s, u == null || u(t.name, s);
38
+ const P = V(() => {
39
+ const t = {};
40
+ p == null || p.forEach((e) => {
41
+ if (e.preFillWithDateTime && e.type === "text") {
42
+ const s = tt();
43
+ t[e.name] = s, u == null || u(e.name, s);
43
44
  } else
44
- e[t.name] = t.defaultValue || x[t.name] || "", u == null || u(
45
- t.name,
46
- t.defaultValue || x[t.name] || ""
45
+ t[e.name] = e.defaultValue || x[e.name] || "", u == null || u(
46
+ e.name,
47
+ e.defaultValue || x[e.name] || ""
47
48
  );
48
- }), b(e), g([]);
49
+ }), b(t), g([]);
49
50
  }, [x]);
50
- function P() {
51
- const e = [];
52
- return p == null || p.forEach((t) => {
53
- const { name: s, label: n, type: m, validation: r, required: i } = t, o = c[s], a = s;
51
+ function $() {
52
+ const t = [];
53
+ return p == null || p.forEach((e) => {
54
+ const { name: s, label: n, type: m, validation: r, required: i } = e, o = c[s], a = s;
54
55
  if (r)
55
56
  if (m === "number") {
56
57
  const f = parseInt(o);
57
- r.min && f < r.min && e.push({
58
+ r.min && f < r.min && t.push({
58
59
  field: a,
59
60
  value: o,
60
61
  message: r.invalid_message
61
- }), r.max && f > r.max && e.push({
62
+ }), r.max && f > r.max && t.push({
62
63
  field: a,
63
64
  value: o,
64
65
  message: r.invalid_message
65
- }), isNaN(f) && e.push({
66
+ }), isNaN(f) && t.push({
66
67
  field: a,
67
68
  value: o,
68
69
  message: "Invalid number"
69
70
  });
70
71
  } else
71
- m === "text" && (r.min_length && o.length < r.min_length && e.push({
72
+ m === "text" && (r.min_length && o.length < r.min_length && t.push({
72
73
  field: a,
73
74
  value: o,
74
75
  message: r.invalid_message
75
- }), r.max_length && o.length > r.max_length && e.push({
76
+ }), r.max_length && o.length > r.max_length && t.push({
76
77
  field: a,
77
78
  value: o,
78
79
  message: r.invalid_message
79
- }), r.pattern && !new RegExp(r.pattern).test(o) && e.push({
80
+ }), r.pattern && !new RegExp(r.pattern).test(o) && t.push({
80
81
  field: a,
81
82
  value: o,
82
83
  message: r.invalid_message
83
84
  }));
84
- i && !o && e.push({
85
+ i && !o && t.push({
85
86
  field: a,
86
87
  value: o,
87
88
  message: `${n} is required`
88
89
  });
89
- }), g(e), e.length && (h == null || h(e)), !e.length;
90
+ }), g(t), t.length && (h == null || h(t)), !t.length;
90
91
  }
91
- const $ = _(
92
- (e) => {
93
- let t = {};
94
- return e == null || e.forEach((s) => {
92
+ const L = V(
93
+ (t) => {
94
+ let e = {};
95
+ return t == null || t.forEach((s) => {
95
96
  const { name: n, type: m, submitDataKey: r } = s, i = m === "number" ? parseInt(c[n]) : c[n];
96
97
  function o(a) {
97
98
  if (a.indexOf(".") !== -1) {
98
- const f = ee(
99
+ const f = et(
99
100
  a,
100
101
  m,
101
102
  c[n]
102
103
  );
103
- t = te(
104
- t,
104
+ e = st(
105
+ e,
105
106
  f
106
107
  );
107
108
  } else
108
- t[a] = i;
109
+ e[a] = i;
109
110
  }
110
111
  typeof r != "string" && (r != null && r.length) ? r.forEach((a) => {
111
112
  o(a);
112
- }) : typeof r == "string" && r ? o(r) : t[n] = i;
113
- }), t;
113
+ }) : typeof r == "string" && r ? o(r) : e[n] = i;
114
+ }), e;
114
115
  },
115
116
  [c]
116
117
  );
117
- function L(e) {
118
- if (e.preventDefault(), P()) {
119
- const s = $(p);
120
- T(s);
118
+ function z(t) {
119
+ if (t.preventDefault(), $()) {
120
+ const s = L(p);
121
+ R(s, B);
121
122
  }
122
123
  }
123
- function z() {
124
- b((e) => {
125
- const t = { ...e };
126
- return Object.keys(t).forEach((s) => {
127
- t[s] = "";
128
- }), t;
124
+ function G() {
125
+ b((t) => {
126
+ const e = { ...t };
127
+ return Object.keys(e).forEach((s) => {
128
+ e[s] = "";
129
+ }), e;
129
130
  }), d == null || d();
130
131
  }
131
- function G(e) {
132
- const t = H.find(
133
- (n) => n.field === e.name
132
+ function J(t) {
133
+ const e = q.find(
134
+ (n) => n.field === t.name
134
135
  ), s = {
135
- ...e,
136
- value: c[e.name],
137
- handleChange: W,
138
- error: !!t,
139
- helperText: t == null ? void 0 : t.message,
140
- inputAdornments: w[e.name] || e.inputAdornments
136
+ ...t,
137
+ value: c[t.name],
138
+ handleChange: H,
139
+ error: !!e,
140
+ helperText: e == null ? void 0 : e.message,
141
+ inputAdornments: D[t.name] || t.inputAdornments,
142
+ authHeader: B
141
143
  };
142
- if (e.hidden)
144
+ if (t.hidden)
143
145
  return null;
144
- if (e.type === "custom" && e.customComponent && S[e.customComponent]) {
145
- const { component: n, props: m } = S[e.customComponent], r = n, i = {
146
+ if (t.type === "custom" && t.customComponent && S[t.customComponent]) {
147
+ const { component: n, props: m } = S[t.customComponent], r = n, i = {
146
148
  ...s,
147
149
  ...m
148
150
  };
149
151
  if (r && i)
150
- return /* @__PURE__ */ l(r, { ...i }, e.name);
152
+ return /* @__PURE__ */ l(r, { ...i }, t.name);
151
153
  } else
152
- return /* @__PURE__ */ l(se, { ...s }, e.name);
154
+ return /* @__PURE__ */ l(rt, { ...s }, t.name);
153
155
  }
154
- function J() {
155
- const e = p.reduce(
156
+ function Q() {
157
+ const t = p.reduce(
156
158
  (s, n) => {
157
159
  const { groupName: m } = n;
158
160
  if (!s.length)
@@ -168,49 +170,49 @@ const ne = re("div")({
168
170
  },
169
171
  []
170
172
  );
171
- function t(s) {
172
- return s.map((n) => typeof n == "string" ? /* @__PURE__ */ l(K, { type: "headingSmall", sx: y.heading, children: n }, n) : G(n));
173
+ function e(s) {
174
+ return s.map((n) => typeof n == "string" ? /* @__PURE__ */ l(C, { type: "headingSmall", sx: y.heading, children: n }, n) : J(n));
173
175
  }
174
- return e.map(
175
- (s) => typeof s[0] == "string" ? /* @__PURE__ */ l(ne, { children: t(s) }, `group-${s[0]}`) : t(s)
176
+ return t.map(
177
+ (s) => typeof s[0] == "string" ? /* @__PURE__ */ l(ot, { children: e(s) }, `group-${s[0]}`) : e(s)
176
178
  );
177
179
  }
178
- Y(() => {
179
- q();
180
+ Z(() => {
181
+ P();
180
182
  }, []);
181
- const Q = {
183
+ const U = {
182
184
  ...y.alignVertical,
183
- ...k
184
- }, U = {
185
+ ...I
186
+ }, X = {
185
187
  ...y.alignVertical,
186
188
  marginTop: "1rem",
187
189
  gap: "0.5rem",
188
- ...N
190
+ ...w
189
191
  };
190
- return Z(
191
- D,
192
+ return K(
193
+ W,
192
194
  () => ({
193
- submitButtonRef: B,
194
- cancelButtonRef: v
195
+ submitButtonRef: v,
196
+ cancelButtonRef: j
195
197
  }),
196
198
  []
197
- ), /* @__PURE__ */ l(F, { sx: I, children: /* @__PURE__ */ j("form", { style: Q, children: [
198
- /* @__PURE__ */ l(F, { sx: M, children: Object.keys(c).length && J() }),
199
- /* @__PURE__ */ j(F, { sx: U, children: [
199
+ ), /* @__PURE__ */ l(F, { sx: M, children: /* @__PURE__ */ E("form", { style: U, children: [
200
+ /* @__PURE__ */ l(F, { sx: N, children: Object.keys(c).length && Q() }),
201
+ /* @__PURE__ */ E(F, { sx: X, children: [
200
202
  /* @__PURE__ */ l(
201
- V,
203
+ A,
202
204
  {
203
- ref: B,
205
+ ref: v,
204
206
  type: "submit",
205
- onClick: L,
206
- children: A
207
+ onClick: z,
208
+ children: T
207
209
  }
208
210
  ),
209
- /* @__PURE__ */ l(V, { ref: v, onClick: z, children: R })
211
+ /* @__PURE__ */ l(A, { ref: j, onClick: G, children: k })
210
212
  ] })
211
213
  ] }) });
212
214
  }
213
215
  );
214
216
  export {
215
- he as default
217
+ dt as default
216
218
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loopr-ai/craft",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
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": {