@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,165 +1,158 @@
1
- import { jsx as N } from "react/jsx-runtime";
2
- import { forwardRef as et, useRef as b, useState as L, useCallback as s, useEffect as X, useContext as nt, createContext as rt } from "react";
3
- import W from "clsx";
4
- import g from "./Draggable.module.scss.js";
5
- const q = rt(null), F = et(
6
- ({
7
- children: R,
8
- defaultPosition: C,
9
- position: p,
10
- axis: a = "both",
11
- bounds: o = "viewport",
12
- keyboardStep: m = 10,
13
- disabled: c = !1,
14
- onDragStart: Y,
15
- onDrag: z,
16
- onDragEnd: v,
17
- classes: A,
18
- className: J,
19
- style: E,
20
- ...Q
21
- }, w) => {
22
- const h = b(null), M = p !== void 0, [T, V] = L(
23
- C ?? { x: 0, y: 0 }
24
- ), x = M ? p : T, l = b(x);
25
- l.current = x;
26
- const [y, B] = L(!1), D = b(null), P = b(0), [$, K] = L(!1), Z = s(() => (P.current += 1, K(!0), () => {
27
- P.current -= 1, P.current === 0 && K(!1);
28
- }), []), _ = s(
29
- (t) => {
30
- h.current = t, typeof w == "function" ? w(t) : w && (w.current = t);
31
- },
32
- [w]
33
- ), u = s((t) => {
34
- const n = h.current?.getBoundingClientRect();
35
- return n ? { left: n.left - t.x, top: n.top - t.y, width: n.width, height: n.height } : { left: 0, top: 0, width: 0, height: 0 };
36
- }, []), d = s(
37
- (t, n, r) => {
38
- if (o === "none" || typeof window > "u") return { x: t, y: n };
39
- const e = o === "parent" && h.current?.parentElement ? h.current.parentElement.getBoundingClientRect() : { left: 0, top: 0, right: window.innerWidth, bottom: window.innerHeight }, i = e.left - r.left, H = e.right - r.width - r.left, I = e.top - r.top, U = e.bottom - r.height - r.top;
40
- return {
41
- x: Math.min(Math.max(t, Math.min(i, H)), Math.max(i, H)),
42
- y: Math.min(Math.max(n, Math.min(I, U)), Math.max(I, U))
43
- };
44
- },
45
- [o]
46
- ), f = s(
47
- (t) => {
48
- l.current = t, M || V(t), z?.(t);
49
- },
50
- [M, z]
51
- ), O = s(
52
- (t) => {
53
- if (c || t.button > 0) return;
54
- t.preventDefault();
55
- const n = l.current;
56
- D.current = {
57
- startX: t.clientX,
58
- startY: t.clientY,
59
- origin: n,
60
- base: u(n)
61
- }, B(!0), Y?.(n);
62
- },
63
- [c, u, Y]
64
- );
65
- X(() => {
66
- if (!y) return;
67
- const t = (r) => {
68
- const e = D.current;
69
- if (!e) return;
70
- const i = a === "y" ? e.origin.x : e.origin.x + (r.clientX - e.startX), H = a === "x" ? e.origin.y : e.origin.y + (r.clientY - e.startY);
71
- f(d(i, H, e.base));
72
- }, n = () => {
73
- B(!1), D.current = null, v?.(l.current);
74
- };
75
- return window.addEventListener("pointermove", t), window.addEventListener("pointerup", n), () => {
76
- window.removeEventListener("pointermove", t), window.removeEventListener("pointerup", n);
77
- };
78
- }, [y, a, d, f, v]), X(() => {
79
- if (o === "none" || typeof window > "u") return;
80
- const t = () => {
81
- if (D.current) return;
82
- const e = l.current, i = d(e.x, e.y, u(e));
83
- (i.x !== e.x || i.y !== e.y) && f(i);
84
- }, n = h.current, r = typeof ResizeObserver > "u" ? null : new ResizeObserver(t);
85
- return n && (r?.observe(n), o === "parent" && n.parentElement && r?.observe(n.parentElement)), window.addEventListener("resize", t), () => {
86
- r?.disconnect(), window.removeEventListener("resize", t);
87
- };
88
- }, [o, d, f, u]);
89
- const k = s(
90
- (t) => {
91
- if (c) return;
92
- const r = {
93
- ArrowLeft: [-m, 0],
94
- ArrowRight: [m, 0],
95
- ArrowUp: [0, -m],
96
- ArrowDown: [0, m]
97
- }[t.key];
98
- if (!r || a === "x" && r[1] !== 0 || a === "y" && r[0] !== 0) return;
99
- t.preventDefault();
100
- const e = l.current, i = d(e.x + r[0], e.y + r[1], u(e));
101
- f(i), v?.(i);
102
- },
103
- [a, d, f, c, u, m, v]
104
- ), S = {
105
- startPointerDrag: O,
106
- onHandleKeyDown: k,
107
- registerHandle: Z,
108
- handleClassName: A?.handle,
109
- disabled: c,
110
- dragging: y
111
- }, j = `translate(${x.x}px, ${x.y}px)`, tt = {
112
- ...E,
113
- transform: E?.transform ? `${j} ${E.transform}` : j
114
- };
115
- return /* @__PURE__ */ N(q.Provider, { value: S, children: /* @__PURE__ */ N(
116
- "div",
117
- {
118
- ref: _,
119
- className: W(
120
- g.root,
121
- !$ && !c && g.surfaceDraggable,
122
- y && g.dragging,
123
- A?.root,
124
- J
125
- ),
126
- style: tt,
127
- onPointerDown: $ ? void 0 : O,
128
- ...Q,
129
- children: R
130
- }
131
- ) });
132
- }
133
- );
134
- F.displayName = "Draggable";
135
- function G({ children: R, className: C, style: p, ...a }) {
136
- const o = nt(q);
137
- if (!o)
138
- throw new Error("Draggable.Handle must be rendered inside a <Draggable>.");
139
- return X(() => o.registerHandle(), [o.registerHandle]), /* @__PURE__ */ N(
140
- "div",
141
- {
142
- className: W(
143
- g.handle,
144
- o.disabled && g.handleDisabled,
145
- o.dragging && g.handleDragging,
146
- o.handleClassName,
147
- C
148
- ),
149
- style: p,
150
- role: "button",
151
- "aria-label": "Drag handle",
152
- "aria-disabled": o.disabled || void 0,
153
- tabIndex: o.disabled ? -1 : 0,
154
- onPointerDown: o.startPointerDrag,
155
- onKeyDown: o.onHandleKeyDown,
156
- ...a,
157
- children: R
158
- }
159
- );
1
+ import { createContext as e, forwardRef as t, useCallback as n, useContext as r, useEffect as i, useRef as a, useState as o } from "react";
2
+ import s from "clsx";
3
+ import c from "./Draggable.module.scss.js";
4
+ import { jsx as l } from "react/jsx-runtime";
5
+ // src/components/Draggable/Draggable.tsx
6
+ var u = e(null), d = t(({ children: e, defaultPosition: t, position: r, axis: d = "both", bounds: f = "viewport", keyboardStep: p = 10, disabled: m = !1, onDragStart: h, onDrag: g, onDragEnd: _, classes: v, className: y, style: b, ...x }, S) => {
7
+ let C = a(null), w = r !== void 0, [T, E] = o(t ?? {
8
+ x: 0,
9
+ y: 0
10
+ }), D = w ? r : T, O = a(D);
11
+ O.current = D;
12
+ let [k, A] = o(!1), j = a(null), M = a(0), [N, P] = o(!1), F = n(() => (M.current += 1, P(!0), () => {
13
+ --M.current, M.current === 0 && P(!1);
14
+ }), []), I = n((e) => {
15
+ C.current = e, typeof S == "function" ? S(e) : S && (S.current = e);
16
+ }, [S]), L = n((e) => {
17
+ let t = C.current?.getBoundingClientRect();
18
+ return t ? {
19
+ left: t.left - e.x,
20
+ top: t.top - e.y,
21
+ width: t.width,
22
+ height: t.height
23
+ } : {
24
+ left: 0,
25
+ top: 0,
26
+ width: 0,
27
+ height: 0
28
+ };
29
+ }, []), R = n((e, t, n) => {
30
+ if (f === "none" || typeof window > "u") return {
31
+ x: e,
32
+ y: t
33
+ };
34
+ let r = f === "parent" && C.current?.parentElement ? C.current.parentElement.getBoundingClientRect() : {
35
+ left: 0,
36
+ top: 0,
37
+ right: window.innerWidth,
38
+ bottom: window.innerHeight
39
+ }, i = r.left - n.left, a = r.right - n.width - n.left, o = r.top - n.top, s = r.bottom - n.height - n.top;
40
+ return {
41
+ x: Math.min(Math.max(e, Math.min(i, a)), Math.max(i, a)),
42
+ y: Math.min(Math.max(t, Math.min(o, s)), Math.max(o, s))
43
+ };
44
+ }, [f]), z = n((e) => {
45
+ O.current = e, w || E(e), g?.(e);
46
+ }, [w, g]), B = n((e) => {
47
+ if (m || e.button > 0) return;
48
+ e.preventDefault();
49
+ let t = O.current;
50
+ j.current = {
51
+ startX: e.clientX,
52
+ startY: e.clientY,
53
+ origin: t,
54
+ base: L(t)
55
+ }, A(!0), h?.(t);
56
+ }, [
57
+ m,
58
+ L,
59
+ h
60
+ ]);
61
+ i(() => {
62
+ if (!k) return;
63
+ let e = (e) => {
64
+ let t = j.current;
65
+ if (!t) return;
66
+ let n = d === "y" ? t.origin.x : t.origin.x + (e.clientX - t.startX), r = d === "x" ? t.origin.y : t.origin.y + (e.clientY - t.startY);
67
+ z(R(n, r, t.base));
68
+ }, t = () => {
69
+ A(!1), j.current = null, _?.(O.current);
70
+ };
71
+ return window.addEventListener("pointermove", e), window.addEventListener("pointerup", t), () => {
72
+ window.removeEventListener("pointermove", e), window.removeEventListener("pointerup", t);
73
+ };
74
+ }, [
75
+ k,
76
+ d,
77
+ R,
78
+ z,
79
+ _
80
+ ]), i(() => {
81
+ if (f === "none" || typeof window > "u") return;
82
+ let e = () => {
83
+ if (j.current) return;
84
+ let e = O.current, t = R(e.x, e.y, L(e));
85
+ (t.x !== e.x || t.y !== e.y) && z(t);
86
+ }, t = C.current, n = typeof ResizeObserver > "u" ? null : new ResizeObserver(e);
87
+ return t && (n?.observe(t), f === "parent" && t.parentElement && n?.observe(t.parentElement)), window.addEventListener("resize", e), () => {
88
+ n?.disconnect(), window.removeEventListener("resize", e);
89
+ };
90
+ }, [
91
+ f,
92
+ R,
93
+ z,
94
+ L
95
+ ]);
96
+ let V = {
97
+ startPointerDrag: B,
98
+ onHandleKeyDown: n((e) => {
99
+ if (m) return;
100
+ let t = {
101
+ ArrowLeft: [-p, 0],
102
+ ArrowRight: [p, 0],
103
+ ArrowUp: [0, -p],
104
+ ArrowDown: [0, p]
105
+ }[e.key];
106
+ if (!t || d === "x" && t[1] !== 0 || d === "y" && t[0] !== 0) return;
107
+ e.preventDefault();
108
+ let n = O.current, r = R(n.x + t[0], n.y + t[1], L(n));
109
+ z(r), _?.(r);
110
+ }, [
111
+ d,
112
+ R,
113
+ z,
114
+ m,
115
+ L,
116
+ p,
117
+ _
118
+ ]),
119
+ registerHandle: F,
120
+ handleClassName: v?.handle,
121
+ disabled: m,
122
+ dragging: k
123
+ }, H = `translate(${D.x}px, ${D.y}px)`, U = {
124
+ ...b,
125
+ transform: b?.transform ? `${H} ${b.transform}` : H
126
+ };
127
+ return /* @__PURE__ */ l(u.Provider, {
128
+ value: V,
129
+ children: /* @__PURE__ */ l("div", {
130
+ ref: I,
131
+ className: s(c.root, !N && !m && c.surfaceDraggable, k && c.dragging, v?.root, y),
132
+ style: U,
133
+ onPointerDown: N ? void 0 : B,
134
+ ...x,
135
+ children: e
136
+ })
137
+ });
138
+ });
139
+ d.displayName = "Draggable";
140
+ function f({ children: e, className: t, style: n, ...a }) {
141
+ let o = r(u);
142
+ if (!o) throw Error("Draggable.Handle must be rendered inside a <Draggable>.");
143
+ return i(() => o.registerHandle(), [o.registerHandle]), /* @__PURE__ */ l("div", {
144
+ className: s(c.handle, o.disabled && c.handleDisabled, o.dragging && c.handleDragging, o.handleClassName, t),
145
+ style: n,
146
+ role: "button",
147
+ "aria-label": "Drag handle",
148
+ "aria-disabled": o.disabled || void 0,
149
+ tabIndex: o.disabled ? -1 : 0,
150
+ onPointerDown: o.startPointerDrag,
151
+ onKeyDown: o.onHandleKeyDown,
152
+ ...a,
153
+ children: e
154
+ });
160
155
  }
161
- G.displayName = "Draggable.Handle";
162
- const ct = Object.assign(F, { Handle: G });
163
- export {
164
- ct as Draggable
165
- };
156
+ f.displayName = "Draggable.Handle";
157
+ var p = Object.assign(d, { Handle: f });
158
+ export { p as Draggable };
@@ -1,17 +1,10 @@
1
- const a = "crk-root-5Kdf2", g = "crk-surfaceDraggable-mIpX8", n = "crk-dragging-XtMt7", r = "crk-handle-r4nFh", e = "crk-handleDragging-FRObk", d = "crk-handleDisabled-8t94h", l = {
2
- root: a,
3
- surfaceDraggable: g,
4
- dragging: n,
5
- handle: r,
6
- handleDragging: e,
7
- handleDisabled: d
8
- };
9
- export {
10
- l as default,
11
- n as dragging,
12
- r as handle,
13
- d as handleDisabled,
14
- e as handleDragging,
15
- a as root,
16
- g as surfaceDraggable
1
+ // src/components/Draggable/Draggable.module.scss
2
+ var e = "crk-root-5Kdf2", t = "crk-surfaceDraggable-mIpX8", n = "crk-dragging-XtMt7", r = "crk-handle-r4nFh", i = "crk-handleDragging-FRObk", a = "crk-handleDisabled-8t94h", o = {
3
+ root: e,
4
+ surfaceDraggable: t,
5
+ dragging: n,
6
+ handle: r,
7
+ handleDragging: i,
8
+ handleDisabled: a
17
9
  };
10
+ export { o as default, n as dragging, r as handle, a as handleDisabled, i as handleDragging, e as root, t as surfaceDraggable };
@@ -1,129 +1,107 @@
1
- import { jsx as c, jsxs as z } from "react/jsx-runtime";
2
- import { forwardRef as q, useRef as S, useId as G, useState as u, useEffect as h, createContext as J, useContext as w } from "react";
3
- import { createPortal as K } from "react-dom";
4
- import l from "clsx";
5
- import { useFocusTrap as Q } from "../../hooks/useFocusTrap.js";
6
- import { useEscapeLayer as V, EscapeLayerProvider as X } from "../../hooks/useEscapeLayer.js";
7
- import t from "./Drawer.module.scss.js";
8
- const m = J({ classes: {}, titleId: "" }), x = ({ children: e, className: s, style: a, onClose: o }) => {
9
- const { classes: i, titleId: p } = w(m);
10
- return /* @__PURE__ */ z(
11
- "div",
12
- {
13
- className: l(t.header, o && t.headerWithClose, i.header, s),
14
- style: a,
15
- children: [
16
- /* @__PURE__ */ c("div", { id: p, className: l(t.headerTitle, i.headerTitle), children: e }),
17
- o && /* @__PURE__ */ c(
18
- "button",
19
- {
20
- type: "button",
21
- className: l(t.closeButton, i.closeButton),
22
- onClick: o,
23
- "aria-label": "Close",
24
- children: "×"
25
- }
26
- )
27
- ]
28
- }
29
- );
1
+ import { createContext as e, forwardRef as t, useContext as n, useEffect as r, useId as i, useRef as a, useState as o } from "react";
2
+ import { createPortal as s } from "react-dom";
3
+ import c from "clsx";
4
+ import { useFocusTrap as l } from "../../hooks/useFocusTrap.js";
5
+ import { EscapeLayerProvider as u, useEscapeLayer as d } from "../../hooks/useEscapeLayer.js";
6
+ import f from "./Drawer.module.scss.js";
7
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
8
+ // src/components/Drawer/Drawer.tsx
9
+ var h = e({
10
+ classes: {},
11
+ titleId: ""
12
+ }), g = ({ children: e, className: t, style: r, onClose: i }) => {
13
+ let { classes: a, titleId: o } = n(h);
14
+ return /* @__PURE__ */ m("div", {
15
+ className: c(f.header, i && f.headerWithClose, a.header, t),
16
+ style: r,
17
+ children: [/* @__PURE__ */ p("div", {
18
+ id: o,
19
+ className: c(f.headerTitle, a.headerTitle),
20
+ children: e
21
+ }), i && /* @__PURE__ */ p("button", {
22
+ type: "button",
23
+ className: c(f.closeButton, a.closeButton),
24
+ onClick: i,
25
+ "aria-label": "Close",
26
+ children: "×"
27
+ })]
28
+ });
30
29
  };
31
- x.displayName = "Drawer.Header";
32
- const R = ({ children: e, className: s, style: a }) => {
33
- const { classes: o } = w(m);
34
- return /* @__PURE__ */ c("div", { className: l(t.body, o.body, s), style: a, children: e });
30
+ g.displayName = "Drawer.Header";
31
+ var _ = ({ children: e, className: t, style: r }) => {
32
+ let { classes: i } = n(h);
33
+ return /* @__PURE__ */ p("div", {
34
+ className: c(f.body, i.body, t),
35
+ style: r,
36
+ children: e
37
+ });
35
38
  };
36
- R.displayName = "Drawer.Body";
37
- const M = ({ children: e, className: s, style: a }) => {
38
- const { classes: o } = w(m);
39
- return /* @__PURE__ */ c("div", { className: l(t.footer, o.footer, s), style: a, children: e });
40
- };
41
- M.displayName = "Drawer.Footer";
42
- const Y = 340, f = q(
43
- ({
44
- open: e,
45
- onClose: s,
46
- side: a = "right",
47
- size: o = "md",
48
- variant: i = "temporary",
49
- closeOnBackdrop: p = !0,
50
- closeOnEscape: C = !0,
51
- classes: y,
52
- className: _,
53
- style: $,
54
- children: A,
55
- "aria-label": N,
56
- "aria-labelledby": E
57
- }, n) => {
58
- const B = S(null), F = (r) => {
59
- B.current = r, typeof n == "function" ? n(r) : n && (n.current = r);
60
- }, O = G(), T = E ?? `${O}-title`, v = i === "temporary", [d, g] = u(e), [k, D] = u(!1), [I, H] = u(a), [P, j] = u(o);
61
- h(() => {
62
- e && (g(!0), D(!1), H(a), j(o));
63
- }, [e, a, o]), h(() => {
64
- if (e || !d) return;
65
- D(!0);
66
- const r = setTimeout(() => g(!1), Y);
67
- return () => clearTimeout(r);
68
- }, [e, d]), Q(B, d && e && v);
69
- const L = V(() => {
70
- C && s();
71
- }, e);
72
- h(() => {
73
- if (!d) return;
74
- const r = document.body.style.overflow;
75
- return document.body.style.overflow = "hidden", () => {
76
- document.body.style.overflow = r;
77
- };
78
- }, [d]);
79
- const b = S(!1), U = (r) => {
80
- b.current = r.target === r.currentTarget;
81
- }, W = (r) => {
82
- p && b.current && r.target === r.currentTarget && s(), b.current = !1;
83
- };
84
- return d ? K(
85
- /* @__PURE__ */ c(
86
- "div",
87
- {
88
- className: l(
89
- t.backdrop,
90
- k && t.backdropClosing,
91
- !v && t.backdropBare,
92
- y?.backdrop
93
- ),
94
- onMouseDown: U,
95
- onMouseUp: W,
96
- role: "presentation",
97
- children: /* @__PURE__ */ c(
98
- "div",
99
- {
100
- ref: F,
101
- className: l(
102
- t.drawer,
103
- t[`side_${I}`],
104
- t[`size_${P}`],
105
- t[`${k ? "slideOut" : "slideIn"}_${I}`],
106
- y?.drawer,
107
- _
108
- ),
109
- style: $,
110
- role: "dialog",
111
- "aria-modal": v ? "true" : void 0,
112
- "aria-label": N,
113
- "aria-labelledby": N ? void 0 : T,
114
- children: /* @__PURE__ */ c(m.Provider, { value: { classes: y ?? {}, titleId: T }, children: /* @__PURE__ */ c(X, { value: L, children: A }) })
115
- }
116
- )
117
- }
118
- ),
119
- document.body
120
- ) : null;
121
- }
122
- );
123
- f.displayName = "Drawer";
124
- f.Header = x;
125
- f.Body = R;
126
- f.Footer = M;
127
- export {
128
- f as Drawer
39
+ _.displayName = "Drawer.Body";
40
+ var v = ({ children: e, className: t, style: r }) => {
41
+ let { classes: i } = n(h);
42
+ return /* @__PURE__ */ p("div", {
43
+ className: c(f.footer, i.footer, t),
44
+ style: r,
45
+ children: e
46
+ });
129
47
  };
48
+ v.displayName = "Drawer.Footer";
49
+ var y = 340, b = t(({ open: e, onClose: t, side: n = "right", size: m = "md", variant: g = "temporary", closeOnBackdrop: _ = !0, closeOnEscape: v = !0, classes: b, className: x, style: S, children: C, "aria-label": w, "aria-labelledby": T }, E) => {
50
+ let D = a(null), O = (e) => {
51
+ D.current = e, typeof E == "function" ? E(e) : E && (E.current = e);
52
+ }, k = i(), A = T ?? `${k}-title`, j = g === "temporary", [M, N] = o(e), [P, F] = o(!1), [I, L] = o(n), [R, z] = o(m);
53
+ r(() => {
54
+ e && (N(!0), F(!1), L(n), z(m));
55
+ }, [
56
+ e,
57
+ n,
58
+ m
59
+ ]), r(() => {
60
+ if (e || !M) return;
61
+ F(!0);
62
+ let t = setTimeout(() => N(!1), y);
63
+ return () => clearTimeout(t);
64
+ }, [e, M]), l(D, M && e && j);
65
+ let B = d(() => {
66
+ v && t();
67
+ }, e);
68
+ r(() => {
69
+ if (!M) return;
70
+ let e = document.body.style.overflow;
71
+ return document.body.style.overflow = "hidden", () => {
72
+ document.body.style.overflow = e;
73
+ };
74
+ }, [M]);
75
+ let V = a(!1);
76
+ return M ? s(/* @__PURE__ */ p("div", {
77
+ className: c(f.backdrop, P && f.backdropClosing, !j && f.backdropBare, b?.backdrop),
78
+ onMouseDown: (e) => {
79
+ V.current = e.target === e.currentTarget;
80
+ },
81
+ onMouseUp: (e) => {
82
+ _ && V.current && e.target === e.currentTarget && t(), V.current = !1;
83
+ },
84
+ role: "presentation",
85
+ children: /* @__PURE__ */ p("div", {
86
+ ref: O,
87
+ className: c(f.drawer, f[`side_${I}`], f[`size_${R}`], f[`${P ? "slideOut" : "slideIn"}_${I}`], b?.drawer, x),
88
+ style: S,
89
+ role: "dialog",
90
+ "aria-modal": j ? "true" : void 0,
91
+ "aria-label": w,
92
+ "aria-labelledby": w ? void 0 : A,
93
+ children: /* @__PURE__ */ p(h.Provider, {
94
+ value: {
95
+ classes: b ?? {},
96
+ titleId: A
97
+ },
98
+ children: /* @__PURE__ */ p(u, {
99
+ value: B,
100
+ children: C
101
+ })
102
+ })
103
+ })
104
+ }), document.body) : null;
105
+ });
106
+ b.displayName = "Drawer", b.Header = g, b.Body = _, b.Footer = v;
107
+ export { b as Drawer };