@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,159 +1,193 @@
1
- import { jsx as f, jsxs as S } from "react/jsx-runtime";
2
- import { forwardRef as pe, useState as ce, useRef as p, useCallback as g, useEffect as H, useImperativeHandle as ye, Fragment as Me } from "react";
3
- import i from "clsx";
4
- import t from "./Timer.module.scss.js";
5
- const T = () => Date.now();
6
- function xe(n) {
7
- const l = Math.max(0, Math.floor(n)), u = Math.floor(l / 86400), d = Math.floor(l % 86400 / 3600), h = Math.floor(l % 3600 / 60), r = l % 60, e = (y) => String(y).padStart(2, "0");
8
- return u > 0 ? `${u}d ${e(d)}:${e(h)}:${e(r)}` : d > 0 ? `${d}:${e(h)}:${e(r)}` : `${e(h)}:${e(r)}`;
1
+ import e from "./Timer.module.js";
2
+ import { Fragment as t, forwardRef as n, useCallback as r, useEffect as i, useImperativeHandle as a, useRef as o, useState as s } from "react";
3
+ import c from "clsx";
4
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
5
+ // src/components/Timer/Timer.tsx
6
+ var d = () => Date.now();
7
+ function ee(e) {
8
+ let t = Math.max(0, Math.floor(e)), n = Math.floor(t / 86400), r = Math.floor(t % 86400 / 3600), i = Math.floor(t % 3600 / 60), a = t % 60, o = (e) => String(e).padStart(2, "0");
9
+ return n > 0 ? `${n}d ${o(r)}:${o(i)}:${o(a)}` : r > 0 ? `${r}:${o(i)}:${o(a)}` : `${o(i)}:${o(a)}`;
9
10
  }
10
- const Ne = ["days", "hours", "minutes", "seconds"], ve = { days: 86400, hours: 3600, minutes: 60, seconds: 1 }, be = { days: "d", hours: "h", minutes: "m", seconds: "s" }, Re = { days: "days", hours: "hours", minutes: "minutes", seconds: "seconds" };
11
- function Ie(n) {
12
- return n >= 86400 ? ["days", "hours", "minutes", "seconds"] : n >= 3600 ? ["hours", "minutes", "seconds"] : ["minutes", "seconds"];
11
+ var f = [
12
+ "days",
13
+ "hours",
14
+ "minutes",
15
+ "seconds"
16
+ ], p = {
17
+ days: 86400,
18
+ hours: 3600,
19
+ minutes: 60,
20
+ seconds: 1
21
+ }, m = {
22
+ days: "d",
23
+ hours: "h",
24
+ minutes: "m",
25
+ seconds: "s"
26
+ }, h = {
27
+ days: "days",
28
+ hours: "hours",
29
+ minutes: "minutes",
30
+ seconds: "seconds"
31
+ };
32
+ function te(e) {
33
+ return e >= 86400 ? [
34
+ "days",
35
+ "hours",
36
+ "minutes",
37
+ "seconds"
38
+ ] : e >= 3600 ? [
39
+ "hours",
40
+ "minutes",
41
+ "seconds"
42
+ ] : ["minutes", "seconds"];
13
43
  }
14
- function Se(n, l, u, d) {
15
- const h = Ne.filter((e) => l.includes(e));
16
- let r = Math.max(0, Math.floor(n));
17
- return h.map((e, y) => {
18
- const $ = ve[e], M = Math.floor(r / $);
19
- r %= $;
20
- const F = y === 0 ? String(M) : String(M).padStart(2, "0"), x = d?.[e];
21
- let b;
22
- return x !== void 0 ? b = typeof x == "function" ? x(M) : x : b = u === "long" ? Re[e] : be[e], { unit: e, value: M, text: F, label: b };
23
- });
44
+ function ne(e, t, n, r) {
45
+ let i = f.filter((e) => t.includes(e)), a = Math.max(0, Math.floor(e));
46
+ return i.map((e, t) => {
47
+ let i = p[e], o = Math.floor(a / i);
48
+ a %= i;
49
+ let s = t === 0 ? String(o) : String(o).padStart(2, "0"), c = r?.[e], l;
50
+ return l = c === void 0 ? n === "long" ? h[e] : m[e] : typeof c == "function" ? c(o) : c, {
51
+ unit: e,
52
+ value: o,
53
+ text: s,
54
+ label: l
55
+ };
56
+ });
24
57
  }
25
- const Te = pe(
26
- ({
27
- mode: n = "countdown",
28
- duration: l,
29
- to: u,
30
- value: d,
31
- autoStart: h = !0,
32
- running: r,
33
- interval: e = 1e3,
34
- variant: y = "digital",
35
- size: $ = "md",
36
- format: M = xe,
37
- units: F,
38
- unitFormat: x = "short",
39
- unitLabels: b,
40
- segmentVariant: ae = "boxed",
41
- renderSegment: G,
42
- segmentSeparator: W,
43
- label: q,
44
- labelPlacement: O = "bottom",
45
- onComplete: z,
46
- onTick: J,
47
- classes: o,
48
- className: ie,
49
- style: le,
50
- "aria-label": ue
51
- }, de) => {
52
- const c = d !== void 0, s = u !== void 0, K = s ? u instanceof Date ? u.getTime() : u : 0, V = (l ?? 0) * 1e3, [, Q] = ce(0), [w, D] = ce(!1), m = p(null), X = p(!1), k = p(0), R = p(!1), L = p(null), Y = p(z), Z = p(J);
53
- Y.current = z, Z.current = J;
54
- const P = g(
55
- () => k.current + (m.current != null ? T() - m.current : 0),
56
- []
57
- ), I = g(() => {
58
- if (c) return d;
59
- if (s) return Math.max(0, (K - T()) / 1e3);
60
- const a = P();
61
- return n === "countdown" ? Math.max(0, (V - a) / 1e3) : a / 1e3;
62
- }, [c, d, s, K, P, n, V]), N = g(() => {
63
- L.current && (clearInterval(L.current), L.current = null);
64
- }, []), U = g(() => {
65
- m.current != null && (k.current += T() - m.current, m.current = null), N(), D(!1);
66
- }, [N]), v = g(() => {
67
- c || (m.current == null && (m.current = T()), R.current = !1, D(!0));
68
- }, [c]), _ = g(() => U(), [U]), ee = g(() => {
69
- N(), m.current = null, k.current = 0, R.current = !1, D(!1), Q((a) => a + 1);
70
- }, [N]), te = g(() => {
71
- k.current = 0, R.current = !1, m.current = T(), D(!0);
72
- }, []);
73
- H(() => {
74
- X.current || (X.current = !0, h && r === void 0 && !c && !s && v());
75
- }, [h, r, c, s, v]), H(() => {
76
- if (c || !(s ? !0 : w)) return;
77
- const E = () => {
78
- const oe = I();
79
- Z.current?.(oe), Q((ge) => ge + 1), (n === "countdown" || s) && oe <= 0 && !R.current && (R.current = !0, Y.current?.(), s || U());
80
- };
81
- return L.current = setInterval(E, e), N;
82
- }, [w, s, c, e, n, I, U, N]), H(() => {
83
- r === void 0 || c || (r ? v() : _());
84
- }, [r, c, v, _]), ye(
85
- de,
86
- () => ({
87
- start: v,
88
- pause: _,
89
- reset: ee,
90
- restart: te,
91
- getTime: () => I(),
92
- get isRunning() {
93
- return w;
94
- }
95
- }),
96
- [v, _, ee, te, I, w]
97
- );
98
- const A = I(), j = n === "countdown" || s ? Math.ceil(A) : Math.floor(A), ne = M(j), C = s ? 0 : V / 1e3;
99
- let B = 0;
100
- C > 0 && (B = n === "countdown" ? A / C : Math.min(1, A / C)), B = Math.max(0, Math.min(1, B));
101
- const me = Math.max(j, l ?? 0), fe = F ?? Ie(me), he = Se(j, fe, x, b), re = O === "top" || O === "left", se = q != null && /* @__PURE__ */ f("span", { className: i(t.label, o?.label), children: q });
102
- return /* @__PURE__ */ S(
103
- "div",
104
- {
105
- className: i(
106
- t.root,
107
- t[$],
108
- t[`label_${O}`],
109
- o?.root,
110
- ie
111
- ),
112
- style: le,
113
- role: "timer",
114
- "aria-label": ue,
115
- "aria-live": "off",
116
- children: [
117
- re && se,
118
- y === "ring" ? /* @__PURE__ */ S("span", { className: t.ringWrap, children: [
119
- /* @__PURE__ */ S("svg", { viewBox: "0 0 100 100", className: t.ring, "aria-hidden": "true", children: [
120
- /* @__PURE__ */ f("circle", { className: i(t.ringTrack, o?.ringTrack), cx: "50", cy: "50", r: "44" }),
121
- /* @__PURE__ */ f(
122
- "circle",
123
- {
124
- className: i(t.ringProgress, o?.ringProgress),
125
- cx: "50",
126
- cy: "50",
127
- r: "44",
128
- style: { strokeDasharray: 2 * Math.PI * 44, strokeDashoffset: 2 * Math.PI * 44 * (1 - B) }
129
- }
130
- )
131
- ] }),
132
- /* @__PURE__ */ f("span", { className: i(t.display, t.ringDisplay, o?.display), children: ne })
133
- ] }) : y === "segments" ? /* @__PURE__ */ f("span", { className: i(t.segments, o?.segments), children: he.map((a, E) => /* @__PURE__ */ S(Me, { children: [
134
- E > 0 && W != null && /* @__PURE__ */ f("span", { className: t.segmentSep, "aria-hidden": "true", children: W }),
135
- G ? G(a, E) : /* @__PURE__ */ S(
136
- "span",
137
- {
138
- className: i(
139
- t.segment,
140
- ae === "boxed" ? t.segmentBoxed : t.segmentPlain,
141
- o?.segment
142
- ),
143
- children: [
144
- /* @__PURE__ */ f("span", { className: i(t.segmentValue, o?.segmentValue), children: a.text }),
145
- /* @__PURE__ */ f("span", { className: i(t.segmentLabel, o?.segmentLabel), children: a.label })
146
- ]
147
- }
148
- )
149
- ] }, a.unit)) }) : /* @__PURE__ */ f("span", { className: i(t.display, o?.display), children: ne }),
150
- !re && se
151
- ]
152
- }
153
- );
154
- }
155
- );
156
- Te.displayName = "Timer";
157
- export {
158
- Te as Timer
159
- };
58
+ var g = n(({ mode: n = "countdown", duration: f, to: p, value: m, autoStart: h = !0, running: g, interval: _ = 1e3, variant: v = "digital", size: re = "md", format: ie = ee, units: ae, unitFormat: oe = "short", unitLabels: se, segmentVariant: ce = "boxed", renderSegment: y, segmentSeparator: b, label: x, labelPlacement: S = "bottom", onComplete: C, onTick: w, classes: T, className: le, style: ue, "aria-label": de }, fe) => {
59
+ let E = m !== void 0, D = p !== void 0, O = D ? p instanceof Date ? p.getTime() : p : 0, k = (f ?? 0) * 1e3, [, A] = s(0), [j, M] = s(!1), N = o(null), P = o(!1), F = o(0), I = o(!1), L = o(null), R = o(C), z = o(w);
60
+ R.current = C, z.current = w;
61
+ let B = r(() => F.current + (N.current == null ? 0 : d() - N.current), []), V = r(() => {
62
+ if (E) return m;
63
+ if (D) return Math.max(0, (O - d()) / 1e3);
64
+ let e = B();
65
+ return n === "countdown" ? Math.max(0, (k - e) / 1e3) : e / 1e3;
66
+ }, [
67
+ E,
68
+ m,
69
+ D,
70
+ O,
71
+ B,
72
+ n,
73
+ k
74
+ ]), H = r(() => {
75
+ L.current &&= (clearInterval(L.current), null);
76
+ }, []), U = r(() => {
77
+ N.current != null && (F.current += d() - N.current, N.current = null), H(), M(!1);
78
+ }, [H]), W = r(() => {
79
+ E || (N.current ??= d(), I.current = !1, M(!0));
80
+ }, [E]), G = r(() => U(), [U]), K = r(() => {
81
+ H(), N.current = null, F.current = 0, I.current = !1, M(!1), A((e) => e + 1);
82
+ }, [H]), q = r(() => {
83
+ F.current = 0, I.current = !1, N.current = d(), M(!0);
84
+ }, []);
85
+ i(() => {
86
+ P.current || (P.current = !0, h && g === void 0 && !E && !D && W());
87
+ }, [
88
+ h,
89
+ g,
90
+ E,
91
+ D,
92
+ W
93
+ ]), i(() => E || !(D || j) ? void 0 : (L.current = setInterval(() => {
94
+ let e = V();
95
+ z.current?.(e), A((e) => e + 1), (n === "countdown" || D) && e <= 0 && !I.current && (I.current = !0, R.current?.(), D || U());
96
+ }, _), H), [
97
+ j,
98
+ D,
99
+ E,
100
+ _,
101
+ n,
102
+ V,
103
+ U,
104
+ H
105
+ ]), i(() => {
106
+ g === void 0 || E || (g ? W() : G());
107
+ }, [
108
+ g,
109
+ E,
110
+ W,
111
+ G
112
+ ]), a(fe, () => ({
113
+ start: W,
114
+ pause: G,
115
+ reset: K,
116
+ restart: q,
117
+ getTime: () => V(),
118
+ get isRunning() {
119
+ return j;
120
+ }
121
+ }), [
122
+ W,
123
+ G,
124
+ K,
125
+ q,
126
+ V,
127
+ j
128
+ ]);
129
+ let J = V(), Y = n === "countdown" || D ? Math.ceil(J) : Math.floor(J), X = ie(Y), Z = D ? 0 : k / 1e3, Q = 0;
130
+ Z > 0 && (Q = n === "countdown" ? J / Z : Math.min(1, J / Z)), Q = Math.max(0, Math.min(1, Q));
131
+ let pe = ne(Y, ae ?? te(Math.max(Y, f ?? 0)), oe, se), $ = S === "top" || S === "left", me = x != null && /* @__PURE__ */ l("span", {
132
+ className: c(e.label, T?.label),
133
+ children: x
134
+ });
135
+ return /* @__PURE__ */ u("div", {
136
+ className: c(e.root, e[re], e[`label_${S}`], T?.root, le),
137
+ style: ue,
138
+ role: "timer",
139
+ "aria-label": de,
140
+ "aria-live": "off",
141
+ children: [
142
+ $ && me,
143
+ v === "ring" ? /* @__PURE__ */ u("span", {
144
+ className: e.ringWrap,
145
+ children: [/* @__PURE__ */ u("svg", {
146
+ viewBox: "0 0 100 100",
147
+ className: e.ring,
148
+ "aria-hidden": "true",
149
+ children: [/* @__PURE__ */ l("circle", {
150
+ className: c(e.ringTrack, T?.ringTrack),
151
+ cx: "50",
152
+ cy: "50",
153
+ r: "44"
154
+ }), /* @__PURE__ */ l("circle", {
155
+ className: c(e.ringProgress, T?.ringProgress),
156
+ cx: "50",
157
+ cy: "50",
158
+ r: "44",
159
+ style: {
160
+ strokeDasharray: 2 * Math.PI * 44,
161
+ strokeDashoffset: 2 * Math.PI * 44 * (1 - Q)
162
+ }
163
+ })]
164
+ }), /* @__PURE__ */ l("span", {
165
+ className: c(e.display, e.ringDisplay, T?.display),
166
+ children: X
167
+ })]
168
+ }) : v === "segments" ? /* @__PURE__ */ l("span", {
169
+ className: c(e.segments, T?.segments),
170
+ children: pe.map((n, r) => /* @__PURE__ */ u(t, { children: [r > 0 && b != null && /* @__PURE__ */ l("span", {
171
+ className: e.segmentSep,
172
+ "aria-hidden": "true",
173
+ children: b
174
+ }), y ? y(n, r) : /* @__PURE__ */ u("span", {
175
+ className: c(e.segment, ce === "boxed" ? e.segmentBoxed : e.segmentPlain, T?.segment),
176
+ children: [/* @__PURE__ */ l("span", {
177
+ className: c(e.segmentValue, T?.segmentValue),
178
+ children: n.text
179
+ }), /* @__PURE__ */ l("span", {
180
+ className: c(e.segmentLabel, T?.segmentLabel),
181
+ children: n.label
182
+ })]
183
+ })] }, n.unit))
184
+ }) : /* @__PURE__ */ l("span", {
185
+ className: c(e.display, T?.display),
186
+ children: X
187
+ }),
188
+ !$ && me
189
+ ]
190
+ });
191
+ });
192
+ g.displayName = "Timer";
193
+ export { g as Timer };
@@ -0,0 +1,29 @@
1
+ // src/components/Timer/Timer.module.scss
2
+ var e = "crk-root-ze-qA", t = "crk-label_top-f5ix1", n = "crk-label_top-f5ix1", r = "crk-label_bottom-vf4Tk", i = "crk-label_bottom-vf4Tk", a = "crk-label_left-Tsjlx", o = "crk-label_left-Tsjlx", s = "crk-label_right-l0T9l", c = "crk-label_right-l0T9l", l = "crk-sm-LpMEk", u = "crk-md-Of6tL", d = "crk-lg-KKqPc", f = "crk-display-09uul", p = "crk-label-F7Uuf", m = "crk-ringWrap-F71Yf", h = "crk-ring-PqZbn", g = "crk-ringTrack-SaJmr", _ = "crk-ringProgress-54wH1", v = "crk-ringDisplay-biAno", y = "crk-segments-U9rJE", b = "crk-segment-2RMKN", x = "crk-segmentBoxed-iVvX0", S = "crk-segmentValue-fsXMN", C = "crk-segmentLabel-kihRG", w = "crk-segmentSep-ZGeiV", T = {
3
+ root: e,
4
+ label_top: t,
5
+ labelTop: n,
6
+ label_bottom: r,
7
+ labelBottom: i,
8
+ label_left: a,
9
+ labelLeft: o,
10
+ label_right: s,
11
+ labelRight: c,
12
+ sm: l,
13
+ md: u,
14
+ lg: d,
15
+ display: f,
16
+ label: p,
17
+ ringWrap: m,
18
+ ring: h,
19
+ ringTrack: g,
20
+ ringProgress: _,
21
+ ringDisplay: v,
22
+ segments: y,
23
+ segment: b,
24
+ segmentBoxed: x,
25
+ segmentValue: S,
26
+ segmentLabel: C,
27
+ segmentSep: w
28
+ };
29
+ export { T as default, f as display, p as label, i as labelBottom, o as labelLeft, c as labelRight, n as labelTop, r as label_bottom, a as label_left, s as label_right, t as label_top, d as lg, u as md, h as ring, v as ringDisplay, _ as ringProgress, g as ringTrack, m as ringWrap, e as root, b as segment, x as segmentBoxed, C as segmentLabel, w as segmentSep, S as segmentValue, y as segments, l as sm };
@@ -79,4 +79,4 @@ export interface ToastProviderProps {
79
79
  * <App />
80
80
  * </ToastProvider>
81
81
  */
82
- export declare function ToastProvider({ children, position, duration, max, classes, }: ToastProviderProps): import("react/jsx-runtime").JSX.Element;
82
+ export declare function ToastProvider({ children, position, duration, max, classes, }: ToastProviderProps): import("react").JSX.Element;