@overdoser/react-toolkit 0.19.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 (279) hide show
  1. package/AGENTS.md +2 -2
  2. package/CHANGELOG.md +47 -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 +41 -16
  123. package/components/Table/Table.js +383 -442
  124. package/components/Table/Table.module.js +42 -0
  125. package/components/Table/index.d.ts +1 -1
  126. package/components/Table/useTableSort.d.ts +1 -1
  127. package/components/Table/useTableSort.js +51 -42
  128. package/components/Tabs/Tabs.js +109 -161
  129. package/components/Tabs/Tabs.module.js +28 -0
  130. package/components/ThemeToggle/ThemeToggle.d.ts +2 -0
  131. package/components/ThemeToggle/ThemeToggle.js +122 -97
  132. package/components/ThemeToggle/ThemeToggle.module.js +13 -0
  133. package/components/Timeline/GanttTimeline.js +357 -318
  134. package/components/Timeline/GanttTimeline.module.js +29 -0
  135. package/components/Timeline/HistoryTimeline.js +486 -450
  136. package/components/Timeline/HistoryTimeline.module.js +31 -0
  137. package/components/Timeline/Timeline.module.js +76 -0
  138. package/components/Timeline/TimelineShared.d.ts +7 -7
  139. package/components/Timeline/TimelineShared.js +288 -279
  140. package/components/Timeline/TraceEventDetails.d.ts +3 -3
  141. package/components/Timeline/TraceEventDetails.js +245 -178
  142. package/components/Timeline/TraceTimeline.js +823 -783
  143. package/components/Timeline/TraceTimeline.module.js +98 -0
  144. package/components/Timeline/historyLayout.js +336 -263
  145. package/components/Timeline/timelineCore.js +208 -183
  146. package/components/Timeline/traceEvent.js +59 -61
  147. package/components/Timeline/traceLayout.js +101 -90
  148. package/components/Timeline/useTimeline.js +76 -79
  149. package/components/Timer/Timer.js +190 -156
  150. package/components/Timer/Timer.module.js +29 -0
  151. package/components/Toast/Toast.d.ts +1 -1
  152. package/components/Toast/Toast.js +128 -128
  153. package/components/Toast/Toast.module.js +37 -0
  154. package/components/Toast/toastStore.js +58 -62
  155. package/components/ToggleIconButton/ToggleIconButton.js +35 -57
  156. package/components/ToggleIconButton/ToggleIconButton.module.js +15 -0
  157. package/components/Tooltip/Tooltip.d.ts +1 -1
  158. package/components/Tooltip/Tooltip.js +76 -85
  159. package/components/Tooltip/Tooltip.module.js +17 -0
  160. package/components/Typography/Typography.js +11 -36
  161. package/components/Typography/Typography.module.js +30 -0
  162. package/components/inputs/Checkbox/Checkbox.js +27 -51
  163. package/components/inputs/Checkbox/Checkbox.module.js +10 -0
  164. package/components/inputs/Checkbox/CheckboxGroup.js +53 -111
  165. package/components/inputs/Checkbox/CheckboxGroup.module.js +17 -0
  166. package/components/inputs/DatePicker/CalendarPanel.d.ts +1 -1
  167. package/components/inputs/DatePicker/CalendarPanel.js +263 -286
  168. package/components/inputs/DatePicker/CalendarPanel.module.js +23 -0
  169. package/components/inputs/DatePicker/DatePicker.js +115 -142
  170. package/components/inputs/DatePicker/DatePicker.module.js +14 -0
  171. package/components/inputs/DatePicker/dateUtils.js +32 -41
  172. package/components/inputs/DateTimePicker/DateTimePicker.js +226 -232
  173. package/components/inputs/DateTimePicker/DateTimePicker.module.js +20 -0
  174. package/components/inputs/DateTimePicker/DateTimeSegments.js +273 -252
  175. package/components/inputs/DateTimePicker/TimeField.d.ts +1 -1
  176. package/components/inputs/DateTimePicker/TimeField.js +131 -132
  177. package/components/inputs/DateTimePicker/timeZoneUtils.js +95 -92
  178. package/components/inputs/Input/Input.js +98 -109
  179. package/components/inputs/Input/Input.module.js +15 -0
  180. package/components/inputs/NumberInput/NumberInput.js +112 -132
  181. package/components/inputs/NumberInput/NumberInput.module.js +14 -0
  182. package/components/inputs/Radio/Radio.js +50 -73
  183. package/components/inputs/Radio/Radio.module.js +9 -0
  184. package/components/inputs/SearchInput/SearchInput.js +98 -115
  185. package/components/inputs/SearchInput/SearchInput.module.js +8 -0
  186. package/components/inputs/Select/Select.js +555 -682
  187. package/components/inputs/Select/Select.module.js +38 -0
  188. package/components/inputs/Slider/Slider.js +97 -128
  189. package/components/inputs/Slider/Slider.module.js +9 -0
  190. package/components/inputs/Switch/Switch.js +11 -8
  191. package/components/inputs/Textarea/Textarea.js +42 -58
  192. package/components/inputs/Textarea/Textarea.module.js +14 -0
  193. package/hooks/useClickOutside.js +17 -14
  194. package/hooks/useDebouncedValue.js +13 -14
  195. package/hooks/useElementSize.js +27 -22
  196. package/hooks/useEscapeLayer.js +28 -29
  197. package/hooks/useFocusTrap.js +27 -38
  198. package/hooks/useKeyboard.js +76 -64
  199. package/hooks/useMediaQuery.js +10 -15
  200. package/hooks/useNow.js +28 -33
  201. package/hooks/usePersistedState.js +98 -91
  202. package/hooks/usePortalPosition.js +25 -19
  203. package/hooks/useResizable.js +106 -104
  204. package/hooks/useTheme.d.ts +2 -2
  205. package/hooks/useTheme.js +28 -25
  206. package/index.css +2 -1
  207. package/index.d.ts +1 -1
  208. package/index.js +97 -215
  209. package/index.layered.css +2 -3
  210. package/llms.txt +9 -6
  211. package/manifest.json +66 -10
  212. package/package.json +1 -1
  213. package/utils/formatBytes.js +29 -13
  214. package/utils/themeScript.d.ts +2 -0
  215. package/utils/themeScript.js +6 -8
  216. package/utils/timeAgo.js +59 -32
  217. package/components/Accordion/Accordion.module.scss.js +0 -36
  218. package/components/ActionButton/ActionButton.module.scss.js +0 -47
  219. package/components/Alert/Alert.module.scss.js +0 -33
  220. package/components/Avatar/Avatar.module.scss.js +0 -43
  221. package/components/Badge/Badge.module.scss.js +0 -31
  222. package/components/Breadcrumbs/Breadcrumbs.module.scss.js +0 -17
  223. package/components/Button/Button.module.scss.js +0 -47
  224. package/components/Card/Card.module.scss.js +0 -60
  225. package/components/Chart/Chart.module.scss.js +0 -61
  226. package/components/Chip/Chip.module.scss.js +0 -59
  227. package/components/CodeBlock/CodeBlock.module.scss.js +0 -43
  228. package/components/CommandPalette/CommandPalette.module.scss.js +0 -49
  229. package/components/ConfirmDialog/ConfirmDialog.module.scss.js +0 -21
  230. package/components/Divider/Divider.module.scss.js +0 -31
  231. package/components/Draggable/Draggable.module.scss.js +0 -17
  232. package/components/Drawer/Drawer.module.scss.js +0 -119
  233. package/components/Dropdown/Dropdown.module.scss.js +0 -53
  234. package/components/Dropzone/Dropzone.module.scss.js +0 -21
  235. package/components/EmptyState/EmptyState.module.scss.js +0 -25
  236. package/components/Form/Form.module.scss.js +0 -29
  237. package/components/ImageViewer/ImageViewer.module.scss.js +0 -47
  238. package/components/Kbd/Kbd.module.scss.js +0 -17
  239. package/components/KeyValueList/KeyValueList.module.scss.js +0 -43
  240. package/components/Link/Link.module.scss.js +0 -16
  241. package/components/List/List.module.scss.js +0 -21
  242. package/components/Loader/Loader.module.scss.js +0 -70
  243. package/components/Modal/Modal.module.scss.js +0 -33
  244. package/components/PageHeader/PageHeader.module.scss.js +0 -43
  245. package/components/Pagination/Pagination.module.scss.js +0 -23
  246. package/components/Popover/Popover.module.scss.js +0 -21
  247. package/components/ProgressBar/ProgressBar.module.scss.js +0 -51
  248. package/components/RelativeTime/RelativeTime.module.scss.js +0 -7
  249. package/components/SegmentedControl/SegmentedControl.module.scss.js +0 -39
  250. package/components/Skeleton/Skeleton.module.scss.js +0 -25
  251. package/components/Spinner/Spinner.module.scss.js +0 -20
  252. package/components/SplitButton/SplitButton.module.scss.js +0 -57
  253. package/components/SplitPane/SplitPane.module.scss.js +0 -25
  254. package/components/StatCard/StatCard.module.scss.js +0 -72
  255. package/components/StatusDot/StatusDot.module.scss.js +0 -32
  256. package/components/Table/Table.module.scss.js +0 -81
  257. package/components/Tabs/Tabs.module.scss.js +0 -53
  258. package/components/ThemeToggle/ThemeToggle.module.scss.js +0 -23
  259. package/components/Timeline/GanttTimeline.module.scss.js +0 -55
  260. package/components/Timeline/HistoryTimeline.module.scss.js +0 -59
  261. package/components/Timeline/Timeline.module.scss.js +0 -141
  262. package/components/Timeline/TraceTimeline.module.scss.js +0 -189
  263. package/components/Timer/Timer.module.scss.js +0 -55
  264. package/components/Toast/Toast.module.scss.js +0 -62
  265. package/components/ToggleIconButton/ToggleIconButton.module.scss.js +0 -27
  266. package/components/Tooltip/Tooltip.module.scss.js +0 -30
  267. package/components/Typography/Typography.module.scss.js +0 -53
  268. package/components/inputs/Checkbox/Checkbox.module.scss.js +0 -17
  269. package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +0 -31
  270. package/components/inputs/DatePicker/CalendarPanel.module.scss.js +0 -41
  271. package/components/inputs/DatePicker/DatePicker.module.scss.js +0 -25
  272. package/components/inputs/DateTimePicker/DateTimePicker.module.scss.js +0 -37
  273. package/components/inputs/Input/Input.module.scss.js +0 -27
  274. package/components/inputs/NumberInput/NumberInput.module.scss.js +0 -25
  275. package/components/inputs/Radio/Radio.module.scss.js +0 -15
  276. package/components/inputs/SearchInput/SearchInput.module.scss.js +0 -13
  277. package/components/inputs/Select/Select.module.scss.js +0 -73
  278. package/components/inputs/Slider/Slider.module.scss.js +0 -15
  279. package/components/inputs/Textarea/Textarea.module.scss.js +0 -25
