@component-hook/picker 1.1.2 → 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,75 +1,74 @@
1
1
  import "./index.css";
2
- import { ref as C, readonly as Z, isRef as j, defineComponent as B, toRef as ie, createElementBlock as F, openBlock as I, unref as g, createElementVNode as Y, normalizeStyle as q, Fragment as R, renderList as ue, toDisplayString as A, watch as ce, createBlock as E, 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";
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
73
  function H(e) {
75
74
  return e;
@@ -79,17 +78,17 @@ 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
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 = 16, N = 48, Ie = 0.52, le = 150, X = 300, Ye = 15, Ce = 8e-3, Oe = "Select Date", Pe = ["year", "month", "day"], Fe = "Select Time", Le = ["hour", "minute", "second"];
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"];
93
92
  function Ee() {
94
93
  const e = {
95
94
  startX: 0,
@@ -99,88 +98,88 @@ function Ee() {
99
98
  offsetX: 0,
100
99
  offsetY: 0
101
100
  };
102
- let s = "";
103
- const n = () => s === "vertical", l = () => s === "horizontal";
101
+ let a = "";
102
+ const n = () => a === "vertical", u = () => a === "horizontal";
104
103
  function o() {
105
- 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 = "";
106
105
  }
107
- function r(f) {
108
- const m = "touches" in f ? f.touches[0] : f;
106
+ function i(p) {
107
+ const m = "touches" in p ? p.touches[0] : p;
109
108
  o(), e.startX = m.clientX, e.startY = m.clientY;
110
109
  }
111
- function d(f) {
110
+ function d(p) {
112
111
  if (!e.startX || !e.startY) return !0;
113
- const m = "touches" in f ? f.touches[0] : f;
112
+ const m = "touches" in p ? p.touches[0] : p;
114
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);
115
- const V = 10;
116
- (!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));
117
116
  }
118
- function p() {
117
+ function f() {
119
118
  e.startX = 0, e.startY = 0;
120
119
  }
121
120
  return {
122
121
  pointer: e,
123
122
  move: d,
124
- start: r,
125
- stop: p,
123
+ start: i,
124
+ stop: f,
126
125
  reset: o,
127
126
  isVertical: n,
128
- isHorizontal: l
127
+ isHorizontal: u
129
128
  };
130
129
  }
131
- function Be({ column: e, onChange: s }) {
132
- const l = Number.parseFloat(getComputedStyle(document.documentElement).fontSize) / be, o = C(0), r = C(0), { pointer: d, start: p, move: f, stop: m } = Ee();
133
- let V = 0, M = 0, x = 0, y = !1, D = null;
134
- function w(h) {
135
- 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;
136
135
  }
137
- function a(h) {
138
- if (f(h)) return;
139
- const b = j(e) ? e.value.length : e.length, P = V + d.deltaY, $ = v((b - 1) * -N), G = Math.min(Math.max(P, $), 0), K = Date.now();
140
- o.value = G, !(K - M <= X) && (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);
141
140
  }
142
- function i() {
141
+ function r() {
143
142
  m();
144
- const h = o.value - x, T = Date.now() - M;
145
- if (T < X && Math.abs(h) > Ye) {
146
- 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);
147
146
  return;
148
147
  }
149
- const b = k(o.value);
150
- r.value = le, c(b), y = !1;
148
+ const b = h(o.value);
149
+ i.value = le, c(b), V = !1;
151
150
  }
152
- function t(h, T) {
153
- const b = Math.abs(h / T), P = o.value + b / Ce * (h < 0 ? -1 : 1), $ = k(P);
154
- r.value = X, c($);
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($);
155
154
  }
156
- function u() {
157
- r.value = 0, y = !1, D && (D(), D = null);
155
+ function l() {
156
+ i.value = 0, V = !1, x && (x(), x = null);
158
157
  }
159
- function c(h) {
160
- const T = -h * v(N), b = () => s == null ? void 0 : s(h);
161
- 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;
162
161
  }
163
- function k(h) {
164
- const T = j(e) ? e.value.length : e.length, b = Math.round(-h / v(N));
165
- 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;
166
165
  }
167
- function v(h) {
168
- return h * l;
166
+ function D(v) {
167
+ return v * u;
169
168
  }
170
- function S(h, T = "auto") {
171
- 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));
172
171
  }
173
172
  return {
174
173
  offsetY: Z(o),
175
- transitionDuration: Z(r),
176
- onPointerDown: w,
177
- onPointerMove: a,
178
- onPointerUp: i,
179
- stopInertialSliding: u,
174
+ transitionDuration: Z(i),
175
+ onPointerDown: y,
176
+ onPointerMove: s,
177
+ onPointerUp: r,
178
+ stopInertialSliding: l,
180
179
  scrollToIndex: S
181
180
  };
182
181
  }
183
- const Ae = ["onClick"], Ne = /* @__PURE__ */ B({
182
+ const Ae = ["onClick"], Ne = /* @__PURE__ */ E({
184
183
  __name: "PickerColumn",
185
184
  props: {
186
185
  column: {},
@@ -188,85 +187,85 @@ const Ae = ["onClick"], Ne = /* @__PURE__ */ B({
188
187
  selectedIndex: { default: 0 }
189
188
  },
190
189
  emits: ["change"],
191
- setup(e, { expose: s, emit: n }) {
192
- const l = e, o = n, { offsetY: r, transitionDuration: d, onPointerDown: p, onPointerMove: f, onPointerUp: m, stopInertialSliding: V, scrollToIndex: M } = Be({
193
- column: ie(l, "column"),
194
- 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
195
194
  });
196
- function x(w) {
197
- w !== l.selectedIndex && o("change", w);
195
+ function w(y) {
196
+ y !== u.selectedIndex && o("change", y);
198
197
  }
199
- function y(w = l.selectedIndex, a) {
200
- M(w, a);
198
+ function V(y = u.selectedIndex, s) {
199
+ g(y, s);
201
200
  }
202
- function D(w) {
203
- w !== l.selectedIndex && y(w, "smooth");
201
+ function x(y) {
202
+ y !== u.selectedIndex && V(y, "smooth");
204
203
  }
205
- return s({ scrollToSelected: y }), (w, a) => (I(), F("div", {
204
+ return a({ scrollToSelected: V }), (y, s) => (C(), P("div", {
206
205
  class: "chook-picker-column",
207
- onTouchstartPassive: a[1] || (a[1] = //@ts-ignore
208
- (...i) => g(p) && g(p)(...i)),
209
- onTouchmovePassive: a[2] || (a[2] = //@ts-ignore
210
- (...i) => g(f) && g(f)(...i)),
211
- onTouchendPassive: a[3] || (a[3] = //@ts-ignore
212
- (...i) => g(m) && g(m)(...i)),
213
- onTouchcancel: a[4] || (a[4] = //@ts-ignore
214
- (...i) => g(m) && g(m)(...i)),
215
- onMousedownPassive: a[5] || (a[5] = //@ts-ignore
216
- (...i) => g(p) && g(p)(...i)),
217
- onMousemovePassive: a[6] || (a[6] = //@ts-ignore
218
- (...i) => g(f) && g(f)(...i)),
219
- onMouseupPassive: a[7] || (a[7] = //@ts-ignore
220
- (...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))
221
220
  }, [
222
- Y("ul", {
221
+ I("ul", {
223
222
  style: q({
224
223
  overflowY: "hidden",
225
- transform: `translate3d(0, ${g(r)}px, 0)`,
226
- transitionDuration: `${g(d)}ms`,
227
- transitionProperty: g(d) ? "all" : "none"
224
+ transform: `translate3d(0, ${T(i)}px, 0)`,
225
+ transitionDuration: `${T(d)}ms`,
226
+ transitionProperty: T(d) ? "all" : "none"
228
227
  }),
229
- onTransitionend: a[0] || (a[0] = //@ts-ignore
230
- (...i) => g(V) && g(V)(...i))
228
+ onTransitionend: s[0] || (s[0] = //@ts-ignore
229
+ (...r) => T(M) && T(M)(...r))
231
230
  }, [
232
- (I(!0), F(R, null, ue(w.column, (i, t) => (I(), F("li", {
233
- 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],
234
233
  class: "chook-picker-column-item",
235
234
  role: "button",
236
235
  tabindex: "0",
237
- onClick: (u) => D(t)
236
+ onClick: (l) => x(t)
238
237
  }, [
239
- Y("p", {
238
+ I("p", {
240
239
  class: "chook-picker-column-label",
241
240
  style: q({
242
- transform: `rotate3d(1, 0, 0, ${(t * g(N) + g(r)) * g(Ie)}deg)`
241
+ transform: `rotate3d(1, 0, 0, ${(t * T(N) + T(i)) * T(Ce)}deg)`
243
242
  })
244
- }, A(i == null ? void 0 : i[w.fields.label]), 5)
243
+ }, A(r?.[y.fields.label]), 5)
245
244
  ], 8, Ae))), 128))
246
245
  ], 36)
247
246
  ], 32));
248
247
  }
249
- }), $e = { class: "chook-picker-container" }, He = /* @__PURE__ */ B({
248
+ }), $e = { class: "chook-picker-container" }, He = /* @__PURE__ */ E({
250
249
  __name: "Popup",
251
250
  props: {
252
251
  teleport: { default: "body" },
253
252
  modelValue: { type: Boolean }
254
253
  },
255
254
  emits: ["update:modelValue", "open", "close", "closed"],
256
- setup(e, { emit: s }) {
257
- const n = e, l = s;
255
+ setup(e, { emit: a }) {
256
+ const n = e, u = a;
258
257
  return ce(
259
258
  () => n.modelValue,
260
259
  (o) => {
261
- o ? (document.body.style.overflow = "hidden", l("open")) : (document.body.style.overflow = "", l("close"));
260
+ o ? (document.body.style.overflow = "hidden", u("open")) : (document.body.style.overflow = "", u("close"));
262
261
  },
263
262
  { immediate: !0 }
264
- ), (o, r) => (I(), E(me, { to: o.teleport }, [
263
+ ), (o, i) => (C(), L(me, { to: o.teleport }, [
265
264
  J(Q, { name: "chook-picker-fade" }, {
266
265
  default: z(() => [
267
- W(Y("div", {
266
+ W(I("div", {
268
267
  class: "chook-picker-mask",
269
- onClick: r[0] || (r[0] = (d) => o.$emit("update:modelValue", !1))
268
+ onClick: i[0] || (i[0] = (d) => o.$emit("update:modelValue", !1))
270
269
  }, null, 512), [
271
270
  [ee, o.modelValue]
272
271
  ])
@@ -275,10 +274,10 @@ const Ae = ["onClick"], Ne = /* @__PURE__ */ B({
275
274
  }),
276
275
  J(Q, {
277
276
  name: "chook-picker-slide",
278
- onAfterLeave: r[1] || (r[1] = (d) => o.$emit("closed"))
277
+ onAfterLeave: i[1] || (i[1] = (d) => o.$emit("closed"))
279
278
  }, {
280
279
  default: z(() => [
281
- W(Y("div", $e, [
280
+ W(I("div", $e, [
282
281
  _(o.$slots, "default")
283
282
  ], 512), [
284
283
  [ee, o.modelValue]
@@ -291,7 +290,7 @@ const Ae = ["onClick"], Ne = /* @__PURE__ */ B({
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,103 +305,101 @@ const Ae = ["onClick"], Ne = /* @__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(He, {
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
361
  default: z(() => [
365
- Y("div", Ue, [
366
- Y("button", {
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(R, { key: 0 }, [
377
- Y("div", Re, [
373
+ t.loading ? (C(), P(R, { key: 0 }, [
374
+ I("div", Re, [
378
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(R, null, ue(M.value, (c, k) => (I(), E(Ne, {
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, [
394
+ l[4] || (l[4] = I("div", { class: "chook-picker-mask-backdrop" }, null, -1))
395
+ ], 32)) : (C(), P("div", ze, [
399
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 },
@@ -419,69 +416,69 @@ const Ae = ["onClick"], Ne = /* @__PURE__ */ B({
419
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 },
@@ -498,71 +495,71 @@ const Ae = ["onClick"], Ne = /* @__PURE__ */ B({
498
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
  };