@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.
Files changed (41) hide show
  1. package/README.md +55 -27
  2. package/dist/core/Field.d.ts +3 -2
  3. package/dist/core/Field.js +1 -1
  4. package/dist/fields/Date.d.ts +2 -11
  5. package/dist/fields/Date.js +105 -98
  6. package/dist/fields/Input.d.ts +7 -22
  7. package/dist/fields/Input.js +110 -38
  8. package/dist/fields/Mask.d.ts +1 -1
  9. package/dist/fields/Mask.js +54 -48
  10. package/dist/fields/Modal.d.ts +7 -7
  11. package/dist/fields/Modal.js +37 -30
  12. package/dist/fields/Money.d.ts +8 -29
  13. package/dist/fields/Money.js +60 -53
  14. package/dist/fields/Numeric.d.ts +1 -1
  15. package/dist/fields/Numeric.js +46 -42
  16. package/dist/fields/Options.d.ts +9 -7
  17. package/dist/fields/Options.js +38 -32
  18. package/dist/fields/Password.d.ts +1 -1
  19. package/dist/fields/Password.js +90 -37
  20. package/dist/fields/Phone.d.ts +2 -20
  21. package/dist/fields/Phone.js +58 -55
  22. package/dist/fields/Range.d.ts +1 -1
  23. package/dist/fields/Range.js +74 -72
  24. package/dist/fields/Select.d.ts +1 -1
  25. package/dist/fields/Select.js +69 -66
  26. package/dist/fields/Textarea.d.ts +2 -22
  27. package/dist/fields/Textarea.js +37 -32
  28. package/dist/fields/Time.d.ts +1 -1
  29. package/dist/fields/Time.js +65 -63
  30. package/dist/fields/type.d.ts +50 -15
  31. package/dist/fields/visibility.d.ts +6 -0
  32. package/dist/fields/visibility.js +6 -0
  33. package/dist/hooks/use.d.ts +0 -1
  34. package/dist/index.d.ts +1 -1
  35. package/dist/index.js +24 -22
  36. package/dist/loadBaseStyles.d.ts +2 -0
  37. package/dist/loadBaseStyles.js +9 -0
  38. package/dist/package.js +6 -1
  39. package/package.json +6 -1
  40. package/dist/index.umd.js +0 -2
  41. package/dist/style.css +0 -5
