@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,141 +1,210 @@
1
- import { useState as O, useRef as M, useCallback as i, useEffect as N, useMemo as k } from "react";
2
- const v = { scale: 1, x: 0, y: 0 }, j = 2.5, Y = 0.2;
3
- function R(c, n, o) {
4
- return Math.min(o, Math.max(n, c));
1
+ import { useCallback as e, useEffect as t, useMemo as n, useRef as r, useState as i } from "react";
2
+ // src/components/ImageViewer/useZoomPan.ts
3
+ var a = {
4
+ scale: 1,
5
+ x: 0,
6
+ y: 0
7
+ }, o = 2.5, s = .2;
8
+ function c(e, t, n) {
9
+ return Math.min(n, Math.max(t, e));
5
10
  }
6
- function q(c, n) {
7
- if (c.scale <= 1 || !n) return { scale: c.scale, x: 0, y: 0 };
8
- const o = n.w * c.scale, s = n.h * c.scale, p = -n.cx0 - o * (1 - Y), h = n.W - n.cx0 - o * Y, P = -n.cy0 - s * (1 - Y), u = n.H - n.cy0 - s * Y;
9
- return {
10
- scale: c.scale,
11
- x: R(c.x, Math.min(p, h), Math.max(p, h)),
12
- y: R(c.y, Math.min(P, u), Math.max(P, u))
13
- };
11
+ function l(e, t) {
12
+ if (e.scale <= 1 || !t) return {
13
+ scale: e.scale,
14
+ x: 0,
15
+ y: 0
16
+ };
17
+ let n = t.w * e.scale, r = t.h * e.scale, i = -t.cx0 - n * .8, a = t.W - t.cx0 - n * s, o = -t.cy0 - r * .8, l = t.H - t.cy0 - r * s;
18
+ return {
19
+ scale: e.scale,
20
+ x: c(e.x, Math.min(i, a), Math.max(i, a)),
21
+ y: c(e.y, Math.min(o, l), Math.max(o, l))
22
+ };
14
23
  }
15
- function F(c, n, o, s) {
16
- if (!s) return { ...c, scale: n };
17
- const p = (o.x - s.cx0 - c.x) / c.scale, h = (o.y - s.cy0 - c.y) / c.scale;
18
- return {
19
- scale: n,
20
- x: o.x - s.cx0 - p * n,
21
- y: o.y - s.cy0 - h * n
22
- };
24
+ function u(e, t, n, r) {
25
+ if (!r) return {
26
+ ...e,
27
+ scale: t
28
+ };
29
+ let i = (n.x - r.cx0 - e.x) / e.scale, a = (n.y - r.cy0 - e.y) / e.scale;
30
+ return {
31
+ scale: t,
32
+ x: n.x - r.cx0 - i * t,
33
+ y: n.y - r.cy0 - a * t
34
+ };
23
35
  }
24
- function J(c = {}) {
25
- const { minScale: n = 1, maxScale: o = 8, step: s = 0.5, wheel: p = !0, doubleClickToggle: h = !0, onChange: P } = c, [u, _] = O(v), [g, S] = O(!1), X = M(null), H = M(null), f = M(u);
26
- f.current = u;
27
- const A = M(P);
28
- A.current = P;
29
- const C = i(() => {
30
- const t = X.current, e = H.current;
31
- if (!t || !e) return null;
32
- const r = t.clientWidth || t.getBoundingClientRect().width, a = t.clientHeight || t.getBoundingClientRect().height, m = e.offsetWidth, W = e.offsetHeight;
33
- return !r || !a || !m || !W ? null : { W: r, H: a, w: m, h: W, cx0: (r - m) / 2, cy0: (a - W) / 2 };
34
- }, []), x = i(
35
- (t) => {
36
- const e = q(
37
- { ...t, scale: R(t.scale, n, o) },
38
- C()
39
- );
40
- f.current = e, _(e), A.current?.(e);
41
- },
42
- [C, n, o]
43
- ), b = i((t, e) => {
44
- const r = X.current;
45
- if (!r) return { x: 0, y: 0 };
46
- const a = r.getBoundingClientRect();
47
- return { x: t - a.left, y: e - a.top };
48
- }, []), l = i(
49
- (t, e) => {
50
- const r = C(), a = R(t, n, o), m = e ?? (r ? { x: r.W / 2, y: r.H / 2 } : { x: 0, y: 0 });
51
- x(F(f.current, a, m, r));
52
- },
53
- [x, C, n, o]
54
- ), $ = i(() => l(f.current.scale * (1 + s)), [l, s]), K = i(() => l(f.current.scale / (1 + s)), [l, s]), w = i(() => x(v), [x]), U = i(() => {
55
- const t = C();
56
- if (!t) return x(v);
57
- l(Math.min(t.W / t.w, t.H / t.h));
58
- }, [C, x, l]), y = M(/* @__PURE__ */ new Map()), d = M(null), I = M(null), B = i((t) => {
59
- if (t.button !== 0 && t.pointerType === "mouse") return;
60
- if (y.current.set(t.pointerId, { x: t.clientX, y: t.clientY }), t.currentTarget.setPointerCapture?.(t.pointerId), y.current.size === 2) {
61
- const [r, a] = Array.from(y.current.values());
62
- I.current = { dist: Math.hypot(r.x - a.x, r.y - a.y), scale: f.current.scale }, d.current = null, S(!1);
63
- return;
64
- }
65
- f.current.scale > 1 && (d.current = { startX: t.clientX, startY: t.clientY, originX: f.current.x, originY: f.current.y }, S(!0));
66
- }, []), E = i(
67
- (t) => {
68
- if (y.current.has(t.pointerId)) {
69
- if (y.current.set(t.pointerId, { x: t.clientX, y: t.clientY }), I.current && y.current.size >= 2) {
70
- const [e, r] = Array.from(y.current.values()), a = Math.hypot(e.x - r.x, e.y - r.y);
71
- if (I.current.dist > 0) {
72
- const m = b((e.x + r.x) / 2, (e.y + r.y) / 2);
73
- l(I.current.scale * (a / I.current.dist), m);
74
- }
75
- return;
76
- }
77
- d.current && x({
78
- scale: f.current.scale,
79
- x: d.current.originX + (t.clientX - d.current.startX),
80
- y: d.current.originY + (t.clientY - d.current.startY)
81
- });
82
- }
83
- },
84
- [x, b, l]
85
- ), z = i((t) => {
86
- y.current.delete(t.pointerId), t.currentTarget.releasePointerCapture?.(t.pointerId), y.current.size < 2 && (I.current = null), y.current.size === 0 && (d.current = null, S(!1));
87
- }, []), T = i(
88
- (t) => {
89
- if (!p) return;
90
- t.preventDefault();
91
- const e = b(t.clientX, t.clientY), r = t.ctrlKey ? Math.exp(-t.deltaY * 0.01) : t.deltaY < 0 ? 1 + s : 1 / (1 + s);
92
- l(f.current.scale * r, e);
93
- },
94
- [p, s, b, l]
95
- ), D = i(
96
- (t) => {
97
- if (!h) return;
98
- const e = b(t.clientX, t.clientY);
99
- f.current.scale > 1 ? w() : l(j, e);
100
- },
101
- [h, b, w, l]
102
- ), L = i((t) => {
103
- X.current = t;
104
- }, []);
105
- N(() => {
106
- if (!g) return;
107
- const t = document.body.style.userSelect;
108
- return document.body.style.userSelect = "none", () => {
109
- document.body.style.userSelect = t;
110
- };
111
- }, [g]);
112
- const V = k(
113
- () => ({
114
- ref: L,
115
- onWheel: T,
116
- onPointerDown: B,
117
- onPointerMove: E,
118
- onPointerUp: z,
119
- onPointerCancel: z,
120
- onDoubleClick: D,
121
- style: {
122
- cursor: u.scale > 1 ? g ? "grabbing" : "grab" : "default",
123
- touchAction: "none"
124
- }
125
- }),
126
- [L, T, B, E, z, D, u.scale, g]
127
- ), Z = k(
128
- () => ({
129
- transform: `translate(${u.x}px, ${u.y}px) scale(${u.scale})`,
130
- transformOrigin: "0 0",
131
- transition: g ? "none" : void 0
132
- }),
133
- [u.x, u.y, u.scale, g]
134
- );
135
- return { ...u, isPanning: g, stageProps: V, contentRef: H, contentStyle: Z, zoomIn: $, zoomOut: K, zoomTo: l, reset: w, fit: U };
36
+ function d(s = {}) {
37
+ let { minScale: d = 1, maxScale: f = 8, step: p = .5, wheel: m = !0, doubleClickToggle: h = !0, onChange: g } = s, [_, v] = i(a), [y, b] = i(!1), x = r(null), S = r(null), C = r(_);
38
+ C.current = _;
39
+ let w = r(g);
40
+ w.current = g;
41
+ let T = e(() => {
42
+ let e = x.current, t = S.current;
43
+ if (!e || !t) return null;
44
+ let n = e.clientWidth || e.getBoundingClientRect().width, r = e.clientHeight || e.getBoundingClientRect().height, i = t.offsetWidth, a = t.offsetHeight;
45
+ return !n || !r || !i || !a ? null : {
46
+ W: n,
47
+ H: r,
48
+ w: i,
49
+ h: a,
50
+ cx0: (n - i) / 2,
51
+ cy0: (r - a) / 2
52
+ };
53
+ }, []), E = e((e) => {
54
+ let t = l({
55
+ ...e,
56
+ scale: c(e.scale, d, f)
57
+ }, T());
58
+ C.current = t, v(t), w.current?.(t);
59
+ }, [
60
+ T,
61
+ d,
62
+ f
63
+ ]), D = e((e, t) => {
64
+ let n = x.current;
65
+ if (!n) return {
66
+ x: 0,
67
+ y: 0
68
+ };
69
+ let r = n.getBoundingClientRect();
70
+ return {
71
+ x: e - r.left,
72
+ y: t - r.top
73
+ };
74
+ }, []), O = e((e, t) => {
75
+ let n = T(), r = c(e, d, f), i = t ?? (n ? {
76
+ x: n.W / 2,
77
+ y: n.H / 2
78
+ } : {
79
+ x: 0,
80
+ y: 0
81
+ });
82
+ E(u(C.current, r, i, n));
83
+ }, [
84
+ E,
85
+ T,
86
+ d,
87
+ f
88
+ ]), k = e(() => O(C.current.scale * (1 + p)), [O, p]), A = e(() => O(C.current.scale / (1 + p)), [O, p]), j = e(() => E(a), [E]), M = e(() => {
89
+ let e = T();
90
+ if (!e) return E(a);
91
+ O(Math.min(e.W / e.w, e.H / e.h));
92
+ }, [
93
+ T,
94
+ E,
95
+ O
96
+ ]), N = r(/* @__PURE__ */ new Map()), P = r(null), F = r(null), I = e((e) => {
97
+ if (e.button === 0 || e.pointerType !== "mouse") {
98
+ if (N.current.set(e.pointerId, {
99
+ x: e.clientX,
100
+ y: e.clientY
101
+ }), e.currentTarget.setPointerCapture?.(e.pointerId), N.current.size === 2) {
102
+ let [e, t] = Array.from(N.current.values());
103
+ F.current = {
104
+ dist: Math.hypot(e.x - t.x, e.y - t.y),
105
+ scale: C.current.scale
106
+ }, P.current = null, b(!1);
107
+ } else C.current.scale > 1 && (P.current = {
108
+ startX: e.clientX,
109
+ startY: e.clientY,
110
+ originX: C.current.x,
111
+ originY: C.current.y
112
+ }, b(!0));
113
+ }
114
+ }, []), L = e((e) => {
115
+ if (N.current.has(e.pointerId)) {
116
+ if (N.current.set(e.pointerId, {
117
+ x: e.clientX,
118
+ y: e.clientY
119
+ }), F.current && N.current.size >= 2) {
120
+ let [e, t] = Array.from(N.current.values()), n = Math.hypot(e.x - t.x, e.y - t.y);
121
+ if (F.current.dist > 0) {
122
+ let r = D((e.x + t.x) / 2, (e.y + t.y) / 2);
123
+ O(F.current.scale * (n / F.current.dist), r);
124
+ }
125
+ } else P.current && E({
126
+ scale: C.current.scale,
127
+ x: P.current.originX + (e.clientX - P.current.startX),
128
+ y: P.current.originY + (e.clientY - P.current.startY)
129
+ });
130
+ }
131
+ }, [
132
+ E,
133
+ D,
134
+ O
135
+ ]), R = e((e) => {
136
+ N.current.delete(e.pointerId), e.currentTarget.releasePointerCapture?.(e.pointerId), N.current.size < 2 && (F.current = null), N.current.size === 0 && (P.current = null, b(!1));
137
+ }, []), z = e((e) => {
138
+ if (!m) return;
139
+ e.preventDefault();
140
+ let t = D(e.clientX, e.clientY), n = e.ctrlKey ? Math.exp(-e.deltaY * .01) : e.deltaY < 0 ? 1 + p : 1 / (1 + p);
141
+ O(C.current.scale * n, t);
142
+ }, [
143
+ m,
144
+ p,
145
+ D,
146
+ O
147
+ ]), B = e((e) => {
148
+ if (!h) return;
149
+ let t = D(e.clientX, e.clientY);
150
+ C.current.scale > 1 ? j() : O(o, t);
151
+ }, [
152
+ h,
153
+ D,
154
+ j,
155
+ O
156
+ ]), V = e((e) => {
157
+ x.current = e;
158
+ }, []);
159
+ t(() => {
160
+ if (!y) return;
161
+ let e = document.body.style.userSelect;
162
+ return document.body.style.userSelect = "none", () => {
163
+ document.body.style.userSelect = e;
164
+ };
165
+ }, [y]);
166
+ let H = n(() => ({
167
+ ref: V,
168
+ onWheel: z,
169
+ onPointerDown: I,
170
+ onPointerMove: L,
171
+ onPointerUp: R,
172
+ onPointerCancel: R,
173
+ onDoubleClick: B,
174
+ style: {
175
+ cursor: _.scale > 1 ? y ? "grabbing" : "grab" : "default",
176
+ touchAction: "none"
177
+ }
178
+ }), [
179
+ V,
180
+ z,
181
+ I,
182
+ L,
183
+ R,
184
+ B,
185
+ _.scale,
186
+ y
187
+ ]), U = n(() => ({
188
+ transform: `translate(${_.x}px, ${_.y}px) scale(${_.scale})`,
189
+ transformOrigin: "0 0",
190
+ transition: y ? "none" : void 0
191
+ }), [
192
+ _.x,
193
+ _.y,
194
+ _.scale,
195
+ y
196
+ ]);
197
+ return {
198
+ ..._,
199
+ isPanning: y,
200
+ stageProps: H,
201
+ contentRef: S,
202
+ contentStyle: U,
203
+ zoomIn: k,
204
+ zoomOut: A,
205
+ zoomTo: O,
206
+ reset: j,
207
+ fit: M
208
+ };
136
209
  }
137
- export {
138
- q as clampState,
139
- J as useZoomPan,
140
- F as zoomAround
141
- };
210
+ export { l as clampState, d as useZoomPan, u as zoomAround };
@@ -1,22 +1,25 @@
1
- import { jsx as t, jsxs as f } from "react/jsx-runtime";
2
- import { forwardRef as h, Fragment as b } from "react";
3
- import a from "clsx";
1
+ import { Fragment as e, forwardRef as t } from "react";
2
+ import n from "clsx";
4
3
  import r from "./Kbd.module.scss.js";
5
- const s = h(
6
- ({ size: d = "md", keys: m, classes: o, className: e, children: c, ...n }, p) => m && m.length > 0 ? /* @__PURE__ */ t(
7
- "kbd",
8
- {
9
- ref: p,
10
- className: a(r.group, r[d], o?.root, e),
11
- ...n,
12
- children: m.map((i, l) => /* @__PURE__ */ f(b, { children: [
13
- l > 0 && /* @__PURE__ */ t("span", { className: a(r.separator, o?.separator), "aria-hidden": "true", children: "+" }),
14
- /* @__PURE__ */ t("kbd", { className: a(r.root, r.key, o?.key), children: i })
15
- ] }, `${i}-${l}`))
16
- }
17
- ) : /* @__PURE__ */ t("kbd", { ref: p, className: a(r.root, r[d], o?.root, e), ...n, children: c })
18
- );
19
- s.displayName = "Kbd";
20
- export {
21
- s as Kbd
22
- };
4
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
5
+ // src/components/Kbd/Kbd.tsx
6
+ var o = t(({ size: t = "md", keys: o, classes: s, className: c, children: l, ...u }, d) => o && o.length > 0 ? /* @__PURE__ */ i("kbd", {
7
+ ref: d,
8
+ className: n(r.group, r[t], s?.root, c),
9
+ ...u,
10
+ children: o.map((t, o) => /* @__PURE__ */ a(e, { children: [o > 0 && /* @__PURE__ */ i("span", {
11
+ className: n(r.separator, s?.separator),
12
+ "aria-hidden": "true",
13
+ children: "+"
14
+ }), /* @__PURE__ */ i("kbd", {
15
+ className: n(r.root, r.key, s?.key),
16
+ children: t
17
+ })] }, `${t}-${o}`))
18
+ }) : /* @__PURE__ */ i("kbd", {
19
+ ref: d,
20
+ className: n(r.root, r[t], s?.root, c),
21
+ ...u,
22
+ children: l
23
+ }));
24
+ o.displayName = "Kbd";
25
+ export { o as Kbd };
@@ -1,17 +1,10 @@
1
- const o = "crk-root-fy7QV", r = "crk-sm-IGdQk", s = "crk-md-OswkR", t = "crk-group-a1GSn", c = "crk-key--OflV", k = "crk-separator-bVh1E", a = {
2
- root: o,
3
- sm: r,
4
- md: s,
5
- group: t,
6
- key: c,
7
- separator: k
8
- };
9
- export {
10
- a as default,
11
- t as group,
12
- c as key,
13
- s as md,
14
- o as root,
15
- k as separator,
16
- r as sm
1
+ // src/components/Kbd/Kbd.module.scss
2
+ var e = "crk-root-fy7QV", t = "crk-sm-IGdQk", n = "crk-md-OswkR", r = "crk-group-a1GSn", i = "crk-key--OflV", a = "crk-separator-bVh1E", o = {
3
+ root: e,
4
+ sm: t,
5
+ md: n,
6
+ group: r,
7
+ key: i,
8
+ separator: a
17
9
  };
10
+ export { o as default, r as group, i as key, n as md, e as root, a as separator, t as sm };