@elcrm/form 0.0.79 → 0.0.81
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/core/Field.js +1 -1
- package/dist/fields/Code.d.ts +14 -0
- package/dist/fields/Code.js +94 -0
- package/dist/fields/Color.js +133 -91
- package/dist/fields/Date.js +132 -77
- package/dist/fields/Display.d.ts +17 -0
- package/dist/fields/Display.js +49 -0
- package/dist/fields/DragDrop.d.ts +26 -0
- package/dist/fields/DragDrop.js +189 -0
- package/dist/fields/Email.d.ts +8 -0
- package/dist/fields/Email.js +80 -0
- package/dist/fields/File.d.ts +24 -0
- package/dist/fields/File.js +115 -0
- package/dist/fields/Hidden.d.ts +11 -0
- package/dist/fields/Hidden.js +33 -0
- package/dist/fields/Numeric.js +42 -24
- package/dist/fields/Percent.d.ts +13 -0
- package/dist/fields/Percent.js +100 -0
- package/dist/fields/Radio.d.ts +22 -0
- package/dist/fields/Radio.js +88 -0
- package/dist/fields/Rating.d.ts +12 -0
- package/dist/fields/Rating.js +82 -0
- package/dist/fields/RichText.d.ts +14 -0
- package/dist/fields/RichText.js +134 -0
- package/dist/fields/Tags.d.ts +12 -0
- package/dist/fields/Tags.js +97 -0
- package/dist/fields/Time.d.ts +8 -1
- package/dist/fields/Time.js +330 -156
- package/dist/fields/Url.d.ts +8 -0
- package/dist/fields/Url.js +80 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +18 -6
- package/dist/index.umd.js +2 -2
- package/dist/package.js +1 -1
- package/dist/style.css +2 -2
- package/dist/styles/Color.module.js +23 -23
- package/dist/styles/Field.module.js +72 -24
- package/package.json +1 -1
package/dist/fields/Time.js
CHANGED
|
@@ -2,10 +2,12 @@ import e from "../styles/Field.module.js";
|
|
|
2
2
|
import t from "../core/Field.js";
|
|
3
3
|
import { useFormFieldState as n } from "../hooks/use.js";
|
|
4
4
|
import r from "../events/onEvent.js";
|
|
5
|
-
import i from "
|
|
6
|
-
import
|
|
5
|
+
import i from "../styles/Select.module.js";
|
|
6
|
+
import a from "react";
|
|
7
|
+
import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
8
|
+
import { createPortal as l } from "react-dom";
|
|
7
9
|
//#region src/lib/fields/Time.tsx
|
|
8
|
-
function
|
|
10
|
+
function u(e) {
|
|
9
11
|
let t = window.getSelection();
|
|
10
12
|
if (!t || t.rangeCount === 0) return 0;
|
|
11
13
|
let n = t.getRangeAt(0);
|
|
@@ -13,27 +15,27 @@ function s(e) {
|
|
|
13
15
|
let r = document.createRange();
|
|
14
16
|
return r.selectNodeContents(e), r.setEnd(n.startContainer, n.startOffset), r.toString().length;
|
|
15
17
|
}
|
|
16
|
-
function
|
|
18
|
+
function d(e, t) {
|
|
17
19
|
let n = t.firstChild;
|
|
18
20
|
if (!n || n.nodeType !== Node.TEXT_NODE) return;
|
|
19
21
|
let r = n.textContent?.length ?? 0, i = Math.max(0, Math.min(e, r)), a = document.createRange(), o = window.getSelection();
|
|
20
22
|
o && (a.setStart(n, i), a.collapse(!0), o.removeAllRanges(), o.addRange(a), t.focus());
|
|
21
23
|
}
|
|
22
|
-
function
|
|
24
|
+
function f(e) {
|
|
23
25
|
return String(e).padStart(2, "0");
|
|
24
26
|
}
|
|
25
|
-
function
|
|
27
|
+
function p(e) {
|
|
26
28
|
return (e || "").replace(/\D/g, "");
|
|
27
29
|
}
|
|
28
|
-
function
|
|
30
|
+
function m(e) {
|
|
29
31
|
if (e == null || e === "" || typeof e != "string") return "";
|
|
30
32
|
let t = e.trim(), n = /^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(t);
|
|
31
33
|
if (!n) return "";
|
|
32
34
|
let r = Math.min(23, Math.max(0, parseInt(n[1], 10))), i = Math.min(59, Math.max(0, parseInt(n[2], 10)));
|
|
33
|
-
return `${
|
|
35
|
+
return `${f(r)}:${f(i)}`;
|
|
34
36
|
}
|
|
35
|
-
function
|
|
36
|
-
let t =
|
|
37
|
+
function h(e) {
|
|
38
|
+
let t = m(e);
|
|
37
39
|
if (!t) return {
|
|
38
40
|
h: null,
|
|
39
41
|
m: null
|
|
@@ -44,224 +46,396 @@ function f(e) {
|
|
|
44
46
|
m: r
|
|
45
47
|
};
|
|
46
48
|
}
|
|
47
|
-
function
|
|
49
|
+
function g(e, t) {
|
|
48
50
|
if (e === null && t === null) return "";
|
|
49
51
|
let n = e ?? 0, r = t ?? 0;
|
|
50
|
-
return `${
|
|
52
|
+
return `${f(n)}:${f(r)}`;
|
|
51
53
|
}
|
|
52
|
-
function
|
|
53
|
-
let n =
|
|
54
|
+
function _(e, t) {
|
|
55
|
+
let n = p(e).slice(0, 2);
|
|
54
56
|
if (n === "") return null;
|
|
55
57
|
let r = parseInt(n, 10);
|
|
56
58
|
return Number.isNaN(r) ? null : Math.min(t, Math.max(0, r));
|
|
57
59
|
}
|
|
58
|
-
function
|
|
59
|
-
let t =
|
|
60
|
+
function v(e) {
|
|
61
|
+
let t = m(e);
|
|
60
62
|
if (!t) return null;
|
|
61
63
|
let [n, r] = t.split(":").map((e) => parseInt(e, 10));
|
|
62
64
|
return n * 60 + r;
|
|
63
65
|
}
|
|
64
|
-
function
|
|
66
|
+
function y(e, t) {
|
|
65
67
|
let n = Math.max(1, Math.round(t / 60));
|
|
66
68
|
if (n <= 1) return e;
|
|
67
69
|
let r = Math.round(e / n) * n;
|
|
68
70
|
return Math.min(59, Math.max(0, r));
|
|
69
71
|
}
|
|
70
|
-
function
|
|
71
|
-
let r =
|
|
72
|
+
function b(e, t, n) {
|
|
73
|
+
let r = m(e);
|
|
72
74
|
if (!r) return "";
|
|
73
|
-
let i =
|
|
75
|
+
let i = v(r);
|
|
74
76
|
if (i === null) return "";
|
|
75
77
|
if (t) {
|
|
76
|
-
let e =
|
|
78
|
+
let e = v(t);
|
|
77
79
|
e !== null && (i = Math.max(i, e));
|
|
78
80
|
}
|
|
79
81
|
if (n) {
|
|
80
|
-
let e =
|
|
82
|
+
let e = v(n);
|
|
81
83
|
e !== null && (i = Math.min(i, e));
|
|
82
84
|
}
|
|
83
|
-
return
|
|
85
|
+
return g(Math.floor(i / 60), i % 60);
|
|
86
|
+
}
|
|
87
|
+
function ee(e, t, n, r) {
|
|
88
|
+
if (r && r.length > 0) {
|
|
89
|
+
let e = /* @__PURE__ */ new Set(), i = [];
|
|
90
|
+
for (let a of r) {
|
|
91
|
+
let r = m(a);
|
|
92
|
+
!r || e.has(r) || (e.add(r), i.push(b(r, t, n) || r));
|
|
93
|
+
}
|
|
94
|
+
return i;
|
|
95
|
+
}
|
|
96
|
+
let i = Math.max(1, Math.round(e / 60));
|
|
97
|
+
i < 5 && (i = 15);
|
|
98
|
+
let a = t ? v(t) ?? 0 : 0, o = n ? v(n) ?? 1439 : 1439, s = Math.min(1439, o), c = [], l = Math.ceil(a / i) * i;
|
|
99
|
+
for (let e = l; e <= s; e += i) {
|
|
100
|
+
let t = Math.floor(e / 60);
|
|
101
|
+
if (t > 23) break;
|
|
102
|
+
let n = e % 60;
|
|
103
|
+
c.push(g(t, n));
|
|
104
|
+
}
|
|
105
|
+
return c;
|
|
84
106
|
}
|
|
85
|
-
function
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
107
|
+
function te() {
|
|
108
|
+
return /* @__PURE__ */ c("svg", {
|
|
109
|
+
viewBox: "0 0 24 24",
|
|
110
|
+
width: "20",
|
|
111
|
+
height: "20",
|
|
112
|
+
fill: "none",
|
|
113
|
+
"aria-hidden": !0,
|
|
114
|
+
children: [/* @__PURE__ */ s("circle", {
|
|
115
|
+
cx: "12",
|
|
116
|
+
cy: "12",
|
|
117
|
+
r: "8.25",
|
|
118
|
+
stroke: "currentColor",
|
|
119
|
+
strokeWidth: "1.75"
|
|
120
|
+
}), /* @__PURE__ */ s("path", {
|
|
121
|
+
d: "M12 7.5V12l3 2",
|
|
122
|
+
stroke: "currentColor",
|
|
123
|
+
strokeWidth: "1.75",
|
|
124
|
+
strokeLinecap: "round",
|
|
125
|
+
strokeLinejoin: "round"
|
|
126
|
+
})]
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function x({ value: i = "", form: v, onValue: x, onBlur: S, 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 }) {
|
|
130
|
+
let { value: ce, version: le } = n(v, C, i), F = m(ce), I = !T, L = a.useRef(null), R = a.useRef(null), ue = a.useRef(null), z = a.useRef(null), [B, V] = a.useState(!1), [H, U] = a.useState(!1), [W, G] = a.useState(null), [K, q] = a.useState(0), J = a.useId(), Y = a.useMemo(() => ee(k, A, j, P), [
|
|
131
|
+
k,
|
|
132
|
+
A,
|
|
133
|
+
j,
|
|
134
|
+
P
|
|
135
|
+
]);
|
|
136
|
+
a.useLayoutEffect(() => {
|
|
137
|
+
if (!B || !I) return;
|
|
138
|
+
let { h: e, m: t } = h(F), n = (e, t) => {
|
|
90
139
|
e && (t === null ? e.innerHTML = "<br>" : e.textContent = String(t));
|
|
91
140
|
};
|
|
92
|
-
n(
|
|
141
|
+
n(L.current, e), n(R.current, t);
|
|
93
142
|
}, [
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
143
|
+
B,
|
|
144
|
+
F,
|
|
145
|
+
le,
|
|
146
|
+
I
|
|
98
147
|
]);
|
|
99
|
-
let
|
|
100
|
-
let e =
|
|
148
|
+
let X = a.useCallback(() => {
|
|
149
|
+
let e = _(L.current?.textContent || "", 23), t = _(R.current?.textContent || "", 59);
|
|
101
150
|
if (e === null && t === null) return "";
|
|
102
|
-
let n =
|
|
151
|
+
let n = g(e, t);
|
|
103
152
|
if (!n) return "";
|
|
104
|
-
let { h: r, m: i } =
|
|
105
|
-
return i !== null && (n =
|
|
153
|
+
let { h: r, m: i } = h(n);
|
|
154
|
+
return i !== null && (n = g(r, y(i, k))), n &&= b(n, A, j), n || "";
|
|
106
155
|
}, [
|
|
107
156
|
A,
|
|
108
157
|
j,
|
|
109
158
|
k
|
|
110
|
-
]),
|
|
111
|
-
|
|
112
|
-
|
|
159
|
+
]), Z = a.useCallback((e) => {
|
|
160
|
+
let t = m(e);
|
|
161
|
+
if (t) {
|
|
162
|
+
let { h: e, m: n } = h(t);
|
|
163
|
+
n !== null && (t = g(e, y(n, k))), t = b(t, A, j);
|
|
164
|
+
}
|
|
165
|
+
return v && C && v.setValue({
|
|
166
|
+
name: C,
|
|
167
|
+
value: t
|
|
168
|
+
}), x && x !== v?.onValue && x({
|
|
169
|
+
value: t,
|
|
170
|
+
name: C
|
|
171
|
+
}), t;
|
|
172
|
+
}, [
|
|
173
|
+
v,
|
|
174
|
+
C,
|
|
175
|
+
x,
|
|
176
|
+
A,
|
|
177
|
+
j,
|
|
178
|
+
k
|
|
179
|
+
]), de = a.useCallback(() => {
|
|
180
|
+
if (!N || !I || Y.length === 0) return;
|
|
181
|
+
let e = z.current;
|
|
182
|
+
if (!e) return;
|
|
183
|
+
let t = Math.max(0, Y.findIndex((e) => e === F));
|
|
184
|
+
q(t >= 0 ? t : 0), G(e.getBoundingClientRect()), U(!0);
|
|
185
|
+
}, [
|
|
186
|
+
N,
|
|
187
|
+
I,
|
|
188
|
+
Y,
|
|
189
|
+
F
|
|
190
|
+
]);
|
|
191
|
+
a.useEffect(() => {
|
|
192
|
+
if (!H) return;
|
|
193
|
+
let e = () => {
|
|
194
|
+
let e = z.current;
|
|
195
|
+
e && G(e.getBoundingClientRect());
|
|
196
|
+
};
|
|
197
|
+
return window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
|
|
198
|
+
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
|
|
199
|
+
};
|
|
200
|
+
}, [H]), a.useEffect(() => {
|
|
201
|
+
if (!H) return;
|
|
202
|
+
let e = (e) => {
|
|
203
|
+
if (e.key === "Escape") {
|
|
204
|
+
e.preventDefault(), U(!1);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (Y.length !== 0) {
|
|
208
|
+
if (e.key === "ArrowDown") e.preventDefault(), q((e) => (e + 1) % Y.length);
|
|
209
|
+
else if (e.key === "ArrowUp") e.preventDefault(), q((e) => e - 1 < 0 ? Y.length - 1 : e - 1);
|
|
210
|
+
else if (e.key === "Enter") {
|
|
211
|
+
e.preventDefault();
|
|
212
|
+
let t = Y[K];
|
|
213
|
+
t && (Z(t), U(!1));
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
218
|
+
}, [
|
|
219
|
+
H,
|
|
220
|
+
Y,
|
|
221
|
+
K,
|
|
222
|
+
Z
|
|
223
|
+
]);
|
|
224
|
+
let Q = (e) => (t) => {
|
|
225
|
+
if (t.preventDefault(), !I) return;
|
|
226
|
+
let n = p(t.clipboardData?.getData("text/plain") ?? ""), r = e === "hour" ? 23 : 59;
|
|
113
227
|
if (n.length >= 4) {
|
|
114
|
-
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 =
|
|
115
|
-
r && (r.textContent = String(e), queueMicrotask(() =>
|
|
228
|
+
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(() => d(String(e).length, r))), i && (i.textContent = String(t), queueMicrotask(() => d(String(t).length, i)));
|
|
116
230
|
return;
|
|
117
231
|
}
|
|
118
232
|
let i = n.slice(0, 2), a = t.currentTarget;
|
|
119
233
|
if (i === "") {
|
|
120
|
-
a.innerHTML = "<br>", queueMicrotask(() =>
|
|
234
|
+
a.innerHTML = "<br>", queueMicrotask(() => d(0, a));
|
|
121
235
|
return;
|
|
122
236
|
}
|
|
123
237
|
let o = parseInt(i, 10);
|
|
124
238
|
if (Number.isNaN(o)) return;
|
|
125
239
|
let s = String(Math.min(r, Math.max(0, o)));
|
|
126
|
-
a.textContent = s, queueMicrotask(() =>
|
|
127
|
-
},
|
|
128
|
-
let t = e.target, n = t.textContent || "", r =
|
|
240
|
+
a.textContent = s, queueMicrotask(() => d(s.length, a));
|
|
241
|
+
}, fe = (e) => {
|
|
242
|
+
let t = e.target, n = t.textContent || "", r = u(t), i = n.slice(0, r).replace(/\D/g, "").length, a = p(n).slice(0, 2);
|
|
129
243
|
if (a === "") {
|
|
130
|
-
t.innerHTML = "<br>", queueMicrotask(() =>
|
|
244
|
+
t.innerHTML = "<br>", queueMicrotask(() => d(0, t));
|
|
131
245
|
return;
|
|
132
246
|
}
|
|
133
247
|
let o = parseInt(a, 10);
|
|
134
248
|
if (Number.isNaN(o)) return;
|
|
135
|
-
let
|
|
136
|
-
t.textContent =
|
|
137
|
-
let
|
|
138
|
-
queueMicrotask(() => c
|
|
139
|
-
},
|
|
140
|
-
let t = e.target, n = t.textContent || "", r =
|
|
249
|
+
let s = String(Math.min(23, Math.max(0, o)));
|
|
250
|
+
t.textContent = s;
|
|
251
|
+
let c = Math.min(i, s.length);
|
|
252
|
+
queueMicrotask(() => d(c, t));
|
|
253
|
+
}, pe = (e) => {
|
|
254
|
+
let t = e.target, n = t.textContent || "", r = u(t), i = n.slice(0, r).replace(/\D/g, "").length, a = p(n).slice(0, 2);
|
|
141
255
|
if (a === "") {
|
|
142
|
-
t.innerHTML = "<br>", queueMicrotask(() =>
|
|
256
|
+
t.innerHTML = "<br>", queueMicrotask(() => d(0, t));
|
|
143
257
|
return;
|
|
144
258
|
}
|
|
145
259
|
let o = parseInt(a, 10);
|
|
146
260
|
if (Number.isNaN(o)) return;
|
|
147
|
-
let
|
|
148
|
-
t.textContent =
|
|
149
|
-
let
|
|
150
|
-
queueMicrotask(() => c
|
|
151
|
-
},
|
|
152
|
-
(e.key === "Enter" || e.key === ":") && (e.preventDefault(),
|
|
153
|
-
},
|
|
261
|
+
let s = String(Math.min(59, Math.max(0, o)));
|
|
262
|
+
t.textContent = s;
|
|
263
|
+
let c = Math.min(i, s.length);
|
|
264
|
+
queueMicrotask(() => d(c, t));
|
|
265
|
+
}, me = (e) => {
|
|
266
|
+
(e.key === "Enter" || e.key === ":") && (e.preventDefault(), R.current?.focus());
|
|
267
|
+
}, he = (e) => {
|
|
154
268
|
e.key === "Enter" && e.preventDefault();
|
|
155
|
-
},
|
|
269
|
+
}, ge = (e) => {
|
|
156
270
|
let t = e.currentTarget;
|
|
157
|
-
(t.textContent || "").trim().length || (t.innerHTML = "<br>"),
|
|
158
|
-
},
|
|
271
|
+
(t.textContent || "").trim().length || (t.innerHTML = "<br>"), I && V(!0);
|
|
272
|
+
}, _e = (e) => {
|
|
159
273
|
r.Blur(e);
|
|
160
274
|
};
|
|
161
|
-
|
|
162
|
-
let e =
|
|
275
|
+
a.useEffect(() => {
|
|
276
|
+
let e = ue.current;
|
|
163
277
|
if (!e) return;
|
|
164
278
|
let t = (t) => {
|
|
165
279
|
let n = t.relatedTarget;
|
|
166
280
|
if (n && e.contains(n)) return;
|
|
167
|
-
let r =
|
|
168
|
-
|
|
169
|
-
name:
|
|
281
|
+
let r = X();
|
|
282
|
+
v && C && v.setValue({
|
|
283
|
+
name: C,
|
|
170
284
|
value: r
|
|
171
|
-
}),
|
|
285
|
+
}), x && x !== v?.onValue && x({
|
|
172
286
|
value: r,
|
|
173
|
-
name:
|
|
174
|
-
}),
|
|
287
|
+
name: C
|
|
288
|
+
}), S && C && S({
|
|
175
289
|
value: r,
|
|
176
|
-
name:
|
|
177
|
-
}),
|
|
290
|
+
name: C
|
|
291
|
+
}), V(!1);
|
|
178
292
|
};
|
|
179
293
|
return e.addEventListener("focusout", t), () => e.removeEventListener("focusout", t);
|
|
180
294
|
}, [
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
295
|
+
v,
|
|
296
|
+
C,
|
|
297
|
+
S,
|
|
184
298
|
A,
|
|
185
299
|
j,
|
|
186
300
|
k,
|
|
187
|
-
|
|
301
|
+
X
|
|
188
302
|
]);
|
|
189
|
-
let { h:
|
|
190
|
-
|
|
191
|
-
let
|
|
192
|
-
|
|
193
|
-
let
|
|
194
|
-
return
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
className: [
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
303
|
+
let { h: ve, m: ye } = h(F), $ = {};
|
|
304
|
+
I && ($.edit = "");
|
|
305
|
+
let be = { ...$ }, xe = { ...$ };
|
|
306
|
+
re && (be.placeholder = re);
|
|
307
|
+
let Se = F !== "" || B;
|
|
308
|
+
return ie && F === "" ? null : /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ s("div", {
|
|
309
|
+
ref: z,
|
|
310
|
+
children: /* @__PURE__ */ c(t, {
|
|
311
|
+
type: "time",
|
|
312
|
+
label: w,
|
|
313
|
+
error: ae,
|
|
314
|
+
element_blok: { className: [E || ""] },
|
|
315
|
+
element_input: {
|
|
316
|
+
className: [
|
|
317
|
+
e.w,
|
|
318
|
+
e.time,
|
|
319
|
+
se === "center" ? e.timeAlignCenter : ""
|
|
320
|
+
].filter(Boolean),
|
|
321
|
+
props: { "data-disabled": T || !I ? "true" : void 0 }
|
|
322
|
+
},
|
|
323
|
+
children: [
|
|
324
|
+
O ? /* @__PURE__ */ s("span", {
|
|
325
|
+
className: e.affix,
|
|
326
|
+
children: O
|
|
327
|
+
}) : null,
|
|
328
|
+
/* @__PURE__ */ c("div", {
|
|
329
|
+
ref: ue,
|
|
330
|
+
className: e.timeInner,
|
|
331
|
+
role: "group",
|
|
332
|
+
"aria-label": w || "Время",
|
|
333
|
+
children: [
|
|
334
|
+
/* @__PURE__ */ s("div", {
|
|
335
|
+
id: oe,
|
|
336
|
+
ref: L,
|
|
337
|
+
className: e.timePart,
|
|
338
|
+
contentEditable: I ? "plaintext-only" : !1,
|
|
339
|
+
suppressContentEditableWarning: !0,
|
|
340
|
+
spellCheck: M,
|
|
341
|
+
inputMode: "numeric",
|
|
342
|
+
onPaste: Q("hour"),
|
|
343
|
+
onInput: fe,
|
|
344
|
+
onKeyDown: me,
|
|
345
|
+
onFocus: ge,
|
|
346
|
+
onBlur: _e,
|
|
347
|
+
"aria-label": "Часы, 0–23",
|
|
348
|
+
...be,
|
|
349
|
+
children: !I || !B ? ve === null ? "" : f(ve) : null
|
|
350
|
+
}),
|
|
351
|
+
Se && /* @__PURE__ */ s("span", {
|
|
352
|
+
className: e.timeSep,
|
|
353
|
+
"aria-hidden": "true",
|
|
354
|
+
children: ":"
|
|
355
|
+
}),
|
|
356
|
+
/* @__PURE__ */ s("div", {
|
|
357
|
+
ref: R,
|
|
358
|
+
className: e.timePart,
|
|
359
|
+
contentEditable: I ? "plaintext-only" : !1,
|
|
360
|
+
suppressContentEditableWarning: !0,
|
|
361
|
+
spellCheck: M,
|
|
362
|
+
inputMode: "numeric",
|
|
363
|
+
onPaste: Q("minute"),
|
|
364
|
+
onInput: pe,
|
|
365
|
+
onKeyDown: he,
|
|
366
|
+
onFocus: ge,
|
|
367
|
+
onBlur: _e,
|
|
368
|
+
"aria-label": "Минуты, 0–59",
|
|
369
|
+
...xe,
|
|
370
|
+
children: !I || !B ? ye === null ? "" : f(ye) : null
|
|
371
|
+
})
|
|
372
|
+
]
|
|
373
|
+
}),
|
|
374
|
+
N ? /* @__PURE__ */ s("button", {
|
|
375
|
+
type: "button",
|
|
376
|
+
className: e.timePickerBtn,
|
|
377
|
+
disabled: !I || Y.length === 0,
|
|
378
|
+
"aria-label": "Быстрый выбор времени",
|
|
379
|
+
"aria-haspopup": "listbox",
|
|
380
|
+
"aria-expanded": H,
|
|
381
|
+
"aria-controls": J,
|
|
382
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
383
|
+
onClick: de,
|
|
384
|
+
children: /* @__PURE__ */ s(te, {})
|
|
385
|
+
}) : null,
|
|
386
|
+
D ? /* @__PURE__ */ s("span", {
|
|
387
|
+
className: e.affix,
|
|
388
|
+
children: D
|
|
389
|
+
}) : null
|
|
390
|
+
]
|
|
391
|
+
})
|
|
392
|
+
}), H && W && l(/* @__PURE__ */ s(ne, {
|
|
393
|
+
parent: W,
|
|
394
|
+
slots: Y,
|
|
395
|
+
current: F,
|
|
396
|
+
activeIndex: K,
|
|
397
|
+
listId: J,
|
|
398
|
+
className: E,
|
|
399
|
+
setOpen: U,
|
|
400
|
+
setActiveIndex: q,
|
|
401
|
+
onPick: (e) => {
|
|
402
|
+
Z(e), U(!1);
|
|
403
|
+
}
|
|
404
|
+
}), document.body)] });
|
|
264
405
|
}
|
|
265
|
-
|
|
406
|
+
x.displayName = "TimeField";
|
|
407
|
+
var ne = ({ parent: e, slots: t, current: n, activeIndex: r, listId: l, className: u, setOpen: d, setActiveIndex: f, onPick: p }) => {
|
|
408
|
+
let m = a.useRef(null);
|
|
409
|
+
a.useEffect(() => {
|
|
410
|
+
(m.current?.querySelector("[data-focus=\"true\"]"))?.scrollIntoView({ block: "nearest" });
|
|
411
|
+
}, [r]);
|
|
412
|
+
let h = window.innerHeight - e.bottom < 306 ? Math.max(6, e.top - 300 - 6) : Math.min(window.innerHeight - 300 - 6, e.bottom + 6), g = Math.max(e.width, 160), _ = Math.min(Math.max(6, e.left), window.innerWidth - g - 6);
|
|
413
|
+
return /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ s("div", {
|
|
414
|
+
className: i.o,
|
|
415
|
+
onClick: () => d(!1),
|
|
416
|
+
"aria-hidden": !0
|
|
417
|
+
}), /* @__PURE__ */ s("div", {
|
|
418
|
+
className: [i.l, u].filter((e) => e !== void 0).join(" "),
|
|
419
|
+
style: {
|
|
420
|
+
top: h + "px",
|
|
421
|
+
left: _ + "px",
|
|
422
|
+
width: g
|
|
423
|
+
},
|
|
424
|
+
children: /* @__PURE__ */ s("ul", {
|
|
425
|
+
id: l,
|
|
426
|
+
role: "listbox",
|
|
427
|
+
ref: m,
|
|
428
|
+
children: t.map((e, t) => /* @__PURE__ */ s("li", {
|
|
429
|
+
id: `${l}-opt-${t}`,
|
|
430
|
+
role: "option",
|
|
431
|
+
"aria-selected": n === e,
|
|
432
|
+
"data-focus": r === t ? "true" : "false",
|
|
433
|
+
onMouseEnter: () => f(t),
|
|
434
|
+
onClick: () => p(e),
|
|
435
|
+
children: e
|
|
436
|
+
}, e))
|
|
437
|
+
})
|
|
438
|
+
})] });
|
|
439
|
+
};
|
|
266
440
|
//#endregion
|
|
267
|
-
export {
|
|
441
|
+
export { x as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TInput } from './type';
|
|
2
|
+
/** UrlField — нативный input type=url. */
|
|
3
|
+
export type TUrl = TInput;
|
|
4
|
+
declare function UrlField({ value, form, onValue, onBlur: onBlurField, name, placeholder, label, error, hidden, disabled, className, after, before, maxLength, autoComplete, id, }: TUrl): import("react/jsx-runtime").JSX.Element | null;
|
|
5
|
+
declare namespace UrlField {
|
|
6
|
+
var displayName: string;
|
|
7
|
+
}
|
|
8
|
+
export default UrlField;
|