asterui 0.12.28 → 0.12.30

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.
package/dist/index75.js CHANGED
@@ -1,12 +1,12 @@
1
- import { jsx as c } from "react/jsx-runtime";
2
- import b from "react";
1
+ import { jsx as f } from "react/jsx-runtime";
2
+ import v from "react";
3
3
  const w = {
4
4
  xs: "gap-1",
5
5
  sm: "gap-2",
6
6
  md: "gap-4",
7
7
  lg: "gap-6",
8
8
  xl: "gap-8"
9
- }, v = {
9
+ }, A = {
10
10
  start: "items-start",
11
11
  end: "items-end",
12
12
  center: "items-center",
@@ -19,43 +19,43 @@ const w = {
19
19
  between: "justify-between",
20
20
  around: "justify-around",
21
21
  evenly: "justify-evenly"
22
- }, k = ({
23
- direction: f = "horizontal",
24
- size: s = "md",
25
- align: r,
22
+ }, z = ({
23
+ direction: r = "horizontal",
24
+ size: e = "md",
25
+ align: p,
26
26
  justify: a,
27
- wrap: p = !1,
27
+ wrap: u = !1,
28
28
  split: l,
29
- className: u = "",
30
- style: d,
31
- children: e,
32
- ...m
29
+ className: d = "",
30
+ style: m,
31
+ children: s,
32
+ ...g
33
33
  }) => {
34
- const o = typeof s == "number", h = o ? "" : w[s], y = r ? v[r] : "", C = a ? N[a] : "", g = [
34
+ const o = typeof e == "number", h = o ? "" : w[e], i = p ?? (r === "vertical" ? "start" : void 0), y = i ? A[i] : "", C = a ? N[a] : "", j = [
35
35
  "flex",
36
- f === "horizontal" ? "flex-row" : "flex-col",
36
+ r === "horizontal" ? "flex-row" : "flex-col",
37
37
  h,
38
38
  y,
39
39
  C,
40
- p ? "flex-wrap" : "",
41
- u
42
- ].filter(Boolean).join(" "), j = {
43
- ...d,
44
- ...o ? { gap: `${s}px` } : {}
40
+ u ? "flex-wrap" : "",
41
+ d
42
+ ].filter(Boolean).join(" "), x = {
43
+ ...m,
44
+ ...o ? { gap: `${e}px` } : {}
45
45
  };
46
- return /* @__PURE__ */ c("div", { className: g, style: j, ...m, children: (() => {
47
- if (!l) return e;
48
- const t = b.Children.toArray(e).filter(Boolean);
49
- if (t.length <= 1) return e;
46
+ return /* @__PURE__ */ f("div", { className: j, style: x, ...g, children: (() => {
47
+ if (!l) return s;
48
+ const t = v.Children.toArray(s).filter(Boolean);
49
+ if (t.length <= 1) return s;
50
50
  const n = [];
51
- return t.forEach((x, i) => {
52
- n.push(x), i < t.length - 1 && n.push(
53
- /* @__PURE__ */ c("span", { className: "flex-shrink-0", children: l }, `split-${i}`)
51
+ return t.forEach((b, c) => {
52
+ n.push(b), c < t.length - 1 && n.push(
53
+ /* @__PURE__ */ f("span", { className: "flex-shrink-0", children: l }, `split-${c}`)
54
54
  );
55
55
  }), n;
56
56
  })() });
57
57
  };
58
58
  export {
59
- k as Space
59
+ z as Space
60
60
  };
61
61
  //# sourceMappingURL=index75.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index75.js","sources":["../src/components/Space.tsx"],"sourcesContent":["import React from 'react'\n\nexport interface SpaceProps extends React.HTMLAttributes<HTMLDivElement> {\n direction?: 'horizontal' | 'vertical'\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number\n align?: 'start' | 'end' | 'center' | 'baseline' | 'stretch'\n justify?: 'start' | 'end' | 'center' | 'between' | 'around' | 'evenly'\n wrap?: boolean\n split?: React.ReactNode\n children: React.ReactNode\n}\n\nconst gapClasses = {\n xs: 'gap-1',\n sm: 'gap-2',\n md: 'gap-4',\n lg: 'gap-6',\n xl: 'gap-8',\n} as const\n\nconst alignClasses = {\n start: 'items-start',\n end: 'items-end',\n center: 'items-center',\n baseline: 'items-baseline',\n stretch: 'items-stretch',\n} as const\n\nconst justifyClasses = {\n start: 'justify-start',\n end: 'justify-end',\n center: 'justify-center',\n between: 'justify-between',\n around: 'justify-around',\n evenly: 'justify-evenly',\n} as const\n\nexport const Space: React.FC<SpaceProps> = ({\n direction = 'horizontal',\n size = 'md',\n align,\n justify,\n wrap = false,\n split,\n className = '',\n style,\n children,\n ...rest\n}) => {\n const isNumericSize = typeof size === 'number'\n const gapClass = isNumericSize ? '' : gapClasses[size]\n const alignClass = align ? alignClasses[align] : ''\n const justifyClass = justify ? justifyClasses[justify] : ''\n const wrapClass = wrap ? 'flex-wrap' : ''\n const directionClass = direction === 'horizontal' ? 'flex-row' : 'flex-col'\n\n const classes = [\n 'flex',\n directionClass,\n gapClass,\n alignClass,\n justifyClass,\n wrapClass,\n className\n ].filter(Boolean).join(' ')\n\n const combinedStyle: React.CSSProperties = {\n ...style,\n ...(isNumericSize ? { gap: `${size}px` } : {}),\n }\n\n // If split is provided, interleave separator between children\n const renderChildren = () => {\n if (!split) return children\n\n const childArray = React.Children.toArray(children).filter(Boolean)\n if (childArray.length <= 1) return children\n\n const result: React.ReactNode[] = []\n childArray.forEach((child, index) => {\n result.push(child)\n if (index < childArray.length - 1) {\n result.push(\n <span key={`split-${index}`} className=\"flex-shrink-0\">\n {split}\n </span>\n )\n }\n })\n return result\n }\n\n return <div className={classes} style={combinedStyle} {...rest}>{renderChildren()}</div>\n}\n"],"names":["gapClasses","alignClasses","justifyClasses","Space","direction","size","align","justify","wrap","split","className","style","children","rest","isNumericSize","gapClass","alignClass","justifyClass","classes","combinedStyle","jsx","childArray","React","result","child","index"],"mappings":";;AAYA,MAAMA,IAAa;AAAA,EACjB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN,GAEMC,IAAe;AAAA,EACnB,OAAO;AAAA,EACP,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,SAAS;AACX,GAEMC,IAAiB;AAAA,EACrB,OAAO;AAAA,EACP,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AACV,GAEaC,IAA8B,CAAC;AAAA,EAC1C,WAAAC,IAAY;AAAA,EACZ,MAAAC,IAAO;AAAA,EACP,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,OAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACL,MAAM;AACJ,QAAMC,IAAgB,OAAOT,KAAS,UAChCU,IAAWD,IAAgB,KAAKd,EAAWK,CAAI,GAC/CW,IAAaV,IAAQL,EAAaK,CAAK,IAAI,IAC3CW,IAAeV,IAAUL,EAAeK,CAAO,IAAI,IAInDW,IAAU;AAAA,IACd;AAAA,IAHqBd,MAAc,eAAe,aAAa;AAAA,IAK/DW;AAAA,IACAC;AAAA,IACAC;AAAA,IARgBT,IAAO,cAAc;AAAA,IAUrCE;AAAA,EAAA,EACA,OAAO,OAAO,EAAE,KAAK,GAAG,GAEpBS,IAAqC;AAAA,IACzC,GAAGR;AAAA,IACH,GAAIG,IAAgB,EAAE,KAAK,GAAGT,CAAI,SAAS,CAAA;AAAA,EAAC;AAwB9C,SAAO,gBAAAe,EAAC,SAAI,WAAWF,GAAS,OAAOC,GAAgB,GAAGN,GAAO,WApB1C,MAAM;AAC3B,QAAI,CAACJ,EAAO,QAAOG;AAEnB,UAAMS,IAAaC,EAAM,SAAS,QAAQV,CAAQ,EAAE,OAAO,OAAO;AAClE,QAAIS,EAAW,UAAU,EAAG,QAAOT;AAEnC,UAAMW,IAA4B,CAAA;AAClC,WAAAF,EAAW,QAAQ,CAACG,GAAOC,MAAU;AACnC,MAAAF,EAAO,KAAKC,CAAK,GACbC,IAAQJ,EAAW,SAAS,KAC9BE,EAAO;AAAA,0BACJ,QAAA,EAA4B,WAAU,iBACpC,UAAAd,KADQ,SAASgB,CAAK,EAEzB;AAAA,MAAA;AAAA,IAGN,CAAC,GACMF;AAAA,EACT,GAEiE,EAAe,CAAE;AACpF;"}
1
+ {"version":3,"file":"index75.js","sources":["../src/components/Space.tsx"],"sourcesContent":["import React from 'react'\n\nexport interface SpaceProps extends React.HTMLAttributes<HTMLDivElement> {\n direction?: 'horizontal' | 'vertical'\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number\n align?: 'start' | 'end' | 'center' | 'baseline' | 'stretch'\n justify?: 'start' | 'end' | 'center' | 'between' | 'around' | 'evenly'\n wrap?: boolean\n split?: React.ReactNode\n children: React.ReactNode\n}\n\nconst gapClasses = {\n xs: 'gap-1',\n sm: 'gap-2',\n md: 'gap-4',\n lg: 'gap-6',\n xl: 'gap-8',\n} as const\n\nconst alignClasses = {\n start: 'items-start',\n end: 'items-end',\n center: 'items-center',\n baseline: 'items-baseline',\n stretch: 'items-stretch',\n} as const\n\nconst justifyClasses = {\n start: 'justify-start',\n end: 'justify-end',\n center: 'justify-center',\n between: 'justify-between',\n around: 'justify-around',\n evenly: 'justify-evenly',\n} as const\n\nexport const Space: React.FC<SpaceProps> = ({\n direction = 'horizontal',\n size = 'md',\n align,\n justify,\n wrap = false,\n split,\n className = '',\n style,\n children,\n ...rest\n}) => {\n const isNumericSize = typeof size === 'number'\n const gapClass = isNumericSize ? '' : gapClasses[size]\n const effectiveAlign = align ?? (direction === 'vertical' ? 'start' : undefined)\n const alignClass = effectiveAlign ? alignClasses[effectiveAlign] : ''\n const justifyClass = justify ? justifyClasses[justify] : ''\n const wrapClass = wrap ? 'flex-wrap' : ''\n const directionClass = direction === 'horizontal' ? 'flex-row' : 'flex-col'\n\n const classes = [\n 'flex',\n directionClass,\n gapClass,\n alignClass,\n justifyClass,\n wrapClass,\n className\n ].filter(Boolean).join(' ')\n\n const combinedStyle: React.CSSProperties = {\n ...style,\n ...(isNumericSize ? { gap: `${size}px` } : {}),\n }\n\n // If split is provided, interleave separator between children\n const renderChildren = () => {\n if (!split) return children\n\n const childArray = React.Children.toArray(children).filter(Boolean)\n if (childArray.length <= 1) return children\n\n const result: React.ReactNode[] = []\n childArray.forEach((child, index) => {\n result.push(child)\n if (index < childArray.length - 1) {\n result.push(\n <span key={`split-${index}`} className=\"flex-shrink-0\">\n {split}\n </span>\n )\n }\n })\n return result\n }\n\n return <div className={classes} style={combinedStyle} {...rest}>{renderChildren()}</div>\n}\n"],"names":["gapClasses","alignClasses","justifyClasses","Space","direction","size","align","justify","wrap","split","className","style","children","rest","isNumericSize","gapClass","effectiveAlign","alignClass","justifyClass","classes","combinedStyle","jsx","childArray","React","result","child","index"],"mappings":";;AAYA,MAAMA,IAAa;AAAA,EACjB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN,GAEMC,IAAe;AAAA,EACnB,OAAO;AAAA,EACP,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,SAAS;AACX,GAEMC,IAAiB;AAAA,EACrB,OAAO;AAAA,EACP,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AACV,GAEaC,IAA8B,CAAC;AAAA,EAC1C,WAAAC,IAAY;AAAA,EACZ,MAAAC,IAAO;AAAA,EACP,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,OAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACL,MAAM;AACJ,QAAMC,IAAgB,OAAOT,KAAS,UAChCU,IAAWD,IAAgB,KAAKd,EAAWK,CAAI,GAC/CW,IAAiBV,MAAUF,MAAc,aAAa,UAAU,SAChEa,IAAaD,IAAiBf,EAAae,CAAc,IAAI,IAC7DE,IAAeX,IAAUL,EAAeK,CAAO,IAAI,IAInDY,IAAU;AAAA,IACd;AAAA,IAHqBf,MAAc,eAAe,aAAa;AAAA,IAK/DW;AAAA,IACAE;AAAA,IACAC;AAAA,IARgBV,IAAO,cAAc;AAAA,IAUrCE;AAAA,EAAA,EACA,OAAO,OAAO,EAAE,KAAK,GAAG,GAEpBU,IAAqC;AAAA,IACzC,GAAGT;AAAA,IACH,GAAIG,IAAgB,EAAE,KAAK,GAAGT,CAAI,SAAS,CAAA;AAAA,EAAC;AAwB9C,SAAO,gBAAAgB,EAAC,SAAI,WAAWF,GAAS,OAAOC,GAAgB,GAAGP,GAAO,WApB1C,MAAM;AAC3B,QAAI,CAACJ,EAAO,QAAOG;AAEnB,UAAMU,IAAaC,EAAM,SAAS,QAAQX,CAAQ,EAAE,OAAO,OAAO;AAClE,QAAIU,EAAW,UAAU,EAAG,QAAOV;AAEnC,UAAMY,IAA4B,CAAA;AAClC,WAAAF,EAAW,QAAQ,CAACG,GAAOC,MAAU;AACnC,MAAAF,EAAO,KAAKC,CAAK,GACbC,IAAQJ,EAAW,SAAS,KAC9BE,EAAO;AAAA,0BACJ,QAAA,EAA4B,WAAU,iBACpC,UAAAf,KADQ,SAASiB,CAAK,EAEzB;AAAA,MAAA;AAAA,IAGN,CAAC,GACMF;AAAA,EACT,GAEiE,EAAe,CAAE;AACpF;"}
package/dist/index86.js CHANGED
@@ -1,164 +1,300 @@
1
- import { jsxs as c, jsx as r } from "react/jsx-runtime";
2
- import { useState as a, useRef as Y, useEffect as j } from "react";
3
- import { Input as _ } from "./index42.js";
4
- function q(t, N = "24", p = !1) {
5
- if (!t) return "";
6
- let n = t.getHours();
7
- const i = String(t.getMinutes()).padStart(2, "0"), d = String(t.getSeconds()).padStart(2, "0");
8
- if (N === "12") {
9
- const x = n >= 12 ? "PM" : "AM";
10
- return n = n % 12 || 12, p ? `${n}:${i}:${d} ${x}` : `${n}:${i} ${x}`;
1
+ import { jsxs as m, jsx as a } from "react/jsx-runtime";
2
+ import { forwardRef as fe, useState as x, useRef as Z, useId as pe, useEffect as W, useCallback as _ } from "react";
3
+ import { Input as me } from "./index42.js";
4
+ function be(s, D = "24", M = !1) {
5
+ if (!s) return "";
6
+ let o = s.getHours();
7
+ const w = String(s.getMinutes()).padStart(2, "0"), y = String(s.getSeconds()).padStart(2, "0");
8
+ if (D === "12") {
9
+ const P = o >= 12 ? "PM" : "AM";
10
+ return o = o % 12 || 12, M ? `${o}:${w}:${y} ${P}` : `${o}:${w} ${P}`;
11
11
  }
12
- const h = String(n).padStart(2, "0");
13
- return p ? `${h}:${i}:${d}` : `${h}:${i}`;
12
+ const A = String(o).padStart(2, "0");
13
+ return M ? `${A}:${w}:${y}` : `${A}:${w}`;
14
14
  }
15
- const Q = ({
16
- value: t,
17
- defaultValue: N,
18
- onChange: p,
19
- format: n = "24",
20
- placeholder: i = "Select time",
21
- disabled: d = !1,
22
- className: h = "",
23
- size: x = "md",
24
- showSeconds: $ = !1,
25
- ...E
26
- }) => {
27
- const [o, O] = a(
28
- t || N || null
29
- ), [u, C] = a(!1), [l, M] = a(o ? o.getHours() : 0), [S, v] = a(o ? o.getMinutes() : 0), [y, H] = a(o ? o.getSeconds() : 0), [P, k] = a(
30
- o && o.getHours() >= 12 ? "PM" : "AM"
31
- ), A = Y(null);
32
- j(() => {
33
- t !== void 0 && (O(t), t && (M(t.getHours()), v(t.getMinutes()), H(t.getSeconds()), k(t.getHours() >= 12 ? "PM" : "AM")));
34
- }, [t]), j(() => {
35
- function e(s) {
36
- A.current && !A.current.contains(s.target) && C(!1);
15
+ const ge = fe(({
16
+ value: s,
17
+ defaultValue: D,
18
+ onChange: M,
19
+ format: o = "24",
20
+ placeholder: w = "Select time",
21
+ disabled: y = !1,
22
+ className: A,
23
+ size: P = "md",
24
+ showSeconds: v = !1,
25
+ allowClear: ee = !0,
26
+ open: H,
27
+ onOpenChange: Y,
28
+ hourStep: E = 1,
29
+ minuteStep: T = 1,
30
+ secondStep: F = 1,
31
+ status: G,
32
+ "data-testid": te,
33
+ ...ne
34
+ }, S) => {
35
+ const [d, R] = x(
36
+ s !== void 0 ? s : D || null
37
+ ), [oe, se] = x(!1), c = H !== void 0 ? H : oe, [p, N] = x(d ? d.getHours() : 0), [$, I] = x(d ? d.getMinutes() : 0), [k, L] = x(d ? d.getSeconds() : 0), [b, j] = x(
38
+ d && d.getHours() >= 12 ? "PM" : "AM"
39
+ ), [g, B] = x("hour"), O = Z(null), ie = Z(null), K = pe(), l = te || "timepicker";
40
+ W(() => {
41
+ s !== void 0 && (R(s), s && (N(s.getHours()), I(s.getMinutes()), L(s.getSeconds()), j(s.getHours() >= 12 ? "PM" : "AM")));
42
+ }, [s]);
43
+ const h = _((e) => {
44
+ H === void 0 && se(e), Y?.(e);
45
+ }, [H, Y]);
46
+ W(() => {
47
+ function e(t) {
48
+ O.current && !O.current.contains(t.target) && h(!1);
37
49
  }
38
- if (u)
50
+ if (c)
39
51
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
40
- }, [u]);
41
- const m = (e, s, w) => {
42
- const g = /* @__PURE__ */ new Date(), b = new Date(
43
- g.getFullYear(),
44
- g.getMonth(),
45
- g.getDate(),
52
+ }, [c, h]), W(() => {
53
+ if (!c) return;
54
+ const e = (t) => {
55
+ if (t.key === "Escape") {
56
+ h(!1);
57
+ return;
58
+ }
59
+ if (t.key !== "Tab") {
60
+ if (t.key === "ArrowUp" || t.key === "ArrowDown") {
61
+ t.preventDefault();
62
+ const i = t.key === "ArrowUp" ? -1 : 1;
63
+ if (g === "hour") {
64
+ const n = o === "12" ? 12 : 23, u = o === "12" ? 1 : 0;
65
+ let r = p + i * E;
66
+ r > n && (r = u), r < u && (r = n), J(r);
67
+ } else if (g === "minute") {
68
+ let n = $ + i * T;
69
+ n > 59 && (n = 0), n < 0 && (n = 59), Q(n);
70
+ } else if (g === "second") {
71
+ let n = k + i * F;
72
+ n > 59 && (n = 0), n < 0 && (n = 59), V(n);
73
+ } else g === "period" && U(b === "AM" ? "PM" : "AM");
74
+ }
75
+ if (t.key === "ArrowLeft" || t.key === "ArrowRight") {
76
+ t.preventDefault();
77
+ const i = ["hour", "minute"];
78
+ v && i.push("second"), o === "12" && i.push("period");
79
+ const n = i.indexOf(g), u = t.key === "ArrowLeft" ? -1 : 1;
80
+ let r = n + u;
81
+ r < 0 && (r = i.length - 1), r >= i.length && (r = 0), B(i[r]);
82
+ }
83
+ t.key === "Enter" && h(!1);
84
+ }
85
+ };
86
+ return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
87
+ }, [c, g, p, $, k, b, o, v, E, T, F, h]);
88
+ const re = _((e) => {
89
+ e.stopPropagation(), R(null), N(0), I(0), L(0), j("AM"), M?.(null);
90
+ }, [M]), C = (e, t, i) => {
91
+ const n = /* @__PURE__ */ new Date(), u = new Date(
92
+ n.getFullYear(),
93
+ n.getMonth(),
94
+ n.getDate(),
46
95
  e,
47
- s,
48
- w
96
+ t,
97
+ i
49
98
  );
50
- O(b), p?.(b);
51
- }, I = (e) => {
52
- let s = e;
53
- n === "12" && (s = P === "PM" ? e % 12 + 12 : e % 12), M(s), m(s, S, y);
54
- }, L = (e) => {
55
- v(e), m(l, e, y);
56
- }, R = (e) => {
57
- H(e), m(l, S, e);
58
- }, D = (e) => {
59
- k(e);
60
- const s = e === "PM" ? l % 12 + 12 : l % 12;
61
- M(s), m(s, S, y);
62
- }, T = (e, s, w, g, b = 0) => {
63
- const F = Array.from({ length: s - b + 1 }, (f, K) => b + K);
64
- return /* @__PURE__ */ c("div", { className: "flex flex-col", children: [
65
- /* @__PURE__ */ r("div", { className: "text-xs font-semibold text-center text-base-content/60 py-2", children: e }),
66
- /* @__PURE__ */ r("div", { className: "flex-1 overflow-y-auto max-h-48", children: F.map((f) => /* @__PURE__ */ r(
67
- "button",
68
- {
69
- type: "button",
70
- onClick: () => g(f),
71
- className: `
72
- w-full px-4 py-2 text-center hover:bg-base-200 transition-colors
73
- ${w === f ? "bg-primary text-primary-content" : ""}
74
- `,
75
- children: String(f).padStart(2, "0")
76
- },
77
- f
78
- )) })
79
- ] });
80
- }, z = n === "12" ? l % 12 || 12 : l;
81
- return /* @__PURE__ */ c("div", { ref: A, className: `relative ${h}`, "data-state": u ? "open" : "closed", ...E, children: [
82
- /* @__PURE__ */ r(
83
- _,
99
+ R(u), M?.(u);
100
+ }, J = (e) => {
101
+ let t = e;
102
+ o === "12" && (t = b === "PM" ? e % 12 + 12 : e % 12), N(t), C(t, $, k);
103
+ }, Q = (e) => {
104
+ I(e), C(p, e, k);
105
+ }, V = (e) => {
106
+ L(e), C(p, $, e);
107
+ }, U = (e) => {
108
+ j(e);
109
+ const t = e === "PM" ? p % 12 + 12 : p % 12;
110
+ N(t), C(t, $, k);
111
+ }, q = (e, t, i, n, u, r = 1, de = 0) => {
112
+ const X = [];
113
+ for (let f = de; f <= i; f += r)
114
+ X.push(f);
115
+ const ce = `${K}-${e}-listbox`, ue = g === e;
116
+ return /* @__PURE__ */ m(
117
+ "div",
84
118
  {
85
- value: q(o, n, $),
86
- placeholder: i,
87
- disabled: d,
88
- size: x,
89
- readOnly: !0,
90
- onClick: () => !d && C(!u),
91
- className: "cursor-pointer"
92
- }
93
- ),
94
- u && /* @__PURE__ */ c("div", { className: "absolute top-full left-0 mt-2 bg-base-100 border border-base-300 rounded-lg shadow-lg z-50", children: [
95
- /* @__PURE__ */ c("div", { className: "flex divide-x divide-base-300", children: [
96
- T(
97
- "Hour",
98
- n === "12" ? 12 : 23,
99
- z,
100
- I,
101
- n === "12" ? 1 : 0
102
- ),
103
- T("Min", 59, S, L),
104
- $ && T("Sec", 59, y, R),
105
- n === "12" && /* @__PURE__ */ c("div", { className: "flex flex-col", children: [
106
- /* @__PURE__ */ r("div", { className: "text-xs font-semibold text-center text-base-content/60 py-2", children: "Period" }),
107
- /* @__PURE__ */ c("div", { className: "flex-1 flex flex-col p-2 gap-2", children: [
108
- /* @__PURE__ */ r(
109
- "button",
110
- {
111
- type: "button",
112
- onClick: () => D("AM"),
113
- className: `
114
- btn btn-sm
115
- ${P === "AM" ? "btn-primary" : "btn-ghost"}
116
- `,
117
- children: "AM"
118
- }
119
- ),
120
- /* @__PURE__ */ r(
119
+ className: "flex flex-col w-16",
120
+ role: "listbox",
121
+ "aria-label": `Select ${t.toLowerCase()}`,
122
+ id: ce,
123
+ "data-testid": `${l}-${e}-column`,
124
+ tabIndex: 0,
125
+ onFocus: () => B(e),
126
+ children: [
127
+ /* @__PURE__ */ a("div", { className: "text-xs font-semibold text-center text-base-content/60 py-2", "aria-hidden": "true", children: t }),
128
+ /* @__PURE__ */ a("div", { className: "overflow-y-auto max-h-48", children: X.map((f) => {
129
+ const z = n === f;
130
+ return /* @__PURE__ */ a(
121
131
  "button",
122
132
  {
123
133
  type: "button",
124
- onClick: () => D("PM"),
125
- className: `
126
- btn btn-sm
127
- ${P === "PM" ? "btn-primary" : "btn-ghost"}
128
- `,
129
- children: "PM"
130
- }
131
- )
132
- ] })
133
- ] })
134
- ] }),
135
- /* @__PURE__ */ c("div", { className: "flex justify-end gap-2 p-3 border-t border-base-300", children: [
136
- /* @__PURE__ */ r(
137
- "button",
138
- {
139
- type: "button",
140
- onClick: () => {
141
- const e = /* @__PURE__ */ new Date();
142
- M(e.getHours()), v(e.getMinutes()), H(e.getSeconds()), k(e.getHours() >= 12 ? "PM" : "AM"), m(e.getHours(), e.getMinutes(), e.getSeconds());
143
- },
144
- className: "btn btn-ghost btn-sm",
145
- children: "Now"
146
- }
147
- ),
148
- /* @__PURE__ */ r(
149
- "button",
134
+ role: "option",
135
+ "aria-selected": z,
136
+ onClick: () => u(f),
137
+ "data-testid": `${l}-${e}-${f}`,
138
+ className: [
139
+ "w-full px-4 py-2 text-center hover:bg-base-200 transition-colors",
140
+ z ? "bg-primary text-primary-content" : "",
141
+ ue && z ? "ring-2 ring-primary ring-offset-1" : ""
142
+ ].filter(Boolean).join(" "),
143
+ children: String(f).padStart(2, "0")
144
+ },
145
+ f
146
+ );
147
+ }) })
148
+ ]
149
+ }
150
+ );
151
+ }, ae = o === "12" ? p % 12 || 12 : p, le = {
152
+ error: "input-error",
153
+ warning: "input-warning"
154
+ };
155
+ return /* @__PURE__ */ m(
156
+ "div",
157
+ {
158
+ ref: (e) => {
159
+ O.current = e, typeof S == "function" ? S(e) : S && (S.current = e);
160
+ },
161
+ className: ["relative", A].filter(Boolean).join(" "),
162
+ "data-testid": l,
163
+ "data-state": c ? "open" : "closed",
164
+ ...ne,
165
+ children: [
166
+ /* @__PURE__ */ m("div", { className: "relative", children: [
167
+ /* @__PURE__ */ a(
168
+ me,
169
+ {
170
+ value: be(d, o, v),
171
+ placeholder: w,
172
+ disabled: y,
173
+ size: P,
174
+ readOnly: !0,
175
+ onClick: () => !y && h(!c),
176
+ className: ["cursor-pointer pr-8", G ? le[G] : ""].filter(Boolean).join(" "),
177
+ "aria-haspopup": "listbox",
178
+ "aria-expanded": c,
179
+ "aria-controls": c ? `${K}-dropdown` : void 0,
180
+ "data-testid": `${l}-input`
181
+ }
182
+ ),
183
+ ee && d && !y && /* @__PURE__ */ a(
184
+ "button",
185
+ {
186
+ type: "button",
187
+ onClick: re,
188
+ className: "absolute right-2 top-1/2 -translate-y-1/2 btn btn-ghost btn-xs btn-circle",
189
+ "aria-label": "Clear time",
190
+ "data-testid": `${l}-clear`,
191
+ children: /* @__PURE__ */ a("svg", { className: "w-3 h-3", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ a("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
192
+ }
193
+ )
194
+ ] }),
195
+ c && /* @__PURE__ */ m(
196
+ "div",
150
197
  {
151
- type: "button",
152
- onClick: () => C(!1),
153
- className: "btn btn-primary btn-sm",
154
- children: "OK"
198
+ ref: ie,
199
+ id: `${K}-dropdown`,
200
+ className: "absolute top-full left-0 mt-2 bg-base-100 border border-base-300 rounded-lg shadow-xl z-[9999] w-fit",
201
+ role: "dialog",
202
+ "aria-label": "Time picker",
203
+ "data-testid": `${l}-dropdown`,
204
+ children: [
205
+ /* @__PURE__ */ m("div", { className: "flex divide-x divide-base-300", children: [
206
+ q(
207
+ "hour",
208
+ "Hour",
209
+ o === "12" ? 12 : 23,
210
+ ae,
211
+ J,
212
+ E,
213
+ o === "12" ? 1 : 0
214
+ ),
215
+ q("minute", "Min", 59, $, Q, T),
216
+ v && q("second", "Sec", 59, k, V, F),
217
+ o === "12" && /* @__PURE__ */ m(
218
+ "div",
219
+ {
220
+ className: "flex flex-col w-16",
221
+ role: "listbox",
222
+ "aria-label": "Select period",
223
+ "data-testid": `${l}-period-column`,
224
+ tabIndex: 0,
225
+ onFocus: () => B("period"),
226
+ children: [
227
+ /* @__PURE__ */ a("div", { className: "text-xs font-semibold text-center text-base-content/60 py-2", "aria-hidden": "true", children: "Period" }),
228
+ /* @__PURE__ */ m("div", { className: "flex flex-col p-2 gap-2", children: [
229
+ /* @__PURE__ */ a(
230
+ "button",
231
+ {
232
+ type: "button",
233
+ role: "option",
234
+ "aria-selected": b === "AM",
235
+ onClick: () => U("AM"),
236
+ "data-testid": `${l}-period-am`,
237
+ className: [
238
+ "btn btn-sm",
239
+ b === "AM" ? "btn-primary" : "btn-ghost"
240
+ ].join(" "),
241
+ children: "AM"
242
+ }
243
+ ),
244
+ /* @__PURE__ */ a(
245
+ "button",
246
+ {
247
+ type: "button",
248
+ role: "option",
249
+ "aria-selected": b === "PM",
250
+ onClick: () => U("PM"),
251
+ "data-testid": `${l}-period-pm`,
252
+ className: [
253
+ "btn btn-sm",
254
+ b === "PM" ? "btn-primary" : "btn-ghost"
255
+ ].join(" "),
256
+ children: "PM"
257
+ }
258
+ )
259
+ ] })
260
+ ]
261
+ }
262
+ )
263
+ ] }),
264
+ /* @__PURE__ */ m("div", { className: "flex justify-end gap-2 p-3 border-t border-base-300", children: [
265
+ /* @__PURE__ */ a(
266
+ "button",
267
+ {
268
+ type: "button",
269
+ onClick: () => {
270
+ const e = /* @__PURE__ */ new Date();
271
+ N(e.getHours()), I(e.getMinutes()), L(e.getSeconds()), j(e.getHours() >= 12 ? "PM" : "AM"), C(e.getHours(), e.getMinutes(), e.getSeconds());
272
+ },
273
+ className: "btn btn-ghost btn-sm",
274
+ "data-testid": `${l}-now`,
275
+ children: "Now"
276
+ }
277
+ ),
278
+ /* @__PURE__ */ a(
279
+ "button",
280
+ {
281
+ type: "button",
282
+ onClick: () => h(!1),
283
+ className: "btn btn-primary btn-sm",
284
+ "data-testid": `${l}-ok`,
285
+ children: "OK"
286
+ }
287
+ )
288
+ ] })
289
+ ]
155
290
  }
156
291
  )
157
- ] })
158
- ] })
159
- ] });
160
- };
292
+ ]
293
+ }
294
+ );
295
+ });
296
+ ge.displayName = "TimePicker";
161
297
  export {
162
- Q as TimePicker
298
+ ge as TimePicker
163
299
  };
164
300
  //# sourceMappingURL=index86.js.map