@elcrm/form 0.0.82 → 0.0.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/styles/Color.module.css +1 -1
- package/dist/assets/styles/Field.module.css +1 -1
- package/dist/assets/styles/Form.module.css +1 -1
- package/dist/assets/styles/Select.module.css +1 -1
- package/dist/core/Field.js +1 -1
- package/dist/fields/Color.js +189 -185
- package/dist/fields/Date.js +145 -140
- package/dist/fields/Password.js +5 -17
- package/dist/fields/Select.js +47 -43
- package/dist/fields/Time.js +107 -104
- package/dist/index.js +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/overlayZ.d.ts +7 -0
- package/dist/overlayZ.js +21 -0
- package/dist/package.js +1 -1
- package/dist/style.css +4 -4
- package/dist/styles/Color.module.js +23 -23
- package/dist/styles/Field.module.js +72 -72
- package/dist/styles/Form.module.js +8 -8
- package/dist/styles/Select.module.js +5 -5
- package/package.json +1 -1
package/dist/fields/Select.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
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
|
-
import r from "../
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { acquireOverlayZIndex as r, releaseOverlayZIndex as i } from "../overlayZ.js";
|
|
5
|
+
import a from "../styles/Select.module.js";
|
|
6
|
+
import o, { useEffect as s, useState as c } from "react";
|
|
7
|
+
import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
8
|
+
import { createPortal as f } from "react-dom";
|
|
8
9
|
//#region src/lib/fields/Select.tsx
|
|
9
|
-
function
|
|
10
|
-
let [w, T] =
|
|
10
|
+
function p({ value: r = 0, form: i, onValue: s, name: c = "", placeholder: p = "", label: h, error: g, hidden: _ = !1, disabled: v = !1, className: y, after: b = "", before: x = "", options: S, order: C }) {
|
|
11
|
+
let [w, T] = o.useState(!1), [E, D] = o.useState(0), [O, k] = o.useState(null), A = o.useId(), { value: j } = n(i, c, r ?? 0), M = Number(j), N = [];
|
|
11
12
|
S && (N = Array.isArray(S) ? S.map((e) => ({
|
|
12
13
|
id: e.id ?? e.i ?? 0,
|
|
13
14
|
label: e.n || "",
|
|
@@ -27,9 +28,9 @@ function l({ value: l = 0, form: d, onValue: f, name: p = "", placeholder: m = "
|
|
|
27
28
|
})().filter((e) => !e.hidden), F = (e) => P.find((t) => t.id === e)?.label, I = w && P.length > 0 ? `${A}-opt-${E}` : void 0, L = (e) => {
|
|
28
29
|
let t = {
|
|
29
30
|
value: e,
|
|
30
|
-
name:
|
|
31
|
+
name: c
|
|
31
32
|
};
|
|
32
|
-
|
|
33
|
+
i && c && i.onValue(t), s && s !== i?.onValue && s(t);
|
|
33
34
|
}, R = (e) => {
|
|
34
35
|
if (P.length === 0 || v) return;
|
|
35
36
|
let t = P.findIndex((e) => e.id === M);
|
|
@@ -63,15 +64,15 @@ function l({ value: l = 0, form: d, onValue: f, name: p = "", placeholder: m = "
|
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
}, V = {};
|
|
66
|
-
|
|
67
|
-
let H = F(M), U = (H === void 0 || H === "") && !!
|
|
68
|
-
return _ && W ? "" : /* @__PURE__ */
|
|
67
|
+
p && (V.placeholder = p);
|
|
68
|
+
let H = F(M), U = (H === void 0 || H === "") && !!p, W = M === 0 || F(M) === void 0;
|
|
69
|
+
return _ && W ? "" : /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ d(t, {
|
|
69
70
|
type: "select",
|
|
70
71
|
label: h,
|
|
71
72
|
element_blok: { className: [y || ""] },
|
|
72
73
|
error: g,
|
|
73
74
|
element_input: {
|
|
74
|
-
className: [
|
|
75
|
+
className: [a.f],
|
|
75
76
|
props: {
|
|
76
77
|
onClick: z,
|
|
77
78
|
onKeyDown: B,
|
|
@@ -86,21 +87,21 @@ function l({ value: l = 0, form: d, onValue: f, name: p = "", placeholder: m = "
|
|
|
86
87
|
}
|
|
87
88
|
},
|
|
88
89
|
children: [
|
|
89
|
-
x ? /* @__PURE__ */
|
|
90
|
+
x ? /* @__PURE__ */ u("span", {
|
|
90
91
|
className: e.affix,
|
|
91
92
|
children: x
|
|
92
93
|
}) : null,
|
|
93
|
-
/* @__PURE__ */
|
|
94
|
+
/* @__PURE__ */ u("div", {
|
|
94
95
|
...V,
|
|
95
|
-
className: U ?
|
|
96
|
-
children: H ??
|
|
96
|
+
className: U ? a.placeholderValue : void 0,
|
|
97
|
+
children: H ?? p ?? ""
|
|
97
98
|
}),
|
|
98
|
-
b ? /* @__PURE__ */
|
|
99
|
+
b ? /* @__PURE__ */ u("span", {
|
|
99
100
|
className: e.affix,
|
|
100
101
|
children: b
|
|
101
102
|
}) : null
|
|
102
103
|
]
|
|
103
|
-
}), w &&
|
|
104
|
+
}), w && f(/* @__PURE__ */ u(m, {
|
|
104
105
|
parent: O || void 0,
|
|
105
106
|
onValue: L,
|
|
106
107
|
className: y,
|
|
@@ -111,37 +112,40 @@ function l({ value: l = 0, form: d, onValue: f, name: p = "", placeholder: m = "
|
|
|
111
112
|
currentValue: M
|
|
112
113
|
}), document.body)] });
|
|
113
114
|
}
|
|
114
|
-
|
|
115
|
-
var
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
115
|
+
p.displayName = "SelectField";
|
|
116
|
+
var m = ({ onValue: e, parent: t, className: n, items: o, setOpen: f, listId: p, activeIndex: m, currentValue: g }) => {
|
|
117
|
+
let [_] = c(() => r());
|
|
118
|
+
if (s(() => () => i(_), [_]), !t) return null;
|
|
119
|
+
let v = () => {
|
|
120
|
+
f(!1);
|
|
121
|
+
}, y = (t) => {
|
|
122
|
+
f(!1), e(t);
|
|
123
|
+
}, b = window.innerHeight - t.bottom < 306 ? Math.max(6, t.top - 300 - 6) : Math.min(window.innerHeight - 300 - 6, t.bottom + 6), x = Math.max(t.width, 260), S = Math.min(Math.max(6, t.left), window.innerWidth - x - 6);
|
|
124
|
+
return /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u("div", {
|
|
125
|
+
className: a.o,
|
|
126
|
+
style: { zIndex: _ },
|
|
127
|
+
onClick: v,
|
|
125
128
|
"aria-hidden": !0
|
|
126
|
-
}), /* @__PURE__ */
|
|
127
|
-
className: [
|
|
129
|
+
}), /* @__PURE__ */ u("div", {
|
|
130
|
+
className: [a.l, n].filter((e) => e !== void 0).join(" "),
|
|
128
131
|
style: {
|
|
129
|
-
top:
|
|
130
|
-
left:
|
|
131
|
-
width:
|
|
132
|
+
top: b + "px",
|
|
133
|
+
left: S + "px",
|
|
134
|
+
width: x,
|
|
135
|
+
zIndex: _ + 1
|
|
132
136
|
},
|
|
133
|
-
children: /* @__PURE__ */
|
|
134
|
-
listId:
|
|
135
|
-
items:
|
|
136
|
-
link:
|
|
137
|
-
activeIndex:
|
|
138
|
-
currentValue:
|
|
137
|
+
children: /* @__PURE__ */ u(h, {
|
|
138
|
+
listId: p,
|
|
139
|
+
items: o,
|
|
140
|
+
link: y,
|
|
141
|
+
activeIndex: m,
|
|
142
|
+
currentValue: g
|
|
139
143
|
})
|
|
140
144
|
})] });
|
|
141
|
-
},
|
|
145
|
+
}, h = ({ listId: e, items: t, link: n, activeIndex: r, currentValue: i }) => /* @__PURE__ */ u("ul", {
|
|
142
146
|
id: e,
|
|
143
147
|
role: "listbox",
|
|
144
|
-
children: t.map((t, a) => /* @__PURE__ */
|
|
148
|
+
children: t.map((t, a) => /* @__PURE__ */ u("li", {
|
|
145
149
|
id: `${e}-opt-${a}`,
|
|
146
150
|
role: "option",
|
|
147
151
|
"aria-selected": i === t.id,
|
|
@@ -151,4 +155,4 @@ var u = ({ onValue: e, parent: t, className: n, items: i, setOpen: c, listId: l,
|
|
|
151
155
|
}, t.id))
|
|
152
156
|
});
|
|
153
157
|
//#endregion
|
|
154
|
-
export {
|
|
158
|
+
export { p as default };
|
package/dist/fields/Time.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 from "../events/onEvent.js";
|
|
5
|
-
import i from "../
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
5
|
+
import { acquireOverlayZIndex as i, releaseOverlayZIndex as a } from "../overlayZ.js";
|
|
6
|
+
import o from "../styles/Select.module.js";
|
|
7
|
+
import s from "react";
|
|
8
|
+
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
9
|
+
import { createPortal as d } from "react-dom";
|
|
9
10
|
//#region src/lib/fields/Time.tsx
|
|
10
|
-
function
|
|
11
|
+
function f(e) {
|
|
11
12
|
let t = window.getSelection();
|
|
12
13
|
if (!t || t.rangeCount === 0) return 0;
|
|
13
14
|
let n = t.getRangeAt(0);
|
|
@@ -15,27 +16,27 @@ function u(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 p(e, t) {
|
|
19
20
|
let n = t.firstChild;
|
|
20
21
|
if (!n || n.nodeType !== Node.TEXT_NODE) return;
|
|
21
22
|
let r = n.textContent?.length ?? 0, i = Math.max(0, Math.min(e, r)), a = document.createRange(), o = window.getSelection();
|
|
22
23
|
o && (a.setStart(n, i), a.collapse(!0), o.removeAllRanges(), o.addRange(a), t.focus());
|
|
23
24
|
}
|
|
24
|
-
function
|
|
25
|
+
function m(e) {
|
|
25
26
|
return String(e).padStart(2, "0");
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
+
function h(e) {
|
|
28
29
|
return (e || "").replace(/\D/g, "");
|
|
29
30
|
}
|
|
30
|
-
function
|
|
31
|
+
function g(e) {
|
|
31
32
|
if (e == null || e === "" || typeof e != "string") return "";
|
|
32
33
|
let t = e.trim(), n = /^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(t);
|
|
33
34
|
if (!n) return "";
|
|
34
35
|
let r = Math.min(23, Math.max(0, parseInt(n[1], 10))), i = Math.min(59, Math.max(0, parseInt(n[2], 10)));
|
|
35
|
-
return `${
|
|
36
|
+
return `${m(r)}:${m(i)}`;
|
|
36
37
|
}
|
|
37
|
-
function
|
|
38
|
-
let t =
|
|
38
|
+
function _(e) {
|
|
39
|
+
let t = g(e);
|
|
39
40
|
if (!t) return {
|
|
40
41
|
h: null,
|
|
41
42
|
m: null
|
|
@@ -46,78 +47,78 @@ function h(e) {
|
|
|
46
47
|
m: r
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
|
-
function
|
|
50
|
+
function v(e, t) {
|
|
50
51
|
if (e === null && t === null) return "";
|
|
51
52
|
let n = e ?? 0, r = t ?? 0;
|
|
52
|
-
return `${
|
|
53
|
+
return `${m(n)}:${m(r)}`;
|
|
53
54
|
}
|
|
54
|
-
function
|
|
55
|
-
let n =
|
|
55
|
+
function y(e, t) {
|
|
56
|
+
let n = h(e).slice(0, 2);
|
|
56
57
|
if (n === "") return null;
|
|
57
58
|
let r = parseInt(n, 10);
|
|
58
59
|
return Number.isNaN(r) ? null : Math.min(t, Math.max(0, r));
|
|
59
60
|
}
|
|
60
|
-
function
|
|
61
|
-
let t =
|
|
61
|
+
function b(e) {
|
|
62
|
+
let t = g(e);
|
|
62
63
|
if (!t) return null;
|
|
63
64
|
let [n, r] = t.split(":").map((e) => parseInt(e, 10));
|
|
64
65
|
return n * 60 + r;
|
|
65
66
|
}
|
|
66
|
-
function
|
|
67
|
+
function x(e, t) {
|
|
67
68
|
let n = Math.max(1, Math.round(t / 60));
|
|
68
69
|
if (n <= 1) return e;
|
|
69
70
|
let r = Math.round(e / n) * n;
|
|
70
71
|
return Math.min(59, Math.max(0, r));
|
|
71
72
|
}
|
|
72
|
-
function
|
|
73
|
-
let r =
|
|
73
|
+
function S(e, t, n) {
|
|
74
|
+
let r = g(e);
|
|
74
75
|
if (!r) return "";
|
|
75
|
-
let i =
|
|
76
|
+
let i = b(r);
|
|
76
77
|
if (i === null) return "";
|
|
77
78
|
if (t) {
|
|
78
|
-
let e =
|
|
79
|
+
let e = b(t);
|
|
79
80
|
e !== null && (i = Math.max(i, e));
|
|
80
81
|
}
|
|
81
82
|
if (n) {
|
|
82
|
-
let e =
|
|
83
|
+
let e = b(n);
|
|
83
84
|
e !== null && (i = Math.min(i, e));
|
|
84
85
|
}
|
|
85
|
-
return
|
|
86
|
+
return v(Math.floor(i / 60), i % 60);
|
|
86
87
|
}
|
|
87
88
|
function ee(e, t, n, r) {
|
|
88
89
|
if (r && r.length > 0) {
|
|
89
90
|
let e = /* @__PURE__ */ new Set(), i = [];
|
|
90
91
|
for (let a of r) {
|
|
91
|
-
let r =
|
|
92
|
-
!r || e.has(r) || (e.add(r), i.push(
|
|
92
|
+
let r = g(a);
|
|
93
|
+
!r || e.has(r) || (e.add(r), i.push(S(r, t, n) || r));
|
|
93
94
|
}
|
|
94
95
|
return i;
|
|
95
96
|
}
|
|
96
97
|
let i = Math.max(1, Math.round(e / 60));
|
|
97
98
|
i < 5 && (i = 15);
|
|
98
|
-
let a = t ?
|
|
99
|
+
let a = t ? b(t) ?? 0 : 0, o = n ? b(n) ?? 1439 : 1439, s = Math.min(1439, o), c = [], l = Math.ceil(a / i) * i;
|
|
99
100
|
for (let e = l; e <= s; e += i) {
|
|
100
101
|
let t = Math.floor(e / 60);
|
|
101
102
|
if (t > 23) break;
|
|
102
103
|
let n = e % 60;
|
|
103
|
-
c.push(
|
|
104
|
+
c.push(v(t, n));
|
|
104
105
|
}
|
|
105
106
|
return c;
|
|
106
107
|
}
|
|
107
108
|
function te() {
|
|
108
|
-
return /* @__PURE__ */
|
|
109
|
+
return /* @__PURE__ */ u("svg", {
|
|
109
110
|
viewBox: "0 0 24 24",
|
|
110
111
|
width: "20",
|
|
111
112
|
height: "20",
|
|
112
113
|
fill: "none",
|
|
113
114
|
"aria-hidden": !0,
|
|
114
|
-
children: [/* @__PURE__ */
|
|
115
|
+
children: [/* @__PURE__ */ l("circle", {
|
|
115
116
|
cx: "12",
|
|
116
117
|
cy: "12",
|
|
117
118
|
r: "8.25",
|
|
118
119
|
stroke: "currentColor",
|
|
119
120
|
strokeWidth: "1.75"
|
|
120
|
-
}), /* @__PURE__ */
|
|
121
|
+
}), /* @__PURE__ */ l("path", {
|
|
121
122
|
d: "M12 7.5V12l3 2",
|
|
122
123
|
stroke: "currentColor",
|
|
123
124
|
strokeWidth: "1.75",
|
|
@@ -126,16 +127,16 @@ function te() {
|
|
|
126
127
|
})]
|
|
127
128
|
});
|
|
128
129
|
}
|
|
129
|
-
function
|
|
130
|
-
let { value: ce, version: le } = n(
|
|
130
|
+
function C({ value: i = "", form: a, onValue: o, onBlur: b, name: C = "", placeholder: re = "", label: w = "", hidden: ie = !1, disabled: T = !1, error: ae = "", className: E = "", after: D = "", before: O = "", step: k = 60, min: A, max: j, id: oe, spellCheck: M = !1, align: se = "start", picker: N = !1, presets: P }) {
|
|
131
|
+
let { value: ce, version: le } = n(a, C, i), F = g(ce), I = !T, L = s.useRef(null), R = s.useRef(null), ue = s.useRef(null), z = s.useRef(null), [B, V] = s.useState(!1), [H, U] = s.useState(!1), [W, G] = s.useState(null), [K, q] = s.useState(0), J = s.useId(), Y = s.useMemo(() => ee(k, A, j, P), [
|
|
131
132
|
k,
|
|
132
133
|
A,
|
|
133
134
|
j,
|
|
134
135
|
P
|
|
135
136
|
]);
|
|
136
|
-
|
|
137
|
+
s.useLayoutEffect(() => {
|
|
137
138
|
if (!B || !I) return;
|
|
138
|
-
let { h: e, m: t } =
|
|
139
|
+
let { h: e, m: t } = _(F), n = (e, t) => {
|
|
139
140
|
e && (t === null ? e.innerHTML = "<br>" : e.textContent = String(t));
|
|
140
141
|
};
|
|
141
142
|
n(L.current, e), n(R.current, t);
|
|
@@ -145,38 +146,38 @@ function x({ value: i = "", form: v, onValue: x, onBlur: S, name: C = "", placeh
|
|
|
145
146
|
le,
|
|
146
147
|
I
|
|
147
148
|
]);
|
|
148
|
-
let X =
|
|
149
|
-
let e =
|
|
149
|
+
let X = s.useCallback(() => {
|
|
150
|
+
let e = y(L.current?.textContent || "", 23), t = y(R.current?.textContent || "", 59);
|
|
150
151
|
if (e === null && t === null) return "";
|
|
151
|
-
let n =
|
|
152
|
+
let n = v(e, t);
|
|
152
153
|
if (!n) return "";
|
|
153
|
-
let { h: r, m: i } =
|
|
154
|
-
return i !== null && (n =
|
|
154
|
+
let { h: r, m: i } = _(n);
|
|
155
|
+
return i !== null && (n = v(r, x(i, k))), n &&= S(n, A, j), n || "";
|
|
155
156
|
}, [
|
|
156
157
|
A,
|
|
157
158
|
j,
|
|
158
159
|
k
|
|
159
|
-
]), Z =
|
|
160
|
-
let t =
|
|
160
|
+
]), Z = s.useCallback((e) => {
|
|
161
|
+
let t = g(e);
|
|
161
162
|
if (t) {
|
|
162
|
-
let { h: e, m: n } =
|
|
163
|
-
n !== null && (t =
|
|
163
|
+
let { h: e, m: n } = _(t);
|
|
164
|
+
n !== null && (t = v(e, x(n, k))), t = S(t, A, j);
|
|
164
165
|
}
|
|
165
|
-
return
|
|
166
|
+
return a && C && a.setValue({
|
|
166
167
|
name: C,
|
|
167
168
|
value: t
|
|
168
|
-
}),
|
|
169
|
+
}), o && o !== a?.onValue && o({
|
|
169
170
|
value: t,
|
|
170
171
|
name: C
|
|
171
172
|
}), t;
|
|
172
173
|
}, [
|
|
173
|
-
|
|
174
|
+
a,
|
|
174
175
|
C,
|
|
175
|
-
|
|
176
|
+
o,
|
|
176
177
|
A,
|
|
177
178
|
j,
|
|
178
179
|
k
|
|
179
|
-
]), de =
|
|
180
|
+
]), de = s.useCallback(() => {
|
|
180
181
|
if (!N || !I || Y.length === 0) return;
|
|
181
182
|
let e = z.current;
|
|
182
183
|
if (!e) return;
|
|
@@ -188,7 +189,7 @@ function x({ value: i = "", form: v, onValue: x, onBlur: S, name: C = "", placeh
|
|
|
188
189
|
Y,
|
|
189
190
|
F
|
|
190
191
|
]);
|
|
191
|
-
|
|
192
|
+
s.useEffect(() => {
|
|
192
193
|
if (!H) return;
|
|
193
194
|
let e = () => {
|
|
194
195
|
let e = z.current;
|
|
@@ -197,7 +198,7 @@ function x({ value: i = "", form: v, onValue: x, onBlur: S, name: C = "", placeh
|
|
|
197
198
|
return window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
|
|
198
199
|
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
|
|
199
200
|
};
|
|
200
|
-
}, [H]),
|
|
201
|
+
}, [H]), s.useEffect(() => {
|
|
201
202
|
if (!H) return;
|
|
202
203
|
let e = (e) => {
|
|
203
204
|
if (e.key === "Escape") {
|
|
@@ -223,25 +224,25 @@ function x({ value: i = "", form: v, onValue: x, onBlur: S, name: C = "", placeh
|
|
|
223
224
|
]);
|
|
224
225
|
let Q = (e) => (t) => {
|
|
225
226
|
if (t.preventDefault(), !I) return;
|
|
226
|
-
let n =
|
|
227
|
+
let n = h(t.clipboardData?.getData("text/plain") ?? ""), r = e === "hour" ? 23 : 59;
|
|
227
228
|
if (n.length >= 4) {
|
|
228
229
|
let e = Math.min(23, Math.max(0, parseInt(n.slice(0, 2), 10))), t = Math.min(59, Math.max(0, parseInt(n.slice(2, 4), 10))), r = L.current, i = R.current;
|
|
229
|
-
r && (r.textContent = String(e), queueMicrotask(() =>
|
|
230
|
+
r && (r.textContent = String(e), queueMicrotask(() => p(String(e).length, r))), i && (i.textContent = String(t), queueMicrotask(() => p(String(t).length, i)));
|
|
230
231
|
return;
|
|
231
232
|
}
|
|
232
233
|
let i = n.slice(0, 2), a = t.currentTarget;
|
|
233
234
|
if (i === "") {
|
|
234
|
-
a.innerHTML = "<br>", queueMicrotask(() =>
|
|
235
|
+
a.innerHTML = "<br>", queueMicrotask(() => p(0, a));
|
|
235
236
|
return;
|
|
236
237
|
}
|
|
237
238
|
let o = parseInt(i, 10);
|
|
238
239
|
if (Number.isNaN(o)) return;
|
|
239
240
|
let s = String(Math.min(r, Math.max(0, o)));
|
|
240
|
-
a.textContent = s, queueMicrotask(() =>
|
|
241
|
+
a.textContent = s, queueMicrotask(() => p(s.length, a));
|
|
241
242
|
}, fe = (e) => {
|
|
242
|
-
let t = e.target, n = t.textContent || "", r =
|
|
243
|
+
let t = e.target, n = t.textContent || "", r = f(t), i = n.slice(0, r).replace(/\D/g, "").length, a = h(n).slice(0, 2);
|
|
243
244
|
if (a === "") {
|
|
244
|
-
t.innerHTML = "<br>", queueMicrotask(() =>
|
|
245
|
+
t.innerHTML = "<br>", queueMicrotask(() => p(0, t));
|
|
245
246
|
return;
|
|
246
247
|
}
|
|
247
248
|
let o = parseInt(a, 10);
|
|
@@ -249,11 +250,11 @@ function x({ value: i = "", form: v, onValue: x, onBlur: S, name: C = "", placeh
|
|
|
249
250
|
let s = String(Math.min(23, Math.max(0, o)));
|
|
250
251
|
t.textContent = s;
|
|
251
252
|
let c = Math.min(i, s.length);
|
|
252
|
-
queueMicrotask(() =>
|
|
253
|
+
queueMicrotask(() => p(c, t));
|
|
253
254
|
}, pe = (e) => {
|
|
254
|
-
let t = e.target, n = t.textContent || "", r =
|
|
255
|
+
let t = e.target, n = t.textContent || "", r = f(t), i = n.slice(0, r).replace(/\D/g, "").length, a = h(n).slice(0, 2);
|
|
255
256
|
if (a === "") {
|
|
256
|
-
t.innerHTML = "<br>", queueMicrotask(() =>
|
|
257
|
+
t.innerHTML = "<br>", queueMicrotask(() => p(0, t));
|
|
257
258
|
return;
|
|
258
259
|
}
|
|
259
260
|
let o = parseInt(a, 10);
|
|
@@ -261,7 +262,7 @@ function x({ value: i = "", form: v, onValue: x, onBlur: S, name: C = "", placeh
|
|
|
261
262
|
let s = String(Math.min(59, Math.max(0, o)));
|
|
262
263
|
t.textContent = s;
|
|
263
264
|
let c = Math.min(i, s.length);
|
|
264
|
-
queueMicrotask(() =>
|
|
265
|
+
queueMicrotask(() => p(c, t));
|
|
265
266
|
}, me = (e) => {
|
|
266
267
|
(e.key === "Enter" || e.key === ":") && (e.preventDefault(), R.current?.focus());
|
|
267
268
|
}, he = (e) => {
|
|
@@ -272,42 +273,42 @@ function x({ value: i = "", form: v, onValue: x, onBlur: S, name: C = "", placeh
|
|
|
272
273
|
}, _e = (e) => {
|
|
273
274
|
r.Blur(e);
|
|
274
275
|
};
|
|
275
|
-
|
|
276
|
+
s.useEffect(() => {
|
|
276
277
|
let e = ue.current;
|
|
277
278
|
if (!e) return;
|
|
278
279
|
let t = (t) => {
|
|
279
280
|
let n = t.relatedTarget;
|
|
280
281
|
if (n && e.contains(n)) return;
|
|
281
282
|
let r = X();
|
|
282
|
-
|
|
283
|
+
a && C && a.setValue({
|
|
283
284
|
name: C,
|
|
284
285
|
value: r
|
|
285
|
-
}),
|
|
286
|
+
}), o && o !== a?.onValue && o({
|
|
286
287
|
value: r,
|
|
287
288
|
name: C
|
|
288
|
-
}),
|
|
289
|
+
}), b && C && b({
|
|
289
290
|
value: r,
|
|
290
291
|
name: C
|
|
291
292
|
}), V(!1);
|
|
292
293
|
};
|
|
293
294
|
return e.addEventListener("focusout", t), () => e.removeEventListener("focusout", t);
|
|
294
295
|
}, [
|
|
295
|
-
|
|
296
|
+
a,
|
|
296
297
|
C,
|
|
297
|
-
|
|
298
|
+
b,
|
|
298
299
|
A,
|
|
299
300
|
j,
|
|
300
301
|
k,
|
|
301
302
|
X
|
|
302
303
|
]);
|
|
303
|
-
let { h: ve, m: ye } =
|
|
304
|
+
let { h: ve, m: ye } = _(F), $ = {};
|
|
304
305
|
I && ($.edit = "");
|
|
305
306
|
let be = { ...$ }, xe = { ...$ };
|
|
306
307
|
re && (be.placeholder = re);
|
|
307
308
|
let Se = F !== "" || B;
|
|
308
|
-
return ie && F === "" ? null : /* @__PURE__ */ c
|
|
309
|
+
return ie && F === "" ? null : /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("div", {
|
|
309
310
|
ref: z,
|
|
310
|
-
children: /* @__PURE__ */
|
|
311
|
+
children: /* @__PURE__ */ u(t, {
|
|
311
312
|
type: "time",
|
|
312
313
|
label: w,
|
|
313
314
|
error: ae,
|
|
@@ -321,17 +322,17 @@ function x({ value: i = "", form: v, onValue: x, onBlur: S, name: C = "", placeh
|
|
|
321
322
|
props: { "data-disabled": T || !I ? "true" : void 0 }
|
|
322
323
|
},
|
|
323
324
|
children: [
|
|
324
|
-
O ? /* @__PURE__ */
|
|
325
|
+
O ? /* @__PURE__ */ l("span", {
|
|
325
326
|
className: e.affix,
|
|
326
327
|
children: O
|
|
327
328
|
}) : null,
|
|
328
|
-
/* @__PURE__ */
|
|
329
|
+
/* @__PURE__ */ u("div", {
|
|
329
330
|
ref: ue,
|
|
330
331
|
className: e.timeInner,
|
|
331
332
|
role: "group",
|
|
332
333
|
"aria-label": w || "Время",
|
|
333
334
|
children: [
|
|
334
|
-
/* @__PURE__ */
|
|
335
|
+
/* @__PURE__ */ l("div", {
|
|
335
336
|
id: oe,
|
|
336
337
|
ref: L,
|
|
337
338
|
className: e.timePart,
|
|
@@ -346,14 +347,14 @@ function x({ value: i = "", form: v, onValue: x, onBlur: S, name: C = "", placeh
|
|
|
346
347
|
onBlur: _e,
|
|
347
348
|
"aria-label": "Часы, 0–23",
|
|
348
349
|
...be,
|
|
349
|
-
children: !I || !B ? ve === null ? "" :
|
|
350
|
+
children: !I || !B ? ve === null ? "" : m(ve) : null
|
|
350
351
|
}),
|
|
351
|
-
Se && /* @__PURE__ */
|
|
352
|
+
Se && /* @__PURE__ */ l("span", {
|
|
352
353
|
className: e.timeSep,
|
|
353
354
|
"aria-hidden": "true",
|
|
354
355
|
children: ":"
|
|
355
356
|
}),
|
|
356
|
-
/* @__PURE__ */
|
|
357
|
+
/* @__PURE__ */ l("div", {
|
|
357
358
|
ref: R,
|
|
358
359
|
className: e.timePart,
|
|
359
360
|
contentEditable: I ? "plaintext-only" : !1,
|
|
@@ -367,11 +368,11 @@ function x({ value: i = "", form: v, onValue: x, onBlur: S, name: C = "", placeh
|
|
|
367
368
|
onBlur: _e,
|
|
368
369
|
"aria-label": "Минуты, 0–59",
|
|
369
370
|
...xe,
|
|
370
|
-
children: !I || !B ? ye === null ? "" :
|
|
371
|
+
children: !I || !B ? ye === null ? "" : m(ye) : null
|
|
371
372
|
})
|
|
372
373
|
]
|
|
373
374
|
}),
|
|
374
|
-
N ? /* @__PURE__ */
|
|
375
|
+
N ? /* @__PURE__ */ l("button", {
|
|
375
376
|
type: "button",
|
|
376
377
|
className: e.timePickerBtn,
|
|
377
378
|
disabled: !I || Y.length === 0,
|
|
@@ -381,15 +382,15 @@ function x({ value: i = "", form: v, onValue: x, onBlur: S, name: C = "", placeh
|
|
|
381
382
|
"aria-controls": J,
|
|
382
383
|
onMouseDown: (e) => e.preventDefault(),
|
|
383
384
|
onClick: de,
|
|
384
|
-
children: /* @__PURE__ */
|
|
385
|
+
children: /* @__PURE__ */ l(te, {})
|
|
385
386
|
}) : null,
|
|
386
|
-
D ? /* @__PURE__ */
|
|
387
|
+
D ? /* @__PURE__ */ l("span", {
|
|
387
388
|
className: e.affix,
|
|
388
389
|
children: D
|
|
389
390
|
}) : null
|
|
390
391
|
]
|
|
391
392
|
})
|
|
392
|
-
}), H && W &&
|
|
393
|
+
}), H && W && d(/* @__PURE__ */ l(ne, {
|
|
393
394
|
parent: W,
|
|
394
395
|
slots: Y,
|
|
395
396
|
current: F,
|
|
@@ -403,39 +404,41 @@ function x({ value: i = "", form: v, onValue: x, onBlur: S, name: C = "", placeh
|
|
|
403
404
|
}
|
|
404
405
|
}), document.body)] });
|
|
405
406
|
}
|
|
406
|
-
|
|
407
|
-
var ne = ({ parent: e, slots: t, current: n, activeIndex: r, listId:
|
|
408
|
-
let
|
|
409
|
-
a.useEffect(() => {
|
|
410
|
-
(
|
|
407
|
+
C.displayName = "TimeField";
|
|
408
|
+
var ne = ({ parent: e, slots: t, current: n, activeIndex: r, listId: d, className: f, setOpen: p, setActiveIndex: m, onPick: h }) => {
|
|
409
|
+
let g = s.useRef(null), [_] = s.useState(() => i());
|
|
410
|
+
s.useEffect(() => () => a(_), [_]), s.useEffect(() => {
|
|
411
|
+
(g.current?.querySelector("[data-focus=\"true\"]"))?.scrollIntoView({ block: "nearest" });
|
|
411
412
|
}, [r]);
|
|
412
|
-
let
|
|
413
|
-
return /* @__PURE__ */ c
|
|
414
|
-
className:
|
|
415
|
-
|
|
413
|
+
let v = window.innerHeight - e.bottom < 306 ? Math.max(6, e.top - 300 - 6) : Math.min(window.innerHeight - 300 - 6, e.bottom + 6), y = Math.max(e.width, 160), b = Math.min(Math.max(6, e.left), window.innerWidth - y - 6);
|
|
414
|
+
return /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("div", {
|
|
415
|
+
className: o.o,
|
|
416
|
+
style: { zIndex: _ },
|
|
417
|
+
onClick: () => p(!1),
|
|
416
418
|
"aria-hidden": !0
|
|
417
|
-
}), /* @__PURE__ */
|
|
418
|
-
className: [
|
|
419
|
+
}), /* @__PURE__ */ l("div", {
|
|
420
|
+
className: [o.l, f].filter((e) => e !== void 0).join(" "),
|
|
419
421
|
style: {
|
|
420
|
-
top:
|
|
421
|
-
left:
|
|
422
|
-
width:
|
|
422
|
+
top: v + "px",
|
|
423
|
+
left: b + "px",
|
|
424
|
+
width: y,
|
|
425
|
+
zIndex: _ + 1
|
|
423
426
|
},
|
|
424
|
-
children: /* @__PURE__ */
|
|
425
|
-
id:
|
|
427
|
+
children: /* @__PURE__ */ l("ul", {
|
|
428
|
+
id: d,
|
|
426
429
|
role: "listbox",
|
|
427
|
-
ref:
|
|
428
|
-
children: t.map((e, t) => /* @__PURE__ */
|
|
429
|
-
id: `${
|
|
430
|
+
ref: g,
|
|
431
|
+
children: t.map((e, t) => /* @__PURE__ */ l("li", {
|
|
432
|
+
id: `${d}-opt-${t}`,
|
|
430
433
|
role: "option",
|
|
431
434
|
"aria-selected": n === e,
|
|
432
435
|
"data-focus": r === t ? "true" : "false",
|
|
433
|
-
onMouseEnter: () =>
|
|
434
|
-
onClick: () =>
|
|
436
|
+
onMouseEnter: () => m(t),
|
|
437
|
+
onClick: () => h(e),
|
|
435
438
|
children: e
|
|
436
439
|
}, e))
|
|
437
440
|
})
|
|
438
441
|
})] });
|
|
439
442
|
};
|
|
440
443
|
//#endregion
|
|
441
|
-
export {
|
|
444
|
+
export { C as default };
|