@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
|
|
2
|
-
import { c as
|
|
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
|
|
9
|
-
const t =
|
|
10
|
-
let o,
|
|
11
|
-
if (t[0] !==
|
|
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:
|
|
14
|
-
variant:
|
|
15
|
-
color:
|
|
16
|
-
paddingSize:
|
|
17
|
-
active:
|
|
18
|
-
disabled:
|
|
19
|
-
...
|
|
20
|
-
} =
|
|
21
|
-
o =
|
|
22
|
-
const
|
|
23
|
-
|
|
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],
|
|
26
|
-
const s =
|
|
27
|
-
let
|
|
28
|
-
return t[
|
|
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
|
-
|
|
31
|
+
k as Button
|
|
32
32
|
};
|
|
@@ -1,68 +1,54 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { Input as
|
|
4
|
-
import {
|
|
5
|
-
import { Button as
|
|
6
|
-
import { clearInputElement as
|
|
7
|
-
import { Flex as
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
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:
|
|
13
|
-
visible:
|
|
14
|
-
right:
|
|
15
|
-
formValidation:
|
|
13
|
+
clearable: p = !0,
|
|
14
|
+
visible: d = !0,
|
|
15
|
+
right: m,
|
|
16
|
+
formValidation: s,
|
|
16
17
|
...f
|
|
17
|
-
} =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
!
|
|
28
|
+
i && !s?.valid && /* @__PURE__ */ l(z, { mt: 0.7, style: {
|
|
26
29
|
flexDirection: "column"
|
|
27
30
|
}, children: [
|
|
28
|
-
/* @__PURE__ */
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
}),
|
|
61
|
-
if (!
|
|
62
|
-
let
|
|
63
|
-
return
|
|
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
|
-
|
|
67
|
-
|
|
52
|
+
L as PasswordInput,
|
|
53
|
+
X as passwordValidation
|
|
68
54
|
};
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
function
|
|
3
|
-
return (e =
|
|
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
|
|
6
|
-
var e =
|
|
5
|
+
function R(r) {
|
|
6
|
+
var e = _(r, "string");
|
|
7
7
|
return typeof e == "symbol" ? e : e + "";
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
if (typeof
|
|
11
|
-
var t =
|
|
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
|
|
14
|
-
if (typeof
|
|
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)(
|
|
17
|
+
return (e === "string" ? String : Number)(r);
|
|
18
18
|
}
|
|
19
|
-
class
|
|
20
|
-
constructor(e, t,
|
|
21
|
-
|
|
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],
|
|
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 =
|
|
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:
|
|
38
|
-
initialValue:
|
|
37
|
+
defaultValue: i ?? void 0,
|
|
38
|
+
initialValue: i ?? void 0,
|
|
39
39
|
formValidation: {
|
|
40
|
-
setValue: (
|
|
41
|
-
this.changeValue(l,
|
|
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
|
|
52
|
+
const I = (r) => {
|
|
53
53
|
const {
|
|
54
54
|
initialValues: e,
|
|
55
55
|
validate: t = {},
|
|
56
|
-
truthyValidationBeforeSubmit:
|
|
56
|
+
truthyValidationBeforeSubmit: i = !0,
|
|
57
57
|
useInitialValidation: l = !0,
|
|
58
|
-
onSubmit:
|
|
59
|
-
} =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
}, [
|
|
72
|
-
return [
|
|
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
|
-
|
|
77
|
+
I as useForm
|
|
76
78
|
};
|