@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.
- package/AGENTS.md +2 -1
- package/CHANGELOG.md +41 -0
- package/components/Accordion/Accordion.js +160 -177
- package/components/Accordion/Accordion.module.scss.js +19 -35
- package/components/ActionButton/ActionButton.js +155 -209
- package/components/ActionButton/ActionButton.module.scss.js +24 -46
- package/components/ActionButton/CopyButton.js +52 -64
- package/components/Alert/Alert.js +93 -96
- package/components/Alert/Alert.module.scss.js +17 -32
- package/components/Avatar/Avatar.js +44 -55
- package/components/Avatar/Avatar.module.scss.js +22 -42
- package/components/Badge/Badge.js +15 -37
- package/components/Badge/Badge.module.scss.js +16 -30
- package/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/components/Breadcrumbs/Breadcrumbs.js +52 -48
- package/components/Breadcrumbs/Breadcrumbs.module.scss.js +9 -16
- package/components/Button/Button.js +35 -57
- package/components/Button/Button.module.scss.js +24 -46
- package/components/Card/Card.js +94 -131
- package/components/Card/Card.module.scss.js +34 -59
- package/components/Chart/AreaChart.d.ts +1 -1
- package/components/Chart/AreaChart.js +248 -249
- package/components/Chart/Axis.d.ts +2 -2
- package/components/Chart/Axis.js +34 -43
- package/components/Chart/BarChart.d.ts +1 -1
- package/components/Chart/BarChart.js +307 -348
- package/components/Chart/Chart.module.scss.js +31 -60
- package/components/Chart/ChartContainer.js +33 -41
- package/components/Chart/ChartLegend.d.ts +1 -1
- package/components/Chart/ChartLegend.js +31 -30
- package/components/Chart/ChartTooltip.d.ts +1 -1
- package/components/Chart/ChartTooltip.js +45 -40
- package/components/Chart/LineChart.d.ts +1 -1
- package/components/Chart/LineChart.js +220 -232
- package/components/Chart/PieChart.d.ts +1 -1
- package/components/Chart/PieChart.js +224 -240
- package/components/Chart/RadarChart.d.ts +1 -1
- package/components/Chart/RadarChart.js +166 -215
- package/components/Chart/Sparkline.js +73 -68
- package/components/Chart/TradingChart.d.ts +1 -1
- package/components/Chart/TradingChart.js +804 -701
- package/components/Chart/scales.js +28 -35
- package/components/Chart/trading/indicators.js +61 -62
- package/components/Chart/trading/period.js +46 -68
- package/components/Chart/useChartDimensions.js +30 -22
- package/components/Chip/Chip.js +98 -141
- package/components/Chip/Chip.module.scss.js +31 -58
- package/components/CodeBlock/CodeBlock.js +111 -119
- package/components/CodeBlock/CodeBlock.module.scss.js +22 -42
- package/components/CommandPalette/CommandPalette.js +387 -392
- package/components/CommandPalette/CommandPalette.module.scss.js +27 -48
- package/components/ConfirmDialog/ConfirmDialog.d.ts +1 -1
- package/components/ConfirmDialog/ConfirmDialog.js +184 -199
- package/components/ConfirmDialog/ConfirmDialog.module.scss.js +11 -20
- package/components/Divider/Divider.js +25 -36
- package/components/Divider/Divider.module.scss.js +16 -30
- package/components/Draggable/Draggable.d.ts +1 -1
- package/components/Draggable/Draggable.js +157 -164
- package/components/Draggable/Draggable.module.scss.js +9 -16
- package/components/Drawer/Drawer.js +104 -126
- package/components/Drawer/Drawer.module.scss.js +65 -118
- package/components/Dropdown/Dropdown.js +175 -234
- package/components/Dropdown/Dropdown.module.scss.js +28 -52
- package/components/Dropdown/DropdownItem.js +55 -58
- package/components/Dropdown/DropdownLabel.js +14 -11
- package/components/Dropdown/DropdownSeparator.js +13 -11
- package/components/Dropdown/dropdownContext.js +4 -5
- package/components/Dropdown/useContextMenu.js +27 -17
- package/components/Dropzone/Dropzone.js +99 -105
- package/components/Dropzone/Dropzone.module.scss.js +11 -20
- package/components/EmptyState/EmptyState.js +57 -54
- package/components/EmptyState/EmptyState.module.scss.js +13 -24
- package/components/Form/Form.d.ts +1 -1
- package/components/Form/Form.js +31 -34
- package/components/Form/Form.module.scss.js +15 -28
- package/components/Form/FormField.d.ts +1 -1
- package/components/Form/FormField.js +71 -75
- package/components/Form/FormRow.d.ts +1 -1
- package/components/Form/FormRow.js +11 -8
- package/components/Form/formFieldDefaults.js +4 -5
- package/components/ImageViewer/ImageViewer.js +312 -201
- package/components/ImageViewer/ImageViewer.module.scss.js +25 -46
- package/components/ImageViewer/useZoomPan.js +206 -137
- package/components/Kbd/Kbd.js +24 -21
- package/components/Kbd/Kbd.module.scss.js +9 -16
- package/components/KeyValueList/KeyValueList.js +119 -123
- package/components/KeyValueList/KeyValueList.module.scss.js +22 -42
- package/components/Link/Link.js +45 -59
- package/components/Link/Link.module.scss.js +9 -15
- package/components/List/List.js +22 -46
- package/components/List/List.module.scss.js +11 -20
- package/components/Loader/Loader.js +152 -182
- package/components/Loader/Loader.module.scss.js +39 -69
- package/components/Modal/Modal.js +93 -105
- package/components/Modal/Modal.module.scss.js +17 -32
- package/components/PageHeader/PageHeader.js +79 -73
- package/components/PageHeader/PageHeader.module.scss.js +22 -42
- package/components/Pagination/Pagination.js +62 -83
- package/components/Pagination/Pagination.module.scss.js +12 -22
- package/components/Pagination/paginationRange.js +15 -22
- package/components/Popover/Popover.js +110 -134
- package/components/Popover/Popover.module.scss.js +11 -20
- package/components/ProgressBar/ProgressBar.d.ts +15 -1
- package/components/ProgressBar/ProgressBar.js +56 -89
- package/components/ProgressBar/ProgressBar.module.scss.js +28 -50
- package/components/RelativeTime/RelativeTime.js +36 -43
- package/components/RelativeTime/RelativeTime.module.scss.js +3 -7
- package/components/SegmentedControl/SegmentedControl.js +93 -129
- package/components/SegmentedControl/SegmentedControl.module.scss.js +20 -38
- package/components/Skeleton/Skeleton.js +36 -50
- package/components/Skeleton/Skeleton.module.scss.js +14 -24
- package/components/Spinner/Spinner.js +25 -25
- package/components/Spinner/Spinner.module.scss.js +11 -19
- package/components/SplitButton/SplitButton.js +149 -196
- package/components/SplitButton/SplitButton.module.scss.js +30 -56
- package/components/SplitPane/SplitPane.js +134 -170
- package/components/SplitPane/SplitPane.module.scss.js +13 -24
- package/components/StatCard/StatCard.js +132 -125
- package/components/StatCard/StatCard.module.scss.js +41 -71
- package/components/StatusDot/StatusDot.js +28 -39
- package/components/StatusDot/StatusDot.module.scss.js +17 -31
- package/components/Table/Table.d.ts +1 -1
- package/components/Table/Table.js +381 -451
- package/components/Table/Table.module.scss.js +41 -80
- package/components/Table/useTableSort.js +51 -42
- package/components/Tabs/Tabs.js +109 -161
- package/components/Tabs/Tabs.module.scss.js +27 -52
- package/components/ThemeToggle/ThemeToggle.js +122 -98
- package/components/ThemeToggle/ThemeToggle.module.scss.js +12 -22
- package/components/Timeline/GanttTimeline.js +357 -318
- package/components/Timeline/GanttTimeline.module.scss.js +28 -54
- package/components/Timeline/HistoryTimeline.js +486 -450
- package/components/Timeline/HistoryTimeline.module.scss.js +30 -58
- package/components/Timeline/Timeline.module.scss.js +75 -140
- package/components/Timeline/TimelineShared.d.ts +7 -7
- package/components/Timeline/TimelineShared.js +288 -279
- package/components/Timeline/TraceEventDetails.d.ts +3 -3
- package/components/Timeline/TraceEventDetails.js +244 -177
- package/components/Timeline/TraceTimeline.js +823 -783
- package/components/Timeline/TraceTimeline.module.scss.js +97 -188
- package/components/Timeline/historyLayout.js +336 -263
- package/components/Timeline/timelineCore.js +208 -183
- package/components/Timeline/traceEvent.js +59 -61
- package/components/Timeline/traceLayout.js +101 -90
- package/components/Timeline/useTimeline.js +76 -79
- package/components/Timer/Timer.js +190 -156
- package/components/Timer/Timer.module.scss.js +28 -54
- package/components/Toast/Toast.d.ts +1 -1
- package/components/Toast/Toast.js +128 -128
- package/components/Toast/Toast.module.scss.js +36 -61
- package/components/Toast/toastStore.js +58 -62
- package/components/ToggleIconButton/ToggleIconButton.js +36 -58
- package/components/ToggleIconButton/ToggleIconButton.module.scss.js +14 -26
- package/components/Tooltip/Tooltip.d.ts +1 -1
- package/components/Tooltip/Tooltip.js +76 -85
- package/components/Tooltip/Tooltip.module.scss.js +16 -29
- package/components/Typography/Typography.js +10 -35
- package/components/Typography/Typography.module.scss.js +29 -52
- package/components/inputs/Checkbox/Checkbox.js +27 -51
- package/components/inputs/Checkbox/Checkbox.module.scss.js +9 -16
- package/components/inputs/Checkbox/CheckboxGroup.js +53 -111
- package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +16 -30
- package/components/inputs/DatePicker/CalendarPanel.d.ts +1 -1
- package/components/inputs/DatePicker/CalendarPanel.js +263 -286
- package/components/inputs/DatePicker/CalendarPanel.module.scss.js +22 -40
- package/components/inputs/DatePicker/DatePicker.js +115 -142
- package/components/inputs/DatePicker/DatePicker.module.scss.js +13 -24
- package/components/inputs/DatePicker/dateUtils.js +32 -41
- package/components/inputs/DateTimePicker/DateTimePicker.js +226 -232
- package/components/inputs/DateTimePicker/DateTimePicker.module.scss.js +19 -36
- package/components/inputs/DateTimePicker/DateTimeSegments.js +273 -252
- package/components/inputs/DateTimePicker/TimeField.d.ts +1 -1
- package/components/inputs/DateTimePicker/TimeField.js +131 -132
- package/components/inputs/DateTimePicker/timeZoneUtils.js +95 -92
- package/components/inputs/Input/Input.js +98 -109
- package/components/inputs/Input/Input.module.scss.js +14 -26
- package/components/inputs/NumberInput/NumberInput.js +112 -132
- package/components/inputs/NumberInput/NumberInput.module.scss.js +13 -24
- package/components/inputs/Radio/Radio.js +50 -73
- package/components/inputs/Radio/Radio.module.scss.js +8 -14
- package/components/inputs/SearchInput/SearchInput.js +98 -115
- package/components/inputs/SearchInput/SearchInput.module.scss.js +7 -12
- package/components/inputs/Select/Select.d.ts +55 -3
- package/components/inputs/Select/Select.js +696 -682
- package/components/inputs/Select/Select.module.scss.js +49 -72
- package/components/inputs/Slider/Slider.js +97 -128
- package/components/inputs/Slider/Slider.module.scss.js +8 -14
- package/components/inputs/Switch/Switch.js +11 -8
- package/components/inputs/Textarea/Textarea.js +42 -58
- package/components/inputs/Textarea/Textarea.module.scss.js +13 -24
- package/hooks/useClickOutside.js +17 -14
- package/hooks/useDebouncedValue.js +13 -14
- package/hooks/useElementSize.js +27 -22
- package/hooks/useEscapeLayer.js +28 -29
- package/hooks/useFocusTrap.js +27 -38
- package/hooks/useKeyboard.js +76 -64
- package/hooks/useMediaQuery.js +10 -15
- package/hooks/useNow.js +28 -33
- package/hooks/usePersistedState.js +98 -94
- package/hooks/usePortalPosition.d.ts +2 -1
- package/hooks/usePortalPosition.js +28 -19
- package/hooks/useResizable.js +106 -104
- package/hooks/useTheme.js +28 -23
- package/index.css +2 -1
- package/index.js +96 -214
- package/index.layered.css +2 -3
- package/llms.txt +28 -4
- package/manifest.json +41 -4
- package/package.json +1 -1
- package/utils/formatBytes.js +29 -13
- package/utils/themeScript.js +6 -8
- package/utils/timeAgo.js +59 -32
|
@@ -1,201 +1,312 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
1
|
+
import { forwardRef as e, useCallback as t, useEffect as n, useId as r, useRef as i, useState as a } from "react";
|
|
2
|
+
import { createPortal as ee } from "react-dom";
|
|
3
|
+
import o from "clsx";
|
|
4
|
+
import s from "./ImageViewer.module.scss.js";
|
|
5
|
+
import { useFocusTrap as te } from "../../hooks/useFocusTrap.js";
|
|
6
|
+
import { EscapeLayerProvider as c, useEscapeLayer as l } from "../../hooks/useEscapeLayer.js";
|
|
7
|
+
import { useKeyboard as u } from "../../hooks/useKeyboard.js";
|
|
8
|
+
import { Spinner as d } from "../Spinner/Spinner.js";
|
|
9
|
+
import { useZoomPan as ne } from "./useZoomPan.js";
|
|
10
|
+
import { Fragment as re, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
11
|
+
// src/components/ImageViewer/ImageViewer.tsx
|
|
12
|
+
var m = {
|
|
13
|
+
viewer: "Image viewer",
|
|
14
|
+
close: "Close",
|
|
15
|
+
previous: "Previous image",
|
|
16
|
+
next: "Next image",
|
|
17
|
+
zoomIn: "Zoom in",
|
|
18
|
+
zoomOut: "Zoom out",
|
|
19
|
+
reset: "Reset zoom",
|
|
20
|
+
fit: "Fit to screen",
|
|
21
|
+
download: "Download",
|
|
22
|
+
loading: "Loading image"
|
|
23
|
+
}, h = 60, g = () => /* @__PURE__ */ f("svg", {
|
|
24
|
+
viewBox: "0 0 20 20",
|
|
25
|
+
fill: "none",
|
|
26
|
+
stroke: "currentColor",
|
|
27
|
+
strokeWidth: "2",
|
|
28
|
+
strokeLinecap: "round",
|
|
29
|
+
"aria-hidden": "true",
|
|
30
|
+
children: /* @__PURE__ */ f("path", { d: "M5 5l10 10M15 5L5 15" })
|
|
31
|
+
}), _ = ({ dir: e }) => /* @__PURE__ */ f("svg", {
|
|
32
|
+
viewBox: "0 0 20 20",
|
|
33
|
+
fill: "none",
|
|
34
|
+
stroke: "currentColor",
|
|
35
|
+
strokeWidth: "2",
|
|
36
|
+
strokeLinecap: "round",
|
|
37
|
+
strokeLinejoin: "round",
|
|
38
|
+
"aria-hidden": "true",
|
|
39
|
+
children: e === "left" ? /* @__PURE__ */ f("path", { d: "M12.5 4.5L7 10l5.5 5.5" }) : /* @__PURE__ */ f("path", { d: "M7.5 4.5L13 10l-5.5 5.5" })
|
|
40
|
+
}), v = () => /* @__PURE__ */ f("svg", {
|
|
41
|
+
viewBox: "0 0 20 20",
|
|
42
|
+
fill: "none",
|
|
43
|
+
stroke: "currentColor",
|
|
44
|
+
strokeWidth: "1.8",
|
|
45
|
+
strokeLinecap: "round",
|
|
46
|
+
strokeLinejoin: "round",
|
|
47
|
+
"aria-hidden": "true",
|
|
48
|
+
children: /* @__PURE__ */ f("path", { d: "M10 3v10m0 0l-4-4m4 4l4-4M4 16h12" })
|
|
49
|
+
}), y = () => /* @__PURE__ */ f("svg", {
|
|
50
|
+
viewBox: "0 0 20 20",
|
|
51
|
+
fill: "none",
|
|
52
|
+
stroke: "currentColor",
|
|
53
|
+
strokeWidth: "1.8",
|
|
54
|
+
strokeLinecap: "round",
|
|
55
|
+
strokeLinejoin: "round",
|
|
56
|
+
"aria-hidden": "true",
|
|
57
|
+
children: /* @__PURE__ */ f("path", { d: "M4 10a6 6 0 1 1 1.8 4.3M4 15v-4h4" })
|
|
58
|
+
}), b = () => /* @__PURE__ */ f("svg", {
|
|
59
|
+
viewBox: "0 0 20 20",
|
|
60
|
+
fill: "none",
|
|
61
|
+
stroke: "currentColor",
|
|
62
|
+
strokeWidth: "1.8",
|
|
63
|
+
strokeLinecap: "round",
|
|
64
|
+
strokeLinejoin: "round",
|
|
65
|
+
"aria-hidden": "true",
|
|
66
|
+
children: /* @__PURE__ */ f("path", { d: "M3 8V3h5M12 3h5v5M17 12v5h-5M8 17H3v-5" })
|
|
67
|
+
}), x = e(({ open: e, onClose: x, items: S, index: C, defaultIndex: ie = 0, onIndexChange: w, loop: T = !0, showCounter: ae = !0, showThumbnails: oe = !1, showZoomControls: se = !0, showDownload: ce, renderSlide: E, closeOnBackdrop: le = !0, zoom: ue, labels: de, classes: D, className: O, style: k }, A) => {
|
|
68
|
+
let j = {
|
|
69
|
+
...m,
|
|
70
|
+
...de
|
|
71
|
+
}, M = S.length, N = C !== void 0, [P, F] = a(ie), I = M === 0 ? 0 : Math.min(Math.max(0, N ? C : P), M - 1), L = S[I], R = i(null), z = (e) => {
|
|
72
|
+
R.current = e, typeof A == "function" ? A(e) : A && (A.current = e);
|
|
73
|
+
}, B = ne(ue), { reset: V, scale: H, isPanning: fe } = B, U = t((e) => {
|
|
74
|
+
if (M === 0) return;
|
|
75
|
+
let t = e;
|
|
76
|
+
t = T ? (e % M + M) % M : Math.min(Math.max(0, e), M - 1), t !== I && (N || F(t), w?.(t));
|
|
77
|
+
}, [
|
|
78
|
+
M,
|
|
79
|
+
T,
|
|
80
|
+
I,
|
|
81
|
+
N,
|
|
82
|
+
w
|
|
83
|
+
]), W = T ? M > 1 : I > 0, G = T ? M > 1 : I < M - 1, K = t(() => W && U(I - 1), [
|
|
84
|
+
W,
|
|
85
|
+
U,
|
|
86
|
+
I
|
|
87
|
+
]), q = t(() => G && U(I + 1), [
|
|
88
|
+
G,
|
|
89
|
+
U,
|
|
90
|
+
I
|
|
91
|
+
]), [J, Y] = a(!1);
|
|
92
|
+
n(() => {
|
|
93
|
+
Y(!1), V();
|
|
94
|
+
}, [
|
|
95
|
+
I,
|
|
96
|
+
L?.src,
|
|
97
|
+
V
|
|
98
|
+
]), n(() => {
|
|
99
|
+
if (!e || M < 2 || typeof Image > "u") return;
|
|
100
|
+
let t = [S[(I + 1) % M], S[(I - 1 + M) % M]];
|
|
101
|
+
for (let e of t) {
|
|
102
|
+
if (!e) continue;
|
|
103
|
+
let t = new Image();
|
|
104
|
+
t.src = e.src;
|
|
105
|
+
}
|
|
106
|
+
}, [
|
|
107
|
+
e,
|
|
108
|
+
I,
|
|
109
|
+
S,
|
|
110
|
+
M
|
|
111
|
+
]), te(R, e);
|
|
112
|
+
let pe = l(() => x(), e);
|
|
113
|
+
n(() => {
|
|
114
|
+
if (!e) return;
|
|
115
|
+
let t = document.body.style.overflow;
|
|
116
|
+
return document.body.style.overflow = "hidden", () => {
|
|
117
|
+
document.body.style.overflow = t;
|
|
118
|
+
};
|
|
119
|
+
}, [e]), u({
|
|
120
|
+
ArrowLeft: K,
|
|
121
|
+
ArrowRight: q,
|
|
122
|
+
"+": B.zoomIn,
|
|
123
|
+
"=": B.zoomIn,
|
|
124
|
+
"-": B.zoomOut,
|
|
125
|
+
0: B.reset
|
|
126
|
+
}, {
|
|
127
|
+
active: e,
|
|
128
|
+
ignoreEditable: !0
|
|
129
|
+
});
|
|
130
|
+
let X = i(null), Z = i(!1), me = (e) => {
|
|
131
|
+
X.current = {
|
|
132
|
+
x: e.clientX ?? 0,
|
|
133
|
+
y: e.clientY ?? 0
|
|
134
|
+
}, Z.current = !1, B.stageProps.onPointerDown(e);
|
|
135
|
+
}, Q = (e) => {
|
|
136
|
+
B.stageProps.onPointerUp(e);
|
|
137
|
+
let t = X.current;
|
|
138
|
+
if (X.current = null, !t) return;
|
|
139
|
+
let n = (e.clientX ?? 0) - t.x, r = (e.clientY ?? 0) - t.y;
|
|
140
|
+
Math.hypot(n, r) >= 5 && (Z.current = !0), H === 1 && Math.abs(n) > h && Math.abs(n) > Math.abs(r) && (n < 0 ? q() : K());
|
|
141
|
+
}, he = (e) => {
|
|
142
|
+
let t = Z.current;
|
|
143
|
+
Z.current = !1, le && !t && e.target === e.currentTarget && x();
|
|
144
|
+
}, ge = r();
|
|
145
|
+
if (!e || M === 0 || !L) return null;
|
|
146
|
+
let _e = ce ?? !!L.download, ve = typeof L.download == "string" ? L.download : L.src, $ = E ? E(L, {
|
|
147
|
+
index: I,
|
|
148
|
+
active: !0
|
|
149
|
+
}) : null, ye = `${Math.round(H * 100)}%`;
|
|
150
|
+
return ee(/* @__PURE__ */ f("div", {
|
|
151
|
+
ref: z,
|
|
152
|
+
className: o(s.root, D?.root, O),
|
|
153
|
+
style: k,
|
|
154
|
+
role: "dialog",
|
|
155
|
+
"aria-modal": "true",
|
|
156
|
+
"aria-label": L.alt || j.viewer,
|
|
157
|
+
"data-index": I,
|
|
158
|
+
children: /* @__PURE__ */ p(c, {
|
|
159
|
+
value: pe,
|
|
160
|
+
children: [
|
|
161
|
+
/* @__PURE__ */ f("div", {
|
|
162
|
+
className: o(s.backdrop, D?.backdrop),
|
|
163
|
+
"aria-hidden": "true"
|
|
164
|
+
}),
|
|
165
|
+
/* @__PURE__ */ p("div", {
|
|
166
|
+
className: o(s.toolbar, D?.toolbar),
|
|
167
|
+
children: [
|
|
168
|
+
ae && M > 1 && /* @__PURE__ */ p("span", {
|
|
169
|
+
className: o(s.counter, D?.counter),
|
|
170
|
+
"aria-live": "polite",
|
|
171
|
+
children: [
|
|
172
|
+
I + 1,
|
|
173
|
+
" / ",
|
|
174
|
+
M
|
|
175
|
+
]
|
|
176
|
+
}),
|
|
177
|
+
/* @__PURE__ */ f("span", { className: s.spacer }),
|
|
178
|
+
se && /* @__PURE__ */ p("div", {
|
|
179
|
+
className: o(s.zoomControls, D?.zoomControls),
|
|
180
|
+
role: "group",
|
|
181
|
+
"aria-label": "Zoom",
|
|
182
|
+
children: [
|
|
183
|
+
/* @__PURE__ */ f("button", {
|
|
184
|
+
type: "button",
|
|
185
|
+
className: s.control,
|
|
186
|
+
onClick: B.zoomOut,
|
|
187
|
+
"aria-label": j.zoomOut,
|
|
188
|
+
children: "−"
|
|
189
|
+
}),
|
|
190
|
+
/* @__PURE__ */ f("span", {
|
|
191
|
+
className: s.zoomValue,
|
|
192
|
+
"data-testid": "zoom-value",
|
|
193
|
+
children: ye
|
|
194
|
+
}),
|
|
195
|
+
/* @__PURE__ */ f("button", {
|
|
196
|
+
type: "button",
|
|
197
|
+
className: s.control,
|
|
198
|
+
onClick: B.zoomIn,
|
|
199
|
+
"aria-label": j.zoomIn,
|
|
200
|
+
children: "+"
|
|
201
|
+
}),
|
|
202
|
+
/* @__PURE__ */ f("button", {
|
|
203
|
+
type: "button",
|
|
204
|
+
className: s.control,
|
|
205
|
+
onClick: B.reset,
|
|
206
|
+
"aria-label": j.reset,
|
|
207
|
+
children: /* @__PURE__ */ f(y, {})
|
|
208
|
+
}),
|
|
209
|
+
/* @__PURE__ */ f("button", {
|
|
210
|
+
type: "button",
|
|
211
|
+
className: s.control,
|
|
212
|
+
onClick: B.fit,
|
|
213
|
+
"aria-label": j.fit,
|
|
214
|
+
children: /* @__PURE__ */ f(b, {})
|
|
215
|
+
})
|
|
216
|
+
]
|
|
217
|
+
}),
|
|
218
|
+
_e && /* @__PURE__ */ f("a", {
|
|
219
|
+
className: s.control,
|
|
220
|
+
href: ve,
|
|
221
|
+
download: !0,
|
|
222
|
+
"aria-label": j.download,
|
|
223
|
+
target: "_blank",
|
|
224
|
+
rel: "noreferrer",
|
|
225
|
+
children: /* @__PURE__ */ f(v, {})
|
|
226
|
+
}),
|
|
227
|
+
/* @__PURE__ */ f("button", {
|
|
228
|
+
type: "button",
|
|
229
|
+
className: s.control,
|
|
230
|
+
onClick: x,
|
|
231
|
+
"aria-label": j.close,
|
|
232
|
+
children: /* @__PURE__ */ f(g, {})
|
|
233
|
+
})
|
|
234
|
+
]
|
|
235
|
+
}),
|
|
236
|
+
/* @__PURE__ */ p("div", {
|
|
237
|
+
className: s.body,
|
|
238
|
+
children: [
|
|
239
|
+
M > 1 && W && /* @__PURE__ */ f("button", {
|
|
240
|
+
type: "button",
|
|
241
|
+
className: o(s.nav, s.navPrev, D?.nav, D?.navPrev),
|
|
242
|
+
onClick: K,
|
|
243
|
+
"aria-label": j.previous,
|
|
244
|
+
children: /* @__PURE__ */ f(_, { dir: "left" })
|
|
245
|
+
}),
|
|
246
|
+
/* @__PURE__ */ f("div", {
|
|
247
|
+
className: o(s.stage, fe && s.panning, D?.stage),
|
|
248
|
+
...B.stageProps,
|
|
249
|
+
onPointerDown: me,
|
|
250
|
+
onPointerUp: Q,
|
|
251
|
+
onClick: he,
|
|
252
|
+
style: B.stageProps.style,
|
|
253
|
+
"data-testid": "image-viewer-stage",
|
|
254
|
+
children: $ ? /* @__PURE__ */ f("div", {
|
|
255
|
+
ref: B.contentRef,
|
|
256
|
+
className: o(s.image, D?.image),
|
|
257
|
+
style: B.contentStyle,
|
|
258
|
+
children: $
|
|
259
|
+
}) : /* @__PURE__ */ p(re, { children: [/* @__PURE__ */ f("img", {
|
|
260
|
+
ref: B.contentRef,
|
|
261
|
+
className: o(s.image, !J && s.imageLoading, D?.image),
|
|
262
|
+
style: B.contentStyle,
|
|
263
|
+
src: L.src,
|
|
264
|
+
alt: L.alt ?? "",
|
|
265
|
+
draggable: !1,
|
|
266
|
+
onLoad: () => Y(!0),
|
|
267
|
+
onError: () => Y(!0)
|
|
268
|
+
}, L.src), !J && /* @__PURE__ */ f("span", {
|
|
269
|
+
className: s.spinner,
|
|
270
|
+
children: /* @__PURE__ */ f(d, {
|
|
271
|
+
size: "lg",
|
|
272
|
+
label: j.loading
|
|
273
|
+
})
|
|
274
|
+
})] })
|
|
275
|
+
}),
|
|
276
|
+
M > 1 && G && /* @__PURE__ */ f("button", {
|
|
277
|
+
type: "button",
|
|
278
|
+
className: o(s.nav, s.navNext, D?.nav, D?.navNext),
|
|
279
|
+
onClick: q,
|
|
280
|
+
"aria-label": j.next,
|
|
281
|
+
children: /* @__PURE__ */ f(_, { dir: "right" })
|
|
282
|
+
})
|
|
283
|
+
]
|
|
284
|
+
}),
|
|
285
|
+
L.caption && /* @__PURE__ */ f("div", {
|
|
286
|
+
id: ge,
|
|
287
|
+
className: o(s.caption, D?.caption),
|
|
288
|
+
children: L.caption
|
|
289
|
+
}),
|
|
290
|
+
oe && M > 1 && /* @__PURE__ */ f("div", {
|
|
291
|
+
className: o(s.thumbnails, D?.thumbnails),
|
|
292
|
+
role: "list",
|
|
293
|
+
children: S.map((e, t) => /* @__PURE__ */ f("button", {
|
|
294
|
+
type: "button",
|
|
295
|
+
role: "listitem",
|
|
296
|
+
className: o(s.thumbnail, t === I && s.thumbnailActive, D?.thumbnail, t === I && D?.thumbnailActive),
|
|
297
|
+
onClick: () => U(t),
|
|
298
|
+
"aria-label": e.alt || `${t + 1}`,
|
|
299
|
+
"aria-current": t === I ? "true" : void 0,
|
|
300
|
+
children: /* @__PURE__ */ f("img", {
|
|
301
|
+
src: e.thumbnail ?? e.src,
|
|
302
|
+
alt: "",
|
|
303
|
+
draggable: !1
|
|
304
|
+
})
|
|
305
|
+
}, `${e.src}-${t}`))
|
|
306
|
+
})
|
|
307
|
+
]
|
|
308
|
+
})
|
|
309
|
+
}), document.body);
|
|
310
|
+
});
|
|
311
|
+
x.displayName = "ImageViewer";
|
|
312
|
+
export { x as ImageViewer };
|
|
@@ -1,47 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
n as backdrop,
|
|
26
|
-
i as body,
|
|
27
|
-
d as caption,
|
|
28
|
-
e as control,
|
|
29
|
-
a as counter,
|
|
30
|
-
P as default,
|
|
31
|
-
m as image,
|
|
32
|
-
b as imageLoading,
|
|
33
|
-
u as nav,
|
|
34
|
-
g as navNext,
|
|
35
|
-
v as navPrev,
|
|
36
|
-
l as panning,
|
|
37
|
-
o as root,
|
|
38
|
-
t as spacer,
|
|
39
|
-
p as spinner,
|
|
40
|
-
k as stage,
|
|
41
|
-
z as thumbnail,
|
|
42
|
-
y as thumbnailActive,
|
|
43
|
-
h as thumbnails,
|
|
44
|
-
c as toolbar,
|
|
45
|
-
r as zoomControls,
|
|
46
|
-
s as zoomValue
|
|
1
|
+
// src/components/ImageViewer/ImageViewer.module.scss
|
|
2
|
+
var e = "crk-root-ONPec", t = "crk-viewerIn-LGN1N", n = "crk-backdrop-zT-Q5", r = "crk-toolbar-AnTEv", i = "crk-spacer-w02Ek", a = "crk-counter-VTMp2", o = "crk-zoomControls-7H0yp", s = "crk-zoomValue-SJmdu", c = "crk-control-PyHnZ", l = "crk-body-OJK4N", u = "crk-stage-e0AOa", d = "crk-image-m6tek", f = "crk-panning-KHk5X", p = "crk-imageLoading-jrFiP", m = "crk-spinner-eg9--", h = "crk-nav-Bejfo", g = "crk-navPrev-GAvIZ", _ = "crk-navNext-Ly2YK", v = "crk-caption-25w3Q", y = "crk-thumbnails-JZb4b", b = "crk-thumbnail-hzBpT", x = "crk-thumbnailActive-Pfwmf", S = {
|
|
3
|
+
root: e,
|
|
4
|
+
viewerIn: t,
|
|
5
|
+
backdrop: n,
|
|
6
|
+
toolbar: r,
|
|
7
|
+
spacer: i,
|
|
8
|
+
counter: a,
|
|
9
|
+
zoomControls: o,
|
|
10
|
+
zoomValue: s,
|
|
11
|
+
control: c,
|
|
12
|
+
body: l,
|
|
13
|
+
stage: u,
|
|
14
|
+
image: d,
|
|
15
|
+
panning: f,
|
|
16
|
+
imageLoading: p,
|
|
17
|
+
spinner: m,
|
|
18
|
+
nav: h,
|
|
19
|
+
navPrev: g,
|
|
20
|
+
navNext: _,
|
|
21
|
+
caption: v,
|
|
22
|
+
thumbnails: y,
|
|
23
|
+
thumbnail: b,
|
|
24
|
+
thumbnailActive: x
|
|
47
25
|
};
|
|
26
|
+
export { n as backdrop, l as body, v as caption, c as control, a as counter, S as default, d as image, p as imageLoading, h as nav, _ as navNext, g as navPrev, f as panning, e as root, i as spacer, m as spinner, u as stage, b as thumbnail, x as thumbnailActive, y as thumbnails, r as toolbar, t as viewerIn, o as zoomControls, s as zoomValue };
|