asterui 0.12.62 → 0.12.63

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.
Files changed (106) hide show
  1. package/dist/components/Anchor.d.ts +2 -0
  2. package/dist/components/Anchor.js +79 -75
  3. package/dist/components/Anchor.js.map +1 -1
  4. package/dist/components/Autocomplete.d.ts +1 -0
  5. package/dist/components/Autocomplete.js +115 -110
  6. package/dist/components/Autocomplete.js.map +1 -1
  7. package/dist/components/Breadcrumb.d.ts +4 -2
  8. package/dist/components/Breadcrumb.js +54 -29
  9. package/dist/components/Breadcrumb.js.map +1 -1
  10. package/dist/components/Button.d.ts +5 -1
  11. package/dist/components/Button.js +117 -107
  12. package/dist/components/Button.js.map +1 -1
  13. package/dist/components/Chart.d.ts +1 -0
  14. package/dist/components/Chart.js +31 -30
  15. package/dist/components/Chart.js.map +1 -1
  16. package/dist/components/Chat.d.ts +1 -0
  17. package/dist/components/Chat.js +32 -30
  18. package/dist/components/Chat.js.map +1 -1
  19. package/dist/components/Command.d.ts +5 -2
  20. package/dist/components/Command.js +262 -233
  21. package/dist/components/Command.js.map +1 -1
  22. package/dist/components/ContextMenu.d.ts +4 -0
  23. package/dist/components/ContextMenu.js +149 -130
  24. package/dist/components/ContextMenu.js.map +1 -1
  25. package/dist/components/Dock.d.ts +2 -0
  26. package/dist/components/Dock.js +70 -46
  27. package/dist/components/Dock.js.map +1 -1
  28. package/dist/components/FileInput.d.ts +1 -0
  29. package/dist/components/FileInput.js +26 -26
  30. package/dist/components/FileInput.js.map +1 -1
  31. package/dist/components/Filter.d.ts +1 -0
  32. package/dist/components/Filter.js +43 -40
  33. package/dist/components/Filter.js.map +1 -1
  34. package/dist/components/Flex.d.ts +1 -0
  35. package/dist/components/Flex.js +43 -42
  36. package/dist/components/Flex.js.map +1 -1
  37. package/dist/components/FloatButton.d.ts +3 -0
  38. package/dist/components/FloatButton.js +178 -127
  39. package/dist/components/FloatButton.js.map +1 -1
  40. package/dist/components/Input.d.ts +1 -0
  41. package/dist/components/Input.js +201 -184
  42. package/dist/components/Input.js.map +1 -1
  43. package/dist/components/Loading.d.ts +1 -0
  44. package/dist/components/Loading.js +40 -37
  45. package/dist/components/Loading.js.map +1 -1
  46. package/dist/components/Masonry.d.ts +1 -0
  47. package/dist/components/Masonry.js +45 -42
  48. package/dist/components/Masonry.js.map +1 -1
  49. package/dist/components/Mention.d.ts +1 -0
  50. package/dist/components/Mention.js +95 -91
  51. package/dist/components/Mention.js.map +1 -1
  52. package/dist/components/MonthCalendar.d.ts +1 -0
  53. package/dist/components/MonthCalendar.js +104 -97
  54. package/dist/components/MonthCalendar.js.map +1 -1
  55. package/dist/components/QRCode.d.ts +1 -0
  56. package/dist/components/QRCode.js +84 -55
  57. package/dist/components/QRCode.js.map +1 -1
  58. package/dist/components/RadialProgress.d.ts +1 -0
  59. package/dist/components/RadialProgress.js +19 -17
  60. package/dist/components/RadialProgress.js.map +1 -1
  61. package/dist/components/Range.d.ts +1 -0
  62. package/dist/components/Range.js +45 -43
  63. package/dist/components/Range.js.map +1 -1
  64. package/dist/components/Rating.d.ts +4 -2
  65. package/dist/components/Rating.js +83 -79
  66. package/dist/components/Rating.js.map +1 -1
  67. package/dist/components/Responsive.d.ts +4 -2
  68. package/dist/components/Responsive.js +10 -9
  69. package/dist/components/Responsive.js.map +1 -1
  70. package/dist/components/Result.d.ts +1 -0
  71. package/dist/components/Result.js +24 -22
  72. package/dist/components/Result.js.map +1 -1
  73. package/dist/components/Select.d.ts +1 -0
  74. package/dist/components/Select.js +72 -62
  75. package/dist/components/Select.js.map +1 -1
  76. package/dist/components/Splitter.d.ts +2 -0
  77. package/dist/components/Splitter.js +137 -131
  78. package/dist/components/Splitter.js.map +1 -1
  79. package/dist/components/Stat.d.ts +4 -2
  80. package/dist/components/Stat.js +19 -18
  81. package/dist/components/Stat.js.map +1 -1
  82. package/dist/components/Steps.d.ts +4 -2
  83. package/dist/components/Steps.js +56 -52
  84. package/dist/components/Steps.js.map +1 -1
  85. package/dist/components/TextRotate.d.ts +1 -0
  86. package/dist/components/TextRotate.js +14 -12
  87. package/dist/components/TextRotate.js.map +1 -1
  88. package/dist/components/Textarea.d.ts +1 -0
  89. package/dist/components/Textarea.js +31 -30
  90. package/dist/components/Textarea.js.map +1 -1
  91. package/dist/components/ThemeController.d.ts +6 -3
  92. package/dist/components/ThemeController.js +101 -92
  93. package/dist/components/ThemeController.js.map +1 -1
  94. package/dist/components/Typography.d.ts +10 -5
  95. package/dist/components/Typography.js +84 -81
  96. package/dist/components/Typography.js.map +1 -1
  97. package/dist/components/VirtualList.d.ts +2 -1
  98. package/dist/components/VirtualList.js +40 -36
  99. package/dist/components/VirtualList.js.map +1 -1
  100. package/dist/components/Watermark.d.ts +1 -0
  101. package/dist/components/Watermark.js +74 -71
  102. package/dist/components/Watermark.js.map +1 -1
  103. package/dist/components/WeekCalendar.d.ts +1 -0
  104. package/dist/components/WeekCalendar.js +91 -76
  105. package/dist/components/WeekCalendar.js.map +1 -1
  106. package/package.json +1 -1
@@ -39,6 +39,7 @@ export interface AnchorProps {
39
39
  className?: string;
40
40
  /** Anchor.Link children */
41
41
  children?: React.ReactNode;
42
+ 'data-testid'?: string;
42
43
  }
