@overdoser/react-toolkit 0.20.0 → 0.22.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 (212) hide show
  1. package/AGENTS.md +2 -1
  2. package/CHANGELOG.md +41 -0
  3. package/components/Accordion/Accordion.js +160 -177
  4. package/components/Accordion/Accordion.module.scss.js +19 -35
  5. package/components/ActionButton/ActionButton.js +155 -209
  6. package/components/ActionButton/ActionButton.module.scss.js +24 -46
  7. package/components/ActionButton/CopyButton.js +52 -64
  8. package/components/Alert/Alert.js +93 -96
  9. package/components/Alert/Alert.module.scss.js +17 -32
  10. package/components/Avatar/Avatar.js +44 -55
  11. package/components/Avatar/Avatar.module.scss.js +22 -42
  12. package/components/Badge/Badge.js +15 -37
  13. package/components/Badge/Badge.module.scss.js +16 -30
  14. package/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
  15. package/components/Breadcrumbs/Breadcrumbs.js +52 -48
  16. package/components/Breadcrumbs/Breadcrumbs.module.scss.js +9 -16
  17. package/components/Button/Button.js +35 -57
  18. package/components/Button/Button.module.scss.js +24 -46
  19. package/components/Card/Card.js +94 -131
  20. package/components/Card/Card.module.scss.js +34 -59
  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.scss.js +31 -60
  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 +45 -40
  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.scss.js +31 -58
  48. package/components/CodeBlock/CodeBlock.js +111 -119
  49. package/components/CodeBlock/CodeBlock.module.scss.js +22 -42
  50. package/components/CommandPalette/CommandPalette.js +387 -392
  51. package/components/CommandPalette/CommandPalette.module.scss.js +27 -48
  52. package/components/ConfirmDialog/ConfirmDialog.d.ts +1 -1
  53. package/components/ConfirmDialog/ConfirmDialog.js +184 -199
  54. package/components/ConfirmDialog/ConfirmDialog.module.scss.js +11 -20
  55. package/components/Divider/Divider.js +25 -36
  56. package/components/Divider/Divider.module.scss.js +16 -30
  57. package/components/Draggable/Draggable.d.ts +1 -1
  58. package/components/Draggable/Draggable.js +157 -164
  59. package/components/Draggable/Draggable.module.scss.js +9 -16
  60. package/components/Drawer/Drawer.js +104 -126
  61. package/components/Drawer/Drawer.module.scss.js +65 -118
  62. package/components/Dropdown/Dropdown.js +175 -234
  63. package/components/Dropdown/Dropdown.module.scss.js +28 -52
  64. package/components/Dropdown/DropdownItem.js +55 -58
  65. package/components/Dropdown/DropdownLabel.js +14 -11
  66. package/components/Dropdown/DropdownSeparator.js +13 -11
  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.scss.js +11 -20
  71. package/components/EmptyState/EmptyState.js +57 -54
  72. package/components/EmptyState/EmptyState.module.scss.js +13 -24
  73. package/components/Form/Form.d.ts +1 -1
  74. package/components/Form/Form.js +31 -34
  75. package/components/Form/Form.module.scss.js +15 -28
  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.scss.js +25 -46
  83. package/components/ImageViewer/useZoomPan.js +206 -137
  84. package/components/Kbd/Kbd.js +24 -21
  85. package/components/Kbd/Kbd.module.scss.js +9 -16
  86. package/components/KeyValueList/KeyValueList.js +119 -123
  87. package/components/KeyValueList/KeyValueList.module.scss.js +22 -42
  88. package/components/Link/Link.js +45 -59
  89. package/components/Link/Link.module.scss.js +9 -15
  90. package/components/List/List.js +22 -46
  91. package/components/List/List.module.scss.js +11 -20
  92. package/components/Loader/Loader.js +152 -182
  93. package/components/Loader/Loader.module.scss.js +39 -69
  94. package/components/Modal/Modal.js +93 -105
  95. package/components/Modal/Modal.module.scss.js +17 -32
  96. package/components/PageHeader/PageHeader.js +79 -73
  97. package/components/PageHeader/PageHeader.module.scss.js +22 -42
  98. package/components/Pagination/Pagination.js +62 -83
  99. package/components/Pagination/Pagination.module.scss.js +12 -22
  100. package/components/Pagination/paginationRange.js +15 -22
  101. package/components/Popover/Popover.js +110 -134
  102. package/components/Popover/Popover.module.scss.js +11 -20
  103. package/components/ProgressBar/ProgressBar.d.ts +15 -1
  104. package/components/ProgressBar/ProgressBar.js +56 -89
  105. package/components/ProgressBar/ProgressBar.module.scss.js +28 -50
  106. package/components/RelativeTime/RelativeTime.js +36 -43
  107. package/components/RelativeTime/RelativeTime.module.scss.js +3 -7
  108. package/components/SegmentedControl/SegmentedControl.js +93 -129
  109. package/components/SegmentedControl/SegmentedControl.module.scss.js +20 -38
  110. package/components/Skeleton/Skeleton.js +36 -50
  111. package/components/Skeleton/Skeleton.module.scss.js +14 -24
  112. package/components/Spinner/Spinner.js +25 -25
  113. package/components/Spinner/Spinner.module.scss.js +11 -19
  114. package/components/SplitButton/SplitButton.js +149 -196
  115. package/components/SplitButton/SplitButton.module.scss.js +30 -56
  116. package/components/SplitPane/SplitPane.js +134 -170
  117. package/components/SplitPane/SplitPane.module.scss.js +13 -24
  118. package/components/StatCard/StatCard.js +132 -125
  119. package/components/StatCard/StatCard.module.scss.js +41 -71
  120. package/components/StatusDot/StatusDot.js +28 -39
  121. package/components/StatusDot/StatusDot.module.scss.js +17 -31
  122. package/components/Table/Table.d.ts +1 -1
  123. package/components/Table/Table.js +381 -451
  124. package/components/Table/Table.module.scss.js +41 -80
  125. package/components/Table/useTableSort.js +51 -42
  126. package/components/Tabs/Tabs.js +109 -161
  127. package/components/Tabs/Tabs.module.scss.js +27 -52
  128. package/components/ThemeToggle/ThemeToggle.js +122 -98
  129. package/components/ThemeToggle/ThemeToggle.module.scss.js +12 -22
  130. package/components/Timeline/GanttTimeline.js +357 -318
  131. package/components/Timeline/GanttTimeline.module.scss.js +28 -54
  132. package/components/Timeline/HistoryTimeline.js +486 -450
  133. package/components/Timeline/HistoryTimeline.module.scss.js +30 -58
  134. package/components/Timeline/Timeline.module.scss.js +75 -140
  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 +244 -177
  139. package/components/Timeline/TraceTimeline.js +823 -783
  140. package/components/Timeline/TraceTimeline.module.scss.js +97 -188
  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.scss.js +28 -54
  148. package/components/Toast/Toast.d.ts +1 -1
  149. package/components/Toast/Toast.js +128 -128
  150. package/components/Toast/Toast.module.scss.js +36 -61
  151. package/components/Toast/toastStore.js +58 -62
  152. package/components/ToggleIconButton/ToggleIconButton.js +36 -58
  153. package/components/ToggleIconButton/ToggleIconButton.module.scss.js +14 -26
  154. package/components/Tooltip/Tooltip.d.ts +1 -1
  155. package/components/Tooltip/Tooltip.js +76 -85
  156. package/components/Tooltip/Tooltip.module.scss.js +16 -29
  157. package/components/Typography/Typography.js +10 -35
  158. package/components/Typography/Typography.module.scss.js +29 -52
  159. package/components/inputs/Checkbox/Checkbox.js +27 -51
  160. package/components/inputs/Checkbox/Checkbox.module.scss.js +9 -16
  161. package/components/inputs/Checkbox/CheckboxGroup.js +53 -111
  162. package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +16 -30
  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.scss.js +22 -40
  166. package/components/inputs/DatePicker/DatePicker.js +115 -142
  167. package/components/inputs/DatePicker/DatePicker.module.scss.js +13 -24
  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.scss.js +19 -36
  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.scss.js +14 -26
  177. package/components/inputs/NumberInput/NumberInput.js +112 -132
  178. package/components/inputs/NumberInput/NumberInput.module.scss.js +13 -24
  179. package/components/inputs/Radio/Radio.js +50 -73
  180. package/components/inputs/Radio/Radio.module.scss.js +8 -14
  181. package/components/inputs/SearchInput/SearchInput.js +98 -115
  182. package/components/inputs/SearchInput/SearchInput.module.scss.js +7 -12
  183. package/components/inputs/Select/Select.d.ts +55 -3
  184. package/components/inputs/Select/Select.js +696 -682
  185. package/components/inputs/Select/Select.module.scss.js +49 -72
  186. package/components/inputs/Slider/Slider.js +97 -128
  187. package/components/inputs/Slider/Slider.module.scss.js +8 -14
  188. package/components/inputs/Switch/Switch.js +11 -8
  189. package/components/inputs/Textarea/Textarea.js +42 -58
  190. package/components/inputs/Textarea/Textarea.module.scss.js +13 -24
  191. package/hooks/useClickOutside.js +17 -14
  192. package/hooks/useDebouncedValue.js +13 -14
  193. package/hooks/useElementSize.js +27 -22
  194. package/hooks/useEscapeLayer.js +28 -29
  195. package/hooks/useFocusTrap.js +27 -38
  196. package/hooks/useKeyboard.js +76 -64
  197. package/hooks/useMediaQuery.js +10 -15
  198. package/hooks/useNow.js +28 -33
  199. package/hooks/usePersistedState.js +98 -94
  200. package/hooks/usePortalPosition.d.ts +2 -1
  201. package/hooks/usePortalPosition.js +28 -19
  202. package/hooks/useResizable.js +106 -104
  203. package/hooks/useTheme.js +28 -23
  204. package/index.css +2 -1
  205. package/index.js +96 -214
  206. package/index.layered.css +2 -3
  207. package/llms.txt +28 -4
  208. package/manifest.json +41 -4
  209. package/package.json +1 -1
  210. package/utils/formatBytes.js +29 -13
  211. package/utils/themeScript.js +6 -8
  212. package/utils/timeAgo.js +59 -32
