@component-hook/picker 1.1.2 → 1.1.4
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 +1143 -1147
- package/dist/react/picker.umd.js +15 -15
- package/dist/vue/index.css +1 -1
- package/dist/vue/picker.es.js +288 -291
- package/dist/vue/picker.umd.js +2 -2
- package/package.json +2 -2
package/dist/vue/picker.es.js
CHANGED
|
@@ -1,75 +1,74 @@
|
|
|
1
1
|
import "./index.css";
|
|
2
|
-
import { ref as
|
|
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
73
|
function H(e) {
|
|
75
74
|
return e;
|
|
@@ -79,17 +78,17 @@ 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
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 = 16, N = 48,
|
|
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"];
|
|
93
92
|
function Ee() {
|
|
94
93
|
const e = {
|
|
95
94
|
startX: 0,
|
|
@@ -99,88 +98,88 @@ function Ee() {
|
|
|
99
98
|
offsetX: 0,
|
|
100
99
|
offsetY: 0
|
|
101
100
|
};
|
|
102
|
-
let
|
|
103
|
-
const n = () =>
|
|
101
|
+
let a = "";
|
|
102
|
+
const n = () => a === "vertical", u = () => a === "horizontal";
|
|
104
103
|
function o() {
|
|
105
|
-
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 = "";
|
|
106
105
|
}
|
|
107
|
-
function
|
|
108
|
-
const m = "touches" in
|
|
106
|
+
function i(p) {
|
|
107
|
+
const m = "touches" in p ? p.touches[0] : p;
|
|
109
108
|
o(), e.startX = m.clientX, e.startY = m.clientY;
|
|
110
109
|
}
|
|
111
|
-
function d(
|
|
110
|
+
function d(p) {
|
|
112
111
|
if (!e.startX || !e.startY) return !0;
|
|
113
|
-
const m = "touches" in
|
|
112
|
+
const m = "touches" in p ? p.touches[0] : p;
|
|
114
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);
|
|
115
|
-
const
|
|
116
|
-
(!
|
|
114
|
+
const M = 10;
|
|
115
|
+
(!a || e.offsetX < M && e.offsetY < M) && (a = Me(e.offsetX, e.offsetY));
|
|
117
116
|
}
|
|
118
|
-
function
|
|
117
|
+
function f() {
|
|
119
118
|
e.startX = 0, e.startY = 0;
|
|
120
119
|
}
|
|
121
120
|
return {
|
|
122
121
|
pointer: e,
|
|
123
122
|
move: d,
|
|
124
|
-
start:
|
|
125
|
-
stop:
|
|
123
|
+
start: i,
|
|
124
|
+
stop: f,
|
|
126
125
|
reset: o,
|
|
127
126
|
isVertical: n,
|
|
128
|
-
isHorizontal:
|
|
127
|
+
isHorizontal: u
|
|
129
128
|
};
|
|
130
129
|
}
|
|
131
|
-
function Be({ column: e, onChange:
|
|
132
|
-
const
|
|
133
|
-
let
|
|
134
|
-
function
|
|
135
|
-
|
|
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;
|
|
136
135
|
}
|
|
137
|
-
function
|
|
138
|
-
if (
|
|
139
|
-
const b = j(e) ? e.value.length : e.length,
|
|
140
|
-
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);
|
|
141
140
|
}
|
|
142
|
-
function
|
|
141
|
+
function r() {
|
|
143
142
|
m();
|
|
144
|
-
const
|
|
145
|
-
if (
|
|
146
|
-
t(
|
|
143
|
+
const v = o.value - w, k = Date.now() - g;
|
|
144
|
+
if (k < X && Math.abs(v) > Ie) {
|
|
145
|
+
t(v, k);
|
|
147
146
|
return;
|
|
148
147
|
}
|
|
149
|
-
const b =
|
|
150
|
-
|
|
148
|
+
const b = h(o.value);
|
|
149
|
+
i.value = le, c(b), V = !1;
|
|
151
150
|
}
|
|
152
|
-
function t(
|
|
153
|
-
const b = Math.abs(
|
|
154
|
-
|
|
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($);
|
|
155
154
|
}
|
|
156
|
-
function
|
|
157
|
-
|
|
155
|
+
function l() {
|
|
156
|
+
i.value = 0, V = !1, x && (x(), x = null);
|
|
158
157
|
}
|
|
159
|
-
function c(
|
|
160
|
-
const
|
|
161
|
-
|
|
158
|
+
function c(v) {
|
|
159
|
+
const k = -v * D(N), b = () => a?.(v);
|
|
160
|
+
V && k !== o.value ? x = b : b(), o.value = k;
|
|
162
161
|
}
|
|
163
|
-
function
|
|
164
|
-
const
|
|
165
|
-
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;
|
|
166
165
|
}
|
|
167
|
-
function v
|
|
168
|
-
return
|
|
166
|
+
function D(v) {
|
|
167
|
+
return v * u;
|
|
169
168
|
}
|
|
170
|
-
function S(
|
|
171
|
-
|
|
169
|
+
function S(v, k = "auto") {
|
|
170
|
+
V && k === "smooth" || (x = null, V = k === "smooth", i.value = k === "smooth" ? le : 0, c(v));
|
|
172
171
|
}
|
|
173
172
|
return {
|
|
174
173
|
offsetY: Z(o),
|
|
175
|
-
transitionDuration: Z(
|
|
176
|
-
onPointerDown:
|
|
177
|
-
onPointerMove:
|
|
178
|
-
onPointerUp:
|
|
179
|
-
stopInertialSliding:
|
|
174
|
+
transitionDuration: Z(i),
|
|
175
|
+
onPointerDown: y,
|
|
176
|
+
onPointerMove: s,
|
|
177
|
+
onPointerUp: r,
|
|
178
|
+
stopInertialSliding: l,
|
|
180
179
|
scrollToIndex: S
|
|
181
180
|
};
|
|
182
181
|
}
|
|
183
|
-
const Ae = ["onClick"], Ne = /* @__PURE__ */
|
|
182
|
+
const Ae = ["onClick"], Ne = /* @__PURE__ */ E({
|
|
184
183
|
__name: "PickerColumn",
|
|
185
184
|
props: {
|
|
186
185
|
column: {},
|
|
@@ -188,85 +187,85 @@ const Ae = ["onClick"], Ne = /* @__PURE__ */ B({
|
|
|
188
187
|
selectedIndex: { default: 0 }
|
|
189
188
|
},
|
|
190
189
|
emits: ["change"],
|
|
191
|
-
setup(e, { expose:
|
|
192
|
-
const
|
|
193
|
-
column:
|
|
194
|
-
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
|
|
195
194
|
});
|
|
196
|
-
function
|
|
197
|
-
|
|
195
|
+
function w(y) {
|
|
196
|
+
y !== u.selectedIndex && o("change", y);
|
|
198
197
|
}
|
|
199
|
-
function y
|
|
200
|
-
|
|
198
|
+
function V(y = u.selectedIndex, s) {
|
|
199
|
+
g(y, s);
|
|
201
200
|
}
|
|
202
|
-
function
|
|
203
|
-
|
|
201
|
+
function x(y) {
|
|
202
|
+
y !== u.selectedIndex && V(y, "smooth");
|
|
204
203
|
}
|
|
205
|
-
return
|
|
204
|
+
return a({ scrollToSelected: V }), (y, s) => (C(), P("div", {
|
|
206
205
|
class: "chook-picker-column",
|
|
207
|
-
onTouchstartPassive:
|
|
208
|
-
(...
|
|
209
|
-
onTouchmovePassive:
|
|
210
|
-
(...
|
|
211
|
-
onTouchendPassive:
|
|
212
|
-
(...
|
|
213
|
-
onTouchcancel:
|
|
214
|
-
(...
|
|
215
|
-
onMousedownPassive:
|
|
216
|
-
(...
|
|
217
|
-
onMousemovePassive:
|
|
218
|
-
(...
|
|
219
|
-
onMouseupPassive:
|
|
220
|
-
(...
|
|
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))
|
|
221
220
|
}, [
|
|
222
|
-
|
|
221
|
+
I("ul", {
|
|
223
222
|
style: q({
|
|
224
223
|
overflowY: "hidden",
|
|
225
|
-
transform: `translate3d(0, ${
|
|
226
|
-
transitionDuration: `${
|
|
227
|
-
transitionProperty:
|
|
224
|
+
transform: `translate3d(0, ${T(i)}px, 0)`,
|
|
225
|
+
transitionDuration: `${T(d)}ms`,
|
|
226
|
+
transitionProperty: T(d) ? "all" : "none"
|
|
228
227
|
}),
|
|
229
|
-
onTransitionend:
|
|
230
|
-
(...
|
|
228
|
+
onTransitionend: s[0] || (s[0] = //@ts-ignore
|
|
229
|
+
(...r) => T(M) && T(M)(...r))
|
|
231
230
|
}, [
|
|
232
|
-
(
|
|
233
|
-
key:
|
|
231
|
+
(C(!0), P(R, null, ue(y.column, (r, t) => (C(), P("li", {
|
|
232
|
+
key: r?.[y.fields.value],
|
|
234
233
|
class: "chook-picker-column-item",
|
|
235
234
|
role: "button",
|
|
236
235
|
tabindex: "0",
|
|
237
|
-
onClick: (
|
|
236
|
+
onClick: (l) => x(t)
|
|
238
237
|
}, [
|
|
239
|
-
|
|
238
|
+
I("p", {
|
|
240
239
|
class: "chook-picker-column-label",
|
|
241
240
|
style: q({
|
|
242
|
-
transform: `rotate3d(1, 0, 0, ${(t *
|
|
241
|
+
transform: `rotate3d(1, 0, 0, ${(t * T(N) + T(i)) * T(Ce)}deg)`
|
|
243
242
|
})
|
|
244
|
-
}, A(
|
|
243
|
+
}, A(r?.[y.fields.label]), 5)
|
|
245
244
|
], 8, Ae))), 128))
|
|
246
245
|
], 36)
|
|
247
246
|
], 32));
|
|
248
247
|
}
|
|
249
|
-
}), $e = { class: "chook-picker-container" }, He = /* @__PURE__ */
|
|
248
|
+
}), $e = { class: "chook-picker-container" }, He = /* @__PURE__ */ E({
|
|
250
249
|
__name: "Popup",
|
|
251
250
|
props: {
|
|
252
251
|
teleport: { default: "body" },
|
|
253
252
|
modelValue: { type: Boolean }
|
|
254
253
|
},
|
|
255
254
|
emits: ["update:modelValue", "open", "close", "closed"],
|
|
256
|
-
setup(e, { emit:
|
|
257
|
-
const n = e,
|
|
255
|
+
setup(e, { emit: a }) {
|
|
256
|
+
const n = e, u = a;
|
|
258
257
|
return ce(
|
|
259
258
|
() => n.modelValue,
|
|
260
259
|
(o) => {
|
|
261
|
-
o ? (document.body.style.overflow = "hidden",
|
|
260
|
+
o ? (document.body.style.overflow = "hidden", u("open")) : (document.body.style.overflow = "", u("close"));
|
|
262
261
|
},
|
|
263
262
|
{ immediate: !0 }
|
|
264
|
-
), (o,
|
|
263
|
+
), (o, i) => (C(), L(me, { to: o.teleport }, [
|
|
265
264
|
J(Q, { name: "chook-picker-fade" }, {
|
|
266
265
|
default: z(() => [
|
|
267
|
-
W(
|
|
266
|
+
W(I("div", {
|
|
268
267
|
class: "chook-picker-mask",
|
|
269
|
-
onClick:
|
|
268
|
+
onClick: i[0] || (i[0] = (d) => o.$emit("update:modelValue", !1))
|
|
270
269
|
}, null, 512), [
|
|
271
270
|
[ee, o.modelValue]
|
|
272
271
|
])
|
|
@@ -275,10 +274,10 @@ const Ae = ["onClick"], Ne = /* @__PURE__ */ B({
|
|
|
275
274
|
}),
|
|
276
275
|
J(Q, {
|
|
277
276
|
name: "chook-picker-slide",
|
|
278
|
-
onAfterLeave:
|
|
277
|
+
onAfterLeave: i[1] || (i[1] = (d) => o.$emit("closed"))
|
|
279
278
|
}, {
|
|
280
279
|
default: z(() => [
|
|
281
|
-
W(
|
|
280
|
+
W(I("div", $e, [
|
|
282
281
|
_(o.$slots, "default")
|
|
283
282
|
], 512), [
|
|
284
283
|
[ee, o.modelValue]
|
|
@@ -291,7 +290,7 @@ const Ae = ["onClick"], Ne = /* @__PURE__ */ B({
|
|
|
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,103 +305,101 @@ const Ae = ["onClick"], Ne = /* @__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
361
|
default: z(() => [
|
|
365
|
-
|
|
366
|
-
|
|
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
|
-
|
|
373
|
+
t.loading ? (C(), P(R, { key: 0 }, [
|
|
374
|
+
I("div", Re, [
|
|
378
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)) : (
|
|
394
|
+
l[4] || (l[4] = I("div", { class: "chook-picker-mask-backdrop" }, null, -1))
|
|
395
|
+
], 32)) : (C(), P("div", ze, [
|
|
399
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 },
|
|
@@ -419,69 +416,69 @@ const Ae = ["onClick"], Ne = /* @__PURE__ */ B({
|
|
|
419
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 },
|
|
@@ -498,71 +495,71 @@ const Ae = ["onClick"], Ne = /* @__PURE__ */ B({
|
|
|
498
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
|
};
|