@overdoser/react-toolkit 0.20.0 → 0.21.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 (273) hide show
  1. package/AGENTS.md +1 -1
  2. package/CHANGELOG.md +14 -0
  3. package/components/Accordion/Accordion.js +160 -177
  4. package/components/Accordion/Accordion.module.js +20 -0
  5. package/components/ActionButton/ActionButton.js +155 -209
  6. package/components/ActionButton/ActionButton.module.js +25 -0
  7. package/components/ActionButton/CopyButton.js +52 -64
  8. package/components/Alert/Alert.js +92 -95
  9. package/components/Alert/Alert.module.js +18 -0
  10. package/components/Avatar/Avatar.js +44 -55
  11. package/components/Avatar/Avatar.module.js +23 -0
  12. package/components/Badge/Badge.js +16 -38
  13. package/components/Badge/Badge.module.js +17 -0
  14. package/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
  15. package/components/Breadcrumbs/Breadcrumbs.js +52 -48
  16. package/components/Breadcrumbs/Breadcrumbs.module.js +10 -0
  17. package/components/Button/Button.js +35 -57
  18. package/components/Button/Button.module.js +25 -0
  19. package/components/Card/Card.js +94 -131
  20. package/components/Card/Card.module.js +35 -0
  21. package/components/Chart/AreaChart.d.ts +1 -1
  22. package/components/Chart/AreaChart.js +248 -249
  23. package/components/Chart/Axis.d.ts +2 -2
  24. package/components/Chart/Axis.js +34 -43
  25. package/components/Chart/BarChart.d.ts +1 -1
  26. package/components/Chart/BarChart.js +307 -348
  27. package/components/Chart/Chart.module.js +32 -0
  28. package/components/Chart/ChartContainer.js +33 -41
  29. package/components/Chart/ChartLegend.d.ts +1 -1
  30. package/components/Chart/ChartLegend.js +31 -30
  31. package/components/Chart/ChartTooltip.d.ts +1 -1
  32. package/components/Chart/ChartTooltip.js +46 -41
  33. package/components/Chart/LineChart.d.ts +1 -1
  34. package/components/Chart/LineChart.js +220 -232
  35. package/components/Chart/PieChart.d.ts +1 -1
  36. package/components/Chart/PieChart.js +224 -240
  37. package/components/Chart/RadarChart.d.ts +1 -1
  38. package/components/Chart/RadarChart.js +166 -215
  39. package/components/Chart/Sparkline.js +73 -68
  40. package/components/Chart/TradingChart.d.ts +1 -1
  41. package/components/Chart/TradingChart.js +804 -701
  42. package/components/Chart/scales.js +28 -35
  43. package/components/Chart/trading/indicators.js +61 -62
  44. package/components/Chart/trading/period.js +46 -68
  45. package/components/Chart/useChartDimensions.js +30 -22
  46. package/components/Chip/Chip.js +98 -141
  47. package/components/Chip/Chip.module.js +32 -0
  48. package/components/CodeBlock/CodeBlock.js +111 -119
  49. package/components/CodeBlock/CodeBlock.module.js +23 -0
  50. package/components/CommandPalette/CommandPalette.js +387 -392
  51. package/components/CommandPalette/CommandPalette.module.js +28 -0
  52. package/components/ConfirmDialog/ConfirmDialog.d.ts +1 -1
  53. package/components/ConfirmDialog/ConfirmDialog.js +184 -199
  54. package/components/ConfirmDialog/ConfirmDialog.module.js +12 -0
  55. package/components/Divider/Divider.js +25 -36
  56. package/components/Divider/Divider.module.js +17 -0
  57. package/components/Draggable/Draggable.d.ts +1 -1
  58. package/components/Draggable/Draggable.js +157 -164
  59. package/components/Draggable/Draggable.module.js +10 -0
  60. package/components/Drawer/Drawer.js +104 -126
  61. package/components/Drawer/Drawer.module.js +66 -0
  62. package/components/Dropdown/Dropdown.js +175 -234
  63. package/components/Dropdown/Dropdown.module.js +29 -0
  64. package/components/Dropdown/DropdownItem.js +55 -58
  65. package/components/Dropdown/DropdownLabel.js +14 -11
  66. package/components/Dropdown/DropdownSeparator.js +12 -10
  67. package/components/Dropdown/dropdownContext.js +4 -5
  68. package/components/Dropdown/useContextMenu.js +27 -17
  69. package/components/Dropzone/Dropzone.js +99 -105
  70. package/components/Dropzone/Dropzone.module.js +12 -0
  71. package/components/EmptyState/EmptyState.js +58 -55
  72. package/components/EmptyState/EmptyState.module.js +14 -0
  73. package/components/Form/Form.d.ts +1 -1
  74. package/components/Form/Form.js +32 -35
  75. package/components/Form/Form.module.js +16 -0
  76. package/components/Form/FormField.d.ts +1 -1
  77. package/components/Form/FormField.js +71 -75
  78. package/components/Form/FormRow.d.ts +1 -1
  79. package/components/Form/FormRow.js +11 -8
  80. package/components/Form/formFieldDefaults.js +4 -5
  81. package/components/ImageViewer/ImageViewer.js +312 -201
  82. package/components/ImageViewer/ImageViewer.module.js +26 -0
  83. package/components/ImageViewer/useZoomPan.js +206 -137
  84. package/components/Kbd/Kbd.js +25 -22
  85. package/components/Kbd/Kbd.module.js +10 -0
  86. package/components/KeyValueList/KeyValueList.js +119 -123
  87. package/components/KeyValueList/KeyValueList.module.js +23 -0
  88. package/components/Link/Link.js +45 -59
  89. package/components/Link/Link.module.js +10 -0
  90. package/components/List/List.js +22 -46
  91. package/components/List/List.module.js +12 -0
  92. package/components/Loader/Loader.js +152 -182
  93. package/components/Loader/Loader.module.js +40 -0
  94. package/components/Modal/Modal.js +93 -105
  95. package/components/Modal/Modal.module.js +18 -0
  96. package/components/PageHeader/PageHeader.js +78 -72
  97. package/components/PageHeader/PageHeader.module.js +23 -0
  98. package/components/Pagination/Pagination.js +63 -84
  99. package/components/Pagination/Pagination.module.js +13 -0
  100. package/components/Pagination/paginationRange.js +15 -22
  101. package/components/Popover/Popover.js +110 -134
  102. package/components/Popover/Popover.module.js +12 -0
  103. package/components/ProgressBar/ProgressBar.d.ts +15 -1
  104. package/components/ProgressBar/ProgressBar.js +57 -90
  105. package/components/ProgressBar/ProgressBar.module.js +29 -0
  106. package/components/RelativeTime/RelativeTime.js +36 -43
  107. package/components/RelativeTime/RelativeTime.module.js +3 -0
  108. package/components/SegmentedControl/SegmentedControl.js +94 -130
  109. package/components/SegmentedControl/SegmentedControl.module.js +21 -0
  110. package/components/Skeleton/Skeleton.js +36 -50
  111. package/components/Skeleton/Skeleton.module.js +15 -0
  112. package/components/Spinner/Spinner.js +25 -25
  113. package/components/Spinner/Spinner.module.js +12 -0
  114. package/components/SplitButton/SplitButton.js +149 -196
  115. package/components/SplitButton/SplitButton.module.js +31 -0
  116. package/components/SplitPane/SplitPane.js +134 -170
  117. package/components/SplitPane/SplitPane.module.js +14 -0
  118. package/components/StatCard/StatCard.js +132 -125
  119. package/components/StatCard/StatCard.module.js +42 -0
  120. package/components/StatusDot/StatusDot.js +28 -39
  121. package/components/StatusDot/StatusDot.module.js +18 -0
  122. package/components/Table/Table.d.ts +1 -1
  123. package/components/Table/Table.js +381 -451
  124. package/components/Table/Table.module.js +42 -0
  125. package/components/Table/useTableSort.js +51 -42
  126. package/components/Tabs/Tabs.js +109 -161
  127. package/components/Tabs/Tabs.module.js +28 -0
  128. package/components/ThemeToggle/ThemeToggle.js +122 -98
  129. package/components/ThemeToggle/ThemeToggle.module.js +13 -0
  130. package/components/Timeline/GanttTimeline.js +357 -318
  131. package/components/Timeline/GanttTimeline.module.js +29 -0
  132. package/components/Timeline/HistoryTimeline.js +486 -450
  133. package/components/Timeline/HistoryTimeline.module.js +31 -0
  134. package/components/Timeline/Timeline.module.js +76 -0
  135. package/components/Timeline/TimelineShared.d.ts +7 -7
  136. package/components/Timeline/TimelineShared.js +288 -279
  137. package/components/Timeline/TraceEventDetails.d.ts +3 -3
  138. package/components/Timeline/TraceEventDetails.js +245 -178
  139. package/components/Timeline/TraceTimeline.js +823 -783
  140. package/components/Timeline/TraceTimeline.module.js +98 -0
  141. package/components/Timeline/historyLayout.js +336 -263
  142. package/components/Timeline/timelineCore.js +208 -183
  143. package/components/Timeline/traceEvent.js +59 -61
  144. package/components/Timeline/traceLayout.js +101 -90
  145. package/components/Timeline/useTimeline.js +76 -79
  146. package/components/Timer/Timer.js +190 -156
  147. package/components/Timer/Timer.module.js +29 -0
  148. package/components/Toast/Toast.d.ts +1 -1
  149. package/components/Toast/Toast.js +128 -128
  150. package/components/Toast/Toast.module.js +37 -0
  151. package/components/Toast/toastStore.js +58 -62
  152. package/components/ToggleIconButton/ToggleIconButton.js +35 -57
  153. package/components/ToggleIconButton/ToggleIconButton.module.js +15 -0
  154. package/components/Tooltip/Tooltip.d.ts +1 -1
  155. package/components/Tooltip/Tooltip.js +76 -85
  156. package/components/Tooltip/Tooltip.module.js +17 -0
  157. package/components/Typography/Typography.js +11 -36
  158. package/components/Typography/Typography.module.js +30 -0
  159. package/components/inputs/Checkbox/Checkbox.js +27 -51
  160. package/components/inputs/Checkbox/Checkbox.module.js +10 -0
  161. package/components/inputs/Checkbox/CheckboxGroup.js +53 -111
  162. package/components/inputs/Checkbox/CheckboxGroup.module.js +17 -0
  163. package/components/inputs/DatePicker/CalendarPanel.d.ts +1 -1
  164. package/components/inputs/DatePicker/CalendarPanel.js +263 -286
  165. package/components/inputs/DatePicker/CalendarPanel.module.js +23 -0
  166. package/components/inputs/DatePicker/DatePicker.js +115 -142
  167. package/components/inputs/DatePicker/DatePicker.module.js +14 -0
  168. package/components/inputs/DatePicker/dateUtils.js +32 -41
  169. package/components/inputs/DateTimePicker/DateTimePicker.js +226 -232
  170. package/components/inputs/DateTimePicker/DateTimePicker.module.js +20 -0
  171. package/components/inputs/DateTimePicker/DateTimeSegments.js +273 -252
  172. package/components/inputs/DateTimePicker/TimeField.d.ts +1 -1
  173. package/components/inputs/DateTimePicker/TimeField.js +131 -132
  174. package/components/inputs/DateTimePicker/timeZoneUtils.js +95 -92
  175. package/components/inputs/Input/Input.js +98 -109
  176. package/components/inputs/Input/Input.module.js +15 -0
  177. package/components/inputs/NumberInput/NumberInput.js +112 -132
  178. package/components/inputs/NumberInput/NumberInput.module.js +14 -0
  179. package/components/inputs/Radio/Radio.js +50 -73
  180. package/components/inputs/Radio/Radio.module.js +9 -0
  181. package/components/inputs/SearchInput/SearchInput.js +98 -115
  182. package/components/inputs/SearchInput/SearchInput.module.js +8 -0
  183. package/components/inputs/Select/Select.js +555 -682
  184. package/components/inputs/Select/Select.module.js +38 -0
  185. package/components/inputs/Slider/Slider.js +97 -128
  186. package/components/inputs/Slider/Slider.module.js +9 -0
  187. package/components/inputs/Switch/Switch.js +11 -8
  188. package/components/inputs/Textarea/Textarea.js +42 -58
  189. package/components/inputs/Textarea/Textarea.module.js +14 -0
  190. package/hooks/useClickOutside.js +17 -14
  191. package/hooks/useDebouncedValue.js +13 -14
  192. package/hooks/useElementSize.js +27 -22
  193. package/hooks/useEscapeLayer.js +28 -29
  194. package/hooks/useFocusTrap.js +27 -38
  195. package/hooks/useKeyboard.js +76 -64
  196. package/hooks/useMediaQuery.js +10 -15
  197. package/hooks/useNow.js +28 -33
  198. package/hooks/usePersistedState.js +98 -94
  199. package/hooks/usePortalPosition.js +25 -19
  200. package/hooks/useResizable.js +106 -104
  201. package/hooks/useTheme.js +28 -23
  202. package/index.css +2 -1
  203. package/index.js +97 -215
  204. package/index.layered.css +2 -3
  205. package/llms.txt +3 -0
  206. package/manifest.json +8 -0
  207. package/package.json +1 -1
  208. package/utils/formatBytes.js +29 -13
  209. package/utils/themeScript.js +6 -8
  210. package/utils/timeAgo.js +59 -32
  211. package/components/Accordion/Accordion.module.scss.js +0 -36
  212. package/components/ActionButton/ActionButton.module.scss.js +0 -47
  213. package/components/Alert/Alert.module.scss.js +0 -33
  214. package/components/Avatar/Avatar.module.scss.js +0 -43
  215. package/components/Badge/Badge.module.scss.js +0 -31
  216. package/components/Breadcrumbs/Breadcrumbs.module.scss.js +0 -17
  217. package/components/Button/Button.module.scss.js +0 -47
  218. package/components/Card/Card.module.scss.js +0 -60
  219. package/components/Chart/Chart.module.scss.js +0 -61
  220. package/components/Chip/Chip.module.scss.js +0 -59
  221. package/components/CodeBlock/CodeBlock.module.scss.js +0 -43
  222. package/components/CommandPalette/CommandPalette.module.scss.js +0 -49
  223. package/components/ConfirmDialog/ConfirmDialog.module.scss.js +0 -21
  224. package/components/Divider/Divider.module.scss.js +0 -31
  225. package/components/Draggable/Draggable.module.scss.js +0 -17
  226. package/components/Drawer/Drawer.module.scss.js +0 -119
  227. package/components/Dropdown/Dropdown.module.scss.js +0 -53
  228. package/components/Dropzone/Dropzone.module.scss.js +0 -21
  229. package/components/EmptyState/EmptyState.module.scss.js +0 -25
  230. package/components/Form/Form.module.scss.js +0 -29
  231. package/components/ImageViewer/ImageViewer.module.scss.js +0 -47
  232. package/components/Kbd/Kbd.module.scss.js +0 -17
  233. package/components/KeyValueList/KeyValueList.module.scss.js +0 -43
  234. package/components/Link/Link.module.scss.js +0 -16
  235. package/components/List/List.module.scss.js +0 -21
  236. package/components/Loader/Loader.module.scss.js +0 -70
  237. package/components/Modal/Modal.module.scss.js +0 -33
  238. package/components/PageHeader/PageHeader.module.scss.js +0 -43
  239. package/components/Pagination/Pagination.module.scss.js +0 -23
  240. package/components/Popover/Popover.module.scss.js +0 -21
  241. package/components/ProgressBar/ProgressBar.module.scss.js +0 -51
  242. package/components/RelativeTime/RelativeTime.module.scss.js +0 -7
  243. package/components/SegmentedControl/SegmentedControl.module.scss.js +0 -39
  244. package/components/Skeleton/Skeleton.module.scss.js +0 -25
  245. package/components/Spinner/Spinner.module.scss.js +0 -20
  246. package/components/SplitButton/SplitButton.module.scss.js +0 -57
  247. package/components/SplitPane/SplitPane.module.scss.js +0 -25
  248. package/components/StatCard/StatCard.module.scss.js +0 -72
  249. package/components/StatusDot/StatusDot.module.scss.js +0 -32
  250. package/components/Table/Table.module.scss.js +0 -81
  251. package/components/Tabs/Tabs.module.scss.js +0 -53
  252. package/components/ThemeToggle/ThemeToggle.module.scss.js +0 -23
  253. package/components/Timeline/GanttTimeline.module.scss.js +0 -55
  254. package/components/Timeline/HistoryTimeline.module.scss.js +0 -59
  255. package/components/Timeline/Timeline.module.scss.js +0 -141
  256. package/components/Timeline/TraceTimeline.module.scss.js +0 -189
  257. package/components/Timer/Timer.module.scss.js +0 -55
  258. package/components/Toast/Toast.module.scss.js +0 -62
  259. package/components/ToggleIconButton/ToggleIconButton.module.scss.js +0 -27
  260. package/components/Tooltip/Tooltip.module.scss.js +0 -30
  261. package/components/Typography/Typography.module.scss.js +0 -53
  262. package/components/inputs/Checkbox/Checkbox.module.scss.js +0 -17
  263. package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +0 -31
  264. package/components/inputs/DatePicker/CalendarPanel.module.scss.js +0 -41
  265. package/components/inputs/DatePicker/DatePicker.module.scss.js +0 -25
  266. package/components/inputs/DateTimePicker/DateTimePicker.module.scss.js +0 -37
  267. package/components/inputs/Input/Input.module.scss.js +0 -27
  268. package/components/inputs/NumberInput/NumberInput.module.scss.js +0 -25
  269. package/components/inputs/Radio/Radio.module.scss.js +0 -15
  270. package/components/inputs/SearchInput/SearchInput.module.scss.js +0 -13
  271. package/components/inputs/Select/Select.module.scss.js +0 -73
  272. package/components/inputs/Slider/Slider.module.scss.js +0 -15
  273. package/components/inputs/Textarea/Textarea.module.scss.js +0 -25