@@ -1,318 +1,357 @@
1
- import { jsx as t, jsxs as f, Fragment as ce } from "react/jsx-runtime";
2
- import { forwardRef as tn, useRef as S, useState as k, useCallback as V, useEffect as ln, useMemo as rn, useLayoutEffect as an } from "react";
3
- import d from "clsx";
4
- import a from "./Timeline.module.scss.js";
5
- import r from "./GanttTimeline.module.scss.js";
6
- import { ticks as sn, TIMELINE_PALETTE_VARS as x, fmtDate as de, fmtDur as Z, eventMatches as on, fmtDateTime as F, tint as cn } from "./timelineCore.js";
7
- import { TimelineSummary as dn, TimelineZoomControls as un, HighlightText as mn, TimelineTooltip as hn } from "./TimelineShared.js";
8
- import { useNowTicker as fn, useContainerWidth as wn, useTimelinePan as pn, useWheelZoom as gn, animateScrollTo as Nn, wheelZoomAllowed as vn } from "./useTimeline.js";
9
- const w = 230, We = 24, R = 400, xn = 26, Cn = tn(
10
- function(Ce, De) {
11
- const {
12
- tasks: z,
13
- title: B,
14
- meta: G,
15
- highlight: K,
16
- defaultHighlight: He,
17
- onHighlightChange: Ie,
18
- showSearch: Ee = !0,
19
- renderSearch: ue,
20
- compactRows: Ae = !1,
21
- showGridlines: Oe = !0,
22
- showControls: me = !0,
23
- wheelZoom: U = "ctrl",
24
- showSummary: I = !1,
25
- summaryPlacement: T = "left",
26
- summaryDefaultPosition: Ve,
27
- maxHeight: Ze = "74vh",
28
- selectedTaskId: _,
29
- defaultSelectedTaskId: Fe = null,
30
- onTaskSelect: ze,
31
- renderRowLabel: he,
32
- renderBar: $,
33
- renderTooltip: X,
34
- renderDetails: Y,
35
- classes: u,
36
- className: Be,
37
- style: Ge
38
- } = Ce, p = S(null), [fe, we] = k(null), [pe, ge] = k(!0), [g, j] = k(null), [Ke, Ue] = k(Fe), P = _ !== void 0 ? _ : Ke, [M, _e] = k({ l: 0, t: 0, w: 0, h: 0 }), Ne = S(I);
39
- Ne.current = I;
40
- const q = S(null), J = V(() => {
41
- const e = p.current;
42
- e && _e(
43
- (n) => n.l === e.scrollLeft && n.t === e.scrollTop && n.w === e.clientWidth && n.h === e.clientHeight ? n : { l: e.scrollLeft, t: e.scrollTop, w: e.clientWidth, h: e.clientHeight }
44
- );
45
- }, []), [W, $e] = k({ l: 0, w: 2e3 }), Q = S(W);
46
- Q.current = W;
47
- const ee = V(() => {
48
- const e = p.current;
49
- if (!e) return;
50
- const n = Math.floor(e.scrollLeft / R) * R, l = (Math.ceil((e.clientWidth || 1600) / R) + 1) * R;
51
- (n !== Q.current.l || l !== Q.current.w) && $e({ l: n, w: l });
52
- }, []), Xe = V(() => {
53
- q.current == null && (q.current = requestAnimationFrame(() => {
54
- q.current = null, ee(), Ne.current && J();
55
- }));
56
- }, [J, ee]);
57
- ln(() => {
58
- I && J();
59
- });
60
- const ve = z.some((e) => e.end == null), N = fn(ve, 400), ne = wn(p), C = pn(p), [Ye, je] = k(He ?? ""), te = K !== void 0 ? K : Ye, E = te.trim(), xe = (e) => {
61
- K === void 0 && je(e), Ie?.(e);
62
- }, Me = ue ? ue({ value: te, setValue: xe }) : Ee ? /* @__PURE__ */ t(
63
- "input",
64
- {
65
- className: d(a.searchInput, u?.search),
66
- placeholder: "Highlight keyword in tasks…",
67
- "aria-label": "Highlight keyword",
68
- value: te,
69
- onChange: (e) => xe(e.target.value)
70
- }
71
- ) : null, o = rn(() => z.slice().sort((e, n) => e.start - n.start), [z]);
72
- let m = o.length ? Math.min(...o.map((e) => e.start)) : N - 1, le = o.length ? Math.max(m + 1, ...o.map((e) => e.end == null ? N : e.end)) : N;
73
- const re = (le - m) * 0.03;
74
- m -= re, le += re;
75
- const ae = le - m, A = Math.max(240, ne - w - We) / ae, i = pe || !fe ? A : fe, se = S(A), be = S(i);
76
- se.current = A, be.current = i;
77
- const O = S(null);
78
- an(() => {
79
- O.current != null && p.current && (p.current.scrollLeft = O.current, O.current = null), ee();
80
- });
81
- const oe = V((e, n) => {
82
- const l = p.current;
83
- if (!l) return;
84
- const c = be.current || 1e-4, h = Math.max(se.current ? se.current * 0.2 : 1e-9, Math.min(1, c * e)), v = (l.scrollLeft + n - w) / c;
85
- O.current = v * h + w - n, ge(!1), we(h);
86
- }, []);
87
- gn(p, (e) => {
88
- if (!vn(U, e)) return;
89
- e.preventDefault();
90
- const n = p.current;
91
- n && oe(Math.exp(-e.deltaY * 18e-4), e.clientX - n.getBoundingClientRect().left);
92
- });
93
- const ie = (e) => {
94
- _ === void 0 && Ue(e ? e.id : null), ze?.(e);
95
- }, qe = (e) => {
96
- const n = window.innerWidth || 1200, l = window.innerHeight || 800, c = e.clientX < n * 0.55 ? Math.max(12, n - 340) : 16, h = Math.max(130, Math.min(e.clientY, l - 130));
97
- return { x: c, y: h };
98
- }, L = Ae ? 42 : 54, s = P != null && o.find((e) => e.id === P) || null, Te = Math.ceil(w + ae * i + We + 90), Je = m + (Te - w) / i, ye = Math.max(m, m + (W.l - R - w) / i), Se = Math.min(Je, m + (W.l + W.w + R - w) / i), ke = sn(ye, Se, Math.max(1, (Se - ye) * i)).list.map((e) => ({
99
- left: Math.round(w + (e.t - m) * i),
100
- label: e.label
101
- })), Qe = o.filter((e) => e.end == null).length, D = I ? /* @__PURE__ */ t(
102
- dn,
103
- {
104
- heading: "Tasks",
105
- className: u?.summary,
106
- placement: T,
107
- floatingDefaultPosition: Ve,
108
- bubbleGlyphColors: x.slice(0, 3),
109
- items: o.map((e, n) => {
110
- const l = e.end == null ? N : e.end, c = Math.round(w + (e.start - m) * i), h = Math.max(14, Math.round(Math.max(0, l - e.start) * i)), v = 34 + n * L, b = !M.w || c < M.l + M.w && c + h > M.l, y = !M.h || v < M.t + M.h && v + L > M.t;
111
- return {
112
- id: e.id,
113
- number: String(n + 1).padStart(2, "0"),
114
- label: e.name,
115
- color: x[n % x.length],
116
- time: de(e.start),
117
- inView: b && y,
118
- selected: P === e.id
119
- };
120
- }),
121
- onPick: (e) => {
122
- const n = o.findIndex((H) => H.id === e), l = p.current;
123
- if (n < 0 || !l) return;
124
- const c = o[n], h = c.end == null ? N : c.end, v = Math.round(w + (c.start - m) * i), b = Math.max(14, Math.round(Math.max(0, h - c.start) * i)), y = {
125
- left: Math.max(0, v + b / 2 - l.clientWidth / 2)
126
- };
127
- l.clientHeight && (y.top = Math.max(0, 34 + n * L + L / 2 - l.clientHeight / 2)), Nn(l, y);
128
- }
129
- }
130
- ) : null;
131
- return /* @__PURE__ */ f(
132
- "div",
133
- {
134
- ref: De,
135
- className: d(a.root, u?.root, Be),
136
- style: Ge,
137
- children: [
138
- (me || Me || B != null || G != null) && /* @__PURE__ */ f("div", { className: d(a.toolbar, u?.toolbar), children: [
139
- /* @__PURE__ */ f("div", { className: a.toolbarText, children: [
140
- B != null && /* @__PURE__ */ t("span", { className: a.toolbarTitle, children: B }),
141
- /* @__PURE__ */ t("span", { className: a.toolbarMeta, children: G ?? (o.length ? `${o.length} tasks · ${Z(ae - 2 * re)} · ${Qe} running` : "No tasks") })
142
- ] }),
143
- Me,
144
- me && /* @__PURE__ */ t(
145
- un,
146
- {
147
- zoomPct: `${Math.round(i / A * 100)}%`,
148
- fitActive: pe,
149
- onZoomIn: () => oe(1.5, ne / 2),
150
- onZoomOut: () => oe(1 / 1.5, ne / 2),
151
- onFit: () => {
152
- ge(!0), we(null);
153
- },
154
- hint: U === "none" ? "drag pans" : (U === "ctrl" ? "Ctrl+scroll zooms" : "scroll zooms") + " · drag pans"
155
- }
156
- )
157
- ] }),
158
- T === "top" && D,
159
- /* @__PURE__ */ f("div", { className: a.layout, children: [
160
- T === "left" && D,
161
- /* @__PURE__ */ f("div", { className: a.main, children: [
162
- /* @__PURE__ */ f("div", { className: a.cardWrap, children: [
163
- /* @__PURE__ */ t("div", { className: d(a.card, u?.card), children: /* @__PURE__ */ t(
164
- "div",
165
- {
166
- ref: p,
167
- className: d(a.scroller, r.scroller, u?.scroller),
168
- style: { maxHeight: Ze },
169
- onPointerDown: C.onPointerDown,
170
- onPointerMove: C.onPointerMove,
171
- onPointerUp: C.onPointerUp,
172
- onPointerLeave: C.onPointerUp,
173
- onScroll: Xe,
174
- children: /* @__PURE__ */ f("div", { className: r.inner, style: { width: Te }, children: [
175
- Oe && ke.map((e, n) => /* @__PURE__ */ t("div", { className: r.gridline, style: { left: e.left } }, n)),
176
- ve && /* @__PURE__ */ t(
177
- "div",
178
- {
179
- className: r.nowLine,
180
- style: { left: Math.round(w + (N - m) * i) }
181
- }
182
- ),
183
- /* @__PURE__ */ t("div", { className: d(r.axis, u?.axis), children: ke.map((e, n) => /* @__PURE__ */ t("div", { className: r.axisLabel, style: { left: e.left }, children: e.label }, n)) }),
184
- o.map((e, n) => {
185
- const l = e.end == null, c = l ? N : e.end, h = Math.max(0, c - e.start), v = on(e, E), b = x[n % x.length], y = Math.round(w + (e.start - m) * i), H = Math.max(14, Math.round(h * i)), Le = Z(h) + (l ? " · running" : ""), Re = H > 130, Pe = { index: n, color: b, running: l, durationMs: h };
186
- return /* @__PURE__ */ f(
187
- "div",
188
- {
189
- className: d(r.row, u?.row),
190
- style: { height: L, opacity: E && !v ? 0.3 : 1 },
191
- children: [
192
- /* @__PURE__ */ t("div", { className: d(r.rowLabel, u?.rowLabel), children: he ? he(e, Pe) : /* @__PURE__ */ f(ce, { children: [
193
- /* @__PURE__ */ t("span", { className: r.rowName, children: /* @__PURE__ */ t(mn, { text: e.name, query: E }) }),
194
- /* @__PURE__ */ t("span", { className: r.rowDates, children: de(e.start) + (l ? " → now" : " → " + de(c)) })
195
- ] }) }),
196
- /* @__PURE__ */ t(
197
- "div",
198
- {
199
- className: d(r.bar, l && r.barRunning, u?.bar),
200
- style: {
201
- left: y,
202
- top: Math.round((L - xn) / 2),
203
- width: H,
204
- borderColor: b,
205
- background: l ? cn(b, 72) : b,
206
- boxShadow: E && v ? "0 0 0 3px var(--crk-timeline-hl-ring, #f3d98b)" : "none"
207
- },
208
- onClick: () => {
209
- C.wasDragSuppressed() || (j(null), ie(P === e.id ? null : e));
210
- },
211
- onMouseEnter: (en) => {
212
- if (P === e.id) return;
213
- const nn = qe(en);
214
- j({
215
- ...nn,
216
- id: e.id,
217
- title: e.name,
218
- time: F(e.start) + (l ? "" : " → " + F(c)),
219
- durLine: (l ? "running · " : "took ") + Z(h) + (e.owner ? " · " + e.owner : ""),
220
- detail: e.detail || ""
221
- });
222
- },
223
- onMouseLeave: () => j(null),
224
- children: $ ? $(e, Pe) : /* @__PURE__ */ f(ce, { children: [
225
- l && /* @__PURE__ */ t("span", { className: d(a.pulseDot, r.barDot) }),
226
- Re && /* @__PURE__ */ t("span", { className: r.barTextInside, children: Le })
227
- ] })
228
- }
229
- ),
230
- !$ && !Re && /* @__PURE__ */ t("div", { className: r.barTextOutside, style: { left: y + H + 10 }, children: Le })
231
- ]
232
- },
233
- e.id
234
- );
235
- })
236
- ] })
237
- }
238
- ) }),
239
- T === "bubble" && D
240
- ] }),
241
- /* @__PURE__ */ t("div", { className: d(a.footnote, u?.footnote), children: "Click a bar to open details in the side panel · dashed bars are still running and keep growing" })
242
- ] }),
243
- s && Y && /* @__PURE__ */ t("aside", { className: d(a.aside, r.drawer, u?.drawer), children: Y(s, {
244
- close: () => ie(null),
245
- running: s.end == null
246
- }) }),
247
- s && !Y && /* @__PURE__ */ f("aside", { className: d(a.aside, r.drawer, u?.drawer), children: [
248
- /* @__PURE__ */ f("div", { className: r.drawerHead, children: [
249
- /* @__PURE__ */ t(
250
- "span",
251
- {
252
- className: r.drawerSwatch,
253
- style: {
254
- background: x[o.indexOf(s) % x.length]
255
- }
256
- }
257
- ),
258
- /* @__PURE__ */ t("span", { className: r.drawerOwner, children: s.owner || "—" }),
259
- /* @__PURE__ */ t(
260
- "span",
261
- {
262
- className: d(
263
- r.drawerState,
264
- s.end == null && r.drawerStateRunning
265
- ),
266
- children: s.end == null ? "running" : "done"
267
- }
268
- ),
269
- /* @__PURE__ */ t("div", { className: r.drawerSpacer }),
270
- /* @__PURE__ */ t(
271
- "button",
272
- {
273
- type: "button",
274
- className: a.asideClose,
275
- "aria-label": "Close details",
276
- onClick: () => ie(null),
277
- children: "✕"
278
- }
279
- )
280
- ] }),
281
- /* @__PURE__ */ t("div", { className: r.drawerName, children: s.name }),
282
- /* @__PURE__ */ t("div", { className: r.drawerTiming, children: F(s.start) + " → " + (s.end == null ? "now" : F(s.end)) + " · " + Z((s.end == null ? N : s.end) - s.start) }),
283
- /* @__PURE__ */ t("div", { className: r.drawerDetail, children: s.detail || "—" }),
284
- /* @__PURE__ */ t("div", { className: a.asideSection, children: "Raw event" }),
285
- /* @__PURE__ */ t("pre", { className: a.asideRaw, children: JSON.stringify(s, null, 2) })
286
- ] }),
287
- (T === "right" || T === "floating") && D
288
- ] }),
289
- T === "bottom" && D,
290
- g && (() => {
291
- const e = o.find((l) => l.id === g.id), n = e && X ? X(e, {
292
- index: o.indexOf(e),
293
- color: x[o.indexOf(e) % x.length],
294
- running: e.end == null,
295
- durationMs: (e.end == null ? N : e.end) - e.start
296
- }) : void 0;
297
- return X && n == null ? null : /* @__PURE__ */ t(hn, { x: g.x, y: g.y, className: u?.tooltip, children: n !== void 0 ? n : /* @__PURE__ */ f(ce, { children: [
298
- /* @__PURE__ */ t("div", { className: a.tooltipTitle, children: g.title }),
299
- /* @__PURE__ */ t(
300
- "div",
301
- {
302
- className: d(a.tooltipLine, a.tooltipMono),
303
- style: { marginTop: 4 },
304
- children: g.time
305
- }
306
- ),
307
- /* @__PURE__ */ t("div", { className: a.tooltipLine, children: g.durLine }),
308
- g.detail && /* @__PURE__ */ t("div", { className: a.tooltipDim, style: { marginTop: 5 }, children: g.detail })
309
- ] }) });
310
- })()
311
- ]
312
- }
313
- );
314
- }
315
- );
316
- export {
317
- Cn as GanttTimeline
318
- };
1
+ import { forwardRef as e, useCallback as t, useEffect as n, useLayoutEffect as r, useMemo as i, useRef as a, useState as o } from "react";
2
+ import s from "clsx";
3
+ import c from "./Timeline.module.scss.js";
4
+ import l from "./GanttTimeline.module.scss.js";
5
+ import { TIMELINE_PALETTE_VARS as u, eventMatches as ee, fmtDate as te, fmtDateTime as d, fmtDur as f, ticks as ne, tint as re } from "./timelineCore.js";
6
+ import { HighlightText as ie, TimelineSummary as p, TimelineTooltip as m, TimelineZoomControls as h } from "./TimelineShared.js";
7
+ import { animateScrollTo as g, useContainerWidth as ae, useNowTicker as oe, useTimelinePan as se, useWheelZoom as ce, wheelZoomAllowed as le } from "./useTimeline.js";
8
+ import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
9
+ // src/components/Timeline/GanttTimeline.tsx
10
+ var b = 230, ue = 24, x = 400, de = 26, fe = e(function(e, fe) {
11
+ let { tasks: pe, title: S, meta: me, highlight: C, defaultHighlight: he, onHighlightChange: ge, showSearch: _e = !0, renderSearch: ve, compactRows: ye = !1, showGridlines: be = !0, showControls: xe = !0, wheelZoom: w = "ctrl", showSummary: T = !1, summaryPlacement: E = "left", summaryDefaultPosition: Se, maxHeight: Ce = "74vh", selectedTaskId: D, defaultSelectedTaskId: we = null, onTaskSelect: Te, renderRowLabel: Ee, renderBar: O, renderTooltip: k, renderDetails: A, classes: j, className: De, style: Oe } = e, M = a(null), [ke, Ae] = o(null), [je, Me] = o(!0), [N, P] = o(null), [Ne, Pe] = o(we), F = D === void 0 ? Ne : D, [I, Fe] = o({
12
+ l: 0,
13
+ t: 0,
14
+ w: 0,
15
+ h: 0
16
+ }), Ie = a(T);
17
+ Ie.current = T;
18
+ let Le = a(null), L = t(() => {
19
+ let e = M.current;
20
+ e && Fe((t) => t.l === e.scrollLeft && t.t === e.scrollTop && t.w === e.clientWidth && t.h === e.clientHeight ? t : {
21
+ l: e.scrollLeft,
22
+ t: e.scrollTop,
23
+ w: e.clientWidth,
24
+ h: e.clientHeight
25
+ });
26
+ }, []), [R, Re] = o({
27
+ l: 0,
28
+ w: 2e3
29
+ }), z = a(R);
30
+ z.current = R;
31
+ let B = t(() => {
32
+ let e = M.current;
33
+ if (!e) return;
34
+ let t = Math.floor(e.scrollLeft / x) * x, n = (Math.ceil((e.clientWidth || 1600) / x) + 1) * x;
35
+ (t !== z.current.l || n !== z.current.w) && Re({
36
+ l: t,
37
+ w: n
38
+ });
39
+ }, []), ze = t(() => {
40
+ Le.current ??= requestAnimationFrame(() => {
41
+ Le.current = null, B(), Ie.current && L();
42
+ });
43
+ }, [L, B]);
44
+ n(() => {
45
+ T && L();
46
+ });
47
+ let Be = pe.some((e) => e.end == null), V = oe(Be, 400), H = ae(M), U = se(M), [Ve, He] = o(he ?? ""), Ue = C === void 0 ? Ve : C, W = Ue.trim(), We = (e) => {
48
+ C === void 0 && He(e), ge?.(e);
49
+ }, Ge = ve ? ve({
50
+ value: Ue,
51
+ setValue: We
52
+ }) : _e ? /* @__PURE__ */ v("input", {
53
+ className: s(c.searchInput, j?.search),
54
+ placeholder: "Highlight keyword in tasks…",
55
+ "aria-label": "Highlight keyword",
56
+ value: Ue,
57
+ onChange: (e) => We(e.target.value)
58
+ }) : null, G = i(() => pe.slice().sort((e, t) => e.start - t.start), [pe]), K = G.length ? Math.min(...G.map((e) => e.start)) : V - 1, Ke = G.length ? Math.max(K + 1, ...G.map((e) => e.end == null ? V : e.end)) : V, qe = (Ke - K) * .03;
59
+ K -= qe, Ke += qe;
60
+ let Je = Ke - K, q = Math.max(240, H - b - ue) / Je, J = je || !ke ? q : ke, Ye = a(q), Xe = a(J);
61
+ Ye.current = q, Xe.current = J;
62
+ let Y = a(null);
63
+ r(() => {
64
+ Y.current != null && M.current && (M.current.scrollLeft = Y.current, Y.current = null), B();
65
+ });
66
+ let Ze = t((e, t) => {
67
+ let n = M.current;
68
+ if (!n) return;
69
+ let r = Xe.current || 1e-4, i = Math.max(Ye.current ? Ye.current * .2 : 1e-9, Math.min(1, r * e)), a = (n.scrollLeft + t - b) / r;
70
+ Y.current = a * i + b - t, Me(!1), Ae(i);
71
+ }, []);
72
+ ce(M, (e) => {
73
+ if (!le(w, e)) return;
74
+ e.preventDefault();
75
+ let t = M.current;
76
+ t && Ze(Math.exp(-e.deltaY * .0018), e.clientX - t.getBoundingClientRect().left);
77
+ });
78
+ let X = (e) => {
79
+ D === void 0 && Pe(e ? e.id : null), Te?.(e);
80
+ }, Qe = (e) => {
81
+ let t = window.innerWidth || 1200, n = window.innerHeight || 800;
82
+ return {
83
+ x: e.clientX < t * .55 ? Math.max(12, t - 340) : 16,
84
+ y: Math.max(130, Math.min(e.clientY, n - 130))
85
+ };
86
+ }, Z = ye ? 42 : 54, Q = F == null ? null : G.find((e) => e.id === F) || null, $e = Math.ceil(b + Je * J + ue + 90), et = K + ($e - b) / J, tt = Math.max(K, K + (R.l - x - b) / J), nt = Math.min(et, K + (R.l + R.w + x - b) / J), rt = ne(tt, nt, Math.max(1, (nt - tt) * J)).list.map((e) => ({
87
+ left: Math.round(b + (e.t - K) * J),
88
+ label: e.label
89
+ })), it = G.filter((e) => e.end == null).length, $ = T ? /* @__PURE__ */ v(p, {
90
+ heading: "Tasks",
91
+ className: j?.summary,
92
+ placement: E,
93
+ floatingDefaultPosition: Se,
94
+ bubbleGlyphColors: u.slice(0, 3),
95
+ items: G.map((e, t) => {
96
+ let n = e.end == null ? V : e.end, r = Math.round(b + (e.start - K) * J), i = Math.max(14, Math.round(Math.max(0, n - e.start) * J)), a = 34 + t * Z, o = !I.w || r < I.l + I.w && r + i > I.l, s = !I.h || a < I.t + I.h && a + Z > I.t;
97
+ return {
98
+ id: e.id,
99
+ number: String(t + 1).padStart(2, "0"),
100
+ label: e.name,
101
+ color: u[t % u.length],
102
+ time: te(e.start),
103
+ inView: o && s,
104
+ selected: F === e.id
105
+ };
106
+ }),
107
+ onPick: (e) => {
108
+ let t = G.findIndex((t) => t.id === e), n = M.current;
109
+ if (t < 0 || !n) return;
110
+ let r = G[t], i = r.end == null ? V : r.end, a = Math.round(b + (r.start - K) * J), o = Math.max(14, Math.round(Math.max(0, i - r.start) * J)), s = { left: Math.max(0, a + o / 2 - n.clientWidth / 2) };
111
+ n.clientHeight && (s.top = Math.max(0, 34 + t * Z + Z / 2 - n.clientHeight / 2)), g(n, s);
112
+ }
113
+ }) : null;
114
+ return /* @__PURE__ */ y("div", {
115
+ ref: fe,
116
+ className: s(c.root, j?.root, De),
117
+ style: Oe,
118
+ children: [
119
+ (xe || Ge || S != null || me != null) && /* @__PURE__ */ y("div", {
120
+ className: s(c.toolbar, j?.toolbar),
121
+ children: [
122
+ /* @__PURE__ */ y("div", {
123
+ className: c.toolbarText,
124
+ children: [S != null && /* @__PURE__ */ v("span", {
125
+ className: c.toolbarTitle,
126
+ children: S
127
+ }), /* @__PURE__ */ v("span", {
128
+ className: c.toolbarMeta,
129
+ children: me ?? (G.length ? `${G.length} tasks · ${f(Je - 2 * qe)} · ${it} running` : "No tasks")
130
+ })]
131
+ }),
132
+ Ge,
133
+ xe && /* @__PURE__ */ v(h, {
134
+ zoomPct: `${Math.round(J / q * 100)}%`,
135
+ fitActive: je,
136
+ onZoomIn: () => Ze(1.5, H / 2),
137
+ onZoomOut: () => Ze(1 / 1.5, H / 2),
138
+ onFit: () => {
139
+ Me(!0), Ae(null);
140
+ },
141
+ hint: w === "none" ? "drag pans" : (w === "ctrl" ? "Ctrl+scroll zooms" : "scroll zooms") + " · drag pans"
142
+ })
143
+ ]
144
+ }),
145
+ E === "top" && $,
146
+ /* @__PURE__ */ y("div", {
147
+ className: c.layout,
148
+ children: [
149
+ E === "left" && $,
150
+ /* @__PURE__ */ y("div", {
151
+ className: c.main,
152
+ children: [/* @__PURE__ */ y("div", {
153
+ className: c.cardWrap,
154
+ children: [/* @__PURE__ */ v("div", {
155
+ className: s(c.card, j?.card),
156
+ children: /* @__PURE__ */ v("div", {
157
+ ref: M,
158
+ className: s(c.scroller, l.scroller, j?.scroller),
159
+ style: { maxHeight: Ce },
160
+ onPointerDown: U.onPointerDown,
161
+ onPointerMove: U.onPointerMove,
162
+ onPointerUp: U.onPointerUp,
163
+ onPointerLeave: U.onPointerUp,
164
+ onScroll: ze,
165
+ children: /* @__PURE__ */ y("div", {
166
+ className: l.inner,
167
+ style: { width: $e },
168
+ children: [
169
+ be && rt.map((e, t) => /* @__PURE__ */ v("div", {
170
+ className: l.gridline,
171
+ style: { left: e.left }
172
+ }, t)),
173
+ Be && /* @__PURE__ */ v("div", {
174
+ className: l.nowLine,
175
+ style: { left: Math.round(b + (V - K) * J) }
176
+ }),
177
+ /* @__PURE__ */ v("div", {
178
+ className: s(l.axis, j?.axis),
179
+ children: rt.map((e, t) => /* @__PURE__ */ v("div", {
180
+ className: l.axisLabel,
181
+ style: { left: e.left },
182
+ children: e.label
183
+ }, t))
184
+ }),
185
+ G.map((e, t) => {
186
+ let n = e.end == null, r = n ? V : e.end, i = Math.max(0, r - e.start), a = ee(e, W), o = u[t % u.length], ne = Math.round(b + (e.start - K) * J), p = Math.max(14, Math.round(i * J)), m = f(i) + (n ? " · running" : ""), h = p > 130, g = {
187
+ index: t,
188
+ color: o,
189
+ running: n,
190
+ durationMs: i
191
+ };
192
+ return /* @__PURE__ */ y("div", {
193
+ className: s(l.row, j?.row),
194
+ style: {
195
+ height: Z,
196
+ opacity: W && !a ? .3 : 1
197
+ },
198
+ children: [
199
+ /* @__PURE__ */ v("div", {
200
+ className: s(l.rowLabel, j?.rowLabel),
201
+ children: Ee ? Ee(e, g) : /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("span", {
202
+ className: l.rowName,
203
+ children: /* @__PURE__ */ v(ie, {
204
+ text: e.name,
205
+ query: W
206
+ })
207
+ }), /* @__PURE__ */ v("span", {
208
+ className: l.rowDates,
209
+ children: te(e.start) + (n ? " → now" : " → " + te(r))
210
+ })] })
211
+ }),
212
+ /* @__PURE__ */ v("div", {
213
+ className: s(l.bar, n && l.barRunning, j?.bar),
214
+ style: {
215
+ left: ne,
216
+ top: Math.round((Z - de) / 2),
217
+ width: p,
218
+ borderColor: o,
219
+ background: n ? re(o, 72) : o,
220
+ boxShadow: W && a ? "0 0 0 3px var(--crk-timeline-hl-ring, #f3d98b)" : "none"
221
+ },
222
+ onClick: () => {
223
+ U.wasDragSuppressed() || (P(null), X(F === e.id ? null : e));
224
+ },
225
+ onMouseEnter: (t) => {
226
+ if (F === e.id) return;
227
+ let a = Qe(t);
228
+ P({
229
+ ...a,
230
+ id: e.id,
231
+ title: e.name,
232
+ time: d(e.start) + (n ? "" : " → " + d(r)),
233
+ durLine: (n ? "running · " : "took ") + f(i) + (e.owner ? " · " + e.owner : ""),
234
+ detail: e.detail || ""
235
+ });
236
+ },
237
+ onMouseLeave: () => P(null),
238
+ children: O ? O(e, g) : /* @__PURE__ */ y(_, { children: [n && /* @__PURE__ */ v("span", { className: s(c.pulseDot, l.barDot) }), h && /* @__PURE__ */ v("span", {
239
+ className: l.barTextInside,
240
+ children: m
241
+ })] })
242
+ }),
243
+ !O && !h && /* @__PURE__ */ v("div", {
244
+ className: l.barTextOutside,
245
+ style: { left: ne + p + 10 },
246
+ children: m
247
+ })
248
+ ]
249
+ }, e.id);
250
+ })
251
+ ]
252
+ })
253
+ })
254
+ }), E === "bubble" && $]
255
+ }), /* @__PURE__ */ v("div", {
256
+ className: s(c.footnote, j?.footnote),
257
+ children: "Click a bar to open details in the side panel · dashed bars are still running and keep growing"
258
+ })]
259
+ }),
260
+ Q && A && /* @__PURE__ */ v("aside", {
261
+ className: s(c.aside, l.drawer, j?.drawer),
262
+ children: A(Q, {
263
+ close: () => X(null),
264
+ running: Q.end == null
265
+ })
266
+ }),
267
+ Q && !A && /* @__PURE__ */ y("aside", {
268
+ className: s(c.aside, l.drawer, j?.drawer),
269
+ children: [
270
+ /* @__PURE__ */ y("div", {
271
+ className: l.drawerHead,
272
+ children: [
273
+ /* @__PURE__ */ v("span", {
274
+ className: l.drawerSwatch,
275
+ style: { background: u[G.indexOf(Q) % u.length] }
276
+ }),
277
+ /* @__PURE__ */ v("span", {
278
+ className: l.drawerOwner,
279
+ children: Q.owner || "—"
280
+ }),
281
+ /* @__PURE__ */ v("span", {
282
+ className: s(l.drawerState, Q.end == null && l.drawerStateRunning),
283
+ children: Q.end == null ? "running" : "done"
284
+ }),
285
+ /* @__PURE__ */ v("div", { className: l.drawerSpacer }),
286
+ /* @__PURE__ */ v("button", {
287
+ type: "button",
288
+ className: c.asideClose,
289
+ "aria-label": "Close details",
290
+ onClick: () => X(null),
291
+ children: "✕"
292
+ })
293
+ ]
294
+ }),
295
+ /* @__PURE__ */ v("div", {
296
+ className: l.drawerName,
297
+ children: Q.name
298
+ }),
299
+ /* @__PURE__ */ v("div", {
300
+ className: l.drawerTiming,
301
+ children: d(Q.start) + " → " + (Q.end == null ? "now" : d(Q.end)) + " · " + f((Q.end == null ? V : Q.end) - Q.start)
302
+ }),
303
+ /* @__PURE__ */ v("div", {
304
+ className: l.drawerDetail,
305
+ children: Q.detail || "—"
306
+ }),
307
+ /* @__PURE__ */ v("div", {
308
+ className: c.asideSection,
309
+ children: "Raw event"
310
+ }),
311
+ /* @__PURE__ */ v("pre", {
312
+ className: c.asideRaw,
313
+ children: JSON.stringify(Q, null, 2)
314
+ })
315
+ ]
316
+ }),
317
+ (E === "right" || E === "floating") && $
318
+ ]
319
+ }),
320
+ E === "bottom" && $,
321
+ N && (() => {
322
+ let e = G.find((e) => e.id === N.id), t = e && k ? k(e, {
323
+ index: G.indexOf(e),
324
+ color: u[G.indexOf(e) % u.length],
325
+ running: e.end == null,
326
+ durationMs: (e.end == null ? V : e.end) - e.start
327
+ }) : void 0;
328
+ return k && t == null ? null : /* @__PURE__ */ v(m, {
329
+ x: N.x,
330
+ y: N.y,
331
+ className: j?.tooltip,
332
+ children: t === void 0 ? /* @__PURE__ */ y(_, { children: [
333
+ /* @__PURE__ */ v("div", {
334
+ className: c.tooltipTitle,
335
+ children: N.title
336
+ }),
337
+ /* @__PURE__ */ v("div", {
338
+ className: s(c.tooltipLine, c.tooltipMono),
339
+ style: { marginTop: 4 },
340
+ children: N.time
341
+ }),
342
+ /* @__PURE__ */ v("div", {
343
+ className: c.tooltipLine,
344
+ children: N.durLine
345
+ }),
346
+ N.detail && /* @__PURE__ */ v("div", {
347
+ className: c.tooltipDim,
348
+ style: { marginTop: 5 },
349
+ children: N.detail
350
+ })
351
+ ] }) : t
352
+ });
353
+ })()
354
+ ]
355
+ });
356
+ });
357
+ export { fe as GanttTimeline };