@code0-tech/pictor 0.10.7 → 0.10.9

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,32 +1,32 @@
1
- import { jsx as R } from "react/jsx-runtime";
2
- import { c as h } from "../../_virtual/compiler-runtime.js";
1
+ import { jsx as h } from "react/jsx-runtime";
2
+ import { c as y } from "../../_virtual/compiler-runtime.js";
3
3
  import '../../assets/components/button/Button.style.css';/* empty css */
4
4
  import z from "react";
5
5
  import "../../utils/contextStore.js";
6
6
  import { mergeComponentProps as S } from "../../utils/component.js";
7
7
  import "js-md5";
8
- const P = z.forwardRef((a, d) => {
9
- const t = h.c(11);
10
- let o, n, e, i;
11
- if (t[0] !== a || t[1] !== d) {
8
+ const k = z.forwardRef((d, l) => {
9
+ const t = y.c(13);
10
+ let o, r, e, i, n;
11
+ if (t[0] !== d || t[1] !== l) {
12
12
  const {
13
- children: f,
14
- variant: l,
15
- color: c,
16
- paddingSize: m,
17
- active: u,
18
- disabled: b,
19
- ...p
20
- } = a;
21
- o = f;
22
- const v = l === void 0 ? "normal" : l, $ = c === void 0 ? "secondary" : c, g = m === void 0 ? "xs" : m, x = u === void 0 ? !1 : u;
23
- n = b === void 0 ? !1 : b, e = d, i = S(`button button--${$} ${x ? "button--active" : ""} ${n ? "button--disabled" : ""} button--${v} button--${g}`, p), t[0] = a, t[1] = d, t[2] = o, t[3] = n, t[4] = e, t[5] = i;
13
+ children: p,
14
+ variant: c,
15
+ color: m,
16
+ paddingSize: u,
17
+ active: b,
18
+ disabled: f,
19
+ ...v
20
+ } = d;
21
+ o = p;
22
+ const $ = c === void 0 ? "normal" : c, g = m === void 0 ? "secondary" : m, x = u === void 0 ? "xs" : u, R = b === void 0 ? !1 : b;
23
+ r = f === void 0 ? !1 : f, e = l, i = "button", n = S(`button button--${g} ${R ? "button--active" : ""} ${r ? "button--disabled" : ""} button--${$} button--${x}`, v), t[0] = d, t[1] = l, t[2] = o, t[3] = r, t[4] = e, t[5] = i, t[6] = n;
24
24
  } else
25
- o = t[2], n = t[3], e = t[4], i = t[5];
26
- const s = n ? "true" : "false";
27
- let r;
28
- return t[6] !== o || t[7] !== e || t[8] !== i || t[9] !== s ? (r = /* @__PURE__ */ R("button", { ref: e, ...i, "aria-disabled": s, children: o }), t[6] = o, t[7] = e, t[8] = i, t[9] = s, t[10] = r) : r = t[10], r;
25
+ o = t[2], r = t[3], e = t[4], i = t[5], n = t[6];
26
+ const s = r ? "true" : "false";
27
+ let a;
28
+ return t[7] !== o || t[8] !== e || t[9] !== i || t[10] !== n || t[11] !== s ? (a = /* @__PURE__ */ h("button", { ref: e, type: i, ...n, "aria-disabled": s, children: o }), t[7] = o, t[8] = e, t[9] = i, t[10] = n, t[11] = s, t[12] = a) : a = t[12], a;
29
29
  });
30
30
  export {
31
- P as Button
31
+ k as Button
32
32
  };
@@ -1,68 +1,54 @@
1
- import { jsxs as i, Fragment as M, jsx as t } from "react/jsx-runtime";
2
- import u from "react";
3
- import { Input as V } from "./Input.js";
4
- import { IconX as s, IconCheck as c, IconEye as x } from "@tabler/icons-react";
5
- import { Button as p } from "../button/Button.js";
6
- import { clearInputElement as w } from "./Input.utils.js";
7
- import { Flex as o } from "../flex/Flex.js";
8
- import { Text as a } from "../text/Text.js";
9
- const v = u.forwardRef((n, e) => {
10
- e = e || u.useRef(null);
1
+ import { jsxs as l, Fragment as y, jsx as n } from "react/jsx-runtime";
2
+ import c from "react";
3
+ import { Input as b } from "./Input.js";
4
+ import { IconEye as I, IconX as R } from "@tabler/icons-react";
5
+ import { Button as u } from "../button/Button.js";
6
+ import { clearInputElement as P } from "./Input.utils.js";
7
+ import { Flex as z } from "../flex/Flex.js";
8
+ import { Progress as D } from "../progress/Progress.js";
9
+ import { InputMessage as A } from "./InputMessage.js";
10
+ const L = c.forwardRef((r, t) => {
11
+ t = t || c.useRef(null);
11
12
  const {
12
- clearable: m = !0,
13
- visible: h = !0,
14
- right: g,
15
- formValidation: r,
13
+ clearable: p = !0,
14
+ visible: d = !0,
15
+ right: m,
16
+ formValidation: s,
16
17
  ...f
17
- } = n, z = (l) => (w(e.current), l.stopPropagation(), l.preventDefault(), !1), y = (l) => (e.current instanceof HTMLInputElement && (e.current.type === "password" ? e.current.type = "text" : e.current.type === "text" && (e.current.type = "password")), !1), d = [g];
18
- return h && d.push(/* @__PURE__ */ t(p, { variant: "none", onClick: (l) => y(), children: /* @__PURE__ */ t(x, { size: 13 }) })), m && d.push(/* @__PURE__ */ t(p, { variant: "none", onClick: (l) => z(l), children: /* @__PURE__ */ t(s, { size: 13 }) })), /* @__PURE__ */ i(M, { children: [
19
- /* @__PURE__ */ t(V, { right: d, rightType: "action", type: "password", ref: e, ...r ? {
20
- formValidation: {
21
- setValue: r.setValue,
22
- valid: r.valid
23
- }
18
+ } = r, h = (e) => (P(t.current), e.stopPropagation(), e.preventDefault(), !1), g = (e) => (t.current instanceof HTMLInputElement && (t.current.type === "password" ? t.current.type = "text" : t.current.type === "text" && (t.current.type = "password")), e.stopPropagation(), e.preventDefault(), !1), o = [m];
19
+ d && o.push(/* @__PURE__ */ n(u, { variant: "none", onClick: (e) => g(e), children: /* @__PURE__ */ n(I, { size: 13 }) })), p && o.push(/* @__PURE__ */ n(u, { variant: "none", onClick: (e) => h(e), children: /* @__PURE__ */ n(R, { size: 13 }) }));
20
+ const a = s?.notValidMessage ?? "", i = /^[1-5]+$/.test(a), x = a.length, M = Math.max(0, 5 - x) / 5 * 100;
21
+ return /* @__PURE__ */ l(y, { children: [
22
+ /* @__PURE__ */ n(b, { right: o, rightType: "action", type: "password", ref: t, ...s ? {
23
+ formValidation: i ? {
24
+ setValue: s.setValue,
25
+ valid: s.valid
26
+ } : s
24
27
  } : {}, ...f }),
25
- !r?.valid && /* @__PURE__ */ i(o, { mt: 0.7, style: {
28
+ i && !s?.valid && /* @__PURE__ */ l(z, { mt: 0.7, style: {
26
29
  flexDirection: "column"
27
30
  }, children: [
28
- /* @__PURE__ */ i(o, { align: "center", style: {
29
- gap: "0.35rem"
30
- }, children: [
31
- r?.notValidMessage?.includes("1") ? /* @__PURE__ */ t(s, { color: "#D90429", size: 16 }) : /* @__PURE__ */ t(c, { color: "#29BF12", size: 16 }),
32
- /* @__PURE__ */ t(a, { children: "Must be at least 8 characters" })
33
- ] }),
34
- /* @__PURE__ */ i(o, { align: "center", style: {
35
- gap: "0.35rem"
36
- }, children: [
37
- r?.notValidMessage?.includes("2") ? /* @__PURE__ */ t(s, { color: "#D90429", size: 16 }) : /* @__PURE__ */ t(c, { color: "#29BF12", size: 16 }),
38
- /* @__PURE__ */ t(a, { children: "Must include a lowercase letter" })
39
- ] }),
40
- /* @__PURE__ */ i(o, { align: "center", style: {
41
- gap: "0.35rem"
42
- }, children: [
43
- r?.notValidMessage?.includes("3") ? /* @__PURE__ */ t(s, { color: "#D90429", size: 16 }) : /* @__PURE__ */ t(c, { color: "#29BF12", size: 16 }),
44
- /* @__PURE__ */ t(a, { children: "Must include an uppercase letter" })
45
- ] }),
46
- /* @__PURE__ */ i(o, { align: "center", style: {
47
- gap: "0.35rem"
48
- }, children: [
49
- r?.notValidMessage?.includes("4") ? /* @__PURE__ */ t(s, { color: "#D90429", size: 16 }) : /* @__PURE__ */ t(c, { color: "#29BF12", size: 16 }),
50
- /* @__PURE__ */ t(a, { children: "Must include a number" })
51
- ] }),
52
- /* @__PURE__ */ i(o, { align: "center", style: {
53
- gap: "0.35rem"
54
- }, children: [
55
- r?.notValidMessage?.includes("5") ? /* @__PURE__ */ t(s, { color: "#D90429", size: 16 }) : /* @__PURE__ */ t(c, { color: "#29BF12", size: 16 }),
56
- /* @__PURE__ */ t(a, { children: "Must include a special character" })
57
- ] })
31
+ /* @__PURE__ */ n(D, { value: M, max: 100, color: "linear-gradient(to right, #D90429 0%, #29BF12 100%)" }),
32
+ (() => {
33
+ const e = ["2", "3", "4", "5", "1"].find((w) => a.includes(w));
34
+ if (!e) return null;
35
+ const V = {
36
+ 1: "Must be at least 8 characters",
37
+ 2: "Must include a lowercase letter",
38
+ 3: "Must include an uppercase letter",
39
+ 4: "Must include a number",
40
+ 5: "Must include a special character"
41
+ }[e];
42
+ return /* @__PURE__ */ n(A, { children: V });
43
+ })()
58
44
  ] })
59
45
  ] });
60
- }), A = (n) => {
61
- if (!n) return "12345";
62
- let e = null;
63
- return n.length < 8 && (e = (e ?? "") + "1"), /[a-z]/.test(n) || (e = (e ?? "") + "2"), /[A-Z]/.test(n) || (e = (e ?? "") + "3"), /[0-9]/.test(n) || (e = (e ?? "") + "4"), /[^A-Za-z0-9]/.test(n) || (e = (e ?? "") + "5"), e;
46
+ }), X = (r) => {
47
+ if (!r) return "12345";
48
+ let t = null;
49
+ return r.length < 8 && (t = (t ?? "") + "1"), /[a-z]/.test(r) || (t = (t ?? "") + "2"), /[A-Z]/.test(r) || (t = (t ?? "") + "3"), /[0-9]/.test(r) || (t = (t ?? "") + "4"), /[^A-Za-z0-9]/.test(r) || (t = (t ?? "") + "5"), t;
64
50
  };
65
51
  export {
66
- v as PasswordInput,
67
- A as passwordValidation
52
+ L as PasswordInput,
53
+ X as passwordValidation
68
54
  };
@@ -1,24 +1,24 @@
1
- import j, { useState as g, useRef as y, useCallback as w, useEffect as P } from "react";
2
- function o(i, e, t) {
3
- return (e = O(e)) in i ? Object.defineProperty(i, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : i[e] = t, i;
1
+ import O, { useState as w, useRef as b, useCallback as M, useEffect as F } from "react";
2
+ function d(r, e, t) {
3
+ return (e = R(e)) in r ? Object.defineProperty(r, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : r[e] = t, r;
4
4
  }
5
- function O(i) {
6
- var e = F(i, "string");
5
+ function R(r) {
6
+ var e = _(r, "string");
7
7
  return typeof e == "symbol" ? e : e + "";
8
8
  }
9
- function F(i, e) {
10
- if (typeof i != "object" || !i) return i;
11
- var t = i[Symbol.toPrimitive];
9
+ function _(r, e) {
10
+ if (typeof r != "object" || !r) return r;
11
+ var t = r[Symbol.toPrimitive];
12
12
  if (t !== void 0) {
13
- var n = t.call(i, e);
14
- if (typeof n != "object") return n;
13
+ var i = t.call(r, e);
14
+ if (typeof i != "object") return i;
15
15
  throw new TypeError("@@toPrimitive must return a primitive value.");
16
16
  }
17
- return (e === "string" ? String : Number)(i);
17
+ return (e === "string" ? String : Number)(r);
18
18
  }
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;
19
+ class p {
20
+ constructor(e, t, i, l = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
21
+ d(this, "changeValue", void 0), d(this, "currentValues", void 0), d(this, "currentValidations", void 0), d(this, "shouldValidate", void 0), d(this, "cachedMessages", void 0), this.changeValue = e, this.currentValues = t, this.currentValidations = i, this.shouldValidate = l, this.cachedMessages = s;
22
22
  }
23
23
  isValid() {
24
24
  if (!this.currentValidations) return !0;
@@ -30,15 +30,15 @@ class f {
30
30
  return !0;
31
31
  }
32
32
  getInputProps(e) {
33
- const t = this.currentValues[e], n = t ?? null, l = e, u = this.currentValidations && this.currentValidations[e] ? this.currentValidations[e] : (s) => null;
33
+ const t = this.currentValues[e], i = t ?? null, l = e, s = this.currentValidations && this.currentValidations[e] ? this.currentValidations[e] : (u) => null;
34
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, {
35
+ return this.shouldValidate.has(e) ? (a = s(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: n ?? void 0,
38
- initialValue: n ?? void 0,
37
+ defaultValue: i ?? void 0,
38
+ initialValue: i ?? void 0,
39
39
  formValidation: {
40
- setValue: (s) => {
41
- this.changeValue(l, s);
40
+ setValue: (u) => {
41
+ this.changeValue(l, u);
42
42
  },
43
43
  notValidMessage: a,
44
44
  valid: a === null
@@ -49,28 +49,30 @@ class f {
49
49
  };
50
50
  }
51
51
  }
52
- const _ = (i) => {
52
+ const I = (r) => {
53
53
  const {
54
54
  initialValues: e,
55
55
  validate: t = {},
56
- truthyValidationBeforeSubmit: n = !0,
56
+ truthyValidationBeforeSubmit: i = !0,
57
57
  useInitialValidation: l = !0,
58
- onSubmit: u
59
- } = i, a = j.useMemo(() => e, [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));
58
+ onSubmit: s
59
+ } = r, a = O.useMemo(() => e, [e]), [u, v] = w(a), V = b(/* @__PURE__ */ new Map()), c = b(u);
60
+ c.current = u;
61
+ const h = M((n, f) => {
62
+ c.current = {
63
+ ...c.current,
64
+ [n]: f
65
+ }, v(c.current);
66
+ }, []), [S, m] = w(() => new p(h, u, t, l ? new Map(Object.keys(a).map((n) => [n, !0])) : /* @__PURE__ */ new Map(), V.current));
67
+ F(() => {
68
+ c.current = a, v(a), m(new p(h, a, t, l ? new Map(Object.keys(a).map((n) => [n, !0])) : /* @__PURE__ */ new Map(), V.current));
67
69
  }, [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];
70
+ const j = M((n, f = !0) => {
71
+ const o = c.current, y = n && new Set(Object.keys(o)).has(String(n)) ? /* @__PURE__ */ new Map([[n, !0]]) : new Map(Object.keys(o).map((P) => [String(P), !0])), g = new p(h, o, t, y, V.current);
72
+ m(g), f && !new Set(Object.keys(o)).has(String(n)) && s && (!i || g.isValid()) && s(o);
73
+ }, [h, t, s, i]);
74
+ return [S, j, u];
73
75
  };
74
76
  export {
75
- _ as useForm
77
+ I as useForm
76
78
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code0-tech/pictor",
3
- "version": "0.10.7",
3
+ "version": "0.10.9",
4
4
  "type": "module",
5
5
  "description": "A simple template for a custom React component library",
6
6
  "scripts": {