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