@@ -1,50 +1,36 @@
1
- import { jsx as n } from "react/jsx-runtime";
2
- import { forwardRef as y } from "react";
3
- import a from "clsx";
4
- import t from "./Skeleton.module.scss.js";
5
- const o = (e) => typeof e == "number" ? `${e}px` : e, w = y(
6
- ({ variant: e = "text", width: m, height: s, animation: l = "pulse", lines: r = 1, classes: i, className: p, style: d, ...f }, c) => {
7
- const h = l === "wave" ? t.wave : l === "none" ? void 0 : t.pulse;
8
- if (e === "text" && r > 1)
9
- return /* @__PURE__ */ n(
10
- "div",
11
- {
12
- ref: c,
13
- "aria-hidden": "true",
14
- className: a(t.stack, i?.root, p),
15
- style: d,
16
- ...f,
17
- children: Array.from({ length: r }).map((k, u) => /* @__PURE__ */ n(
18
- "span",
19
- {
20
- className: a(t.line, t.text, h, i?.line),
21
- style: {
22
- width: u === r - 1 ? "60%" : o(m) ?? "100%",
23
- height: o(s)
24
- }
25
- },
26
- u
27
- ))
28
- }
29
- );
30
- const x = {
31
- width: o(m),
32
- height: o(s),
33
- ...d
34
- };
35
- return /* @__PURE__ */ n(
36
- "div",
37
- {
38
- ref: c,
39
- "aria-hidden": "true",
40
- className: a(t.line, t[e], h, i?.root, p),
41
- style: x,
42
- ...f
43
- }
44
- );
45
- }
46
- );
47
- w.displayName = "Skeleton";
48
- export {
49
- w as Skeleton
50
- };
1
+ import e from "./Skeleton.module.js";
2
+ import { forwardRef as t } from "react";
3
+ import n from "clsx";
4
+ import { jsx as r } from "react/jsx-runtime";
5
+ // src/components/Skeleton/Skeleton.tsx
6
+ var i = (e) => typeof e == "number" ? `${e}px` : e, a = t(({ variant: t = "text", width: a, height: o, animation: s = "pulse", lines: c = 1, classes: l, className: u, style: d, ...f }, p) => {
7
+ let m = s === "wave" ? e.wave : s === "none" ? void 0 : e.pulse;
8
+ if (t === "text" && c > 1) return /* @__PURE__ */ r("div", {
9
+ ref: p,
10
+ "aria-hidden": "true",
11
+ className: n(e.stack, l?.root, u),
12
+ style: d,
13
+ ...f,
14
+ children: Array.from({ length: c }).map((t, s) => /* @__PURE__ */ r("span", {
15
+ className: n(e.line, e.text, m, l?.line),
16
+ style: {
17
+ width: s === c - 1 ? "60%" : i(a) ?? "100%",
18
+ height: i(o)
19
+ }
20
+ }, s))
21
+ });
22
+ let h = {
23
+ width: i(a),
24
+ height: i(o),
25
+ ...d
26
+ };
27
+ return /* @__PURE__ */ r("div", {
28
+ ref: p,
29
+ "aria-hidden": "true",
30
+ className: n(e.line, e[t], m, l?.root, u),
31
+ style: h,
32
+ ...f
33
+ });
34
+ });
35
+ a.displayName = "Skeleton";
36
+ export { a as Skeleton };
@@ -0,0 +1,15 @@
1
+ // src/components/Skeleton/Skeleton.module.scss
2
+ var e = "crk-line-8roAA", t = "crk-stack-8QHed", n = "crk-text-4oj9n", r = "crk-circle-o-WgD", i = "crk-rect-8lO4C", a = "crk-pulse-dX0ir", o = "crk-crk-skeleton-pulse-ZXPJJ", s = "crk-wave-S82D6", c = "crk-crk-skeleton-wave-rDp6Z", l = {
3
+ line: e,
4
+ stack: t,
5
+ text: n,
6
+ circle: r,
7
+ rect: i,
8
+ pulse: a,
9
+ "crk-skeleton-pulse": "crk-crk-skeleton-pulse-ZXPJJ",
10
+ crkSkeletonPulse: o,
11
+ wave: s,
12
+ "crk-skeleton-wave": "crk-crk-skeleton-wave-rDp6Z",
13
+ crkSkeletonWave: c
14
+ };
15
+ export { r as circle, o as crkSkeletonPulse, c as crkSkeletonWave, l as default, e as line, a as pulse, i as rect, t as stack, n as text, s as wave };
@@ -1,25 +1,25 @@
1
- import { jsxs as c, jsx as n } from "react/jsx-runtime";
2
- import { forwardRef as d } from "react";
3
- import a from "clsx";
4
- import r from "./Spinner.module.scss.js";
5
- const f = d(
6
- ({ size: t = "md", color: i, label: o = "Loading", classes: e, className: m, style: l, ...s }, p) => /* @__PURE__ */ c(
7
- "span",
8
- {
9
- ref: p,
10
- role: "status",
11
- "aria-live": "polite",
12
- className: a(r.root, r[t], e?.root, m),
13
- style: i ? { ...l, color: i } : l,
14
- ...s,
15
- children: [
16
- /* @__PURE__ */ n("span", { className: a(r.circle, e?.circle), "aria-hidden": "true" }),
17
- o ? /* @__PURE__ */ n("span", { className: a(r.label, e?.label), children: o }) : null
18
- ]
19
- }
20
- )
21
- );
22
- f.displayName = "Spinner";
23
- export {
24
- f as Spinner
25
- };
1
+ import e from "./Spinner.module.js";
2
+ import { forwardRef as t } from "react";
3
+ import n from "clsx";
4
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
5
+ // src/components/Spinner/Spinner.tsx
6
+ var a = t(({ size: t = "md", color: a, label: o = "Loading", classes: s, className: c, style: l, ...u }, d) => /* @__PURE__ */ i("span", {
7
+ ref: d,
8
+ role: "status",
9
+ "aria-live": "polite",
10
+ className: n(e.root, e[t], s?.root, c),
11
+ style: a ? {
12
+ ...l,
13
+ color: a
14
+ } : l,
15
+ ...u,
16
+ children: [/* @__PURE__ */ r("span", {
17
+ className: n(e.circle, s?.circle),
18
+ "aria-hidden": "true"
19
+ }), o ? /* @__PURE__ */ r("span", {
20
+ className: n(e.label, s?.label),
21
+ children: o
22
+ }) : null]
23
+ }));
24
+ a.displayName = "Spinner";
25
+ export { a as Spinner };
@@ -0,0 +1,12 @@
1
+ // src/components/Spinner/Spinner.module.scss
2
+ var e = "crk-root-wia8E", t = "crk-circle-8olrz", n = "crk-crk-spinner-rotate-vrMQr", r = "crk-sm-q2vog", i = "crk-md-kcEfs", a = "crk-lg-8yfDn", o = "crk-label-ahktK", s = {
3
+ root: e,
4
+ circle: t,
5
+ "crk-spinner-rotate": "crk-crk-spinner-rotate-vrMQr",
6
+ crkSpinnerRotate: n,
7
+ sm: r,
8
+ md: i,
9
+ lg: a,
10
+ label: o
11
+ };
12
+ export { t as circle, n as crkSpinnerRotate, s as default, o as label, a as lg, i as md, e as root, r as sm };
@@ -1,196 +1,149 @@
1
- import { jsxs as N, jsx as r } from "react/jsx-runtime";
2
- import { forwardRef as Y, useState as Z, useRef as L, useId as $, useEffect as q, useCallback as F } from "react";
3
- import { createPortal as ee } from "react-dom";
4
- import i from "clsx";
5
- import t from "./SplitButton.module.scss.js";
6
- import h from "../Button/Button.module.scss.js";
7
- import { useEscapeLayer as te, EscapeLayerProvider as ne } from "../../hooks/useEscapeLayer.js";
8
- import { usePortalPosition as re } from "../../hooks/usePortalPosition.js";
9
- const oe = Y(
10
- ({
11
- actions: g,
12
- variant: b = "secondary",
13
- size: S = "md",
14
- disabled: O = !1,
15
- align: v = "right",
16
- portal: y = !0,
17
- menuLabel: G = "More actions",
18
- maxWidth: k,
19
- className: H,
20
- style: w,
21
- id: x,
22
- onOpen: I,
23
- onClose: c,
24
- classes: s
25
- }, J) => {
26
- const [n, E] = Z(!1), C = L(null), u = L(null), R = L(null), M = $();
27
- q(() => {
28
- n && u.current && u.current.querySelector('[role="menuitem"]:not([disabled])')?.focus();
29
- }, [n]);
30
- const f = F(() => {
31
- E(!1), c?.(), R.current?.focus();
32
- }, [c]), K = F(() => {
33
- E((e) => {
34
- const l = !e;
35
- return l ? I?.() : c?.(), l;
36
- });
37
- }, [I, c]);
38
- q(() => {
39
- if (!n) return;
40
- const e = (l) => {
41
- const m = l.target;
42
- C.current?.contains(m) || u.current?.contains(m) || f();
43
- };
44
- return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
45
- }, [n, f]);
46
- const Q = te(f, n), d = re(C, n && y);
47
- if (g.length === 0) return null;
48
- const [o, ...P] = g, a = P.length > 0, z = O || o.disabled, B = i(h.root, h[b], h[S]), T = b === "secondary" ? t.overlapOutline : b === "ghost" ? t.dividerSubtle : t.dividerOnFill, j = i(
49
- B,
50
- t.main,
51
- a && t.mainAttached,
52
- a && n && t.mainOpen,
53
- s?.main
54
- ), p = (e) => k !== void 0 && (typeof e == "string" || typeof e == "number") ? String(e) : void 0, D = /* @__PURE__ */ N("span", { className: t.mainContent, children: [
55
- /* @__PURE__ */ r("span", { className: t.mainLabel, children: o.label }),
56
- a && /* @__PURE__ */ r("span", { className: t.sizer, "aria-hidden": "true", children: g.map((e, l) => /* @__PURE__ */ r("span", { className: t.sizerItem, children: e.label }, l)) })
57
- ] }), U = o.href && !z ? /* @__PURE__ */ r(
58
- "a",
59
- {
60
- id: x,
61
- className: j,
62
- href: o.href,
63
- target: o.target,
64
- rel: o.target === "_blank" ? "noopener noreferrer" : void 0,
65
- title: p(o.label),
66
- onClick: o.onClick,
67
- children: D
68
- }
69
- ) : /* @__PURE__ */ r(
70
- "button",
71
- {
72
- id: x,
73
- type: "button",
74
- className: j,
75
- disabled: z,
76
- title: p(o.label),
77
- onClick: o.onClick,
78
- children: D
79
- }
80
- ), V = P.map((e, l) => {
81
- const m = i(
82
- t.item,
83
- e.disabled && t.itemDisabled,
84
- e.danger && t.itemDanger,
85
- s?.item
86
- ), _ = (X) => {
87
- e.onClick?.(X), f();
88
- };
89
- return e.href && !e.disabled ? /* @__PURE__ */ r(
90
- "a",
91
- {
92
- role: "menuitem",
93
- className: m,
94
- href: e.href,
95
- target: e.target,
96
- rel: e.target === "_blank" ? "noopener noreferrer" : void 0,
97
- title: p(e.label),
98
- onClick: _,
99
- children: e.label
100
- },
101
- l
102
- ) : /* @__PURE__ */ r(
103
- "button",
104
- {
105
- type: "button",
106
- role: "menuitem",
107
- className: m,
108
- disabled: e.disabled,
109
- title: p(e.label),
110
- onClick: _,
111
- children: e.label
112
- },
113
- l
114
- );
115
- }), W = { sm: t.menuSm, md: t.menuMd, lg: t.menuLg }[S], A = (e) => /* @__PURE__ */ r(
116
- "div",
117
- {
118
- ref: u,
119
- id: M,
120
- className: i(
121
- t.menu,
122
- W,
123
- n && t.menuOpen,
124
- v === "left" ? t.alignLeft : t.alignRight,
125
- s?.menu
126
- ),
127
- style: e,
128
- role: "menu",
129
- children: /* @__PURE__ */ r(ne, { value: Q, children: V })
130
- }
131
- );
132
- return /* @__PURE__ */ N(
133
- "div",
134
- {
135
- ref: J,
136
- className: i(t.root, s?.root, H),
137
- style: k !== void 0 ? { maxWidth: k, ...w } : w,
138
- children: [
139
- /* @__PURE__ */ N("div", { ref: C, className: i(t.group, s?.group), children: [
140
- U,
141
- a && /* @__PURE__ */ r(
142
- "button",
143
- {
144
- ref: R,
145
- type: "button",
146
- className: i(
147
- B,
148
- h.iconOnly,
149
- t.toggle,
150
- n && t.toggleOpen,
151
- T,
152
- s?.toggle
153
- ),
154
- disabled: O,
155
- onClick: K,
156
- "aria-haspopup": "menu",
157
- "aria-expanded": n,
158
- "aria-controls": n ? M : void 0,
159
- "aria-label": G,
160
- children: /* @__PURE__ */ r(
161
- "svg",
162
- {
163
- className: i(t.chevron, n && t.chevronOpen, s?.chevron),
164
- viewBox: "0 0 10 6",
165
- "aria-hidden": "true",
166
- children: /* @__PURE__ */ r("path", { d: "M1 1l4 4 4-4", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
167
- }
168
- )
169
- }
170
- )
171
- ] }),
172
- a && !y && A(),
173
- a && y && n && typeof document < "u" && ee(
174
- A({
175
- position: "fixed",
176
- top: d.top,
177
- left: v === "right" ? void 0 : d.left,
178
- // clientWidth, not innerWidth: `right` on a fixed element is
179
- // measured from the viewport edge inside the scrollbar, while
180
- // innerWidth includes it — the menu would shift left by the
181
- // scrollbar width whenever the page scrolls.
182
- right: v === "right" ? document.documentElement.clientWidth - (d.left + d.width) : void 0,
183
- width: d.width,
184
- zIndex: "var(--crk-z-floating)"
185
- }),
186
- document.body
187
- )
188
- ]
189
- }
190
- );
191
- }
192
- );
193
- oe.displayName = "SplitButton";
194
- export {
195
- oe as SplitButton
196
- };
1
+ import e from "./SplitButton.module.js";
2
+ import t from "../Button/Button.module.js";
3
+ import { EscapeLayerProvider as n, useEscapeLayer as r } from "../../hooks/useEscapeLayer.js";
4
+ import { usePortalPosition as i } from "../../hooks/usePortalPosition.js";
5
+ import { forwardRef as a, useCallback as o, useEffect as s, useId as c, useRef as l, useState as u } from "react";
6
+ import d from "clsx";
7
+ import { jsx as f, jsxs as p } from "react/jsx-runtime";
8
+ import { createPortal as m } from "react-dom";
9
+ // src/components/SplitButton/SplitButton.tsx
10
+ var h = a(({ actions: a, variant: h = "secondary", size: g = "md", disabled: _ = !1, align: v = "right", portal: y = !0, menuLabel: b = "More actions", maxWidth: x, className: S, style: C, id: w, onOpen: T, onClose: E, classes: D }, O) => {
11
+ let [k, A] = u(!1), j = l(null), M = l(null), N = l(null), P = c();
12
+ s(() => {
13
+ k && M.current && M.current.querySelector("[role=\"menuitem\"]:not([disabled])")?.focus();
14
+ }, [k]);
15
+ let F = o(() => {
16
+ A(!1), E?.(), N.current?.focus();
17
+ }, [E]), I = o(() => {
18
+ A((e) => {
19
+ let t = !e;
20
+ return t ? T?.() : E?.(), t;
21
+ });
22
+ }, [T, E]);
23
+ s(() => {
24
+ if (!k) return;
25
+ let e = (e) => {
26
+ let t = e.target;
27
+ j.current?.contains(t) || M.current?.contains(t) || F();
28
+ };
29
+ return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
30
+ }, [k, F]);
31
+ let L = r(F, k), R = i(j, k && y);
32
+ if (a.length === 0) return null;
33
+ let [z, ...B] = a, V = B.length > 0, H = _ || z.disabled, U = d(t.root, t[h], t[g]), W = h === "secondary" ? e.overlapOutline : h === "ghost" ? e.dividerSubtle : e.dividerOnFill, G = d(U, e.main, V && e.mainAttached, V && k && e.mainOpen, D?.main), K = (e) => x !== void 0 && (typeof e == "string" || typeof e == "number") ? String(e) : void 0, q = /* @__PURE__ */ p("span", {
34
+ className: e.mainContent,
35
+ children: [/* @__PURE__ */ f("span", {
36
+ className: e.mainLabel,
37
+ children: z.label
38
+ }), V && /* @__PURE__ */ f("span", {
39
+ className: e.sizer,
40
+ "aria-hidden": "true",
41
+ children: a.map((t, n) => /* @__PURE__ */ f("span", {
42
+ className: e.sizerItem,
43
+ children: t.label
44
+ }, n))
45
+ })]
46
+ }), J = z.href && !H ? /* @__PURE__ */ f("a", {
47
+ id: w,
48
+ className: G,
49
+ href: z.href,
50
+ target: z.target,
51
+ rel: z.target === "_blank" ? "noopener noreferrer" : void 0,
52
+ title: K(z.label),
53
+ onClick: z.onClick,
54
+ children: q
55
+ }) : /* @__PURE__ */ f("button", {
56
+ id: w,
57
+ type: "button",
58
+ className: G,
59
+ disabled: H,
60
+ title: K(z.label),
61
+ onClick: z.onClick,
62
+ children: q
63
+ }), Y = B.map((t, n) => {
64
+ let r = d(e.item, t.disabled && e.itemDisabled, t.danger && e.itemDanger, D?.item), i = (e) => {
65
+ t.onClick?.(e), F();
66
+ };
67
+ return t.href && !t.disabled ? /* @__PURE__ */ f("a", {
68
+ role: "menuitem",
69
+ className: r,
70
+ href: t.href,
71
+ target: t.target,
72
+ rel: t.target === "_blank" ? "noopener noreferrer" : void 0,
73
+ title: K(t.label),
74
+ onClick: i,
75
+ children: t.label
76
+ }, n) : /* @__PURE__ */ f("button", {
77
+ type: "button",
78
+ role: "menuitem",
79
+ className: r,
80
+ disabled: t.disabled,
81
+ title: K(t.label),
82
+ onClick: i,
83
+ children: t.label
84
+ }, n);
85
+ }), X = {
86
+ sm: e.menuSm,
87
+ md: e.menuMd,
88
+ lg: e.menuLg
89
+ }[g], Z = (t) => /* @__PURE__ */ f("div", {
90
+ ref: M,
91
+ id: P,
92
+ className: d(e.menu, X, k && e.menuOpen, v === "left" ? e.alignLeft : e.alignRight, D?.menu),
93
+ style: t,
94
+ role: "menu",
95
+ children: /* @__PURE__ */ f(n, {
96
+ value: L,
97
+ children: Y
98
+ })
99
+ });
100
+ return /* @__PURE__ */ p("div", {
101
+ ref: O,
102
+ className: d(e.root, D?.root, S),
103
+ style: x === void 0 ? C : {
104
+ maxWidth: x,
105
+ ...C
106
+ },
107
+ children: [
108
+ /* @__PURE__ */ p("div", {
109
+ ref: j,
110
+ className: d(e.group, D?.group),
111
+ children: [J, V && /* @__PURE__ */ f("button", {
112
+ ref: N,
113
+ type: "button",
114
+ className: d(U, t.iconOnly, e.toggle, k && e.toggleOpen, W, D?.toggle),
115
+ disabled: _,
116
+ onClick: I,
117
+ "aria-haspopup": "menu",
118
+ "aria-expanded": k,
119
+ "aria-controls": k ? P : void 0,
120
+ "aria-label": b,
121
+ children: /* @__PURE__ */ f("svg", {
122
+ className: d(e.chevron, k && e.chevronOpen, D?.chevron),
123
+ viewBox: "0 0 10 6",
124
+ "aria-hidden": "true",
125
+ children: /* @__PURE__ */ f("path", {
126
+ d: "M1 1l4 4 4-4",
127
+ fill: "none",
128
+ stroke: "currentColor",
129
+ strokeWidth: "1.5",
130
+ strokeLinecap: "round",
131
+ strokeLinejoin: "round"
132
+ })
133
+ })
134
+ })]
135
+ }),
136
+ V && !y && Z(),
137
+ V && y && k && typeof document < "u" && m(Z({
138
+ position: "fixed",
139
+ top: R.top,
140
+ left: v === "right" ? void 0 : R.left,
141
+ right: v === "right" ? document.documentElement.clientWidth - (R.left + R.width) : void 0,
142
+ width: R.width,
143
+ zIndex: "var(--crk-z-floating)"
144
+ }), document.body)
145
+ ]
146
+ });
147
+ });
148
+ h.displayName = "SplitButton";
149
+ export { h as SplitButton };
@@ -0,0 +1,31 @@
1
+ // src/components/SplitButton/SplitButton.module.scss
2
+ var e = "crk-root-WQNOC", t = "crk-group-vpjIZ", n = "crk-main-rC6D1", r = "crk-mainContent-ztmsF", i = "crk-mainLabel-nGrtw", a = "crk-sizer-PLveG", o = "crk-sizerItem-dwWwd", s = "crk-mainAttached-AhE-l", c = "crk-toggle-yVTi-", l = "crk-mainOpen-7hEXl", u = "crk-toggleOpen-56O29", d = "crk-dividerOnFill-HLKeu", f = "crk-dividerSubtle-g-TfH", p = "crk-overlapOutline-yWbkD", m = "crk-chevron-4zed5", h = "crk-chevronOpen-7vOPn", g = "crk-menu-2ijiM", _ = "crk-menuOpen-hANn0", v = "crk-menuEnter-xjAuj", y = "crk-menuSm-WBQSi", b = "crk-menuMd-xjRTT", x = "crk-menuLg-rXDWh", S = "crk-alignLeft-aXK9A", C = "crk-alignRight-ANsBn", w = "crk-item-rolo0", T = "crk-itemDisabled-A7T-8", E = "crk-itemDanger-g19Qe", D = {
3
+ root: e,
4
+ group: t,
5
+ main: n,
6
+ mainContent: r,
7
+ mainLabel: i,
8
+ sizer: a,
9
+ sizerItem: o,
10
+ mainAttached: s,
11
+ toggle: c,
12
+ mainOpen: l,
13
+ toggleOpen: u,
14
+ dividerOnFill: d,
15
+ dividerSubtle: f,
16
+ overlapOutline: p,
17
+ chevron: m,
18
+ chevronOpen: h,
19
+ menu: g,
20
+ menuOpen: _,
21
+ menuEnter: v,
22
+ menuSm: y,
23
+ menuMd: b,
24
+ menuLg: x,
25
+ alignLeft: S,
26
+ alignRight: C,
27
+ item: w,
28
+ itemDisabled: T,
29
+ itemDanger: E
30
+ };
31
+ export { S as alignLeft, C as alignRight, m as chevron, h as chevronOpen, D as default, d as dividerOnFill, f as dividerSubtle, t as group, w as item, E as itemDanger, T as itemDisabled, n as main, s as mainAttached, r as mainContent, i as mainLabel, l as mainOpen, g as menu, v as menuEnter, x as menuLg, b as menuMd, _ as menuOpen, y as menuSm, p as overlapOutline, e as root, a as sizer, o as sizerItem, c as toggle, u as toggleOpen };