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