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