@@ -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 "../mask/MaskPhone.js";
6
- import { useFormInit as o } from "../FormInitContext.js";
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 s, jsx as c } from "react/jsx-runtime";
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 l(e) {
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 u(e, t) {
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 d({ value: d, form: f, onValue: p, onSave: m, name: h = "", placeholder: g = "", title: _ = "", label: v = "", error: y = "", hide: b = !1, edit: x = !0, active: S = !0, after: C = "", show: w = !0, view: T, className: E = "", disabled: D = !1 }) {
25
- let { onNotice: O } = 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
- }, F = (e) => {
35
- let t = e.target, n = t.textContent || "", r = l(t), i = n.slice(0, r).replace(/\D/g, "").length, a = L(n);
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 = u(a.q, i);
34
+ let o = f(a.q, i);
38
35
  a.q.length > 0 && queueMicrotask(() => {
39
- P(Math.min(o, a.q.length), t);
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: h || ""
40
+ name: _ || ""
44
41
  };
45
- f && h && f.onValue(s), p && p !== f?.onValue && p(s);
46
- }, I = (e) => r.PasteOne(i(e)), L = (e) => {
47
- j = "+_(___) ___-__-__", M = !0, N = 0;
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 === "" && (M = !0);
50
- let i = r.split(""), o = "";
46
+ r === "" && (N = !0);
47
+ let i = r.split(""), a = "";
51
48
  i.forEach((e) => {
52
- M && (o += e, a[o] !== void 0 && M ? (M = !1, j = a[o].mask.replace(/* @__PURE__ */ RegExp("[0-9]", "g"), "_"), n = a[o].code) : (M && (N = ("" + o).length, j = `+${o}_(___) ___-__-__`.replace(/* @__PURE__ */ RegExp("[0-9]", "g"), "_"), n = ""), N > ("" + o).length && (M = !0, j = `+${o}_(___) ___-__-__`.replace(/* @__PURE__ */ RegExp("[0-9]", "g"), "_"), n = "")));
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 = j.replace(/\D/g, "");
51
+ let s = M.replace(/\D/g, "");
55
52
  return s.length >= r.length && (r = s), {
56
- q: j.replace(/[_\d]/g, function() {
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
- }, R = (e) => {
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
- }, z = L(String(k || "")), B = (e) => {
68
+ }, B = R(String(A || "")), V = (e) => {
72
69
  e.key === "Enter" && e.preventDefault();
73
- }, V = (e) => {
74
- r.Blur(e), m && m({
70
+ }, H = (e) => {
71
+ r.Blur(e), g && g({
75
72
  value: (e.target.textContent || "").replace(/\D/g, ""),
76
- name: h || ""
73
+ name: _ || ""
77
74
  });
78
- }, H = (e) => {
75
+ }, U = (e) => {
79
76
  r.Focus({ target: e.currentTarget });
80
- }, U = {};
81
- return g && (U.placeholder = g), b ? /* @__PURE__ */ c(s, {}) : /* @__PURE__ */ c(t, {
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
- title: _ || v,
84
- error: y,
85
- element_blok: { className: [E] },
82
+ label: y,
83
+ error: b,
84
+ element_blok: { className: [C] },
86
85
  element_input: { className: [e.w] },
87
- children: /* @__PURE__ */ c("div", {
88
- onPaste: I,
89
- onInput: F,
90
- onKeyDown: B,
91
- onContextMenu: R,
92
- onBlur: V,
93
- onFocus: H,
94
- inputMode: "tel",
95
- role: "textbox",
96
- "aria-label": _ || v || g || "Телефон",
97
- "aria-disabled": D || !(x && S),
98
- tabIndex: D ? -1 : 0,
99
- "data-disabled": D || !(x && S),
100
- contentEditable: x && S && !D ? "plaintext-only" : !1,
101
- suppressContentEditableWarning: !0,
102
- ...U,
103
- children: z.q
104
- }, A)
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
- d.displayName = "PhoneField";
110
+ p.displayName = "PhoneField";
108
111
  //#endregion
109
- export { d as default };
112
+ export { p as default };
@@ -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, onSave, name, title, label, error, min, max, step, edit, active, disabled, className, isReload, }: TRange): import("react/jsx-runtime").JSX.Element;
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
  }
@@ -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 a(e, t, n) {
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 o(e, t, n, r) {
12
- return a(!Number.isFinite(r) || r <= 0 ? e : t + Math.round((e - t) / r) * r, t, n);
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 s({ value: s = 0, form: c, onValue: l, onSave: u, name: d = "", title: f = "", label: p = "", error: m = "", min: h = 0, max: g = 100, step: _ = 1, edit: v = !0, active: y = !0, disabled: b = !1, className: x = "", isReload: S = !1 }) {
15
- let { value: C } = n(c, d, s), w = a(Number(C), h, g), T = g === h ? 0 : (w - h) / (g - h) * 100, E = T >= 99.999, D = v && y && !b, O = r.useRef(null), k = r.useCallback((e) => {
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: o(e, h, g, _),
18
- name: d || "",
19
- reload: S
17
+ value: s(e, x, S, C),
18
+ name: f || ""
20
19
  };
21
- c && d && c.setValue(t), l && l !== c?.onValue && l(t);
20
+ l && f && l.setValue(t), u && u !== l?.onValue && u(t);
22
21
  }, [
23
- c,
24
- d,
25
- S,
26
22
  l,
27
- h,
28
- g,
29
- _
30
- ]), A = r.useCallback((e) => {
31
- let t = O.current;
32
- if (!t) return h;
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 o(h + (e - n.left) / r * (g - h), h, g, _);
32
+ return s(x + (e - n.left) / r * (S - x), x, S, C);
35
33
  }, [
36
- h,
37
- g,
38
- _
39
- ]), j = (e) => {
40
- D && (e.preventDefault(), e.currentTarget.setPointerCapture(e.pointerId), k(A(e.clientX)));
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
- }, P = (e) => {
48
- if (!D) return;
49
- let t = w;
50
- if (e.key === "ArrowRight" || e.key === "ArrowUp") t = w + _;
51
- else if (e.key === "ArrowLeft" || e.key === "ArrowDown") t = w - _;
52
- else if (e.key === "Home") t = h;
53
- else if (e.key === "End") t = g;
54
- else if (e.key === "PageUp") t = w + _ * 10;
55
- else if (e.key === "PageDown") t = w - _ * 10;
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(), k(o(t, h, g, _));
58
- }, F = () => {
59
- if (!u || !d) return;
60
- let e = c && d ? c.getValue(d, s) : w;
61
- u({
62
- value: a(Number(e), h, g),
63
- name: d
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__ */ i(t, {
64
+ return g && (w == null || w === "") ? null : /* @__PURE__ */ a(t, {
67
65
  type: "range",
68
- title: f || p,
69
- error: m,
70
- element_blok: { className: [x || ""] },
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": b || !D ? "true" : void 0 }
71
+ props: { "data-disabled": _ || !O ? "true" : void 0 }
74
72
  },
75
- children: /* @__PURE__ */ i("div", { children: /* @__PURE__ */ i("div", {
76
- ref: O,
77
- className: e.rangeTrack,
78
- role: "slider",
79
- tabIndex: D ? 0 : -1,
80
- "aria-label": f || p || "Диапазон",
81
- "aria-valuemin": h,
82
- "aria-valuemax": g,
83
- "aria-valuenow": w,
84
- "data-disabled": b || !D ? "true" : void 0,
85
- onPointerDown: j,
86
- onPointerMove: M,
87
- onPointerUp: N,
88
- onPointerCancel: N,
89
- onKeyDown: P,
90
- onBlur: F,
91
- children: /* @__PURE__ */ i("div", {
92
- className: E ? `${e.rangeFill} ${e.rangeFillFull}` : e.rangeFill,
93
- style: { width: `${T}%` },
94
- "aria-hidden": !0
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
- s.displayName = "RangeField";
101
+ c.displayName = "RangeField";
100
102
  //#endregion
101
- export { s as default };
103
+ export { c as default };
@@ -14,7 +14,7 @@ export type TSelect = TInput & {
14
14
  options?: SelectOptions;
15
15
  order?: number[];
16
16
  };
17
- declare function SelectField({ form, title, error, edit, active, hide, value, onValue, options, placeholder, className, name, order, isReload, disabled, }: TSelect): import("react/jsx-runtime").JSX.Element | "";
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
  }
@@ -1,119 +1,122 @@
1
- import e from "../core/Field.js";
2
- import { useFormFieldState as t } from "../hooks/use.js";
3
- import n from "../styles/Select.module.js";
1
+ import e from "../styles/Select.module.js";
2
+ import t from "../core/Field.js";
3
+ import { useFormFieldState as n } from "../hooks/use.js";
4
4
  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({ form: c, title: u, error: d, edit: f = !0, active: p = !0, hide: m, value: h = 0, onValue: g, options: _, placeholder: v = "", className: y, name: b = "", order: x, isReload: S = !1, disabled: C = !1 }) {
9
- let [w, T] = r.useState(!1), [E, D] = r.useState(0), [O, k] = r.useState(null), A = r.useId(), { value: j } = t(c, b, h ?? 0), M = Number(j), N = [];
10
- _ && (N = Array.isArray(_) ? _.map((e) => ({
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 } = n(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(_).map((e) => {
15
- let t = Number(e), n = _[t];
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 P = (() => {
23
- if (!x || x.length === 0) return N;
24
- let e = new Map(N.map((e) => [e.id, e]));
25
- return x.map((t) => e.get(t)).filter((e) => !!e);
26
- })().filter((e) => !e.hidden), F = (e) => P.find((t) => t.id === e)?.label;
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: b,
32
- reload: S
29
+ name: f
33
30
  };
34
- c && b && c.onValue(t), g && g !== c?.onValue && g(t);
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
- if (P.length === 0 || !(f && p) || C) return;
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
- R(e.currentTarget);
41
- }, B = (e) => {
42
- if (!(!(f && p) || C) && P.length !== 0) {
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 (w) {
44
+ if (C) {
48
45
  if (e.key === "Escape") {
49
- e.preventDefault(), T(!1);
46
+ e.preventDefault(), w(!1);
50
47
  return;
51
48
  }
52
49
  if (e.key === "ArrowDown") {
53
- e.preventDefault(), D((e) => (e + 1) % P.length);
50
+ e.preventDefault(), E((e) => (e + 1) % N.length);
54
51
  return;
55
52
  }
56
53
  if (e.key === "ArrowUp") {
57
- e.preventDefault(), D((e) => e - 1 < 0 ? P.length - 1 : e - 1);
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 = P[E];
63
- t && L(t.id), T(!1);
59
+ let t = N[T];
60
+ t && I(t.id), w(!1);
64
61
  }
65
62
  }
66
63
  }
67
- }, V = {};
68
- return v && (V.placeholder = v), m ? "" : /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ a(e, {
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(t, {
69
68
  type: "select",
70
- title: u,
71
- element_blok: { className: [y || ""] },
72
- error: d,
69
+ label: m,
70
+ element_blok: { className: [v || ""] },
71
+ error: h,
73
72
  element_input: {
74
- className: [n.f],
73
+ className: [e.f],
75
74
  props: {
76
- onClick: z,
77
- onKeyDown: B,
78
- tabIndex: f && p && !C ? 0 : -1,
75
+ onClick: R,
76
+ onKeyDown: z,
77
+ tabIndex: _ ? -1 : 0,
79
78
  role: "combobox",
80
- "aria-expanded": w,
79
+ "aria-expanded": C,
81
80
  "aria-haspopup": "listbox",
82
- "aria-controls": A,
83
- ...I ? { "aria-activedescendant": I } : {},
84
- "aria-disabled": C || !(f && p),
85
- "data-disabled": C || !(f && p)
81
+ "aria-controls": k,
82
+ ...F ? { "aria-activedescendant": F } : {},
83
+ "aria-disabled": _,
84
+ "data-disabled": _
86
85
  }
87
86
  },
88
- children: /* @__PURE__ */ a("div", {
89
- ...V,
90
- children: F(M) || v || ""
91
- })
92
- }), w && s(/* @__PURE__ */ a(l, {
93
- parent: O || void 0,
94
- onValue: L,
95
- className: y,
96
- items: P,
97
- setOpen: T,
98
- listId: A,
99
- activeIndex: E,
100
- currentValue: M
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";
104
- var l = ({ onValue: e, parent: t, className: r, items: s, setOpen: c, listId: l, activeIndex: d, currentValue: f }) => {
105
- if (!t) return null;
107
+ var l = ({ onValue: t, parent: n, className: r, items: s, setOpen: c, listId: l, activeIndex: d, currentValue: f }) => {
108
+ if (!n) return null;
106
109
  let p = () => {
107
110
  c(!1);
108
- }, m = (t) => {
109
- c(!1), e(t);
110
- }, h = window.innerHeight - t.bottom < 306 ? Math.max(6, t.top - 300 - 6) : Math.min(window.innerHeight - 300 - 6, t.bottom + 6), g = Math.max(t.width, 260), _ = Math.min(Math.max(6, t.left), window.innerWidth - g - 6);
111
+ }, m = (e) => {
112
+ c(!1), t(e);
113
+ }, h = window.innerHeight - n.bottom < 306 ? Math.max(6, n.top - 300 - 6) : Math.min(window.innerHeight - 300 - 6, n.bottom + 6), g = Math.max(n.width, 260), _ = Math.min(Math.max(6, n.left), window.innerWidth - g - 6);
111
114
  return /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ a("div", {
112
- className: n.o,
115
+ className: e.o,
113
116
  onClick: p,
114
117
  "aria-hidden": !0
115
118
  }), /* @__PURE__ */ a("div", {
116
- className: [n.l, r].filter((e) => e !== void 0).join(" "),
119
+ className: [e.l, r].filter((e) => e !== void 0).join(" "),
117
120
  style: {
118
121
  top: h + "px",
119
122
  left: _ + "px",
@@ -1,26 +1,6 @@
1
1
  import { TInput } from './type';
2
- /**
3
- * TextareaField component
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
  }