@component-hook/picker 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,42 +1,40 @@
1
1
  import "./index.css";
2
2
  import { forwardRef as e, useEffect as t, useImperativeHandle as n, useMemo as r, useRef as i, useState as a } from "react";
3
- //#region \0rolldown/runtime.js
4
- var o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
5
- if (typeof require < "u") return require.apply(this, arguments);
6
- throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
7
- }), c = .52, l = .008, u = [
3
+ import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
4
+ //#region src/shared/constants.ts
5
+ var l = .52, u = .008, d = [
8
6
  "year",
9
7
  "month",
10
8
  "day"
11
- ], d = [
9
+ ], f = [
12
10
  "hour",
13
11
  "minute",
14
12
  "second"
15
- ], f = Array.isArray;
13
+ ], p = Array.isArray;
16
14
  //#endregion
17
15
  //#region src/shared/utils/common.ts
18
- function p(e, t) {
19
- if (v(e)) return "multiple";
16
+ function m(e, t) {
17
+ if (y(e)) return "multiple";
20
18
  let [n] = e;
21
19
  return n?.[t.children] ? "cascade" : "single";
22
20
  }
23
- function m(e) {
21
+ function h(e) {
24
22
  return {
25
23
  children: e?.children || "children",
26
24
  label: e?.label || "label",
27
25
  value: e?.value || "value"
28
26
  };
29
27
  }
30
- function h(e, t, n) {
31
- if (v(e)) return [];
28
+ function g(e, t, n) {
29
+ if (y(e)) return [];
32
30
  let r = [], i = e, a = 0;
33
31
  for (; i;) {
34
- let e = t[a], o = _(i, e, n);
32
+ let e = t[a], o = v(i, e, n);
35
33
  o === -1 && (o = 0), r.push(i), a += 1, i = i[o]?.[n.children];
36
34
  }
37
35
  return r;
38
36
  }
39
- function g(e, t, n, r) {
37
+ function _(e, t, n, r) {
40
38
  let i = [...n], a = e, o = t + 1;
41
39
  for (; a?.[r.children];) {
42
40
  let e = a[r.children][0];
@@ -44,21 +42,21 @@ function g(e, t, n, r) {
44
42
  }
45
43
  return i;
46
44
  }
47
- function _(e, t, n) {
45
+ function v(e, t, n) {
48
46
  return e.findIndex((e) => e?.[n.value] === t);
49
47
  }
50
- function v(e) {
48
+ function y(e) {
51
49
  let [t] = e;
52
- return f(t);
50
+ return p(t);
53
51
  }
54
- function y(e, t) {
52
+ function b(e, t) {
55
53
  return e > t ? "horizontal" : t > e ? "vertical" : "";
56
54
  }
57
- function b() {
55
+ function x() {
58
56
  let { fontSize: e } = getComputedStyle(document.documentElement);
59
57
  return Number(e.replace("px", "")) || 16;
60
58
  }
61
- function x(e, t, n) {
59
+ function S(e, t, n) {
62
60
  let r = [];
63
61
  for (let i = e; i <= t; i++) {
64
62
  let e = n(String(i));
@@ -69,55 +67,55 @@ function x(e, t, n) {
69
67
  }
70
68
  return r;
71
69
  }
72
- function S(e, t) {
73
- return e === t.getFullYear();
74
- }
75
70
  function C(e, t) {
76
71
  return e === t.getFullYear();
77
72
  }
78
73
  function w(e, t) {
79
- return e === t.getMonth() + 1;
74
+ return e === t.getFullYear();
80
75
  }
81
76
  function T(e, t) {
82
77
  return e === t.getMonth() + 1;
83
78
  }
84
79
  function E(e, t) {
80
+ return e === t.getMonth() + 1;
81
+ }
82
+ function D(e, t) {
85
83
  return new Date(e, t, 0).getDate();
86
84
  }
87
- function D(e, t, n) {
85
+ function O(e, t, n) {
88
86
  let r = /* @__PURE__ */ new Date(), i = Date.now(), a = e.getTime(), o = t.getTime(), s = i >= a && i <= o;
89
87
  return n === "year" ? s ? r.getFullYear() : e.getFullYear() : n === "month" ? (s ? r.getMonth() : e.getMonth()) + 1 : s ? r.getDate() : e.getDate();
90
88
  }
91
- function O(e) {
89
+ function k(e) {
92
90
  return e;
93
91
  }
94
- function k(e) {
92
+ function A(e) {
95
93
  return /^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d$/.test(e);
96
94
  }
97
- function A(e) {
98
- if (!k(e)) return null;
99
- let [t, n, r] = e.split(":");
95
+ function j(e) {
96
+ if (!A(e)) return null;
97
+ let [t, n, r] = e.split(":", 3);
100
98
  return {
101
99
  hour: Number(t),
102
100
  minute: Number(n),
103
101
  second: Number(r)
104
102
  };
105
103
  }
106
- function j(e) {
104
+ function M(e) {
107
105
  return e.padStart(2, "0");
108
106
  }
109
- function M(e, t, n) {
107
+ function N(e, t, n) {
110
108
  let r = Date.now(), { hour: i, minute: a, second: o } = e, { hour: s, minute: c, second: l } = t, u = (/* @__PURE__ */ new Date()).setHours(i, a, o), d = (/* @__PURE__ */ new Date()).setHours(s, c, l), f = r >= u && r <= d;
111
109
  return n === "hour" ? f ? (/* @__PURE__ */ new Date()).getHours() : i : n === "minute" ? f ? (/* @__PURE__ */ new Date()).getMinutes() : a : f ? (/* @__PURE__ */ new Date()).getSeconds() : o;
112
110
  }
113
111
  //#endregion
114
112
  //#region src/react/hooks/fixed-forward-ref.ts
115
- function N(t) {
113
+ function P(t) {
116
114
  return e(t);
117
115
  }
118
116
  //#endregion
119
117
  //#region src/shared/utils/pointer.ts
120
- function P() {
118
+ function F() {
121
119
  let e = {
122
120
  startX: 0,
123
121
  startY: 0,
@@ -136,7 +134,7 @@ function P() {
136
134
  function s(r) {
137
135
  if (!e.startX || !e.startY) return !0;
138
136
  let i = "touches" in r ? r.touches[0] : r;
139
- e.deltaX = Math.max(i.clientX, 0) - e.startX, e.deltaY = i.clientY - e.startY, e.offsetX = Math.abs(e.deltaX), e.offsetY = Math.abs(e.deltaY), (!t || e.offsetX < 10 && e.offsetY < 10) && (t = y(e.offsetX, e.offsetY)), n && (e.offsetX > 5 || e.offsetY > 5) && (n = !1);
137
+ e.deltaX = Math.max(i.clientX, 0) - e.startX, e.deltaY = i.clientY - e.startY, e.offsetX = Math.abs(e.deltaX), e.offsetY = Math.abs(e.deltaY), (!t || e.offsetX < 10 && e.offsetY < 10) && (t = b(e.offsetX, e.offsetY)), n && (e.offsetX > 5 || e.offsetY > 5) && (n = !1);
140
138
  }
141
139
  function c() {
142
140
  e.startX = 0, e.startY = 0;
@@ -153,42 +151,42 @@ function P() {
153
151
  }
154
152
  //#endregion
155
153
  //#region src/react/hooks/use-scroll-snap.ts
156
- function F({ column: e, onChange: t }) {
157
- let n = b() / 16, [o, s] = a(0), c = i(null), u = i(0), d = i(0), f = i(0), p = i(0), m = i(!1), h = i(null), { pointer: g, start: _, move: v, stop: y } = r(() => P(), []);
158
- function x(e) {
154
+ function I({ column: e, onChange: t }) {
155
+ let n = x() / 16, [o, s] = a(0), c = i(null), l = i(0), d = i(0), f = i(0), p = i(0), m = i(!1), h = i(null), { pointer: g, start: _, move: v, stop: y } = r(() => F(), []);
156
+ function b(e) {
159
157
  return e * n;
160
158
  }
161
159
  function S(t) {
162
- let n = e.length, r = Math.round(-t / x(48));
160
+ let n = e.length, r = Math.round(-t / b(48));
163
161
  return r < 0 ? 0 : r >= n ? n - 1 : r;
164
162
  }
165
163
  function C(e) {
166
- let n = -e * x(48), r = () => t?.(e);
167
- m.current && n !== u.current ? h.current = r : r(), E(n);
164
+ let n = -e * b(48), r = () => t?.(e);
165
+ m.current && n !== l.current ? h.current = r : r(), E(n);
168
166
  }
169
167
  function w(e) {
170
- _(e), m.current = !0, s(0), f.current = Date.now(), d.current = u.current, p.current = d.current, h.current = null;
168
+ _(e), m.current = !0, s(0), f.current = Date.now(), d.current = l.current, p.current = d.current, h.current = null;
171
169
  }
172
170
  function T(t) {
173
171
  if (v(t)) return;
174
- let n = e.length, r = d.current + g.deltaY, i = x((n - 1) * -48), a = Math.min(Math.max(r, i), 0), o = Date.now();
172
+ let n = e.length, r = d.current + g.deltaY, i = b((n - 1) * -48), a = Math.min(Math.max(r, i), 0), o = Date.now();
175
173
  E(a), !(o - f.current <= 300) && (f.current = o, p.current = a);
176
174
  }
177
175
  function E(e) {
178
- u.current = e, c.current && c.current.style.setProperty("--offset-y", String(e));
176
+ l.current = e, c.current && c.current.style.setProperty("--offset-y", String(e));
179
177
  }
180
178
  function D() {
181
179
  y();
182
- let e = u.current - p.current, t = Date.now() - f.current;
180
+ let e = l.current - p.current, t = Date.now() - f.current;
183
181
  if (t < 300 && Math.abs(e) > 15) {
184
182
  O(e, t);
185
183
  return;
186
184
  }
187
- let n = S(u.current);
185
+ let n = S(l.current);
188
186
  s(150), C(n), m.current = !1;
189
187
  }
190
188
  function O(e, t) {
191
- let n = Math.abs(e / t), r = S(u.current + n / l * (e < 0 ? -1 : 1));
189
+ let n = Math.abs(e / t), r = S(l.current + n / u * (e < 0 ? -1 : 1));
192
190
  s(300), C(r);
193
191
  }
194
192
  function k() {
@@ -208,422 +206,246 @@ function F({ column: e, onChange: t }) {
208
206
  };
209
207
  }
210
208
  //#endregion
211
- //#region ../../node_modules/.pnpm/react@19.2.7/node_modules/react/cjs/react-jsx-runtime.production.js
212
- var I = /* @__PURE__ */ o(((e) => {
213
- var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
214
- function r(e, n, r) {
215
- var i = null;
216
- if (r !== void 0 && (i = "" + r), n.key !== void 0 && (i = "" + n.key), "key" in n) for (var a in r = {}, n) a !== "key" && (r[a] = n[a]);
217
- else r = n;
218
- return n = r.ref, {
219
- $$typeof: t,
220
- type: e,
221
- key: i,
222
- ref: n === void 0 ? null : n,
223
- props: r
224
- };
225
- }
226
- e.Fragment = n, e.jsx = r, e.jsxs = r;
227
- })), L = /* @__PURE__ */ o(((e) => {
228
- process.env.NODE_ENV !== "production" && (function() {
229
- function t(e) {
230
- if (e == null) return null;
231
- if (typeof e == "function") return e.$$typeof === k ? null : e.displayName || e.name || null;
232
- if (typeof e == "string") return e;
233
- switch (e) {
234
- case v: return "Fragment";
235
- case b: return "Profiler";
236
- case y: return "StrictMode";
237
- case w: return "Suspense";
238
- case T: return "SuspenseList";
239
- case O: return "Activity";
240
- }
241
- if (typeof e == "object") switch (typeof e.tag == "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), e.$$typeof) {
242
- case _: return "Portal";
243
- case S: return e.displayName || "Context";
244
- case x: return (e._context.displayName || "Context") + ".Consumer";
245
- case C:
246
- var n = e.render;
247
- return e = e.displayName, e ||= (e = n.displayName || n.name || "", e === "" ? "ForwardRef" : "ForwardRef(" + e + ")"), e;
248
- case E: return n = e.displayName || null, n === null ? t(e.type) || "Memo" : n;
249
- case D:
250
- n = e._payload, e = e._init;
251
- try {
252
- return t(e(n));
253
- } catch {}
254
- }
255
- return null;
256
- }
257
- function n(e) {
258
- return "" + e;
259
- }
260
- function r(e) {
261
- try {
262
- n(e);
263
- var t = !1;
264
- } catch {
265
- t = !0;
266
- }
267
- if (t) {
268
- t = console;
269
- var r = t.error, i = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
270
- return r.call(t, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", i), n(e);
271
- }
272
- }
273
- function i(e) {
274
- if (e === v) return "<>";
275
- if (typeof e == "object" && e && e.$$typeof === D) return "<...>";
276
- try {
277
- var n = t(e);
278
- return n ? "<" + n + ">" : "<...>";
279
- } catch {
280
- return "<...>";
281
- }
282
- }
283
- function a() {
284
- var e = A.A;
285
- return e === null ? null : e.getOwner();
286
- }
287
- function o() {
288
- return Error("react-stack-top-frame");
289
- }
290
- function c(e) {
291
- if (j.call(e, "key")) {
292
- var t = Object.getOwnPropertyDescriptor(e, "key").get;
293
- if (t && t.isReactWarning) return !1;
294
- }
295
- return e.key !== void 0;
296
- }
297
- function l(e, t) {
298
- function n() {
299
- P || (P = !0, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", t));
300
- }
301
- n.isReactWarning = !0, Object.defineProperty(e, "key", {
302
- get: n,
303
- configurable: !0
304
- });
305
- }
306
- function u() {
307
- var e = t(this.type);
308
- return F[e] || (F[e] = !0, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")), e = this.props.ref, e === void 0 ? null : e;
309
- }
310
- function d(e, t, n, r, i, a) {
311
- var o = n.ref;
312
- return e = {
313
- $$typeof: g,
314
- type: e,
315
- key: t,
316
- props: n,
317
- _owner: r
318
- }, (o === void 0 ? null : o) === null ? Object.defineProperty(e, "ref", {
319
- enumerable: !1,
320
- value: null
321
- }) : Object.defineProperty(e, "ref", {
322
- enumerable: !1,
323
- get: u
324
- }), e._store = {}, Object.defineProperty(e._store, "validated", {
325
- configurable: !1,
326
- enumerable: !1,
327
- writable: !0,
328
- value: 0
329
- }), Object.defineProperty(e, "_debugInfo", {
330
- configurable: !1,
331
- enumerable: !1,
332
- writable: !0,
333
- value: null
334
- }), Object.defineProperty(e, "_debugStack", {
335
- configurable: !1,
336
- enumerable: !1,
337
- writable: !0,
338
- value: i
339
- }), Object.defineProperty(e, "_debugTask", {
340
- configurable: !1,
341
- enumerable: !1,
342
- writable: !0,
343
- value: a
344
- }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
345
- }
346
- function f(e, n, i, o, s, u) {
347
- var f = n.children;
348
- if (f !== void 0) if (o) if (M(f)) {
349
- for (o = 0; o < f.length; o++) p(f[o]);
350
- Object.freeze && Object.freeze(f);
351
- } else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
352
- else p(f);
353
- if (j.call(n, "key")) {
354
- f = t(e);
355
- var m = Object.keys(n).filter(function(e) {
356
- return e !== "key";
357
- });
358
- o = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", R[f + o] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", o, f, m, f), R[f + o] = !0);
359
- }
360
- if (f = null, i !== void 0 && (r(i), f = "" + i), c(n) && (r(n.key), f = "" + n.key), "key" in n) for (var h in i = {}, n) h !== "key" && (i[h] = n[h]);
361
- else i = n;
362
- return f && l(i, typeof e == "function" ? e.displayName || e.name || "Unknown" : e), d(e, f, i, a(), s, u);
363
- }
364
- function p(e) {
365
- m(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e && e.$$typeof === D && (e._payload.status === "fulfilled" ? m(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
366
- }
367
- function m(e) {
368
- return typeof e == "object" && !!e && e.$$typeof === g;
369
- }
370
- var h = s("react"), g = Symbol.for("react.transitional.element"), _ = Symbol.for("react.portal"), v = Symbol.for("react.fragment"), y = Symbol.for("react.strict_mode"), b = Symbol.for("react.profiler"), x = Symbol.for("react.consumer"), S = Symbol.for("react.context"), C = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), T = Symbol.for("react.suspense_list"), E = Symbol.for("react.memo"), D = Symbol.for("react.lazy"), O = Symbol.for("react.activity"), k = Symbol.for("react.client.reference"), A = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, j = Object.prototype.hasOwnProperty, M = Array.isArray, N = console.createTask ? console.createTask : function() {
371
- return null;
372
- };
373
- h = { react_stack_bottom_frame: function(e) {
374
- return e();
375
- } };
376
- var P, F = {}, I = h.react_stack_bottom_frame.bind(h, o)(), L = N(i(o)), R = {};
377
- e.Fragment = v, e.jsx = function(e, t, n) {
378
- var r = 1e4 > A.recentlyCreatedOwnerStacks++;
379
- return f(e, t, n, !1, r ? Error("react-stack-top-frame") : I, r ? N(i(e)) : L);
380
- }, e.jsxs = function(e, t, n) {
381
- var r = 1e4 > A.recentlyCreatedOwnerStacks++;
382
- return f(e, t, n, !0, r ? Error("react-stack-top-frame") : I, r ? N(i(e)) : L);
383
- };
384
- })();
385
- })), R = (/* @__PURE__ */ o(((e, t) => {
386
- process.env.NODE_ENV === "production" ? t.exports = I() : t.exports = L();
387
- })))();
388
- function z({ column: e, fields: t, selectedIndex: r = 0, onChange: i }, a) {
389
- let { columnRef: o, transitionDuration: s, onPointerDown: l, onPointerMove: u, onPointerUp: d, stopInertialSliding: f, scrollToIndex: p } = F({
209
+ //#region src/react/components/picker-column.tsx
210
+ function L({ column: e, fields: t, selectedIndex: r = 0, onChange: i }, a) {
211
+ let { columnRef: o, transitionDuration: c, onPointerDown: u, onPointerMove: d, onPointerUp: f, stopInertialSliding: p, scrollToIndex: m } = I({
390
212
  column: e,
391
- onChange: m
213
+ onChange: h
392
214
  });
393
- function m(e) {
215
+ function h(e) {
394
216
  e !== r && i(e);
395
217
  }
396
- function h(e = r, t) {
397
- p(e, t);
218
+ function g(e = r, t) {
219
+ m(e, t);
398
220
  }
399
- function g(e) {
400
- e !== r && h(e, "smooth");
221
+ function _(e) {
222
+ e !== r && g(e, "smooth");
401
223
  }
402
- return n(a, () => ({ scrollToSelected: h })), /* @__PURE__ */ (0, R.jsx)("div", {
224
+ return n(a, () => ({ scrollToSelected: g })), /* @__PURE__ */ s("div", {
403
225
  role: "presentation",
404
- "aria-label": "Picker column",
405
226
  className: "chook-picker-column",
406
- onTouchStart: l,
407
- onTouchMove: u,
408
- onTouchEnd: d,
409
- onTouchCancel: d,
410
- onMouseDown: l,
411
- onMouseMove: u,
412
- onMouseUp: d,
413
- onMouseLeave: d,
227
+ onTouchStart: u,
228
+ onTouchMove: d,
229
+ onTouchEnd: f,
230
+ onTouchCancel: f,
231
+ onMouseDown: u,
232
+ onMouseMove: d,
233
+ onMouseUp: f,
234
+ onMouseLeave: f,
414
235
  style: {
415
236
  overflowY: "hidden",
416
237
  touchAction: "none"
417
238
  },
418
- children: /* @__PURE__ */ (0, R.jsx)("ul", {
239
+ children: /* @__PURE__ */ s("ul", {
419
240
  ref: o,
241
+ "aria-label": "Picker column",
420
242
  style: {
421
243
  overflowY: "hidden",
422
244
  transform: "translate3d(0, calc(var(--offset-y) * 1px), 0)",
423
- transitionDuration: `${s}ms`,
424
- transitionProperty: s ? "all" : "none",
245
+ transitionDuration: `${c}ms`,
246
+ transitionProperty: c ? "all" : "none",
425
247
  touchAction: "none"
426
248
  },
427
- onTransitionEnd: f,
428
- children: e.map((e, n) => /* @__PURE__ */ (0, R.jsx)("div", {
249
+ onTransitionEnd: p,
250
+ children: e.map((e, n) => /* @__PURE__ */ s("div", {
429
251
  tabIndex: 0,
430
252
  role: "button",
431
253
  "aria-label": "Select option",
432
254
  className: "chook-picker-column-item",
433
- onClick: () => g(n),
255
+ onClick: () => _(n),
434
256
  onKeyDown: (e) => {
435
- (e.key === "Enter" || e.key === " ") && g(n);
257
+ (e.key === "Enter" || e.key === " ") && _(n);
436
258
  },
437
- children: /* @__PURE__ */ (0, R.jsx)("p", {
259
+ children: /* @__PURE__ */ s("p", {
438
260
  className: "chook-picker-column-label",
439
- style: { transform: `rotate3d(1, 0, 0, calc((${n * 48} + var(--offset-y)) * ${c}deg)` },
261
+ style: { transform: `rotate3d(1, 0, 0, calc((${n * 48} + var(--offset-y)) * ${l}deg)` },
440
262
  children: e?.[t.label]
441
263
  })
442
264
  }, e?.[t.value]))
443
265
  })
444
266
  });
445
267
  }
446
- var B = N(z);
447
- B.displayName = "Column";
268
+ var R = P(L);
269
+ R.displayName = "Column";
448
270
  //#endregion
449
271
  //#region src/react/components/picker-columns.tsx
450
- function V(e, t) {
451
- let { loading: r, loadingSlot: a, columns: o, emptySlot: s, currentColumns: c, fields: l, selectedIndices: u, updateSelectedValueByIndex: d } = e, f = i([]);
452
- function p(e, t) {
453
- f.current[e]?.scrollToSelected(t);
272
+ function z(e, t) {
273
+ let { loading: r, loadingSlot: a, columns: l, emptySlot: u, currentColumns: d, fields: f, selectedIndices: p, updateSelectedValueByIndex: m } = e, h = i([]);
274
+ function g(e, t) {
275
+ h.current[e]?.scrollToSelected(t);
454
276
  }
455
- return n(t, () => ({ scrollColumnToSelected: p })), r ? /* @__PURE__ */ (0, R.jsxs)(R.Fragment, { children: [/* @__PURE__ */ (0, R.jsx)("div", {
277
+ return n(t, () => ({ scrollColumnToSelected: g })), r ? /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ s("div", {
456
278
  className: "chook-picker-loading",
457
279
  children: a
458
- }), /* @__PURE__ */ (0, R.jsx)("div", { className: "chook-picker-columns" })] }) : o.length ? /* @__PURE__ */ (0, R.jsxs)("div", {
280
+ }), /* @__PURE__ */ s("div", { className: "chook-picker-columns" })] }) : l.length ? /* @__PURE__ */ c("div", {
459
281
  className: "chook-picker-columns chook-picker-columns-backdrop",
460
282
  onTouchMove: (e) => e.stopPropagation(),
461
- children: [c.map((e, t) => /* @__PURE__ */ (0, R.jsx)(B, {
283
+ children: [d.map((e, t) => /* @__PURE__ */ s(R, {
462
284
  ref: (e) => {
463
- f.current[t] = e;
285
+ h.current[t] = e;
464
286
  },
465
287
  column: e,
466
- fields: l,
467
- selectedIndex: u[t],
468
- onChange: (e) => d(t, e)
469
- }, t)), /* @__PURE__ */ (0, R.jsx)("div", { className: "chook-picker-mask-backdrop" })]
470
- }) : /* @__PURE__ */ (0, R.jsx)("div", {
288
+ fields: f,
289
+ selectedIndex: p[t],
290
+ onChange: (e) => m(t, e)
291
+ }, t)), /* @__PURE__ */ s("div", { className: "chook-picker-mask-backdrop" })]
292
+ }) : /* @__PURE__ */ s("div", {
471
293
  className: "chook-picker-columns",
472
- children: s
294
+ children: u
473
295
  });
474
296
  }
475
- var H = N(V);
476
- H.displayName = "Columns";
297
+ var B = P(z);
298
+ B.displayName = "Columns";
477
299
  //#endregion
478
300
  //#region src/react/components/picker.tsx
479
- function U({ values: e, columns: n, loading: o = !1, loadingSlot: s, emptySlot: c, columnsFieldNames: l, onChange: u }) {
480
- let [d, f] = a(e ?? []), [v, y] = a([]), b = i(null), x = m(l), S = p(n, x), C = r(() => S === "single" ? [n] : S === "multiple" ? n : h(n, d, x), [
301
+ function V({ values: e, columns: n, loading: o = !1, loadingSlot: c, emptySlot: l, columnsFieldNames: u, onChange: d }) {
302
+ let [f, p] = a(e ?? []), [y, b] = a([]), x = i(null), S = h(u), C = m(n, S), w = r(() => C === "single" ? [n] : C === "multiple" ? n : g(n, f, S), [
481
303
  n,
482
- S,
483
- d,
484
- x
304
+ C,
305
+ f,
306
+ S
485
307
  ]);
486
- function w(e, t) {
487
- let n = C[e], r = n[t]?.[x.value];
488
- if (r === d[e]) return;
489
- let i = [...d];
490
- if (i[e] = r, S === "cascade") {
491
- let r = n[t], a = g(r, e, i, x);
492
- f(a), u?.(a);
493
- } else f(i), u?.(i);
494
- }
495
- function T(e) {
496
- return e.some((e, t) => e !== d[t]);
308
+ function T(e, t) {
309
+ let n = w[e], r = n[t]?.[S.value];
310
+ if (r === f[e]) return;
311
+ let i = [...f];
312
+ if (i[e] = r, C === "cascade") {
313
+ let r = n[t], a = _(r, e, i, S);
314
+ p(a), d?.(a);
315
+ } else p(i), d?.(i);
316
+ }
317
+ function E(e) {
318
+ return e.some((e, t) => e !== f[t]);
497
319
  }
498
320
  return t(() => {
499
- !e || !T(e) || f([...e]);
321
+ e && E(e) && p([...e]);
500
322
  }, [e]), t(() => {
501
- let e = C.length, t = [], n = [...d], r = !1;
323
+ let e = w.length, t = [], n = [...f], r = !1;
502
324
  for (let i = 0; i < e; i++) {
503
- let e = C[i], a = d[i], o = _(e, a, x);
325
+ let e = w[i], a = f[i], o = v(e, a, S);
504
326
  if (o === -1) {
505
- let r = (v[i] ?? 0) >= e.length ? Math.max(e.length - 1, 0) : 0;
506
- n[i] = e[r]?.[x.value], t[i] = r;
327
+ let r = (y[i] ?? 0) >= e.length ? Math.max(e.length - 1, 0) : 0;
328
+ n[i] = e[r]?.[S.value], t[i] = r;
507
329
  } else t[i] = o;
508
- t[i] !== v[i] && (b.current?.scrollColumnToSelected(i, t[i]), r = !0);
330
+ t[i] !== y[i] && (x.current?.scrollColumnToSelected(i, t[i]), r = !0);
509
331
  }
510
- r && (f(n), y(t));
332
+ r && (p(n), b(t));
511
333
  }, [
512
- d,
513
- C,
514
- x
515
- ]), /* @__PURE__ */ (0, R.jsx)("div", {
334
+ f,
335
+ w,
336
+ S
337
+ ]), /* @__PURE__ */ s("div", {
516
338
  className: "chook-picker-container",
517
339
  "aria-label": "Picker",
518
- children: /* @__PURE__ */ (0, R.jsx)(H, {
519
- ref: b,
340
+ children: /* @__PURE__ */ s(B, {
341
+ ref: x,
520
342
  loading: o,
521
- loadingSlot: s,
343
+ loadingSlot: c,
522
344
  columns: n,
523
- emptySlot: c,
524
- currentColumns: C,
525
- fields: x,
526
- selectedIndices: v,
527
- updateSelectedValueByIndex: w
345
+ emptySlot: l,
346
+ currentColumns: w,
347
+ fields: S,
348
+ selectedIndices: y,
349
+ updateSelectedValueByIndex: T
528
350
  })
529
351
  });
530
352
  }
531
353
  //#endregion
532
354
  //#region src/react/components/date-picker.tsx
533
- function W({ values: e, columnsType: i = u, minDate: o = new Date((/* @__PURE__ */ new Date()).getFullYear() - 10, 0, 1), maxDate: s = new Date((/* @__PURE__ */ new Date()).getFullYear() + 10, 11, 31), formatYearLabel: c = O, formatMonthLabel: l = O, formatDayLabel: d = O, onChange: f }, p) {
534
- let [m, h] = a([]), g = r(() => e ?? m, [e, m]), _ = r(() => {
355
+ function H({ values: e, columnsType: i = d, minDate: o = new Date((/* @__PURE__ */ new Date()).getFullYear() - 10, 0, 1), maxDate: c = new Date((/* @__PURE__ */ new Date()).getFullYear() + 10, 11, 31), formatYearLabel: l = k, formatMonthLabel: u = k, formatDayLabel: f = k, onChange: p }, m) {
356
+ let [h, g] = a([]), _ = r(() => e ?? h, [e, h]), v = r(() => {
535
357
  let e = {
536
- year: v,
537
- month: y,
538
- day: b
358
+ year: y,
359
+ month: b,
360
+ day: x
539
361
  };
540
362
  return i.map((t) => e[t]());
541
363
  }, [
542
364
  i,
543
365
  o,
544
- s,
545
- g,
546
366
  c,
367
+ _,
547
368
  l,
548
- d
369
+ u,
370
+ f
549
371
  ]);
550
- function v() {
551
- return x(o.getFullYear(), s.getFullYear(), c);
552
- }
553
372
  function y() {
554
- let e = k("year");
555
- return x(S(e, o) ? o.getMonth() + 1 : 1, C(e, s) ? s.getMonth() + 1 : 12, l);
373
+ return S(o.getFullYear(), c.getFullYear(), l);
556
374
  }
557
375
  function b() {
558
- let e = k("year"), t = k("month"), n = S(e, o) && w(t, o), r = C(e, s) && T(t, s);
559
- return x(n ? o.getDate() : 1, r ? s.getDate() : E(e, t), d);
376
+ let e = A("year");
377
+ return S(C(e, o) ? o.getMonth() + 1 : 1, w(e, c) ? c.getMonth() + 1 : 12, u);
378
+ }
379
+ function x() {
380
+ let e = A("year"), t = A("month"), n = C(e, o) && T(t, o), r = w(e, c) && E(t, c);
381
+ return S(n ? o.getDate() : 1, r ? c.getDate() : D(e, t), f);
560
382
  }
561
- function k(e) {
562
- let t = i.indexOf(e), n = g?.[t];
563
- return n ? Number(n) : D(o, s, e);
383
+ function A(e) {
384
+ let t = i.indexOf(e), n = _?.[t];
385
+ return n ? Number(n) : O(o, c, e);
564
386
  }
565
- function A(t) {
566
- e || h(t), f?.(t);
387
+ function j(t) {
388
+ e || g(t), p?.(t);
567
389
  }
568
- function j() {
569
- A(i.map((e) => D(o, s, e)));
390
+ function M() {
391
+ j(i.map((e) => O(o, c, e)));
570
392
  }
571
393
  return t(() => {
572
- (!e || !e.length) && j();
573
- }, []), n(p, () => ({ setCurrentDate: j })), /* @__PURE__ */ (0, R.jsx)(U, {
574
- values: g,
575
- columns: _,
576
- onChange: A
394
+ (!e || !e.length) && M();
395
+ }, []), n(m, () => ({ setCurrentDate: M })), /* @__PURE__ */ s(V, {
396
+ values: _,
397
+ columns: v,
398
+ onChange: j
577
399
  });
578
400
  }
579
- var G = N(W);
580
- G.displayName = "DatePicker";
401
+ var U = P(H);
402
+ U.displayName = "DatePicker";
581
403
  //#endregion
582
404
  //#region src/react/components/time-picker.tsx
583
- function K({ values: e, columnsType: i = d, minTime: o, maxTime: s, formatHourLabel: c = j, formatMinuteLabel: l = j, formatSecondLabel: u = j, onChange: f }, p) {
584
- let [m, h] = a([]), g = r(() => e ?? m, [e, m]), _ = r(() => A(o ?? "") ?? {
405
+ function W({ values: e, columnsType: i = f, minTime: o, maxTime: c, formatHourLabel: l = M, formatMinuteLabel: u = M, formatSecondLabel: d = M, onChange: p }, m) {
406
+ let [h, g] = a([]), _ = r(() => e ?? h, [e, h]), v = r(() => j(o ?? "") ?? {
585
407
  hour: 0,
586
408
  minute: 0,
587
409
  second: 0
588
- }, [o]), v = r(() => A(s ?? "") ?? {
410
+ }, [o]), y = r(() => j(c ?? "") ?? {
589
411
  hour: 23,
590
412
  minute: 59,
591
413
  second: 59
592
- }, [s]), y = {
593
- hour: S,
594
- minute: C,
595
- second: w
596
- }, b = i.map((e) => y[e]());
597
- function S() {
598
- return x(_.hour, v.hour, c);
599
- }
414
+ }, [c]), b = {
415
+ hour: C,
416
+ minute: w,
417
+ second: T
418
+ }, x = i.map((e) => b[e]());
600
419
  function C() {
601
- let e = T("hour"), { hour: t, minute: n } = _, { hour: r, minute: i } = v;
602
- return x(e === t ? n : 0, e === r ? i : 59, l);
420
+ return S(v.hour, y.hour, l);
603
421
  }
604
422
  function w() {
605
- let e = T("hour"), t = T("minute"), { hour: n, minute: r, second: i } = _, { hour: a, minute: o, second: s } = v;
606
- return x(e === n && t === r ? i : 0, e === a && t === o ? s : 59, u);
423
+ let e = E("hour"), { hour: t, minute: n } = v, { hour: r, minute: i } = y;
424
+ return S(e === t ? n : 0, e === r ? i : 59, u);
425
+ }
426
+ function T() {
427
+ let e = E("hour"), t = E("minute"), { hour: n, minute: r, second: i } = v, { hour: a, minute: o, second: s } = y;
428
+ return S(e === n && t === r ? i : 0, e === a && t === o ? s : 59, d);
607
429
  }
608
- function T(e) {
609
- let t = i.indexOf(e), n = g?.[t];
610
- return n === void 0 ? M(_, v, e) : Number(n);
430
+ function E(e) {
431
+ let t = i.indexOf(e), n = _?.[t];
432
+ return n === void 0 ? N(v, y, e) : Number(n);
611
433
  }
612
- function E(t) {
613
- e || h(t), f?.(t);
434
+ function D(t) {
435
+ e || g(t), p?.(t);
614
436
  }
615
- function D() {
616
- E(i.map((e) => M(_, v, e)));
437
+ function O() {
438
+ D(i.map((e) => N(v, y, e)));
617
439
  }
618
440
  return t(() => {
619
- (!e || !e.length) && D();
620
- }, []), n(p, () => ({ setCurrentTime: D })), /* @__PURE__ */ (0, R.jsx)(U, {
621
- values: g,
622
- columns: b,
623
- onChange: E
441
+ (!e || !e.length) && O();
442
+ }, []), n(m, () => ({ setCurrentTime: O })), /* @__PURE__ */ s(V, {
443
+ values: _,
444
+ columns: x,
445
+ onChange: D
624
446
  });
625
447
  }
626
- var q = N(K);
627
- q.displayName = "TimePicker";
448
+ var G = P(W);
449
+ G.displayName = "TimePicker";
628
450
  //#endregion
629
- export { G as DatePicker, U as Picker, q as TimePicker };
451
+ export { U as DatePicker, V as Picker, G as TimePicker };