@component-hook/picker 1.4.4 → 1.5.0
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/react/index.css +1 -1
- package/dist/react/picker.es.d.ts +10286 -0
- package/dist/react/picker.es.js +600 -720
- package/dist/react/picker.umd.js +3 -3
- package/dist/vue/index.css +1 -1
- package/dist/vue/picker.es.d.ts +10356 -59
- package/dist/vue/picker.es.js +428 -424
- package/dist/vue/picker.umd.js +2 -2
- package/package.json +7 -6
package/dist/vue/picker.es.js
CHANGED
|
@@ -1,447 +1,451 @@
|
|
|
1
1
|
import "./index.css";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { Fragment as e, computed as t, createBlock as n, createElementBlock as r, createElementVNode as i, defineComponent as a, mergeModels as o, nextTick as s, normalizeStyle as c, openBlock as l, readonly as u, ref as d, renderList as f, renderSlot as p, toDisplayString as m, toRef as h, unref as g, useModel as _, useTemplateRef as v, watchEffect as y, withModifiers as b } from "vue";
|
|
3
|
+
//#region src/shared/constants.ts
|
|
4
|
+
var x = .52, S = .008, C = [
|
|
5
|
+
"year",
|
|
6
|
+
"month",
|
|
7
|
+
"day"
|
|
8
|
+
], w = [
|
|
9
|
+
"hour",
|
|
10
|
+
"minute",
|
|
11
|
+
"second"
|
|
12
|
+
], T = Array.isArray;
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/shared/utils/common.ts
|
|
15
|
+
function E(e, t) {
|
|
16
|
+
if (j(e)) return "multiple";
|
|
17
|
+
let [n] = e;
|
|
18
|
+
return n?.[t.children] ? "cascade" : "single";
|
|
8
19
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
20
|
+
function D(e) {
|
|
21
|
+
return {
|
|
22
|
+
children: e?.children || "children",
|
|
23
|
+
label: e?.label || "label",
|
|
24
|
+
value: e?.value || "value"
|
|
25
|
+
};
|
|
15
26
|
}
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
return o;
|
|
27
|
+
function O(e, t, n) {
|
|
28
|
+
if (j(e)) return [];
|
|
29
|
+
let r = [], i = e, a = 0;
|
|
30
|
+
for (; i;) {
|
|
31
|
+
let e = t[a], o = A(i, e, n);
|
|
32
|
+
o === -1 && (o = 0), r.push(i), a += 1, i = i[o]?.[n.children];
|
|
33
|
+
}
|
|
34
|
+
return r;
|
|
26
35
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return u;
|
|
36
|
+
function k(e, t, n, r) {
|
|
37
|
+
let i = [...n], a = e, o = t + 1;
|
|
38
|
+
for (; a?.[r.children];) {
|
|
39
|
+
let e = a[r.children][0];
|
|
40
|
+
i[o] = e.value, a = e, o += 1;
|
|
41
|
+
}
|
|
42
|
+
return i;
|
|
35
43
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
44
|
+
function A(e, t, n) {
|
|
45
|
+
return e.findIndex((e) => e?.[n.value] === t);
|
|
38
46
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
function j(e) {
|
|
48
|
+
let [t] = e;
|
|
49
|
+
return T(t);
|
|
42
50
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
51
|
+
function M(e, t) {
|
|
52
|
+
return e > t ? "horizontal" : t > e ? "vertical" : "";
|
|
45
53
|
}
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const i = f(`${u}`);
|
|
50
|
-
o.push({ label: i, value: u });
|
|
51
|
-
}
|
|
52
|
-
return o;
|
|
54
|
+
function N() {
|
|
55
|
+
let { fontSize: e } = getComputedStyle(document.documentElement);
|
|
56
|
+
return Number(e.replace("px", "")) || 16;
|
|
53
57
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
58
|
+
function P(e, t, n) {
|
|
59
|
+
let r = [];
|
|
60
|
+
for (let i = e; i <= t; i++) {
|
|
61
|
+
let e = n(String(i));
|
|
62
|
+
r.push({
|
|
63
|
+
label: e,
|
|
64
|
+
value: i
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return r;
|
|
56
68
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
69
|
+
function F(e, t) {
|
|
70
|
+
return e === t.getFullYear();
|
|
59
71
|
}
|
|
60
|
-
function
|
|
61
|
-
|
|
72
|
+
function I(e, t) {
|
|
73
|
+
return e === t.getFullYear();
|
|
62
74
|
}
|
|
63
|
-
function
|
|
64
|
-
|
|
75
|
+
function L(e, t) {
|
|
76
|
+
return e === t.getMonth() + 1;
|
|
65
77
|
}
|
|
66
|
-
function
|
|
67
|
-
|
|
78
|
+
function R(e, t) {
|
|
79
|
+
return e === t.getMonth() + 1;
|
|
68
80
|
}
|
|
69
|
-
function
|
|
70
|
-
|
|
71
|
-
return f === "year" ? m ? o.getFullYear() : e.getFullYear() : f === "month" ? m ? o.getMonth() + 1 : e.getMonth() + 1 : m ? o.getDate() : e.getDate();
|
|
81
|
+
function z(e, t) {
|
|
82
|
+
return new Date(e, t, 0).getDate();
|
|
72
83
|
}
|
|
73
|
-
function
|
|
74
|
-
|
|
84
|
+
function B(e, t, n) {
|
|
85
|
+
let r = /* @__PURE__ */ new Date(), i = Date.now(), a = e.getTime(), o = t.getTime(), s = i >= a && i <= o;
|
|
86
|
+
return n === "year" ? s ? r.getFullYear() : e.getFullYear() : n === "month" ? (s ? r.getMonth() : e.getMonth()) + 1 : s ? r.getDate() : e.getDate();
|
|
75
87
|
}
|
|
76
|
-
function
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
function ee(e) {
|
|
80
|
-
if (!De(e)) return null;
|
|
81
|
-
const [l, f, o] = e.split(":");
|
|
82
|
-
return { hour: Number(l), minute: Number(f), second: Number(o) };
|
|
88
|
+
function V(e) {
|
|
89
|
+
return e;
|
|
83
90
|
}
|
|
84
91
|
function H(e) {
|
|
85
|
-
|
|
92
|
+
return /^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d$/.test(e);
|
|
93
|
+
}
|
|
94
|
+
function U(e) {
|
|
95
|
+
if (!H(e)) return null;
|
|
96
|
+
let [t, n, r] = e.split(":");
|
|
97
|
+
return {
|
|
98
|
+
hour: Number(t),
|
|
99
|
+
minute: Number(n),
|
|
100
|
+
second: Number(r)
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function W(e) {
|
|
104
|
+
return e.padStart(2, "0");
|
|
86
105
|
}
|
|
87
|
-
function
|
|
88
|
-
|
|
89
|
-
|
|
106
|
+
function G(e, t, n) {
|
|
107
|
+
let r = Date.now(), { hour: i, minute: a, second: o } = e, { hour: s, minute: c, second: l } = t, u = (/* @__PURE__ */ new Date()).setHours(i, a, o), d = (/* @__PURE__ */ new Date()).setHours(s, c, l), f = r >= u && r <= d;
|
|
108
|
+
return n === "hour" ? f ? (/* @__PURE__ */ new Date()).getHours() : i : n === "minute" ? f ? (/* @__PURE__ */ new Date()).getMinutes() : a : f ? (/* @__PURE__ */ new Date()).getSeconds() : o;
|
|
90
109
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
isVertical: f,
|
|
127
|
-
isHorizontal: o
|
|
128
|
-
};
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/shared/utils/pointer.ts
|
|
112
|
+
function K() {
|
|
113
|
+
let e = {
|
|
114
|
+
startX: 0,
|
|
115
|
+
startY: 0,
|
|
116
|
+
deltaX: 0,
|
|
117
|
+
deltaY: 0,
|
|
118
|
+
offsetX: 0,
|
|
119
|
+
offsetY: 0
|
|
120
|
+
}, t = "", n = !0, r = () => t === "vertical", i = () => t === "horizontal";
|
|
121
|
+
function a() {
|
|
122
|
+
e.deltaX = 0, e.deltaY = 0, e.offsetX = 0, e.offsetY = 0, t = "", n = !0;
|
|
123
|
+
}
|
|
124
|
+
function o(t) {
|
|
125
|
+
let n = "touches" in t ? t.touches[0] : t;
|
|
126
|
+
a(), e.startX = n.clientX, e.startY = n.clientY;
|
|
127
|
+
}
|
|
128
|
+
function s(r) {
|
|
129
|
+
if (!e.startX || !e.startY) return !0;
|
|
130
|
+
let i = "touches" in r ? r.touches[0] : r;
|
|
131
|
+
e.deltaX = Math.max(i.clientX, 0) - e.startX, e.deltaY = i.clientY - e.startY, e.offsetX = Math.abs(e.deltaX), e.offsetY = Math.abs(e.deltaY), (!t || e.offsetX < 10 && e.offsetY < 10) && (t = M(e.offsetX, e.offsetY)), n && (e.offsetX > 5 || e.offsetY > 5) && (n = !1);
|
|
132
|
+
}
|
|
133
|
+
function c() {
|
|
134
|
+
e.startX = 0, e.startY = 0;
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
pointer: e,
|
|
138
|
+
move: s,
|
|
139
|
+
start: o,
|
|
140
|
+
stop: c,
|
|
141
|
+
reset: a,
|
|
142
|
+
isVertical: r,
|
|
143
|
+
isHorizontal: i
|
|
144
|
+
};
|
|
129
145
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/vue/hooks/use-scroll-snap.ts
|
|
148
|
+
function q({ column: e, onChange: t }) {
|
|
149
|
+
let n = N() / 16, r = d(0), i = d(0), { pointer: a, start: o, move: s, stop: c } = K(), l = 0, f = 0, p = 0, m = !1, h = null;
|
|
150
|
+
function _(e) {
|
|
151
|
+
o(e), m = !0, i.value = 0, f = Date.now(), l = r.value, p = l, h = null;
|
|
152
|
+
}
|
|
153
|
+
function v(t) {
|
|
154
|
+
if (s(t)) return;
|
|
155
|
+
let n = g(e).length, i = l + a.deltaY, o = T((n - 1) * -48), c = Math.min(Math.max(i, o), 0), u = Date.now();
|
|
156
|
+
r.value = c, !(u - f <= 300) && (f = u, p = c);
|
|
157
|
+
}
|
|
158
|
+
function y() {
|
|
159
|
+
c();
|
|
160
|
+
let e = r.value - p, t = Date.now() - f;
|
|
161
|
+
if (t < 300 && Math.abs(e) > 15) {
|
|
162
|
+
b(e, t);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
let n = w(r.value);
|
|
166
|
+
i.value = 150, C(n), m = !1;
|
|
167
|
+
}
|
|
168
|
+
function b(e, t) {
|
|
169
|
+
let n = Math.abs(e / t), a = w(r.value + n / S * (e < 0 ? -1 : 1));
|
|
170
|
+
i.value = 300, C(a);
|
|
171
|
+
}
|
|
172
|
+
function x() {
|
|
173
|
+
i.value = 0, m = !1, h &&= (h(), null);
|
|
174
|
+
}
|
|
175
|
+
function C(e) {
|
|
176
|
+
let n = -e * T(48), i = () => t?.(e);
|
|
177
|
+
m && n !== r.value ? h = i : i(), r.value = n;
|
|
178
|
+
}
|
|
179
|
+
function w(t) {
|
|
180
|
+
let n = g(e).length, r = Math.round(-t / T(48));
|
|
181
|
+
return r < 0 ? 0 : r >= n ? n - 1 : r;
|
|
182
|
+
}
|
|
183
|
+
function T(e) {
|
|
184
|
+
return e * n;
|
|
185
|
+
}
|
|
186
|
+
function E(e, t = "auto") {
|
|
187
|
+
m && t === "smooth" || (h = null, m = t === "smooth", i.value = t === "smooth" ? 150 : 0, C(e));
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
offsetY: u(r),
|
|
191
|
+
transitionDuration: u(i),
|
|
192
|
+
onPointerDown: _,
|
|
193
|
+
onPointerMove: v,
|
|
194
|
+
onPointerUp: y,
|
|
195
|
+
stopInertialSliding: x,
|
|
196
|
+
scrollToIndex: E
|
|
197
|
+
};
|
|
181
198
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
})
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
}
|
|
433
|
-
return l({
|
|
434
|
-
setCurrentTime: s
|
|
435
|
-
}), (t, n) => (k(), B(ae, {
|
|
436
|
-
modelValue: i.value,
|
|
437
|
-
"onUpdate:modelValue": n[0] || (n[0] = (a) => i.value = a),
|
|
438
|
-
columns: v.value,
|
|
439
|
-
onChange: n[1] || (n[1] = (a) => u("change", a))
|
|
440
|
-
}, null, 8, ["modelValue", "columns"]));
|
|
441
|
-
}
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region src/vue/components/PickerColumn.vue?vue&type=script&setup=true&lang.ts
|
|
201
|
+
var J = ["onClick"], Y = /* @__PURE__ */ a({
|
|
202
|
+
__name: "PickerColumn",
|
|
203
|
+
props: {
|
|
204
|
+
column: {},
|
|
205
|
+
fields: {},
|
|
206
|
+
selectedIndex: { default: 0 }
|
|
207
|
+
},
|
|
208
|
+
emits: ["change"],
|
|
209
|
+
setup(t, { expose: n, emit: a }) {
|
|
210
|
+
let o = t, s = a, { offsetY: u, transitionDuration: d, onPointerDown: p, onPointerMove: _, onPointerUp: v, stopInertialSliding: y, scrollToIndex: S } = q({
|
|
211
|
+
column: h(o, "column"),
|
|
212
|
+
onChange: C
|
|
213
|
+
});
|
|
214
|
+
function C(e) {
|
|
215
|
+
e !== o.selectedIndex && s("change", e);
|
|
216
|
+
}
|
|
217
|
+
function w(e = o.selectedIndex, t) {
|
|
218
|
+
S(e, t);
|
|
219
|
+
}
|
|
220
|
+
function T(e) {
|
|
221
|
+
e !== o.selectedIndex && w(e, "smooth");
|
|
222
|
+
}
|
|
223
|
+
return n({ scrollToSelected: w }), (n, a) => (l(), r("div", {
|
|
224
|
+
class: "chook-picker-column",
|
|
225
|
+
"aria-label": "Picker column",
|
|
226
|
+
onTouchstartPassive: a[1] ||= (...e) => g(p) && g(p)(...e),
|
|
227
|
+
onTouchmove: a[2] ||= b((...e) => g(_) && g(_)(...e), ["prevent"]),
|
|
228
|
+
onTouchendPassive: a[3] ||= (...e) => g(v) && g(v)(...e),
|
|
229
|
+
onTouchcancel: a[4] ||= (...e) => g(v) && g(v)(...e),
|
|
230
|
+
onMousedownPassive: a[5] ||= (...e) => g(p) && g(p)(...e),
|
|
231
|
+
onMousemovePassive: a[6] ||= (...e) => g(_) && g(_)(...e),
|
|
232
|
+
onMouseupPassive: a[7] ||= (...e) => g(v) && g(v)(...e),
|
|
233
|
+
onMouseleavePassive: a[8] ||= (...e) => g(v) && g(v)(...e)
|
|
234
|
+
}, [i("ul", {
|
|
235
|
+
style: c({
|
|
236
|
+
overflowY: "hidden",
|
|
237
|
+
"--offset-y": `${g(u)}`,
|
|
238
|
+
transform: "translate3d(0, calc(var(--offset-y) * 1px), 0)",
|
|
239
|
+
transitionDuration: `${g(d)}ms`,
|
|
240
|
+
transitionProperty: g(d) ? "all" : "none"
|
|
241
|
+
}),
|
|
242
|
+
onTransitionend: a[0] ||= (...e) => g(y) && g(y)(...e)
|
|
243
|
+
}, [(l(!0), r(e, null, f(t.column, (e, n) => (l(), r("li", {
|
|
244
|
+
key: e?.[t.fields.value],
|
|
245
|
+
class: "chook-picker-column-item",
|
|
246
|
+
role: "button",
|
|
247
|
+
tabindex: "0",
|
|
248
|
+
onClick: (e) => T(n)
|
|
249
|
+
}, [i("p", {
|
|
250
|
+
class: "chook-picker-column-label",
|
|
251
|
+
style: c({ transform: `rotate3d(1, 0, 0, calc((${n * g(48)} + var(--offset-y)) * ${g(x)}deg)` })
|
|
252
|
+
}, m(e?.[t.fields.label]), 5)], 8, J))), 128))], 36)], 32));
|
|
253
|
+
}
|
|
254
|
+
}), X = {
|
|
255
|
+
class: "chook-picker-container",
|
|
256
|
+
"aria-label": "Picker"
|
|
257
|
+
}, Z = { class: "chook-picker-loading" }, Q = {
|
|
258
|
+
key: 1,
|
|
259
|
+
class: "chook-picker-columns"
|
|
260
|
+
}, $ = /* @__PURE__ */ a({
|
|
261
|
+
__name: "Picker",
|
|
262
|
+
props: /*@__PURE__*/ o({
|
|
263
|
+
columns: {},
|
|
264
|
+
loading: { type: Boolean },
|
|
265
|
+
columnsFieldNames: {}
|
|
266
|
+
}, {
|
|
267
|
+
modelValue: { default: () => [] },
|
|
268
|
+
modelModifiers: {}
|
|
269
|
+
}),
|
|
270
|
+
emits: /*@__PURE__*/ o(["change"], ["update:modelValue"]),
|
|
271
|
+
setup(a, { emit: o }) {
|
|
272
|
+
let c = a, u = o, m = _(a, "modelValue"), h = d([]), g = v("columnsRef"), x = t(() => D(c.columnsFieldNames)), S = t(() => E(c.columns, x.value)), C = t(() => {
|
|
273
|
+
let { columns: e } = c;
|
|
274
|
+
return S.value === "single" ? [e] : S.value === "multiple" ? e : O(e, m.value, x.value);
|
|
275
|
+
});
|
|
276
|
+
function w(e, t) {
|
|
277
|
+
let n = C.value[e], r = n[t]?.[x.value.value];
|
|
278
|
+
if (r === m.value[e]) return;
|
|
279
|
+
let i = [...m.value];
|
|
280
|
+
if (i[e] = r, S.value === "cascade") {
|
|
281
|
+
let r = n[t];
|
|
282
|
+
m.value = k(r, e, i, x.value);
|
|
283
|
+
} else m.value = i;
|
|
284
|
+
s(() => {
|
|
285
|
+
u("change", m.value);
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
function T() {
|
|
289
|
+
let e = C.value.length, t = [];
|
|
290
|
+
for (let n = 0; n < e; n++) {
|
|
291
|
+
let e = C.value[n], r = m.value[n], i = A(e, r, x.value);
|
|
292
|
+
if (i === -1) {
|
|
293
|
+
let r = (h.value[n] ?? 0) >= e.length ? Math.max(e.length - 1, 0) : 0;
|
|
294
|
+
m.value[n] = e[r]?.[x.value.value], t[n] = r;
|
|
295
|
+
} else t[n] = i;
|
|
296
|
+
t[n] !== h.value[n] && g.value?.[n]?.scrollToSelected(t[n]);
|
|
297
|
+
}
|
|
298
|
+
h.value = t;
|
|
299
|
+
}
|
|
300
|
+
return y(() => {
|
|
301
|
+
T();
|
|
302
|
+
}, { flush: "post" }), (t, o) => (l(), r("div", X, [a.loading ? (l(), r(e, { key: 0 }, [i("div", Z, [p(t.$slots, "loading")]), o[1] ||= i("div", { class: "chook-picker-columns" }, null, -1)], 64)) : a.columns.length ? (l(), r("div", {
|
|
303
|
+
key: 2,
|
|
304
|
+
class: "chook-picker-columns chook-picker-columns-backdrop",
|
|
305
|
+
onTouchmove: o[0] ||= b(() => {}, ["stop"])
|
|
306
|
+
}, [(l(!0), r(e, null, f(C.value, (e, t) => (l(), n(Y, {
|
|
307
|
+
key: t,
|
|
308
|
+
ref_for: !0,
|
|
309
|
+
ref_key: "columnsRef",
|
|
310
|
+
ref: g,
|
|
311
|
+
column: e,
|
|
312
|
+
fields: x.value,
|
|
313
|
+
"selected-index": h.value[t],
|
|
314
|
+
onChange: (e) => w(t, e)
|
|
315
|
+
}, null, 8, [
|
|
316
|
+
"column",
|
|
317
|
+
"fields",
|
|
318
|
+
"selected-index",
|
|
319
|
+
"onChange"
|
|
320
|
+
]))), 128)), o[2] ||= i("div", { class: "chook-picker-mask-backdrop" }, null, -1)], 32)) : (l(), r("div", Q, [p(t.$slots, "empty")]))]));
|
|
321
|
+
}
|
|
322
|
+
}), ee = /* @__PURE__ */ a({
|
|
323
|
+
__name: "DatePicker",
|
|
324
|
+
props: /*@__PURE__*/ o({
|
|
325
|
+
columnsType: { default: () => C },
|
|
326
|
+
minDate: { default: () => new Date((/* @__PURE__ */ new Date()).getFullYear() - 10, 0, 1) },
|
|
327
|
+
maxDate: { default: () => new Date((/* @__PURE__ */ new Date()).getFullYear() + 10, 11, 31) },
|
|
328
|
+
formatYearLabel: {
|
|
329
|
+
type: Function,
|
|
330
|
+
default: V
|
|
331
|
+
},
|
|
332
|
+
formatMonthLabel: {
|
|
333
|
+
type: Function,
|
|
334
|
+
default: V
|
|
335
|
+
},
|
|
336
|
+
formatDayLabel: {
|
|
337
|
+
type: Function,
|
|
338
|
+
default: V
|
|
339
|
+
}
|
|
340
|
+
}, {
|
|
341
|
+
modelValue: { default: () => [] },
|
|
342
|
+
modelModifiers: {}
|
|
343
|
+
}),
|
|
344
|
+
emits: /*@__PURE__*/ o(["change"], ["update:modelValue"]),
|
|
345
|
+
setup(e, { expose: r, emit: i }) {
|
|
346
|
+
let a = e, o = i, s = _(e, "modelValue"), c = t(() => {
|
|
347
|
+
let { columnsType: e, minDate: t, maxDate: n } = a, r = {
|
|
348
|
+
year: u,
|
|
349
|
+
month: d,
|
|
350
|
+
day: f
|
|
351
|
+
};
|
|
352
|
+
return e.map((e) => r[e](t, n));
|
|
353
|
+
});
|
|
354
|
+
s.value.length || m();
|
|
355
|
+
function u(e, t) {
|
|
356
|
+
return P(e.getFullYear(), t.getFullYear(), a.formatYearLabel);
|
|
357
|
+
}
|
|
358
|
+
function d(e, t) {
|
|
359
|
+
let n = p("year");
|
|
360
|
+
return P(F(n, e) ? e.getMonth() + 1 : 1, I(n, t) ? t.getMonth() + 1 : 12, a.formatMonthLabel);
|
|
361
|
+
}
|
|
362
|
+
function f(e, t) {
|
|
363
|
+
let n = p("year"), r = p("month"), i = F(n, e) && L(r, e), o = I(n, t) && R(r, t);
|
|
364
|
+
return P(i ? e.getDate() : 1, o ? t.getDate() : z(n, r), a.formatDayLabel);
|
|
365
|
+
}
|
|
366
|
+
function p(e) {
|
|
367
|
+
let { columnsType: t } = a, n = t.indexOf(e), r = s.value[n];
|
|
368
|
+
return r ? Number(r) : B(a.minDate, a.maxDate, e);
|
|
369
|
+
}
|
|
370
|
+
function m() {
|
|
371
|
+
let { columnsType: e } = a;
|
|
372
|
+
s.value = e.map((e) => B(a.minDate, a.maxDate, e));
|
|
373
|
+
}
|
|
374
|
+
return r({ setCurrentDate: m }), (e, t) => (l(), n($, {
|
|
375
|
+
modelValue: s.value,
|
|
376
|
+
"onUpdate:modelValue": t[0] ||= (e) => s.value = e,
|
|
377
|
+
columns: c.value,
|
|
378
|
+
onChange: t[1] ||= (e) => o("change", e)
|
|
379
|
+
}, null, 8, ["modelValue", "columns"]));
|
|
380
|
+
}
|
|
381
|
+
}), te = /* @__PURE__ */ a({
|
|
382
|
+
__name: "TimePicker",
|
|
383
|
+
props: /*@__PURE__*/ o({
|
|
384
|
+
columnsType: { default: () => w },
|
|
385
|
+
minTime: {},
|
|
386
|
+
maxTime: {},
|
|
387
|
+
formatHourLabel: {
|
|
388
|
+
type: Function,
|
|
389
|
+
default: W
|
|
390
|
+
},
|
|
391
|
+
formatMinuteLabel: {
|
|
392
|
+
type: Function,
|
|
393
|
+
default: W
|
|
394
|
+
},
|
|
395
|
+
formatSecondLabel: {
|
|
396
|
+
type: Function,
|
|
397
|
+
default: W
|
|
398
|
+
}
|
|
399
|
+
}, {
|
|
400
|
+
modelValue: { default: () => [] },
|
|
401
|
+
modelModifiers: {}
|
|
402
|
+
}),
|
|
403
|
+
emits: /*@__PURE__*/ o(["change"], ["update:modelValue"]),
|
|
404
|
+
setup(e, { expose: r, emit: i }) {
|
|
405
|
+
let a = e, o = i, s = _(e, "modelValue"), c = t(() => {
|
|
406
|
+
let { columnsType: e } = a, t = {
|
|
407
|
+
hour: f,
|
|
408
|
+
minute: p,
|
|
409
|
+
second: m
|
|
410
|
+
};
|
|
411
|
+
return e.map((e) => t[e]());
|
|
412
|
+
}), u = t(() => U(a.minTime ?? "") ?? {
|
|
413
|
+
hour: 0,
|
|
414
|
+
minute: 0,
|
|
415
|
+
second: 0
|
|
416
|
+
}), d = t(() => U(a.maxTime ?? "") ?? {
|
|
417
|
+
hour: 23,
|
|
418
|
+
minute: 59,
|
|
419
|
+
second: 59
|
|
420
|
+
});
|
|
421
|
+
s.value.length || g();
|
|
422
|
+
function f() {
|
|
423
|
+
let e = u.value.hour, t = d.value.hour;
|
|
424
|
+
return P(e, t, a.formatHourLabel);
|
|
425
|
+
}
|
|
426
|
+
function p() {
|
|
427
|
+
let e = h("hour"), { hour: t, minute: n } = u.value, { hour: r, minute: i } = d.value;
|
|
428
|
+
return P(e === t ? n : 0, e === r ? i : 59, a.formatMinuteLabel);
|
|
429
|
+
}
|
|
430
|
+
function m() {
|
|
431
|
+
let e = h("hour"), t = h("minute"), { hour: n, minute: r, second: i } = u.value, { hour: o, minute: s, second: c } = d.value;
|
|
432
|
+
return P(e === n && t === r ? i : 0, e === o && t === s ? c : 59, a.formatSecondLabel);
|
|
433
|
+
}
|
|
434
|
+
function h(e) {
|
|
435
|
+
let { columnsType: t } = a, n = t.indexOf(e), r = s.value[n];
|
|
436
|
+
return r === void 0 ? G(u.value, d.value, e) : Number(r);
|
|
437
|
+
}
|
|
438
|
+
function g() {
|
|
439
|
+
let { columnsType: e } = a;
|
|
440
|
+
s.value = e.map((e) => G(u.value, d.value, e));
|
|
441
|
+
}
|
|
442
|
+
return r({ setCurrentTime: g }), (e, t) => (l(), n($, {
|
|
443
|
+
modelValue: s.value,
|
|
444
|
+
"onUpdate:modelValue": t[0] ||= (e) => s.value = e,
|
|
445
|
+
columns: c.value,
|
|
446
|
+
onChange: t[1] ||= (e) => o("change", e)
|
|
447
|
+
}, null, 8, ["modelValue", "columns"]));
|
|
448
|
+
}
|
|
442
449
|
});
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
ae as Picker,
|
|
446
|
-
He as TimePicker
|
|
447
|
-
};
|
|
450
|
+
//#endregion
|
|
451
|
+
export { ee as DatePicker, $ as Picker, te as TimePicker };
|