43
44
  export interface AnchorLinkProps {
44
45
  /** Target element id (without #) */
@@ -49,6 +50,7 @@ export interface AnchorLinkProps {
49
50
  children?: React.ReactNode;
50
51
  /** Custom class name */
51
52
  className?: string;
53
+ 'data-testid'?: string;
52
54
  }
53
55
  export declare const Anchor: React.FC<AnchorProps> & {
54
56
  Link: React.FC<AnchorLinkProps>;
@@ -1,116 +1,120 @@
1
- import { jsx as a, jsxs as W } from "react/jsx-runtime";
2
- import { useState as R, useRef as V, useCallback as y, useEffect as $, createContext as X, useContext as Z } from "react";
3
- const C = X(null), _ = () => {
4
- const o = Z(C);
1
+ import { jsx as l, jsxs as Z } from "react/jsx-runtime";
2
+ import { useState as C, useRef as D, useCallback as $, useEffect as T, createContext as _, useContext as O } from "react";
3
+ const H = _(null), tt = () => {
4
+ const o = O(H);
5
5
  if (!o)
6
6
  throw new Error("Anchor.Link must be used within an Anchor");
7
7
  return o;
8
- }, Y = ({
8
+ }, q = ({
9
9
  href: o,
10
10
  title: h,
11
11
  children: c,
12
- className: f = ""
12
+ className: x = "",
13
+ "data-testid": i
13
14
  }) => {
14
- const { activeLink: r, direction: k, registerLink: l, unregisterLink: w, handleClick: x } = _();
15
- $(() => (l(o), () => w(o)), [o, l, w]);
16
- const v = r === o, d = k === "vertical";
17
- return /* @__PURE__ */ W("div", { className: d ? "" : "inline-block", children: [
18
- /* @__PURE__ */ a(
15
+ const { activeLink: b, direction: d, registerLink: w, unregisterLink: v, handleClick: m } = tt();
16
+ T(() => (w(o), () => v(o)), [o, w, v]);
17
+ const p = b === o, a = d === "vertical";
18
+ return /* @__PURE__ */ Z("div", { className: a ? "" : "inline-block", children: [
19
+ /* @__PURE__ */ l(
19
20
  "a",
20
21
  {
21
22
  href: `#${o}`,
22
- onClick: (b) => x(b, o, h),
23
+ onClick: (y) => m(y, o, h),
23
24
  className: `
24
25
  block text-sm transition-colors
25
- ${d ? "py-1 pl-3 border-l-2" : "px-3 py-1 border-b-2"}
26
- ${v ? "text-primary border-primary font-medium" : "text-base-content/70 border-transparent hover:text-base-content hover:border-base-content/30"}
27
- ${f}
26
+ ${a ? "py-1 pl-3 border-l-2" : "px-3 py-1 border-b-2"}
27
+ ${p ? "text-primary border-primary font-medium" : "text-base-content/70 border-transparent hover:text-base-content hover:border-base-content/30"}
28
+ ${x}
28
29
  `.trim(),
30
+ "data-testid": i,
29
31
  children: h
30
32
  }
31
33
  ),
32
- c && /* @__PURE__ */ a("div", { className: d ? "pl-3" : "inline-flex", children: c })
34
+ c && /* @__PURE__ */ l("div", { className: a ? "pl-3" : "inline-flex", children: c })
33
35
  ] });
34
- }, O = ({
36
+ }, et = ({
35
37
  items: o,
36
38
  direction: h = "vertical",
37
39
  offsetTop: c = 0,
38
- bounds: f = 5,
39
- getContainer: r,
40
- getCurrentAnchor: k,
41
- onChange: l,
40
+ bounds: x = 5,
41
+ getContainer: i,
42
+ getCurrentAnchor: b,
43
+ onChange: d,
42
44
  onClick: w,
43
- activeLink: x,
44
- affix: v = !1,
45
- affixOffsetTop: d = 0,
46
- replace: b = !1,
47
- className: D = "",
48
- children: q
45
+ activeLink: v,
46
+ affix: m = !1,
47
+ affixOffsetTop: p = 0,
48
+ replace: a = !1,
49
+ className: y = "",
50
+ children: F,
51
+ "data-testid": B
49
52
  }) => {
50
- const [F, H] = R(""), [i, N] = R([]), [m, G] = R(!1), p = V(null), B = V(null), g = x !== void 0, L = g ? x : F, J = k ? k(L) : L, K = y((n) => {
51
- N((t) => t.includes(n) ? t : [...t, n]);
52
- }, []), M = y((n) => {
53
- N((t) => t.filter((e) => e !== n));
54
- }, []), T = y((n) => {
55
- const t = document.getElementById(n);
56
- if (t) {
57
- const e = r?.() ?? window, s = t.getBoundingClientRect().top, u = e === window ? 0 : e.getBoundingClientRect().top, E = e === window ? window.scrollY : e.scrollTop, A = s - u + E - c;
58
- e === window ? window.scrollTo({ top: A, behavior: "smooth" }) : e.scrollTo({ top: A, behavior: "smooth" }), b ? window.history.replaceState(null, "", `#${n}`) : window.history.pushState(null, "", `#${n}`);
53
+ const [G, N] = C(""), [r, S] = C([]), [g, J] = C(!1), f = D(null), E = D(null), k = v !== void 0, L = k ? v : G, K = b ? b(L) : L, M = $((t) => {
54
+ S((e) => e.includes(t) ? e : [...e, t]);
55
+ }, []), Q = $((t) => {
56
+ S((e) => e.filter((n) => n !== t));
57
+ }, []), I = $((t) => {
58
+ const e = document.getElementById(t);
59
+ if (e) {
60
+ const n = i?.() ?? window, s = e.getBoundingClientRect().top, u = n === window ? 0 : n.getBoundingClientRect().top, R = n === window ? window.scrollY : n.scrollTop, A = s - u + R - c;
61
+ n === window ? window.scrollTo({ top: A, behavior: "smooth" }) : n.scrollTo({ top: A, behavior: "smooth" }), a ? window.history.replaceState(null, "", `#${t}`) : window.history.pushState(null, "", `#${t}`);
59
62
  }
60
- }, [r, c, b]), Q = y((n, t, e) => {
61
- n.preventDefault(), w?.(n, { href: t, title: e }), T(t), g || H(t), l?.(t);
62
- }, [w, T, g, l]);
63
- $(() => {
64
- if (!v || !p.current) return;
65
- const n = r?.() ?? window, t = () => {
66
- if (!p.current || !B.current) return;
67
- const e = B.current.getBoundingClientRect(), s = n === window ? 0 : n.getBoundingClientRect().top, u = e.top - s <= d;
68
- u !== m && G(u);
63
+ }, [i, c, a]), U = $((t, e, n) => {
64
+ t.preventDefault(), w?.(t, { href: e, title: n }), I(e), k || N(e), d?.(e);
65
+ }, [w, I, k, d]);
66
+ T(() => {
67
+ if (!m || !f.current) return;
68
+ const t = i?.() ?? window, e = () => {
69
+ if (!f.current || !E.current) return;
70
+ const n = E.current.getBoundingClientRect(), s = t === window ? 0 : t.getBoundingClientRect().top, u = n.top - s <= p;
71
+ u !== g && J(u);
69
72
  };
70
- return n.addEventListener("scroll", t, { passive: !0 }), t(), () => n.removeEventListener("scroll", t);
71
- }, [v, d, r, m]), $(() => {
72
- if (i.length === 0) return;
73
- const n = r?.() ?? window, t = () => {
74
- let e = "";
75
- const s = n === window ? document.documentElement : n, u = n === window ? 0 : s.getBoundingClientRect().top, E = n === window ? window.scrollY : s.scrollTop, A = s.scrollHeight, U = n === window ? window.innerHeight : s.clientHeight;
76
- if (E + U >= A - 10 && i.length > 0)
77
- e = i[i.length - 1];
73
+ return t.addEventListener("scroll", e, { passive: !0 }), e(), () => t.removeEventListener("scroll", e);
74
+ }, [m, p, i, g]), T(() => {
75
+ if (r.length === 0) return;
76
+ const t = i?.() ?? window, e = () => {
77
+ let n = "";
78
+ const s = t === window ? document.documentElement : t, u = t === window ? 0 : s.getBoundingClientRect().top, R = t === window ? window.scrollY : s.scrollTop, A = s.scrollHeight, X = t === window ? window.innerHeight : s.clientHeight;
79
+ if (R + X >= A - 10 && r.length > 0)
80
+ n = r[r.length - 1];
78
81
  else {
79
- for (const z of i) {
80
- const P = document.getElementById(z);
81
- P && P.getBoundingClientRect().top - u - c <= f && (e = z);
82
+ for (const V of r) {
83
+ const Y = document.getElementById(V);
84
+ Y && Y.getBoundingClientRect().top - u - c <= x && (n = V);
82
85
  }
83
- !e && i.length > 0 && (e = i[0]);
86
+ !n && r.length > 0 && (n = r[0]);
84
87
  }
85
- e && e !== L && (g || H(e), l?.(e));
88
+ n && n !== L && (k || N(n), d?.(n));
86
89
  };
87
- return n.addEventListener("scroll", t, { passive: !0 }), t(), () => n.removeEventListener("scroll", t);
88
- }, [i, r, c, f, L, g, l]);
89
- const I = {
90
- activeLink: J,
90
+ return t.addEventListener("scroll", e, { passive: !0 }), e(), () => t.removeEventListener("scroll", e);
91
+ }, [r, i, c, x, L, k, d]);
92
+ const j = {
93
+ activeLink: K,
91
94
  direction: h,
92
95
  offsetTop: c,
93
- registerLink: K,
94
- unregisterLink: M,
95
- handleClick: Q
96
- }, S = (n) => n.map((t) => /* @__PURE__ */ a(Y, { href: t.href, title: t.title, children: t.children && S(t.children) }, t.href)), j = /* @__PURE__ */ a(
96
+ registerLink: M,
97
+ unregisterLink: Q,
98
+ handleClick: U
99
+ }, W = (t) => B ? `${B}-${t}` : void 0, z = (t) => t.map((e) => /* @__PURE__ */ l(q, { href: e.href, title: e.title, "data-testid": W(`link-${e.href}`), children: e.children && z(e.children) }, e.href)), P = /* @__PURE__ */ l(
97
100
  "nav",
98
101
  {
99
- ref: p,
102
+ ref: f,
100
103
  className: `
101
104
  ${h === "horizontal" ? "flex items-center" : "flex flex-col"}
102
- ${m ? "fixed bg-base-100 shadow-sm z-10" : ""}
103
- ${D}
105
+ ${g ? "fixed bg-base-100 shadow-sm z-10" : ""}
106
+ ${y}
104
107
  `.trim(),
105
- style: m ? { top: d } : void 0,
106
- children: o ? S(o) : q
108
+ style: g ? { top: p } : void 0,
109
+ "data-testid": B,
110
+ children: o ? z(o) : F
107
111
  }
108
112
  );
109
- return v ? /* @__PURE__ */ a(C.Provider, { value: I, children: /* @__PURE__ */ a("div", { ref: B, style: m && p.current ? { height: p.current.offsetHeight } : void 0, children: j }) }) : /* @__PURE__ */ a(C.Provider, { value: I, children: j });
110
- }, rt = Object.assign(O, {
111
- Link: Y
113
+ return m ? /* @__PURE__ */ l(H.Provider, { value: j, children: /* @__PURE__ */ l("div", { ref: E, style: g && f.current ? { height: f.current.offsetHeight } : void 0, children: P }) }) : /* @__PURE__ */ l(H.Provider, { value: j, children: P });
114
+ }, st = Object.assign(et, {
115
+ Link: q
112
116
  });
113
117
  export {
114
- rt as Anchor
118
+ st as Anchor
115
119
  };
116
120
  //# sourceMappingURL=Anchor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Anchor.js","sources":["../../src/components/Anchor.tsx"],"sourcesContent":["import React, { useState, useEffect, useCallback, createContext, useContext, useRef } from 'react'\n\nexport interface AnchorLinkItem {\n /** Target element id (without #) */\n href: string\n /** Link title */\n title: React.ReactNode\n /** Nested links */\n children?: AnchorLinkItem[]\n}\n\nexport interface AnchorProps {\n /** Anchor links (alternative to Anchor.Link children) */\n items?: AnchorLinkItem[]\n /** Layout direction */\n direction?: 'horizontal' | 'vertical'\n /** Offset from top when calculating scroll position */\n offsetTop?: number\n /** Bounding distance of anchor area */\n bounds?: number\n /** Target scroll container (default: window) */\n getContainer?: () => HTMLElement | Window\n /** Customize the anchor highlight */\n getCurrentAnchor?: (activeLink: string) => string\n /** Callback when active link changes */\n onChange?: (activeLink: string) => void\n /** Callback when link is clicked */\n onClick?: (e: React.MouseEvent, link: { href: string; title: React.ReactNode }) => void\n /** Currently active link (controlled) */\n activeLink?: string\n /** Whether to fix the anchor when scrolling */\n affix?: boolean\n /** Pixels to offset from top when affix is true */\n affixOffsetTop?: number\n /** Replace history instead of push */\n replace?: boolean\n /** Custom class name */\n className?: string\n /** Anchor.Link children */\n children?: React.ReactNode\n}\n\nexport interface AnchorLinkProps {\n /** Target element id (without #) */\n href: string\n /** Link title */\n title: React.ReactNode\n /** Nested links */\n children?: React.ReactNode\n /** Custom class name */\n className?: string\n}\n\ninterface AnchorContextValue {\n activeLink: string\n direction: 'horizontal' | 'vertical'\n offsetTop: number\n registerLink: (href: string) => void\n unregisterLink: (href: string) => void\n handleClick: (e: React.MouseEvent, href: string, title: React.ReactNode) => void\n}\n\nconst AnchorContext = createContext<AnchorContextValue | null>(null)\n\nconst useAnchorContext = () => {\n const context = useContext(AnchorContext)\n if (!context) {\n throw new Error('Anchor.Link must be used within an Anchor')\n }\n return context\n}\n\nconst AnchorLink: React.FC<AnchorLinkProps> = ({\n href,\n title,\n children,\n className = '',\n}) => {\n const { activeLink, direction, registerLink, unregisterLink, handleClick } = useAnchorContext()\n\n useEffect(() => {\n registerLink(href)\n return () => unregisterLink(href)\n }, [href, registerLink, unregisterLink])\n\n const isActive = activeLink === href\n const isVertical = direction === 'vertical'\n\n return (\n <div className={isVertical ? '' : 'inline-block'}>\n <a\n href={`#${href}`}\n onClick={(e) => handleClick(e, href, title)}\n className={`\n block text-sm transition-colors\n ${isVertical ? 'py-1 pl-3 border-l-2' : 'px-3 py-1 border-b-2'}\n ${isActive\n ? 'text-primary border-primary font-medium'\n : 'text-base-content/70 border-transparent hover:text-base-content hover:border-base-content/30'\n }\n ${className}\n `.trim()}\n >\n {title}\n </a>\n {children && (\n <div className={isVertical ? 'pl-3' : 'inline-flex'}>\n {children}\n </div>\n )}\n </div>\n )\n}\n\nconst AnchorComponent: React.FC<AnchorProps> = ({\n items,\n direction = 'vertical',\n offsetTop = 0,\n bounds = 5,\n getContainer,\n getCurrentAnchor,\n onChange,\n onClick,\n activeLink: controlledActiveLink,\n affix = false,\n affixOffsetTop = 0,\n replace = false,\n className = '',\n children,\n}) => {\n const [internalActiveLink, setInternalActiveLink] = useState('')\n const [links, setLinks] = useState<string[]>([])\n const [isAffixed, setIsAffixed] = useState(false)\n const anchorRef = useRef<HTMLDivElement>(null)\n const placeholderRef = useRef<HTMLDivElement>(null)\n\n const isControlled = controlledActiveLink !== undefined\n const rawActiveLink = isControlled ? controlledActiveLink : internalActiveLink\n const activeLink = getCurrentAnchor ? getCurrentAnchor(rawActiveLink) : rawActiveLink\n\n const registerLink = useCallback((href: string) => {\n setLinks((prev) => (prev.includes(href) ? prev : [...prev, href]))\n }, [])\n\n const unregisterLink = useCallback((href: string) => {\n setLinks((prev) => prev.filter((link) => link !== href))\n }, [])\n\n const scrollToTarget = useCallback((href: string) => {\n const target = document.getElementById(href)\n if (target) {\n const container = getContainer?.() ?? window\n const targetTop = target.getBoundingClientRect().top\n const containerTop = container === window\n ? 0\n : (container as HTMLElement).getBoundingClientRect().top\n const scrollTop = container === window\n ? window.scrollY\n : (container as HTMLElement).scrollTop\n\n const top = targetTop - containerTop + scrollTop - offsetTop\n\n if (container === window) {\n window.scrollTo({ top, behavior: 'smooth' })\n } else {\n (container as HTMLElement).scrollTo({ top, behavior: 'smooth' })\n }\n\n // Update URL hash\n if (replace) {\n window.history.replaceState(null, '', `#${href}`)\n } else {\n window.history.pushState(null, '', `#${href}`)\n }\n }\n }, [getContainer, offsetTop, replace])\n\n const handleClick = useCallback((\n e: React.MouseEvent,\n href: string,\n title: React.ReactNode\n ) => {\n e.preventDefault()\n onClick?.(e, { href, title })\n scrollToTarget(href)\n\n if (!isControlled) {\n setInternalActiveLink(href)\n }\n onChange?.(href)\n }, [onClick, scrollToTarget, isControlled, onChange])\n\n // Affix logic\n useEffect(() => {\n if (!affix || !anchorRef.current) return\n\n const container = getContainer?.() ?? window\n\n const handleScroll = () => {\n if (!anchorRef.current || !placeholderRef.current) return\n\n const placeholderRect = placeholderRef.current.getBoundingClientRect()\n const containerTop = container === window\n ? 0\n : (container as HTMLElement).getBoundingClientRect().top\n\n const shouldAffix = placeholderRect.top - containerTop <= affixOffsetTop\n\n if (shouldAffix !== isAffixed) {\n setIsAffixed(shouldAffix)\n }\n }\n\n container.addEventListener('scroll', handleScroll, { passive: true })\n handleScroll()\n\n return () => container.removeEventListener('scroll', handleScroll)\n }, [affix, affixOffsetTop, getContainer, isAffixed])\n\n // Scroll spy\n useEffect(() => {\n if (links.length === 0) return\n\n const container = getContainer?.() ?? window\n\n const handleScroll = () => {\n let currentActive = ''\n const containerEl = container === window ? document.documentElement : container as HTMLElement\n const containerTop = container === window\n ? 0\n : containerEl.getBoundingClientRect().top\n\n // Check if scrolled to near the bottom\n const scrollTop = container === window ? window.scrollY : containerEl.scrollTop\n const scrollHeight = containerEl.scrollHeight\n const clientHeight = container === window ? window.innerHeight : containerEl.clientHeight\n const isNearBottom = scrollTop + clientHeight >= scrollHeight - 10\n\n // If near bottom, use the last link\n if (isNearBottom && links.length > 0) {\n currentActive = links[links.length - 1]\n } else {\n // Find the last element that has scrolled past the top (standard scroll spy behavior)\n for (const href of links) {\n const element = document.getElementById(href)\n if (element) {\n const rect = element.getBoundingClientRect()\n const distance = rect.top - containerTop - offsetTop\n\n // If element's top is within bounds of the threshold, it's the current section\n if (distance <= bounds) {\n currentActive = href\n }\n }\n }\n\n // If nothing matched, use the first link\n if (!currentActive && links.length > 0) {\n currentActive = links[0]\n }\n }\n\n if (currentActive && currentActive !== rawActiveLink) {\n if (!isControlled) {\n setInternalActiveLink(currentActive)\n }\n onChange?.(currentActive)\n }\n }\n\n container.addEventListener('scroll', handleScroll, { passive: true })\n handleScroll() // Initial check\n\n return () => container.removeEventListener('scroll', handleScroll)\n }, [links, getContainer, offsetTop, bounds, rawActiveLink, isControlled, onChange])\n\n const contextValue: AnchorContextValue = {\n activeLink,\n direction,\n offsetTop,\n registerLink,\n unregisterLink,\n handleClick,\n }\n\n const renderItems = (linkItems: AnchorLinkItem[]): React.ReactNode => {\n return linkItems.map((item) => (\n <AnchorLink key={item.href} href={item.href} title={item.title}>\n {item.children && renderItems(item.children)}\n </AnchorLink>\n ))\n }\n\n const anchorContent = (\n <nav\n ref={anchorRef}\n className={`\n ${direction === 'horizontal' ? 'flex items-center' : 'flex flex-col'}\n ${isAffixed ? 'fixed bg-base-100 shadow-sm z-10' : ''}\n ${className}\n `.trim()}\n style={isAffixed ? { top: affixOffsetTop } : undefined}\n >\n {items ? renderItems(items) : children}\n </nav>\n )\n\n if (affix) {\n return (\n <AnchorContext.Provider value={contextValue}>\n <div ref={placeholderRef} style={isAffixed && anchorRef.current ? { height: anchorRef.current.offsetHeight } : undefined}>\n {anchorContent}\n </div>\n </AnchorContext.Provider>\n )\n }\n\n return (\n <AnchorContext.Provider value={contextValue}>\n {anchorContent}\n </AnchorContext.Provider>\n )\n}\n\nexport const Anchor = Object.assign(AnchorComponent, {\n Link: AnchorLink,\n})\n"],"names":["AnchorContext","createContext","useAnchorContext","context","useContext","AnchorLink","href","title","children","className","activeLink","direction","registerLink","unregisterLink","handleClick","useEffect","isActive","isVertical","jsxs","jsx","e","AnchorComponent","items","offsetTop","bounds","getContainer","getCurrentAnchor","onChange","onClick","controlledActiveLink","affix","affixOffsetTop","replace","internalActiveLink","setInternalActiveLink","useState","links","setLinks","isAffixed","setIsAffixed","anchorRef","useRef","placeholderRef","isControlled","rawActiveLink","useCallback","prev","link","scrollToTarget","target","container","targetTop","containerTop","scrollTop","top","handleScroll","placeholderRect","shouldAffix","currentActive","containerEl","scrollHeight","clientHeight","element","contextValue","renderItems","linkItems","item","anchorContent","Anchor"],"mappings":";;AA8DA,MAAMA,IAAgBC,EAAyC,IAAI,GAE7DC,IAAmB,MAAM;AAC7B,QAAMC,IAAUC,EAAWJ,CAAa;AACxC,MAAI,CAACG;AACH,UAAM,IAAI,MAAM,2CAA2C;AAE7D,SAAOA;AACT,GAEME,IAAwC,CAAC;AAAA,EAC7C,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC,IAAY;AACd,MAAM;AACJ,QAAM,EAAE,YAAAC,GAAY,WAAAC,GAAW,cAAAC,GAAc,gBAAAC,GAAgB,aAAAC,EAAA,IAAgBZ,EAAA;AAE7E,EAAAa,EAAU,OACRH,EAAaN,CAAI,GACV,MAAMO,EAAeP,CAAI,IAC/B,CAACA,GAAMM,GAAcC,CAAc,CAAC;AA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":"Anchor.js","sources":["../../src/components/Anchor.tsx"],"sourcesContent":["import React, { useState, useEffect, useCallback, createContext, useContext, useRef } from 'react'\n\nexport interface AnchorLinkItem {\n /** Target element id (without #) */\n href: string\n /** Link title */\n title: React.ReactNode\n /** Nested links */\n children?: AnchorLinkItem[]\n}\n\nexport interface AnchorProps {\n /** Anchor links (alternative to Anchor.Link children) */\n items?: AnchorLinkItem[]\n /** Layout direction */\n direction?: 'horizontal' | 'vertical'\n /** Offset from top when calculating scroll position */\n offsetTop?: number\n /** Bounding distance of anchor area */\n bounds?: number\n /** Target scroll container (default: window) */\n getContainer?: () => HTMLElement | Window\n /** Customize the anchor highlight */\n getCurrentAnchor?: (activeLink: string) => string\n /** Callback when active link changes */\n onChange?: (activeLink: string) => void\n /** Callback when link is clicked */\n onClick?: (e: React.MouseEvent, link: { href: string; title: React.ReactNode }) => void\n /** Currently active link (controlled) */\n activeLink?: string\n /** Whether to fix the anchor when scrolling */\n affix?: boolean\n /** Pixels to offset from top when affix is true */\n affixOffsetTop?: number\n /** Replace history instead of push */\n replace?: boolean\n /** Custom class name */\n className?: string\n /** Anchor.Link children */\n children?: React.ReactNode\n 'data-testid'?: string\n}\n\nexport interface AnchorLinkProps {\n /** Target element id (without #) */\n href: string\n /** Link title */\n title: React.ReactNode\n /** Nested links */\n children?: React.ReactNode\n /** Custom class name */\n className?: string\n 'data-testid'?: string\n}\n\ninterface AnchorContextValue {\n activeLink: string\n direction: 'horizontal' | 'vertical'\n offsetTop: number\n registerLink: (href: string) => void\n unregisterLink: (href: string) => void\n handleClick: (e: React.MouseEvent, href: string, title: React.ReactNode) => void\n}\n\nconst AnchorContext = createContext<AnchorContextValue | null>(null)\n\nconst useAnchorContext = () => {\n const context = useContext(AnchorContext)\n if (!context) {\n throw new Error('Anchor.Link must be used within an Anchor')\n }\n return context\n}\n\nconst AnchorLink: React.FC<AnchorLinkProps> = ({\n href,\n title,\n children,\n className = '',\n 'data-testid': testId,\n}) => {\n const { activeLink, direction, registerLink, unregisterLink, handleClick } = useAnchorContext()\n\n useEffect(() => {\n registerLink(href)\n return () => unregisterLink(href)\n }, [href, registerLink, unregisterLink])\n\n const isActive = activeLink === href\n const isVertical = direction === 'vertical'\n\n return (\n <div className={isVertical ? '' : 'inline-block'}>\n <a\n href={`#${href}`}\n onClick={(e) => handleClick(e, href, title)}\n className={`\n block text-sm transition-colors\n ${isVertical ? 'py-1 pl-3 border-l-2' : 'px-3 py-1 border-b-2'}\n ${isActive\n ? 'text-primary border-primary font-medium'\n : 'text-base-content/70 border-transparent hover:text-base-content hover:border-base-content/30'\n }\n ${className}\n `.trim()}\n data-testid={testId}\n >\n {title}\n </a>\n {children && (\n <div className={isVertical ? 'pl-3' : 'inline-flex'}>\n {children}\n </div>\n )}\n </div>\n )\n}\n\nconst AnchorComponent: React.FC<AnchorProps> = ({\n items,\n direction = 'vertical',\n offsetTop = 0,\n bounds = 5,\n getContainer,\n getCurrentAnchor,\n onChange,\n onClick,\n activeLink: controlledActiveLink,\n affix = false,\n affixOffsetTop = 0,\n replace = false,\n className = '',\n children,\n 'data-testid': testId,\n}) => {\n const [internalActiveLink, setInternalActiveLink] = useState('')\n const [links, setLinks] = useState<string[]>([])\n const [isAffixed, setIsAffixed] = useState(false)\n const anchorRef = useRef<HTMLDivElement>(null)\n const placeholderRef = useRef<HTMLDivElement>(null)\n\n const isControlled = controlledActiveLink !== undefined\n const rawActiveLink = isControlled ? controlledActiveLink : internalActiveLink\n const activeLink = getCurrentAnchor ? getCurrentAnchor(rawActiveLink) : rawActiveLink\n\n const registerLink = useCallback((href: string) => {\n setLinks((prev) => (prev.includes(href) ? prev : [...prev, href]))\n }, [])\n\n const unregisterLink = useCallback((href: string) => {\n setLinks((prev) => prev.filter((link) => link !== href))\n }, [])\n\n const scrollToTarget = useCallback((href: string) => {\n const target = document.getElementById(href)\n if (target) {\n const container = getContainer?.() ?? window\n const targetTop = target.getBoundingClientRect().top\n const containerTop = container === window\n ? 0\n : (container as HTMLElement).getBoundingClientRect().top\n const scrollTop = container === window\n ? window.scrollY\n : (container as HTMLElement).scrollTop\n\n const top = targetTop - containerTop + scrollTop - offsetTop\n\n if (container === window) {\n window.scrollTo({ top, behavior: 'smooth' })\n } else {\n (container as HTMLElement).scrollTo({ top, behavior: 'smooth' })\n }\n\n // Update URL hash\n if (replace) {\n window.history.replaceState(null, '', `#${href}`)\n } else {\n window.history.pushState(null, '', `#${href}`)\n }\n }\n }, [getContainer, offsetTop, replace])\n\n const handleClick = useCallback((\n e: React.MouseEvent,\n href: string,\n title: React.ReactNode\n ) => {\n e.preventDefault()\n onClick?.(e, { href, title })\n scrollToTarget(href)\n\n if (!isControlled) {\n setInternalActiveLink(href)\n }\n onChange?.(href)\n }, [onClick, scrollToTarget, isControlled, onChange])\n\n // Affix logic\n useEffect(() => {\n if (!affix || !anchorRef.current) return\n\n const container = getContainer?.() ?? window\n\n const handleScroll = () => {\n if (!anchorRef.current || !placeholderRef.current) return\n\n const placeholderRect = placeholderRef.current.getBoundingClientRect()\n const containerTop = container === window\n ? 0\n : (container as HTMLElement).getBoundingClientRect().top\n\n const shouldAffix = placeholderRect.top - containerTop <= affixOffsetTop\n\n if (shouldAffix !== isAffixed) {\n setIsAffixed(shouldAffix)\n }\n }\n\n container.addEventListener('scroll', handleScroll, { passive: true })\n handleScroll()\n\n return () => container.removeEventListener('scroll', handleScroll)\n }, [affix, affixOffsetTop, getContainer, isAffixed])\n\n // Scroll spy\n useEffect(() => {\n if (links.length === 0) return\n\n const container = getContainer?.() ?? window\n\n const handleScroll = () => {\n let currentActive = ''\n const containerEl = container === window ? document.documentElement : container as HTMLElement\n const containerTop = container === window\n ? 0\n : containerEl.getBoundingClientRect().top\n\n // Check if scrolled to near the bottom\n const scrollTop = container === window ? window.scrollY : containerEl.scrollTop\n const scrollHeight = containerEl.scrollHeight\n const clientHeight = container === window ? window.innerHeight : containerEl.clientHeight\n const isNearBottom = scrollTop + clientHeight >= scrollHeight - 10\n\n // If near bottom, use the last link\n if (isNearBottom && links.length > 0) {\n currentActive = links[links.length - 1]\n } else {\n // Find the last element that has scrolled past the top (standard scroll spy behavior)\n for (const href of links) {\n const element = document.getElementById(href)\n if (element) {\n const rect = element.getBoundingClientRect()\n const distance = rect.top - containerTop - offsetTop\n\n // If element's top is within bounds of the threshold, it's the current section\n if (distance <= bounds) {\n currentActive = href\n }\n }\n }\n\n // If nothing matched, use the first link\n if (!currentActive && links.length > 0) {\n currentActive = links[0]\n }\n }\n\n if (currentActive && currentActive !== rawActiveLink) {\n if (!isControlled) {\n setInternalActiveLink(currentActive)\n }\n onChange?.(currentActive)\n }\n }\n\n container.addEventListener('scroll', handleScroll, { passive: true })\n handleScroll() // Initial check\n\n return () => container.removeEventListener('scroll', handleScroll)\n }, [links, getContainer, offsetTop, bounds, rawActiveLink, isControlled, onChange])\n\n const contextValue: AnchorContextValue = {\n activeLink,\n direction,\n offsetTop,\n registerLink,\n unregisterLink,\n handleClick,\n }\n const getTestId = (suffix: string) => (testId ? `${testId}-${suffix}` : undefined)\n\n const renderItems = (linkItems: AnchorLinkItem[]): React.ReactNode => {\n return linkItems.map((item) => (\n <AnchorLink key={item.href} href={item.href} title={item.title} data-testid={getTestId(`link-${item.href}`)}>\n {item.children && renderItems(item.children)}\n </AnchorLink>\n ))\n }\n\n const anchorContent = (\n <nav\n ref={anchorRef}\n className={`\n ${direction === 'horizontal' ? 'flex items-center' : 'flex flex-col'}\n ${isAffixed ? 'fixed bg-base-100 shadow-sm z-10' : ''}\n ${className}\n `.trim()}\n style={isAffixed ? { top: affixOffsetTop } : undefined}\n data-testid={testId}\n >\n {items ? renderItems(items) : children}\n </nav>\n )\n\n if (affix) {\n return (\n <AnchorContext.Provider value={contextValue}>\n <div ref={placeholderRef} style={isAffixed && anchorRef.current ? { height: anchorRef.current.offsetHeight } : undefined}>\n {anchorContent}\n </div>\n </AnchorContext.Provider>\n )\n }\n\n return (\n <AnchorContext.Provider value={contextValue}>\n {anchorContent}\n </AnchorContext.Provider>\n )\n}\n\nexport const Anchor = Object.assign(AnchorComponent, {\n Link: AnchorLink,\n})\n"],"names":["AnchorContext","createContext","useAnchorContext","context","useContext","AnchorLink","href","title","children","className","testId","activeLink","direction","registerLink","unregisterLink","handleClick","useEffect","isActive","isVertical","jsxs","jsx","e","AnchorComponent","items","offsetTop","bounds","getContainer","getCurrentAnchor","onChange","onClick","controlledActiveLink","affix","affixOffsetTop","replace","internalActiveLink","setInternalActiveLink","useState","links","setLinks","isAffixed","setIsAffixed","anchorRef","useRef","placeholderRef","isControlled","rawActiveLink","useCallback","prev","link","scrollToTarget","target","container","targetTop","containerTop","scrollTop","top","handleScroll","placeholderRect","shouldAffix","currentActive","containerEl","scrollHeight","clientHeight","element","contextValue","getTestId","suffix","renderItems","linkItems","item","anchorContent","Anchor"],"mappings":";;AAgEA,MAAMA,IAAgBC,EAAyC,IAAI,GAE7DC,KAAmB,MAAM;AAC7B,QAAMC,IAAUC,EAAWJ,CAAa;AACxC,MAAI,CAACG;AACH,UAAM,IAAI,MAAM,2CAA2C;AAE7D,SAAOA;AACT,GAEME,IAAwC,CAAC;AAAA,EAC7C,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,eAAeC;AACjB,MAAM;AACJ,QAAM,EAAE,YAAAC,GAAY,WAAAC,GAAW,cAAAC,GAAc,gBAAAC,GAAgB,aAAAC,EAAA,IAAgBb,GAAA;AAE7E,EAAAc,EAAU,OACRH,EAAaP,CAAI,GACV,MAAMQ,EAAeR,CAAI,IAC/B,CAACA,GAAMO,GAAcC,CAAc,CAAC;AAEvC,QAAMG,IAAWN,MAAeL,GAC1BY,IAAaN,MAAc;AAEjC,SACE,gBAAAO,EAAC,OAAA,EAAI,WAAWD,IAAa,KAAK,gBAChC,UAAA;AAAA,IAAA,gBAAAE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,MAAM,IAAId,CAAI;AAAA,QACd,SAAS,CAACe,MAAMN,EAAYM,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DivElem
34
34
  onOpenChange?: (open: boolean) => void;
35
35
  /** Activate first option by default */
36
36
  defaultActiveFirstOption?: boolean;
37
+ 'data-testid'?: string;
37
38
  }
38
39
  export declare const Autocomplete: React.FC<AutocompleteProps>;
@@ -1,7 +1,7 @@
1
- import { jsxs as M, jsx as o } from "react/jsx-runtime";
2
- import { useId as de, useState as k, useRef as O, useEffect as z } from "react";
3
- import { useConfig as ue } from "../providers/ConfigProvider.js";
4
- const pe = "dropdown", fe = "dropdown-bottom", he = "dropdown-open", be = "dropdown-content", me = "menu", Ie = "input", ge = "input-xs", we = "input-sm", xe = "input-md", ye = "input-lg", ve = "input-xl", Ce = "input-neutral", ke = "input-primary", De = "input-secondary", Ne = "input-accent", $e = "input-info", je = "input-success", A = "input-warning", R = "input-error", Ee = ({ onClick: l, className: I }) => /* @__PURE__ */ o(
1
+ import { jsxs as z, jsx as o } from "react/jsx-runtime";
2
+ import { useId as pe, useState as D, useRef as A, useEffect as T } from "react";
3
+ import { useConfig as fe } from "../providers/ConfigProvider.js";
4
+ const be = "dropdown", he = "dropdown-bottom", me = "dropdown-open", ge = "dropdown-content", Ie = "menu", we = "input", xe = "input-xs", ve = "input-sm", ye = "input-md", Ce = "input-lg", $e = "input-xl", ke = "input-neutral", De = "input-primary", Ne = "input-secondary", je = "input-accent", Ee = "input-info", Se = "input-success", R = "input-warning", V = "input-error", Be = ({ onClick: l, className: I }) => /* @__PURE__ */ o(
5
5
  "button",
6
6
  {
7
7
  type: "button",
@@ -11,169 +11,174 @@ const pe = "dropdown", fe = "dropdown-bottom", he = "dropdown-open", be = "dropd
11
11
  tabIndex: -1,
12
12
  children: /* @__PURE__ */ o("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ o("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
13
13
  }
14
- ), ze = ({
14
+ ), Te = ({
15
15
  value: l,
16
16
  defaultValue: I = "",
17
- onChange: g,
18
- onSelect: T,
19
- onSearch: V,
20
- options: K,
21
- placeholder: P = "Type to search...",
22
- disabled: p = !1,
23
- size: U,
24
- color: D,
25
- status: w,
26
- className: W = "",
27
- allowCustomValue: N = !0,
28
- filterOption: $,
29
- notFoundContent: X = "No results found",
30
- allowClear: f,
31
- onClear: F,
32
- open: j,
33
- defaultOpen: H = !1,
34
- onOpenChange: q,
35
- defaultActiveFirstOption: x = !0,
36
- ...G
17
+ onChange: w,
18
+ onSelect: K,
19
+ onSearch: P,
20
+ options: U,
21
+ placeholder: W = "Type to search...",
22
+ disabled: f = !1,
23
+ size: X,
24
+ color: N,
25
+ status: x,
26
+ className: F = "",
27
+ allowCustomValue: j = !0,
28
+ filterOption: E,
29
+ notFoundContent: H = "No results found",
30
+ allowClear: b,
31
+ onClear: q,
32
+ open: S,
33
+ defaultOpen: G = !1,
34
+ onOpenChange: J,
35
+ defaultActiveFirstOption: v = !0,
36
+ "data-testid": y,
37
+ ...Q
37
38
  }) => {
38
- const { componentSize: J } = ue(), Q = U ?? J ?? "md", y = de(), Y = `${y}-input`, E = `${y}-listbox`, v = K.map(
39
+ const { componentSize: Y } = fe(), Z = X ?? Y ?? "md", C = pe(), _ = `${C}-input`, B = `${C}-listbox`, $ = U.map(
39
40
  (e) => typeof e == "string" ? { value: e, label: e } : e
40
- ), [h, b] = k(I), [Z, _] = k(H), [t, r] = k(-1), m = O(null), i = O(null), S = j !== void 0, d = S ? j : Z, c = (e) => {
41
- S || _(e), q?.(e);
41
+ ), [h, m] = D(I), [ee, te] = D(G), [n, r] = D(-1), g = A(null), i = A(null), L = S !== void 0, d = L ? S : ee, c = (e) => {
42
+ L || te(e), J?.(e);
42
43
  };
43
- z(() => {
44
+ T(() => {
44
45
  if (l !== void 0) {
45
- const e = v.find((n) => n.value === l);
46
- b(e?.label || l);
46
+ const e = $.find((t) => t.value === l);
47
+ m(e?.label || l);
47
48
  }
48
- }, [l, v]);
49
- const ee = (e, n) => e.label.toLowerCase().includes(n.toLowerCase()), a = v.filter(
50
- (e) => $ ? $(e, h) : ee(e, h)
51
- ), u = a.filter((e) => !e.disabled), ne = (e) => {
52
- const n = e.target.value;
53
- b(n), c(!0), x && u.length > 0 ? r(0) : r(-1), V?.(n), N && g?.(n);
54
- }, C = (e) => {
55
- e.disabled || (b(e.label), c(!1), r(-1), g?.(e.value), T?.(e.value, e), m.current?.focus());
56
- }, te = (e) => {
49
+ }, [l, $]);
50
+ const ne = (e, t) => e.label.toLowerCase().includes(t.toLowerCase()), a = $.filter(
51
+ (e) => E ? E(e, h) : ne(e, h)
52
+ ), u = a.filter((e) => !e.disabled), se = (e) => {
53
+ const t = e.target.value;
54
+ m(t), c(!0), v && u.length > 0 ? r(0) : r(-1), P?.(t), j && w?.(t);
55
+ }, k = (e) => {
56
+ e.disabled || (m(e.label), c(!1), r(-1), w?.(e.value), K?.(e.value, e), g.current?.focus());
57
+ }, oe = (e) => {
57
58
  if (!d && (e.key === "ArrowDown" || e.key === "ArrowUp")) {
58
- c(!0), x && u.length > 0 && r(0);
59
+ c(!0), v && u.length > 0 && r(0);
59
60
  return;
60
61
  }
61
62
  switch (e.key) {
62
63
  case "ArrowDown":
63
- e.preventDefault(), r((n) => {
64
- for (let s = n + 1; s < a.length; s++)
64
+ e.preventDefault(), r((t) => {
65
+ for (let s = t + 1; s < a.length; s++)
65
66
  if (!a[s].disabled) return s;
66
- return n;
67
+ return t;
67
68
  });
68
69
  break;
69
70
  case "ArrowUp":
70
- e.preventDefault(), r((n) => {
71
- for (let s = n - 1; s >= 0; s--)
71
+ e.preventDefault(), r((t) => {
72
+ for (let s = t - 1; s >= 0; s--)
72
73
  if (!a[s].disabled) return s;
73
- return n;
74
+ return t;
74
75
  });
75
76
  break;
76
77
  case "Enter":
77
- e.preventDefault(), t >= 0 && a[t] && !a[t].disabled ? C(a[t]) : !N && u.length > 0 && C(u[0]);
78
+ e.preventDefault(), n >= 0 && a[n] && !a[n].disabled ? k(a[n]) : !j && u.length > 0 && k(u[0]);
78
79
  break;
79
80
  case "Escape":
80
- c(!1), r(-1), m.current?.blur();
81
+ c(!1), r(-1), g.current?.blur();
81
82
  break;
82
83
  }
83
- }, se = () => {
84
- c(!0), x && u.length > 0 && r(0);
85
- }, oe = (e) => {
84
+ }, re = () => {
85
+ c(!0), v && u.length > 0 && r(0);
86
+ }, ae = (e) => {
86
87
  i.current && i.current.contains(e.relatedTarget) || setTimeout(() => c(!1), 200);
87
- }, re = (e) => {
88
- e.stopPropagation(), b(""), g?.(""), F?.(), m.current?.focus();
89
- }, ae = {
90
- xs: ge,
91
- sm: we,
92
- md: xe,
93
- lg: ye,
94
- xl: ve
95
- }, le = w ? {
96
- error: R,
97
- warning: A
98
- }[w] : D ? {
99
- neutral: Ce,
100
- primary: ke,
101
- secondary: De,
102
- accent: Ne,
103
- info: $e,
104
- success: je,
105
- warning: A,
106
- error: R
107
- }[D] : "";
108
- z(() => {
109
- t >= 0 && i.current && i.current.children[t]?.scrollIntoView({ block: "nearest" });
110
- }, [t]);
111
- const B = f && h && !p, ce = typeof f == "object" && f.clearIcon ? f.clearIcon : null, L = (e) => `${y}-option-${e}`, ie = [
112
- `${Ie} w-full`,
113
- ae[Q],
114
- le,
115
- B && "pr-10"
116
- ].filter(Boolean).join(" ");
117
- return /* @__PURE__ */ M(
88
+ }, le = (e) => {
89
+ e.stopPropagation(), m(""), w?.(""), q?.(), g.current?.focus();
90
+ }, ce = {
91
+ xs: xe,
92
+ sm: ve,
93
+ md: ye,
94
+ lg: Ce,
95
+ xl: $e
96
+ }, ie = x ? {
97
+ error: V,
98
+ warning: R
99
+ }[x] : N ? {
100
+ neutral: ke,
101
+ primary: De,
102
+ secondary: Ne,
103
+ accent: je,
104
+ info: Ee,
105
+ success: Se,
106
+ warning: R,
107
+ error: V
108
+ }[N] : "";
109
+ T(() => {
110
+ n >= 0 && i.current && i.current.children[n]?.scrollIntoView({ block: "nearest" });
111
+ }, [n]);
112
+ const M = b && h && !f, de = typeof b == "object" && b.clearIcon ? b.clearIcon : null, O = (e) => `${C}-option-${e}`, ue = [
113
+ `${we} w-full`,
114
+ ce[Z],
115
+ ie,
116
+ M && "pr-10"
117
+ ].filter(Boolean).join(" "), p = (e) => y ? `${y}-${e}` : void 0;
118
+ return /* @__PURE__ */ z(
118
119
  "div",
119
120
  {
120
- className: `${pe} ${fe} w-full ${d && !p ? he : ""} ${W}`,
121
+ className: `${be} ${he} w-full ${d && !f ? me : ""} ${F}`,
121
122
  "data-state": d ? "open" : "closed",
122
- ...G,
123
+ "data-testid": y,
124
+ ...Q,
123
125
  children: [
124
- /* @__PURE__ */ M("div", { className: "relative w-full", children: [
126
+ /* @__PURE__ */ z("div", { className: "relative w-full", children: [
125
127
  /* @__PURE__ */ o(
126
128
  "input",
127
129
  {
128
- ref: m,
129
- id: Y,
130
+ ref: g,
131
+ id: _,
130
132
  type: "text",
131
133
  role: "combobox",
132
134
  "aria-expanded": d,
133
135
  "aria-haspopup": "listbox",
134
- "aria-controls": E,
136
+ "aria-controls": B,
135
137
  "aria-autocomplete": "list",
136
- "aria-activedescendant": t >= 0 ? L(t) : void 0,
137
- "aria-invalid": w === "error" ? !0 : void 0,
138
+ "aria-activedescendant": n >= 0 ? O(n) : void 0,
139
+ "aria-invalid": x === "error" ? !0 : void 0,
138
140
  value: h,
139
- onChange: ne,
140
- onKeyDown: te,
141
- onFocus: se,
142
- onBlur: oe,
143
- placeholder: P,
144
- disabled: p,
145
- className: ie
141
+ onChange: se,
142
+ onKeyDown: oe,
143
+ onFocus: re,
144
+ onBlur: ae,
145
+ placeholder: W,
146
+ disabled: f,
147
+ className: ue,
148
+ "data-testid": p("input")
146
149
  }
147
150
  ),
148
- B && /* @__PURE__ */ o("span", { className: "absolute right-3 top-1/2 -translate-y-1/2 z-10", children: ce || /* @__PURE__ */ o(Ee, { onClick: re }) })
151
+ M && /* @__PURE__ */ o("span", { className: "absolute right-3 top-1/2 -translate-y-1/2 z-10", "data-testid": p("clear"), children: de || /* @__PURE__ */ o(Be, { onClick: le }) })
149
152
  ] }),
150
- d && !p && /* @__PURE__ */ o(
153
+ d && !f && /* @__PURE__ */ o(
151
154
  "ul",
152
155
  {
153
156
  ref: i,
154
- id: E,
157
+ id: B,
155
158
  role: "listbox",
156
159
  "aria-label": "Suggestions",
157
160
  tabIndex: -1,
158
- className: `${be} ${me} bg-base-100 rounded-box z-50 w-full shadow-lg border border-base-300 max-h-60 overflow-auto flex-nowrap`,
159
- children: a.length > 0 ? a.map((e, n) => /* @__PURE__ */ o("li", { children: /* @__PURE__ */ o(
161
+ className: `${ge} ${Ie} bg-base-100 rounded-box z-50 w-full shadow-lg border border-base-300 max-h-60 overflow-auto flex-nowrap`,
162
+ "data-testid": p("listbox"),
163
+ children: a.length > 0 ? a.map((e, t) => /* @__PURE__ */ o("li", { children: /* @__PURE__ */ o(
160
164
  "a",
161
165
  {
162
- id: L(n),
166
+ id: O(t),
163
167
  role: "option",
164
- "aria-selected": t === n,
168
+ "aria-selected": n === t,
165
169
  "aria-disabled": e.disabled,
166
170
  onMouseDown: (s) => {
167
- s.preventDefault(), C(e);
171
+ s.preventDefault(), k(e);
168
172
  },
169
- onMouseEnter: () => !e.disabled && r(n),
173
+ onMouseEnter: () => !e.disabled && r(t),
170
174
  className: [
171
- n === t && !e.disabled && "active",
175
+ t === n && !e.disabled && "active",
172
176
  e.disabled && "disabled text-base-content/40 cursor-not-allowed"
173
177
  ].filter(Boolean).join(" "),
178
+ "data-testid": p(`option-${e.value || t}`),
174
179
  children: e.label
175
180
  }
176
- ) }, e.value)) : /* @__PURE__ */ o("li", { className: "disabled", children: /* @__PURE__ */ o("span", { className: "text-base-content/60 text-center cursor-default", children: X }) })
181
+ ) }, e.value)) : /* @__PURE__ */ o("li", { className: "disabled", "data-testid": p("empty"), children: /* @__PURE__ */ o("span", { className: "text-base-content/60 text-center cursor-default", children: H }) })
177
182
  }
178
183
  )
179
184
  ]
@@ -181,6 +186,6 @@ const pe = "dropdown", fe = "dropdown-bottom", he = "dropdown-open", be = "dropd
181
186
  );
182
187
  };
183
188
  export {
184
- ze as Autocomplete
189
+ Te as Autocomplete
185
190
  };
186
191
  //# sourceMappingURL=Autocomplete.js.map