@component-hook/picker 1.1.1 → 1.1.3
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.js +1188 -1184
- package/dist/react/picker.umd.js +15 -15
- package/dist/vue/index.css +1 -1
- package/dist/vue/picker.es.js +341 -344
- package/dist/vue/picker.umd.js +2 -2
- package/package.json +7 -7
package/dist/vue/picker.es.js
CHANGED
|
@@ -1,77 +1,76 @@
|
|
|
1
1
|
import "./index.css";
|
|
2
|
-
import {
|
|
2
|
+
import { ref as Y, readonly as Z, isRef as j, defineComponent as E, toRef as re, createElementBlock as P, openBlock as C, unref as T, createElementVNode as I, normalizeStyle as q, Fragment as R, renderList as ue, toDisplayString as A, watch as ce, createBlock as L, Teleport as me, createVNode as J, Transition as Q, withCtx as z, withDirectives as W, vShow as ee, renderSlot as _, computed as O, watchEffect as de, withModifiers as fe, nextTick as pe } from "vue";
|
|
3
3
|
const ve = Array.isArray;
|
|
4
|
-
function he(e,
|
|
5
|
-
if (
|
|
4
|
+
function he(e, a) {
|
|
5
|
+
if (ae(e)) return "multiple";
|
|
6
6
|
const [n] = e;
|
|
7
|
-
return n
|
|
7
|
+
return n?.[a.children] ? "cascade" : "single";
|
|
8
8
|
}
|
|
9
9
|
function Te(e) {
|
|
10
10
|
return {
|
|
11
|
-
children:
|
|
12
|
-
label:
|
|
13
|
-
value:
|
|
11
|
+
children: e?.children || "children",
|
|
12
|
+
label: e?.label || "label",
|
|
13
|
+
value: e?.value || "value"
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
function ge(e,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
let o = e, r = 0;
|
|
16
|
+
function ge(e, a, n) {
|
|
17
|
+
if (ae(e)) return [];
|
|
18
|
+
const u = [];
|
|
19
|
+
let o = e, i = 0;
|
|
21
20
|
for (; o; ) {
|
|
22
|
-
const
|
|
23
|
-
let f =
|
|
24
|
-
f === -1 && (f = 0),
|
|
21
|
+
const d = a[i];
|
|
22
|
+
let f = se(o, d, n);
|
|
23
|
+
f === -1 && (f = 0), u.push(o), i += 1, o = o[f]?.[n.children];
|
|
25
24
|
}
|
|
26
|
-
return
|
|
25
|
+
return u;
|
|
27
26
|
}
|
|
28
|
-
function ke(e,
|
|
27
|
+
function ke(e, a, n, u) {
|
|
29
28
|
const o = [...n];
|
|
30
|
-
let
|
|
31
|
-
for (;
|
|
32
|
-
const
|
|
33
|
-
o[d] =
|
|
29
|
+
let i = e, d = a + 1;
|
|
30
|
+
for (; i?.[u.children]; ) {
|
|
31
|
+
const f = i[u.children][0];
|
|
32
|
+
o[d] = f.value, i = f, d += 1;
|
|
34
33
|
}
|
|
35
34
|
return o;
|
|
36
35
|
}
|
|
37
|
-
function
|
|
38
|
-
return e.findIndex((
|
|
36
|
+
function se(e, a, n) {
|
|
37
|
+
return e.findIndex((u) => u?.[n.value] === a);
|
|
39
38
|
}
|
|
40
|
-
function
|
|
41
|
-
const [
|
|
42
|
-
return ve(
|
|
39
|
+
function ae(e) {
|
|
40
|
+
const [a] = e;
|
|
41
|
+
return ve(a);
|
|
43
42
|
}
|
|
44
|
-
function Me(e,
|
|
45
|
-
return e >
|
|
43
|
+
function Me(e, a) {
|
|
44
|
+
return e > a ? "horizontal" : a > e ? "vertical" : "";
|
|
46
45
|
}
|
|
47
|
-
function
|
|
48
|
-
const
|
|
49
|
-
for (let o = e; o <=
|
|
50
|
-
const
|
|
51
|
-
|
|
46
|
+
function F(e, a, n) {
|
|
47
|
+
const u = [];
|
|
48
|
+
for (let o = e; o <= a; o++) {
|
|
49
|
+
const i = n(`${o}`);
|
|
50
|
+
u.push({ label: i, value: o });
|
|
52
51
|
}
|
|
53
|
-
return
|
|
52
|
+
return u;
|
|
54
53
|
}
|
|
55
|
-
function te(e,
|
|
56
|
-
return e ===
|
|
54
|
+
function te(e, a) {
|
|
55
|
+
return e === a.getFullYear();
|
|
57
56
|
}
|
|
58
|
-
function ne(e,
|
|
59
|
-
return e ===
|
|
57
|
+
function ne(e, a) {
|
|
58
|
+
return e === a.getFullYear();
|
|
60
59
|
}
|
|
61
|
-
function Ve(e,
|
|
62
|
-
return e ===
|
|
60
|
+
function Ve(e, a) {
|
|
61
|
+
return e === a.getMonth() + 1;
|
|
63
62
|
}
|
|
64
|
-
function ye(e,
|
|
65
|
-
return e ===
|
|
63
|
+
function ye(e, a) {
|
|
64
|
+
return e === a.getMonth() + 1;
|
|
66
65
|
}
|
|
67
|
-
function we(e,
|
|
68
|
-
return new Date(e,
|
|
66
|
+
function we(e, a) {
|
|
67
|
+
return new Date(e, a, 0).getDate();
|
|
69
68
|
}
|
|
70
|
-
function xe(e,
|
|
71
|
-
const
|
|
72
|
-
return n === "year" ?
|
|
69
|
+
function xe(e, a, n) {
|
|
70
|
+
const u = /* @__PURE__ */ new Date(), o = Date.now(), i = e.getTime(), d = a.getTime(), f = o >= i && o <= d;
|
|
71
|
+
return n === "year" ? f ? u.getFullYear() : e.getFullYear() : n === "month" ? f ? u.getMonth() + 1 : e.getMonth() + 1 : f ? u.getDate() : e.getDate();
|
|
73
72
|
}
|
|
74
|
-
function
|
|
73
|
+
function H(e) {
|
|
75
74
|
return e;
|
|
76
75
|
}
|
|
77
76
|
function De(e) {
|
|
@@ -79,60 +78,18 @@ function De(e) {
|
|
|
79
78
|
}
|
|
80
79
|
function oe(e) {
|
|
81
80
|
if (!De(e)) return null;
|
|
82
|
-
const [
|
|
83
|
-
return { hour: Number(
|
|
81
|
+
const [a, n, u] = e.split(":");
|
|
82
|
+
return { hour: Number(a), minute: Number(n), second: Number(u) };
|
|
84
83
|
}
|
|
85
|
-
function
|
|
84
|
+
function U(e) {
|
|
86
85
|
return e.padStart(2, "0");
|
|
87
86
|
}
|
|
88
|
-
function Se(e,
|
|
89
|
-
const
|
|
90
|
-
return n === "hour" ?
|
|
87
|
+
function Se(e, a, n) {
|
|
88
|
+
const u = Date.now(), { hour: o, minute: i, second: d } = e, { hour: f, minute: p, second: m } = a, M = (/* @__PURE__ */ new Date()).setHours(o, i, d), g = (/* @__PURE__ */ new Date()).setHours(f, p, m), w = u >= M && u <= g;
|
|
89
|
+
return n === "hour" ? w ? (/* @__PURE__ */ new Date()).getHours() : o : n === "minute" ? w ? (/* @__PURE__ */ new Date()).getMinutes() : i : w ? (/* @__PURE__ */ new Date()).getSeconds() : d;
|
|
91
90
|
}
|
|
92
|
-
const be =
|
|
93
|
-
|
|
94
|
-
props: {
|
|
95
|
-
teleport: { default: "body" },
|
|
96
|
-
modelValue: { type: Boolean }
|
|
97
|
-
},
|
|
98
|
-
emits: ["update:modelValue", "open", "close", "closed"],
|
|
99
|
-
setup(e, { emit: s }) {
|
|
100
|
-
const n = e, l = s;
|
|
101
|
-
return ie(
|
|
102
|
-
() => n.modelValue,
|
|
103
|
-
(o) => {
|
|
104
|
-
o ? (document.body.style.overflow = "hidden", l("open")) : (document.body.style.overflow = "", l("close"));
|
|
105
|
-
},
|
|
106
|
-
{ immediate: !0 }
|
|
107
|
-
), (o, r) => (I(), E(ce, { to: o.teleport }, [
|
|
108
|
-
Z(j, { name: "chook-picker-fade" }, {
|
|
109
|
-
default: X(() => [
|
|
110
|
-
q(Y("div", {
|
|
111
|
-
class: "chook-picker-mask",
|
|
112
|
-
onClick: r[0] || (r[0] = (d) => o.$emit("update:modelValue", !1))
|
|
113
|
-
}, null, 512), [
|
|
114
|
-
[J, o.modelValue]
|
|
115
|
-
])
|
|
116
|
-
]),
|
|
117
|
-
_: 1
|
|
118
|
-
}),
|
|
119
|
-
Z(j, {
|
|
120
|
-
name: "chook-picker-slide",
|
|
121
|
-
onAfterLeave: r[1] || (r[1] = (d) => o.$emit("closed"))
|
|
122
|
-
}, {
|
|
123
|
-
default: X(() => [
|
|
124
|
-
q(Y("div", be, [
|
|
125
|
-
R(o.$slots, "default")
|
|
126
|
-
], 512), [
|
|
127
|
-
[J, o.modelValue]
|
|
128
|
-
])
|
|
129
|
-
]),
|
|
130
|
-
_: 3
|
|
131
|
-
})
|
|
132
|
-
], 8, ["to"]));
|
|
133
|
-
}
|
|
134
|
-
}), Ye = 16, _ = 48, Ce = 0.52, le = 150, U = 300, Oe = 15, Pe = 8e-3, Fe = "Select Date", Le = ["year", "month", "day"], Ee = "Select Time", Be = ["hour", "minute", "second"];
|
|
135
|
-
function Ae() {
|
|
91
|
+
const be = 16, N = 48, Ce = 0.52, le = 150, X = 300, Ie = 15, Ye = 8e-3, Oe = "Select Date", Pe = ["year", "month", "day"], Fe = "Select Time", Le = ["hour", "minute", "second"];
|
|
92
|
+
function Ee() {
|
|
136
93
|
const e = {
|
|
137
94
|
startX: 0,
|
|
138
95
|
startY: 0,
|
|
@@ -141,88 +98,88 @@ function Ae() {
|
|
|
141
98
|
offsetX: 0,
|
|
142
99
|
offsetY: 0
|
|
143
100
|
};
|
|
144
|
-
let
|
|
145
|
-
const n = () =>
|
|
101
|
+
let a = "";
|
|
102
|
+
const n = () => a === "vertical", u = () => a === "horizontal";
|
|
146
103
|
function o() {
|
|
147
|
-
e.deltaX = 0, e.deltaY = 0, e.offsetX = 0, e.offsetY = 0,
|
|
104
|
+
e.deltaX = 0, e.deltaY = 0, e.offsetX = 0, e.offsetY = 0, a = "";
|
|
148
105
|
}
|
|
149
|
-
function
|
|
150
|
-
const m = "touches" in
|
|
106
|
+
function i(p) {
|
|
107
|
+
const m = "touches" in p ? p.touches[0] : p;
|
|
151
108
|
o(), e.startX = m.clientX, e.startY = m.clientY;
|
|
152
109
|
}
|
|
153
|
-
function d(
|
|
110
|
+
function d(p) {
|
|
154
111
|
if (!e.startX || !e.startY) return !0;
|
|
155
|
-
const m = "touches" in
|
|
112
|
+
const m = "touches" in p ? p.touches[0] : p;
|
|
156
113
|
e.deltaX = Math.max(m.clientX, 0) - e.startX, e.deltaY = m.clientY - e.startY, e.offsetX = Math.abs(e.deltaX), e.offsetY = Math.abs(e.deltaY);
|
|
157
|
-
const
|
|
158
|
-
(!
|
|
114
|
+
const M = 10;
|
|
115
|
+
(!a || e.offsetX < M && e.offsetY < M) && (a = Me(e.offsetX, e.offsetY));
|
|
159
116
|
}
|
|
160
|
-
function
|
|
117
|
+
function f() {
|
|
161
118
|
e.startX = 0, e.startY = 0;
|
|
162
119
|
}
|
|
163
120
|
return {
|
|
164
121
|
pointer: e,
|
|
165
122
|
move: d,
|
|
166
|
-
start:
|
|
167
|
-
stop:
|
|
123
|
+
start: i,
|
|
124
|
+
stop: f,
|
|
168
125
|
reset: o,
|
|
169
126
|
isVertical: n,
|
|
170
|
-
isHorizontal:
|
|
127
|
+
isHorizontal: u
|
|
171
128
|
};
|
|
172
129
|
}
|
|
173
|
-
function
|
|
174
|
-
const
|
|
175
|
-
let
|
|
176
|
-
function
|
|
177
|
-
|
|
130
|
+
function Be({ column: e, onChange: a }) {
|
|
131
|
+
const u = Number.parseFloat(getComputedStyle(document.documentElement).fontSize) / be, o = Y(0), i = Y(0), { pointer: d, start: f, move: p, stop: m } = Ee();
|
|
132
|
+
let M = 0, g = 0, w = 0, V = !1, x = null;
|
|
133
|
+
function y(v) {
|
|
134
|
+
f(v), V = !0, i.value = 0, g = Date.now(), M = o.value, w = M, x = null;
|
|
178
135
|
}
|
|
179
|
-
function
|
|
180
|
-
if (
|
|
181
|
-
const b =
|
|
182
|
-
o.value = G, !(K -
|
|
136
|
+
function s(v) {
|
|
137
|
+
if (p(v)) return;
|
|
138
|
+
const b = j(e) ? e.value.length : e.length, B = M + d.deltaY, $ = D((b - 1) * -N), G = Math.min(Math.max(B, $), 0), K = Date.now();
|
|
139
|
+
o.value = G, !(K - g <= X) && (g = K, w = G);
|
|
183
140
|
}
|
|
184
|
-
function
|
|
141
|
+
function r() {
|
|
185
142
|
m();
|
|
186
|
-
const
|
|
187
|
-
if (
|
|
188
|
-
t(
|
|
143
|
+
const v = o.value - w, k = Date.now() - g;
|
|
144
|
+
if (k < X && Math.abs(v) > Ie) {
|
|
145
|
+
t(v, k);
|
|
189
146
|
return;
|
|
190
147
|
}
|
|
191
|
-
const b =
|
|
192
|
-
|
|
148
|
+
const b = h(o.value);
|
|
149
|
+
i.value = le, c(b), V = !1;
|
|
193
150
|
}
|
|
194
|
-
function t(
|
|
195
|
-
const b = Math.abs(
|
|
196
|
-
|
|
151
|
+
function t(v, k) {
|
|
152
|
+
const b = Math.abs(v / k), B = o.value + b / Ye * (v < 0 ? -1 : 1), $ = h(B);
|
|
153
|
+
i.value = X, c($);
|
|
197
154
|
}
|
|
198
|
-
function
|
|
199
|
-
|
|
155
|
+
function l() {
|
|
156
|
+
i.value = 0, V = !1, x && (x(), x = null);
|
|
200
157
|
}
|
|
201
|
-
function c(
|
|
202
|
-
const
|
|
203
|
-
|
|
158
|
+
function c(v) {
|
|
159
|
+
const k = -v * D(N), b = () => a?.(v);
|
|
160
|
+
V && k !== o.value ? x = b : b(), o.value = k;
|
|
204
161
|
}
|
|
205
|
-
function
|
|
206
|
-
const
|
|
207
|
-
return b < 0 ? 0 : b >=
|
|
162
|
+
function h(v) {
|
|
163
|
+
const k = j(e) ? e.value.length : e.length, b = Math.round(-v / D(N));
|
|
164
|
+
return b < 0 ? 0 : b >= k ? k - 1 : b;
|
|
208
165
|
}
|
|
209
|
-
function v
|
|
210
|
-
return
|
|
166
|
+
function D(v) {
|
|
167
|
+
return v * u;
|
|
211
168
|
}
|
|
212
|
-
function S(
|
|
213
|
-
|
|
169
|
+
function S(v, k = "auto") {
|
|
170
|
+
V && k === "smooth" || (x = null, V = k === "smooth", i.value = k === "smooth" ? le : 0, c(v));
|
|
214
171
|
}
|
|
215
172
|
return {
|
|
216
|
-
offsetY:
|
|
217
|
-
transitionDuration:
|
|
218
|
-
onPointerDown:
|
|
219
|
-
onPointerMove:
|
|
220
|
-
onPointerUp:
|
|
221
|
-
stopInertialSliding:
|
|
173
|
+
offsetY: Z(o),
|
|
174
|
+
transitionDuration: Z(i),
|
|
175
|
+
onPointerDown: y,
|
|
176
|
+
onPointerMove: s,
|
|
177
|
+
onPointerUp: r,
|
|
178
|
+
stopInertialSliding: l,
|
|
222
179
|
scrollToIndex: S
|
|
223
180
|
};
|
|
224
181
|
}
|
|
225
|
-
const
|
|
182
|
+
const Ae = ["onClick"], Ne = /* @__PURE__ */ E({
|
|
226
183
|
__name: "PickerColumn",
|
|
227
184
|
props: {
|
|
228
185
|
column: {},
|
|
@@ -230,68 +187,110 @@ const $e = ["onClick"], He = /* @__PURE__ */ B({
|
|
|
230
187
|
selectedIndex: { default: 0 }
|
|
231
188
|
},
|
|
232
189
|
emits: ["change"],
|
|
233
|
-
setup(e, { expose:
|
|
234
|
-
const
|
|
235
|
-
column:
|
|
236
|
-
onChange:
|
|
190
|
+
setup(e, { expose: a, emit: n }) {
|
|
191
|
+
const u = e, o = n, { offsetY: i, transitionDuration: d, onPointerDown: f, onPointerMove: p, onPointerUp: m, stopInertialSliding: M, scrollToIndex: g } = Be({
|
|
192
|
+
column: re(u, "column"),
|
|
193
|
+
onChange: w
|
|
237
194
|
});
|
|
238
|
-
function
|
|
239
|
-
|
|
195
|
+
function w(y) {
|
|
196
|
+
y !== u.selectedIndex && o("change", y);
|
|
240
197
|
}
|
|
241
|
-
function y
|
|
242
|
-
|
|
198
|
+
function V(y = u.selectedIndex, s) {
|
|
199
|
+
g(y, s);
|
|
243
200
|
}
|
|
244
|
-
function
|
|
245
|
-
|
|
201
|
+
function x(y) {
|
|
202
|
+
y !== u.selectedIndex && V(y, "smooth");
|
|
246
203
|
}
|
|
247
|
-
return
|
|
204
|
+
return a({ scrollToSelected: V }), (y, s) => (C(), P("div", {
|
|
248
205
|
class: "chook-picker-column",
|
|
249
|
-
onTouchstartPassive:
|
|
250
|
-
(...
|
|
251
|
-
onTouchmovePassive:
|
|
252
|
-
(...
|
|
253
|
-
onTouchendPassive:
|
|
254
|
-
(...
|
|
255
|
-
onTouchcancel:
|
|
256
|
-
(...
|
|
257
|
-
onMousedownPassive:
|
|
258
|
-
(...
|
|
259
|
-
onMousemovePassive:
|
|
260
|
-
(...
|
|
261
|
-
onMouseupPassive:
|
|
262
|
-
(...
|
|
206
|
+
onTouchstartPassive: s[1] || (s[1] = //@ts-ignore
|
|
207
|
+
(...r) => T(f) && T(f)(...r)),
|
|
208
|
+
onTouchmovePassive: s[2] || (s[2] = //@ts-ignore
|
|
209
|
+
(...r) => T(p) && T(p)(...r)),
|
|
210
|
+
onTouchendPassive: s[3] || (s[3] = //@ts-ignore
|
|
211
|
+
(...r) => T(m) && T(m)(...r)),
|
|
212
|
+
onTouchcancel: s[4] || (s[4] = //@ts-ignore
|
|
213
|
+
(...r) => T(m) && T(m)(...r)),
|
|
214
|
+
onMousedownPassive: s[5] || (s[5] = //@ts-ignore
|
|
215
|
+
(...r) => T(f) && T(f)(...r)),
|
|
216
|
+
onMousemovePassive: s[6] || (s[6] = //@ts-ignore
|
|
217
|
+
(...r) => T(p) && T(p)(...r)),
|
|
218
|
+
onMouseupPassive: s[7] || (s[7] = //@ts-ignore
|
|
219
|
+
(...r) => T(m) && T(m)(...r))
|
|
263
220
|
}, [
|
|
264
|
-
|
|
265
|
-
style:
|
|
221
|
+
I("ul", {
|
|
222
|
+
style: q({
|
|
266
223
|
overflowY: "hidden",
|
|
267
|
-
transform: `translate3d(0, ${
|
|
268
|
-
transitionDuration: `${
|
|
269
|
-
transitionProperty:
|
|
224
|
+
transform: `translate3d(0, ${T(i)}px, 0)`,
|
|
225
|
+
transitionDuration: `${T(d)}ms`,
|
|
226
|
+
transitionProperty: T(d) ? "all" : "none"
|
|
270
227
|
}),
|
|
271
|
-
onTransitionend:
|
|
272
|
-
(...
|
|
228
|
+
onTransitionend: s[0] || (s[0] = //@ts-ignore
|
|
229
|
+
(...r) => T(M) && T(M)(...r))
|
|
273
230
|
}, [
|
|
274
|
-
(
|
|
275
|
-
key:
|
|
231
|
+
(C(!0), P(R, null, ue(y.column, (r, t) => (C(), P("li", {
|
|
232
|
+
key: r?.[y.fields.value],
|
|
276
233
|
class: "chook-picker-column-item",
|
|
277
234
|
role: "button",
|
|
278
235
|
tabindex: "0",
|
|
279
|
-
onClick: (
|
|
236
|
+
onClick: (l) => x(t)
|
|
280
237
|
}, [
|
|
281
|
-
|
|
238
|
+
I("p", {
|
|
282
239
|
class: "chook-picker-column-label",
|
|
283
|
-
style:
|
|
284
|
-
transform: `rotate3d(1, 0, 0, ${(t *
|
|
240
|
+
style: q({
|
|
241
|
+
transform: `rotate3d(1, 0, 0, ${(t * T(N) + T(i)) * T(Ce)}deg)`
|
|
285
242
|
})
|
|
286
|
-
}, A(
|
|
287
|
-
], 8,
|
|
243
|
+
}, A(r?.[y.fields.label]), 5)
|
|
244
|
+
], 8, Ae))), 128))
|
|
288
245
|
], 36)
|
|
289
246
|
], 32));
|
|
290
247
|
}
|
|
248
|
+
}), $e = { class: "chook-picker-container" }, He = /* @__PURE__ */ E({
|
|
249
|
+
__name: "Popup",
|
|
250
|
+
props: {
|
|
251
|
+
teleport: { default: "body" },
|
|
252
|
+
modelValue: { type: Boolean }
|
|
253
|
+
},
|
|
254
|
+
emits: ["update:modelValue", "open", "close", "closed"],
|
|
255
|
+
setup(e, { emit: a }) {
|
|
256
|
+
const n = e, u = a;
|
|
257
|
+
return ce(
|
|
258
|
+
() => n.modelValue,
|
|
259
|
+
(o) => {
|
|
260
|
+
o ? (document.body.style.overflow = "hidden", u("open")) : (document.body.style.overflow = "", u("close"));
|
|
261
|
+
},
|
|
262
|
+
{ immediate: !0 }
|
|
263
|
+
), (o, i) => (C(), L(me, { to: o.teleport }, [
|
|
264
|
+
J(Q, { name: "chook-picker-fade" }, {
|
|
265
|
+
default: z(() => [
|
|
266
|
+
W(I("div", {
|
|
267
|
+
class: "chook-picker-mask",
|
|
268
|
+
onClick: i[0] || (i[0] = (d) => o.$emit("update:modelValue", !1))
|
|
269
|
+
}, null, 512), [
|
|
270
|
+
[ee, o.modelValue]
|
|
271
|
+
])
|
|
272
|
+
]),
|
|
273
|
+
_: 1
|
|
274
|
+
}),
|
|
275
|
+
J(Q, {
|
|
276
|
+
name: "chook-picker-slide",
|
|
277
|
+
onAfterLeave: i[1] || (i[1] = (d) => o.$emit("closed"))
|
|
278
|
+
}, {
|
|
279
|
+
default: z(() => [
|
|
280
|
+
W(I("div", $e, [
|
|
281
|
+
_(o.$slots, "default")
|
|
282
|
+
], 512), [
|
|
283
|
+
[ee, o.modelValue]
|
|
284
|
+
])
|
|
285
|
+
]),
|
|
286
|
+
_: 3
|
|
287
|
+
})
|
|
288
|
+
], 8, ["to"]));
|
|
289
|
+
}
|
|
291
290
|
}), Ue = { class: "chook-picker-header" }, Xe = { class: "chook-picker-title" }, Re = { class: "chook-picker-loading" }, ze = {
|
|
292
291
|
key: 1,
|
|
293
292
|
class: "chook-picker-columns"
|
|
294
|
-
},
|
|
293
|
+
}, ie = /* @__PURE__ */ E({
|
|
295
294
|
__name: "Picker",
|
|
296
295
|
props: {
|
|
297
296
|
show: { type: Boolean },
|
|
@@ -306,263 +305,261 @@ const $e = ["onClick"], He = /* @__PURE__ */ B({
|
|
|
306
305
|
columnsFieldNames: {}
|
|
307
306
|
},
|
|
308
307
|
emits: ["update:show", "update:modelValue", "confirm", "cancel", "open", "closed"],
|
|
309
|
-
setup(e, { emit:
|
|
310
|
-
const n = e,
|
|
308
|
+
setup(e, { emit: a }) {
|
|
309
|
+
const n = e, u = a, o = Y([]), i = Y([]), d = Y([]), f = Y(null), p = O({
|
|
311
310
|
get: () => n.show,
|
|
312
|
-
set: (t) =>
|
|
313
|
-
}), m = O(() => Te(n.columnsFieldNames)),
|
|
311
|
+
set: (t) => u("update:show", t)
|
|
312
|
+
}), m = O(() => Te(n.columnsFieldNames)), M = O(() => he(n.columns, m.value)), g = O(() => {
|
|
314
313
|
const { columns: t } = n;
|
|
315
|
-
return
|
|
314
|
+
return M.value === "single" ? [t] : M.value === "multiple" ? t : ge(t, i.value, m.value);
|
|
316
315
|
});
|
|
317
|
-
function
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
r.value = ke(T, t, S, m.value);
|
|
316
|
+
function w(t, l) {
|
|
317
|
+
const c = g.value[t], h = c[l]?.[m.value.value], D = i.value[t];
|
|
318
|
+
if (h === D) return;
|
|
319
|
+
const S = [...i.value];
|
|
320
|
+
if (S[t] = h, M.value === "cascade") {
|
|
321
|
+
const v = c[l];
|
|
322
|
+
i.value = ke(v, t, S, m.value);
|
|
325
323
|
} else
|
|
326
|
-
|
|
327
|
-
n.linkage &&
|
|
324
|
+
i.value = S;
|
|
325
|
+
n.linkage && V();
|
|
328
326
|
}
|
|
329
|
-
function
|
|
330
|
-
|
|
327
|
+
function V() {
|
|
328
|
+
u("update:modelValue", i.value), o.value = i.value;
|
|
331
329
|
}
|
|
332
|
-
function
|
|
333
|
-
|
|
330
|
+
function x() {
|
|
331
|
+
u("update:show", !1);
|
|
334
332
|
}
|
|
335
|
-
async function
|
|
336
|
-
|
|
333
|
+
async function y() {
|
|
334
|
+
u("open"), await pe(), i.value = n.modelValue ? [...n.modelValue] : [...o.value];
|
|
337
335
|
}
|
|
338
|
-
function
|
|
339
|
-
n.linkage ||
|
|
336
|
+
function s() {
|
|
337
|
+
n.linkage || V(), x(), u("confirm", i.value);
|
|
340
338
|
}
|
|
341
|
-
function
|
|
342
|
-
|
|
339
|
+
function r() {
|
|
340
|
+
x(), u("cancel");
|
|
343
341
|
}
|
|
344
342
|
return de(() => {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
r.value[v] = (c = S[P]) == null ? void 0 : c[m.value.value], u[v] = P;
|
|
343
|
+
const t = g.value.length, l = [];
|
|
344
|
+
for (let c = 0; c < t; c++) {
|
|
345
|
+
const h = g.value[c], D = i.value[c], S = se(h, D, m.value);
|
|
346
|
+
if (S === -1) {
|
|
347
|
+
const k = (d.value[c] ?? 0) >= h.length ? Math.max(h.length - 1, 0) : 0;
|
|
348
|
+
i.value[c] = h[k]?.[m.value.value], l[c] = k;
|
|
352
349
|
} else
|
|
353
|
-
|
|
354
|
-
|
|
350
|
+
l[c] = S;
|
|
351
|
+
l[c] !== d.value[c] && f.value?.[c].scrollToSelected(l[c]);
|
|
355
352
|
}
|
|
356
|
-
d.value =
|
|
357
|
-
}), (t,
|
|
358
|
-
modelValue:
|
|
359
|
-
"onUpdate:modelValue":
|
|
353
|
+
d.value = l;
|
|
354
|
+
}), (t, l) => (C(), L(He, {
|
|
355
|
+
modelValue: p.value,
|
|
356
|
+
"onUpdate:modelValue": l[1] || (l[1] = (c) => p.value = c),
|
|
360
357
|
teleport: t.teleport,
|
|
361
|
-
onOpen:
|
|
362
|
-
onClosed:
|
|
358
|
+
onOpen: y,
|
|
359
|
+
onClosed: l[2] || (l[2] = (c) => t.$emit("closed"))
|
|
363
360
|
}, {
|
|
364
|
-
default:
|
|
365
|
-
|
|
366
|
-
|
|
361
|
+
default: z(() => [
|
|
362
|
+
I("div", Ue, [
|
|
363
|
+
I("button", {
|
|
367
364
|
class: "chook-picker-cancel",
|
|
368
|
-
onClick:
|
|
365
|
+
onClick: r
|
|
369
366
|
}, A(t.cancelButtonText), 1),
|
|
370
|
-
|
|
371
|
-
|
|
367
|
+
I("p", Xe, A(t.title), 1),
|
|
368
|
+
I("button", {
|
|
372
369
|
class: "chook-picker-confirm",
|
|
373
|
-
onClick:
|
|
370
|
+
onClick: s
|
|
374
371
|
}, A(t.confirmButtonText), 1)
|
|
375
372
|
]),
|
|
376
|
-
t.loading ? (
|
|
377
|
-
|
|
378
|
-
|
|
373
|
+
t.loading ? (C(), P(R, { key: 0 }, [
|
|
374
|
+
I("div", Re, [
|
|
375
|
+
_(t.$slots, "loading")
|
|
379
376
|
]),
|
|
380
|
-
|
|
381
|
-
], 64)) : t.columns.length ? (
|
|
377
|
+
l[3] || (l[3] = I("div", { class: "chook-picker-columns" }, null, -1))
|
|
378
|
+
], 64)) : t.columns.length ? (C(), P("div", {
|
|
382
379
|
key: 2,
|
|
383
380
|
class: "chook-picker-columns chook-picker-columns-backdrop",
|
|
384
|
-
onTouchmove:
|
|
381
|
+
onTouchmove: l[0] || (l[0] = fe(() => {
|
|
385
382
|
}, ["stop"]))
|
|
386
383
|
}, [
|
|
387
|
-
(
|
|
388
|
-
key:
|
|
384
|
+
(C(!0), P(R, null, ue(g.value, (c, h) => (C(), L(Ne, {
|
|
385
|
+
key: h,
|
|
389
386
|
ref_for: !0,
|
|
390
387
|
ref_key: "columnsRef",
|
|
391
|
-
ref:
|
|
388
|
+
ref: f,
|
|
392
389
|
column: c,
|
|
393
390
|
fields: m.value,
|
|
394
|
-
"selected-index": d.value[
|
|
395
|
-
onChange: (
|
|
391
|
+
"selected-index": d.value[h],
|
|
392
|
+
onChange: (D) => w(h, D)
|
|
396
393
|
}, null, 8, ["column", "fields", "selected-index", "onChange"]))), 128)),
|
|
397
|
-
|
|
398
|
-
], 32)) : (
|
|
399
|
-
|
|
394
|
+
l[4] || (l[4] = I("div", { class: "chook-picker-mask-backdrop" }, null, -1))
|
|
395
|
+
], 32)) : (C(), P("div", ze, [
|
|
396
|
+
_(t.$slots, "empty")
|
|
400
397
|
]))
|
|
401
398
|
]),
|
|
402
399
|
_: 3
|
|
403
400
|
}, 8, ["modelValue", "teleport"]));
|
|
404
401
|
}
|
|
405
|
-
}), Ge = /* @__PURE__ */
|
|
402
|
+
}), Ge = /* @__PURE__ */ E({
|
|
406
403
|
__name: "DatePicker",
|
|
407
404
|
props: {
|
|
408
405
|
show: { type: Boolean },
|
|
409
406
|
modelValue: {},
|
|
410
|
-
title: { default:
|
|
411
|
-
columnsType: { default: () =>
|
|
407
|
+
title: { default: Oe },
|
|
408
|
+
columnsType: { default: () => Pe },
|
|
412
409
|
minDate: { default: () => new Date((/* @__PURE__ */ new Date()).getFullYear() - 10, 0, 1) },
|
|
413
410
|
maxDate: { default: () => new Date((/* @__PURE__ */ new Date()).getFullYear() + 10, 11, 31) },
|
|
414
411
|
teleport: {},
|
|
415
412
|
confirmButtonText: {},
|
|
416
413
|
cancelButtonText: {},
|
|
417
|
-
formatYearLabel: { type: Function, default:
|
|
418
|
-
formatMonthLabel: { type: Function, default:
|
|
419
|
-
formatDayLabel: { type: Function, default:
|
|
414
|
+
formatYearLabel: { type: Function, default: H },
|
|
415
|
+
formatMonthLabel: { type: Function, default: H },
|
|
416
|
+
formatDayLabel: { type: Function, default: H }
|
|
420
417
|
},
|
|
421
418
|
emits: ["update:show", "update:modelValue", "confirm", "cancel", "open", "closed"],
|
|
422
|
-
setup(e, { emit:
|
|
423
|
-
const n = e,
|
|
419
|
+
setup(e, { emit: a }) {
|
|
420
|
+
const n = e, u = a, o = Y([]), i = Y([]), d = O({
|
|
424
421
|
get: () => n.show,
|
|
425
|
-
set: (
|
|
426
|
-
}),
|
|
427
|
-
const { columnsType:
|
|
428
|
-
year:
|
|
422
|
+
set: (s) => u("update:show", s)
|
|
423
|
+
}), f = O(() => {
|
|
424
|
+
const { columnsType: s, minDate: r, maxDate: t } = n, l = {
|
|
425
|
+
year: p,
|
|
429
426
|
month: m,
|
|
430
|
-
day:
|
|
427
|
+
day: M
|
|
431
428
|
};
|
|
432
|
-
return
|
|
429
|
+
return s.map((c) => l[c](r, t));
|
|
433
430
|
});
|
|
434
|
-
function
|
|
435
|
-
const t =
|
|
436
|
-
return
|
|
431
|
+
function p(s, r) {
|
|
432
|
+
const t = s.getFullYear(), l = r.getFullYear();
|
|
433
|
+
return F(t, l, n.formatYearLabel);
|
|
437
434
|
}
|
|
438
|
-
function m(
|
|
439
|
-
const t =
|
|
440
|
-
return
|
|
435
|
+
function m(s, r) {
|
|
436
|
+
const t = g("year"), l = te(t, s) ? s.getMonth() + 1 : 1, c = ne(t, r) ? r.getMonth() + 1 : 12;
|
|
437
|
+
return F(l, c, n.formatMonthLabel);
|
|
441
438
|
}
|
|
442
|
-
function
|
|
443
|
-
const t =
|
|
444
|
-
return
|
|
439
|
+
function M(s, r) {
|
|
440
|
+
const t = g("year"), l = g("month"), c = te(t, s) && Ve(l, s), h = ne(t, r) && ye(l, r), D = c ? s.getDate() : 1, S = h ? r.getDate() : we(t, l);
|
|
441
|
+
return F(D, S, n.formatDayLabel);
|
|
445
442
|
}
|
|
446
|
-
function
|
|
447
|
-
const { columnsType:
|
|
448
|
-
return
|
|
443
|
+
function g(s) {
|
|
444
|
+
const { columnsType: r } = n, t = r.indexOf(s), l = o.value[t];
|
|
445
|
+
return l ? Number(l) : xe(n.minDate, n.maxDate, s);
|
|
449
446
|
}
|
|
450
|
-
function
|
|
451
|
-
|
|
447
|
+
function w(s) {
|
|
448
|
+
u("update:modelValue", s), i.value = s, u("confirm", s);
|
|
452
449
|
}
|
|
453
|
-
function
|
|
454
|
-
|
|
450
|
+
function V() {
|
|
451
|
+
u("cancel");
|
|
455
452
|
}
|
|
456
|
-
function
|
|
457
|
-
if (
|
|
453
|
+
function x() {
|
|
454
|
+
if (u("open"), n.modelValue && n.modelValue.length) {
|
|
458
455
|
o.value = [...n.modelValue];
|
|
459
456
|
return;
|
|
460
457
|
}
|
|
461
|
-
const { columnsType:
|
|
462
|
-
o.value =
|
|
458
|
+
const { columnsType: s } = n;
|
|
459
|
+
o.value = s.map((r) => g(r));
|
|
463
460
|
}
|
|
464
|
-
function
|
|
465
|
-
o.value = n.modelValue ? [...n.modelValue] : [...
|
|
461
|
+
function y() {
|
|
462
|
+
o.value = n.modelValue ? [...n.modelValue] : [...i.value], u("closed");
|
|
466
463
|
}
|
|
467
|
-
return (
|
|
464
|
+
return (s, r) => (C(), L(ie, {
|
|
468
465
|
modelValue: o.value,
|
|
469
|
-
"onUpdate:modelValue":
|
|
466
|
+
"onUpdate:modelValue": r[0] || (r[0] = (t) => o.value = t),
|
|
470
467
|
show: d.value,
|
|
471
|
-
"onUpdate:show":
|
|
472
|
-
title:
|
|
473
|
-
columns:
|
|
474
|
-
teleport:
|
|
475
|
-
"confirm-button-text":
|
|
476
|
-
"cancel-button-text":
|
|
468
|
+
"onUpdate:show": r[1] || (r[1] = (t) => d.value = t),
|
|
469
|
+
title: s.title,
|
|
470
|
+
columns: f.value,
|
|
471
|
+
teleport: s.teleport,
|
|
472
|
+
"confirm-button-text": s.confirmButtonText,
|
|
473
|
+
"cancel-button-text": s.cancelButtonText,
|
|
477
474
|
linkage: "",
|
|
478
|
-
onConfirm:
|
|
479
|
-
onCancel:
|
|
480
|
-
onOpen:
|
|
481
|
-
onClosed:
|
|
475
|
+
onConfirm: w,
|
|
476
|
+
onCancel: V,
|
|
477
|
+
onOpen: x,
|
|
478
|
+
onClosed: y
|
|
482
479
|
}, null, 8, ["modelValue", "show", "title", "columns", "teleport", "confirm-button-text", "cancel-button-text"]));
|
|
483
480
|
}
|
|
484
|
-
}), Ke = /* @__PURE__ */
|
|
481
|
+
}), Ke = /* @__PURE__ */ E({
|
|
485
482
|
__name: "TimePicker",
|
|
486
483
|
props: {
|
|
487
484
|
show: { type: Boolean },
|
|
488
485
|
modelValue: {},
|
|
489
|
-
title: { default:
|
|
490
|
-
columnsType: { default: () =>
|
|
486
|
+
title: { default: Fe },
|
|
487
|
+
columnsType: { default: () => Le },
|
|
491
488
|
minTime: {},
|
|
492
489
|
maxTime: {},
|
|
493
490
|
teleport: {},
|
|
494
491
|
confirmButtonText: {},
|
|
495
492
|
cancelButtonText: {},
|
|
496
|
-
formatHourLabel: { type: Function, default:
|
|
497
|
-
formatMinuteLabel: { type: Function, default:
|
|
498
|
-
formatSecondLabel: { type: Function, default:
|
|
493
|
+
formatHourLabel: { type: Function, default: U },
|
|
494
|
+
formatMinuteLabel: { type: Function, default: U },
|
|
495
|
+
formatSecondLabel: { type: Function, default: U }
|
|
499
496
|
},
|
|
500
497
|
emits: ["update:show", "update:modelValue", "confirm", "cancel", "open", "closed"],
|
|
501
|
-
setup(e, { emit:
|
|
502
|
-
const n = e,
|
|
498
|
+
setup(e, { emit: a }) {
|
|
499
|
+
const n = e, u = a, o = Y([]), i = Y([]), d = O({
|
|
503
500
|
get: () => n.show,
|
|
504
|
-
set: (t) =>
|
|
505
|
-
}),
|
|
506
|
-
const { columnsType: t } = n,
|
|
507
|
-
hour:
|
|
508
|
-
minute:
|
|
509
|
-
second:
|
|
501
|
+
set: (t) => u("update:show", t)
|
|
502
|
+
}), f = O(() => {
|
|
503
|
+
const { columnsType: t } = n, l = {
|
|
504
|
+
hour: M,
|
|
505
|
+
minute: g,
|
|
506
|
+
second: w
|
|
510
507
|
};
|
|
511
|
-
return t.map((c) =>
|
|
512
|
-
}),
|
|
513
|
-
function V() {
|
|
514
|
-
const t = f.value.hour, u = m.value.hour;
|
|
515
|
-
return L(t, u, n.formatHourLabel);
|
|
516
|
-
}
|
|
508
|
+
return t.map((c) => l[c]());
|
|
509
|
+
}), p = O(() => oe(n.minTime ?? "") ?? { hour: 0, minute: 0, second: 0 }), m = O(() => oe(n.maxTime ?? "") ?? { hour: 23, minute: 59, second: 59 });
|
|
517
510
|
function M() {
|
|
518
|
-
const t =
|
|
519
|
-
return
|
|
511
|
+
const t = p.value.hour, l = m.value.hour;
|
|
512
|
+
return F(t, l, n.formatHourLabel);
|
|
520
513
|
}
|
|
521
|
-
function
|
|
522
|
-
const t =
|
|
523
|
-
return
|
|
514
|
+
function g() {
|
|
515
|
+
const t = V("hour"), { hour: l, minute: c } = p.value, { hour: h, minute: D } = m.value;
|
|
516
|
+
return F(t === l ? c : 0, t === h ? D : 59, n.formatMinuteLabel);
|
|
524
517
|
}
|
|
525
|
-
function
|
|
526
|
-
const
|
|
527
|
-
return
|
|
518
|
+
function w() {
|
|
519
|
+
const t = V("hour"), l = V("minute"), { hour: c, minute: h, second: D } = p.value, { hour: S, minute: v, second: k } = m.value;
|
|
520
|
+
return F(t === c && l === h ? D : 0, t === S && l === v ? k : 59, n.formatSecondLabel);
|
|
528
521
|
}
|
|
529
|
-
function
|
|
530
|
-
|
|
522
|
+
function V(t) {
|
|
523
|
+
const { columnsType: l } = n, c = l.indexOf(t), h = o.value[c];
|
|
524
|
+
return h !== void 0 ? Number(h) : Se(p.value, m.value, t);
|
|
531
525
|
}
|
|
532
|
-
function
|
|
533
|
-
|
|
526
|
+
function x(t) {
|
|
527
|
+
u("update:modelValue", t), i.value = t, u("confirm", t);
|
|
534
528
|
}
|
|
535
|
-
function
|
|
536
|
-
|
|
529
|
+
function y() {
|
|
530
|
+
u("cancel");
|
|
531
|
+
}
|
|
532
|
+
function s() {
|
|
533
|
+
if (u("open"), n.modelValue && n.modelValue.length) {
|
|
537
534
|
o.value = [...n.modelValue];
|
|
538
535
|
return;
|
|
539
536
|
}
|
|
540
537
|
const { columnsType: t } = n;
|
|
541
|
-
o.value = t.map((
|
|
538
|
+
o.value = t.map((l) => V(l));
|
|
542
539
|
}
|
|
543
|
-
function
|
|
544
|
-
o.value = n.modelValue ? [...n.modelValue] : [...
|
|
540
|
+
function r() {
|
|
541
|
+
o.value = n.modelValue ? [...n.modelValue] : [...i.value], u("closed");
|
|
545
542
|
}
|
|
546
|
-
return (t,
|
|
543
|
+
return (t, l) => (C(), L(ie, {
|
|
547
544
|
modelValue: o.value,
|
|
548
|
-
"onUpdate:modelValue":
|
|
545
|
+
"onUpdate:modelValue": l[0] || (l[0] = (c) => o.value = c),
|
|
549
546
|
show: d.value,
|
|
550
|
-
"onUpdate:show":
|
|
547
|
+
"onUpdate:show": l[1] || (l[1] = (c) => d.value = c),
|
|
551
548
|
title: t.title,
|
|
552
|
-
columns:
|
|
549
|
+
columns: f.value,
|
|
553
550
|
teleport: t.teleport,
|
|
554
551
|
"confirm-button-text": t.confirmButtonText,
|
|
555
552
|
"cancel-button-text": t.cancelButtonText,
|
|
556
553
|
linkage: "",
|
|
557
|
-
onConfirm:
|
|
558
|
-
onCancel:
|
|
559
|
-
onOpen:
|
|
560
|
-
onClosed:
|
|
554
|
+
onConfirm: x,
|
|
555
|
+
onCancel: y,
|
|
556
|
+
onOpen: s,
|
|
557
|
+
onClosed: r
|
|
561
558
|
}, null, 8, ["modelValue", "show", "title", "columns", "teleport", "confirm-button-text", "cancel-button-text"]));
|
|
562
559
|
}
|
|
563
560
|
});
|
|
564
561
|
export {
|
|
565
562
|
Ge as DatePicker,
|
|
566
|
-
|
|
563
|
+
ie as Picker,
|
|
567
564
|
Ke as TimePicker
|
|
568
565
|
};
|