@overdoser/react-toolkit 0.17.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/AGENTS.md +51 -7
  2. package/CHANGELOG.md +149 -0
  3. package/components/Accordion/Accordion.d.ts +94 -0
  4. package/components/Accordion/Accordion.js +180 -0
  5. package/components/Accordion/Accordion.module.scss.js +36 -0
  6. package/components/Accordion/index.d.ts +2 -0
  7. package/components/Alert/Alert.d.ts +29 -1
  8. package/components/Alert/Alert.js +44 -30
  9. package/components/Alert/Alert.module.scss.js +24 -16
  10. package/components/Alert/index.d.ts +1 -1
  11. package/components/Card/Card.d.ts +86 -0
  12. package/components/Card/Card.js +132 -0
  13. package/components/Card/Card.module.scss.js +60 -0
  14. package/components/Card/index.d.ts +2 -0
  15. package/components/Chip/Chip.d.ts +86 -0
  16. package/components/Chip/Chip.js +141 -0
  17. package/components/Chip/Chip.module.scss.js +59 -0
  18. package/components/Chip/index.d.ts +2 -0
  19. package/components/CodeBlock/CodeBlock.d.ts +78 -0
  20. package/components/CodeBlock/CodeBlock.js +120 -0
  21. package/components/CodeBlock/CodeBlock.module.scss.js +43 -0
  22. package/components/CodeBlock/index.d.ts +2 -0
  23. package/components/CommandPalette/CommandPalette.d.ts +141 -0
  24. package/components/CommandPalette/CommandPalette.js +397 -0
  25. package/components/CommandPalette/CommandPalette.module.scss.js +49 -0
  26. package/components/CommandPalette/index.d.ts +2 -0
  27. package/components/ConfirmDialog/ConfirmDialog.d.ts +119 -0
  28. package/components/ConfirmDialog/ConfirmDialog.js +201 -0
  29. package/components/ConfirmDialog/ConfirmDialog.module.scss.js +21 -0
  30. package/components/ConfirmDialog/index.d.ts +2 -0
  31. package/components/Drawer/Drawer.d.ts +1 -0
  32. package/components/Drawer/Drawer.js +35 -36
  33. package/components/Drawer/Drawer.module.scss.js +20 -18
  34. package/components/Dropdown/Dropdown.d.ts +47 -7
  35. package/components/Dropdown/Dropdown.js +174 -81
  36. package/components/Dropdown/Dropdown.module.scss.js +40 -22
  37. package/components/Dropdown/DropdownItem.d.ts +31 -2
  38. package/components/Dropdown/DropdownItem.js +54 -27
  39. package/components/Dropdown/DropdownLabel.d.ts +11 -0
  40. package/components/Dropdown/DropdownLabel.js +11 -0
  41. package/components/Dropdown/DropdownSeparator.d.ts +12 -0
  42. package/components/Dropdown/DropdownSeparator.js +11 -0
  43. package/components/Dropdown/dropdownContext.d.ts +6 -0
  44. package/components/Dropdown/dropdownContext.js +5 -0
  45. package/components/Dropdown/index.d.ts +8 -2
  46. package/components/Dropdown/useContextMenu.d.ts +32 -0
  47. package/components/Dropdown/useContextMenu.js +18 -0
  48. package/components/EmptyState/EmptyState.d.ts +53 -0
  49. package/components/EmptyState/EmptyState.js +55 -0
  50. package/components/EmptyState/EmptyState.module.scss.js +25 -0
  51. package/components/EmptyState/index.d.ts +2 -0
  52. package/components/Form/FormField.js +25 -24
  53. package/components/ImageViewer/ImageViewer.d.ts +105 -0
  54. package/components/ImageViewer/ImageViewer.js +201 -0
  55. package/components/ImageViewer/ImageViewer.module.scss.js +47 -0
  56. package/components/ImageViewer/index.d.ts +4 -0
  57. package/components/ImageViewer/useZoomPan.d.ts +94 -0
  58. package/components/ImageViewer/useZoomPan.js +141 -0
  59. package/components/Kbd/Kbd.d.ts +26 -0
  60. package/components/Kbd/Kbd.js +22 -0
  61. package/components/Kbd/Kbd.module.scss.js +17 -0
  62. package/components/Kbd/index.d.ts +2 -0
  63. package/components/KeyValueList/KeyValueList.d.ts +84 -0
  64. package/components/KeyValueList/KeyValueList.js +127 -0
  65. package/components/KeyValueList/KeyValueList.module.scss.js +43 -0
  66. package/components/KeyValueList/index.d.ts +2 -0
  67. package/components/Loader/Loader.d.ts +104 -0
  68. package/components/Loader/Loader.js +186 -0
  69. package/components/Loader/Loader.module.scss.js +70 -0
  70. package/components/Loader/index.d.ts +2 -0
  71. package/components/Modal/Modal.d.ts +1 -0
  72. package/components/Modal/Modal.js +40 -41
  73. package/components/Modal/Modal.module.scss.js +18 -16
  74. package/components/PageHeader/PageHeader.d.ts +61 -0
  75. package/components/PageHeader/PageHeader.js +73 -0
  76. package/components/PageHeader/PageHeader.module.scss.js +43 -0
  77. package/components/PageHeader/index.d.ts +2 -0
  78. package/components/ProgressBar/ProgressBar.d.ts +74 -0
  79. package/components/ProgressBar/ProgressBar.js +90 -0
  80. package/components/ProgressBar/ProgressBar.module.scss.js +51 -0
  81. package/components/ProgressBar/index.d.ts +2 -0
  82. package/components/RelativeTime/RelativeTime.d.ts +45 -0
  83. package/components/RelativeTime/RelativeTime.js +43 -0
  84. package/components/RelativeTime/RelativeTime.module.scss.js +7 -0
  85. package/components/RelativeTime/index.d.ts +2 -0
  86. package/components/SegmentedControl/SegmentedControl.d.ts +84 -0
  87. package/components/SegmentedControl/SegmentedControl.js +131 -0
  88. package/components/SegmentedControl/SegmentedControl.module.scss.js +39 -0
  89. package/components/SegmentedControl/index.d.ts +2 -0
  90. package/components/SplitPane/SplitPane.d.ts +61 -0
  91. package/components/SplitPane/SplitPane.js +171 -0
  92. package/components/SplitPane/SplitPane.module.scss.js +25 -0
  93. package/components/SplitPane/index.d.ts +2 -0
  94. package/components/StatCard/StatCard.d.ts +105 -0
  95. package/components/StatCard/StatCard.js +127 -0
  96. package/components/StatCard/StatCard.module.scss.js +72 -0
  97. package/components/StatCard/index.d.ts +2 -0
  98. package/components/StatusDot/StatusDot.d.ts +33 -0
  99. package/components/StatusDot/StatusDot.js +39 -0
  100. package/components/StatusDot/StatusDot.module.scss.js +32 -0
  101. package/components/StatusDot/index.d.ts +2 -0
  102. package/components/Table/Table.d.ts +100 -2
  103. package/components/Table/Table.js +371 -210
  104. package/components/Table/Table.module.scss.js +68 -46
  105. package/components/Table/index.d.ts +1 -1
  106. package/components/ThemeToggle/ThemeToggle.d.ts +38 -0
  107. package/components/ThemeToggle/ThemeToggle.js +97 -0
  108. package/components/ThemeToggle/ThemeToggle.module.scss.js +23 -0
  109. package/components/ThemeToggle/index.d.ts +2 -0
  110. package/components/inputs/Checkbox/Checkbox.d.ts +2 -0
  111. package/components/inputs/Checkbox/Checkbox.js +29 -28
  112. package/components/inputs/Checkbox/Checkbox.module.scss.js +8 -6
  113. package/components/inputs/Input/Input.d.ts +33 -1
  114. package/components/inputs/Input/Input.js +94 -35
  115. package/components/inputs/Input/Input.module.scss.js +14 -12
  116. package/components/inputs/Radio/Radio.d.ts +5 -4
  117. package/components/inputs/Radio/Radio.js +55 -50
  118. package/components/inputs/Radio/Radio.module.scss.js +12 -10
  119. package/components/inputs/SearchInput/SearchInput.d.ts +57 -0
  120. package/components/inputs/SearchInput/SearchInput.js +116 -0
  121. package/components/inputs/SearchInput/SearchInput.module.scss.js +13 -0
  122. package/components/inputs/SearchInput/index.d.ts +2 -0
  123. package/components/inputs/Select/Select.d.ts +52 -0
  124. package/components/inputs/Select/Select.js +494 -385
  125. package/components/inputs/Select/Select.module.scss.js +34 -30
  126. package/components/inputs/Switch/Switch.d.ts +15 -0
  127. package/components/inputs/Switch/Switch.js +8 -0
  128. package/components/inputs/Switch/index.d.ts +2 -0
  129. package/hooks/useDebouncedValue.d.ts +15 -0
  130. package/hooks/useDebouncedValue.js +15 -0
  131. package/hooks/useElementSize.d.ts +20 -0
  132. package/hooks/useElementSize.js +23 -0
  133. package/hooks/useKeyboard.d.ts +49 -5
  134. package/hooks/useKeyboard.js +66 -16
  135. package/hooks/useMediaQuery.d.ts +14 -0
  136. package/hooks/useMediaQuery.js +16 -0
  137. package/hooks/useNow.d.ts +14 -0
  138. package/hooks/useNow.js +35 -0
  139. package/hooks/usePersistedState.d.ts +30 -0
  140. package/hooks/usePersistedState.js +96 -0
  141. package/hooks/useResizable.d.ts +66 -0
  142. package/hooks/useResizable.js +105 -0
  143. package/hooks/useTheme.d.ts +33 -0
  144. package/hooks/useTheme.js +27 -0
  145. package/index.css +1 -1
  146. package/index.d.ts +60 -4
  147. package/index.js +208 -130
  148. package/index.layered.css +1 -1
  149. package/llms.txt +659 -25
  150. package/manifest.json +1797 -76
  151. package/package.json +1 -1
  152. package/recipes/confirm-modal.tsx +65 -53
  153. package/recipes/floating-copy-button.tsx +32 -28
  154. package/utils/formatBytes.d.ts +21 -0
  155. package/utils/formatBytes.js +14 -0
  156. package/utils/index.d.ts +6 -0
  157. package/utils/themeScript.d.ts +17 -0
  158. package/utils/themeScript.js +9 -0
  159. package/utils/timeAgo.d.ts +33 -0
  160. package/utils/timeAgo.js +37 -0
