@elcrm/form 0.0.64 → 0.0.66
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/README.md +55 -27
- package/dist/core/Field.d.ts +3 -2
- package/dist/core/Field.js +1 -1
- package/dist/fields/Date.d.ts +2 -11
- package/dist/fields/Date.js +105 -98
- package/dist/fields/Input.d.ts +7 -22
- package/dist/fields/Input.js +110 -38
- package/dist/fields/Mask.d.ts +1 -1
- package/dist/fields/Mask.js +54 -48
- package/dist/fields/Modal.d.ts +7 -7
- package/dist/fields/Modal.js +37 -30
- package/dist/fields/Money.d.ts +8 -29
- package/dist/fields/Money.js +60 -53
- package/dist/fields/Numeric.d.ts +1 -1
- package/dist/fields/Numeric.js +46 -42
- package/dist/fields/Options.d.ts +9 -7
- package/dist/fields/Options.js +38 -32
- package/dist/fields/Password.d.ts +1 -1
- package/dist/fields/Password.js +90 -37
- package/dist/fields/Phone.d.ts +2 -20
- package/dist/fields/Phone.js +58 -55
- package/dist/fields/Range.d.ts +1 -1
- package/dist/fields/Range.js +74 -72
- package/dist/fields/Select.d.ts +1 -1
- package/dist/fields/Select.js +69 -66
- package/dist/fields/Textarea.d.ts +2 -22
- package/dist/fields/Textarea.js +37 -32
- package/dist/fields/Time.d.ts +1 -1
- package/dist/fields/Time.js +65 -63
- package/dist/fields/type.d.ts +50 -15
- package/dist/fields/visibility.d.ts +6 -0
- package/dist/fields/visibility.js +6 -0
- package/dist/hooks/use.d.ts +0 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +24 -22
- package/dist/loadBaseStyles.d.ts +2 -0
- package/dist/loadBaseStyles.js +9 -0
- package/dist/package.js +6 -1
- package/package.json +6 -1
- package/dist/index.umd.js +0 -2
- package/dist/style.css +0 -5
package/dist/fields/Money.js
CHANGED
|
@@ -2,10 +2,11 @@ import e from "../styles/Field.module.js";
|
|
|
2
2
|
import t from "../core/Field.js";
|
|
3
3
|
import { useFormFieldState as n } from "../hooks/use.js";
|
|
4
4
|
import r, { pastePlainTextIntoSelection as i } from "../events/onEvent.js";
|
|
5
|
+
import { isEmptyTextLike as a } from "./visibility.js";
|
|
5
6
|
import "react";
|
|
6
|
-
import { jsx as
|
|
7
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
7
8
|
//#region src/lib/fields/Money.tsx
|
|
8
|
-
function
|
|
9
|
+
function c(e) {
|
|
9
10
|
let t = window.getSelection();
|
|
10
11
|
if (!t || t.rangeCount === 0) return 0;
|
|
11
12
|
let n = t.getRangeAt(0);
|
|
@@ -13,81 +14,87 @@ function s(e) {
|
|
|
13
14
|
let r = document.createRange();
|
|
14
15
|
return r.selectNodeContents(e), r.setEnd(n.startContainer, n.startOffset), r.toString().length;
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
+
function l(e, t, n) {
|
|
17
18
|
let r = Math.max(0, Math.min(t, e.length));
|
|
18
19
|
return n(e.slice(0, r)).length;
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
-
let { value: k, version: A } = n(
|
|
21
|
+
function u({ value: u, form: f, onValue: p, name: m = "", placeholder: h = "", label: g = "", error: _ = "", hidden: v = !1, disabled: y = !1, onBlur: b, className: x = "", after: S = "", before: C = "", inputmode: w = "decimal", course: T = 100, view: E, type: D, isClear: O = !1 }) {
|
|
22
|
+
let { value: k, version: A } = n(f, m || "", u), j = f && m ? k : u, M = (e) => D === "multi" ? e.replace(/[^+\d.+-]/g, "") : e.replace(/[^+\d.]/g, ""), N = (e, t) => {
|
|
22
23
|
let n = t.firstChild;
|
|
23
24
|
if (!n || n.nodeType !== Node.TEXT_NODE) return;
|
|
24
25
|
let r = n.textContent?.length ?? 0, i = Math.max(0, Math.min(e, r)), a = document.createRange(), o = window.getSelection();
|
|
25
26
|
o && (a.setStart(n, i), a.collapse(!0), o.removeAllRanges(), o.addRange(a), t.focus());
|
|
26
|
-
},
|
|
27
|
-
let t = e.target, n = t.textContent || "", r =
|
|
28
|
-
value: Number(i || 0) *
|
|
29
|
-
name:
|
|
27
|
+
}, P = (e) => {
|
|
28
|
+
let t = e.target, n = t.textContent || "", r = c(t), i = M(n), a = l(n, r, M), o = {
|
|
29
|
+
value: Number(i || 0) * T,
|
|
30
|
+
name: m
|
|
30
31
|
};
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
f && m && f.onValue(o), p && p !== f?.onValue && p(o), t.textContent = i, i.length > 0 && queueMicrotask(() => {
|
|
33
|
+
N(Math.min(a, i.length), t);
|
|
33
34
|
});
|
|
34
|
-
},
|
|
35
|
+
}, F = (e) => {
|
|
35
36
|
let t = e.target;
|
|
36
37
|
r.Blur(e), (t.textContent || "") === "" && (t.textContent = "0");
|
|
37
38
|
let n = {
|
|
38
|
-
value: Number(
|
|
39
|
-
name:
|
|
39
|
+
value: Number(M(t.textContent || "")) * T,
|
|
40
|
+
name: m
|
|
40
41
|
};
|
|
41
|
-
|
|
42
|
-
},
|
|
42
|
+
b?.(n), f && m && f.setValue(n), p && p !== f?.onValue && p(n), t.textContent = d(t.textContent || "");
|
|
43
|
+
}, I = (e) => {
|
|
43
44
|
let t = e.target;
|
|
44
|
-
t.textContent =
|
|
45
|
-
},
|
|
45
|
+
t.textContent = M(t.textContent || ""), r.Focus({ target: e.currentTarget });
|
|
46
|
+
}, L = (e) => {
|
|
46
47
|
let t = e.currentTarget.previousElementSibling;
|
|
47
48
|
t && (t.textContent = "");
|
|
48
49
|
let n = {
|
|
49
50
|
value: 0,
|
|
50
|
-
name:
|
|
51
|
+
name: m
|
|
51
52
|
};
|
|
52
|
-
|
|
53
|
-
},
|
|
53
|
+
f && m && f.setValue(n), p && p !== f?.onValue && p(n);
|
|
54
|
+
}, R = (e) => {
|
|
54
55
|
e.key === "Enter" && e.preventDefault();
|
|
55
|
-
},
|
|
56
|
-
e.preventDefault(), i(
|
|
57
|
-
};
|
|
58
|
-
if (
|
|
59
|
-
let
|
|
60
|
-
return
|
|
56
|
+
}, z = (e) => {
|
|
57
|
+
e.preventDefault(), i(M(e.clipboardData?.getData("text/plain") ?? ""), e.currentTarget);
|
|
58
|
+
}, B = !y, V = j == null || (typeof j == "number" ? !1 : a(String(j ?? "")));
|
|
59
|
+
if (v && V) return "";
|
|
60
|
+
let H = {};
|
|
61
|
+
return H.inputMode = w ?? "decimal", h && (H.placeholder = h), B && (H.edit = ""), /* @__PURE__ */ s(t, {
|
|
61
62
|
type: "input",
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
label: g,
|
|
64
|
+
error: _,
|
|
65
|
+
element_blok: { className: [x] },
|
|
64
66
|
element_input: { className: [e.w] },
|
|
65
|
-
children: [
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
67
|
+
children: [
|
|
68
|
+
C,
|
|
69
|
+
/* @__PURE__ */ o("div", {
|
|
70
|
+
...H,
|
|
71
|
+
onInput: P,
|
|
72
|
+
onPaste: z,
|
|
73
|
+
onBlur: F,
|
|
74
|
+
onKeyDown: R,
|
|
75
|
+
onFocus: I,
|
|
76
|
+
role: "textbox",
|
|
77
|
+
spellCheck: !1,
|
|
78
|
+
"aria-label": g || h || "Сумма",
|
|
79
|
+
"aria-disabled": !B,
|
|
80
|
+
tabIndex: y ? -1 : 0,
|
|
81
|
+
contentEditable: B ? "plaintext-only" : !1,
|
|
82
|
+
suppressContentEditableWarning: !0,
|
|
83
|
+
children: !h || j ? d(j ?? "") : ""
|
|
84
|
+
}, A),
|
|
85
|
+
O && /* @__PURE__ */ o("button", {
|
|
86
|
+
type: "button",
|
|
87
|
+
onClick: L,
|
|
88
|
+
"aria-label": "Очистить поле",
|
|
89
|
+
children: "x"
|
|
90
|
+
}),
|
|
91
|
+
S
|
|
92
|
+
]
|
|
86
93
|
});
|
|
87
94
|
}
|
|
88
|
-
|
|
89
|
-
function
|
|
95
|
+
u.displayName = "MoneyField";
|
|
96
|
+
function d(e, t) {
|
|
90
97
|
return t && (e = Number(e) / t), parseFloat(String(e || 0)).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1 ");
|
|
91
98
|
}
|
|
92
99
|
//#endregion
|
|
93
|
-
export {
|
|
100
|
+
export { u as default };
|
package/dist/fields/Numeric.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { TInput } from './type';
|
|
|
2
2
|
type TNumeric = TInput & {
|
|
3
3
|
max?: number;
|
|
4
4
|
};
|
|
5
|
-
declare function NumberField({ form, onValue,
|
|
5
|
+
declare function NumberField({ value, form, onValue, name, placeholder, label, hidden, disabled, onBlur: onBlurField, className, after, before, error, inputmode, maxLength, max, view, }: TNumeric): import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
declare namespace NumberField {
|
|
7
7
|
var displayName: string;
|
|
8
8
|
}
|
package/dist/fields/Numeric.js
CHANGED
|
@@ -2,16 +2,16 @@ import e from "../styles/Field.module.js";
|
|
|
2
2
|
import t from "../core/Field.js";
|
|
3
3
|
import { useFormFieldState as n } from "../hooks/use.js";
|
|
4
4
|
import r, { asEditableClipboard as i } from "../events/onEvent.js";
|
|
5
|
+
import { isEmptyTextLike as a } from "./visibility.js";
|
|
5
6
|
import "react";
|
|
6
|
-
import { Fragment as
|
|
7
|
+
import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
7
8
|
//#region src/lib/fields/Numeric.tsx
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
let D = b ?? d, O = !1, k = (e) => {
|
|
9
|
+
function l({ value: l, form: u, onValue: d, name: f = "", placeholder: p = "", label: m = "", hidden: h = !1, disabled: g = !1, onBlur: _, className: v = "", after: y = "", before: b = "", error: x = "", inputmode: S = "numeric", maxLength: C, max: w, view: T }) {
|
|
10
|
+
let E = !g, { value: D, version: O } = n(u, f, l);
|
|
11
|
+
p = p === void 0 ? "" : p, w = w === void 0 ? 99 : w;
|
|
12
|
+
let k = C ?? w, A = !1, j = (e) => {
|
|
13
13
|
let t = e.currentTarget, n = (t.textContent || "").replace(/\D/g, "");
|
|
14
|
-
n.length >
|
|
14
|
+
n.length > k && (n = n.slice(0, k), t.textContent = n, queueMicrotask(() => {
|
|
15
15
|
let e = t.firstChild;
|
|
16
16
|
if (e && e.nodeType === Node.TEXT_NODE) {
|
|
17
17
|
let t = n.length, r = window.getSelection(), i = document.createRange();
|
|
@@ -20,50 +20,54 @@ function s({ form: s, onValue: c, onSave: l, active: u, max: d, edit: f, title:
|
|
|
20
20
|
}));
|
|
21
21
|
let r = {
|
|
22
22
|
value: n,
|
|
23
|
-
name:
|
|
23
|
+
name: f
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
},
|
|
25
|
+
u && f && u.onValue(r), d && d !== u?.onValue && d(r);
|
|
26
|
+
}, M = (e) => {
|
|
27
27
|
let t = e.currentTarget;
|
|
28
28
|
t.textContent = (t.textContent || "").replace(/\D/g, ""), r.Focus({ target: e.currentTarget });
|
|
29
|
-
},
|
|
30
|
-
if (
|
|
31
|
-
if (e.which === 17 || e.which === 91) return
|
|
29
|
+
}, N = (e) => {
|
|
30
|
+
if (A && e.which === 86) return;
|
|
31
|
+
if (e.which === 17 || e.which === 91) return A = !0;
|
|
32
32
|
if (e.key === "Backspace") return;
|
|
33
33
|
let t = (e.currentTarget.textContent ?? "").replace(/\D/g, "").length;
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
if (e.which === 17 || e.which === 91) return
|
|
37
|
-
},
|
|
38
|
-
r.Blur(e),
|
|
34
|
+
k > 0 && t >= k && e.key.length === 1 && /\d/.test(e.key) && e.preventDefault(), e.key === "Enter" && e.preventDefault(), e.key.length === 1 && !/\d/.test(e.key) && e.preventDefault();
|
|
35
|
+
}, P = (e) => {
|
|
36
|
+
if (e.which === 17 || e.which === 91) return A = !1;
|
|
37
|
+
}, F = (e) => r.PasteDigits(k, i(e)), I = (e) => {
|
|
38
|
+
r.Blur(e), _?.({
|
|
39
39
|
value: e.currentTarget.textContent,
|
|
40
|
-
name:
|
|
40
|
+
name: f
|
|
41
41
|
});
|
|
42
|
-
},
|
|
43
|
-
return
|
|
42
|
+
}, L = {};
|
|
43
|
+
return E && (L.edit = ""), L.inputMode = S ?? "numeric", p && (L.placeholder = p), h && a(D) ? /* @__PURE__ */ s(o, {}) : /* @__PURE__ */ c(t, {
|
|
44
44
|
type: "numeric",
|
|
45
|
-
|
|
46
|
-
error:
|
|
47
|
-
element_blok: { className: [
|
|
45
|
+
label: m,
|
|
46
|
+
error: x,
|
|
47
|
+
element_blok: { className: [v || ""] },
|
|
48
48
|
element_input: { className: [e.w] },
|
|
49
|
-
children:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
49
|
+
children: [
|
|
50
|
+
b,
|
|
51
|
+
/* @__PURE__ */ s("div", {
|
|
52
|
+
onPaste: F,
|
|
53
|
+
onInput: j,
|
|
54
|
+
onFocus: M,
|
|
55
|
+
onBlur: I,
|
|
56
|
+
onKeyDown: N,
|
|
57
|
+
onKeyUp: P,
|
|
58
|
+
spellCheck: !1,
|
|
59
|
+
role: "textbox",
|
|
60
|
+
tabIndex: E ? 0 : -1,
|
|
61
|
+
"aria-label": m || p || "Число",
|
|
62
|
+
contentEditable: E ? "plaintext-only" : !1,
|
|
63
|
+
suppressContentEditableWarning: !0,
|
|
64
|
+
...L,
|
|
65
|
+
children: D
|
|
66
|
+
}, O),
|
|
67
|
+
y
|
|
68
|
+
]
|
|
65
69
|
});
|
|
66
70
|
}
|
|
67
|
-
|
|
71
|
+
l.displayName = "NumberField";
|
|
68
72
|
//#endregion
|
|
69
|
-
export {
|
|
73
|
+
export { l as default };
|
package/dist/fields/Options.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
import { UseFormApi } from '../hooks/use';
|
|
2
3
|
import { TValue } from './type';
|
|
3
4
|
interface Input {
|
|
@@ -6,13 +7,14 @@ interface Input {
|
|
|
6
7
|
onValue?: (data: TValue) => void | Promise<void>;
|
|
7
8
|
name: string;
|
|
8
9
|
placeholder?: string;
|
|
9
|
-
|
|
10
|
+
/** Подпись поля */
|
|
11
|
+
label?: string;
|
|
10
12
|
error?: string;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
hidden?: boolean;
|
|
14
|
+
/** true — блок выбора не открывается */
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
after?: ReactNode;
|
|
17
|
+
before?: ReactNode;
|
|
16
18
|
view?: string;
|
|
17
19
|
className?: string;
|
|
18
20
|
module?: string;
|
|
@@ -23,7 +25,7 @@ interface Input {
|
|
|
23
25
|
outFormat?: "array" | "string" | "object";
|
|
24
26
|
separator?: string;
|
|
25
27
|
}
|
|
26
|
-
declare function OptionsField({ value, form, onValue, name, placeholder, separator,
|
|
28
|
+
declare function OptionsField({ value, form, onValue, name, placeholder, separator, label, error, hidden, disabled, outFormat, after, before, modal, options, className, }: Input): import("react/jsx-runtime").JSX.Element;
|
|
27
29
|
declare namespace OptionsField {
|
|
28
30
|
var displayName: string;
|
|
29
31
|
}
|
package/dist/fields/Options.js
CHANGED
|
@@ -2,62 +2,68 @@ import e from "../styles/Field.module.js";
|
|
|
2
2
|
import t from "../core/Field.js";
|
|
3
3
|
import { useFormFieldState as n } from "../hooks/use.js";
|
|
4
4
|
import { useFormInit as r } from "../FormInitContext.js";
|
|
5
|
-
import { Fragment as i, jsx as a } from "react/jsx-runtime";
|
|
5
|
+
import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
6
6
|
//#region src/lib/fields/Options.tsx
|
|
7
|
-
var
|
|
8
|
-
function
|
|
9
|
-
let { onModal:
|
|
10
|
-
if (
|
|
11
|
-
if (!
|
|
12
|
-
let e =
|
|
13
|
-
|
|
7
|
+
var s = (e, t = ",") => (e !== void 0 && e !== "" ? e.split(t) : []).filter((e) => e !== "").reduce((e, t) => (e[t] = !0, e), {});
|
|
8
|
+
function c({ value: c, form: l, onValue: u, name: d, placeholder: f = "", separator: p = ",", label: m, error: h, hidden: g = !1, disabled: _ = !1, outFormat: v = "object", after: y, before: b, modal: x, options: S, className: C }) {
|
|
9
|
+
let { onModal: w } = r(), { value: T } = n(l, d, c), E = T, D = typeof E == "string" ? s(E, p) : E && typeof E == "object" ? E : {}, O = () => {
|
|
10
|
+
if (_) return;
|
|
11
|
+
if (!x) return console.error("modal - empty");
|
|
12
|
+
let e = x.split(".");
|
|
13
|
+
w({
|
|
14
14
|
module: e[0],
|
|
15
15
|
modalName: e[1],
|
|
16
16
|
callback: (e) => {
|
|
17
17
|
let t = e;
|
|
18
|
-
if (
|
|
18
|
+
if (u) {
|
|
19
19
|
let e = {
|
|
20
|
-
value: v === "array" ? Object.keys(t) : v === "string" ? Object.keys(t).filter((e) => t[e]).join(
|
|
21
|
-
name:
|
|
20
|
+
value: v === "array" ? Object.keys(t) : v === "string" ? Object.keys(t).filter((e) => t[e]).join(p) : t,
|
|
21
|
+
name: d
|
|
22
22
|
};
|
|
23
|
-
switch (
|
|
23
|
+
switch (l && d && l.setValue(e), v) {
|
|
24
24
|
case "array":
|
|
25
|
-
|
|
25
|
+
u !== l?.onValue && u({
|
|
26
26
|
value: Object.keys(t),
|
|
27
|
-
name:
|
|
27
|
+
name: d
|
|
28
28
|
});
|
|
29
29
|
break;
|
|
30
30
|
case "string":
|
|
31
|
-
|
|
32
|
-
value: Object.keys(t).filter((e) => t[e]).join(
|
|
33
|
-
name:
|
|
31
|
+
u !== l?.onValue && u({
|
|
32
|
+
value: Object.keys(t).filter((e) => t[e]).join(p),
|
|
33
|
+
name: d
|
|
34
34
|
});
|
|
35
35
|
break;
|
|
36
|
-
default:
|
|
36
|
+
default: u !== l?.onValue && u({
|
|
37
37
|
value: t,
|
|
38
|
-
name:
|
|
38
|
+
name: d
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
|
-
onValue:
|
|
44
|
-
options:
|
|
45
|
-
fieldName:
|
|
46
|
-
value:
|
|
43
|
+
onValue: u,
|
|
44
|
+
options: S,
|
|
45
|
+
fieldName: d,
|
|
46
|
+
value: D
|
|
47
47
|
});
|
|
48
|
-
},
|
|
49
|
-
|
|
48
|
+
}, k = {};
|
|
49
|
+
f && (k.placeholder = f);
|
|
50
|
+
let A = Object.keys(D).length === 0;
|
|
51
|
+
return g && A ? /* @__PURE__ */ a(i, {}) : /* @__PURE__ */ o(t, {
|
|
50
52
|
type: "group",
|
|
51
|
-
|
|
52
|
-
error:
|
|
53
|
-
element_blok: { className: [
|
|
53
|
+
label: m,
|
|
54
|
+
error: h,
|
|
55
|
+
element_blok: { className: [C || ""] },
|
|
54
56
|
element_input: {
|
|
55
57
|
className: [e.g],
|
|
56
|
-
props: { onClick:
|
|
58
|
+
props: { onClick: O }
|
|
57
59
|
},
|
|
58
|
-
children:
|
|
60
|
+
children: [
|
|
61
|
+
b,
|
|
62
|
+
Object.keys(D).map((e) => /* @__PURE__ */ a("div", { children: S?.[e]?.label }, e)),
|
|
63
|
+
y
|
|
64
|
+
]
|
|
59
65
|
});
|
|
60
66
|
}
|
|
61
|
-
|
|
67
|
+
c.displayName = "OptionsField";
|
|
62
68
|
//#endregion
|
|
63
|
-
export {
|
|
69
|
+
export { c as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TPasswordField } from './type';
|
|
2
|
-
declare function PasswordField({ value, form, onValue,
|
|
2
|
+
declare function PasswordField({ value, form, onValue, name, placeholder, label, error, hidden, disabled, onBlur: onBlurField, className, after, before, native, maxLength, eyes, }: TPasswordField): import("react/jsx-runtime").JSX.Element | "";
|
|
3
3
|
declare namespace PasswordField {
|
|
4
4
|
var displayName: string;
|
|
5
5
|
}
|
package/dist/fields/Password.js
CHANGED
|
@@ -2,67 +2,109 @@ import e from "../styles/Field.module.js";
|
|
|
2
2
|
import t from "../core/Field.js";
|
|
3
3
|
import { useFormFieldState as n } from "../hooks/use.js";
|
|
4
4
|
import r from "../events/onEvent.js";
|
|
5
|
-
import i from "
|
|
6
|
-
import
|
|
5
|
+
import { isEmptyTextLike as i } from "./visibility.js";
|
|
6
|
+
import a from "react";
|
|
7
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
7
8
|
//#region src/lib/fields/Password.tsx
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
function c() {
|
|
10
|
+
return /* @__PURE__ */ s("svg", {
|
|
11
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
12
|
+
width: "1.25em",
|
|
13
|
+
height: "1.25em",
|
|
14
|
+
viewBox: "0 0 24 24",
|
|
15
|
+
fill: "none",
|
|
16
|
+
stroke: "currentColor",
|
|
17
|
+
strokeWidth: "2",
|
|
18
|
+
strokeLinecap: "round",
|
|
19
|
+
strokeLinejoin: "round",
|
|
20
|
+
"aria-hidden": !0,
|
|
21
|
+
children: [/* @__PURE__ */ o("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }), /* @__PURE__ */ o("circle", {
|
|
22
|
+
cx: "12",
|
|
23
|
+
cy: "12",
|
|
24
|
+
r: "3"
|
|
25
|
+
})]
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function l() {
|
|
29
|
+
return /* @__PURE__ */ s("svg", {
|
|
30
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
31
|
+
width: "1.25em",
|
|
32
|
+
height: "1.25em",
|
|
33
|
+
viewBox: "0 0 24 24",
|
|
34
|
+
fill: "none",
|
|
35
|
+
stroke: "currentColor",
|
|
36
|
+
strokeWidth: "2",
|
|
37
|
+
strokeLinecap: "round",
|
|
38
|
+
strokeLinejoin: "round",
|
|
39
|
+
"aria-hidden": !0,
|
|
40
|
+
children: [/* @__PURE__ */ o("path", { d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24" }), /* @__PURE__ */ o("line", {
|
|
41
|
+
x1: "1",
|
|
42
|
+
y1: "1",
|
|
43
|
+
x2: "23",
|
|
44
|
+
y2: "23"
|
|
45
|
+
})]
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function u({ value: u, form: d, onValue: f, name: p = "", placeholder: m = "", label: h, error: g, hidden: _ = !1, disabled: v = !1, onBlur: y, className: b, after: x = "", before: S = "", native: C = !1, maxLength: w, eyes: T }) {
|
|
49
|
+
let [E, D] = a.useState(!1), { value: O } = n(d, p, u), k = a.useRef(null), A = typeof O == "string" ? O : O == null ? "" : String(O);
|
|
50
|
+
a.useEffect(() => {
|
|
11
51
|
let e = k.current;
|
|
12
52
|
e && e.value !== A && (e.value = A);
|
|
13
53
|
}, [A]);
|
|
14
54
|
let j = (e) => {
|
|
15
55
|
let t = {
|
|
16
56
|
value: e,
|
|
17
|
-
name:
|
|
18
|
-
reload: y
|
|
57
|
+
name: p
|
|
19
58
|
};
|
|
20
|
-
|
|
59
|
+
d && p && d.onValue(t), f && f !== d?.onValue && f(t);
|
|
21
60
|
}, M = (e) => {
|
|
22
61
|
j(e.target.value);
|
|
23
62
|
}, N = (e) => {
|
|
24
63
|
e.key === "Enter" && e.preventDefault();
|
|
25
64
|
}, P = (e) => {
|
|
26
|
-
r.Blur(e),
|
|
65
|
+
r.Blur(e), y?.({
|
|
27
66
|
value: (e.target.value || "").trim(),
|
|
28
|
-
name:
|
|
67
|
+
name: p || ""
|
|
29
68
|
});
|
|
30
69
|
};
|
|
31
|
-
if (
|
|
32
|
-
let F =
|
|
33
|
-
|
|
70
|
+
if (C) return "";
|
|
71
|
+
let F = !v;
|
|
72
|
+
if (_ && i(A)) return "";
|
|
73
|
+
let I = T?.[0] ?? /* @__PURE__ */ o(c, {}), L = T?.[1] ?? /* @__PURE__ */ o(l, {});
|
|
74
|
+
return /* @__PURE__ */ s(t, {
|
|
34
75
|
type: "input",
|
|
35
|
-
|
|
76
|
+
label: h,
|
|
36
77
|
error: g,
|
|
37
|
-
element_blok: { className: [
|
|
78
|
+
element_blok: { className: [b || ""] },
|
|
38
79
|
element_input: {
|
|
39
80
|
className: [e.w],
|
|
40
|
-
props: { "data-disabled":
|
|
81
|
+
props: { "data-disabled": v || !F ? "true" : void 0 }
|
|
41
82
|
},
|
|
42
83
|
children: [
|
|
43
|
-
|
|
84
|
+
S,
|
|
85
|
+
/* @__PURE__ */ o("div", {
|
|
44
86
|
style: {
|
|
45
87
|
flex: 1,
|
|
46
88
|
minWidth: 0,
|
|
47
89
|
display: "flex",
|
|
48
90
|
alignItems: "center"
|
|
49
91
|
},
|
|
50
|
-
children: /* @__PURE__ */
|
|
92
|
+
children: /* @__PURE__ */ o("input", {
|
|
51
93
|
type: E ? "text" : "password",
|
|
52
94
|
defaultValue: A,
|
|
53
95
|
ref: k,
|
|
54
96
|
onChange: M,
|
|
55
97
|
onKeyDown: N,
|
|
56
98
|
onBlur: P,
|
|
57
|
-
disabled:
|
|
58
|
-
readOnly:
|
|
59
|
-
maxLength:
|
|
99
|
+
disabled: v,
|
|
100
|
+
readOnly: v,
|
|
101
|
+
maxLength: w,
|
|
60
102
|
spellCheck: !1,
|
|
61
103
|
autoComplete: "current-password",
|
|
62
|
-
"aria-label":
|
|
63
|
-
"aria-disabled":
|
|
64
|
-
tabIndex:
|
|
65
|
-
placeholder:
|
|
104
|
+
"aria-label": h || m || "Пароль",
|
|
105
|
+
"aria-disabled": v || !F,
|
|
106
|
+
tabIndex: v ? -1 : 0,
|
|
107
|
+
placeholder: m,
|
|
66
108
|
style: {
|
|
67
109
|
width: "100%",
|
|
68
110
|
border: "none",
|
|
@@ -76,25 +118,36 @@ function s({ value: s, form: c, onValue: l, onSave: u, name: d = "", placeholder
|
|
|
76
118
|
}
|
|
77
119
|
})
|
|
78
120
|
}),
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
tabIndex:
|
|
121
|
+
/* @__PURE__ */ o("button", {
|
|
122
|
+
type: "button",
|
|
123
|
+
tabIndex: v ? -1 : 0,
|
|
82
124
|
"aria-label": E ? "Скрыть пароль" : "Показать пароль",
|
|
83
125
|
"aria-pressed": E,
|
|
84
|
-
|
|
126
|
+
disabled: v,
|
|
127
|
+
onClick: () => !v && D(!E),
|
|
85
128
|
onKeyDown: (e) => {
|
|
86
|
-
|
|
129
|
+
v || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), D(!E));
|
|
87
130
|
},
|
|
88
131
|
style: {
|
|
89
|
-
cursor:
|
|
90
|
-
alignSelf: "center"
|
|
132
|
+
cursor: v ? "not-allowed" : "pointer",
|
|
133
|
+
alignSelf: "center",
|
|
134
|
+
display: "inline-flex",
|
|
135
|
+
alignItems: "center",
|
|
136
|
+
justifyContent: "center",
|
|
137
|
+
padding: "4px",
|
|
138
|
+
margin: 0,
|
|
139
|
+
marginRight: "8px",
|
|
140
|
+
border: "none",
|
|
141
|
+
background: "transparent",
|
|
142
|
+
color: "inherit",
|
|
143
|
+
font: "inherit"
|
|
91
144
|
},
|
|
92
|
-
children: E ?
|
|
93
|
-
})
|
|
94
|
-
|
|
145
|
+
children: E ? L : I
|
|
146
|
+
}),
|
|
147
|
+
x
|
|
95
148
|
]
|
|
96
149
|
});
|
|
97
150
|
}
|
|
98
|
-
|
|
151
|
+
u.displayName = "PasswordField";
|
|
99
152
|
//#endregion
|
|
100
|
-
export {
|
|
153
|
+
export { u as default };
|
package/dist/fields/Phone.d.ts
CHANGED
|
@@ -1,24 +1,6 @@
|
|
|
1
1
|
import { TInput } from './type';
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* @param {string} [value] - значение
|
|
6
|
-
* @param {function} [onValue] - callback на изменение
|
|
7
|
-
* @param {function} [onSave] - callback на save
|
|
8
|
-
* @param {string} [name] - имя
|
|
9
|
-
* @param {string} [placeholder] - placeholder
|
|
10
|
-
* @param {string} [title] - заголовок
|
|
11
|
-
* @param {string} [label] - заголовок (альтернативное title)
|
|
12
|
-
* @param {string} [error] - ошибка
|
|
13
|
-
* @param {boolean} [hide] - скрыть
|
|
14
|
-
* @param {boolean} [edit] - редактировать
|
|
15
|
-
* @param {boolean} [active] - активность
|
|
16
|
-
* @param {string} [after] - контент после
|
|
17
|
-
* @param {boolean} [show] - отображать
|
|
18
|
-
* @param {string} [view] - тип view
|
|
19
|
-
* @param {string} [className] - css class
|
|
20
|
-
*/
|
|
21
|
-
declare function PhoneField({ value, form, onValue, onSave, name, placeholder, title, label, error, hide, edit, active, after, show, view, className, disabled, }: TInput): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
/** PhoneField — телефон с маской и копированием в буфер (через Form.Init → onNotice). */
|
|
3
|
+
declare function PhoneField({ value, form, onValue, onBlur: onBlurField, name, placeholder, label, error, hidden, disabled, className, after, before, inputmode, view, }: TInput): import("react/jsx-runtime").JSX.Element;
|
|
22
4
|
declare namespace PhoneField {
|
|
23
5
|
var displayName: string;
|
|
24
6
|
}
|