@overdoser/react-toolkit 0.18.0 → 0.20.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 (157) hide show
  1. package/AGENTS.md +51 -7
  2. package/CHANGELOG.md +162 -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/Modal/Modal.d.ts +1 -0
  68. package/components/Modal/Modal.js +40 -41
  69. package/components/Modal/Modal.module.scss.js +18 -16
  70. package/components/PageHeader/PageHeader.d.ts +61 -0
  71. package/components/PageHeader/PageHeader.js +73 -0
  72. package/components/PageHeader/PageHeader.module.scss.js +43 -0
  73. package/components/PageHeader/index.d.ts +2 -0
  74. package/components/ProgressBar/ProgressBar.d.ts +74 -0
  75. package/components/ProgressBar/ProgressBar.js +90 -0
  76. package/components/ProgressBar/ProgressBar.module.scss.js +51 -0
  77. package/components/ProgressBar/index.d.ts +2 -0
  78. package/components/RelativeTime/RelativeTime.d.ts +45 -0
  79. package/components/RelativeTime/RelativeTime.js +43 -0
  80. package/components/RelativeTime/RelativeTime.module.scss.js +7 -0
  81. package/components/RelativeTime/index.d.ts +2 -0
  82. package/components/SegmentedControl/SegmentedControl.d.ts +84 -0
  83. package/components/SegmentedControl/SegmentedControl.js +131 -0
  84. package/components/SegmentedControl/SegmentedControl.module.scss.js +39 -0
  85. package/components/SegmentedControl/index.d.ts +2 -0
  86. package/components/SplitPane/SplitPane.d.ts +61 -0
  87. package/components/SplitPane/SplitPane.js +171 -0
  88. package/components/SplitPane/SplitPane.module.scss.js +25 -0
  89. package/components/SplitPane/index.d.ts +2 -0
  90. package/components/StatCard/StatCard.d.ts +105 -0
  91. package/components/StatCard/StatCard.js +127 -0
  92. package/components/StatCard/StatCard.module.scss.js +72 -0
  93. package/components/StatCard/index.d.ts +2 -0
  94. package/components/StatusDot/StatusDot.d.ts +33 -0
  95. package/components/StatusDot/StatusDot.js +39 -0
  96. package/components/StatusDot/StatusDot.module.scss.js +32 -0
  97. package/components/StatusDot/index.d.ts +2 -0
  98. package/components/Table/Table.d.ts +140 -17
  99. package/components/Table/Table.js +382 -210
  100. package/components/Table/Table.module.scss.js +68 -46
  101. package/components/Table/index.d.ts +1 -1
  102. package/components/Table/useTableSort.d.ts +1 -1
  103. package/components/ThemeToggle/ThemeToggle.d.ts +40 -0
  104. package/components/ThemeToggle/ThemeToggle.js +98 -0
  105. package/components/ThemeToggle/ThemeToggle.module.scss.js +23 -0
  106. package/components/ThemeToggle/index.d.ts +2 -0
  107. package/components/inputs/Checkbox/Checkbox.d.ts +2 -0
  108. package/components/inputs/Checkbox/Checkbox.js +29 -28
  109. package/components/inputs/Checkbox/Checkbox.module.scss.js +8 -6
  110. package/components/inputs/Input/Input.d.ts +33 -1
  111. package/components/inputs/Input/Input.js +94 -35
  112. package/components/inputs/Input/Input.module.scss.js +14 -12
  113. package/components/inputs/Radio/Radio.d.ts +5 -4
  114. package/components/inputs/Radio/Radio.js +55 -50
  115. package/components/inputs/Radio/Radio.module.scss.js +12 -10
  116. package/components/inputs/SearchInput/SearchInput.d.ts +57 -0
  117. package/components/inputs/SearchInput/SearchInput.js +116 -0
  118. package/components/inputs/SearchInput/SearchInput.module.scss.js +13 -0
  119. package/components/inputs/SearchInput/index.d.ts +2 -0
  120. package/components/inputs/Select/Select.d.ts +52 -0
  121. package/components/inputs/Select/Select.js +494 -385
  122. package/components/inputs/Select/Select.module.scss.js +34 -30
  123. package/components/inputs/Switch/Switch.d.ts +15 -0
  124. package/components/inputs/Switch/Switch.js +8 -0
  125. package/components/inputs/Switch/index.d.ts +2 -0
  126. package/hooks/useDebouncedValue.d.ts +15 -0
  127. package/hooks/useDebouncedValue.js +15 -0
  128. package/hooks/useElementSize.d.ts +20 -0
  129. package/hooks/useElementSize.js +23 -0
  130. package/hooks/useKeyboard.d.ts +49 -5
  131. package/hooks/useKeyboard.js +66 -16
  132. package/hooks/useMediaQuery.d.ts +14 -0
  133. package/hooks/useMediaQuery.js +16 -0
  134. package/hooks/useNow.d.ts +14 -0
  135. package/hooks/useNow.js +35 -0
  136. package/hooks/usePersistedState.d.ts +30 -0
  137. package/hooks/usePersistedState.js +99 -0
  138. package/hooks/useResizable.d.ts +66 -0
  139. package/hooks/useResizable.js +105 -0
  140. package/hooks/useTheme.d.ts +33 -0
  141. package/hooks/useTheme.js +25 -0
  142. package/index.css +1 -1
  143. package/index.d.ts +58 -4
  144. package/index.js +208 -132
  145. package/index.layered.css +1 -1
  146. package/llms.txt +620 -26
  147. package/manifest.json +1795 -99
  148. package/package.json +1 -1
  149. package/recipes/confirm-modal.tsx +65 -53
  150. package/recipes/floating-copy-button.tsx +32 -28
  151. package/utils/formatBytes.d.ts +21 -0
  152. package/utils/formatBytes.js +14 -0
  153. package/utils/index.d.ts +6 -0
  154. package/utils/themeScript.d.ts +19 -0
  155. package/utils/themeScript.js +9 -0
  156. package/utils/timeAgo.d.ts +33 -0
  157. package/utils/timeAgo.js +37 -0
