@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,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 a, jsxs as o } from "react/jsx-runtime";
7
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
7
8
  //#region src/lib/fields/Money.tsx
8
- function s(e) {
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 c(e, t, n) {
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 l({ value: l, form: d, onValue: f, name: p, placeholder: m = "", title: h = "", error: g = "", hide: _ = !1, edit: v = !0, active: y = !0, after: b = "", show: x = !0, course: S = 100, view: C, type: w, onSave: T, className: E = "", isClear: D = !1, disabled: O = !1 }) {
21
- let { value: k, version: A } = n(d, p || "", l), j = d && p ? k : l, M = !!(_ && (j === "" || j == null)), N = (e) => w === "multi" ? e.replace(/[^+\d.+-]/g, "") : e.replace(/[^+\d.]/g, ""), P = (e, t) => {
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
- }, F = (e) => {
27
- let t = e.target, n = t.textContent || "", r = s(t), i = N(n), a = c(n, r, N), o = {
28
- value: Number(i || 0) * S,
29
- name: p
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
- d && p && d.onValue(o), f && f !== d?.onValue && f(o), t.textContent = i, i.length > 0 && queueMicrotask(() => {
32
- P(Math.min(a, i.length), t);
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
- }, I = (e) => {
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(N(t.textContent || "")) * S,
39
- name: p
39
+ value: Number(M(t.textContent || "")) * T,
40
+ name: m
40
41
  };
41
- T?.(n), d && p && d.setValue(n), f && f !== d?.onValue && f(n), t.textContent = u(t.textContent || "");
42
- }, L = (e) => {
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 = N(t.textContent || ""), r.Focus({ target: e.currentTarget });
45
- }, R = (e) => {
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: p
51
+ name: m
51
52
  };
52
- d && p && d.setValue(n), f && f !== d?.onValue && f(n);
53
- }, z = (e) => {
53
+ f && m && f.setValue(n), p && p !== f?.onValue && p(n);
54
+ }, R = (e) => {
54
55
  e.key === "Enter" && e.preventDefault();
55
- }, B = (e) => {
56
- e.preventDefault(), i(N(e.clipboardData?.getData("text/plain") ?? ""), e.currentTarget);
57
- };
58
- if (!(v && y) && !x || !(v && y) && M) return "";
59
- let V = {};
60
- return V.inputMode = "decimal", m && (V.placeholder = m), v && y && (V.edit = ""), /* @__PURE__ */ o(t, {
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
- title: h,
63
- element_blok: { className: [E] },
63
+ label: g,
64
+ error: _,
65
+ element_blok: { className: [x] },
64
66
  element_input: { className: [e.w] },
65
- children: [/* @__PURE__ */ a("div", {
66
- ...V,
67
- onInput: F,
68
- onPaste: B,
69
- onBlur: I,
70
- onKeyDown: z,
71
- onFocus: L,
72
- role: "textbox",
73
- "aria-label": h || m || "Сумма",
74
- "aria-disabled": O || !(v && y),
75
- tabIndex: O ? -1 : 0,
76
- contentEditable: v && y && !O ? "plaintext-only" : !1,
77
- suppressContentEditableWarning: !0,
78
- "data-after": b,
79
- children: !m || j ? u(j ?? "") : ""
80
- }, A), D && /* @__PURE__ */ a("button", {
81
- type: "button",
82
- onClick: R,
83
- "aria-label": "Очистить поле",
84
- children: "x"
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
- l.displayName = "MoneyField";
89
- function u(e, t) {
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 { l as default };
100
+ export { u as default };
@@ -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, onSave, active, max, edit, title, error, show, hide, value, placeholder, className, maxLength, name, after, before, view, }: TNumeric): import("react/jsx-runtime").JSX.Element;
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
  }
@@ -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 a, jsx as o } from "react/jsx-runtime";
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 s({ form: s, onValue: c, onSave: l, active: u, max: d, edit: f, title: p, error: m, show: h, hide: g, value: _, placeholder: v, className: y, maxLength: b, name: x = "", after: S = "", before: C = "", view: w }) {
9
- f = f === void 0 ? !0 : f, u = u === void 0 ? !0 : u;
10
- let { value: T, version: E } = n(s, x, _);
11
- g = !!(g && (T === "" || T === void 0)) && !(f && u), v = v === void 0 ? "" : v, d = d === void 0 ? 99 : d;
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 > D && (n = n.slice(0, D), t.textContent = n, queueMicrotask(() => {
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: x
23
+ name: f
24
24
  };
25
- s && x && s.onValue(r), c && c !== s?.onValue && c(r);
26
- }, A = (e) => {
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
- }, j = (e) => {
30
- if (O && e.which === 86) return;
31
- if (e.which === 17 || e.which === 91) return O = !0;
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
- D > 0 && t >= D && 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
- }, M = (e) => {
36
- if (e.which === 17 || e.which === 91) return O = !1;
37
- }, N = (e) => r.PasteDigits(D, i(e)), P = (e) => {
38
- r.Blur(e), l?.({
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: x
40
+ name: f
41
41
  });
42
- }, F = {};
43
- return f && u && (F.edit = ""), F.inputMode = "decimal", v && (F.placeholder = v), g ? /* @__PURE__ */ o(a, {}) : /* @__PURE__ */ o(t, {
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
- title: p,
46
- error: m,
47
- element_blok: { className: [y || ""] },
45
+ label: m,
46
+ error: x,
47
+ element_blok: { className: [v || ""] },
48
48
  element_input: { className: [e.w] },
49
- children: /* @__PURE__ */ o("div", {
50
- onPaste: N,
51
- onInput: k,
52
- onFocus: A,
53
- onBlur: P,
54
- onKeyDown: j,
55
- onKeyUp: M,
56
- spellCheck: !0,
57
- role: "textbox",
58
- tabIndex: f && u ? 0 : -1,
59
- "aria-label": p || v || "Число",
60
- contentEditable: f && u ? "plaintext-only" : !1,
61
- suppressContentEditableWarning: !0,
62
- ...F,
63
- children: T
64
- }, E)
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
- s.displayName = "NumberField";
71
+ l.displayName = "NumberField";
68
72
  //#endregion
69
- export { s as default };
73
+ export { l as default };
@@ -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
- title?: string;
10
+ /** Подпись поля */
11
+ label?: string;
10
12
  error?: string;
11
- hide?: boolean;
12
- edit?: boolean;
13
- show?: boolean;
14
- active?: boolean;
15
- after?: string;
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, title, error, hide, edit, active, outFormat, after, modal, options, className, }: Input): import("react/jsx-runtime").JSX.Element;
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
  }
@@ -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 o = (e, t = ",") => (e !== void 0 && e !== "" ? e.split(t) : []).filter((e) => e !== "").reduce((e, t) => (e[t] = !0, e), {});
8
- function s({ value: s, form: c, onValue: l, name: u, placeholder: d = "", separator: f = ",", title: p, error: m, hide: h = !1, edit: g = !0, active: _ = !0, outFormat: v = "object", after: y = "", modal: b, options: x, className: S }) {
9
- let { onModal: C } = r(), { value: w } = n(c, u, s), T = w, E = typeof T == "string" ? o(T, f) : T && typeof T == "object" ? T : {}, D = () => {
10
- if (!(g && _)) return;
11
- if (!b) return console.error("modal - empty");
12
- let e = b.split(".");
13
- C({
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 (l) {
18
+ if (u) {
19
19
  let e = {
20
- value: v === "array" ? Object.keys(t) : v === "string" ? Object.keys(t).filter((e) => t[e]).join(f) : t,
21
- name: u
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 (c && u && c.setValue(e), v) {
23
+ switch (l && d && l.setValue(e), v) {
24
24
  case "array":
25
- l !== c?.onValue && l({
25
+ u !== l?.onValue && u({
26
26
  value: Object.keys(t),
27
- name: u
27
+ name: d
28
28
  });
29
29
  break;
30
30
  case "string":
31
- l !== c?.onValue && l({
32
- value: Object.keys(t).filter((e) => t[e]).join(f),
33
- name: u
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: l !== c?.onValue && l({
36
+ default: u !== l?.onValue && u({
37
37
  value: t,
38
- name: u
38
+ name: d
39
39
  });
40
40
  }
41
41
  }
42
42
  },
43
- onValue: l,
44
- options: x,
45
- fieldName: u,
46
- value: E
43
+ onValue: u,
44
+ options: S,
45
+ fieldName: d,
46
+ value: D
47
47
  });
48
- }, O = {};
49
- return d && (O.placeholder = d), h ? /* @__PURE__ */ a(i, {}) : /* @__PURE__ */ a(t, {
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
- title: p,
52
- error: m,
53
- element_blok: { className: [S || ""] },
53
+ label: m,
54
+ error: h,
55
+ element_blok: { className: [C || ""] },
54
56
  element_input: {
55
57
  className: [e.g],
56
- props: { onClick: D }
58
+ props: { onClick: O }
57
59
  },
58
- children: Object.keys(E).map((e) => /* @__PURE__ */ a("div", { children: x?.[e]?.label }, e))
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
- s.displayName = "OptionsField";
67
+ c.displayName = "OptionsField";
62
68
  //#endregion
63
- export { s as default };
69
+ export { c as default };
@@ -1,5 +1,5 @@
1
1
  import { TPasswordField } from './type';
2
- declare function PasswordField({ value, form, onValue, onSave, name, placeholder, className, title, label, error, edit, active, isReload, native, isShow, maxLength, eyes, after, disabled, }: TPasswordField): import("react/jsx-runtime").JSX.Element | "";
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
  }
@@ -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 "react";
6
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
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 s({ value: s, form: c, onValue: l, onSave: u, name: d = "", placeholder: f = "", className: p, title: m, label: h, error: g, edit: _ = !0, active: v = !0, isReload: y = !1, native: b = !1, isShow: x = !1, maxLength: S, eyes: C = [], after: w = "", disabled: T = !1 }) {
9
- let [E, D] = i.useState(x), { value: O } = n(c, d, s), k = i.useRef(null), A = typeof O == "string" ? O : O == null ? "" : String(O);
10
- i.useEffect(() => {
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: d,
18
- reload: y
57
+ name: p
19
58
  };
20
- c && d && c.onValue(t), l && l !== c?.onValue && l(t);
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), u?.({
65
+ r.Blur(e), y?.({
27
66
  value: (e.target.value || "").trim(),
28
- name: d || ""
67
+ name: p || ""
29
68
  });
30
69
  };
31
- if (b) return "";
32
- let F = _ && v && !T;
33
- return /* @__PURE__ */ o(t, {
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
- title: m || h,
76
+ label: h,
36
77
  error: g,
37
- element_blok: { className: [p || ""] },
78
+ element_blok: { className: [b || ""] },
38
79
  element_input: {
39
80
  className: [e.w],
40
- props: { "data-disabled": T || !F ? "true" : void 0 }
81
+ props: { "data-disabled": v || !F ? "true" : void 0 }
41
82
  },
42
83
  children: [
43
- /* @__PURE__ */ a("div", {
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__ */ a("input", {
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: T,
58
- readOnly: !_ || !v,
59
- maxLength: S,
99
+ disabled: v,
100
+ readOnly: v,
101
+ maxLength: w,
60
102
  spellCheck: !1,
61
103
  autoComplete: "current-password",
62
- "aria-label": m || h || f || "Пароль",
63
- "aria-disabled": T || !F,
64
- tabIndex: T ? -1 : 0,
65
- placeholder: f,
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
- C[0] ? /* @__PURE__ */ a("i", {
80
- role: "button",
81
- tabIndex: T ? -1 : 0,
121
+ /* @__PURE__ */ o("button", {
122
+ type: "button",
123
+ tabIndex: v ? -1 : 0,
82
124
  "aria-label": E ? "Скрыть пароль" : "Показать пароль",
83
125
  "aria-pressed": E,
84
- onClick: () => !T && D(!E),
126
+ disabled: v,
127
+ onClick: () => !v && D(!E),
85
128
  onKeyDown: (e) => {
86
- T || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), D(!E));
129
+ v || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), D(!E));
87
130
  },
88
131
  style: {
89
- cursor: T ? "not-allowed" : "pointer",
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 ? C[1] : C[0]
93
- }) : null,
94
- w
145
+ children: E ? L : I
146
+ }),
147
+ x
95
148
  ]
96
149
  });
97
150
  }
98
- s.displayName = "PasswordField";
151
+ u.displayName = "PasswordField";
99
152
  //#endregion
100
- export { s as default };
153
+ export { u as default };
@@ -1,24 +1,6 @@
1
1
  import { TInput } from './type';
2
- /**
3
- * PhoneField component
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
  }