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