@@ -0,0 +1,42 @@
1
+ // src/components/Table/Table.module.scss
2
+ var e = "crk-wrapper-zxjMt", t = "crk-scrollable-Apjbs", n = "crk-root-Gf85-", r = "crk-paginator-UlYIY", i = "crk-dragging-dAaIR", a = "crk-headerCell-ePPZW", o = "crk-headerCellSticky-Qwz3q", s = "crk-cellSticky-LwmbD", c = "crk-headerCellSortable-NMybk", l = "crk-sortIndicator-WGD2S", u = "crk-sortArrow-1-ok4", d = "crk-sortArrowActive-yhWrO", f = "crk-sortIndex-HGoca", p = "crk-row-H0wL1", m = "crk-cell-ZfnbG", h = "crk-emptyRow-AoPfj", g = "crk-emptyCell-99-7C", _ = "crk-loaderWrap-Bug3B", v = "crk-loadingRow-i25F2", y = "crk-rowClickable--9VTD", b = "crk-rowSelected-ucID4", x = "crk-hoverable-ljU9B", S = "crk-selectHeaderCell-sK1ej", C = "crk-selectCell-4A3ho", w = "crk-layoutFixed-PUK1R", T = "crk-bulkBar-OPem5", E = "crk-bulkLabel-Z5fZQ", D = "crk-bulkClear--wKbf", O = "crk-bulkActions-jm9bq", k = "crk-striped-6Qckq", A = "crk-compact-2-UWr", j = "crk-paginatorInfo-BVca4", M = "crk-paginatorText-sqWS0", N = "crk-pageSizeSelect-yhqJQ", P = "crk-paginatorNav-MDSui", F = "crk-pageButton-1PX-g", I = "crk-pageButtonActive--D7Q7", L = "crk-pageEllipsis-en59J", R = {
3
+ wrapper: e,
4
+ scrollable: t,
5
+ root: n,
6
+ paginator: r,
7
+ dragging: i,
8
+ headerCell: a,
9
+ headerCellSticky: o,
10
+ cellSticky: s,
11
+ headerCellSortable: c,
12
+ sortIndicator: l,
13
+ sortArrow: u,
14
+ sortArrowActive: d,
15
+ sortIndex: f,
16
+ row: p,
17
+ cell: m,
18
+ emptyRow: h,
19
+ emptyCell: g,
20
+ loaderWrap: _,
21
+ loadingRow: v,
22
+ rowClickable: y,
23
+ rowSelected: b,
24
+ hoverable: x,
25
+ selectHeaderCell: S,
26
+ selectCell: C,
27
+ layoutFixed: w,
28
+ bulkBar: T,
29
+ bulkLabel: E,
30
+ bulkClear: D,
31
+ bulkActions: O,
32
+ striped: k,
33
+ compact: A,
34
+ paginatorInfo: j,
35
+ paginatorText: M,
36
+ pageSizeSelect: N,
37
+ paginatorNav: P,
38
+ pageButton: F,
39
+ pageButtonActive: I,
40
+ pageEllipsis: L
41
+ };
42
+ export { O as bulkActions, T as bulkBar, D as bulkClear, E as bulkLabel, m as cell, s as cellSticky, A as compact, R as default, i as dragging, g as emptyCell, h as emptyRow, a as headerCell, c as headerCellSortable, o as headerCellSticky, x as hoverable, w as layoutFixed, _ as loaderWrap, v as loadingRow, F as pageButton, I as pageButtonActive, L as pageEllipsis, N as pageSizeSelect, r as paginator, j as paginatorInfo, P as paginatorNav, M as paginatorText, n as root, p as row, y as rowClickable, b as rowSelected, t as scrollable, C as selectCell, S as selectHeaderCell, u as sortArrow, d as sortArrowActive, f as sortIndex, l as sortIndicator, k as striped, e as wrapper };
@@ -1,4 +1,4 @@
1
1
  export { Table } from './Table';
