@elcrm/form 0.0.64 → 0.0.65
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 +53 -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 +97 -90
- 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 +58 -55
- 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/package.json +1 -1
- package/dist/index.umd.js +0 -2
- package/dist/style.css +0 -5
package/dist/fields/Phone.js
CHANGED
|
@@ -2,12 +2,13 @@ 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 a from "
|
|
6
|
-
import
|
|
5
|
+
import { isEmptyTextLike as a } from "./visibility.js";
|
|
6
|
+
import o from "../mask/MaskPhone.js";
|
|
7
|
+
import { useFormInit as s } from "../FormInitContext.js";
|
|
7
8
|
import "react";
|
|
8
|
-
import { Fragment as
|
|
9
|
+
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
9
10
|
//#region src/lib/fields/Phone.tsx
|
|
10
|
-
function
|
|
11
|
+
function d(e) {
|
|
11
12
|
let t = window.getSelection();
|
|
12
13
|
if (!t || t.rangeCount === 0) return 0;
|
|
13
14
|
let n = t.getRangeAt(0);
|
|
@@ -15,52 +16,48 @@ function l(e) {
|
|
|
15
16
|
let r = document.createRange();
|
|
16
17
|
return r.selectNodeContents(e), r.setEnd(n.startContainer, n.startOffset), r.toString().length;
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
+
function f(e, t) {
|
|
19
20
|
if (t <= 0) return 0;
|
|
20
21
|
let n = 0;
|
|
21
22
|
for (let r = 0; r < e.length; r++) if (/\d/.test(e[r]) && (n++, n === t)) return r + 1;
|
|
22
23
|
return e.length;
|
|
23
24
|
}
|
|
24
|
-
function
|
|
25
|
-
let { onNotice: O } =
|
|
26
|
-
x = x === void 0 ? !0 : x, S = S === void 0 ? !0 : S;
|
|
27
|
-
let { value: k, version: A } = n(f, h, d);
|
|
28
|
-
b = !!(b && (k === "" || k === void 0)) && !(x && S);
|
|
29
|
-
let j = "+_(___) ___-__-__", M = !0, N = 0, P = (e, t) => {
|
|
25
|
+
function p({ value: p, form: m, onValue: h, onBlur: g, name: _ = "", placeholder: v = "", label: y = "", error: b = "", hidden: x = !1, disabled: S = !1, className: C = "", after: w = "", before: T = "", inputmode: E = "tel", view: D }) {
|
|
26
|
+
let { onNotice: O } = s(), k = !S, { value: A, version: j } = n(m, _, p), M = "+_(___) ___-__-__", N = !0, P = 0, F = (e, t) => {
|
|
30
27
|
let n = t.firstChild;
|
|
31
28
|
if (!n || n.nodeType !== Node.TEXT_NODE) return;
|
|
32
29
|
let r = n.textContent?.length ?? 0, i = Math.max(0, Math.min(e, r)), a = document.createRange(), o = window.getSelection();
|
|
33
30
|
o && (a.setStart(n, i), a.collapse(!0), o.removeAllRanges(), o.addRange(a), t.focus());
|
|
34
|
-
},
|
|
35
|
-
let t = e.target, n = t.textContent || "", r =
|
|
31
|
+
}, I = (e) => {
|
|
32
|
+
let t = e.target, n = t.textContent || "", r = d(t), i = n.slice(0, r).replace(/\D/g, "").length, a = R(n);
|
|
36
33
|
t.textContent = a.q;
|
|
37
|
-
let o =
|
|
34
|
+
let o = f(a.q, i);
|
|
38
35
|
a.q.length > 0 && queueMicrotask(() => {
|
|
39
|
-
|
|
36
|
+
F(Math.min(o, a.q.length), t);
|
|
40
37
|
});
|
|
41
38
|
let s = {
|
|
42
39
|
value: a.q.replace(/\D/g, ""),
|
|
43
|
-
name:
|
|
40
|
+
name: _ || ""
|
|
44
41
|
};
|
|
45
|
-
|
|
46
|
-
},
|
|
47
|
-
|
|
42
|
+
m && _ && m.onValue(s), h && h !== m?.onValue && h(s);
|
|
43
|
+
}, L = (e) => r.PasteOne(i(e)), R = (e) => {
|
|
44
|
+
M = "+_(___) ___-__-__", N = !0, P = 0;
|
|
48
45
|
let t = 0, n = "", r = e.replace(/\D/g, "");
|
|
49
|
-
r === "" && (
|
|
50
|
-
let i = r.split(""),
|
|
46
|
+
r === "" && (N = !0);
|
|
47
|
+
let i = r.split(""), a = "";
|
|
51
48
|
i.forEach((e) => {
|
|
52
|
-
|
|
49
|
+
N && (a += e, o[a] !== void 0 && N ? (N = !1, M = o[a].mask.replace(/* @__PURE__ */ RegExp("[0-9]", "g"), "_"), n = o[a].code) : (N && (P = ("" + a).length, M = `+${a}_(___) ___-__-__`.replace(/* @__PURE__ */ RegExp("[0-9]", "g"), "_"), n = ""), P > ("" + a).length && (N = !0, M = `+${a}_(___) ___-__-__`.replace(/* @__PURE__ */ RegExp("[0-9]", "g"), "_"), n = "")));
|
|
53
50
|
});
|
|
54
|
-
let s =
|
|
51
|
+
let s = M.replace(/\D/g, "");
|
|
55
52
|
return s.length >= r.length && (r = s), {
|
|
56
|
-
q:
|
|
53
|
+
q: M.replace(/[_\d]/g, function() {
|
|
57
54
|
return r.charAt(t++) || "_";
|
|
58
55
|
}),
|
|
59
56
|
i: t,
|
|
60
57
|
v: r,
|
|
61
58
|
f: n
|
|
62
59
|
};
|
|
63
|
-
},
|
|
60
|
+
}, z = (e) => {
|
|
64
61
|
e.preventDefault();
|
|
65
62
|
let t = e.target;
|
|
66
63
|
navigator.clipboard.writeText((t.textContent || "").replace(/\D/g, "")).then(function() {
|
|
@@ -68,42 +65,48 @@ function d({ value: d, form: f, onValue: p, onSave: m, name: h = "", placeholder
|
|
|
68
65
|
}, function(e) {
|
|
69
66
|
console.error("Async: Could not copy text: ", e);
|
|
70
67
|
});
|
|
71
|
-
},
|
|
68
|
+
}, B = R(String(A || "")), V = (e) => {
|
|
72
69
|
e.key === "Enter" && e.preventDefault();
|
|
73
|
-
},
|
|
74
|
-
r.Blur(e),
|
|
70
|
+
}, H = (e) => {
|
|
71
|
+
r.Blur(e), g && g({
|
|
75
72
|
value: (e.target.textContent || "").replace(/\D/g, ""),
|
|
76
|
-
name:
|
|
73
|
+
name: _ || ""
|
|
77
74
|
});
|
|
78
|
-
},
|
|
75
|
+
}, U = (e) => {
|
|
79
76
|
r.Focus({ target: e.currentTarget });
|
|
80
|
-
},
|
|
81
|
-
|
|
77
|
+
}, W = {};
|
|
78
|
+
v && (W.placeholder = v), W.inputMode = E ?? "tel";
|
|
79
|
+
let G = String(A ?? "").replace(/\D/g, "");
|
|
80
|
+
return x && a(G) ? /* @__PURE__ */ l(c, {}) : /* @__PURE__ */ u(t, {
|
|
82
81
|
type: "input",
|
|
83
|
-
|
|
84
|
-
error:
|
|
85
|
-
element_blok: { className: [
|
|
82
|
+
label: y,
|
|
83
|
+
error: b,
|
|
84
|
+
element_blok: { className: [C] },
|
|
86
85
|
element_input: { className: [e.w] },
|
|
87
|
-
children:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
86
|
+
children: [
|
|
87
|
+
T,
|
|
88
|
+
/* @__PURE__ */ l("div", {
|
|
89
|
+
onPaste: L,
|
|
90
|
+
onInput: I,
|
|
91
|
+
onKeyDown: V,
|
|
92
|
+
onContextMenu: z,
|
|
93
|
+
onBlur: H,
|
|
94
|
+
onFocus: U,
|
|
95
|
+
spellCheck: !1,
|
|
96
|
+
role: "textbox",
|
|
97
|
+
"aria-label": y || v || "Телефон",
|
|
98
|
+
"aria-disabled": !k,
|
|
99
|
+
tabIndex: S ? -1 : 0,
|
|
100
|
+
"data-disabled": !k,
|
|
101
|
+
contentEditable: k ? "plaintext-only" : !1,
|
|
102
|
+
suppressContentEditableWarning: !0,
|
|
103
|
+
...W,
|
|
104
|
+
children: B.q
|
|
105
|
+
}, j),
|
|
106
|
+
w
|
|
107
|
+
]
|
|
105
108
|
});
|
|
106
109
|
}
|
|
107
|
-
|
|
110
|
+
p.displayName = "PhoneField";
|
|
108
111
|
//#endregion
|
|
109
|
-
export {
|
|
112
|
+
export { p as default };
|
package/dist/fields/Range.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type TRange = TInput & {
|
|
|
7
7
|
};
|
|
8
8
|
/** @deprecated — используйте `TRange` */
|
|
9
9
|
export type TProgress = TRange;
|
|
10
|
-
declare function RangeField({ value, form, onValue,
|
|
10
|
+
declare function RangeField({ value, form, onValue, onBlur: onBlurField, name, placeholder, label, error, hidden, disabled, className, after, before, min, max, step, }: TRange): import("react/jsx-runtime").JSX.Element | null;
|
|
11
11
|
declare namespace RangeField {
|
|
12
12
|
var displayName: string;
|
|
13
13
|
}
|
package/dist/fields/Range.js
CHANGED
|
@@ -2,100 +2,102 @@ 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 "react";
|
|
5
|
-
import { jsx as i } from "react/jsx-runtime";
|
|
5
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
6
6
|
//#region src/lib/fields/Range.tsx
|
|
7
|
-
function
|
|
7
|
+
function o(e, t, n) {
|
|
8
8
|
let r = e;
|
|
9
9
|
return Number.isFinite(r) || (r = t), Math.min(n, Math.max(t, r));
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
return
|
|
11
|
+
function s(e, t, n, r) {
|
|
12
|
+
return o(!Number.isFinite(r) || r <= 0 ? e : t + Math.round((e - t) / r) * r, t, n);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
let { value:
|
|
14
|
+
function c({ value: c = 0, form: l, onValue: u, onBlur: d, name: f = "", placeholder: p = "", label: m = "", error: h = "", hidden: g = !1, disabled: _ = !1, className: v = "", after: y = "", before: b = "", min: x = 0, max: S = 100, step: C = 1 }) {
|
|
15
|
+
let { value: w } = n(l, f, c), T = o(Number(w), x, S), E = S === x ? 0 : (T - x) / (S - x) * 100, D = E >= 99.999, O = !_, k = r.useRef(null), A = r.useCallback((e) => {
|
|
16
16
|
let t = {
|
|
17
|
-
value:
|
|
18
|
-
name:
|
|
19
|
-
reload: S
|
|
17
|
+
value: s(e, x, S, C),
|
|
18
|
+
name: f || ""
|
|
20
19
|
};
|
|
21
|
-
|
|
20
|
+
l && f && l.setValue(t), u && u !== l?.onValue && u(t);
|
|
22
21
|
}, [
|
|
23
|
-
c,
|
|
24
|
-
d,
|
|
25
|
-
S,
|
|
26
22
|
l,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
f,
|
|
24
|
+
u,
|
|
25
|
+
x,
|
|
26
|
+
S,
|
|
27
|
+
C
|
|
28
|
+
]), j = r.useCallback((e) => {
|
|
29
|
+
let t = k.current;
|
|
30
|
+
if (!t) return x;
|
|
33
31
|
let n = t.getBoundingClientRect(), r = n.width || 1;
|
|
34
|
-
return
|
|
32
|
+
return s(x + (e - n.left) / r * (S - x), x, S, C);
|
|
35
33
|
}, [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
]),
|
|
40
|
-
|
|
41
|
-
}, M = (e) => {
|
|
42
|
-
D && e.currentTarget.hasPointerCapture(e.pointerId) && k(A(e.clientX));
|
|
34
|
+
x,
|
|
35
|
+
S,
|
|
36
|
+
C
|
|
37
|
+
]), M = (e) => {
|
|
38
|
+
O && (e.preventDefault(), e.currentTarget.setPointerCapture(e.pointerId), A(j(e.clientX)));
|
|
43
39
|
}, N = (e) => {
|
|
40
|
+
O && e.currentTarget.hasPointerCapture(e.pointerId) && A(j(e.clientX));
|
|
41
|
+
}, P = (e) => {
|
|
44
42
|
try {
|
|
45
43
|
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
46
44
|
} catch {}
|
|
47
|
-
},
|
|
48
|
-
if (!
|
|
49
|
-
let t =
|
|
50
|
-
if (e.key === "ArrowRight" || e.key === "ArrowUp") t =
|
|
51
|
-
else if (e.key === "ArrowLeft" || e.key === "ArrowDown") t =
|
|
52
|
-
else if (e.key === "Home") t =
|
|
53
|
-
else if (e.key === "End") t =
|
|
54
|
-
else if (e.key === "PageUp") t =
|
|
55
|
-
else if (e.key === "PageDown") t =
|
|
45
|
+
}, F = (e) => {
|
|
46
|
+
if (!O) return;
|
|
47
|
+
let t = T;
|
|
48
|
+
if (e.key === "ArrowRight" || e.key === "ArrowUp") t = T + C;
|
|
49
|
+
else if (e.key === "ArrowLeft" || e.key === "ArrowDown") t = T - C;
|
|
50
|
+
else if (e.key === "Home") t = x;
|
|
51
|
+
else if (e.key === "End") t = S;
|
|
52
|
+
else if (e.key === "PageUp") t = T + C * 10;
|
|
53
|
+
else if (e.key === "PageDown") t = T - C * 10;
|
|
56
54
|
else return;
|
|
57
|
-
e.preventDefault(),
|
|
58
|
-
},
|
|
59
|
-
if (!
|
|
60
|
-
let e =
|
|
61
|
-
|
|
62
|
-
value:
|
|
63
|
-
name:
|
|
55
|
+
e.preventDefault(), A(s(t, x, S, C));
|
|
56
|
+
}, I = () => {
|
|
57
|
+
if (!d || !f) return;
|
|
58
|
+
let e = l && f ? l.getValue(f, c) : T;
|
|
59
|
+
d({
|
|
60
|
+
value: o(Number(e), x, S),
|
|
61
|
+
name: f
|
|
64
62
|
});
|
|
65
63
|
};
|
|
66
|
-
return /* @__PURE__ */
|
|
64
|
+
return g && (w == null || w === "") ? null : /* @__PURE__ */ a(t, {
|
|
67
65
|
type: "range",
|
|
68
|
-
|
|
69
|
-
error:
|
|
70
|
-
element_blok: { className: [
|
|
66
|
+
label: m,
|
|
67
|
+
error: h,
|
|
68
|
+
element_blok: { className: [v || ""] },
|
|
71
69
|
element_input: {
|
|
72
70
|
className: [e.w, e.range],
|
|
73
|
-
props: { "data-disabled":
|
|
71
|
+
props: { "data-disabled": _ || !O ? "true" : void 0 }
|
|
74
72
|
},
|
|
75
|
-
children:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
73
|
+
children: [
|
|
74
|
+
b,
|
|
75
|
+
/* @__PURE__ */ i("div", { children: /* @__PURE__ */ i("div", {
|
|
76
|
+
ref: k,
|
|
77
|
+
className: e.rangeTrack,
|
|
78
|
+
role: "slider",
|
|
79
|
+
tabIndex: O ? 0 : -1,
|
|
80
|
+
"aria-label": m || p || "Диапазон",
|
|
81
|
+
"aria-valuemin": x,
|
|
82
|
+
"aria-valuemax": S,
|
|
83
|
+
"aria-valuenow": T,
|
|
84
|
+
"data-disabled": _ || !O ? "true" : void 0,
|
|
85
|
+
onPointerDown: M,
|
|
86
|
+
onPointerMove: N,
|
|
87
|
+
onPointerUp: P,
|
|
88
|
+
onPointerCancel: P,
|
|
89
|
+
onKeyDown: F,
|
|
90
|
+
onBlur: I,
|
|
91
|
+
children: /* @__PURE__ */ i("div", {
|
|
92
|
+
className: D ? `${e.rangeFill} ${e.rangeFillFull}` : e.rangeFill,
|
|
93
|
+
style: { width: `${E}%` },
|
|
94
|
+
"aria-hidden": !0
|
|
95
|
+
})
|
|
96
|
+
}) }),
|
|
97
|
+
y
|
|
98
|
+
]
|
|
97
99
|
});
|
|
98
100
|
}
|
|
99
|
-
|
|
101
|
+
c.displayName = "RangeField";
|
|
100
102
|
//#endregion
|
|
101
|
-
export {
|
|
103
|
+
export { c as default };
|
package/dist/fields/Select.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export type TSelect = TInput & {
|
|
|
14
14
|
options?: SelectOptions;
|
|
15
15
|
order?: number[];
|
|
16
16
|
};
|
|
17
|
-
declare function SelectField({
|
|
17
|
+
declare function SelectField({ value, form, onValue, name, placeholder, label, error, hidden, disabled, className, after, before, options, order, }: TSelect): import("react/jsx-runtime").JSX.Element | "";
|
|
18
18
|
declare namespace SelectField {
|
|
19
19
|
var displayName: string;
|
|
20
20
|
}
|
package/dist/fields/Select.js
CHANGED
|
@@ -5,99 +5,102 @@ import r from "react";
|
|
|
5
5
|
import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
6
6
|
import { createPortal as s } from "react-dom";
|
|
7
7
|
//#region src/lib/fields/Select.tsx
|
|
8
|
-
function c({
|
|
9
|
-
let [
|
|
10
|
-
|
|
8
|
+
function c({ value: c = 0, form: u, onValue: d, name: f = "", placeholder: p = "", label: m, error: h, hidden: g = !1, disabled: _ = !1, className: v, after: y = "", before: b = "", options: x, order: S }) {
|
|
9
|
+
let [C, w] = r.useState(!1), [T, E] = r.useState(0), [D, O] = r.useState(null), k = r.useId(), { value: A } = t(u, f, c ?? 0), j = Number(A), M = [];
|
|
10
|
+
x && (M = Array.isArray(x) ? x.map((e) => ({
|
|
11
11
|
id: e.id ?? e.i ?? 0,
|
|
12
12
|
label: e.n || "",
|
|
13
13
|
hidden: e.s === 0
|
|
14
|
-
})).filter((e) => e.id !== 0 && e.label.length > 0) : Object.keys(
|
|
15
|
-
let t = Number(e), n =
|
|
14
|
+
})).filter((e) => e.id !== 0 && e.label.length > 0) : Object.keys(x).map((e) => {
|
|
15
|
+
let t = Number(e), n = x[t];
|
|
16
16
|
return {
|
|
17
17
|
id: t,
|
|
18
18
|
label: n?.n || "",
|
|
19
19
|
hidden: n?.s === 0
|
|
20
20
|
};
|
|
21
21
|
}).filter((e) => e.label.length > 0));
|
|
22
|
-
let
|
|
23
|
-
if (!
|
|
24
|
-
let e = new Map(
|
|
25
|
-
return
|
|
26
|
-
})().filter((e) => !e.hidden),
|
|
27
|
-
m = !!(m && (M === 0 || F(M) === void 0)) && !(f && p);
|
|
28
|
-
let I = w && P.length > 0 ? `${A}-opt-${E}` : void 0, L = (e) => {
|
|
22
|
+
let N = (() => {
|
|
23
|
+
if (!S || S.length === 0) return M;
|
|
24
|
+
let e = new Map(M.map((e) => [e.id, e]));
|
|
25
|
+
return S.map((t) => e.get(t)).filter((e) => !!e);
|
|
26
|
+
})().filter((e) => !e.hidden), P = (e) => N.find((t) => t.id === e)?.label, F = C && N.length > 0 ? `${k}-opt-${T}` : void 0, I = (e) => {
|
|
29
27
|
let t = {
|
|
30
28
|
value: e,
|
|
31
|
-
name:
|
|
32
|
-
reload: S
|
|
29
|
+
name: f
|
|
33
30
|
};
|
|
34
|
-
|
|
31
|
+
u && f && u.onValue(t), d && d !== u?.onValue && d(t);
|
|
32
|
+
}, L = (e) => {
|
|
33
|
+
if (N.length === 0 || _) return;
|
|
34
|
+
let t = N.findIndex((e) => e.id === j);
|
|
35
|
+
O(e.getBoundingClientRect()), E(t >= 0 ? t : 0), w(!0);
|
|
35
36
|
}, R = (e) => {
|
|
36
|
-
|
|
37
|
-
let t = P.findIndex((e) => e.id === M);
|
|
38
|
-
k(e.getBoundingClientRect()), D(t >= 0 ? t : 0), T(!0);
|
|
37
|
+
L(e.currentTarget);
|
|
39
38
|
}, z = (e) => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (!w && (e.key === "ArrowDown" || e.key === "Enter" || e.key === " ")) {
|
|
44
|
-
e.preventDefault(), R(e.currentTarget);
|
|
39
|
+
if (!_ && N.length !== 0) {
|
|
40
|
+
if (!C && (e.key === "ArrowDown" || e.key === "Enter" || e.key === " ")) {
|
|
41
|
+
e.preventDefault(), L(e.currentTarget);
|
|
45
42
|
return;
|
|
46
43
|
}
|
|
47
|
-
if (
|
|
44
|
+
if (C) {
|
|
48
45
|
if (e.key === "Escape") {
|
|
49
|
-
e.preventDefault(),
|
|
46
|
+
e.preventDefault(), w(!1);
|
|
50
47
|
return;
|
|
51
48
|
}
|
|
52
49
|
if (e.key === "ArrowDown") {
|
|
53
|
-
e.preventDefault(),
|
|
50
|
+
e.preventDefault(), E((e) => (e + 1) % N.length);
|
|
54
51
|
return;
|
|
55
52
|
}
|
|
56
53
|
if (e.key === "ArrowUp") {
|
|
57
|
-
e.preventDefault(),
|
|
54
|
+
e.preventDefault(), E((e) => e - 1 < 0 ? N.length - 1 : e - 1);
|
|
58
55
|
return;
|
|
59
56
|
}
|
|
60
57
|
if (e.key === "Enter") {
|
|
61
58
|
e.preventDefault();
|
|
62
|
-
let t =
|
|
63
|
-
t &&
|
|
59
|
+
let t = N[T];
|
|
60
|
+
t && I(t.id), w(!1);
|
|
64
61
|
}
|
|
65
62
|
}
|
|
66
63
|
}
|
|
67
|
-
},
|
|
68
|
-
|
|
64
|
+
}, B = {};
|
|
65
|
+
p && (B.placeholder = p);
|
|
66
|
+
let V = j === 0 || P(j) === void 0;
|
|
67
|
+
return g && V ? "" : /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ o(e, {
|
|
69
68
|
type: "select",
|
|
70
|
-
|
|
71
|
-
element_blok: { className: [
|
|
72
|
-
error:
|
|
69
|
+
label: m,
|
|
70
|
+
element_blok: { className: [v || ""] },
|
|
71
|
+
error: h,
|
|
73
72
|
element_input: {
|
|
74
73
|
className: [n.f],
|
|
75
74
|
props: {
|
|
76
|
-
onClick:
|
|
77
|
-
onKeyDown:
|
|
78
|
-
tabIndex:
|
|
75
|
+
onClick: R,
|
|
76
|
+
onKeyDown: z,
|
|
77
|
+
tabIndex: _ ? -1 : 0,
|
|
79
78
|
role: "combobox",
|
|
80
|
-
"aria-expanded":
|
|
79
|
+
"aria-expanded": C,
|
|
81
80
|
"aria-haspopup": "listbox",
|
|
82
|
-
"aria-controls":
|
|
83
|
-
...
|
|
84
|
-
"aria-disabled":
|
|
85
|
-
"data-disabled":
|
|
81
|
+
"aria-controls": k,
|
|
82
|
+
...F ? { "aria-activedescendant": F } : {},
|
|
83
|
+
"aria-disabled": _,
|
|
84
|
+
"data-disabled": _
|
|
86
85
|
}
|
|
87
86
|
},
|
|
88
|
-
children:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
87
|
+
children: [
|
|
88
|
+
b,
|
|
89
|
+
/* @__PURE__ */ a("div", {
|
|
90
|
+
...B,
|
|
91
|
+
children: P(j) || p || ""
|
|
92
|
+
}),
|
|
93
|
+
y
|
|
94
|
+
]
|
|
95
|
+
}), C && s(/* @__PURE__ */ a(l, {
|
|
96
|
+
parent: D || void 0,
|
|
97
|
+
onValue: I,
|
|
98
|
+
className: v,
|
|
99
|
+
items: N,
|
|
100
|
+
setOpen: w,
|
|
101
|
+
listId: k,
|
|
102
|
+
activeIndex: T,
|
|
103
|
+
currentValue: j
|
|
101
104
|
}), document.body)] });
|
|
102
105
|
}
|
|
103
106
|
c.displayName = "SelectField";
|
|
@@ -1,26 +1,6 @@
|
|
|
1
1
|
import { TInput } from './type';
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* @param {string} [id] - id
|
|
6
|
-
* @param {string} [value] - значение
|
|
7
|
-
* @param {function} [onValue] - callback на изменение
|
|
8
|
-
* @param {string} [name] - имя
|
|
9
|
-
* @param {string} [placeholder] - placeholder
|
|
10
|
-
* @param {string} [title] - заголовок
|
|
11
|
-
* @param {string} [label] - заголовок (альтернативное title)
|
|
12
|
-
* @param {boolean} [hide] - скрыть
|
|
13
|
-
* @param {boolean} [edit] - редактировать
|
|
14
|
-
* @param {boolean} [active] - активность
|
|
15
|
-
* @param {string} [after] - контент после
|
|
16
|
-
* @param {boolean} [show] - отображать
|
|
17
|
-
* @param {number} [maxLength] - максимальная длина
|
|
18
|
-
* @param {function} [onSave] - callback на save
|
|
19
|
-
* @param {string} [className] - css class
|
|
20
|
-
* @param {boolean} [isCopy] - разрешить копирование
|
|
21
|
-
* @return {ReactElement} - поле ввода
|
|
22
|
-
*/
|
|
23
|
-
declare function TextareaField({ value, form, onValue, name, placeholder, title, label, hide, edit, active, after, show, maxLength, error, onSave, className, isCopy, }: TInput): import("react/jsx-runtime").JSX.Element | "";
|
|
2
|
+
/** TextareaField — многострочное поле (contentEditable). */
|
|
3
|
+
declare function TextareaField({ value, form, onValue, name, placeholder, label, hidden, disabled, onBlur: onBlurField, className, after, before, error, inputmode, maxLength, spellCheck, }: TInput): import("react/jsx-runtime").JSX.Element;
|
|
24
4
|
declare namespace TextareaField {
|
|
25
5
|
var displayName: string;
|
|
26
6
|
}
|
package/dist/fields/Textarea.js
CHANGED
|
@@ -2,46 +2,51 @@ 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/Textarea.tsx
|
|
8
|
-
function
|
|
9
|
-
let { value:
|
|
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 = "text", maxLength: C, spellCheck: w = !0 }) {
|
|
10
|
+
let { value: T, version: E } = n(u, f || "", l), D = !g, O = (e) => {
|
|
10
11
|
let t = {
|
|
11
12
|
value: e.currentTarget.innerText,
|
|
12
|
-
name:
|
|
13
|
+
name: f || ""
|
|
13
14
|
};
|
|
14
|
-
|
|
15
|
-
},
|
|
15
|
+
u && f && u.onValue(t), d && d !== u?.onValue && d(t);
|
|
16
|
+
}, k = (e) => {
|
|
16
17
|
let t = (e.currentTarget.textContent ?? "").trim();
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return d && (k.placeholder = d), h && g && (k.edit = ""), /* @__PURE__ */ o(t, {
|
|
18
|
+
C && t.length >= C && e.key !== "Backspace" && e.preventDefault(), e.key === "Enter" && !e.shiftKey && e.preventDefault();
|
|
19
|
+
}, A = (e) => r.Paste(C || 0, i(e));
|
|
20
|
+
if (h && a(T)) return /* @__PURE__ */ s(o, {});
|
|
21
|
+
let j = {};
|
|
22
|
+
return p && (j.placeholder = p), D && (j.edit = ""), j.inputMode = S || "text", /* @__PURE__ */ c(t, {
|
|
23
23
|
type: "note",
|
|
24
|
-
|
|
25
|
-
error:
|
|
26
|
-
element_blok: { className: [
|
|
24
|
+
label: m,
|
|
25
|
+
error: x,
|
|
26
|
+
element_blok: { className: [v || ""] },
|
|
27
27
|
element_input: { className: [e.n] },
|
|
28
|
-
children:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
28
|
+
children: [
|
|
29
|
+
b,
|
|
30
|
+
/* @__PURE__ */ s("div", {
|
|
31
|
+
onPaste: A,
|
|
32
|
+
onInput: O,
|
|
33
|
+
onBlur: (e) => {
|
|
34
|
+
r.Blur(e), _?.({
|
|
35
|
+
value: (e.currentTarget.textContent ?? "").trim(),
|
|
36
|
+
name: f || ""
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
onKeyDown: k,
|
|
40
|
+
spellCheck: w,
|
|
41
|
+
contentEditable: D ? "plaintext-only" : !1,
|
|
42
|
+
suppressContentEditableWarning: !0,
|
|
43
|
+
...j,
|
|
44
|
+
children: T
|
|
45
|
+
}, E),
|
|
46
|
+
y
|
|
47
|
+
]
|
|
43
48
|
});
|
|
44
49
|
}
|
|
45
|
-
|
|
50
|
+
l.displayName = "TextareaField";
|
|
46
51
|
//#endregion
|
|
47
|
-
export {
|
|
52
|
+
export { l as default };
|