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