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
@@ -1,219 +1,223 @@
1
- import { jsx as n, jsxs as m, Fragment as te } from "react/jsx-runtime";
2
- import W, { forwardRef as pe, useRef as H, useId as ne, useState as K, useCallback as V, useMemo as ee, useEffect as M, createContext as fe, useContext as he } from "react";
3
- const be = "modal", ge = "modal-box", Q = "kbd", Y = "kbd-xs", re = fe(null);
4
- function A() {
5
- const r = he(re);
1
+ import { jsx as n, jsxs as f, Fragment as re } from "react/jsx-runtime";
2
+ import X, { forwardRef as he, useRef as W, useId as ae, useState as O, useCallback as V, useMemo as ne, useEffect as j, createContext as ge, useContext as be } from "react";
3
+ const xe = "modal", ye = "modal-box", Z = "kbd", _ = "kbd-xs", se = ge(null);
4
+ function D() {
5
+ const r = be(se);
6
6
  if (!r)
7
7
  throw new Error("Command compound components must be used within a Command");
8
8
  return r;
9
9
  }
10
- const xe = (r, c, s = []) => {
11
- const d = c.toLowerCase();
12
- return r.toLowerCase().includes(d) ? !0 : s.some((p) => p.toLowerCase().includes(d));
13
- }, se = pe(
10
+ const ve = (r, c, a = []) => {
11
+ const i = c.toLowerCase();
12
+ return r.toLowerCase().includes(i) ? !0 : a.some((p) => p.toLowerCase().includes(i));
13
+ }, oe = he(
14
14
  ({
15
15
  children: r,
16
16
  open: c,
17
- onOpenChange: s,
18
- defaultOpen: d = !1,
19
- items: l,
20
- filter: p = xe,
21
- loop: f = !0,
17
+ onOpenChange: a,
18
+ defaultOpen: i = !1,
19
+ items: d,
20
+ filter: p = ve,
21
+ loop: b = !0,
22
22
  shortcut: x = ["k"],
23
23
  placeholder: I = "Type a command or search...",
24
- emptyMessage: y = "No results found.",
25
- className: q = "",
26
- ...z
27
- }, h) => {
28
- const E = H(null), G = H(null), F = H(null), U = H(null), L = ne(), [$, X] = K(d), v = c !== void 0, D = v ? c : $, b = V(
24
+ emptyMessage: L = "No results found.",
25
+ className: C = "",
26
+ "data-testid": N,
27
+ ...J
28
+ }, M) => {
29
+ const h = W(null), A = W(null), B = W(null), Q = W(null), P = ae(), [q, T] = O(i), R = c !== void 0, $ = R ? c : q, u = V(
29
30
  (e) => {
30
- v || X(e), s?.(e);
31
+ R || T(e), a?.(e);
31
32
  },
32
- [v, s]
33
- ), [k, j] = K(""), [g, w] = K(0), [O, Z] = K(/* @__PURE__ */ new Map()), [C, J] = K(["root"]), _ = C[C.length - 1], oe = V((e) => {
34
- J((t) => [...t, e]), j(""), w(0);
35
- }, []), B = V(() => {
36
- C.length > 1 && (J((e) => e.slice(0, -1)), j(""), w(0));
37
- }, [C.length]), le = V(
38
- (e, t, a, i, u) => {
39
- Z((o) => {
40
- const S = new Map(o);
41
- return S.set(e, { id: e, value: t, keywords: a, disabled: i, onSelect: u }), S;
33
+ [R, a]
34
+ ), [v, S] = O(""), [y, k] = O(0), [z, ee] = O(/* @__PURE__ */ new Map()), [w, Y] = O(["root"]), te = w[w.length - 1], ie = V((e) => {
35
+ Y((t) => [...t, e]), S(""), k(0);
36
+ }, []), K = V(() => {
37
+ w.length > 1 && (Y((e) => e.slice(0, -1)), S(""), k(0));
38
+ }, [w.length]), de = V(
39
+ (e, t, o, l, m) => {
40
+ ee((s) => {
41
+ const F = new Map(s);
42
+ return F.set(e, { id: e, value: t, keywords: o, disabled: l, onSelect: m }), F;
42
43
  });
43
44
  },
44
45
  []
45
- ), ie = V((e) => {
46
- Z((t) => {
47
- const a = new Map(t);
48
- return a.delete(e), a;
46
+ ), ce = V((e) => {
47
+ ee((t) => {
48
+ const o = new Map(t);
49
+ return o.delete(e), o;
49
50
  });
50
- }, []), P = ee(() => l ? l.filter((t) => {
51
- if (!k) return !0;
52
- const a = typeof t.label == "string" ? t.label : "";
53
- return p(a, k, t.keywords);
51
+ }, []), H = ne(() => d ? d.filter((t) => {
52
+ if (!v) return !0;
53
+ const o = typeof t.label == "string" ? t.label : "";
54
+ return p(o, v, t.keywords);
54
55
  }).map((t) => ({
55
56
  id: t.key,
56
57
  value: typeof t.label == "string" ? t.label : t.key,
57
58
  keywords: t.keywords || [],
58
59
  disabled: t.disabled || !1
59
- })) : Array.from(O.values()).filter((t) => k ? p(t.value, k, t.keywords) : !0), [l, O, k, p]), N = ee(
60
- () => P.filter((e) => !e.disabled),
61
- [P]
62
- ), R = V(
60
+ })) : Array.from(z.values()).filter((t) => v ? p(t.value, v, t.keywords) : !0), [d, z, v, p]), E = ne(
61
+ () => H.filter((e) => !e.disabled),
62
+ [H]
63
+ ), G = V(
63
64
  (e) => {
64
- if (l) {
65
- const t = l.find((a) => a.key === e);
66
- t && !t.disabled && (t.onSelect?.(), b(!1));
65
+ if (d) {
66
+ const t = d.find((o) => o.key === e);
67
+ t && !t.disabled && (t.onSelect?.(), u(!1));
67
68
  } else {
68
- const t = O.get(e);
69
- t && !t.disabled && (t.onSelect?.(), b(!1));
69
+ const t = z.get(e);
70
+ t && !t.disabled && (t.onSelect?.(), u(!1));
70
71
  }
71
72
  },
72
- [l, O, b]
73
+ [d, z, u]
73
74
  );
74
- M(() => {
75
- D && (j(""), w(0), J(["root"]));
76
- }, [D]), M(() => {
77
- const e = E.current;
78
- e && (D ? e.open || (U.current = document.activeElement, e.showModal(), setTimeout(() => G.current?.focus(), 0)) : e.open && (e.close(), U.current?.focus()));
79
- }, [D]), M(() => {
80
- const e = E.current;
75
+ j(() => {
76
+ $ && (S(""), k(0), Y(["root"]));
77
+ }, [$]), j(() => {
78
+ const e = h.current;
79
+ e && ($ ? e.open || (Q.current = document.activeElement, e.showModal(), setTimeout(() => A.current?.focus(), 0)) : e.open && (e.close(), Q.current?.focus()));
80
+ }, [$]), j(() => {
81
+ const e = h.current;
81
82
  if (!e) return;
82
83
  const t = () => {
83
- b(!1);
84
+ u(!1);
84
85
  };
85
86
  return e.addEventListener("close", t), () => e.removeEventListener("close", t);
86
- }, [b]), M(() => {
87
+ }, [u]), j(() => {
87
88
  const e = (t) => {
88
- const a = x[0]?.toLowerCase();
89
- (t.metaKey || t.ctrlKey) && t.key.toLowerCase() === a && (t.preventDefault(), b(!D));
89
+ const o = x[0]?.toLowerCase();
90
+ (t.metaKey || t.ctrlKey) && t.key.toLowerCase() === o && (t.preventDefault(), u(!$));
90
91
  };
91
92
  return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
92
- }, [x, D, b]);
93
- const ce = V(
93
+ }, [x, $, u]);
94
+ const ue = V(
94
95
  (e) => {
95
96
  switch (e.key) {
96
97
  case "ArrowDown": {
97
- if (e.preventDefault(), N.length === 0) return;
98
- w((t) => {
99
- const a = t + 1;
100
- return a >= N.length ? f ? 0 : t : a;
98
+ if (e.preventDefault(), E.length === 0) return;
99
+ k((t) => {
100
+ const o = t + 1;
101
+ return o >= E.length ? b ? 0 : t : o;
101
102
  });
102
103
  break;
103
104
  }
104
105
  case "ArrowUp": {
105
- if (e.preventDefault(), N.length === 0) return;
106
- w((t) => {
107
- const a = t - 1;
108
- return a < 0 ? f ? N.length - 1 : 0 : a;
106
+ if (e.preventDefault(), E.length === 0) return;
107
+ k((t) => {
108
+ const o = t - 1;
109
+ return o < 0 ? b ? E.length - 1 : 0 : o;
109
110
  });
110
111
  break;
111
112
  }
112
113
  case "Enter": {
113
114
  e.preventDefault();
114
- const t = N[g];
115
- t && R(t.id);
115
+ const t = E[y];
116
+ t && G(t.id);
116
117
  break;
117
118
  }
118
119
  case "Escape": {
119
- e.preventDefault(), C.length > 1 ? B() : b(!1);
120
+ e.preventDefault(), w.length > 1 ? K() : u(!1);
120
121
  break;
121
122
  }
122
123
  case "Backspace": {
123
- k === "" && C.length > 1 && (e.preventDefault(), B());
124
+ v === "" && w.length > 1 && (e.preventDefault(), K());
124
125
  break;
125
126
  }
126
127
  }
127
128
  },
128
- [N, g, f, R, C, B, k, b]
129
+ [E, y, b, G, w, K, v, u]
129
130
  );
130
- M(() => {
131
- g >= 0 && F.current && F.current.querySelectorAll("[data-command-item]")[g]?.scrollIntoView({ block: "nearest" });
132
- }, [g]);
133
- const de = (e) => {
134
- e.target === E.current && b(!1);
135
- }, ue = {
136
- searchValue: k,
137
- setSearchValue: j,
138
- highlightedIndex: g,
139
- setHighlightedIndex: w,
140
- registerItem: (e, t, a, i) => le(e, t, a, i),
141
- unregisterItem: ie,
142
- filteredItems: P,
143
- selectItem: R,
144
- loop: f,
145
- baseId: L,
146
- currentPage: _,
147
- setPage: oe,
148
- goBack: B,
149
- pageStack: C
150
- }, me = () => {
151
- if (!l) return null;
131
+ j(() => {
132
+ y >= 0 && B.current && B.current.querySelectorAll("[data-command-item]")[y]?.scrollIntoView({ block: "nearest" });
133
+ }, [y]);
134
+ const pe = (e) => {
135
+ e.target === h.current && u(!1);
136
+ }, g = (e) => N ? `${N}-${e}` : void 0, me = {
137
+ searchValue: v,
138
+ setSearchValue: S,
139
+ highlightedIndex: y,
140
+ setHighlightedIndex: k,
141
+ registerItem: (e, t, o, l) => de(e, t, o, l),
142
+ unregisterItem: ce,
143
+ filteredItems: H,
144
+ selectItem: G,
145
+ loop: b,
146
+ baseId: P,
147
+ currentPage: te,
148
+ setPage: ie,
149
+ goBack: K,
150
+ pageStack: w,
151
+ getTestId: g
152
+ }, fe = () => {
153
+ if (!d) return null;
152
154
  const e = /* @__PURE__ */ new Map(), t = [];
153
- P.forEach((i) => {
154
- const u = l.find((o) => o.key === i.id);
155
- if (u)
156
- if (u.group) {
157
- const o = e.get(u.group) || [];
158
- o.push(u), e.set(u.group, o);
155
+ H.forEach((l) => {
156
+ const m = d.find((s) => s.key === l.id);
157
+ if (m)
158
+ if (m.group) {
159
+ const s = e.get(m.group) || [];
160
+ s.push(m), e.set(m.group, s);
159
161
  } else
160
- t.push(u);
162
+ t.push(m);
161
163
  });
162
- let a = 0;
163
- return /* @__PURE__ */ m(te, { children: [
164
- Array.from(e.entries()).map(([i, u]) => /* @__PURE__ */ m("div", { role: "group", "aria-label": i, children: [
165
- /* @__PURE__ */ n("div", { className: "px-3 py-2 text-xs font-semibold text-base-content/60 uppercase tracking-wider", children: i }),
166
- u.map((o) => {
167
- const S = a++, T = S === g;
168
- return /* @__PURE__ */ m(
164
+ let o = 0;
165
+ return /* @__PURE__ */ f(re, { children: [
166
+ Array.from(e.entries()).map(([l, m]) => /* @__PURE__ */ f("div", { role: "group", "aria-label": l, "data-testid": g(`group-${l}`), children: [
167
+ /* @__PURE__ */ n("div", { className: "px-3 py-2 text-xs font-semibold text-base-content/60 uppercase tracking-wider", children: l }),
168
+ m.map((s) => {
169
+ const F = o++, U = F === y;
170
+ return /* @__PURE__ */ f(
169
171
  "div",
170
172
  {
171
173
  role: "option",
172
- "aria-selected": T,
173
- "aria-disabled": o.disabled,
174
+ "aria-selected": U,
175
+ "aria-disabled": s.disabled,
174
176
  "data-command-item": !0,
175
- "data-highlighted": T,
177
+ "data-highlighted": U,
176
178
  className: [
177
179
  "px-3 py-2 cursor-pointer flex items-center gap-3",
178
- T && "bg-primary text-primary-content",
179
- !T && "hover:bg-base-200",
180
- o.disabled && "opacity-50 cursor-not-allowed"
180
+ U && "bg-primary text-primary-content",
181
+ !U && "hover:bg-base-200",
182
+ s.disabled && "opacity-50 cursor-not-allowed"
181
183
  ].filter(Boolean).join(" "),
182
- onClick: () => !o.disabled && R(o.key),
183
- onMouseEnter: () => !o.disabled && w(S),
184
+ "data-testid": g(`item-${s.key}`),
185
+ onClick: () => !s.disabled && G(s.key),
186
+ onMouseEnter: () => !s.disabled && k(F),
184
187
  children: [
185
- o.icon && /* @__PURE__ */ n("span", { className: "w-5 h-5", children: o.icon }),
186
- /* @__PURE__ */ n("span", { children: o.label })
188
+ s.icon && /* @__PURE__ */ n("span", { className: "w-5 h-5", children: s.icon }),
189
+ /* @__PURE__ */ n("span", { children: s.label })
187
190
  ]
188
191
  },
189
- o.key
192
+ s.key
190
193
  );
191
194
  })
192
- ] }, i)),
193
- t.length > 0 && /* @__PURE__ */ n("div", { role: "group", children: t.map((i) => {
194
- const u = a++, o = u === g;
195
- return /* @__PURE__ */ m(
195
+ ] }, l)),
196
+ t.length > 0 && /* @__PURE__ */ n("div", { role: "group", "data-testid": g("group-ungrouped"), children: t.map((l) => {
197
+ const m = o++, s = m === y;
198
+ return /* @__PURE__ */ f(
196
199
  "div",
197
200
  {
198
201
  role: "option",
199
- "aria-selected": o,
200
- "aria-disabled": i.disabled,
202
+ "aria-selected": s,
203
+ "aria-disabled": l.disabled,
201
204
  "data-command-item": !0,
202
- "data-highlighted": o,
205
+ "data-highlighted": s,
203
206
  className: [
204
207
  "px-3 py-2 cursor-pointer flex items-center gap-3",
205
- o && "bg-primary text-primary-content",
206
- !o && "hover:bg-base-200",
207
- i.disabled && "opacity-50 cursor-not-allowed"
208
+ s && "bg-primary text-primary-content",
209
+ !s && "hover:bg-base-200",
210
+ l.disabled && "opacity-50 cursor-not-allowed"
208
211
  ].filter(Boolean).join(" "),
209
- onClick: () => !i.disabled && R(i.key),
210
- onMouseEnter: () => !i.disabled && w(u),
212
+ "data-testid": g(`item-${l.key}`),
213
+ onClick: () => !l.disabled && G(l.key),
214
+ onMouseEnter: () => !l.disabled && k(m),
211
215
  children: [
212
- i.icon && /* @__PURE__ */ n("span", { className: "w-5 h-5", children: i.icon }),
213
- /* @__PURE__ */ n("span", { children: i.label })
216
+ l.icon && /* @__PURE__ */ n("span", { className: "w-5 h-5", children: l.icon }),
217
+ /* @__PURE__ */ n("span", { children: l.label })
214
218
  ]
215
219
  },
216
- i.key
220
+ l.key
217
221
  );
218
222
  }) })
219
223
  ] });
@@ -222,32 +226,35 @@ const xe = (r, c, s = []) => {
222
226
  "dialog",
223
227
  {
224
228
  ref: (e) => {
225
- E.current = e, typeof h == "function" ? h(e) : h && (h.current = e);
229
+ h.current = e, typeof M == "function" ? M(e) : M && (M.current = e);
226
230
  },
227
- className: `${be} ${q}`,
228
- onClick: de,
229
- ...z,
231
+ className: `${xe} ${C}`,
232
+ onClick: pe,
233
+ "data-testid": N,
234
+ ...J,
230
235
  children: /* @__PURE__ */ n(
231
236
  "div",
232
237
  {
233
- className: `${ge} p-0 max-w-lg w-full overflow-hidden`,
238
+ className: `${ye} p-0 max-w-lg w-full overflow-hidden`,
234
239
  role: "dialog",
235
240
  "aria-modal": "true",
236
241
  "aria-label": "Command palette",
237
- children: /* @__PURE__ */ m(re.Provider, { value: ue, children: [
238
- C.length > 1 && /* @__PURE__ */ m("div", { className: "px-3 py-2 border-b border-base-content/10 flex items-center gap-2 text-sm", children: [
242
+ "data-testid": g("dialog"),
243
+ children: /* @__PURE__ */ f(se.Provider, { value: me, children: [
244
+ w.length > 1 && /* @__PURE__ */ f("div", { className: "px-3 py-2 border-b border-base-content/10 flex items-center gap-2 text-sm", children: [
239
245
  /* @__PURE__ */ n(
240
246
  "button",
241
247
  {
242
- onClick: B,
248
+ onClick: K,
243
249
  className: "hover:bg-base-200 rounded p-1",
244
250
  "aria-label": "Go back",
251
+ "data-testid": g("back"),
245
252
  children: /* @__PURE__ */ n("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 19l-7-7 7-7" }) })
246
253
  }
247
254
  ),
248
- /* @__PURE__ */ n("span", { className: "text-base-content/60", children: _ })
255
+ /* @__PURE__ */ n("span", { className: "text-base-content/60", children: te })
249
256
  ] }),
250
- /* @__PURE__ */ n("div", { className: "px-3 py-3 border-b border-base-content/10", children: /* @__PURE__ */ m("div", { className: "flex items-center gap-3", children: [
257
+ /* @__PURE__ */ n("div", { className: "px-3 py-3 border-b border-base-content/10", children: /* @__PURE__ */ f("div", { className: "flex items-center gap-3", children: [
251
258
  /* @__PURE__ */ n(
252
259
  "svg",
253
260
  {
@@ -269,46 +276,55 @@ const xe = (r, c, s = []) => {
269
276
  /* @__PURE__ */ n(
270
277
  "input",
271
278
  {
272
- ref: G,
279
+ ref: A,
273
280
  type: "text",
274
281
  className: "flex-1 bg-transparent border-none outline-none text-base placeholder:text-base-content/50",
275
282
  placeholder: I,
276
- value: k,
283
+ value: v,
277
284
  onChange: (e) => {
278
- j(e.target.value), w(0);
285
+ S(e.target.value), k(0);
279
286
  },
280
- onKeyDown: ce,
287
+ onKeyDown: ue,
281
288
  role: "combobox",
282
289
  "aria-expanded": "true",
283
- "aria-controls": `${L}-listbox`,
284
- "aria-activedescendant": N[g] ? `${L}-item-${N[g].id}` : void 0
290
+ "aria-controls": `${P}-listbox`,
291
+ "aria-activedescendant": E[y] ? `${P}-item-${E[y].id}` : void 0,
292
+ "data-testid": g("input")
285
293
  }
286
294
  )
287
295
  ] }) }),
288
296
  /* @__PURE__ */ n(
289
297
  "div",
290
298
  {
291
- ref: F,
299
+ ref: B,
292
300
  className: "max-h-80 overflow-y-auto py-2",
293
301
  role: "listbox",
294
- id: `${L}-listbox`,
295
- children: l ? P.length > 0 ? me() : /* @__PURE__ */ n("div", { className: "px-3 py-8 text-center text-base-content/60", children: y }) : r
302
+ id: `${P}-listbox`,
303
+ "data-testid": g("list"),
304
+ children: d ? H.length > 0 ? fe() : /* @__PURE__ */ n("div", { className: "px-3 py-8 text-center text-base-content/60", "data-testid": g("empty"), children: L }) : r
296
305
  }
297
306
  ),
298
- /* @__PURE__ */ n("div", { className: "px-3 py-2 border-t border-base-content/10 flex items-center justify-between text-xs text-base-content/50", children: /* @__PURE__ */ m("div", { className: "flex items-center gap-4", children: [
299
- /* @__PURE__ */ m("span", { className: "flex items-center gap-1", children: [
300
- /* @__PURE__ */ n("kbd", { className: `${Q} ${Y}`, children: "↑↓" }),
301
- " navigate"
302
- ] }),
303
- /* @__PURE__ */ m("span", { className: "flex items-center gap-1", children: [
304
- /* @__PURE__ */ n("kbd", { className: `${Q} ${Y}`, children: "↵" }),
305
- " select"
306
- ] }),
307
- /* @__PURE__ */ m("span", { className: "flex items-center gap-1", children: [
308
- /* @__PURE__ */ n("kbd", { className: `${Q} ${Y}`, children: "esc" }),
309
- " close"
310
- ] })
311
- ] }) })
307
+ /* @__PURE__ */ n(
308
+ "div",
309
+ {
310
+ className: "px-3 py-2 border-t border-base-content/10 flex items-center justify-between text-xs text-base-content/50",
311
+ "data-testid": g("footer"),
312
+ children: /* @__PURE__ */ f("div", { className: "flex items-center gap-4", children: [
313
+ /* @__PURE__ */ f("span", { className: "flex items-center gap-1", children: [
314
+ /* @__PURE__ */ n("kbd", { className: `${Z} ${_}`, children: "↑↓" }),
315
+ " navigate"
316
+ ] }),
317
+ /* @__PURE__ */ f("span", { className: "flex items-center gap-1", children: [
318
+ /* @__PURE__ */ n("kbd", { className: `${Z} ${_}`, children: "↵" }),
319
+ " select"
320
+ ] }),
321
+ /* @__PURE__ */ f("span", { className: "flex items-center gap-1", children: [
322
+ /* @__PURE__ */ n("kbd", { className: `${Z} ${_}`, children: "esc" }),
323
+ " close"
324
+ ] })
325
+ ] })
326
+ }
327
+ )
312
328
  ] })
313
329
  }
314
330
  )
@@ -316,78 +332,90 @@ const xe = (r, c, s = []) => {
316
332
  );
317
333
  }
318
334
  );
319
- se.displayName = "Command";
320
- function ye({ placeholder: r, value: c, onValueChange: s, ...d }) {
321
- const { searchValue: l, setSearchValue: p } = A();
335
+ oe.displayName = "Command";
336
+ function ke({ placeholder: r, value: c, onValueChange: a, "data-testid": i, ...d }) {
337
+ const { searchValue: p, setSearchValue: b, getTestId: x } = D();
322
338
  return /* @__PURE__ */ n(
323
339
  "input",
324
340
  {
325
341
  type: "text",
326
342
  className: "flex-1 bg-transparent border-none outline-none text-base placeholder:text-base-content/50",
327
343
  placeholder: r,
328
- value: c !== void 0 ? c : l,
329
- onChange: (I) => {
330
- const y = I.target.value;
331
- s ? s(y) : p(y);
344
+ value: c !== void 0 ? c : p,
345
+ onChange: (C) => {
346
+ const N = C.target.value;
347
+ a ? a(N) : b(N);
332
348
  },
349
+ "data-testid": i ?? x?.("input"),
333
350
  ...d
334
351
  }
335
352
  );
336
353
  }
337
- function ve({ children: r }) {
338
- const { baseId: c, currentPage: s } = A(), d = W.Children.toArray(r).filter((l) => W.isValidElement(l) ? l.type === ae ? l.props.id === s : s === "root" : !1);
339
- return /* @__PURE__ */ n("div", { role: "listbox", id: `${c}-listbox`, className: "py-2", children: d });
354
+ function we({ children: r }) {
355
+ const { baseId: c, currentPage: a, getTestId: i } = D(), d = X.Children.toArray(r).filter((p) => X.isValidElement(p) ? p.type === le ? p.props.id === a : a === "root" : !1);
356
+ return /* @__PURE__ */ n("div", { role: "listbox", id: `${c}-listbox`, className: "py-2", "data-testid": i?.("list"), children: d });
340
357
  }
341
- function ke({ heading: r, children: c }) {
342
- const { searchValue: s, filteredItems: d } = A(), p = W.Children.toArray(c).some((f) => {
343
- if (!W.isValidElement(f)) return !1;
344
- const x = f.props, I = x.value || "";
345
- return s ? d.some((y) => y.value === I || y.id === x.value) : !0;
358
+ function Ie({ heading: r, children: c }) {
359
+ const { searchValue: a, filteredItems: i, getTestId: d } = D(), b = X.Children.toArray(c).some((x) => {
360
+ if (!X.isValidElement(x)) return !1;
361
+ const I = x.props, L = I.value || "";
362
+ return a ? i.some((C) => C.value === L || C.id === I.value) : !0;
346
363
  });
347
- return s && !p ? null : /* @__PURE__ */ m("div", { role: "group", "aria-label": typeof r == "string" ? r : void 0, children: [
348
- r && /* @__PURE__ */ n("div", { className: "px-3 py-2 text-xs font-semibold text-base-content/60 uppercase tracking-wider", children: r }),
349
- c
350
- ] });
364
+ return a && !b ? null : /* @__PURE__ */ f(
365
+ "div",
366
+ {
367
+ role: "group",
368
+ "aria-label": typeof r == "string" ? r : void 0,
369
+ "data-testid": d?.(`group-${typeof r == "string" ? r : "group"}`),
370
+ children: [
371
+ r && /* @__PURE__ */ n("div", { className: "px-3 py-2 text-xs font-semibold text-base-content/60 uppercase tracking-wider", children: r }),
372
+ c
373
+ ]
374
+ }
375
+ );
351
376
  }
352
- function we({
377
+ function Ce({
353
378
  children: r,
354
379
  value: c,
355
- onSelect: s,
356
- disabled: d = !1,
357
- keywords: l = [],
358
- icon: p
380
+ onSelect: a,
381
+ disabled: i = !1,
382
+ keywords: d = [],
383
+ icon: p,
384
+ "data-testid": b
359
385
  }) {
360
386
  const {
361
- registerItem: f,
362
- unregisterItem: x,
363
- filteredItems: I,
364
- highlightedIndex: y,
365
- setHighlightedIndex: q,
366
- baseId: z
367
- } = A(), h = ne(), E = c || (typeof r == "string" ? r : "");
368
- M(() => (f(h, E, l, d), () => x(h)), [h, E, l, d, f, x]);
369
- const G = H(s);
370
- if (G.current = s, !I.some((v) => v.id === h)) return null;
371
- const L = I.filter((v) => !v.disabled).findIndex((v) => v.id === h), $ = L === y, X = () => {
372
- !d && s && s();
387
+ registerItem: x,
388
+ unregisterItem: I,
389
+ filteredItems: L,
390
+ highlightedIndex: C,
391
+ setHighlightedIndex: N,
392
+ baseId: J,
393
+ getTestId: M
394
+ } = D(), h = ae(), A = c || (typeof r == "string" ? r : "");
395
+ j(() => (x(h, A, d, i), () => I(h)), [h, A, d, i, x, I]);
396
+ const B = W(a);
397
+ if (B.current = a, !L.some((u) => u.id === h)) return null;
398
+ const q = L.filter((u) => !u.disabled).findIndex((u) => u.id === h), T = q === C, R = b ?? M?.(`item-${A || h}`), $ = () => {
399
+ !i && a && a();
373
400
  };
374
- return /* @__PURE__ */ m(
401
+ return /* @__PURE__ */ f(
375
402
  "div",
376
403
  {
377
- id: `${z}-item-${h}`,
404
+ id: `${J}-item-${h}`,
378
405
  role: "option",
379
- "aria-selected": $,
380
- "aria-disabled": d,
406
+ "aria-selected": T,
407
+ "aria-disabled": i,
381
408
  "data-command-item": !0,
382
- "data-highlighted": $,
409
+ "data-highlighted": T,
410
+ "data-testid": R,
383
411
  className: [
384
412
  "px-3 py-2 cursor-pointer flex items-center gap-3",
385
- $ && "bg-primary text-primary-content",
386
- !$ && "hover:bg-base-200",
387
- d && "opacity-50 cursor-not-allowed"
413
+ T && "bg-primary text-primary-content",
414
+ !T && "hover:bg-base-200",
415
+ i && "opacity-50 cursor-not-allowed"
388
416
  ].filter(Boolean).join(" "),
389
- onClick: X,
390
- onMouseEnter: () => !d && q(L),
417
+ onClick: $,
418
+ onMouseEnter: () => !i && N(q),
391
419
  children: [
392
420
  p && /* @__PURE__ */ n("span", { className: "w-5 h-5", children: p }),
393
421
  /* @__PURE__ */ n("span", { children: r })
@@ -395,28 +423,29 @@ function we({
395
423
  }
396
424
  );
397
425
  }
398
- function Ce({ children: r = "No results found." }) {
399
- const { filteredItems: c, searchValue: s } = A();
400
- return c.length > 0 || !s ? null : /* @__PURE__ */ n("div", { className: "px-3 py-8 text-center text-base-content/60", children: r });
426
+ function Ne({ children: r = "No results found." }) {
427
+ const { filteredItems: c, searchValue: a, getTestId: i } = D();
428
+ return c.length > 0 || !a ? null : /* @__PURE__ */ n("div", { className: "px-3 py-8 text-center text-base-content/60", "data-testid": i?.("empty"), children: r });
401
429
  }
402
- function ae({ id: r, children: c }) {
403
- const { currentPage: s } = A();
404
- return s !== r ? null : /* @__PURE__ */ n(te, { children: c });
430
+ function le({ id: r, children: c }) {
431
+ const { currentPage: a } = D();
432
+ return a !== r ? null : /* @__PURE__ */ n(re, { children: c });
405
433
  }
406
- function Ie() {
407
- return /* @__PURE__ */ n("div", { className: "my-2 border-t border-base-content/10", role: "separator" });
434
+ function $e() {
435
+ const { getTestId: r } = D();
436
+ return /* @__PURE__ */ n("div", { className: "my-2 border-t border-base-content/10", role: "separator", "data-testid": r?.("separator") });
408
437
  }
409
- const Le = Object.assign(se, {
410
- Input: ye,
411
- List: ve,
412
- Group: ke,
413
- Item: we,
414
- Empty: Ce,
415
- Page: ae,
416
- Separator: Ie
438
+ const Ve = Object.assign(oe, {
439
+ Input: ke,
440
+ List: we,
441
+ Group: Ie,
442
+ Item: Ce,
443
+ Empty: Ne,
444
+ Page: le,
445
+ Separator: $e
417
446
  });
418
447
  export {
419
- Le as Command,
420
- Le as default
448
+ Ve as Command,
449
+ Ve as default
421
450
  };
422
451
  //# sourceMappingURL=Command.js.map