@code0-tech/pictor 0.7.1 → 0.7.2

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.
@@ -1 +1 @@
1
- .editor-input{width:100%;flex:1 1 auto;overflow:hidden;padding:.59rem 0;position:relative;align-self:stretch}.editor-input .cm-editor{height:100%;outline:none!important}.editor-input .cm-content{padding:0;position:relative}.editor-input .cm-line{align-self:stretch;padding-left:0}
1
+ .editor-input{width:100%;flex:1 1 auto;overflow:hidden;padding:.59rem 0;position:relative;align-self:stretch}.editor-input .cm-editor{height:100%;outline:none!important}.editor-input .cm-content{padding:0;position:relative}.editor-input .cm-line{align-self:stretch;padding-left:0}.editor-input .cm-cursor{border-width:2px;border-radius:50rem;border-color:#fff}
@@ -1 +1 @@
1
- .input-wrapper{display:flex;z-index:1;width:100%;align-items:start;box-sizing:border-box;gap:.175rem}.input-wrapper{background:#201e2c;box-shadow:inset 0 1px 1px #ffffff1a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box}.input-wrapper:hover{background:#bfbfbf26;box-shadow:inset 0 1px 1px #ffffff1a}.input-wrapper:active,.input-wrapper:focus,.input-wrapper[aria-selected=true],.input-wrapper[data-state=open]{background:#bfbfbf33;box-shadow:inset 0 1px 1px #ffffff1a;outline:none}.input-wrapper{font-family:Inter,sans-serif;font-weight:400;letter-spacing:-.5px;border-radius:1rem}.input-wrapper:has(.input-wrapper__control:focus){background:#bfbfbf33;box-shadow:inset 0 1px 1px #ffffff1a;outline:none}.input-wrapper--not-valid{background:#1c0516;box-shadow:inset 0 1px 1px #d904291a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box}.input-wrapper>:first-child{padding-left:.7rem}.input-wrapper__left,.input-wrapper__right{display:flex;align-items:center;justify-content:center;min-height:30px;gap:.7rem;margin:.175rem}.input-wrapper__left>button,.input-wrapper__right>button{height:100%;padding-left:0;padding-right:0}.input-wrapper__left--action,.input-wrapper__right--action{padding:0}.input-wrapper__left--placeholder,.input-wrapper__right--placeholder{background:#070514;box-shadow:inset 0 1px 1px #bfbfbf1a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box;font-family:Inter,sans-serif;font-weight:400;letter-spacing:-.5px;border-radius:.825rem;padding:.7rem;box-shadow:none}.input-wrapper__left--icon,.input-wrapper__right--icon{align-items:center}
1
+ .input-wrapper{display:flex;z-index:1;width:100%;align-items:start;box-sizing:border-box;gap:.175rem}.input-wrapper{background:#201e2c;box-shadow:inset 0 1px 1px #ffffff1a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box}.input-wrapper:hover{background:#bfbfbf26;box-shadow:inset 0 1px 1px #ffffff1a}.input-wrapper:active,.input-wrapper:focus,.input-wrapper[aria-selected=true],.input-wrapper[data-state=open]{background:#bfbfbf33;box-shadow:inset 0 1px 1px #ffffff1a;outline:none}.input-wrapper{font-family:Inter,sans-serif;font-weight:400;letter-spacing:-.5px;border-radius:1rem}.input-wrapper:has(.input-wrapper__control:focus){background:#bfbfbf33;box-shadow:inset 0 1px 1px #ffffff1a;outline:none}.input-wrapper--not-valid{background:#1c0516;box-shadow:inset 0 1px 1px #d904291a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box}.input-wrapper>:first-child{padding-left:.7rem}.input-wrapper__left,.input-wrapper__right{display:flex;align-items:center;justify-content:center;min-height:30px;gap:.7rem;margin:.175rem}.input-wrapper__left--action,.input-wrapper__right--action{padding:0}.input-wrapper__left--placeholder,.input-wrapper__right--placeholder{background:#070514;box-shadow:inset 0 1px 1px #bfbfbf1a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box;font-family:Inter,sans-serif;font-weight:400;letter-spacing:-.5px;border-radius:.825rem;padding:.7rem;box-shadow:none}.input-wrapper__left--icon,.input-wrapper__right--icon{align-items:center}
@@ -1 +1 @@
1
- .select-input__content{padding:.35rem;position:relative;box-sizing:border-box;z-index:999}.select-input__content{border-radius:1rem}.select-input__item{border-radius:.65rem;padding:.35rem .7rem;gap:.7rem;cursor:pointer;width:100%;display:flex;align-items:center;font-size:.8rem}.select-input__item{background:#070514;box-shadow:inset 0 1px 1px #bfbfbf1a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box}.select-input__item:focus{outline:none}.select-input__item{font-family:Inter,sans-serif;font-weight:400;letter-spacing:-.5px}.select-input__item:disabled,.select-input__item[data-disabled],.select-input__item[aria-disabled=true],.select-input__item--disabled{cursor:not-allowed;opacity:25%;pointer-events:unset}.select-input__item{box-shadow:none}.select-input__item:focus,.select-input__item[data-focus=true]{background:#191825;box-shadow:inset 0 1px 1px #ffffff1a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box;box-shadow:none;width:100%}.select-input__trigger{height:-webkit-fill-available;height:stretch;width:100%;position:relative;align-self:stretch;cursor:pointer}.select-input__content--primary{background:#070514;box-shadow:inset 0 1px 1px #bfbfbf1a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box;border:rgb(25.4,23.6,37.1) 2px solid}.select-input__content--secondary{background:#191825;box-shadow:inset 0 1px 1px #bfbfbf1a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box;border:rgb(25.4,23.6,37.1) 2px solid}.select-input__content--tertiary{background:#201e2c;box-shadow:inset 0 1px 1px #bfbfbf1a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box;border:rgb(25.4,23.6,37.1) 2px solid}.select-input__content--success{background:#0a1814;box-shadow:inset 0 1px 1px #bfbfbf1a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box;border:rgb(25.4,23.6,37.1) 2px solid}.select-input__content--warning{background:#201813;box-shadow:inset 0 1px 1px #bfbfbf1a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box;border:rgb(25.4,23.6,37.1) 2px solid}.select-input__content--error{background:#1c0516;box-shadow:inset 0 1px 1px #bfbfbf1a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box;border:rgb(25.4,23.6,37.1) 2px solid}.select-input__content--info{background:#121e24;box-shadow:inset 0 1px 1px #bfbfbf1a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box;border:rgb(25.4,23.6,37.1) 2px solid}
1
+ .select-input__content{padding:.35rem;position:relative;box-sizing:border-box;z-index:999}.select-input__content{border-radius:1rem}.select-input__item{border-radius:.65rem;padding:.35rem .7rem;gap:.7rem;cursor:pointer;width:100%;display:flex;align-items:center;font-size:.8rem}.select-input__item{background:#070514;box-shadow:inset 0 1px 1px #bfbfbf1a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box}.select-input__item:focus{outline:none}.select-input__item{font-family:Inter,sans-serif;font-weight:400;letter-spacing:-.5px}.select-input__item:disabled,.select-input__item[data-disabled],.select-input__item[aria-disabled=true],.select-input__item--disabled{cursor:not-allowed;opacity:25%;pointer-events:unset}.select-input__item{box-shadow:none}.select-input__item:focus,.select-input__item[data-focus=true]{background:#191825;box-shadow:inset 0 1px 1px #ffffff1a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box;box-shadow:none;width:100%}.select-input__trigger{width:100%;position:relative;align-self:stretch;cursor:pointer}.select-input__content--primary{background:#070514;box-shadow:inset 0 1px 1px #bfbfbf1a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box;border:rgb(25.4,23.6,37.1) 2px solid}.select-input__content--secondary{background:#191825;box-shadow:inset 0 1px 1px #bfbfbf1a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box;border:rgb(25.4,23.6,37.1) 2px solid}.select-input__content--tertiary{background:#201e2c;box-shadow:inset 0 1px 1px #bfbfbf1a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box;border:rgb(25.4,23.6,37.1) 2px solid}.select-input__content--success{background:#0a1814;box-shadow:inset 0 1px 1px #bfbfbf1a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box;border:rgb(25.4,23.6,37.1) 2px solid}.select-input__content--warning{background:#201813;box-shadow:inset 0 1px 1px #bfbfbf1a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box;border:rgb(25.4,23.6,37.1) 2px solid}.select-input__content--error{background:#1c0516;box-shadow:inset 0 1px 1px #bfbfbf1a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box;border:rgb(25.4,23.6,37.1) 2px solid}.select-input__content--info{background:#121e24;box-shadow:inset 0 1px 1px #bfbfbf1a;border:none;color:#ffffffbf;position:relative;box-sizing:border-box;border:rgb(25.4,23.6,37.1) 2px solid}
@@ -296,7 +296,7 @@ const De = (i) => me(i) || typeof i == "string" || typeof i == "number" || Array
296
296
  if (I(e), t === "json")
297
297
  try {
298
298
  const d = JSON.parse(e);
299
- q?.(d), Z?.setValue(d);
299
+ q?.(d), Z?.setValue?.(d);
300
300
  } catch {
301
301
  }
302
302
  else
@@ -26,7 +26,7 @@ const ee = (l) => {
26
26
  const i = x, [t, R] = z.useState(l.initialValue ?? "indeterminate");
27
27
  let g;
28
28
  e[2] !== t || e[3] !== i ? (g = () => {
29
- i.setValue(t);
29
+ i.setValue?.(t);
30
30
  }, e[2] = t, e[3] = i, e[4] = g) : g = e[4];
31
31
  let v;
32
32
  e[5] !== t ? (v = [t], e[5] = t, e[6] = v) : v = e[6], z.useEffect(g, v);
@@ -56,7 +56,7 @@ const N = (i) => {
56
56
  }, ...r]
57
57
  }), [r]);
58
58
  return /* @__PURE__ */ a(y, { title: g, description: u, right: s, left: m, rightType: l, leftType: c, formValidation: o, children: /* @__PURE__ */ a(T, { extensions: d, onChange: (n) => {
59
- o?.setValue(n), f?.(n);
59
+ o?.setValue?.(n), f?.(n);
60
60
  }, theme: k, ...C("editor-input", b), basicSetup: {
61
61
  lineNumbers: !1,
62
62
  foldGutter: !1,
@@ -29,7 +29,7 @@ const B = (n) => {
29
29
  e[11] !== h ? (l = V(h, {}), e[11] = h, e[12] = l) : l = e[12], t = T, d = V("pin-input", {
30
30
  ...g,
31
31
  onValueChange: (v) => {
32
- g.onValueChange && g.onValueChange(v), i.setValue(v);
32
+ g.onValueChange && g.onValueChange(v), i.setValue?.(v);
33
33
  }
34
34
  }), e[0] = n, e[1] = t, e[2] = i, e[3] = d, e[4] = l, e[5] = o, e[6] = s;
35
35
  } else
@@ -27,7 +27,7 @@ const y = (s) => {
27
27
  } : V, e[7] !== d ? (i = d ? /* @__PURE__ */ f(G, { children: d }) : null, e[7] = d, e[8] = i) : i = e[8], e[9] !== p ? (l = p ? /* @__PURE__ */ f(I, { children: p }) : null, e[9] = p, e[10] = l) : l = e[10], o = M.RadioGroup, r = h ?? s.defaultValue, a = v("radio-group", {
28
28
  ...c,
29
29
  onValueChange: (g) => {
30
- c.onValueChange && c.onValueChange(g), t.setValue(g);
30
+ c.onValueChange && c.onValueChange(g), t.setValue?.(g);
31
31
  }
32
32
  }), e[0] = s, e[1] = o, e[2] = t, e[3] = r, e[4] = a, e[5] = i, e[6] = l;
33
33
  } else
@@ -5,81 +5,81 @@ import "../../utils/contextStore.js";
5
5
  import "react";
6
6
  import { mergeComponentProps as f } from "../../utils/component.js";
7
7
  import "js-md5";
8
- import { InputWrapper as p } from "./InputWrapper.js";
8
+ import { InputWrapper as R } from "./InputWrapper.js";
9
9
  import '../../assets/components/form/SelectInput.style.css';/* empty css */
10
- const A = (n) => {
10
+ const A = (i) => {
11
11
  const t = r.c(24);
12
- let e, l, i, c, m, u, a, _, g, T;
13
- if (t[0] !== n) {
12
+ let e, l, n, c, m, u, a, _, g, T;
13
+ if (t[0] !== i) {
14
14
  const {
15
- title: C,
16
- description: I,
17
- left: y,
18
- leftType: w,
19
- rightType: P,
20
- right: R,
15
+ title: I,
16
+ description: y,
17
+ left: C,
18
+ leftType: p,
19
+ rightType: w,
20
+ right: P,
21
21
  formValidation: h,
22
22
  ...x
23
- } = n;
24
- l = p, c = C, m = I, u = y, a = w, _ = R, g = P, T = h, e = s.Root, i = f("select-input", {
23
+ } = i;
24
+ l = R, c = I, m = y, u = C, a = p, _ = P, g = w, T = h, e = s.Root, n = f("select-input", {
25
25
  ...x,
26
26
  onValueChange: (d) => {
27
- h?.setValue(d), x.onValueChange?.(d), n.onChange?.({});
27
+ h?.setValue?.(d), x.onValueChange?.(d);
28
28
  }
29
- }), t[0] = n, t[1] = e, t[2] = l, t[3] = i, t[4] = c, t[5] = m, t[6] = u, t[7] = a, t[8] = _, t[9] = g, t[10] = T;
29
+ }), t[0] = i, t[1] = e, t[2] = l, t[3] = n, t[4] = c, t[5] = m, t[6] = u, t[7] = a, t[8] = _, t[9] = g, t[10] = T;
30
30
  } else
31
- e = t[1], l = t[2], i = t[3], c = t[4], m = t[5], u = t[6], a = t[7], _ = t[8], g = t[9], T = t[10];
32
- const $ = i;
31
+ e = t[1], l = t[2], n = t[3], c = t[4], m = t[5], u = t[6], a = t[7], _ = t[8], g = t[9], T = t[10];
32
+ const $ = n;
33
33
  let S;
34
34
  t[11] !== e || t[12] !== $ ? (S = /* @__PURE__ */ o(e, { ...$ }), t[11] = e, t[12] = $, t[13] = S) : S = t[13];
35
35
  let V;
36
36
  return t[14] !== l || t[15] !== c || t[16] !== m || t[17] !== u || t[18] !== a || t[19] !== _ || t[20] !== g || t[21] !== T || t[22] !== S ? (V = /* @__PURE__ */ o(l, { title: c, description: m, left: u, leftType: a, right: _, rightType: g, formValidation: T, children: S }), t[14] = l, t[15] = c, t[16] = m, t[17] = u, t[18] = a, t[19] = _, t[20] = g, t[21] = T, t[22] = S, t[23] = V) : V = t[23], V;
37
- }, B = (n) => {
37
+ }, B = (i) => {
38
38
  const t = r.c(4);
39
39
  let e;
40
- t[0] !== n ? (e = f("select-input__trigger", n), t[0] = n, t[1] = e) : e = t[1];
40
+ t[0] !== i ? (e = f("select-input__trigger", i), t[0] = i, t[1] = e) : e = t[1];
41
41
  let l;
42
42
  return t[2] !== e ? (l = /* @__PURE__ */ o(s.Trigger, { ...e }), t[2] = e, t[3] = l) : l = t[3], l;
43
- }, D = (n) => {
43
+ }, D = (i) => {
44
44
  const t = r.c(4);
45
45
  let e;
46
- t[0] !== n ? (e = f("select-input__value", n), t[0] = n, t[1] = e) : e = t[1];
46
+ t[0] !== i ? (e = f("select-input__value", i), t[0] = i, t[1] = e) : e = t[1];
47
47
  let l;
48
48
  return t[2] !== e ? (l = /* @__PURE__ */ o(s.Value, { ...e }), t[2] = e, t[3] = l) : l = t[3], l;
49
- }, F = (n) => {
50
- const t = r.c(5), e = `select-input__content select-input__content--${n.color ?? "primary"}`;
49
+ }, F = (i) => {
50
+ const t = r.c(5), e = `select-input__content select-input__content--${i.color ?? "primary"}`;
51
51
  let l;
52
- t[0] !== n || t[1] !== e ? (l = f(e, n), t[0] = n, t[1] = e, t[2] = l) : l = t[2];
53
- const i = l;
52
+ t[0] !== i || t[1] !== e ? (l = f(e, i), t[0] = i, t[1] = e, t[2] = l) : l = t[2];
53
+ const n = l;
54
54
  let c;
55
- return t[3] !== i ? (c = /* @__PURE__ */ o(s.Content, { ...i }), t[3] = i, t[4] = c) : c = t[4], c;
56
- }, G = (n) => {
55
+ return t[3] !== n ? (c = /* @__PURE__ */ o(s.Content, { ...n }), t[3] = n, t[4] = c) : c = t[4], c;
56
+ }, G = (i) => {
57
57
  const t = r.c(4);
58
58
  let e;
59
- t[0] !== n ? (e = f("select-input__portal", n), t[0] = n, t[1] = e) : e = t[1];
59
+ t[0] !== i ? (e = f("select-input__portal", i), t[0] = i, t[1] = e) : e = t[1];
60
60
  const l = e;
61
- let i;
62
- return t[2] !== l ? (i = /* @__PURE__ */ o(s.Portal, { ...l }), t[2] = l, t[3] = i) : i = t[3], i;
63
- }, H = (n) => {
61
+ let n;
62
+ return t[2] !== l ? (n = /* @__PURE__ */ o(s.Portal, { ...l }), t[2] = l, t[3] = n) : n = t[3], n;
63
+ }, H = (i) => {
64
64
  const t = r.c(4);
65
65
  let e;
66
- t[0] !== n ? (e = f("select-input__viewport", n), t[0] = n, t[1] = e) : e = t[1];
66
+ t[0] !== i ? (e = f("select-input__viewport", i), t[0] = i, t[1] = e) : e = t[1];
67
67
  let l;
68
68
  return t[2] !== e ? (l = /* @__PURE__ */ o(s.Viewport, { ...e }), t[2] = e, t[3] = l) : l = t[3], l;
69
- }, J = (n) => {
69
+ }, J = (i) => {
70
70
  const t = r.c(4);
71
71
  let e;
72
- t[0] !== n ? (e = f("select-input__item", n), t[0] = n, t[1] = e) : e = t[1];
72
+ t[0] !== i ? (e = f("select-input__item", i), t[0] = i, t[1] = e) : e = t[1];
73
73
  const l = e;
74
- let i;
75
- return t[2] !== l ? (i = /* @__PURE__ */ o(s.Item, { ...l }), t[2] = l, t[3] = i) : i = t[3], i;
76
- }, K = (n) => {
74
+ let n;
75
+ return t[2] !== l ? (n = /* @__PURE__ */ o(s.Item, { ...l }), t[2] = l, t[3] = n) : n = t[3], n;
76
+ }, K = (i) => {
77
77
  const t = r.c(4);
78
78
  let e;
79
- t[0] !== n ? (e = f("select-input__item-text", n), t[0] = n, t[1] = e) : e = t[1];
79
+ t[0] !== i ? (e = f("select-input__item-text", i), t[0] = i, t[1] = e) : e = t[1];
80
80
  const l = e;
81
- let i;
82
- return t[2] !== l ? (i = /* @__PURE__ */ o(s.ItemText, { ...l }), t[2] = l, t[3] = i) : i = t[3], i;
81
+ let n;
82
+ return t[2] !== l ? (n = /* @__PURE__ */ o(s.ItemText, { ...l }), t[2] = l, t[3] = n) : n = t[3], n;
83
83
  };
84
84
  export {
85
85
  F as SelectContent,
@@ -14,7 +14,7 @@ export interface ValidationProps<Value> {
14
14
  value?: Value | undefined;
15
15
  required?: boolean;
16
16
  formValidation?: {
17
- setValue: (value: any) => void;
17
+ setValue?: (value: any) => void;
18
18
  valid?: boolean;
19
19
  notValidMessage?: string | null;
20
20
  };
@@ -22,7 +22,7 @@ export interface ValidationProps<Value> {
22
22
  export type ValidationsProps<Values> = Partial<{
23
23
  [Key in keyof Values]: ValidationProps<Values[Key]>;
24
24
  }>;
25
- export type FormValidationReturn<Values> = [IValidation<Values>, <Key extends keyof Values>(key?: Key | any) => void];
25
+ export type FormValidationReturn<Values> = [IValidation<Values>, <Key extends keyof Values>(key?: Key | any, submit?: boolean) => void, Values];
26
26
  export interface IValidation<Values> {
27
27
  getInputProps<Key extends keyof Values>(key: Key): ValidationProps<Values[Key]>;
28
28
  isValid(): boolean;
@@ -1,24 +1,24 @@
1
- import { useState as m, useRef as w, useCallback as b, useEffect as j } from "react";
1
+ import j, { useState as g, useRef as y, useCallback as w, useEffect as P } from "react";
2
2
  function o(i, e, t) {
3
- return (e = y(e)) in i ? Object.defineProperty(i, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : i[e] = t, i;
3
+ return (e = O(e)) in i ? Object.defineProperty(i, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : i[e] = t, i;
4
4
  }
5
- function y(i) {
6
- var e = P(i, "string");
5
+ function O(i) {
6
+ var e = F(i, "string");
7
7
  return typeof e == "symbol" ? e : e + "";
8
8
  }
9
- function P(i, e) {
9
+ function F(i, e) {
10
10
  if (typeof i != "object" || !i) return i;
11
11
  var t = i[Symbol.toPrimitive];
12
12
  if (t !== void 0) {
13
- var a = t.call(i, e);
14
- if (typeof a != "object") return a;
13
+ var n = t.call(i, e);
14
+ if (typeof n != "object") return n;
15
15
  throw new TypeError("@@toPrimitive must return a primitive value.");
16
16
  }
17
17
  return (e === "string" ? String : Number)(i);
18
18
  }
19
- class v {
20
- constructor(e, t, a, u = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map()) {
21
- o(this, "changeValue", void 0), o(this, "currentValues", void 0), o(this, "currentValidations", void 0), o(this, "shouldValidate", void 0), o(this, "cachedMessages", void 0), this.changeValue = e, this.currentValues = t, this.currentValidations = a, this.shouldValidate = u, this.cachedMessages = r;
19
+ class f {
20
+ constructor(e, t, n, l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map()) {
21
+ o(this, "changeValue", void 0), o(this, "currentValues", void 0), o(this, "currentValidations", void 0), o(this, "shouldValidate", void 0), o(this, "cachedMessages", void 0), this.changeValue = e, this.currentValues = t, this.currentValidations = n, this.shouldValidate = l, this.cachedMessages = u;
22
22
  }
23
23
  isValid() {
24
24
  if (!this.currentValidations) return !0;
@@ -30,18 +30,18 @@ class v {
30
30
  return !0;
31
31
  }
32
32
  getInputProps(e) {
33
- const t = this.currentValues[e], a = t ?? null, u = e, r = this.currentValidations && this.currentValidations[e] ? this.currentValidations[e] : (l) => null;
34
- let s = null;
35
- return this.shouldValidate.has(e) ? (s = r(t, this.currentValues), this.cachedMessages.set(e, s)) : s = this.cachedMessages.get(e) ?? null, {
33
+ const t = this.currentValues[e], n = t ?? null, l = e, u = this.currentValidations && this.currentValidations[e] ? this.currentValidations[e] : (s) => null;
34
+ let a = null;
35
+ return this.shouldValidate.has(e) ? (a = u(t, this.currentValues), this.cachedMessages.set(e, a)) : a = this.cachedMessages.get(e) ?? null, {
36
36
  // @ts-ignore – z.B. wenn dein Input `defaultValue` kennt
37
- defaultValue: a ?? void 0,
38
- initialValue: a ?? void 0,
37
+ defaultValue: n ?? void 0,
38
+ initialValue: n ?? void 0,
39
39
  formValidation: {
40
- setValue: (l) => {
41
- this.changeValue(u, l);
40
+ setValue: (s) => {
41
+ this.changeValue(l, s);
42
42
  },
43
- notValidMessage: s,
44
- valid: s === null
43
+ notValidMessage: a,
44
+ valid: a === null
45
45
  },
46
46
  ...this.currentValidations && this.currentValidations[e] ? {
47
47
  required: !0
@@ -49,31 +49,28 @@ class v {
49
49
  };
50
50
  }
51
51
  }
52
- const F = (i) => {
52
+ const E = (i) => {
53
53
  const {
54
54
  initialValues: e,
55
55
  validate: t = {},
56
- truthyValidationBeforeSubmit: a = !0,
57
- useInitialValidation: u = !0,
58
- onSubmit: r
59
- } = i, [s, l] = m(e), c = w(e), f = w(/* @__PURE__ */ new Map()), d = b((n, p) => {
60
- l((h) => {
61
- const V = {
62
- ...h,
63
- [n]: p
64
- };
65
- return c.current = V, V;
66
- });
67
- }, []), [M, g] = m(new v(d, s, t, u ? new Map(Object.keys(e).map((n) => [n, !0])) : /* @__PURE__ */ new Map(), f.current));
68
- j(() => {
69
- l(e), c.current = e, g(new v(d, e, t, u ? new Map(Object.keys(e).map((n) => [n, !0])) : /* @__PURE__ */ new Map(), f.current));
70
- }, [e]);
71
- const S = b((n) => {
72
- const p = n && new Set(Object.keys(e)).has(String(n)) ? /* @__PURE__ */ new Map([[n, !0]]) : new Map(Object.keys(e).map((V) => [String(V), !0])), h = new v(d, c.current, t, p, f.current);
73
- g(h), !new Set(Object.keys(e)).has(String(n)) && r && (!a || h.isValid()) && r(c.current);
74
- }, [d, t, r, a, e]);
75
- return [M, S];
56
+ truthyValidationBeforeSubmit: n = !0,
57
+ useInitialValidation: l = !0,
58
+ onSubmit: u
59
+ } = i, a = j.useMemo(() => e, []), [s, p] = g(a), d = y(/* @__PURE__ */ new Map()), c = w((r, h) => {
60
+ p((V) => ({
61
+ ...V,
62
+ [r]: h
63
+ }));
64
+ }, []), [b, v] = g(new f(c, s, t, l ? new Map(Object.keys(a).map((r) => [r, !0])) : /* @__PURE__ */ new Map(), d.current));
65
+ P(() => {
66
+ p(a), v(new f(c, a, t, l ? new Map(Object.keys(a).map((r) => [r, !0])) : /* @__PURE__ */ new Map(), d.current));
67
+ }, [a]);
68
+ const M = w((r, h = !0) => {
69
+ const V = r && new Set(Object.keys(s)).has(String(r)) ? /* @__PURE__ */ new Map([[r, !0]]) : new Map(Object.keys(s).map((S) => [String(S), !0])), m = new f(c, s, t, V, d.current);
70
+ v(m), h && !new Set(Object.keys(s)).has(String(r)) && u && (!n || m.isValid()) && u(s);
71
+ }, [c, t, u, n, s]);
72
+ return [b, M, s];
76
73
  };
77
74
  export {
78
- F as useForm
75
+ E as useForm
79
76
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code0-tech/pictor",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "type": "module",
5
5
  "description": "A simple template for a custom React component library",
6
6
  "scripts": {