2
- export type { TableProps, TableClasses, ColumnDef, PaginationConfig, TableRowKey, TableBulkActionsContext } from './Table';
2
+ export type { TableProps, TableClasses, ColumnDef, DataColumnDef, DisplayColumnDef, PaginationConfig, TableRowKey, TableBulkActionsContext } from './Table';
3
3
  export { useTableSort } from './useTableSort';
4
4
  export type { SortConfig } from './useTableSort';
@@ -26,7 +26,7 @@ export interface SortConfig {
26
26
  * const { sortedData, sortConfig, requestSort } = useTableSort(users);
27
27
  * ```
28
28
  */
29
- export declare function useTableSort<T extends Record<string, unknown>>(data: T[], initialSort?: SortConfig[]): {
29
+ export declare function useTableSort<T extends object>(data: T[], initialSort?: SortConfig[]): {
30
30
  sortedData: T[];
31
31
  sortConfig: SortConfig[];
32
32
  requestSort: (key: keyof T & string, startDirection?: 'asc' | 'desc') => void;
@@ -1,44 +1,53 @@
1
- import { useState as m, useCallback as l, useMemo as p } from "react";
2
- function C(n, s) {
3
- return n == null && s == null ? 0 : n == null ? -1 : s == null ? 1 : typeof n == "number" && typeof s == "number" ? n - s : String(n).localeCompare(String(s));
1
+ import { useCallback as e, useMemo as t, useState as n } from "react";
2
+ // src/components/Table/useTableSort.ts
3
+ function r(e, t) {
4
+ return e == null && t == null ? 0 : e == null ? -1 : t == null ? 1 : typeof e == "number" && typeof t == "number" ? e - t : String(e).localeCompare(String(t));
4
5
  }
5
- function M(n, s = []) {
6
- const [c, f] = m(s), g = l(
7
- (e, r = "asc") => {
8
- const i = r === "asc" ? "desc" : "asc";
9
- f((o) => {
10
- const t = o.find((d) => d.key === e);
11
- return t ? t.direction === r ? [{ key: e, direction: i }] : [] : [{ key: e, direction: r }];
12
- });
13
- },
14
- []
15
- ), x = l(
16
- (e, r = "asc") => {
17
- const i = r === "asc" ? "desc" : "asc";
18
- f((o) => {
19
- const t = o.findIndex((u) => u.key === e);
20
- if (t === -1)
21
- return [...o, { key: e, direction: r }];
22
- if (o[t].direction === r) {
23
- const u = [...o];
24
- return u[t] = { key: e, direction: i }, u;
25
- }
26
- return o.filter((u, a) => a !== t);
27
- });
28
- },
29
- []
30
- ), S = l(() => {
31
- f([]);
32
- }, []);
33
- return { sortedData: p(() => c.length === 0 ? n : [...n].sort((e, r) => {
34
- for (const { key: i, direction: o } of c) {
35
- const t = C(e[i], r[i]);
36
- if (t !== 0)
37
- return o === "asc" ? t : -t;
38
- }
39
- return 0;
40
- }), [n, c]), sortConfig: c, requestSort: g, requestMultiSort: x, resetSort: S };
6
+ function i(i, a = []) {
7
+ let [o, s] = n(a), c = e((e, t = "asc") => {
8
+ let n = t === "asc" ? "desc" : "asc";
9
+ s((r) => {
10
+ let i = r.find((t) => t.key === e);
11
+ return i ? i.direction === t ? [{
12
+ key: e,
13
+ direction: n
14
+ }] : [] : [{
15
+ key: e,
16
+ direction: t
17
+ }];
18
+ });
19
+ }, []), l = e((e, t = "asc") => {
20
+ let n = t === "asc" ? "desc" : "asc";
21
+ s((r) => {
22
+ let i = r.findIndex((t) => t.key === e);
23
+ if (i === -1) return [...r, {
24
+ key: e,
25
+ direction: t
26
+ }];
27
+ if (r[i].direction === t) {
28
+ let t = [...r];
29
+ return t[i] = {
30
+ key: e,
31
+ direction: n
32
+ }, t;
33
+ }
34
+ return r.filter((e, t) => t !== i);
35
+ });
36
+ }, []), u = e(() => {
37
+ s([]);
38
+ }, []);
39
+ return {
40
+ sortedData: t(() => o.length === 0 ? i : [...i].sort((e, t) => {
41
+ for (let { key: n, direction: i } of o) {
42
+ let a = r(e[n], t[n]);
43
+ if (a !== 0) return i === "asc" ? a : -a;
44
+ }
45
+ return 0;
46
+ }), [i, o]),
47
+ sortConfig: o,
48
+ requestSort: c,
49
+ requestMultiSort: l,
50
+ resetSort: u
51
+ };
41
52
  }
42
- export {
43
- M as useTableSort
44
- };
53
+ export { i as useTableSort };
@@ -1,163 +1,111 @@
1
- import { jsx as m } from "react/jsx-runtime";
2
- import { forwardRef as x, useId as R, useState as L, useCallback as g, useRef as V, createContext as D, useContext as S } from "react";
3
- import $ from "clsx";
4
- import d from "./Tabs.module.scss.js";
5
- const N = D(null);
6
- function I(e) {
7
- const n = S(N);
8
- if (!n) throw new Error(`${e} must be rendered inside a <Tabs>.`);
9
- return n;
1
+ import e from "./Tabs.module.js";
2
+ import { createContext as t, forwardRef as n, useCallback as r, useContext as i, useId as a, useRef as o, useState as s } from "react";
3
+ import c from "clsx";
4
+ import { jsx as l } from "react/jsx-runtime";
5
+ // src/components/Tabs/Tabs.tsx
6
+ var u = t(null);
7
+ function d(e) {
8
+ let t = i(u);
9
+ if (!t) throw Error(`${e} must be rendered inside a <Tabs>.`);
10
+ return t;
10
11
  }
11
- const k = x(
12
- ({
13
- value: e,
14
- defaultValue: n,
15
- onValueChange: b,
16
- orientation: o = "horizontal",
17
- variant: r = "line",
18
- size: s = "md",
19
- classes: i,
20
- className: a,
21
- children: l,
22
- ...t
23
- }, p) => {
24
- const c = R(), f = e !== void 0, [h, T] = L(n), u = f ? e : h, y = g(
25
- (w) => {
26
- f || T(w), b?.(w);
27
- },
28
- [f, b]
29
- ), v = {
30
- value: u,
31
- setValue: y,
32
- baseId: c,
33
- orientation: o,
34
- variant: r,
35
- size: s,
36
- classes: i
37
- };
38
- return /* @__PURE__ */ m(N.Provider, { value: v, children: /* @__PURE__ */ m(
39
- "div",
40
- {
41
- ref: p,
42
- className: $(
43
- d.root,
44
- o === "vertical" && d.vertical,
45
- i?.root,
46
- a
47
- ),
48
- ...t,
49
- children: l
50
- }
51
- ) });
52
- }
53
- );
54
- k.displayName = "Tabs";
55
- const A = x(
56
- ({ className: e, children: n, onKeyDown: b, ...o }, r) => {
57
- const s = I("Tabs.List"), i = V(null), a = g(
58
- (t) => {
59
- i.current = t, typeof r == "function" ? r(t) : r && (r.current = t);
60
- },
61
- [r]
62
- ), l = (t) => {
63
- if (b?.(t), t.defaultPrevented) return;
64
- const p = i.current;
65
- if (!p) return;
66
- const c = Array.from(
67
- p.querySelectorAll('[role="tab"]:not([aria-disabled="true"])')
68
- );
69
- if (c.length === 0) return;
70
- const f = s.orientation === "vertical" ? "ArrowDown" : "ArrowRight", h = s.orientation === "vertical" ? "ArrowUp" : "ArrowLeft", T = c.indexOf(document.activeElement);
71
- let u = null;
72
- if (t.key === f ? u = (T + 1) % c.length : t.key === h ? u = (T - 1 + c.length) % c.length : t.key === "Home" ? u = 0 : t.key === "End" && (u = c.length - 1), u === null) return;
73
- t.preventDefault();
74
- const y = c[u];
75
- y.focus();
76
- const v = y.dataset.value;
77
- v !== void 0 && s.setValue(v);
78
- };
79
- return /* @__PURE__ */ m(
80
- "div",
81
- {
82
- ref: a,
83
- role: "tablist",
84
- "aria-orientation": s.orientation,
85
- className: $(
86
- d.list,
87
- d[`list_${s.variant}`],
88
- d[`list_${s.size}`],
89
- s.classes?.list,
90
- e
91
- ),
92
- onKeyDown: l,
93
- ...o,
94
- children: n
95
- }
96
- );
97
- }
98
- );
99
- A.displayName = "Tabs.List";
100
- const C = x(
101
- ({ value: e, disabled: n = !1, className: b, children: o, onClick: r, ...s }, i) => {
102
- const a = I("Tabs.Tab"), l = a.value === e;
103
- return /* @__PURE__ */ m(
104
- "button",
105
- {
106
- ref: i,
107
- type: "button",
108
- role: "tab",
109
- id: `${a.baseId}-tab-${e}`,
110
- "data-value": e,
111
- "aria-selected": l,
112
- "aria-controls": `${a.baseId}-panel-${e}`,
113
- "aria-disabled": n || void 0,
114
- tabIndex: l ? 0 : -1,
115
- disabled: n,
116
- className: $(
117
- d.tab,
118
- d[`tab_${a.variant}`],
119
- l && d.tabSelected,
120
- a.classes?.tab,
121
- b
122
- ),
123
- onClick: (t) => {
124
- r?.(t), n || a.setValue(e);
125
- },
126
- ...s,
127
- children: o
128
- }
129
- );
130
- }
131
- );
132
- C.displayName = "Tabs.Tab";
133
- const P = x(
134
- ({ value: e, keepMounted: n = !1, className: b, style: o, children: r, ...s }, i) => {
135
- const a = I("Tabs.Panel"), l = a.value === e;
136
- if (!l && !n) return null;
137
- const t = l ? o : { display: "none", ...o };
138
- return /* @__PURE__ */ m(
139
- "div",
140
- {
141
- ref: i,
142
- role: "tabpanel",
143
- id: `${a.baseId}-panel-${e}`,
144
- "aria-labelledby": `${a.baseId}-tab-${e}`,
145
- hidden: !l,
146
- tabIndex: 0,
147
- className: $(d.panel, a.classes?.panel, b),
148
- style: t,
149
- ...s,
150
- children: r
151
- }
152
- );
153
- }
154
- );
155
- P.displayName = "Tabs.Panel";
156
- const K = Object.assign(k, {
157
- List: A,
158
- Tab: C,
159
- Panel: P
12
+ var f = n(({ value: t, defaultValue: n, onValueChange: i, orientation: o = "horizontal", variant: d = "line", size: f = "md", classes: p, className: m, children: h, ...g }, _) => {
13
+ let v = a(), y = t !== void 0, [b, x] = s(n), S = {
14
+ value: y ? t : b,
15
+ setValue: r((e) => {
16
+ y || x(e), i?.(e);
17
+ }, [y, i]),
18
+ baseId: v,
19
+ orientation: o,
20
+ variant: d,
21
+ size: f,
22
+ classes: p
23
+ };
24
+ return /* @__PURE__ */ l(u.Provider, {
25
+ value: S,
26
+ children: /* @__PURE__ */ l("div", {
27
+ ref: _,
28
+ className: c(e.root, o === "vertical" && e.vertical, p?.root, m),
29
+ ...g,
30
+ children: h
31
+ })
32
+ });
160
33
  });
161
- export {
162
- K as Tabs
163
- };
34
+ f.displayName = "Tabs";
35
+ var p = n(({ className: t, children: n, onKeyDown: i, ...a }, s) => {
36
+ let u = d("Tabs.List"), f = o(null), p = r((e) => {
37
+ f.current = e, typeof s == "function" ? s(e) : s && (s.current = e);
38
+ }, [s]);
39
+ return /* @__PURE__ */ l("div", {
40
+ ref: p,
41
+ role: "tablist",
42
+ "aria-orientation": u.orientation,
43
+ className: c(e.list, e[`list_${u.variant}`], e[`list_${u.size}`], u.classes?.list, t),
44
+ onKeyDown: (e) => {
45
+ if (i?.(e), e.defaultPrevented) return;
46
+ let t = f.current;
47
+ if (!t) return;
48
+ let n = Array.from(t.querySelectorAll("[role=\"tab\"]:not([aria-disabled=\"true\"])"));
49
+ if (n.length === 0) return;
50
+ let r = u.orientation === "vertical" ? "ArrowDown" : "ArrowRight", a = u.orientation === "vertical" ? "ArrowUp" : "ArrowLeft", o = n.indexOf(document.activeElement), s = null;
51
+ if (e.key === r ? s = (o + 1) % n.length : e.key === a ? s = (o - 1 + n.length) % n.length : e.key === "Home" ? s = 0 : e.key === "End" && (s = n.length - 1), s === null) return;
52
+ e.preventDefault();
53
+ let c = n[s];
54
+ c.focus();
55
+ let l = c.dataset.value;
56
+ l !== void 0 && u.setValue(l);
57
+ },
58
+ ...a,
59
+ children: n
60
+ });
61
+ });
62
+ p.displayName = "Tabs.List";
63
+ var m = n(({ value: t, disabled: n = !1, className: r, children: i, onClick: a, ...o }, s) => {
64
+ let u = d("Tabs.Tab"), f = u.value === t;
65
+ return /* @__PURE__ */ l("button", {
66
+ ref: s,
67
+ type: "button",
68
+ role: "tab",
69
+ id: `${u.baseId}-tab-${t}`,
70
+ "data-value": t,
71
+ "aria-selected": f,
72
+ "aria-controls": `${u.baseId}-panel-${t}`,
73
+ "aria-disabled": n || void 0,
74
+ tabIndex: f ? 0 : -1,
75
+ disabled: n,
76
+ className: c(e.tab, e[`tab_${u.variant}`], f && e.tabSelected, u.classes?.tab, r),
77
+ onClick: (e) => {
78
+ a?.(e), n || u.setValue(t);
79
+ },
80
+ ...o,
81
+ children: i
82
+ });
83
+ });
84
+ m.displayName = "Tabs.Tab";
85
+ var h = n(({ value: t, keepMounted: n = !1, className: r, style: i, children: a, ...o }, s) => {
86
+ let u = d("Tabs.Panel"), f = u.value === t;
87
+ if (!f && !n) return null;
88
+ let p = f ? i : {
89
+ display: "none",
90
+ ...i
91
+ };
92
+ return /* @__PURE__ */ l("div", {
93
+ ref: s,
94
+ role: "tabpanel",
95
+ id: `${u.baseId}-panel-${t}`,
96
+ "aria-labelledby": `${u.baseId}-tab-${t}`,
97
+ hidden: !f,
98
+ tabIndex: 0,
99
+ className: c(e.panel, u.classes?.panel, r),
100
+ style: p,
101
+ ...o,
102
+ children: a
103
+ });
104
+ });
105
+ h.displayName = "Tabs.Panel";
106
+ var g = Object.assign(f, {
107
+ List: p,
108
+ Tab: m,
109
+ Panel: h
110
+ });
111
+ export { g as Tabs };
@@ -0,0 +1,28 @@
1
+ // src/components/Tabs/Tabs.module.scss
2
+ var e = "crk-root-2x4fl", t = "crk-vertical-D93pf", n = "crk-list-6iAKX", r = "crk-list_line-ZazHL", i = "crk-list_line-ZazHL", a = "crk-list_solid-Lbmnx", o = "crk-list_solid-Lbmnx", s = "crk-list_pill-g90VV", c = "crk-list_pill-g90VV", l = "crk-list_sm-U-pax", u = "crk-list_sm-U-pax", d = "crk-tab-LYqhc", f = "crk-list_md-0H3Fg", p = "crk-list_md-0H3Fg", m = "crk-list_lg-vxB6m", h = "crk-list_lg-vxB6m", g = "crk-tab_line-8v4fZ", _ = "crk-tab_line-8v4fZ", v = "crk-tabSelected-lZne9", y = "crk-tab_solid-4RJvK", b = "crk-tab_solid-4RJvK", x = "crk-tab_pill-qGlBx", S = "crk-tab_pill-qGlBx", C = "crk-panel-0OUR6", w = {
3
+ root: e,
4
+ vertical: t,
5
+ list: n,
6
+ list_line: r,
7
+ listLine: i,
8
+ list_solid: a,
9
+ listSolid: o,
10
+ list_pill: s,
11
+ listPill: c,
12
+ list_sm: l,
13
+ listSm: u,
14
+ tab: d,
15
+ list_md: f,
16
+ listMd: p,
17
+ list_lg: m,
18
+ listLg: h,
19
+ tab_line: g,
20
+ tabLine: _,
21
+ tabSelected: v,
22
+ tab_solid: y,
23
+ tabSolid: b,
24
+ tab_pill: x,
25
+ tabPill: S,
26
+ panel: C
27
+ };
28
+ export { w as default, n as list, h as listLg, i as listLine, p as listMd, c as listPill, u as listSm, o as listSolid, m as list_lg, r as list_line, f as list_md, s as list_pill, l as list_sm, a as list_solid, C as panel, e as root, d as tab, _ as tabLine, S as tabPill, v as tabSelected, b as tabSolid, g as tab_line, x as tab_pill, y as tab_solid, t as vertical };
@@ -24,6 +24,8 @@ export interface ThemeToggleProps extends Omit<ComponentPropsWithRef<'button'>,
24
24
  showLabel?: boolean;
25
25
  /** localStorage key passed to `useTheme`. @default 'crk-theme' */
26
26
  storageKey?: string;
27
+ /** Theme used when nothing is stored yet. Match `THEME_INIT_SCRIPT`'s `defaultTheme`. @default 'system' */
28
+ defaultTheme?: 'light' | 'dark' | 'system';
27
29
  /** Override class names on internal elements. */
28
30
  classes?: Partial<ThemeToggleClasses>;
29
31
  }