@code0-tech/pictor 0.6.2 → 0.6.4
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.
|
@@ -5,9 +5,9 @@ import "../../utils/contextStore.js";
|
|
|
5
5
|
import "react";
|
|
6
6
|
import { mergeComponentProps as r } from "../../utils/component.js";
|
|
7
7
|
import "js-md5";
|
|
8
|
-
import {
|
|
8
|
+
import { DialogPortal as u, DialogContent as h, Dialog as g, DialogOverlay as C } from "../dialog/Dialog.js";
|
|
9
9
|
import '../../assets/components/form/Input.style.css';import '../../assets/components/command/Command.style.css';/* empty css */
|
|
10
|
-
import { Badge as
|
|
10
|
+
import { Badge as _ } from "../badge/Badge.js";
|
|
11
11
|
import "@radix-ui/react-checkbox";
|
|
12
12
|
import "@tabler/icons-react";
|
|
13
13
|
/* empty css */
|
|
@@ -20,35 +20,35 @@ import "@radix-ui/react-one-time-password-field";
|
|
|
20
20
|
import "@radix-ui/react-radio-group";
|
|
21
21
|
import "../form/SwitchInput.js";
|
|
22
22
|
import "../form/TextAreaInput.js";
|
|
23
|
-
import { TextInput as
|
|
24
|
-
const
|
|
23
|
+
import { TextInput as $ } from "../form/TextInput.js";
|
|
24
|
+
const P = (e) => {
|
|
25
25
|
const t = c.c(4);
|
|
26
26
|
let m;
|
|
27
27
|
t[0] !== e ? (m = r("command", e), t[0] = e, t[1] = m) : m = t[1];
|
|
28
28
|
const o = m;
|
|
29
29
|
let n;
|
|
30
30
|
return t[2] !== o ? (n = /* @__PURE__ */ l(a, { ...o }), t[2] = o, t[3] = n) : n = t[3], n;
|
|
31
|
-
},
|
|
31
|
+
}, H = (e) => {
|
|
32
32
|
const t = c.c(11);
|
|
33
33
|
let m;
|
|
34
34
|
t[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (m = /* @__PURE__ */ l(C, {}), t[0] = m) : m = t[0];
|
|
35
35
|
let o;
|
|
36
|
-
t[1] !== e ? (o = /* @__PURE__ */ l(
|
|
36
|
+
t[1] !== e ? (o = /* @__PURE__ */ l(P, { ...e, h: "100%", children: e.children }), t[1] = e, t[2] = o) : o = t[2];
|
|
37
37
|
let n;
|
|
38
|
-
t[3] !== e.contentProps || t[4] !== o ? (n = /* @__PURE__ */
|
|
39
|
-
let i;
|
|
40
|
-
return t[6] !== e.dialogProps || t[7] !== e.onOpenChange || t[8] !== e.open || t[9] !== n ? (i = /* @__PURE__ */ s(h, { ...e.dialogProps, open: e.open, onOpenChange: e.onOpenChange, children: [
|
|
38
|
+
t[3] !== e.contentProps || t[4] !== o ? (n = /* @__PURE__ */ s(u, { children: [
|
|
41
39
|
m,
|
|
42
|
-
|
|
43
|
-
] }), t[
|
|
44
|
-
|
|
40
|
+
/* @__PURE__ */ l(h, { className: "command__dialog", ...e.contentProps, children: o })
|
|
41
|
+
] }), t[3] = e.contentProps, t[4] = o, t[5] = n) : n = t[5];
|
|
42
|
+
let i;
|
|
43
|
+
return t[6] !== e.dialogProps || t[7] !== e.onOpenChange || t[8] !== e.open || t[9] !== n ? (i = /* @__PURE__ */ l(g, { ...e.dialogProps, open: e.open, onOpenChange: e.onOpenChange, children: n }), t[6] = e.dialogProps, t[7] = e.onOpenChange, t[8] = e.open, t[9] = n, t[10] = i) : i = t[10], i;
|
|
44
|
+
}, J = (e) => {
|
|
45
45
|
const t = c.c(4);
|
|
46
46
|
let m;
|
|
47
47
|
t[0] !== e ? (m = r("command__list", e), t[0] = e, t[1] = m) : m = t[1];
|
|
48
48
|
const o = m;
|
|
49
49
|
let n;
|
|
50
50
|
return t[2] !== o ? (n = /* @__PURE__ */ l(a.List, { ...o }), t[2] = o, t[3] = n) : n = t[3], n;
|
|
51
|
-
},
|
|
51
|
+
}, K = (e) => {
|
|
52
52
|
const t = c.c(10);
|
|
53
53
|
let m;
|
|
54
54
|
t[0] !== e.value ? (m = e.value?.toString(), t[0] = e.value, t[1] = m) : m = t[1];
|
|
@@ -64,53 +64,53 @@ const $ = (e) => {
|
|
|
64
64
|
}
|
|
65
65
|
}, t[2] = e, t[3] = o) : o = t[3];
|
|
66
66
|
let n;
|
|
67
|
-
t[4] !== e ? (n = /* @__PURE__ */ l(
|
|
67
|
+
t[4] !== e ? (n = /* @__PURE__ */ l($, { className: "command__input", ...e }), t[4] = e, t[5] = n) : n = t[5];
|
|
68
68
|
let i;
|
|
69
69
|
return t[6] !== m || t[7] !== o || t[8] !== n ? (i = /* @__PURE__ */ l(a.Input, { value: m, onValueChange: o, asChild: !0, children: n }), t[6] = m, t[7] = o, t[8] = n, t[9] = i) : i = t[9], i;
|
|
70
|
-
},
|
|
70
|
+
}, M = (e) => {
|
|
71
71
|
const t = c.c(4);
|
|
72
72
|
let m;
|
|
73
73
|
t[0] !== e ? (m = r("command__empty", e), t[0] = e, t[1] = m) : m = t[1];
|
|
74
74
|
const o = m;
|
|
75
75
|
let n;
|
|
76
76
|
return t[2] !== o ? (n = /* @__PURE__ */ l(a.Empty, { ...o }), t[2] = o, t[3] = n) : n = t[3], n;
|
|
77
|
-
},
|
|
77
|
+
}, Q = (e) => {
|
|
78
78
|
const t = c.c(4);
|
|
79
79
|
let m;
|
|
80
80
|
t[0] !== e ? (m = r("command__group", e), t[0] = e, t[1] = m) : m = t[1];
|
|
81
81
|
const o = m;
|
|
82
82
|
let n;
|
|
83
83
|
return t[2] !== o ? (n = /* @__PURE__ */ l(a.Group, { ...o }), t[2] = o, t[3] = n) : n = t[3], n;
|
|
84
|
-
},
|
|
84
|
+
}, U = (e) => {
|
|
85
85
|
const t = c.c(4);
|
|
86
86
|
let m;
|
|
87
87
|
t[0] !== e ? (m = r("command__item", e), t[0] = e, t[1] = m) : m = t[1];
|
|
88
88
|
const o = m;
|
|
89
89
|
let n;
|
|
90
90
|
return t[2] !== o ? (n = /* @__PURE__ */ l(a.Item, { ...o }), t[2] = o, t[3] = n) : n = t[3], n;
|
|
91
|
-
},
|
|
91
|
+
}, W = (e) => {
|
|
92
92
|
const t = c.c(4);
|
|
93
93
|
let m;
|
|
94
94
|
t[0] !== e ? (m = r("command__separator", e), t[0] = e, t[1] = m) : m = t[1];
|
|
95
95
|
const o = m;
|
|
96
96
|
let n;
|
|
97
97
|
return t[2] !== o ? (n = /* @__PURE__ */ l(a.Separator, { ...o }), t[2] = o, t[3] = n) : n = t[3], n;
|
|
98
|
-
},
|
|
98
|
+
}, X = (e) => {
|
|
99
99
|
const t = c.c(5);
|
|
100
100
|
let m;
|
|
101
101
|
t[0] !== e ? (m = r("command__shortcut", e), t[0] = e, t[1] = m) : m = t[1];
|
|
102
102
|
const o = m;
|
|
103
103
|
let n;
|
|
104
|
-
return t[2] !== e.children || t[3] !== o ? (n = /* @__PURE__ */ l(
|
|
104
|
+
return t[2] !== e.children || t[3] !== o ? (n = /* @__PURE__ */ l(_, { ...o, children: e.children }), t[2] = e.children, t[3] = o, t[4] = n) : n = t[4], n;
|
|
105
105
|
};
|
|
106
106
|
export {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
107
|
+
P as Command,
|
|
108
|
+
H as CommandDialog,
|
|
109
|
+
M as CommandEmpty,
|
|
110
|
+
Q as CommandGroup,
|
|
111
|
+
K as CommandInput,
|
|
112
|
+
U as CommandItem,
|
|
113
|
+
J as CommandList,
|
|
114
|
+
W as CommandSeparator,
|
|
115
|
+
X as CommandShortcut
|
|
116
116
|
};
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
1
|
+
import { jsxs as i, Fragment as M, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import u from "react";
|
|
3
3
|
import { Input as V } from "./Input.js";
|
|
4
4
|
import { IconX as s, IconCheck as c, IconEye as x } from "@tabler/icons-react";
|
|
5
|
-
import { Button as
|
|
6
|
-
import { clearInputElement as
|
|
5
|
+
import { Button as p } from "../button/Button.js";
|
|
6
|
+
import { clearInputElement as w } from "./Input.utils.js";
|
|
7
7
|
import { Flex as o } from "../flex/Flex.js";
|
|
8
8
|
import { Text as a } from "../text/Text.js";
|
|
9
|
-
const
|
|
10
|
-
e = e ||
|
|
9
|
+
const A = u.forwardRef((n, e) => {
|
|
10
|
+
e = e || u.useRef(null);
|
|
11
11
|
const {
|
|
12
12
|
clearable: m = !0,
|
|
13
|
-
visible:
|
|
14
|
-
right:
|
|
13
|
+
visible: h = !0,
|
|
14
|
+
right: g,
|
|
15
15
|
formValidation: r,
|
|
16
16
|
...f
|
|
17
|
-
} = n, z = (
|
|
18
|
-
return
|
|
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
19
|
/* @__PURE__ */ t(V, { right: d, rightType: "action", type: "password", ref: e, ...r ? {
|
|
20
20
|
formValidation: {
|
|
21
21
|
setValue: r.setValue,
|
|
22
22
|
valid: r.valid
|
|
23
23
|
}
|
|
24
24
|
} : {}, ...f }),
|
|
25
|
-
!r?.valid && /* @__PURE__ */
|
|
25
|
+
!r?.valid && /* @__PURE__ */ i(o, { mt: 0.7, style: {
|
|
26
26
|
flexDirection: "column"
|
|
27
27
|
}, children: [
|
|
28
|
-
/* @__PURE__ */
|
|
28
|
+
/* @__PURE__ */ i(o, { align: "center", style: {
|
|
29
29
|
gap: "0.35rem"
|
|
30
30
|
}, children: [
|
|
31
31
|
r?.notValidMessage?.includes("1") ? /* @__PURE__ */ t(s, { color: "#D90429", size: 16 }) : /* @__PURE__ */ t(c, { color: "#29BF12", size: 16 }),
|
|
32
32
|
/* @__PURE__ */ t(a, { children: "Must be at least 8 characters" })
|
|
33
33
|
] }),
|
|
34
|
-
/* @__PURE__ */
|
|
34
|
+
/* @__PURE__ */ i(o, { align: "center", style: {
|
|
35
35
|
gap: "0.35rem"
|
|
36
36
|
}, children: [
|
|
37
37
|
r?.notValidMessage?.includes("2") ? /* @__PURE__ */ t(s, { color: "#D90429", size: 16 }) : /* @__PURE__ */ t(c, { color: "#29BF12", size: 16 }),
|
|
38
38
|
/* @__PURE__ */ t(a, { children: "Must include a lowercase letter" })
|
|
39
39
|
] }),
|
|
40
|
-
/* @__PURE__ */
|
|
40
|
+
/* @__PURE__ */ i(o, { align: "center", style: {
|
|
41
41
|
gap: "0.35rem"
|
|
42
42
|
}, children: [
|
|
43
43
|
r?.notValidMessage?.includes("3") ? /* @__PURE__ */ t(s, { color: "#D90429", size: 16 }) : /* @__PURE__ */ t(c, { color: "#29BF12", size: 16 }),
|
|
44
44
|
/* @__PURE__ */ t(a, { children: "Must include an uppercase letter" })
|
|
45
45
|
] }),
|
|
46
|
-
/* @__PURE__ */
|
|
46
|
+
/* @__PURE__ */ i(o, { align: "center", style: {
|
|
47
47
|
gap: "0.35rem"
|
|
48
48
|
}, children: [
|
|
49
49
|
r?.notValidMessage?.includes("4") ? /* @__PURE__ */ t(s, { color: "#D90429", size: 16 }) : /* @__PURE__ */ t(c, { color: "#29BF12", size: 16 }),
|
|
50
50
|
/* @__PURE__ */ t(a, { children: "Must include a number" })
|
|
51
51
|
] }),
|
|
52
|
-
/* @__PURE__ */
|
|
52
|
+
/* @__PURE__ */ i(o, { align: "center", style: {
|
|
53
53
|
gap: "0.35rem"
|
|
54
54
|
}, children: [
|
|
55
55
|
r?.notValidMessage?.includes("5") ? /* @__PURE__ */ t(s, { color: "#D90429", size: 16 }) : /* @__PURE__ */ t(c, { color: "#29BF12", size: 16 }),
|
|
@@ -57,12 +57,12 @@ const E = p.forwardRef((n, e) => {
|
|
|
57
57
|
] })
|
|
58
58
|
] })
|
|
59
59
|
] });
|
|
60
|
-
}),
|
|
60
|
+
}), E = (n) => {
|
|
61
61
|
if (!n) return "12345";
|
|
62
62
|
let e = null;
|
|
63
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;
|
|
64
64
|
};
|
|
65
65
|
export {
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
A as PasswordInput,
|
|
67
|
+
E as passwordValidation
|
|
68
68
|
};
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
function
|
|
3
|
-
return (
|
|
1
|
+
import { useState as m, useRef as w, useCallback as b, useEffect as j } from "react";
|
|
2
|
+
function c(a, e, t) {
|
|
3
|
+
return (e = y(e)) in a ? Object.defineProperty(a, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : a[e] = t, a;
|
|
4
4
|
}
|
|
5
|
-
function
|
|
6
|
-
var
|
|
7
|
-
return typeof
|
|
5
|
+
function y(a) {
|
|
6
|
+
var e = P(a, "string");
|
|
7
|
+
return typeof e == "symbol" ? e : e + "";
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
if (typeof
|
|
11
|
-
var
|
|
12
|
-
if (
|
|
13
|
-
var
|
|
14
|
-
if (typeof
|
|
9
|
+
function P(a, e) {
|
|
10
|
+
if (typeof a != "object" || !a) return a;
|
|
11
|
+
var t = a[Symbol.toPrimitive];
|
|
12
|
+
if (t !== void 0) {
|
|
13
|
+
var i = t.call(a, e);
|
|
14
|
+
if (typeof i != "object") return i;
|
|
15
15
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
16
16
|
}
|
|
17
|
-
return (
|
|
17
|
+
return (e === "string" ? String : Number)(a);
|
|
18
18
|
}
|
|
19
|
-
class
|
|
20
|
-
constructor(
|
|
21
|
-
|
|
19
|
+
class v {
|
|
20
|
+
constructor(e, t, i, u = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map()) {
|
|
21
|
+
c(this, "changeValue", void 0), c(this, "currentValues", void 0), c(this, "currentValidations", void 0), c(this, "shouldValidate", void 0), c(this, "cachedMessages", void 0), this.changeValue = e, this.currentValues = t, this.currentValidations = i, this.shouldValidate = u, this.cachedMessages = r;
|
|
22
22
|
}
|
|
23
23
|
isValid() {
|
|
24
24
|
if (!this.currentValidations) return !0;
|
|
25
|
-
for (const
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
25
|
+
for (const e in this.currentValidations) {
|
|
26
|
+
const t = this.currentValidations[e];
|
|
27
|
+
if (t && t(this.currentValues[e], this.currentValues) !== null)
|
|
28
28
|
return !1;
|
|
29
29
|
}
|
|
30
30
|
return !0;
|
|
31
31
|
}
|
|
32
|
-
getInputProps(
|
|
33
|
-
const
|
|
32
|
+
getInputProps(e) {
|
|
33
|
+
const t = this.currentValues[e], i = t ?? null, u = e, r = this.currentValidations && this.currentValidations[e] ? this.currentValidations[e] : (l) => null;
|
|
34
34
|
let s = null;
|
|
35
|
-
return this.shouldValidate.has(
|
|
35
|
+
return this.shouldValidate.has(e) ? (s = r(t, this.currentValues), this.cachedMessages.set(e, s)) : s = this.cachedMessages.get(e) ?? null, {
|
|
36
36
|
// @ts-ignore – z.B. wenn dein Input `defaultValue` kennt
|
|
37
|
-
defaultValue:
|
|
38
|
-
initialValue:
|
|
37
|
+
defaultValue: i,
|
|
38
|
+
initialValue: i ?? void 0,
|
|
39
39
|
formValidation: {
|
|
40
40
|
setValue: (l) => {
|
|
41
41
|
this.changeValue(u, l);
|
|
@@ -43,36 +43,36 @@ class b {
|
|
|
43
43
|
notValidMessage: s,
|
|
44
44
|
valid: s === null
|
|
45
45
|
},
|
|
46
|
-
...this.currentValidations && this.currentValidations[
|
|
46
|
+
...this.currentValidations && this.currentValidations[e] ? {
|
|
47
47
|
required: !0
|
|
48
48
|
} : {}
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
const F = (
|
|
52
|
+
const F = (a) => {
|
|
53
53
|
const {
|
|
54
|
-
initialValues:
|
|
55
|
-
validate:
|
|
56
|
-
truthyValidationBeforeSubmit:
|
|
54
|
+
initialValues: e,
|
|
55
|
+
validate: t = {},
|
|
56
|
+
truthyValidationBeforeSubmit: i = !0,
|
|
57
57
|
useInitialValidation: u = !0,
|
|
58
58
|
onSubmit: r
|
|
59
|
-
} =
|
|
60
|
-
l((
|
|
61
|
-
const
|
|
62
|
-
...
|
|
63
|
-
[n]:
|
|
59
|
+
} = a, [s, l] = m(e), o = w(e), f = w(/* @__PURE__ */ new Map()), d = b((n, p) => {
|
|
60
|
+
l((h) => {
|
|
61
|
+
const V = {
|
|
62
|
+
...h,
|
|
63
|
+
[n]: p
|
|
64
64
|
};
|
|
65
|
-
return
|
|
65
|
+
return o.current = V, V;
|
|
66
66
|
});
|
|
67
|
-
}, []), [
|
|
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
68
|
j(() => {
|
|
69
|
-
l(
|
|
70
|
-
}, [
|
|
71
|
-
const S =
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
}, [
|
|
75
|
-
return [
|
|
69
|
+
l(e), o.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, o.current, t, p, f.current);
|
|
73
|
+
g(h), !new Set(Object.keys(e)).has(String(n)) && r && (!i || h.isValid()) && r(o.current);
|
|
74
|
+
}, [d, t, r, i, e]);
|
|
75
|
+
return [M, S];
|
|
76
76
|
};
|
|
77
77
|
export {
|
|
78
78
|
F as useForm
|