@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,23 +1,13 @@
1
- const t = "crk-root-IuiQ5", s = "crk-sm-tfMLg", c = "crk-md-MdjxU", o = "crk-lg-6-p8a", l = "crk-list-UN-OF", i = "crk-item-ZOauk", r = "crk-active-gs4QO", n = "crk-control-HnlrC", e = "crk-ellipsis-iAsGN", k = {
2
- root: t,
3
- sm: s,
4
- md: c,
5
- lg: o,
6
- list: l,
7
- item: i,
8
- active: r,
9
- control: n,
10
- ellipsis: e
11
- };
12
- export {
13
- r as active,
14
- n as control,
15
- k as default,
16
- e as ellipsis,
17
- i as item,
18
- o as lg,
19
- l as list,
20
- c as md,
21
- t as root,
22
- s as sm
1
+ // src/components/Pagination/Pagination.module.scss
2
+ var e = "crk-root-IuiQ5", t = "crk-sm-tfMLg", n = "crk-md-MdjxU", r = "crk-lg-6-p8a", i = "crk-list-UN-OF", a = "crk-item-ZOauk", o = "crk-active-gs4QO", s = "crk-control-HnlrC", c = "crk-ellipsis-iAsGN", l = {
3
+ root: e,
4
+ sm: t,
5
+ md: n,
6
+ lg: r,
7
+ list: i,
8
+ item: a,
9
+ active: o,
10
+ control: s,
11
+ ellipsis: c
23
12
  };
13
+ export { o as active, s as control, l as default, c as ellipsis, a as item, r as lg, i as list, n as md, e as root, t as sm };
@@ -1,24 +1,17 @@
1
- function l(i, s) {
2
- const e = Math.max(s - i + 1, 0);
3
- return Array.from({ length: e }, (h, m) => i + m);
1
+ // src/components/Pagination/paginationRange.ts
2
+ function e(e, t) {
3
+ let n = Math.max(t - e + 1, 0);
4
+ return Array.from({ length: n }, (t, n) => e + n);
4
5
  }
5
- function x(i, s, e = 1, h = 2) {
6
- if (s <= 0) return [];
7
- const m = l(1, Math.min(e, s)), M = l(Math.max(s - e + 1, e + 1), s), a = Math.max(
8
- Math.min(i - h, s - e - h * 2 - 1),
9
- e + 2
10
- ), g = Math.min(
11
- Math.max(i + h, e + h * 2 + 2),
12
- M.length > 0 ? M[0] - 2 : s - 1
13
- );
14
- return [
15
- ...m,
16
- ...a > e + 2 ? ["ellipsis"] : e + 1 < s - e ? [e + 1] : [],
17
- ...l(a, g),
18
- ...g < s - e - 1 ? ["ellipsis"] : s - e > e ? [s - e] : [],
19
- ...M
20
- ];
6
+ function t(t, n, r = 1, i = 2) {
7
+ if (n <= 0) return [];
8
+ let a = e(1, Math.min(r, n)), o = e(Math.max(n - r + 1, r + 1), n), s = Math.max(Math.min(t - i, n - r - i * 2 - 1), r + 2), c = Math.min(Math.max(t + i, r + i * 2 + 2), o.length > 0 ? o[0] - 2 : n - 1);
9
+ return [
10
+ ...a,
11
+ ...s > r + 2 ? ["ellipsis"] : r + 1 < n - r ? [r + 1] : [],
12
+ ...e(s, c),
13
+ ...c < n - r - 1 ? ["ellipsis"] : n - r > r ? [n - r] : [],
14
+ ...o
15
+ ];
21
16
  }
22
- export {
23
- x as paginationRange
24
- };
17
+ export { t as paginationRange };
@@ -1,135 +1,111 @@
1
- import { jsx as y, jsxs as K } from "react/jsx-runtime";
2
- import { forwardRef as Q, useState as E, useRef as B, useId as U, useCallback as O, useLayoutEffect as Z, useEffect as _, isValidElement as ee, cloneElement as te } from "react";
3
- import R from "clsx";
4
- import L from "./Popover.module.scss.js";
5
- import { useClickOutside as oe } from "../../hooks/useClickOutside.js";
6
- import { useEscapeLayer as re, EscapeLayerProvider as ne } from "../../hooks/useEscapeLayer.js";
7
- function ie(...a) {
8
- return (h) => {
9
- for (const l of a)
10
- l && (typeof l == "function" ? l(h) : l.current = h);
11
- };
1
+ import { cloneElement as e, forwardRef as t, isValidElement as n, useCallback as r, useEffect as i, useId as a, useLayoutEffect as o, useRef as s, useState as c } from "react";
2
+ import l from "clsx";
3
+ import u from "./Popover.module.scss.js";
4
+ import { useClickOutside as d } from "../../hooks/useClickOutside.js";
5
+ import { EscapeLayerProvider as f, useEscapeLayer as p } from "../../hooks/useEscapeLayer.js";
6
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
7
+ // src/components/Popover/Popover.tsx
8
+ function g(...e) {
9
+ return (t) => {
10
+ for (let n of e) n && (typeof n == "function" ? n(t) : n.current = t);
11
+ };
12
12
  }
13
- const se = Q(
14
- ({
15
- trigger: a,
16
- asChild: h = !1,
17
- content: l,
18
- position: n = "bottom",
19
- autoPosition: m = !0,
20
- open: j,
21
- onOpenChange: z,
22
- classes: g,
23
- className: H,
24
- style: T
25
- }, V) => {
26
- const [W, A] = E(!1), [D, M] = E(n), [F, P] = E(0), [G, X] = E(0), Y = B(null), u = B(null), v = B(null), k = U(), C = j !== void 0, o = C ? j : W, w = O(
27
- (t) => {
28
- C || A(t), z?.(t);
29
- },
30
- [C, z]
31
- ), $ = O(() => {
32
- w(!1), v.current?.focus();
33
- }, [w]), q = O(() => {
34
- w(!o);
35
- }, [o, w]);
36
- oe(Y, $, o);
37
- const J = re($, o);
38
- Z(() => {
39
- if (!o || !m) {
40
- M(n), P(0), X(0);
41
- return;
42
- }
43
- if (typeof window > "u") return;
44
- const t = () => {
45
- const b = v.current, x = u.current;
46
- if (!b || !x) return;
47
- const s = b.getBoundingClientRect(), i = x.getBoundingClientRect(), I = window.innerWidth, S = window.innerHeight, r = 8;
48
- let c = n;
49
- if (n === "bottom" || n === "top") {
50
- const e = s.bottom + r + i.height <= S, p = s.top - r - i.height >= 0;
51
- n === "bottom" && !e && p ? c = "top" : n === "top" && !p && e && (c = "bottom");
52
- } else {
53
- const e = s.right + r + i.width <= I, p = s.left - r - i.width >= 0;
54
- n === "right" && !e && p ? c = "left" : n === "left" && !p && e && (c = "right");
55
- }
56
- let f = 0, d = 0;
57
- if (c === "bottom" || c === "top") {
58
- const e = s.left + s.width / 2 - i.width / 2;
59
- e < r ? f = r - e : e + i.width > I - r && (f = I - r - (e + i.width));
60
- } else {
61
- const e = s.top + s.height / 2 - i.height / 2;
62
- e < r ? d = r - e : e + i.height > S - r && (d = S - r - (e + i.height));
63
- }
64
- f = Math.round(f), d = Math.round(d), M((e) => e === c ? e : c), P((e) => e === f ? e : f), X((e) => e === d ? e : d);
65
- };
66
- return t(), window.addEventListener("scroll", t, !0), window.addEventListener("resize", t), () => {
67
- window.removeEventListener("scroll", t, !0), window.removeEventListener("resize", t);
68
- };
69
- }, [o, m, n]), _(() => {
70
- if (o && u.current) {
71
- const t = u.current.querySelector(
72
- 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
73
- );
74
- t ? t.focus() : u.current.focus();
75
- }
76
- }, [o]);
77
- let N;
78
- if (h && ee(a)) {
79
- const t = a, b = t.ref;
80
- N = te(t, {
81
- ref: ie(v, b),
82
- onClick: (x) => {
83
- t.props.onClick?.(x), q();
84
- },
85
- className: R(t.props.className, g?.trigger),
86
- "aria-expanded": o,
87
- "aria-haspopup": "dialog",
88
- "aria-controls": o ? k : void 0
89
- });
90
- } else
91
- N = /* @__PURE__ */ y(
92
- "button",
93
- {
94
- ref: v,
95
- type: "button",
96
- className: R(L.trigger, g?.trigger),
97
- onClick: q,
98
- "aria-expanded": o,
99
- "aria-haspopup": "dialog",
100
- "aria-controls": o ? k : void 0,
101
- children: a
102
- }
103
- );
104
- return /* @__PURE__ */ y(
105
- "div",
106
- {
107
- ref: V,
108
- className: R(L.root, g?.root, H),
109
- style: T,
110
- children: /* @__PURE__ */ K("div", { ref: Y, children: [
111
- N,
112
- o && /* @__PURE__ */ y(
113
- "div",
114
- {
115
- ref: u,
116
- id: k,
117
- role: "dialog",
118
- tabIndex: -1,
119
- className: R(L.popover, L[m ? D : n], g?.popover),
120
- style: m ? {
121
- "--crk-popover-shift-x": `${F}px`,
122
- "--crk-popover-shift-y": `${G}px`
123
- } : void 0,
124
- children: /* @__PURE__ */ y(ne, { value: J, children: l })
125
- }
126
- )
127
- ] })
128
- }
129
- );
130
- }
131
- );
132
- se.displayName = "Popover";
133
- export {
134
- se as Popover
135
- };
13
+ var _ = t(({ trigger: t, asChild: _ = !1, content: v, position: y = "bottom", autoPosition: b = !0, open: x, onOpenChange: S, classes: C, className: w, style: T }, E) => {
14
+ let [D, O] = c(!1), [k, A] = c(y), [j, M] = c(0), [N, P] = c(0), F = s(null), I = s(null), L = s(null), R = a(), z = x !== void 0, B = z ? x : D, V = r((e) => {
15
+ z || O(e), S?.(e);
16
+ }, [z, S]), H = r(() => {
17
+ V(!1), L.current?.focus();
18
+ }, [V]), U = r(() => {
19
+ V(!B);
20
+ }, [B, V]);
21
+ d(F, H, B);
22
+ let W = p(H, B);
23
+ o(() => {
24
+ if (!B || !b) {
25
+ A(y), M(0), P(0);
26
+ return;
27
+ }
28
+ if (typeof window > "u") return;
29
+ let e = () => {
30
+ let e = L.current, t = I.current;
31
+ if (!e || !t) return;
32
+ let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = window.innerWidth, a = window.innerHeight, o = y;
33
+ if (y === "bottom" || y === "top") {
34
+ let e = n.bottom + 8 + r.height <= a, t = n.top - 8 - r.height >= 0;
35
+ y === "bottom" && !e && t ? o = "top" : y === "top" && !t && e && (o = "bottom");
36
+ } else {
37
+ let e = n.right + 8 + r.width <= i, t = n.left - 8 - r.width >= 0;
38
+ y === "right" && !e && t ? o = "left" : y === "left" && !t && e && (o = "right");
39
+ }
40
+ let s = 0, c = 0;
41
+ if (o === "bottom" || o === "top") {
42
+ let e = n.left + n.width / 2 - r.width / 2;
43
+ e < 8 ? s = 8 - e : e + r.width > i - 8 && (s = i - 8 - (e + r.width));
44
+ } else {
45
+ let e = n.top + n.height / 2 - r.height / 2;
46
+ e < 8 ? c = 8 - e : e + r.height > a - 8 && (c = a - 8 - (e + r.height));
47
+ }
48
+ s = Math.round(s), c = Math.round(c), A((e) => e === o ? e : o), M((e) => e === s ? e : s), P((e) => e === c ? e : c);
49
+ };
50
+ return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
51
+ window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
52
+ };
53
+ }, [
54
+ B,
55
+ b,
56
+ y
57
+ ]), i(() => {
58
+ if (B && I.current) {
59
+ let e = I.current.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])");
60
+ e ? e.focus() : I.current.focus();
61
+ }
62
+ }, [B]);
63
+ let G;
64
+ if (_ && n(t)) {
65
+ let n = t, r = n.ref;
66
+ G = e(n, {
67
+ ref: g(L, r),
68
+ onClick: (e) => {
69
+ n.props.onClick?.(e), U();
70
+ },
71
+ className: l(n.props.className, C?.trigger),
72
+ "aria-expanded": B,
73
+ "aria-haspopup": "dialog",
74
+ "aria-controls": B ? R : void 0
75
+ });
76
+ } else G = /* @__PURE__ */ m("button", {
77
+ ref: L,
78
+ type: "button",
79
+ className: l(u.trigger, C?.trigger),
80
+ onClick: U,
81
+ "aria-expanded": B,
82
+ "aria-haspopup": "dialog",
83
+ "aria-controls": B ? R : void 0,
84
+ children: t
85
+ });
86
+ return /* @__PURE__ */ m("div", {
87
+ ref: E,
88
+ className: l(u.root, C?.root, w),
89
+ style: T,
90
+ children: /* @__PURE__ */ h("div", {
91
+ ref: F,
92
+ children: [G, B && /* @__PURE__ */ m("div", {
93
+ ref: I,
94
+ id: R,
95
+ role: "dialog",
96
+ tabIndex: -1,
97
+ className: l(u.popover, u[b ? k : y], C?.popover),
98
+ style: b ? {
99
+ "--crk-popover-shift-x": `${j}px`,
100
+ "--crk-popover-shift-y": `${N}px`
101
+ } : void 0,
102
+ children: /* @__PURE__ */ m(f, {
103
+ value: W,
104
+ children: v
105
+ })
106
+ })]
107
+ })
108
+ });
109
+ });
110
+ _.displayName = "Popover";
111
+ export { _ as Popover };
@@ -1,21 +1,12 @@
1
- const o = "crk-root-8H-L9", t = "crk-trigger-Zn1nQ", r = "crk-popover-rvS3X", e = "crk-popoverFade-hj41M", c = "crk-bottom-lawQw", p = "crk-top-rqvC6", s = "crk-left-J6exv", n = "crk-right-3y20l", g = {
2
- root: o,
3
- trigger: t,
4
- popover: r,
5
- popoverFade: e,
6
- bottom: c,
7
- top: p,
8
- left: s,
9
- right: n
10
- };
11
- export {
12
- c as bottom,
13
- g as default,
14
- s as left,
15
- r as popover,
16
- e as popoverFade,
17
- n as right,
18
- o as root,
19
- p as top,
20
- t as trigger
1
+ // src/components/Popover/Popover.module.scss
2
+ var e = "crk-root-8H-L9", t = "crk-trigger-Zn1nQ", n = "crk-popover-rvS3X", r = "crk-popoverFade-hj41M", i = "crk-bottom-lawQw", a = "crk-top-rqvC6", o = "crk-left-J6exv", s = "crk-right-3y20l", c = {
3
+ root: e,
4
+ trigger: t,
5
+ popover: n,
6
+ popoverFade: r,
7
+ bottom: i,
8
+ top: a,
9
+ left: o,
10
+ right: s
21
11
  };
12
+ export { i as bottom, c as default, o as left, n as popover, r as popoverFade, s as right, e as root, a as top, t as trigger };
@@ -1,4 +1,4 @@
1
- import { ComponentPropsWithRef, ReactNode } from 'react';
1
+ import { ComponentPropsWithRef, MouseEvent, ReactNode } from 'react';
2
2
  export type ProgressBarVariant = 'primary' | 'success' | 'warning' | 'danger' | 'neutral';
3
3
  export interface ProgressBarThreshold {
4
4
  /** Lower bound (inclusive) from which `variant` applies. */
@@ -58,6 +58,19 @@ export interface ProgressBarProps extends Omit<ComponentPropsWithRef<'div'>, 'ch
58
58
  * at the top of a survey/wizard page. @default 'rounded'
59
59
  */
60
60
  shape?: 'rounded' | 'square';
61
+ /**
62
+ * Segmented mode only. Makes every segment a clickable, keyboard-focusable
63
+ * button and calls back with its zero-based index — jump-to-step in a
64
+ * wizard/survey. The track switches from `role="progressbar"` to a
65
+ * `role="group"` of buttons (progressbar children are presentational, so
66
+ * screen readers would otherwise skip them).
67
+ */
68
+ onSegmentClick?: (index: number, event: MouseEvent<HTMLButtonElement>) => void;
69
+ /**
70
+ * Accessible name for each clickable segment (`onSegmentClick` only).
71
+ * @default (index, segments) => `Step ${index + 1} of ${segments}`
72
+ */
73
+ segmentLabel?: (index: number, segments: number) => string;
61
74
  /** Override class names on internal elements. */
62
75
  classes?: Partial<ProgressBarClasses>;
63
76
  }
@@ -70,5 +83,6 @@ export interface ProgressBarProps extends Omit<ComponentPropsWithRef<'div'>, 'ch
70
83
  * <ProgressBar value={level} thresholds={[{ value: 0, variant: 'danger' }, { value: 20, variant: 'warning' }, { value: 50, variant: 'success' }]} />
71
84
  * <ProgressBar value={2} max={5} segments={5} size="lg" />
72
85
  * <ProgressBar value={2} max={4} segments={4} showCurrent shape="square" aria-label="Step 3 of 4" />
86
+ * <ProgressBar value={done} max={4} segments={4} showCurrent onSegmentClick={(i) => goToStep(i)} />
73
87
  */
74
88
  export declare const ProgressBar: import('react').ForwardRefExoticComponent<Omit<ProgressBarProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
@@ -1,90 +1,57 @@
1
- import { jsxs as M, jsx as m } from "react/jsx-runtime";
2
- import { forwardRef as R, useMemo as V } from "react";
1
+ import { forwardRef as e, useMemo as t } from "react";
3
2
  import n from "clsx";
4
- import e from "./ProgressBar.module.scss.js";
5
- const _ = (o, s) => `${Math.round(o / s * 100)}%`, z = R(
6
- ({
7
- value: o,
8
- max: s = 100,
9
- label: l,
10
- showValue: h = !1,
11
- formatValue: k = _,
12
- size: w = "md",
13
- variant: v = "primary",
14
- thresholds: g,
15
- segments: i,
16
- showCurrent: F = !1,
17
- shape: j = "rounded",
18
- classes: r,
19
- className: q,
20
- style: B,
21
- "aria-label": C,
22
- "aria-labelledby": P,
23
- ...S
24
- }, $) => {
25
- const c = s > 0 ? s : 100, a = o === void 0 || Number.isNaN(o), d = a ? 0 : Math.min(c, Math.max(0, o)), N = d / c, A = V(() => {
26
- if (a || !g?.length) return v;
27
- const x = [...g].sort((p, L) => p.value - L.value);
28
- let t = v;
29
- for (const p of x)
30
- p.value <= d && (t = p.variant);
31
- return t;
32
- }, [a, g, v, d]), u = !a && typeof i == "number" && i > 1, f = u ? Math.round(N * i) : 0, y = u && F && f < i ? f : -1, b = l != null && l !== !1, H = b || h && !a;
33
- return /* @__PURE__ */ M(
34
- "div",
35
- {
36
- ref: $,
37
- className: n(e.root, e[w], e[A], j === "square" && e.square, r?.root, q),
38
- style: B,
39
- ...S,
40
- children: [
41
- H && /* @__PURE__ */ M("div", { className: n(e.header, r?.header), children: [
42
- b && /* @__PURE__ */ m("span", { className: n(e.label, r?.label), children: l }),
43
- h && !a && /* @__PURE__ */ m("span", { className: n(e.value, r?.value), children: k(d, c) })
44
- ] }),
45
- /* @__PURE__ */ m(
46
- "div",
47
- {
48
- role: "progressbar",
49
- "aria-valuemin": 0,
50
- "aria-valuemax": c,
51
- "aria-valuenow": a ? void 0 : d,
52
- "aria-label": C ?? (typeof l == "string" ? l : void 0),
53
- "aria-labelledby": P,
54
- className: n(
55
- e.track,
56
- a && e.indeterminate,
57
- u && e.segmented,
58
- r?.track
59
- ),
60
- children: u ? Array.from({ length: i }, (x, t) => /* @__PURE__ */ m(
61
- "span",
62
- {
63
- className: n(
64
- e.segment,
65
- t < f && e.segmentFilled,
66
- t === y && e.segmentCurrent,
67
- r?.segment,
68
- t < f && r?.segmentFilled,
69
- t === y && r?.segmentCurrent
70
- )
71
- },
72
- t
73
- )) : /* @__PURE__ */ m(
74
- "span",
75
- {
76
- className: n(e.fill, r?.fill),
77
- style: a ? void 0 : { width: `${N * 100}%` }
78
- }
79
- )
80
- }
81
- )
82
- ]
83
- }
84
- );
85
- }
86
- );
87
- z.displayName = "ProgressBar";
88
- export {
89
- z as ProgressBar
90
- };
3
+ import r from "./ProgressBar.module.scss.js";
4
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
5
+ // src/components/ProgressBar/ProgressBar.tsx
6
+ var o = (e, t) => `${Math.round(e / t * 100)}%`, s = (e, t) => `Step ${e + 1} of ${t}`, c = e(({ value: e, max: c = 100, label: l, showValue: u = !1, formatValue: d = o, size: f = "md", variant: p = "primary", thresholds: m, segments: h, showCurrent: g = !1, shape: _ = "rounded", onSegmentClick: v, segmentLabel: y = s, classes: b, className: x, style: S, "aria-label": C, "aria-labelledby": w, ...T }, E) => {
7
+ let D = c > 0 ? c : 100, O = e === void 0 || Number.isNaN(e), k = O ? 0 : Math.min(D, Math.max(0, e)), A = k / D, j = t(() => {
8
+ if (O || !m?.length) return p;
9
+ let e = [...m].sort((e, t) => e.value - t.value), t = p;
10
+ for (let n of e) n.value <= k && (t = n.variant);
11
+ return t;
12
+ }, [
13
+ O,
14
+ m,
15
+ p,
16
+ k
17
+ ]), M = !O && typeof h == "number" && h > 1, N = M ? Math.round(A * h) : 0, P = M && g && N < h ? N : -1, F = M && typeof v == "function", I = l != null && l !== !1, L = I || u && !O;
18
+ return /* @__PURE__ */ a("div", {
19
+ ref: E,
20
+ className: n(r.root, r[f], r[j], _ === "square" && r.square, b?.root, x),
21
+ style: S,
22
+ ...T,
23
+ children: [L && /* @__PURE__ */ a("div", {
24
+ className: n(r.header, b?.header),
25
+ children: [I && /* @__PURE__ */ i("span", {
26
+ className: n(r.label, b?.label),
27
+ children: l
28
+ }), u && !O && /* @__PURE__ */ i("span", {
29
+ className: n(r.value, b?.value),
30
+ children: d(k, D)
31
+ })]
32
+ }), /* @__PURE__ */ i("div", {
33
+ role: F ? "group" : "progressbar",
34
+ "aria-valuemin": F ? void 0 : 0,
35
+ "aria-valuemax": F ? void 0 : D,
36
+ "aria-valuenow": F || O ? void 0 : k,
37
+ "aria-label": C ?? (typeof l == "string" ? l : void 0),
38
+ "aria-labelledby": w,
39
+ className: n(r.track, O && r.indeterminate, M && r.segmented, F && r.clickable, b?.track),
40
+ children: M ? Array.from({ length: h }, (e, t) => {
41
+ let a = n(r.segment, t < N && r.segmentFilled, t === P && r.segmentCurrent, b?.segment, t < N && b?.segmentFilled, t === P && b?.segmentCurrent);
42
+ return F ? /* @__PURE__ */ i("button", {
43
+ type: "button",
44
+ className: a,
45
+ "aria-label": y(t, h),
46
+ "aria-current": t === P ? "step" : void 0,
47
+ onClick: (e) => v?.(t, e)
48
+ }, t) : /* @__PURE__ */ i("span", { className: a }, t);
49
+ }) : /* @__PURE__ */ i("span", {
50
+ className: n(r.fill, b?.fill),
51
+ style: O ? void 0 : { width: `${A * 100}%` }
52
+ })
53
+ })]
54
+ });
55
+ });
56
+ c.displayName = "ProgressBar";
57
+ export { c as ProgressBar };
@@ -1,51 +1,29 @@
1
- const r = "crk-root-OIfFA", e = "crk-sm-lcp3n", s = "crk-md-6WStK", c = "crk-lg-i8EIC", t = "crk-primary-d7Piz", n = "crk-success-cvbui", o = "crk-warning-T5lWo", l = "crk-danger-43KPI", k = "crk-neutral-8XqGp", a = "crk-header-z7QvW", g = "crk-label-hsH4C", d = "crk-value-lGO18", i = "crk-track-vjybM", m = "crk-fill-MAyGB", u = "crk-indeterminate-D4x08", p = "crk-crk-progress-slide-lJXeI", f = "crk-segmented-4U5CV", P = "crk-segment-kL8tr", v = "crk-segmentFilled-iSzPI", y = "crk-segmentCurrent-H443l", C = "crk-square-6Soi4", F = "crk-crk-progress-fade-748w-", I = {
2
- root: r,
3
- sm: e,
4
- md: s,
5
- lg: c,
6
- primary: t,
7
- success: n,
8
- warning: o,
9
- danger: l,
10
- neutral: k,
11
- header: a,
12
- label: g,
13
- value: d,
14
- track: i,
15
- fill: m,
16
- indeterminate: u,
17
- "crk-progress-slide": "crk-crk-progress-slide-lJXeI",
18
- crkProgressSlide: p,
19
- segmented: f,
20
- segment: P,
21
- segmentFilled: v,
22
- segmentCurrent: y,
23
- square: C,
24
- "crk-progress-fade": "crk-crk-progress-fade-748w-",
25
- crkProgressFade: F
26
- };
27
- export {
28
- F as crkProgressFade,
29
- p as crkProgressSlide,
30
- l as danger,
31
- I as default,
32
- m as fill,
33
- a as header,
34
- u as indeterminate,
35
- g as label,
36
- c as lg,
37
- s as md,
38
- k as neutral,
39
- t as primary,
40
- r as root,
41
- P as segment,
42
- y as segmentCurrent,
43
- v as segmentFilled,
44
- f as segmented,
45
- e as sm,
46
- C as square,
47
- n as success,
48
- i as track,
49
- d as value,
50
- o as warning
1
+ // src/components/ProgressBar/ProgressBar.module.scss
2
+ var e = "crk-root-OIfFA", t = "crk-sm-lcp3n", n = "crk-md-6WStK", r = "crk-lg-i8EIC", i = "crk-primary-d7Piz", a = "crk-success-cvbui", o = "crk-warning-T5lWo", s = "crk-danger-43KPI", c = "crk-neutral-8XqGp", l = "crk-header-z7QvW", u = "crk-label-hsH4C", d = "crk-value-lGO18", f = "crk-track-vjybM", p = "crk-fill-MAyGB", m = "crk-indeterminate-D4x08", h = "crk-crk-progress-slide-lJXeI", g = "crk-segmented-4U5CV", _ = "crk-segment-kL8tr", v = "crk-segmentFilled-iSzPI", y = "crk-segmentCurrent-H443l", b = "crk-clickable-xDN2c", x = "crk-square-6Soi4", S = "crk-crk-progress-fade-748w-", C = {
3
+ root: e,
4
+ sm: t,
5
+ md: n,
6
+ lg: r,
7
+ primary: i,
8
+ success: a,
9
+ warning: o,
10
+ danger: s,
11
+ neutral: c,
12
+ header: l,
13
+ label: u,
14
+ value: d,
15
+ track: f,
16
+ fill: p,
17
+ indeterminate: m,
18
+ "crk-progress-slide": "crk-crk-progress-slide-lJXeI",
19
+ crkProgressSlide: h,
20
+ segmented: g,
21
+ segment: _,
22
+ segmentFilled: v,
23
+ segmentCurrent: y,
24
+ clickable: b,
25
+ square: x,
26
+ "crk-progress-fade": "crk-crk-progress-fade-748w-",
27
+ crkProgressFade: S
51
28
  };
29
+ export { b as clickable, S as crkProgressFade, h as crkProgressSlide, s as danger, C as default, p as fill, l as header, m as indeterminate, u as label, r as lg, n as md, c as neutral, i as primary, e as root, _ as segment, y as segmentCurrent, v as segmentFilled, g as segmented, t as sm, x as square, a as success, f as track, d as value, o as warning };