@component-hook/picker 1.0.0 → 1.0.1

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