@code0-tech/pictor 0.11.0 → 0.12.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.
- package/dist/assets/components/avatar/Avatar.style.css +1 -1
- package/dist/assets/components/card/Card.style.css +1 -1
- package/dist/assets/components/context-menu/ContextMenu.style.css +1 -1
- package/dist/assets/components/data-table/DataTable.style.css +1 -1
- package/dist/assets/components/form/Input.style.css +1 -1
- package/dist/assets/components/menu/Menu.style.css +1 -1
- package/dist/assets/components/scroll-area/ScrollArea.style.css +1 -1
- package/dist/assets/components/tooltip/Tooltip.style.css +1 -1
- package/dist/components/avatar/Avatar.js +17 -16
- package/dist/components/card/Card.d.ts +1 -0
- package/dist/components/card/Card.js +25 -23
- package/dist/components/context-menu/ContextMenu.js +109 -90
- package/dist/components/data-table/DataTable.d.ts +4 -1
- package/dist/components/data-table/DataTable.js +53 -31
- package/dist/components/data-table/DataTableHeader.d.ts +14 -0
- package/dist/components/data-table/DataTableHeader.js +39 -0
- package/dist/components/data-table/DataTablePagination.d.ts +30 -0
- package/dist/components/data-table/DataTablePagination.js +75 -0
- package/dist/components/data-table/index.d.ts +2 -0
- package/dist/components/data-table/index.js +16 -5
- package/dist/components/form/PinInput.js +44 -47
- package/dist/components/form/useForm.js +61 -46
- package/dist/components/menu/Menu.js +112 -93
- package/dist/components/scroll-area/ScrollArea.d.ts +8 -0
- package/dist/components/scroll-area/ScrollArea.js +70 -39
- package/dist/components/tooltip/Tooltip.js +53 -43
- package/dist/index.js +203 -191
- package/package.json +11 -11
|
@@ -1,42 +1,64 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
1
|
+
import { jsxs as x, jsx as y } from "react/jsx-runtime";
|
|
2
|
+
import c from "react";
|
|
3
3
|
import '../../assets/components/data-table/DataTable.style.css';/* empty css */
|
|
4
4
|
import "../../utils/contextStore.js";
|
|
5
|
-
import { mergeComponentProps as
|
|
5
|
+
import { mergeComponentProps as E } from "../../utils/component.js";
|
|
6
6
|
import "js-md5";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
import { Flex as F } from "../flex/Flex.js";
|
|
8
|
+
import { DataTableHeader as R } from "./DataTableHeader.js";
|
|
9
|
+
import { DataTablePaginationContext as v } from "./DataTablePagination.js";
|
|
10
|
+
const C = (u, p) => p.split(".").reduce((n, m) => {
|
|
11
|
+
if (n != null)
|
|
12
|
+
return Array.isArray(n) ? n.map((i) => i?.[m]).filter((i) => i !== void 0) : n[m];
|
|
13
|
+
}, u), U = (u) => {
|
|
11
14
|
const {
|
|
12
|
-
data:
|
|
13
|
-
sort:
|
|
14
|
-
filter:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
data: p,
|
|
16
|
+
sort: n,
|
|
17
|
+
filter: m,
|
|
18
|
+
limit: i,
|
|
19
|
+
pagination: A,
|
|
20
|
+
loading: _,
|
|
21
|
+
loadingComponent: z,
|
|
22
|
+
emptyComponent: D,
|
|
23
|
+
onSelect: N,
|
|
24
|
+
children: g,
|
|
25
|
+
...k
|
|
26
|
+
} = u, [b, P] = c.useState(0), h = Array.isArray(g) ? g : [g], w = h.find((r) => typeof r == "function"), V = h.find((r) => c.isValidElement(r) && r.type === R), S = h.filter((r) => typeof r != "function" && r !== V), O = p.filter((r) => Object.entries(m || {}).every(([o, {
|
|
27
|
+
operator: a,
|
|
28
|
+
value: e
|
|
24
29
|
}]) => {
|
|
25
|
-
const
|
|
26
|
-
return
|
|
27
|
-
})),
|
|
28
|
-
for (const [
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
31
|
-
if (
|
|
30
|
+
const t = C(r, o);
|
|
31
|
+
return a === "isOneOf" && !Array.isArray(e) && !Array.isArray(t) ? t === e : a === "isOneOf" && !Array.isArray(e) && Array.isArray(t) ? Array.from(t).includes(e) : a === "isOneOf" && Array.isArray(e) && !Array.isArray(t) ? Array.from(e).some((l) => l === t) : a === "isOneOf" && Array.isArray(e) && Array.isArray(t) ? Array.from(e).some((l) => Array.from(t).includes(l)) : !1;
|
|
32
|
+
})), f = c.useMemo(() => n ? [...O].sort((r, o) => {
|
|
33
|
+
for (const [a, e] of Object.entries(n)) {
|
|
34
|
+
const t = C(r, a), l = C(o, a);
|
|
35
|
+
if (t < l) return e === "asc" ? -1 : 1;
|
|
36
|
+
if (t > l) return e === "asc" ? 1 : -1;
|
|
32
37
|
}
|
|
33
38
|
return 0;
|
|
34
|
-
}) :
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
}) : O, [O, n]), d = typeof i == "number" ? i : 10, j = A ? Math.max(1, Math.ceil(f.length / d)) : 1, s = Math.min(b, j - 1);
|
|
40
|
+
c.useEffect(() => {
|
|
41
|
+
b !== s && P(s);
|
|
42
|
+
}, [b, s]);
|
|
43
|
+
const T = A ? f.slice(s * d, s * d + d) : typeof i == "number" ? f.slice(0, i) : f, M = /* @__PURE__ */ x("table", { ...E("data-table", k), children: [
|
|
44
|
+
V,
|
|
45
|
+
/* @__PURE__ */ x("tbody", { children: [
|
|
46
|
+
T.map((r, o) => /* @__PURE__ */ y("tr", { className: "data-table__row", onClick: () => N?.(r), children: w?.(r, o) })),
|
|
47
|
+
f.length === 0 && !_ && D ? /* @__PURE__ */ y("tr", { className: "data-table__row", onClick: () => N?.(void 0), children: D }) : null
|
|
48
|
+
] })
|
|
38
49
|
] });
|
|
50
|
+
return A ? /* @__PURE__ */ y(v.Provider, { value: {
|
|
51
|
+
page: s,
|
|
52
|
+
pageCount: j,
|
|
53
|
+
setPage: P
|
|
54
|
+
}, children: /* @__PURE__ */ x(F, { style: {
|
|
55
|
+
flexDirection: "column",
|
|
56
|
+
gap: "0.5rem"
|
|
57
|
+
}, children: [
|
|
58
|
+
M,
|
|
59
|
+
S.map((r, o) => /* @__PURE__ */ y(c.Fragment, { children: r }, o))
|
|
60
|
+
] }) }) : M;
|
|
39
61
|
};
|
|
40
62
|
export {
|
|
41
|
-
|
|
63
|
+
U as DataTable
|
|
42
64
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { Component } from '../../utils';
|
|
3
|
+
export interface DataTableHeaderProps extends Component<HTMLTableSectionElement> {
|
|
4
|
+
children?: React.ReactNode | React.ReactNode[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Optional header for a <DataTable/>. Place it as a child (alongside the row renderer) and fill it
|
|
8
|
+
* with <DataTableHeaderColumn/> cells that line up with the columns your row renderer emits.
|
|
9
|
+
*/
|
|
10
|
+
export declare const DataTableHeader: React.FC<DataTableHeaderProps>;
|
|
11
|
+
export interface DataTableHeaderColumnProps extends Component<HTMLTableCellElement> {
|
|
12
|
+
children?: React.ReactNode | React.ReactNode[];
|
|
13
|
+
}
|
|
14
|
+
export declare const DataTableHeaderColumn: React.FC<DataTableHeaderColumnProps>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "../../_virtual/compiler-runtime.js";
|
|
3
|
+
import "../../utils/contextStore.js";
|
|
4
|
+
import "react";
|
|
5
|
+
import { mergeComponentProps as m } from "../../utils/component.js";
|
|
6
|
+
import "js-md5";
|
|
7
|
+
const p = (a) => {
|
|
8
|
+
const e = c.c(8);
|
|
9
|
+
let t, r;
|
|
10
|
+
if (e[0] !== a) {
|
|
11
|
+
const {
|
|
12
|
+
children: i,
|
|
13
|
+
...s
|
|
14
|
+
} = a;
|
|
15
|
+
t = i, r = m("data-table__header", s), e[0] = a, e[1] = t, e[2] = r;
|
|
16
|
+
} else
|
|
17
|
+
t = e[1], r = e[2];
|
|
18
|
+
let l;
|
|
19
|
+
e[3] !== t ? (l = /* @__PURE__ */ n("tr", { className: "data-table__header-row", children: t }), e[3] = t, e[4] = l) : l = e[4];
|
|
20
|
+
let o;
|
|
21
|
+
return e[5] !== r || e[6] !== l ? (o = /* @__PURE__ */ n("thead", { ...r, children: l }), e[5] = r, e[6] = l, e[7] = o) : o = e[7], o;
|
|
22
|
+
}, x = (a) => {
|
|
23
|
+
const e = c.c(6);
|
|
24
|
+
let t, r;
|
|
25
|
+
if (e[0] !== a) {
|
|
26
|
+
const {
|
|
27
|
+
children: o,
|
|
28
|
+
...i
|
|
29
|
+
} = a;
|
|
30
|
+
t = o, r = m("data-table__header-column", i), e[0] = a, e[1] = t, e[2] = r;
|
|
31
|
+
} else
|
|
32
|
+
t = e[1], r = e[2];
|
|
33
|
+
let l;
|
|
34
|
+
return e[3] !== t || e[4] !== r ? (l = /* @__PURE__ */ n("th", { ...r, children: t }), e[3] = t, e[4] = r, e[5] = l) : l = e[5], l;
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
p as DataTableHeader,
|
|
38
|
+
x as DataTableHeaderColumn
|
|
39
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { Component } from '../../utils';
|
|
3
|
+
export interface DataTablePaginationContextValue {
|
|
4
|
+
page: number;
|
|
5
|
+
pageCount: number;
|
|
6
|
+
setPage: React.Dispatch<React.SetStateAction<number>>;
|
|
7
|
+
}
|
|
8
|
+
export declare const DataTablePaginationContext: React.Context<DataTablePaginationContextValue | null>;
|
|
9
|
+
export declare const useDataTablePagination: () => DataTablePaginationContextValue;
|
|
10
|
+
export interface DataTablePaginationProps extends Component<HTMLDivElement> {
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Layout container for the pagination controls. Place it as a child of a paginated
|
|
14
|
+
* <DataTable/>, which creates the context these controls read from. Fully styleable –
|
|
15
|
+
* compose it with <DataTablePaginationValue/>, the triggers and your own <Text/>/<Button/>.
|
|
16
|
+
*/
|
|
17
|
+
export declare const DataTablePagination: React.FC<DataTablePaginationProps>;
|
|
18
|
+
/**
|
|
19
|
+
* Renders the 1-indexed current page number. Unstyled – wrap it in your own <Text/> to style it.
|
|
20
|
+
*/
|
|
21
|
+
export declare const DataTablePaginationValue: React.FC;
|
|
22
|
+
/**
|
|
23
|
+
* Renders the total number of pages. Unstyled – wrap it in your own <Text/> to style it.
|
|
24
|
+
*/
|
|
25
|
+
export declare const DataTableMaxPaginationValue: React.FC;
|
|
26
|
+
export interface DataTablePaginationTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
27
|
+
asChild?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare const DataTablePaginationForwardTrigger: React.ForwardRefExoticComponent<DataTablePaginationTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
30
|
+
export declare const DataTablePaginationBackwardsTrigger: React.ForwardRefExoticComponent<DataTablePaginationTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsx as r, Fragment as f } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "../../_virtual/compiler-runtime.js";
|
|
3
|
+
import i from "react";
|
|
4
|
+
import "../../utils/contextStore.js";
|
|
5
|
+
import { mergeComponentProps as x } from "../../utils/component.js";
|
|
6
|
+
import "js-md5";
|
|
7
|
+
const h = i.createContext(null), d = () => {
|
|
8
|
+
const a = i.useContext(h);
|
|
9
|
+
if (!a)
|
|
10
|
+
throw new Error("DataTablePagination components must be rendered inside a paginated <DataTable/>");
|
|
11
|
+
return a;
|
|
12
|
+
}, V = (a) => {
|
|
13
|
+
const e = c.c(4);
|
|
14
|
+
let t;
|
|
15
|
+
e[0] !== a ? (t = x("data-table__pagination", a), e[0] = a, e[1] = t) : t = e[1];
|
|
16
|
+
let n;
|
|
17
|
+
return e[2] !== t ? (n = /* @__PURE__ */ r("div", { ...t }), e[2] = t, e[3] = n) : n = e[3], n;
|
|
18
|
+
}, y = () => {
|
|
19
|
+
const a = c.c(2), {
|
|
20
|
+
page: e
|
|
21
|
+
} = d(), t = e + 1;
|
|
22
|
+
let n;
|
|
23
|
+
return a[0] !== t ? (n = /* @__PURE__ */ r(f, { children: t }), a[0] = t, a[1] = n) : n = a[1], n;
|
|
24
|
+
}, B = () => {
|
|
25
|
+
const a = c.c(2), {
|
|
26
|
+
pageCount: e
|
|
27
|
+
} = d();
|
|
28
|
+
let t;
|
|
29
|
+
return a[0] !== e ? (t = /* @__PURE__ */ r(f, { children: e }), a[0] = e, a[1] = t) : t = a[1], t;
|
|
30
|
+
}, T = i.forwardRef((a, e) => {
|
|
31
|
+
const {
|
|
32
|
+
page: t,
|
|
33
|
+
pageCount: n,
|
|
34
|
+
setPage: w
|
|
35
|
+
} = d(), {
|
|
36
|
+
direction: g,
|
|
37
|
+
asChild: C,
|
|
38
|
+
onClick: u,
|
|
39
|
+
disabled: P,
|
|
40
|
+
children: l,
|
|
41
|
+
...p
|
|
42
|
+
} = a, D = g === "forward" ? t >= n - 1 : t <= 0, s = P ?? D, m = () => {
|
|
43
|
+
s || w((o) => g === "forward" ? Math.min(n - 1, o + 1) : Math.max(0, o - 1));
|
|
44
|
+
};
|
|
45
|
+
if (C && i.isValidElement(l)) {
|
|
46
|
+
const o = l;
|
|
47
|
+
return i.cloneElement(o, {
|
|
48
|
+
ref: e,
|
|
49
|
+
disabled: o.props.disabled ?? s,
|
|
50
|
+
onClick: (b) => {
|
|
51
|
+
o.props.onClick?.(b), u?.(b), m();
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return /* @__PURE__ */ r("button", { ...p, ref: e, type: "button", disabled: s, onClick: (o) => {
|
|
56
|
+
u?.(o), m();
|
|
57
|
+
}, children: l });
|
|
58
|
+
}), F = i.forwardRef((a, e) => {
|
|
59
|
+
const t = c.c(3);
|
|
60
|
+
let n;
|
|
61
|
+
return t[0] !== a || t[1] !== e ? (n = /* @__PURE__ */ r(T, { ...a, direction: "forward", ref: e }), t[0] = a, t[1] = e, t[2] = n) : n = t[2], n;
|
|
62
|
+
}), j = i.forwardRef((a, e) => {
|
|
63
|
+
const t = c.c(3);
|
|
64
|
+
let n;
|
|
65
|
+
return t[0] !== a || t[1] !== e ? (n = /* @__PURE__ */ r(T, { ...a, direction: "backward", ref: e }), t[0] = a, t[1] = e, t[2] = n) : n = t[2], n;
|
|
66
|
+
});
|
|
67
|
+
export {
|
|
68
|
+
B as DataTableMaxPaginationValue,
|
|
69
|
+
V as DataTablePagination,
|
|
70
|
+
j as DataTablePaginationBackwardsTrigger,
|
|
71
|
+
h as DataTablePaginationContext,
|
|
72
|
+
F as DataTablePaginationForwardTrigger,
|
|
73
|
+
y as DataTablePaginationValue,
|
|
74
|
+
d as useDataTablePagination
|
|
75
|
+
};
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import { DataTable as t } from "./DataTable.js";
|
|
2
2
|
import { DataTableColumn as o } from "./DataTableColumn.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { DataTableHeader as i, DataTableHeaderColumn as l } from "./DataTableHeader.js";
|
|
4
|
+
import { DataTableMaxPaginationValue as T, DataTablePagination as b, DataTablePaginationBackwardsTrigger as D, DataTablePaginationContext as u, DataTablePaginationForwardTrigger as m, DataTablePaginationValue as x, useDataTablePagination as p } from "./DataTablePagination.js";
|
|
5
|
+
import { DataTableFilterInput as f, createFilterQueryLanguage as d } from "./DataTableFilterInput.js";
|
|
6
|
+
import { DataTableFilterSuggestionMenu as s } from "./DataTableFilterSuggestionMenu.js";
|
|
5
7
|
export {
|
|
6
8
|
t as DataTable,
|
|
7
9
|
o as DataTableColumn,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
f as DataTableFilterInput,
|
|
11
|
+
s as DataTableFilterSuggestionMenu,
|
|
12
|
+
i as DataTableHeader,
|
|
13
|
+
l as DataTableHeaderColumn,
|
|
14
|
+
T as DataTableMaxPaginationValue,
|
|
15
|
+
b as DataTablePagination,
|
|
16
|
+
D as DataTablePaginationBackwardsTrigger,
|
|
17
|
+
u as DataTablePaginationContext,
|
|
18
|
+
m as DataTablePaginationForwardTrigger,
|
|
19
|
+
x as DataTablePaginationValue,
|
|
20
|
+
d as createFilterQueryLanguage,
|
|
21
|
+
p as useDataTablePagination
|
|
11
22
|
};
|
|
@@ -1,69 +1,66 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { c
|
|
3
|
-
import { OneTimePasswordFieldInput as
|
|
1
|
+
import { jsx as a, jsxs as v, Fragment as F } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "../../_virtual/compiler-runtime.js";
|
|
3
|
+
import { OneTimePasswordFieldInput as x, OneTimePasswordFieldHiddenInput as C, OneTimePasswordField as M } from "@radix-ui/react-one-time-password-field";
|
|
4
4
|
import "../../utils/contextStore.js";
|
|
5
5
|
import "react";
|
|
6
6
|
import { mergeComponentProps as V } from "../../utils/component.js";
|
|
7
7
|
import "js-md5";
|
|
8
|
-
import { InputLabel as
|
|
9
|
-
import { InputDescription as
|
|
10
|
-
import { InputMessage as
|
|
8
|
+
import { InputLabel as T } from "./InputLabel.js";
|
|
9
|
+
import { InputDescription as _ } from "./InputDescription.js";
|
|
10
|
+
import { InputMessage as $ } from "./InputMessage.js";
|
|
11
11
|
import '../../assets/components/form/Input.style.css';/* empty css */
|
|
12
|
-
const
|
|
13
|
-
const e =
|
|
14
|
-
let t, i,
|
|
12
|
+
const z = (n) => {
|
|
13
|
+
const e = c.c(20);
|
|
14
|
+
let t, i, s, l, o;
|
|
15
15
|
if (e[0] !== n) {
|
|
16
16
|
const {
|
|
17
|
-
title:
|
|
18
|
-
description:
|
|
19
|
-
disabled:
|
|
20
|
-
formValidation:
|
|
21
|
-
...
|
|
22
|
-
} = n;
|
|
23
|
-
i =
|
|
17
|
+
title: u,
|
|
18
|
+
description: f,
|
|
19
|
+
disabled: g,
|
|
20
|
+
formValidation: h,
|
|
21
|
+
...p
|
|
22
|
+
} = n, P = g === void 0 ? !1 : g;
|
|
23
|
+
i = h === void 0 ? {
|
|
24
24
|
valid: !0,
|
|
25
25
|
notValidMessage: null,
|
|
26
|
-
setValue:
|
|
27
|
-
} :
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
g.onValueChange && g.onValueChange(v), i.setValue?.(v);
|
|
26
|
+
setValue: b
|
|
27
|
+
} : h, e[6] !== u ? (l = u ? /* @__PURE__ */ a(T, { children: u }) : null, e[6] = u, e[7] = l) : l = e[7], e[8] !== f ? (o = f ? /* @__PURE__ */ a(_, { children: f }) : null, e[8] = f, e[9] = o) : o = e[9], t = M, s = V(`pin-input ${i?.valid ? "" : "pin-input--not-valid"}`, {
|
|
28
|
+
...p,
|
|
29
|
+
disabled: P,
|
|
30
|
+
onValueChange: (I) => {
|
|
31
|
+
p.onValueChange && p.onValueChange(I), i.setValue?.(I);
|
|
33
32
|
}
|
|
34
|
-
}), e[0] = n, e[1] = t, e[2] = i, e[3] =
|
|
33
|
+
}), e[0] = n, e[1] = t, e[2] = i, e[3] = s, e[4] = l, e[5] = o;
|
|
35
34
|
} else
|
|
36
|
-
t = e[1], i = e[2],
|
|
37
|
-
let
|
|
38
|
-
e[
|
|
35
|
+
t = e[1], i = e[2], s = e[3], l = e[4], o = e[5];
|
|
36
|
+
let r;
|
|
37
|
+
e[10] !== t || e[11] !== s ? (r = /* @__PURE__ */ a(t, { ...s }), e[10] = t, e[11] = s, e[12] = r) : r = e[12];
|
|
38
|
+
let d;
|
|
39
|
+
e[13] !== i ? (d = !i?.valid && i?.notValidMessage ? /* @__PURE__ */ a($, { children: i.notValidMessage }) : null, e[13] = i, e[14] = d) : d = e[14];
|
|
39
40
|
let m;
|
|
40
|
-
e[
|
|
41
|
-
|
|
42
|
-
e[19] !== i ? (u = !i?.valid && i?.notValidMessage ? /* @__PURE__ */ r(w, { children: i.notValidMessage }) : null, e[19] = i, e[20] = u) : u = e[20];
|
|
43
|
-
let f;
|
|
44
|
-
return e[21] !== o || e[22] !== s || e[23] !== m || e[24] !== u ? (f = /* @__PURE__ */ F(x, { children: [
|
|
41
|
+
return e[15] !== l || e[16] !== o || e[17] !== r || e[18] !== d ? (m = /* @__PURE__ */ v(F, { children: [
|
|
42
|
+
l,
|
|
45
43
|
o,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const e = I.c(4);
|
|
44
|
+
r,
|
|
45
|
+
d
|
|
46
|
+
] }), e[15] = l, e[16] = o, e[17] = r, e[18] = d, e[19] = m) : m = e[19], m;
|
|
47
|
+
}, A = (n) => {
|
|
48
|
+
const e = c.c(4);
|
|
52
49
|
let t;
|
|
53
|
-
e[0] !== n ? (t = V("
|
|
50
|
+
e[0] !== n ? (t = V("pin-input__field", n), e[0] = n, e[1] = t) : t = e[1];
|
|
54
51
|
let i;
|
|
55
|
-
return e[2] !== t ? (i = /* @__PURE__ */
|
|
56
|
-
},
|
|
57
|
-
const e =
|
|
52
|
+
return e[2] !== t ? (i = /* @__PURE__ */ a(x, { ...t }), e[2] = t, e[3] = i) : i = e[3], i;
|
|
53
|
+
}, B = (n) => {
|
|
54
|
+
const e = c.c(4);
|
|
58
55
|
let t;
|
|
59
56
|
e[0] !== n ? (t = V("pin-input__hidden-field", n), e[0] = n, e[1] = t) : t = e[1];
|
|
60
57
|
let i;
|
|
61
|
-
return e[2] !== t ? (i = /* @__PURE__ */
|
|
58
|
+
return e[2] !== t ? (i = /* @__PURE__ */ a(C, { ...t }), e[2] = t, e[3] = i) : i = e[3], i;
|
|
62
59
|
};
|
|
63
|
-
function
|
|
60
|
+
function b(n) {
|
|
64
61
|
}
|
|
65
62
|
export {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
z as PinInput,
|
|
64
|
+
A as PinInputField,
|
|
65
|
+
B as PinInputHiddenField
|
|
69
66
|
};
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
function
|
|
3
|
-
return (e =
|
|
1
|
+
import y, { useState as P, useRef as v, useCallback as j, useEffect as I } from "react";
|
|
2
|
+
function h(s, e, t) {
|
|
3
|
+
return (e = _(e)) in s ? Object.defineProperty(s, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : s[e] = t, s;
|
|
4
4
|
}
|
|
5
|
-
function
|
|
6
|
-
var e =
|
|
5
|
+
function _(s) {
|
|
6
|
+
var e = B(s, "string");
|
|
7
7
|
return typeof e == "symbol" ? e : e + "";
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
if (typeof
|
|
11
|
-
var t =
|
|
9
|
+
function B(s, e) {
|
|
10
|
+
if (typeof s != "object" || !s) return s;
|
|
11
|
+
var t = s[Symbol.toPrimitive];
|
|
12
12
|
if (t !== void 0) {
|
|
13
|
-
var
|
|
14
|
-
if (typeof
|
|
13
|
+
var n = t.call(s, e);
|
|
14
|
+
if (typeof n != "object") return n;
|
|
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)(s);
|
|
18
18
|
}
|
|
19
|
-
class
|
|
20
|
-
constructor(e, t,
|
|
21
|
-
|
|
19
|
+
class w {
|
|
20
|
+
constructor(e, t, n, V = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map()) {
|
|
21
|
+
h(this, "changeValue", void 0), h(this, "currentValues", void 0), h(this, "currentValidations", void 0), h(this, "shouldValidate", void 0), h(this, "cachedMessages", void 0), h(this, "cachedSetters", void 0), h(this, "cachedProps", void 0), this.changeValue = e, this.currentValues = t, this.currentValidations = n, this.shouldValidate = V, this.cachedMessages = l, this.cachedSetters = r, this.cachedProps = a;
|
|
22
22
|
}
|
|
23
23
|
isValid() {
|
|
24
24
|
if (!this.currentValidations) return !0;
|
|
@@ -30,49 +30,64 @@ class p {
|
|
|
30
30
|
return !0;
|
|
31
31
|
}
|
|
32
32
|
getInputProps(e) {
|
|
33
|
-
const t = this.currentValues[e],
|
|
34
|
-
let
|
|
35
|
-
|
|
33
|
+
const t = this.currentValues[e], n = t ?? null, V = e, l = this.currentValidations && this.currentValidations[e] ? this.currentValidations[e] : (d) => null;
|
|
34
|
+
let r = null;
|
|
35
|
+
this.shouldValidate.has(e) ? (r = l(t, this.currentValues), this.cachedMessages.set(e, r)) : r = this.cachedMessages.get(e) ?? null;
|
|
36
|
+
const a = !!(this.currentValidations && this.currentValidations[e]), u = this.cachedProps.get(e);
|
|
37
|
+
if (u && Object.is(u.value, n) && u.message === r && u.required === a)
|
|
38
|
+
return u.props;
|
|
39
|
+
let c = this.cachedSetters.get(e);
|
|
40
|
+
if (!c) {
|
|
41
|
+
const d = this.changeValue;
|
|
42
|
+
c = (o) => {
|
|
43
|
+
d(V, o);
|
|
44
|
+
}, this.cachedSetters.set(e, c);
|
|
45
|
+
}
|
|
46
|
+
const p = {
|
|
36
47
|
// @ts-ignore – z.B. wenn dein Input `defaultValue` kennt
|
|
37
|
-
defaultValue:
|
|
38
|
-
initialValue:
|
|
48
|
+
defaultValue: n ?? void 0,
|
|
49
|
+
initialValue: n ?? void 0,
|
|
39
50
|
formValidation: {
|
|
40
|
-
setValue:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
notValidMessage: a,
|
|
44
|
-
valid: a === null
|
|
51
|
+
setValue: c,
|
|
52
|
+
notValidMessage: r,
|
|
53
|
+
valid: r === null
|
|
45
54
|
},
|
|
46
|
-
...
|
|
55
|
+
...a ? {
|
|
47
56
|
required: !0
|
|
48
57
|
} : {}
|
|
49
58
|
};
|
|
59
|
+
return this.cachedProps.set(e, {
|
|
60
|
+
value: n,
|
|
61
|
+
message: r,
|
|
62
|
+
required: a,
|
|
63
|
+
props: p
|
|
64
|
+
}), p;
|
|
50
65
|
}
|
|
51
66
|
}
|
|
52
|
-
const
|
|
67
|
+
const N = (s) => {
|
|
53
68
|
const {
|
|
54
69
|
initialValues: e,
|
|
55
70
|
validate: t = {},
|
|
56
|
-
truthyValidationBeforeSubmit:
|
|
57
|
-
useInitialValidation:
|
|
58
|
-
onSubmit:
|
|
59
|
-
} =
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
...
|
|
64
|
-
[
|
|
65
|
-
},
|
|
66
|
-
}, []), [
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}, [
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
}, [
|
|
74
|
-
return [
|
|
71
|
+
truthyValidationBeforeSubmit: n = !0,
|
|
72
|
+
useInitialValidation: V = !0,
|
|
73
|
+
onSubmit: l
|
|
74
|
+
} = s, r = y.useMemo(() => e, [e]), [a, u] = P(r), c = v(/* @__PURE__ */ new Map()), p = v(/* @__PURE__ */ new Map()), d = v(/* @__PURE__ */ new Map()), o = v(a);
|
|
75
|
+
o.current = a;
|
|
76
|
+
const g = j((i, m) => {
|
|
77
|
+
o.current = {
|
|
78
|
+
...o.current,
|
|
79
|
+
[i]: m
|
|
80
|
+
}, u(o.current);
|
|
81
|
+
}, []), [O, M] = P(() => new w(g, a, t, V ? new Map(Object.keys(r).map((i) => [i, !0])) : /* @__PURE__ */ new Map(), c.current, p.current, d.current)), b = v(!1);
|
|
82
|
+
I(() => {
|
|
83
|
+
o.current = r, u(r), b.current && d.current.clear(), b.current = !0, M(new w(g, r, t, V ? new Map(Object.keys(r).map((i) => [i, !0])) : /* @__PURE__ */ new Map(), c.current, p.current, d.current));
|
|
84
|
+
}, [r]);
|
|
85
|
+
const R = j((i, m = !0) => {
|
|
86
|
+
const f = o.current, F = i && new Set(Object.keys(f)).has(String(i)) ? /* @__PURE__ */ new Map([[i, !0]]) : new Map(Object.keys(f).map((q) => [String(q), !0])), S = new w(g, f, t, F, c.current, p.current, d.current);
|
|
87
|
+
M(S), m && !new Set(Object.keys(f)).has(String(i)) && l && (!n || S.isValid()) && l(f);
|
|
88
|
+
}, [g, t, l, n]);
|
|
89
|
+
return [O, R, a];
|
|
75
90
|
};
|
|
76
91
|
export {
|
|
77
|
-
|
|
92
|
+
N as useForm
|
|
78
93
|
};
|