@@ -0,0 +1,397 @@
1
+ import { jsx as i, jsxs as y, Fragment as ie } from "react/jsx-runtime";
2
+ import { forwardRef as $e, useId as Ee, useRef as F, useState as U, useCallback as T, useEffect as K, useMemo as X } from "react";
3
+ import { createPortal as Pe } from "react-dom";
4
+ import f from "clsx";
5
+ import o from "./CommandPalette.module.scss.js";
6
+ import { useFocusTrap as Re } from "../../hooks/useFocusTrap.js";
7
+ import { useEscapeLayer as Be, EscapeLayerProvider as _e } from "../../hooks/useEscapeLayer.js";
8
+ import { useKeyboard as Fe } from "../../hooks/useKeyboard.js";
9
+ import { Kbd as A } from "../Kbd/Kbd.js";
10
+ import { Spinner as ce } from "../Spinner/Spinner.js";
11
+ function ue(n, l) {
12
+ const s = l.trim().toLowerCase();
13
+ if (!s) return [];
14
+ const h = n.toLowerCase(), u = h.indexOf(s);
15
+ if (u >= 0) return Array.from({ length: s.length }, (v, b) => u + b);
16
+ const p = [];
17
+ let w = 0;
18
+ for (const v of s) {
19
+ if (v === " ") continue;
20
+ const b = h.indexOf(v, w);
21
+ if (b < 0) return null;
22
+ p.push(b), w = b + 1;
23
+ }
24
+ return p;
25
+ }
26
+ function de(n, l) {
27
+ const s = ue(n, l);
28
+ if (s === null) return !1;
29
+ if (s.length === 0) return 1;
30
+ const h = n.toLowerCase(), u = l.trim().toLowerCase(), p = s[0];
31
+ if (h.indexOf(u) === p)
32
+ return 100 + (p === 0 || /\s/.test(h[p - 1]) ? 20 : 0) - Math.min(p, 30);
33
+ const w = s[s.length - 1] - s[0] - (s.length - 1);
34
+ return Math.max(1, 50 - w - p);
35
+ }
36
+ function Ke(n, l) {
37
+ if (!l.trim()) return 1;
38
+ let s = !1;
39
+ typeof n.label == "string" && (s = de(n.label, l));
40
+ for (const h of n.keywords ?? []) {
41
+ const u = de(h, l);
42
+ u !== !1 && (s = Math.max(s === !1 ? 0 : s, u - 10));
43
+ }
44
+ return s;
45
+ }
46
+ function Ue(n, l, s, h) {
47
+ if (!s || typeof n != "string" || !l.trim()) return n;
48
+ const u = ue(n, l);
49
+ if (!u || u.length === 0) return n;
50
+ const p = new Set(u), w = [];
51
+ let v = "", b = !1;
52
+ const D = () => {
53
+ v && (w.push(b ? /* @__PURE__ */ i("mark", { className: h, children: v }, w.length) : v), v = "");
54
+ };
55
+ for (let z = 0; z < n.length; z++) {
56
+ const E = p.has(z);
57
+ E !== b && (D(), b = E), v += n[z];
58
+ }
59
+ return D(), w;
60
+ }
61
+ function Oe(n = !1) {
62
+ const [l, s] = U(n), h = T(() => s((u) => !u), []);
63
+ return X(
64
+ () => ({ open: l, setOpen: s, toggle: h, paletteProps: { open: l, onOpenChange: s } }),
65
+ [l, h]
66
+ );
67
+ }
68
+ const je = $e(
69
+ ({
70
+ open: n,
71
+ onOpenChange: l,
72
+ items: s,
73
+ onSelect: h,
74
+ closeOnSelect: u = !0,
75
+ query: p,
76
+ defaultQuery: w = "",
77
+ onQueryChange: v,
78
+ filter: b = Ke,
79
+ loading: D = !1,
80
+ loadingMessage: z = "Searching…",
81
+ emptyMessage: E = "No results",
82
+ placeholder: fe = "Type a command or search…",
83
+ hotkey: P = "mod+k",
84
+ recentIds: j,
85
+ recentLabel: Y = "Recent",
86
+ maxResults: Z = 50,
87
+ groupOrder: H,
88
+ footer: q,
89
+ escapeClearsQuery: he = !1,
90
+ highlightMatches: me = !0,
91
+ renderItem: O,
92
+ "aria-label": pe = "Command palette",
93
+ classes: d,
94
+ className: be,
95
+ style: ge
96
+ }, R) => {
97
+ const G = Ee(), ee = F(null), Q = F(null), ve = F(null), ke = (e) => {
98
+ ee.current = e, typeof R == "function" ? R(e) : R && (R.current = e);
99
+ }, [ye, we] = U(w), M = p ?? ye, B = T(
100
+ (e) => {
101
+ p === void 0 && we(e), v?.(e);
102
+ },
103
+ [p, v]
104
+ ), [N, V] = U([]), te = N.length ? N[N.length - 1].children ?? [] : s, [g, S] = U(0);
105
+ K(() => {
106
+ n && (V([]), S(0));
107
+ }, [n]);
108
+ const { sections: xe, flat: c } = X(() => {
109
+ const e = M.trim(), r = [];
110
+ te.forEach((a, m) => {
111
+ let C = !0;
112
+ b && (C = b(a, M)), C !== !1 && r.push({ item: a, score: (C === !0 ? 1 : C) * 1e6 - m });
113
+ }), b && e && r.sort((a, m) => m.score - a.score);
114
+ let t = r.map((a) => a.item);
115
+ const k = [];
116
+ if (!e && j?.length && N.length === 0) {
117
+ for (const m of j) {
118
+ const C = t.find((Te) => Te.id === m);
119
+ C && k.push(C);
120
+ }
121
+ const a = new Set(k.map((m) => m.id));
122
+ t = t.filter((m) => !a.has(m.id));
123
+ }
124
+ let I = Z;
125
+ const $ = (a) => {
126
+ const m = a.slice(0, Math.max(0, I));
127
+ return I -= m.length, m;
128
+ }, L = [];
129
+ k.length && L.push({ key: "__recent", label: Y, items: $(k) });
130
+ const x = /* @__PURE__ */ new Map(), W = [];
131
+ for (const a of t)
132
+ a.group ? (x.has(a.group) || x.set(a.group, []), x.get(a.group).push(a)) : W.push(a);
133
+ W.length && L.push({ key: "__ungrouped", label: null, items: $(W) });
134
+ const ze = [...(H ?? []).filter((a) => x.has(a)), ...[...x.keys()].filter((a) => !H?.includes(a))];
135
+ for (const a of ze) {
136
+ const m = $(x.get(a));
137
+ m.length && L.push({ key: a, label: a, items: m });
138
+ }
139
+ const Ae = L.flatMap((a) => a.items);
140
+ return { sections: L, flat: Ae };
141
+ }, [te, M, b, j, Y, Z, H, N.length]);
142
+ K(() => {
143
+ const e = c.findIndex((r) => !r.disabled);
144
+ S((r) => c[r] && !c[r].disabled ? r : e < 0 ? 0 : e);
145
+ }, [c]), K(() => {
146
+ Q.current?.querySelector(`[data-index="${g}"]`)?.scrollIntoView?.({ block: "nearest" });
147
+ }, [g]);
148
+ const re = T(
149
+ (e, r = !0) => {
150
+ if (!c.length) return;
151
+ let t = g;
152
+ for (let k = 0; k < c.length && (t += e, r ? t = (t + c.length) % c.length : t = Math.max(0, Math.min(c.length - 1, t)), !!c[t].disabled); k++)
153
+ ;
154
+ S(t);
155
+ },
156
+ [c, g]
157
+ ), _ = T(
158
+ (e) => {
159
+ if (!c.length) return;
160
+ let r = Math.max(0, Math.min(c.length - 1, e));
161
+ const t = e >= g ? -1 : 1;
162
+ for (; c[r]?.disabled; )
163
+ if (r += t, r < 0 || r >= c.length) return;
164
+ S(r);
165
+ },
166
+ [c, g]
167
+ ), ne = T(
168
+ (e) => {
169
+ if (!e.disabled) {
170
+ if (e.children?.length) {
171
+ V((r) => [...r, e]), B(""), S(0);
172
+ return;
173
+ }
174
+ e.onSelect?.(), h?.(e), u && l(!1);
175
+ }
176
+ },
177
+ [h, u, l, B]
178
+ ), ae = T(
179
+ (e) => {
180
+ V((r) => r.slice(0, e)), S(0);
181
+ },
182
+ []
183
+ ), Ne = X(
184
+ () => P ? { [P]: () => l(!n) } : {},
185
+ [P, n, l]
186
+ );
187
+ Fe(Ne, { active: P !== !1 }), Re(ee, n);
188
+ const De = Be(() => {
189
+ if (he && M) {
190
+ B("");
191
+ return;
192
+ }
193
+ l(!1);
194
+ }, n);
195
+ K(() => {
196
+ if (!n) return;
197
+ const e = document.body.style.overflow;
198
+ return document.body.style.overflow = "hidden", () => {
199
+ document.body.style.overflow = e;
200
+ };
201
+ }, [n]);
202
+ const J = F(!1), Me = (e) => {
203
+ J.current = e.target === e.currentTarget;
204
+ }, Se = (e) => {
205
+ J.current && e.target === e.currentTarget && l(!1), J.current = !1;
206
+ }, Ie = (e) => {
207
+ switch (e.key) {
208
+ case "ArrowDown":
209
+ e.preventDefault(), re(1);
210
+ break;
211
+ case "ArrowUp":
212
+ e.preventDefault(), re(-1);
213
+ break;
214
+ case "Home":
215
+ e.preventDefault(), _(0);
216
+ break;
217
+ case "End":
218
+ e.preventDefault(), _(c.length - 1);
219
+ break;
220
+ case "PageDown":
221
+ e.preventDefault(), _(g + 10);
222
+ break;
223
+ case "PageUp":
224
+ e.preventDefault(), _(g - 10);
225
+ break;
226
+ case "Enter": {
227
+ if (D) return;
228
+ const r = c[g];
229
+ if (!r) return;
230
+ if (e.preventDefault(), r.href) {
231
+ Q.current?.querySelector(`[data-index="${g}"]`)?.click();
232
+ return;
233
+ }
234
+ ne(r);
235
+ break;
236
+ }
237
+ case "Backspace":
238
+ !M && N.length && (e.preventDefault(), ae(N.length - 1));
239
+ break;
240
+ }
241
+ };
242
+ if (!n) return null;
243
+ const se = `${G}-list`, oe = (e) => `${G}-opt-${e}`, Le = c[g], Ce = /* @__PURE__ */ y(ie, { children: [
244
+ /* @__PURE__ */ y("span", { children: [
245
+ /* @__PURE__ */ i(A, { size: "sm", children: "↑" }),
246
+ /* @__PURE__ */ i(A, { size: "sm", children: "↓" }),
247
+ " navigate"
248
+ ] }),
249
+ /* @__PURE__ */ y("span", { children: [
250
+ /* @__PURE__ */ i(A, { size: "sm", children: "↵" }),
251
+ " select"
252
+ ] }),
253
+ /* @__PURE__ */ y("span", { children: [
254
+ /* @__PURE__ */ i(A, { size: "sm", children: "esc" }),
255
+ " close"
256
+ ] })
257
+ ] });
258
+ let le = -1;
259
+ return Pe(
260
+ /* @__PURE__ */ i(
261
+ "div",
262
+ {
263
+ className: f(o.backdrop, d?.backdrop),
264
+ onMouseDown: Me,
265
+ onMouseUp: Se,
266
+ role: "presentation",
267
+ children: /* @__PURE__ */ i(
268
+ "div",
269
+ {
270
+ ref: ke,
271
+ className: f(o.panel, d?.panel, be),
272
+ style: ge,
273
+ role: "dialog",
274
+ "aria-modal": "true",
275
+ "aria-label": pe,
276
+ children: /* @__PURE__ */ y(_e, { value: De, children: [
277
+ /* @__PURE__ */ y("div", { className: f(o.header, d?.header), children: [
278
+ N.map((e, r) => /* @__PURE__ */ i(
279
+ "button",
280
+ {
281
+ type: "button",
282
+ className: f(o.breadcrumb, d?.breadcrumb),
283
+ onClick: () => ae(r + 1 === N.length ? r : r + 1),
284
+ "aria-label": typeof e.label == "string" ? `Back to ${e.label}` : void 0,
285
+ children: e.label
286
+ },
287
+ e.id
288
+ )),
289
+ /* @__PURE__ */ i(
290
+ "input",
291
+ {
292
+ ref: ve,
293
+ className: f(o.input, d?.input),
294
+ type: "text",
295
+ role: "combobox",
296
+ "aria-expanded": "true",
297
+ "aria-controls": se,
298
+ "aria-activedescendant": Le ? oe(g) : void 0,
299
+ "aria-autocomplete": "list",
300
+ autoComplete: "off",
301
+ spellCheck: !1,
302
+ placeholder: fe,
303
+ value: M,
304
+ onChange: (e) => B(e.target.value),
305
+ onKeyDown: Ie
306
+ }
307
+ ),
308
+ D && /* @__PURE__ */ i(ce, { size: "sm", label: "Searching", className: o.headerSpinner })
309
+ ] }),
310
+ /* @__PURE__ */ y("div", { ref: Q, id: se, role: "listbox", className: f(o.list, d?.list), children: [
311
+ D && /* @__PURE__ */ y("div", { className: f(o.message, o.loading, d?.loading), role: "status", children: [
312
+ /* @__PURE__ */ i(ce, { size: "sm", label: "" }),
313
+ " ",
314
+ z
315
+ ] }),
316
+ !D && c.length === 0 && /* @__PURE__ */ i("div", { className: f(o.message, o.empty, d?.empty), role: "status", children: E }),
317
+ !D && xe.map((e) => {
318
+ const r = `${G}-group-${e.key.replace(/\s+/g, "-")}`;
319
+ return /* @__PURE__ */ y(
320
+ "div",
321
+ {
322
+ role: e.label !== null ? "group" : void 0,
323
+ "aria-labelledby": e.label !== null ? r : void 0,
324
+ className: f(o.group, d?.group),
325
+ children: [
326
+ e.label !== null && /* @__PURE__ */ i("div", { id: r, className: f(o.groupLabel, d?.groupLabel), children: e.label }),
327
+ e.items.map((t) => {
328
+ le += 1;
329
+ const k = le, I = k === g, $ = t.href ? "a" : "div", L = O ? O(t, { active: I, query: M }) : /* @__PURE__ */ y(ie, { children: [
330
+ t.icon && /* @__PURE__ */ i("span", { className: f(o.itemIcon, d?.itemIcon), "aria-hidden": "true", children: t.icon }),
331
+ /* @__PURE__ */ y("span", { className: o.itemText, children: [
332
+ /* @__PURE__ */ i("span", { className: f(o.itemLabel, d?.itemLabel), children: Ue(t.label, M, me, f(o.match, d?.match)) }),
333
+ t.description && /* @__PURE__ */ i("span", { className: f(o.itemDescription, d?.itemDescription), children: t.description })
334
+ ] }),
335
+ t.children?.length ? /* @__PURE__ */ i("span", { className: o.itemChevron, "aria-hidden": "true", children: "›" }) : null,
336
+ t.shortcut && /* @__PURE__ */ i("span", { className: f(o.itemShortcut, d?.itemShortcut), "aria-hidden": "true", children: Array.isArray(t.shortcut) ? /* @__PURE__ */ i(A, { size: "sm", keys: t.shortcut }) : /* @__PURE__ */ i(A, { size: "sm", children: t.shortcut }) })
337
+ ] });
338
+ return /* @__PURE__ */ i(
339
+ $,
340
+ {
341
+ id: oe(k),
342
+ "data-index": k,
343
+ role: "option",
344
+ "aria-selected": I,
345
+ "aria-disabled": t.disabled || void 0,
346
+ href: t.href,
347
+ tabIndex: -1,
348
+ className: f(
349
+ o.item,
350
+ I && o.itemActive,
351
+ t.disabled && o.itemDisabled,
352
+ d?.item,
353
+ I && d?.itemActive
354
+ ),
355
+ onMouseMove: () => {
356
+ !t.disabled && g !== k && S(k);
357
+ },
358
+ onMouseDown: (x) => x.preventDefault(),
359
+ onClick: (x) => {
360
+ if (t.disabled) {
361
+ x.preventDefault();
362
+ return;
363
+ }
364
+ if (t.href) {
365
+ t.onSelect?.(), h?.(t), u && l(!1);
366
+ return;
367
+ }
368
+ ne(t);
369
+ },
370
+ children: L
371
+ },
372
+ t.id
373
+ );
374
+ })
375
+ ]
376
+ },
377
+ e.key
378
+ );
379
+ })
380
+ ] }),
381
+ q !== null && /* @__PURE__ */ i("div", { className: f(o.footer, d?.footer), children: q === void 0 ? Ce : q })
382
+ ] })
383
+ }
384
+ )
385
+ }
386
+ ),
387
+ document.body
388
+ );
389
+ }
390
+ );
391
+ je.displayName = "CommandPalette";
392
+ export {
393
+ je as CommandPalette,
394
+ Ke as defaultFilter,
395
+ ue as matchIndices,
396
+ Oe as useCommandPalette
397
+ };
@@ -0,0 +1,49 @@
1
+ const e = "crk-backdrop-85I58", t = "crk-panel-RBr7A", c = "crk-header-WpV0d", r = "crk-breadcrumb-yrjqZ", o = "crk-input-1yX4p", i = "crk-headerSpinner-vWtoV", n = "crk-list-Z8b3Q", s = "crk-group-hKsgv", m = "crk-groupLabel-S-h3h", a = "crk-item-TULJl", p = "crk-itemActive-T5Hpv", k = "crk-itemDisabled-A-ped", l = "crk-itemIcon-Ruqhi", d = "crk-itemText-nEkyw", h = "crk-itemLabel-03iZM", b = "crk-itemDescription-ehmYh", u = "crk-itemChevron-234PX", g = "crk-itemShortcut-OHXBv", v = "crk-match--l5e2", S = "crk-message-TgWpQ", L = "crk-loading-fcSft", f = "crk-footer-bwQFJ", D = {
2
+ backdrop: e,
3
+ panel: t,
4
+ header: c,
5
+ breadcrumb: r,
6
+ input: o,
7
+ headerSpinner: i,
8
+ list: n,
9
+ group: s,
10
+ groupLabel: m,
11
+ item: a,
12
+ itemActive: p,
13
+ itemDisabled: k,
14
+ itemIcon: l,
15
+ itemText: d,
16
+ itemLabel: h,
17
+ itemDescription: b,
18
+ itemChevron: u,
19
+ itemShortcut: g,
20
+ match: v,
21
+ message: S,
22
+ loading: L,
23
+ footer: f
24
+ };
25
+ export {
26
+ e as backdrop,
27
+ r as breadcrumb,
28
+ D as default,
29
+ f as footer,
30
+ s as group,
31
+ m as groupLabel,
32
+ c as header,
33
+ i as headerSpinner,
34
+ o as input,
35
+ a as item,
36
+ p as itemActive,
37
+ u as itemChevron,
38
+ b as itemDescription,
39
+ k as itemDisabled,
40
+ l as itemIcon,
41
+ h as itemLabel,
42
+ g as itemShortcut,
43
+ d as itemText,
44
+ n as list,
45
+ L as loading,
46
+ v as match,
47
+ S as message,
48
+ t as panel
49
+ };
@@ -0,0 +1,2 @@
1
+ export { CommandPalette, useCommandPalette, defaultFilter, matchIndices } from './CommandPalette';
2
+ export type { CommandItem, CommandPaletteProps, CommandPaletteClasses, CommandItemRenderContext, } from './CommandPalette';
@@ -0,0 +1,119 @@
1
+ import { CSSProperties, ReactNode } from 'react';
2
+ export interface ConfirmDialogClasses {
3
+ modal: string;
4
+ header: string;
5
+ body: string;
6
+ description: string;
7
+ icon: string;
8
+ input: string;
9
+ error: string;
10
+ footer: string;
11
+ cancel: string;
12
+ confirm: string;
13
+ }
14
+ export interface ConfirmDialogProps {
15
+ /** Whether the dialog is visible. */
16
+ open: boolean;
17
+ /**
18
+ * Called when the user confirms. Return a promise to put the confirm button
19
+ * into its loading state and lock cancel / Escape / backdrop until it
20
+ * settles. A rejection keeps the dialog open and shows the error under the
21
+ * body. The dialog never closes itself — set `open={false}` in `onConfirm`
22
+ * (or use `useConfirm()`, which does).
23
+ */
24
+ onConfirm: () => void | Promise<void>;
25
+ /** Called on the cancel button, Escape, the header "×" and backdrop click (never while `onConfirm` is pending). */
26
+ onCancel: () => void;
27
+ /** Dialog heading. @default 'Are you sure?' */
28
+ title?: ReactNode;
29
+ /** Body text, rendered first (muted). */
30
+ description?: ReactNode;
31
+ /** Extra body content, rendered after `description`. */
32
+ children?: ReactNode;
33
+ /** Confirm button label. @default 'Confirm' */
34
+ confirmLabel?: ReactNode;
35
+ /** Cancel button label. @default 'Cancel' */
36
+ cancelLabel?: ReactNode;
37
+ /** Destructive action: danger-coloured confirm button, warning icon, focus starts on Cancel. @default false */
38
+ danger?: boolean;
39
+ /**
40
+ * Type-to-confirm. When set, an input ("Type `<text>` to confirm") must
41
+ * match exactly before the confirm button enables.
42
+ */
43
+ requireText?: string;
44
+ /** Leading icon next to the title. `false` hides it. @default a warning triangle when `danger`, otherwise none */
45
+ icon?: ReactNode | false;
46
+ /** Which button receives focus when the dialog opens (the input wins when `requireText` is set). @default 'cancel' when `danger`, else 'confirm' */
47
+ autoFocus?: 'confirm' | 'cancel';
48
+ /** Close (cancel) when the backdrop is clicked. @default true */
49
+ closeOnBackdrop?: boolean;
50
+ /** Turns a rejected `onConfirm` into the error text shown under the body. @default (err) => String(err?.message ?? err) */
51
+ errorMessage?: (err: unknown) => ReactNode;
52
+ /** Accessible label; used when there is no `title` (a string `title` labels the dialog itself). */
53
+ 'aria-label'?: string;
54
+ /** Override class names on internal elements. */
55
+ classes?: Partial<ConfirmDialogClasses>;
56
+ className?: string;
57
+ style?: CSSProperties;
58
+ }
59
+ /**
60
+ * Confirmation dialog built on `Modal` (size `sm`): title, body, Cancel /
61
+ * Confirm buttons, optional `danger` styling, async `onConfirm` with loading
62
+ * and error states, and `requireText` type-to-confirm. Controlled via `open`.
63
+ *
64
+ * For a promise-style API (`if (await confirm({ … }))`) mount
65
+ * `ConfirmProvider` once and call `useConfirm()`.
66
+ *
67
+ * @example
68
+ * <ConfirmDialog
69
+ * open={open}
70
+ * danger
71
+ * title="Delete project?"
72
+ * description="This cannot be undone."
73
+ * confirmLabel="Delete"
74
+ * onConfirm={async () => { await deleteProject(id); setOpen(false); }}
75
+ * onCancel={() => setOpen(false)}
76
+ * />
77
+ */
78
+ export declare const ConfirmDialog: import('react').ForwardRefExoticComponent<ConfirmDialogProps & import('react').RefAttributes<HTMLDivElement>>;
79
+ /** Options for `useConfirm()`'s `confirm(options)`. */
80
+ export type ConfirmOptions = Omit<ConfirmDialogProps, 'open' | 'onConfirm' | 'onCancel' | 'children'> & {
81
+ /** Extra body content (same slot as `ConfirmDialog`'s `children`). */
82
+ body?: ReactNode;
83
+ /**
84
+ * Runs when the user confirms, before the promise resolves `true`. Return a
85
+ * promise for a loading state; a rejection shows the error and keeps the
86
+ * dialog open (the `confirm()` promise stays pending).
87
+ */
88
+ onConfirm?: () => void | Promise<void>;
89
+ };
90
+ export type ConfirmFn = (options?: ConfirmOptions) => Promise<boolean>;
91
+ export interface ConfirmProviderProps {
92
+ children?: ReactNode;
93
+ /** Defaults merged under every `confirm()` call's options (labels, `closeOnBackdrop`, `classes`…). */
94
+ defaults?: Partial<ConfirmOptions>;
95
+ }
96
+ /**
97
+ * Mounts one `ConfirmDialog` and provides `useConfirm()`.
98
+ *
99
+ * @example
100
+ * <ConfirmProvider>
101
+ * <App />
102
+ * </ConfirmProvider>
103
+ */
104
+ export declare function ConfirmProvider({ children, defaults }: ConfirmProviderProps): import("react/jsx-runtime").JSX.Element;
105
+ export declare namespace ConfirmProvider {
106
+ var displayName: string;
107
+ }
108
+ /**
109
+ * Promise-style confirmation. Requires a `ConfirmProvider` above.
110
+ *
111
+ * @example
112
+ * const confirm = useConfirm();
113
+ * async function remove() {
114
+ * if (await confirm({ title: 'Delete project?', danger: true, confirmLabel: 'Delete' })) {
115
+ * await api.delete(id);
116
+ * }
117
+ * }
118
+ */
119
+ export declare function useConfirm(): ConfirmFn;