@component-hook/picker 1.1.1 → 1.1.3

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