@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,92 +1,103 @@
1
- function G(d, a = {}) {
2
- const f = a.barH ?? 26, c = a.rowH ?? 66, x = a.chipH ?? 51, S = a.minH ?? 420, w = d.map((o) => ({
3
- ...o,
4
- sub: 0,
5
- row: -1,
6
- labelX: o.left,
7
- showLabel: !1,
8
- barTop: 0,
9
- labelTop: 0,
10
- conn: !1,
11
- connTop: 0,
12
- connH: 0,
13
- hconn: !1,
14
- hconnLeft: 0,
15
- hconnTop: 0,
16
- hconnW: 0
17
- })), t = w.slice().sort((o, n) => o.left - n.left || n.width - o.width), u = [];
18
- t.forEach((o) => {
19
- let n = 0;
20
- for (; n < u.length && o.left < u[n] + 3; ) n++;
21
- o.sub = n, u[n] = o.left + o.width;
22
- });
23
- const H = Math.max(1, u.length), T = [0, 4, 1, 5, 2, 6, 3, 7], E = [], W = [], g = (o, n, e, r) => {
24
- const X = o < 4, v = X ? o + 1 : o - 3;
25
- for (const l of E) {
26
- const b = l.row < 4;
27
- if (b !== X) continue;
28
- if ((b ? l.row + 1 : l.row - 3) <= v && r >= l.x1 - 3 && r <= l.x2 + 3) return !0;
29
- }
30
- for (const l of W) {
31
- const b = l.row < 4;
32
- if (b !== X) continue;
33
- if ((b ? l.row + 1 : l.row - 3) >= v && l.x >= n - 3 && l.x <= e + 3) return !0;
34
- }
35
- return !1;
36
- }, s = [1e9, 1e9, 1e9, 1e9, 1e9, 1e9, 1e9, 1e9];
37
- t.slice().reverse().forEach((o) => {
38
- const n = o.labelW;
39
- o.row = -1, o.labelX = o.left;
40
- for (const e of T)
41
- if (o.left + n <= s[e] - 14 && !g(e, o.left, o.left + n, o.left)) {
42
- o.row = e, o.labelX = o.left;
43
- break;
44
- }
45
- if (o.row < 0)
46
- for (const e of T) {
47
- const r = Math.min(o.left, s[e] - 14 - n);
48
- if (r >= o.left - 140 && !g(e, r, r + n, o.left)) {
49
- o.row = e, o.labelX = r;
50
- break;
51
- }
52
- }
53
- if (o.row < 0)
54
- for (const e of T) {
55
- const r = Math.min(o.left, s[e] - 14 - n);
56
- if (r >= o.left - 140) {
57
- o.row = e, o.labelX = r;
58
- break;
59
- }
60
- }
61
- o.row >= 0 && (s[o.row] = Math.min(s[o.row], o.labelX), E.push({ row: o.row, x1: o.labelX, x2: o.labelX + n }), W.push({ row: o.row, x: o.left })), o.showLabel = o.row >= 0;
62
- });
63
- const L = t.reduce(
64
- (o, n) => n.row >= 0 && n.row < 4 ? Math.max(o, n.row + 1) : o,
65
- 1
66
- ), N = t.reduce((o, n) => n.row >= 4 ? Math.max(o, n.row - 3) : o, 0), h = H * (f + 4) - 4, k = 10 + L * c + h + N * c + 14, m = Math.max(S, k), p = Math.max(
67
- 10 + L * c,
68
- Math.min(Math.round((m - h) / 2), m - h - N * c - 14)
69
- );
70
- w.forEach((o) => {
71
- if (o.barTop = p + o.sub * (f + 4), o.row < 0) return;
72
- const n = o.row < 4;
73
- o.labelTop = n ? p - (o.row + 1) * c : p + h + 10 + (o.row - 4) * c, n ? (o.connTop = o.labelTop + x, o.connH = o.barTop - o.connTop - 1) : (o.connTop = o.barTop + f + 1, o.connH = o.labelTop - o.connTop + 2), o.conn = o.connH > 2, o.labelX > o.left + 2 ? (o.hconn = !0, o.hconnTop = o.labelTop + Math.round(x / 2), o.hconnLeft = o.left + 1, o.hconnW = Math.max(2, o.labelX - o.left - 3), o.conn = !0) : o.labelX + o.labelW < o.left - 2 && (o.hconn = !0, o.hconnTop = o.labelTop + Math.round(x / 2), o.hconnLeft = o.labelX + o.labelW - 1, o.hconnW = Math.max(2, o.left - (o.labelX + o.labelW) + 2), o.conn = !0);
74
- });
75
- let M = 0;
76
- return w.forEach((o) => {
77
- M = Math.max(M, o.left + o.width, o.showLabel ? o.labelX + o.labelW : 0);
78
- }), {
79
- items: w,
80
- h: m,
81
- axisY: p + Math.round(h / 2),
82
- subRows: H,
83
- maxExt: M
84
- };
1
+ function e(e, t = {}) {
2
+ let n = t.barH ?? 26, r = t.rowH ?? 66, i = t.chipH ?? 51, a = t.minH ?? 420, o = e.map((e) => ({
3
+ ...e,
4
+ sub: 0,
5
+ row: -1,
6
+ labelX: e.left,
7
+ showLabel: !1,
8
+ barTop: 0,
9
+ labelTop: 0,
10
+ conn: !1,
11
+ connTop: 0,
12
+ connH: 0,
13
+ hconn: !1,
14
+ hconnLeft: 0,
15
+ hconnTop: 0,
16
+ hconnW: 0
17
+ })), s = o.slice().sort((e, t) => e.left - t.left || t.width - e.width), c = [];
18
+ s.forEach((e) => {
19
+ let t = 0;
20
+ for (; t < c.length && e.left < c[t] + 3;) t++;
21
+ e.sub = t, c[t] = e.left + e.width;
22
+ });
23
+ let l = Math.max(1, c.length), u = [
24
+ 0,
25
+ 4,
26
+ 1,
27
+ 5,
28
+ 2,
29
+ 6,
30
+ 3,
31
+ 7
32
+ ], d = [], f = [], p = (e, t, n, r) => {
33
+ let i = e < 4, a = i ? e + 1 : e - 3;
34
+ for (let e of d) {
35
+ let t = e.row < 4;
36
+ if (t === i && (t ? e.row + 1 : e.row - 3) <= a && r >= e.x1 - 3 && r <= e.x2 + 3) return !0;
37
+ }
38
+ for (let e of f) {
39
+ let r = e.row < 4;
40
+ if (r === i && (r ? e.row + 1 : e.row - 3) >= a && e.x >= t - 3 && e.x <= n + 3) return !0;
41
+ }
42
+ return !1;
43
+ }, m = [
44
+ 1e9,
45
+ 1e9,
46
+ 1e9,
47
+ 1e9,
48
+ 1e9,
49
+ 1e9,
50
+ 1e9,
51
+ 1e9
52
+ ];
53
+ s.slice().reverse().forEach((e) => {
54
+ let t = e.labelW;
55
+ e.row = -1, e.labelX = e.left;
56
+ for (let n of u) if (e.left + t <= m[n] - 14 && !p(n, e.left, e.left + t, e.left)) {
57
+ e.row = n, e.labelX = e.left;
58
+ break;
59
+ }
60
+ if (e.row < 0) for (let n of u) {
61
+ let r = Math.min(e.left, m[n] - 14 - t);
62
+ if (r >= e.left - 140 && !p(n, r, r + t, e.left)) {
63
+ e.row = n, e.labelX = r;
64
+ break;
65
+ }
66
+ }
67
+ if (e.row < 0) for (let n of u) {
68
+ let r = Math.min(e.left, m[n] - 14 - t);
69
+ if (r >= e.left - 140) {
70
+ e.row = n, e.labelX = r;
71
+ break;
72
+ }
73
+ }
74
+ e.row >= 0 && (m[e.row] = Math.min(m[e.row], e.labelX), d.push({
75
+ row: e.row,
76
+ x1: e.labelX,
77
+ x2: e.labelX + t
78
+ }), f.push({
79
+ row: e.row,
80
+ x: e.left
81
+ })), e.showLabel = e.row >= 0;
82
+ });
83
+ let h = s.reduce((e, t) => t.row >= 0 && t.row < 4 ? Math.max(e, t.row + 1) : e, 1), g = s.reduce((e, t) => t.row >= 4 ? Math.max(e, t.row - 3) : e, 0), _ = l * (n + 4) - 4, v = 10 + h * r + _ + g * r + 14, y = Math.max(a, v), b = Math.max(10 + h * r, Math.min(Math.round((y - _) / 2), y - _ - g * r - 14));
84
+ o.forEach((e) => {
85
+ if (e.barTop = b + e.sub * (n + 4), e.row < 0) return;
86
+ let t = e.row < 4;
87
+ e.labelTop = t ? b - (e.row + 1) * r : b + _ + 10 + (e.row - 4) * r, t ? (e.connTop = e.labelTop + i, e.connH = e.barTop - e.connTop - 1) : (e.connTop = e.barTop + n + 1, e.connH = e.labelTop - e.connTop + 2), e.conn = e.connH > 2, e.labelX > e.left + 2 ? (e.hconn = !0, e.hconnTop = e.labelTop + Math.round(i / 2), e.hconnLeft = e.left + 1, e.hconnW = Math.max(2, e.labelX - e.left - 3), e.conn = !0) : e.labelX + e.labelW < e.left - 2 && (e.hconn = !0, e.hconnTop = e.labelTop + Math.round(i / 2), e.hconnLeft = e.labelX + e.labelW - 1, e.hconnW = Math.max(2, e.left - (e.labelX + e.labelW) + 2), e.conn = !0);
88
+ });
89
+ let x = 0;
90
+ return o.forEach((e) => {
91
+ x = Math.max(x, e.left + e.width, e.showLabel ? e.labelX + e.labelW : 0);
92
+ }), {
93
+ items: o,
94
+ h: y,
95
+ axisY: b + Math.round(_ / 2),
96
+ subRows: l,
97
+ maxExt: x
98
+ };
85
99
  }
86
- function U(d, a, f) {
87
- return Math.max(String(d).length + String(a).length + 4, String(f).length, 23) * 6 + 20;
100
+ function t(e, t, n) {
101
+ return Math.max(String(e).length + String(t).length + 4, String(n).length, 23) * 6 + 20;
88
102
  }
89
- export {
90
- G as layoutTraceBand,
91
- U as traceChipWidth
92
- };
103
+ export { e as layoutTraceBand, t as traceChipWidth };
@@ -1,85 +1,82 @@
1
- import { useState as y, useEffect as v, useRef as h, useCallback as p } from "react";
2
- function W(e) {
3
- const n = h(null), o = h(!1), r = p(
4
- (i) => {
5
- const c = e.current;
6
- c && (n.current = { x: i.clientX, y: i.clientY, l: c.scrollLeft, t: c.scrollTop, moved: !1 });
7
- },
8
- [e]
9
- ), t = p(
10
- (i) => {
11
- const c = n.current, u = e.current;
12
- if (!c || !u) return;
13
- const d = i.clientX - c.x, f = i.clientY - c.y;
14
- Math.abs(d) + Math.abs(f) > 5 && (c.moved = !0), u.scrollLeft = c.l - d, u.scrollTop = c.t - f;
15
- },
16
- [e]
17
- ), s = p(() => {
18
- n.current && n.current.moved && (o.current = !0, setTimeout(() => {
19
- o.current = !1;
20
- }, 60)), n.current = null;
21
- }, []), l = p(() => o.current, []);
22
- return { onPointerDown: r, onPointerMove: t, onPointerUp: s, wasDragSuppressed: l };
1
+ import { useCallback as e, useEffect as t, useRef as n, useState as r } from "react";
2
+ // src/components/Timeline/useTimeline.ts
3
+ function i(t) {
4
+ let r = n(null), i = n(!1);
5
+ return {
6
+ onPointerDown: e((e) => {
7
+ let n = t.current;
8
+ n && (r.current = {
9
+ x: e.clientX,
10
+ y: e.clientY,
11
+ l: n.scrollLeft,
12
+ t: n.scrollTop,
13
+ moved: !1
14
+ });
15
+ }, [t]),
16
+ onPointerMove: e((e) => {
17
+ let n = r.current, i = t.current;
18
+ if (!n || !i) return;
19
+ let a = e.clientX - n.x, o = e.clientY - n.y;
20
+ Math.abs(a) + Math.abs(o) > 5 && (n.moved = !0), i.scrollLeft = n.l - a, i.scrollTop = n.t - o;
21
+ }, [t]),
22
+ onPointerUp: e(() => {
23
+ r.current && r.current.moved && (i.current = !0, setTimeout(() => {
24
+ i.current = !1;
25
+ }, 60)), r.current = null;
26
+ }, []),
27
+ wasDragSuppressed: e(() => i.current, [])
28
+ };
23
29
  }
24
- function b(e, n = 1100) {
25
- const [o, r] = y(n);
26
- return v(() => {
27
- const t = e.current;
28
- if (!t) return;
29
- const s = new ResizeObserver(() => {
30
- t.clientWidth && r(t.clientWidth);
31
- });
32
- return s.observe(t), t.clientWidth && r(t.clientWidth), () => s.disconnect();
33
- }, [e]), o;
30
+ function a(e, n = 1100) {
31
+ let [i, a] = r(n);
32
+ return t(() => {
33
+ let t = e.current;
34
+ if (!t) return;
35
+ let n = new ResizeObserver(() => {
36
+ t.clientWidth && a(t.clientWidth);
37
+ });
38
+ return n.observe(t), t.clientWidth && a(t.clientWidth), () => n.disconnect();
39
+ }, [e]), i;
34
40
  }
35
- function A(e, n = 450) {
36
- const [o, r] = y(() => Date.now());
37
- return v(() => {
38
- if (!e) return;
39
- const t = setInterval(() => r(Date.now()), n);
40
- return () => clearInterval(t);
41
- }, [e, n]), e ? o : Date.now();
41
+ function o(e, n = 450) {
42
+ let [i, a] = r(() => Date.now());
43
+ return t(() => {
44
+ if (!e) return;
45
+ let t = setInterval(() => a(Date.now()), n);
46
+ return () => clearInterval(t);
47
+ }, [e, n]), e ? i : Date.now();
42
48
  }
43
- const w = /* @__PURE__ */ new WeakMap();
44
- function D(e, n, o = 900) {
45
- const r = w.get(e);
46
- r != null && cancelAnimationFrame(r);
47
- const t = e.scrollLeft, s = e.scrollTop, l = n.left != null ? n.left - t : 0, i = n.top != null ? n.top - s : 0;
48
- if (!l && !i) return;
49
- if (typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches || o <= 0) {
50
- n.left != null && (e.scrollLeft = n.left), n.top != null && (e.scrollTop = n.top);
51
- return;
52
- }
53
- const u = performance.now(), d = (m) => 1 - Math.pow(1 - m, 3);
54
- let f = !1;
55
- const a = () => {
56
- f = !0, e.removeEventListener("wheel", a), e.removeEventListener("pointerdown", a), w.delete(e);
57
- };
58
- e.addEventListener("wheel", a, { once: !0 }), e.addEventListener("pointerdown", a, { once: !0 });
59
- const L = (m) => {
60
- if (f) return;
61
- const T = Math.min(1, (m - u) / o), M = d(T);
62
- n.left != null && (e.scrollLeft = t + l * M), n.top != null && (e.scrollTop = s + i * M), T < 1 ? w.set(e, requestAnimationFrame(L)) : a();
63
- };
64
- w.set(e, requestAnimationFrame(L));
49
+ var s = /* @__PURE__ */ new WeakMap();
50
+ function c(e, t, n = 900) {
51
+ let r = s.get(e);
52
+ r != null && cancelAnimationFrame(r);
53
+ let i = e.scrollLeft, a = e.scrollTop, o = t.left == null ? 0 : t.left - i, c = t.top == null ? 0 : t.top - a;
54
+ if (!o && !c) return;
55
+ if (typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches || n <= 0) {
56
+ t.left != null && (e.scrollLeft = t.left), t.top != null && (e.scrollTop = t.top);
57
+ return;
58
+ }
59
+ let l = performance.now(), u = (e) => 1 - (1 - e) ** 3, d = !1, f = () => {
60
+ d = !0, e.removeEventListener("wheel", f), e.removeEventListener("pointerdown", f), s.delete(e);
61
+ };
62
+ e.addEventListener("wheel", f, { once: !0 }), e.addEventListener("pointerdown", f, { once: !0 });
63
+ let p = (r) => {
64
+ if (d) return;
65
+ let m = Math.min(1, (r - l) / n), h = u(m);
66
+ t.left != null && (e.scrollLeft = i + o * h), t.top != null && (e.scrollTop = a + c * h), m < 1 ? s.set(e, requestAnimationFrame(p)) : f();
67
+ };
68
+ s.set(e, requestAnimationFrame(p));
65
69
  }
66
- function x(e, n) {
67
- return e === "free" || e === "ctrl" && (n.ctrlKey || n.metaKey);
70
+ function l(e, t) {
71
+ return e === "free" || e === "ctrl" && (t.ctrlKey || t.metaKey);
68
72
  }
69
- function P(e, n, o) {
70
- const r = h(n);
71
- r.current = n, v(() => {
72
- const t = e.current;
73
- if (!t) return;
74
- const s = (l) => r.current(l);
75
- return t.addEventListener("wheel", s, { passive: !1 }), () => t.removeEventListener("wheel", s);
76
- }, [e, o]);
73
+ function u(e, r, i) {
74
+ let a = n(r);
75
+ a.current = r, t(() => {
76
+ let t = e.current;
77
+ if (!t) return;
78
+ let n = (e) => a.current(e);
79
+ return t.addEventListener("wheel", n, { passive: !1 }), () => t.removeEventListener("wheel", n);
80
+ }, [e, i]);
77
81
  }
78
- export {
79
- D as animateScrollTo,
80
- b as useContainerWidth,
81
- A as useNowTicker,
82
- W as useTimelinePan,
83
- P as useWheelZoom,
84
- x as wheelZoomAllowed
85
- };
82
+ export { c as animateScrollTo, a as useContainerWidth, o as useNowTicker, i as useTimelinePan, u as useWheelZoom, l as wheelZoomAllowed };