@@ -0,0 +1,201 @@
1
+ import { jsxs as m, jsx as r } from "react/jsx-runtime";
2
+ import { forwardRef as $, useState as k, useRef as y, useId as T, useEffect as j, useCallback as v, useMemo as q, useContext as ee, createContext as ne } from "react";
3
+ import f from "clsx";
4
+ import { Modal as w } from "../Modal/Modal.js";
5
+ import { Button as G } from "../Button/Button.js";
6
+ import { Input as re } from "../inputs/Input/Input.js";
7
+ import t from "./ConfirmDialog.module.scss.js";
8
+ const oe = /* @__PURE__ */ r("svg", { viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ r(
9
+ "path",
10
+ {
11
+ fillRule: "evenodd",
12
+ d: "M8.26 3.1c.77-1.33 2.71-1.33 3.48 0l5.58 9.67c.77 1.33-.19 3-1.74 3H4.42c-1.55 0-2.51-1.67-1.74-3L8.26 3.1zM10 7a1 1 0 011 1v3a1 1 0 11-2 0V8a1 1 0 011-1zm0 7a1 1 0 100-2 1 1 0 000 2z",
13
+ clipRule: "evenodd"
14
+ }
15
+ ) }), te = (e) => String(e?.message ?? e), J = $(
16
+ ({
17
+ open: e,
18
+ onConfirm: C,
19
+ onCancel: u,
20
+ title: s = "Are you sure?",
21
+ description: i,
22
+ children: x,
23
+ confirmLabel: h = "Confirm",
24
+ cancelLabel: P = "Cancel",
25
+ danger: p = !1,
26
+ requireText: d,
27
+ icon: g,
28
+ autoFocus: E,
29
+ closeOnBackdrop: n = !0,
30
+ errorMessage: c = te,
31
+ "aria-label": b,
32
+ classes: o,
33
+ className: U,
34
+ style: X
35
+ }, Y) => {
36
+ const [a, I] = k(!1), [F, N] = k(void 0), [M, H] = k(""), L = y(null), S = y(null), A = y(null), R = y(!0), K = T();
37
+ j(() => (R.current = !0, () => {
38
+ R.current = !1;
39
+ }), []), j(() => {
40
+ e || (I(!1), N(void 0), H(""));
41
+ }, [e]);
42
+ const V = E ?? (p ? "cancel" : "confirm");
43
+ j(() => {
44
+ if (!e) return;
45
+ (d ? A.current : V === "cancel" ? S.current : L.current)?.focus();
46
+ }, [e, V, d]);
47
+ const z = d === void 0 || M === d, B = z && !a, W = v(async () => {
48
+ if (!B) return;
49
+ N(void 0);
50
+ let l;
51
+ try {
52
+ l = C();
53
+ } catch (O) {
54
+ N(O);
55
+ return;
56
+ }
57
+ if (l && typeof l.then == "function") {
58
+ I(!0);
59
+ try {
60
+ await l;
61
+ } catch (O) {
62
+ R.current && N(O);
63
+ } finally {
64
+ R.current && I(!1);
65
+ }
66
+ }
67
+ }, [B, C]), D = v(() => {
68
+ a || u();
69
+ }, [a, u]), _ = g === !1 ? null : g !== void 0 ? g : p ? oe : null, Z = q(
70
+ () => ({ modal: o?.modal, header: o?.header, body: o?.body, footer: o?.footer }),
71
+ [o]
72
+ );
73
+ return /* @__PURE__ */ m(
74
+ w,
75
+ {
76
+ ref: Y,
77
+ open: e,
78
+ onClose: D,
79
+ size: "sm",
80
+ closeOnBackdrop: n && !a,
81
+ closeOnEscape: !a,
82
+ classes: Z,
83
+ className: f(t.root, p && t.danger, U),
84
+ style: X,
85
+ "aria-label": typeof s == "string" ? s : s ? void 0 : b,
86
+ children: [
87
+ s ? /* @__PURE__ */ r(w.Header, { onClose: a ? void 0 : D, children: /* @__PURE__ */ m("span", { className: t.titleRow, children: [
88
+ _ && /* @__PURE__ */ r("span", { className: f(t.icon, o?.icon), "aria-hidden": "true", children: _ }),
89
+ /* @__PURE__ */ r("span", { className: t.title, children: s })
90
+ ] }) }) : null,
91
+ /* @__PURE__ */ m(w.Body, { children: [
92
+ i && /* @__PURE__ */ r("div", { className: f(t.description, o?.description), children: i }),
93
+ x,
94
+ d !== void 0 && /* @__PURE__ */ m("div", { className: f(t.input, o?.input), children: [
95
+ /* @__PURE__ */ m("label", { htmlFor: K, className: t.inputLabel, children: [
96
+ "Type ",
97
+ /* @__PURE__ */ r("b", { children: d }),
98
+ " to confirm"
99
+ ] }),
100
+ /* @__PURE__ */ r(
101
+ re,
102
+ {
103
+ ref: A,
104
+ id: K,
105
+ value: M,
106
+ onChange: (l) => H(l.target.value),
107
+ onKeyDown: (l) => {
108
+ l.key === "Enter" && B && (l.preventDefault(), W());
109
+ },
110
+ autoComplete: "off",
111
+ spellCheck: !1,
112
+ disabled: a,
113
+ "aria-invalid": M.length > 0 && !z ? !0 : void 0
114
+ }
115
+ )
116
+ ] }),
117
+ F !== void 0 && /* @__PURE__ */ r("div", { role: "alert", className: f(t.error, o?.error), children: c(F) })
118
+ ] }),
119
+ /* @__PURE__ */ m(w.Footer, { children: [
120
+ /* @__PURE__ */ r(
121
+ G,
122
+ {
123
+ ref: S,
124
+ variant: "ghost",
125
+ onClick: D,
126
+ disabled: a,
127
+ className: f(t.cancel, o?.cancel),
128
+ children: P
129
+ }
130
+ ),
131
+ /* @__PURE__ */ r(
132
+ G,
133
+ {
134
+ ref: L,
135
+ variant: p ? "danger" : "primary",
136
+ onClick: () => {
137
+ W();
138
+ },
139
+ loading: a,
140
+ disabled: !z,
141
+ className: f(t.confirm, o?.confirm),
142
+ children: h
143
+ }
144
+ )
145
+ ] })
146
+ ]
147
+ }
148
+ );
149
+ }
150
+ );
151
+ J.displayName = "ConfirmDialog";
152
+ const Q = ne(null);
153
+ let ie = 0;
154
+ function le({ children: e, defaults: C }) {
155
+ const [u, s] = k(null), i = y(null);
156
+ i.current = u;
157
+ const x = v(
158
+ (n = {}) => new Promise((c) => {
159
+ i.current?.resolve(!1);
160
+ const b = { id: ++ie, options: { ...C, ...n }, resolve: c };
161
+ i.current = b, s(b);
162
+ }),
163
+ [C]
164
+ ), h = v((n, c) => {
165
+ i.current === n && (i.current = null, s(null), n.resolve(c));
166
+ }, []), P = v(async () => {
167
+ const n = i.current;
168
+ if (!n) return;
169
+ const c = n.options.onConfirm?.();
170
+ c && typeof c.then == "function" && await c, h(n, !0);
171
+ }, [h]), p = v(() => {
172
+ const n = i.current;
173
+ n && h(n, !1);
174
+ }, [h]), { body: d, onConfirm: g, ...E } = u?.options ?? {};
175
+ return /* @__PURE__ */ m(Q.Provider, { value: x, children: [
176
+ e,
177
+ /* @__PURE__ */ r(
178
+ J,
179
+ {
180
+ ...E,
181
+ open: u !== null,
182
+ onConfirm: P,
183
+ onCancel: p,
184
+ children: d
185
+ },
186
+ u?.id ?? "idle"
187
+ )
188
+ ] });
189
+ }
190
+ le.displayName = "ConfirmProvider";
191
+ function he() {
192
+ const e = ee(Q);
193
+ if (!e)
194
+ throw new Error("useConfirm() must be used inside a <ConfirmProvider>.");
195
+ return e;
196
+ }
197
+ export {
198
+ J as ConfirmDialog,
199
+ le as ConfirmProvider,
200
+ he as useConfirm
201
+ };
@@ -0,0 +1,21 @@
1
+ const t = "crk-titleRow-45dc7", c = "crk-title-Y07Q8", n = "crk-icon-8MwQK", r = "crk-danger-yQ2Yd", o = "crk-description-KCKQ-", e = "crk-input--R-KC", i = "crk-inputLabel-mD7a2", s = "crk-error-f81j6", l = {
2
+ titleRow: t,
3
+ title: c,
4
+ icon: n,
5
+ danger: r,
6
+ description: o,
7
+ input: e,
8
+ inputLabel: i,
9
+ error: s
10
+ };
11
+ export {
12
+ r as danger,
13
+ l as default,
14
+ o as description,
15
+ s as error,
16
+ n as icon,
17
+ e as input,
18
+ i as inputLabel,
19
+ c as title,
20
+ t as titleRow
21
+ };
@@ -0,0 +1,2 @@
1
+ export { ConfirmDialog, ConfirmProvider, useConfirm } from './ConfirmDialog';
2
+ export type { ConfirmDialogProps, ConfirmDialogClasses, ConfirmOptions, ConfirmFn, ConfirmProviderProps, } from './ConfirmDialog';
@@ -3,6 +3,7 @@ export interface DrawerClasses {
3
3
  backdrop: string;
4
4
  drawer: string;
5
5
  header: string;
6
+ headerTitle: string;
6
7
  closeButton: string;
7
8
  body: string;
8
9
  footer: string;
@@ -1,25 +1,24 @@
1
1
  import { jsx as c, jsxs as z } from "react/jsx-runtime";
2
- import { forwardRef as q, useRef as T, useId as G, useState as u, useEffect as w, createContext as J, useContext as h } from "react";
2
+ import { forwardRef as q, useRef as S, useId as G, useState as u, useEffect as h, createContext as J, useContext as w } from "react";
3
3
  import { createPortal as K } from "react-dom";
4
- import d from "clsx";
4
+ import l from "clsx";
5
5
  import { useFocusTrap as Q } from "../../hooks/useFocusTrap.js";
6
6
  import { useEscapeLayer as V, EscapeLayerProvider as X } from "../../hooks/useEscapeLayer.js";
7
7
  import t from "./Drawer.module.scss.js";
8
8
  const m = J({ classes: {}, titleId: "" }), x = ({ children: e, className: s, style: a, onClose: o }) => {
9
- const { classes: i, titleId: p } = h(m);
9
+ const { classes: i, titleId: p } = w(m);
10
10
  return /* @__PURE__ */ z(
11
11
  "div",
12
12
  {
13
- id: p,
14
- className: d(t.header, o && t.headerWithClose, i.header, s),
13
+ className: l(t.header, o && t.headerWithClose, i.header, s),
15
14
  style: a,
16
15
  children: [
17
- e,
16
+ /* @__PURE__ */ c("div", { id: p, className: l(t.headerTitle, i.headerTitle), children: e }),
18
17
  o && /* @__PURE__ */ c(
19
18
  "button",
20
19
  {
21
20
  type: "button",
22
- className: d(t.closeButton, i.closeButton),
21
+ className: l(t.closeButton, i.closeButton),
23
22
  onClick: o,
24
23
  "aria-label": "Close",
25
24
  children: "×"
@@ -31,13 +30,13 @@ const m = J({ classes: {}, titleId: "" }), x = ({ children: e, className: s, sty
31
30
  };
32
31
  x.displayName = "Drawer.Header";
33
32
  const R = ({ children: e, className: s, style: a }) => {
34
- const { classes: o } = h(m);
35
- return /* @__PURE__ */ c("div", { className: d(t.body, o.body, s), style: a, children: e });
33
+ const { classes: o } = w(m);
34
+ return /* @__PURE__ */ c("div", { className: l(t.body, o.body, s), style: a, children: e });
36
35
  };
37
36
  R.displayName = "Drawer.Body";
38
37
  const M = ({ children: e, className: s, style: a }) => {
39
- const { classes: o } = h(m);
40
- return /* @__PURE__ */ c("div", { className: d(t.footer, o.footer, s), style: a, children: e });
38
+ const { classes: o } = w(m);
39
+ return /* @__PURE__ */ c("div", { className: l(t.footer, o.footer, s), style: a, children: e });
41
40
  };
42
41
  M.displayName = "Drawer.Footer";
43
42
  const Y = 340, f = q(
@@ -56,40 +55,40 @@ const Y = 340, f = q(
56
55
  "aria-label": N,
57
56
  "aria-labelledby": E
58
57
  }, n) => {
59
- const B = T(null), F = (r) => {
58
+ const B = S(null), F = (r) => {
60
59
  B.current = r, typeof n == "function" ? n(r) : n && (n.current = r);
61
- }, O = G(), g = E ?? `${O}-title`, b = i === "temporary", [l, k] = u(e), [D, I] = u(!1), [S, H] = u(a), [P, j] = u(o);
62
- w(() => {
63
- e && (k(!0), I(!1), H(a), j(o));
64
- }, [e, a, o]), w(() => {
65
- if (e || !l) return;
66
- I(!0);
67
- const r = setTimeout(() => k(!1), Y);
60
+ }, O = G(), T = E ?? `${O}-title`, v = i === "temporary", [d, g] = u(e), [k, D] = u(!1), [I, H] = u(a), [P, j] = u(o);
61
+ h(() => {
62
+ e && (g(!0), D(!1), H(a), j(o));
63
+ }, [e, a, o]), h(() => {
64
+ if (e || !d) return;
65
+ D(!0);
66
+ const r = setTimeout(() => g(!1), Y);
68
67
  return () => clearTimeout(r);
69
- }, [e, l]), Q(B, l && e && b);
68
+ }, [e, d]), Q(B, d && e && v);
70
69
  const L = V(() => {
71
70
  C && s();
72
71
  }, e);
73
- w(() => {
74
- if (!l) return;
72
+ h(() => {
73
+ if (!d) return;
75
74
  const r = document.body.style.overflow;
76
75
  return document.body.style.overflow = "hidden", () => {
77
76
  document.body.style.overflow = r;
78
77
  };
79
- }, [l]);
80
- const v = T(!1), U = (r) => {
81
- v.current = r.target === r.currentTarget;
78
+ }, [d]);
79
+ const b = S(!1), U = (r) => {
80
+ b.current = r.target === r.currentTarget;
82
81
  }, W = (r) => {
83
- p && v.current && r.target === r.currentTarget && s(), v.current = !1;
82
+ p && b.current && r.target === r.currentTarget && s(), b.current = !1;
84
83
  };
85
- return l ? K(
84
+ return d ? K(
86
85
  /* @__PURE__ */ c(
87
86
  "div",
88
87
  {
89
- className: d(
88
+ className: l(
90
89
  t.backdrop,
91
- D && t.backdropClosing,
92
- !b && t.backdropBare,
90
+ k && t.backdropClosing,
91
+ !v && t.backdropBare,
93
92
  y?.backdrop
94
93
  ),
95
94
  onMouseDown: U,
@@ -99,20 +98,20 @@ const Y = 340, f = q(
99
98
  "div",
100
99
  {
101
100
  ref: F,
102
- className: d(
101
+ className: l(
103
102
  t.drawer,
104
- t[`side_${S}`],
103
+ t[`side_${I}`],
105
104
  t[`size_${P}`],
106
- t[`${D ? "slideOut" : "slideIn"}_${S}`],
105
+ t[`${k ? "slideOut" : "slideIn"}_${I}`],
107
106
  y?.drawer,
108
107
  _
109
108
  ),
110
109
  style: $,
111
110
  role: "dialog",
112
- "aria-modal": b ? "true" : void 0,
111
+ "aria-modal": v ? "true" : void 0,
113
112
  "aria-label": N,
114
- "aria-labelledby": N ? void 0 : g,
115
- children: /* @__PURE__ */ c(m.Provider, { value: { classes: y ?? {}, titleId: g }, children: /* @__PURE__ */ c(X, { value: L, children: A }) })
113
+ "aria-labelledby": N ? void 0 : T,
114
+ children: /* @__PURE__ */ c(m.Provider, { value: { classes: y ?? {}, titleId: T }, children: /* @__PURE__ */ c(X, { value: L, children: A }) })
116
115
  }
117
116
  )
118
117
  }
@@ -1,4 +1,4 @@
1
- const r = "crk-backdrop-LBGhN", t = "crk-crk-drawer-fade-in-fnZXU", e = "crk-backdropClosing-0aeyJ", o = "crk-crk-drawer-fade-out-iDYoX", c = "crk-backdropBare-7fB4W", s = "crk-drawer-IKoOm", i = "crk-side_right-sYQoY", d = "crk-side_right-sYQoY", k = "crk-side_left-gAeYL", n = "crk-side_left-gAeYL", l = "crk-side_top-QFjZz", a = "crk-side_top-QFjZz", u = "crk-side_bottom-Y1t6g", _ = "crk-side_bottom-Y1t6g", w = "crk-slideIn_right-HORcg", g = "crk-slideIn_right-HORcg", f = "crk-crk-drawer-in-right-lit2r", p = "crk-slideOut_right-lbnQY", I = "crk-slideOut_right-lbnQY", O = "crk-crk-drawer-out-right-lrub3", m = "crk-slideIn_left-VvJeV", b = "crk-slideIn_left-VvJeV", h = "crk-crk-drawer-in-left-98vE7", z = "crk-slideOut_left-4pc01", D = "crk-slideOut_left-4pc01", L = "crk-crk-drawer-out-left-EI6P3", B = "crk-slideIn_top-ULcWL", T = "crk-slideIn_top-ULcWL", R = "crk-crk-drawer-in-top-8ZkO6", Y = "crk-slideOut_top-00Tue", F = "crk-slideOut_top-00Tue", C = "crk-crk-drawer-out-top-KDkv7", y = "crk-slideIn_bottom-uBTzu", E = "crk-slideIn_bottom-uBTzu", Q = "crk-crk-drawer-in-bottom-b9y67", j = "crk-slideOut_bottom-g6ELp", v = "crk-slideOut_bottom-g6ELp", S = "crk-crk-drawer-out-bottom-IShFs", X = "crk-size_sm-o8tw7", Z = "crk-size_sm-o8tw7", P = "crk-size_md-akgTC", U = "crk-size_md-akgTC", V = "crk-size_lg-Yjulz", W = "crk-size_lg-Yjulz", J = "crk-size_full-DIjPg", K = "crk-size_full-DIjPg", A = "crk-header--OScS", H = "crk-closeButton-WdXyR", M = "crk-body-CXRcE", x = "crk-footer-0kQ83", G = "crk-drawerClosing-9hrsd", N = {
1
+ const r = "crk-backdrop-LBGhN", t = "crk-crk-drawer-fade-in-fnZXU", e = "crk-backdropClosing-0aeyJ", o = "crk-crk-drawer-fade-out-iDYoX", c = "crk-backdropBare-7fB4W", s = "crk-drawer-IKoOm", i = "crk-side_right-sYQoY", d = "crk-side_right-sYQoY", k = "crk-side_left-gAeYL", n = "crk-side_left-gAeYL", l = "crk-side_top-QFjZz", a = "crk-side_top-QFjZz", u = "crk-side_bottom-Y1t6g", _ = "crk-side_bottom-Y1t6g", w = "crk-slideIn_right-HORcg", g = "crk-slideIn_right-HORcg", f = "crk-crk-drawer-in-right-lit2r", p = "crk-slideOut_right-lbnQY", I = "crk-slideOut_right-lbnQY", O = "crk-crk-drawer-out-right-lrub3", m = "crk-slideIn_left-VvJeV", h = "crk-slideIn_left-VvJeV", b = "crk-crk-drawer-in-left-98vE7", z = "crk-slideOut_left-4pc01", D = "crk-slideOut_left-4pc01", L = "crk-crk-drawer-out-left-EI6P3", B = "crk-slideIn_top-ULcWL", T = "crk-slideIn_top-ULcWL", R = "crk-crk-drawer-in-top-8ZkO6", Y = "crk-slideOut_top-00Tue", F = "crk-slideOut_top-00Tue", C = "crk-crk-drawer-out-top-KDkv7", y = "crk-slideIn_bottom-uBTzu", Q = "crk-slideIn_bottom-uBTzu", E = "crk-crk-drawer-in-bottom-b9y67", j = "crk-slideOut_bottom-g6ELp", v = "crk-slideOut_bottom-g6ELp", S = "crk-crk-drawer-out-bottom-IShFs", X = "crk-size_sm-o8tw7", Z = "crk-size_sm-o8tw7", P = "crk-size_md-akgTC", U = "crk-size_md-akgTC", V = "crk-size_lg-Yjulz", W = "crk-size_lg-Yjulz", J = "crk-size_full-DIjPg", K = "crk-size_full-DIjPg", A = "crk-header--OScS", H = "crk-headerTitle-LQr32", M = "crk-closeButton-WdXyR", x = "crk-body-CXRcE", G = "crk-footer-0kQ83", N = "crk-drawerClosing-9hrsd", q = {
2
2
  backdrop: r,
3
3
  "crk-drawer-fade-in": "crk-crk-drawer-fade-in-fnZXU",
4
4
  crkDrawerFadeIn: t,
@@ -24,9 +24,9 @@ const r = "crk-backdrop-LBGhN", t = "crk-crk-drawer-fade-in-fnZXU", e = "crk-bac
24
24
  "crk-drawer-out-right": "crk-crk-drawer-out-right-lrub3",
25
25
  crkDrawerOutRight: O,
26
26
  slideIn_left: m,
27
- slideInLeft: b,
27
+ slideInLeft: h,
28
28
  "crk-drawer-in-left": "crk-crk-drawer-in-left-98vE7",
29
- crkDrawerInLeft: h,
29
+ crkDrawerInLeft: b,
30
30
  slideOut_left: z,
31
31
  slideOutLeft: D,
32
32
  "crk-drawer-out-left": "crk-crk-drawer-out-left-EI6P3",
@@ -40,9 +40,9 @@ const r = "crk-backdrop-LBGhN", t = "crk-crk-drawer-fade-in-fnZXU", e = "crk-bac
40
40
  "crk-drawer-out-top": "crk-crk-drawer-out-top-KDkv7",
41
41
  crkDrawerOutTop: C,
42
42
  slideIn_bottom: y,
43
- slideInBottom: E,
43
+ slideInBottom: Q,
44
44
  "crk-drawer-in-bottom": "crk-crk-drawer-in-bottom-b9y67",
45
- crkDrawerInBottom: Q,
45
+ crkDrawerInBottom: E,
46
46
  slideOut_bottom: j,
47
47
  slideOutBottom: v,
48
48
  "crk-drawer-out-bottom": "crk-crk-drawer-out-bottom-IShFs",
@@ -56,32 +56,34 @@ const r = "crk-backdrop-LBGhN", t = "crk-crk-drawer-fade-in-fnZXU", e = "crk-bac
56
56
  size_full: J,
57
57
  sizeFull: K,
58
58
  header: A,
59
- closeButton: H,
60
- body: M,
61
- footer: x,
62
- drawerClosing: G
59
+ headerTitle: H,
60
+ closeButton: M,
61
+ body: x,
62
+ footer: G,
63
+ drawerClosing: N
63
64
  };
64
65
  export {
65
66
  r as backdrop,
66
67
  c as backdropBare,
67
68
  e as backdropClosing,
68
- M as body,
69
- H as closeButton,
69
+ x as body,
70
+ M as closeButton,
70
71
  t as crkDrawerFadeIn,
71
72
  o as crkDrawerFadeOut,
72
- Q as crkDrawerInBottom,
73
- h as crkDrawerInLeft,
73
+ E as crkDrawerInBottom,
74
+ b as crkDrawerInLeft,
74
75
  f as crkDrawerInRight,
75
76
  R as crkDrawerInTop,
76
77
  S as crkDrawerOutBottom,
77
78
  L as crkDrawerOutLeft,
78
79
  O as crkDrawerOutRight,
79
80
  C as crkDrawerOutTop,
80
- N as default,
81
+ q as default,
81
82
  s as drawer,
82
- G as drawerClosing,
83
- x as footer,
83
+ N as drawerClosing,
84
+ G as footer,
84
85
  A as header,
86
+ H as headerTitle,
85
87
  _ as sideBottom,
86
88
  n as sideLeft,
87
89
  d as sideRight,
@@ -98,8 +100,8 @@ export {
98
100
  V as size_lg,
99
101
  P as size_md,
100
102
  X as size_sm,
101
- E as slideInBottom,
102
- b as slideInLeft,
103
+ Q as slideInBottom,
104
+ h as slideInLeft,
103
105
  g as slideInRight,
104
106
  T as slideInTop,
105
107
  y as slideIn_bottom,
@@ -14,6 +14,18 @@ export interface DropdownClasses {
14
14
  chevron: string;
15
15
  menu: string;
16
16
  item: string;
17
+ itemIcon: string;
18
+ itemLabel: string;
19
+ itemDescription: string;
20
+ itemShortcut: string;
21
+ itemCheck: string;
22
+ separator: string;
23
+ label: string;
24
+ }
25
+ /** Viewport point for context-menu mode. */
26
+ export interface DropdownAnchor {
27
+ x: number;
28
+ y: number;
17
29
  }
18
30
  export interface DropdownProps {
19
31
  /**
@@ -56,24 +68,52 @@ export interface DropdownProps {
56
68
  * @default true
57
69
  */
58
70
  portal?: boolean;
71
+ /**
72
+ * Controlled open state. Leave `undefined` for the default uncontrolled
73
+ * behaviour (the trigger toggles it). Pair with `onOpenChange`.
74
+ */
75
+ open?: boolean;
76
+ /** Fires with the next open state (trigger click, outside click, Escape, item activation). */
77
+ onOpenChange?: (open: boolean) => void;
78
+ /**
79
+ * **Context-menu mode**: position the menu at this viewport point (e.g. the
80
+ * pointer on right-click) instead of under the trigger. The menu is portaled,
81
+ * clamped to the viewport and flips above / to the left when it would
82
+ * overflow. Passing the prop at all (even `null` = closed, no position yet)
83
+ * selects this mode: with no `trigger` and no `options`, nothing is rendered
84
+ * in place — only the menu. Use `useContextMenu()` to drive it.
85
+ */
86
+ anchor?: DropdownAnchor | null;
59
87
  /** Override class names on internal elements. */
60
88
  classes?: Partial<DropdownClasses>;
61
89
  }
62
90
  /**
63
- * Two-mode dropdown:
64
- * - **Menu mode**: pass `trigger` + `<DropdownItem>` children for an action menu.
65
- * - **Select mode**: pass `options` + `value` + `onChange` to use as a form input.
66
- * In this mode the `trigger` prop is ignored.
91
+ * Three-mode dropdown:
92
+ * - **Menu mode**: pass `trigger` + `<DropdownItem>` children for an action
93
+ * menu. Items support `icon`, `shortcut`, `danger`, `checked`,
94
+ * `description`; group them with `<DropdownSeparator>` / `<DropdownLabel>`.
95
+ * - **Select mode**: pass `options` + `value` + `onChange` to use as a form
96
+ * input. In this mode the `trigger` prop is ignored.
97
+ * - **Context-menu mode**: pass `anchor` (+ controlled `open` /
98
+ * `onOpenChange`, typically from `useContextMenu()`) to open the same menu
99
+ * at a pointer position.
67
100
  *
68
- * Closes on outside click and Escape; auto-focuses the first menu item on open.
101
+ * Closes on outside click, Escape and item activation; focuses the first item
102
+ * on open; ArrowUp/ArrowDown (wrapping), Home/End and typeahead move focus.
69
103
  *
70
104
  * @example Menu mode
71
105
  * <Dropdown trigger="More ▾">
72
- * <DropdownItem onClick={onEdit}>Edit</DropdownItem>
73
- * <DropdownItem onClick={onDelete}>Delete</DropdownItem>
106
+ * <DropdownItem icon={<PencilIcon />} shortcut={<Kbd>E</Kbd>} onClick={onEdit}>Edit</DropdownItem>
107
+ * <DropdownSeparator />
108
+ * <DropdownItem danger onClick={onDelete}>Delete</DropdownItem>
74
109
  * </Dropdown>
75
110
  *
76
111
  * @example Select mode
77
112
  * <Dropdown options={options} value={value} onChange={setValue} />
113
+ *
114
+ * @example Context-menu mode
115
+ * const menu = useContextMenu();
116
+ * <div onContextMenu={menu.onContextMenu}>…</div>
117
+ * <Dropdown anchor={menu.anchor} open={menu.open} onOpenChange={menu.onOpenChange}>…</Dropdown>
78
118
  */
79
119
  export declare const Dropdown: import('react').ForwardRefExoticComponent<DropdownProps & import('react').RefAttributes<HTMLDivElement>>;