@fumadocs/base-ui 16.7.12 → 16.7.14
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/css/generated/shared.css +2 -7
- package/dist/components/image-zoom.d.ts +1 -1
- package/dist/components/image-zoom.js +2 -2
- package/dist/components/toc/clerk.js +32 -17
- package/dist/components/toc/default.js +43 -7
- package/dist/components/toc/index.d.ts +2 -11
- package/dist/components/toc/index.js +2 -59
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.3_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/Controlled.d.ts +36 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.3_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/Controlled.js +435 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.3_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/Uncontrolled.d.ts +7 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.3_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/Uncontrolled.js +17 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.3_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/icons.js +24 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.3_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/index.d.ts +2 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.3_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/utils.js +372 -0
- package/dist/style.css +14 -14
- package/package.json +14 -11
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
import { ICompress, IEnlarge } from "./icons.js";
|
|
2
|
+
import { adjustSvgIDs, getImgAlt, getImgSrc, getStyleGhost, getStyleModalImg, testDiv, testImg, testImgLoaded, testSvg } from "./utils.js";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import ReactDOM from "react-dom";
|
|
5
|
+
//#region ../../node_modules/.pnpm/react-medium-image-zoom@5.4.3_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/Controlled.js
|
|
6
|
+
const IMAGE_QUERY = [
|
|
7
|
+
"img",
|
|
8
|
+
"svg",
|
|
9
|
+
"[role=\"img\"]",
|
|
10
|
+
"[data-zoom]"
|
|
11
|
+
].map((x) => `${x}:not([aria-hidden="true"])`).join(",");
|
|
12
|
+
const defaultBodyAttrs = {
|
|
13
|
+
overflow: "",
|
|
14
|
+
width: ""
|
|
15
|
+
};
|
|
16
|
+
function getDialogContainer() {
|
|
17
|
+
const existing = document.querySelector("[data-rmiz-portal]");
|
|
18
|
+
if (existing != null) return existing;
|
|
19
|
+
const el = document.createElement("div");
|
|
20
|
+
el.setAttribute("data-rmiz-portal", "");
|
|
21
|
+
document.body.appendChild(el);
|
|
22
|
+
return el;
|
|
23
|
+
}
|
|
24
|
+
function handleDialogCancelStatic(e) {
|
|
25
|
+
e.preventDefault();
|
|
26
|
+
}
|
|
27
|
+
function Controlled(props) {
|
|
28
|
+
return React.createElement(ControlledBase, { ...props });
|
|
29
|
+
}
|
|
30
|
+
var ControlledBase = class extends React.Component {
|
|
31
|
+
constructor() {
|
|
32
|
+
super(...arguments);
|
|
33
|
+
this.state = {
|
|
34
|
+
id: "",
|
|
35
|
+
isZoomImgLoaded: false,
|
|
36
|
+
loadedImgEl: void 0,
|
|
37
|
+
modalState: "UNLOADED",
|
|
38
|
+
shouldRefresh: false,
|
|
39
|
+
styleGhost: {}
|
|
40
|
+
};
|
|
41
|
+
this.refContent = React.createRef();
|
|
42
|
+
this.refDialog = React.createRef();
|
|
43
|
+
this.refModalContent = React.createRef();
|
|
44
|
+
this.refModalImg = React.createRef();
|
|
45
|
+
this.refWrap = React.createRef();
|
|
46
|
+
this.imgEl = null;
|
|
47
|
+
this.isScaling = false;
|
|
48
|
+
this.prevBodyAttrs = defaultBodyAttrs;
|
|
49
|
+
this.styleModalImg = {};
|
|
50
|
+
this.handleModalStateChange = (prevModalState) => {
|
|
51
|
+
const { state: { modalState } } = this;
|
|
52
|
+
if (prevModalState !== "LOADING" && modalState === "LOADING") {
|
|
53
|
+
this.loadZoomImg();
|
|
54
|
+
window.addEventListener("resize", this.handleResize, { passive: true });
|
|
55
|
+
window.addEventListener("touchstart", this.handleTouchStart, { passive: true });
|
|
56
|
+
window.addEventListener("touchmove", this.handleTouchMove, { passive: true });
|
|
57
|
+
window.addEventListener("touchend", this.handleTouchEnd, { passive: true });
|
|
58
|
+
window.addEventListener("touchcancel", this.handleTouchCancel, { passive: true });
|
|
59
|
+
document.addEventListener("keydown", this.handleKeyDown, true);
|
|
60
|
+
} else if (prevModalState !== "LOADED" && modalState === "LOADED") window.addEventListener("wheel", this.handleWheel, { passive: true });
|
|
61
|
+
else if (prevModalState !== "UNLOADING" && modalState === "UNLOADING") {
|
|
62
|
+
this.ensureImgTransitionEnd();
|
|
63
|
+
window.removeEventListener("wheel", this.handleWheel);
|
|
64
|
+
window.removeEventListener("touchstart", this.handleTouchStart);
|
|
65
|
+
window.removeEventListener("touchmove", this.handleTouchMove);
|
|
66
|
+
window.removeEventListener("touchend", this.handleTouchEnd);
|
|
67
|
+
window.removeEventListener("touchcancel", this.handleTouchCancel);
|
|
68
|
+
document.removeEventListener("keydown", this.handleKeyDown, true);
|
|
69
|
+
} else if (prevModalState !== "UNLOADED" && modalState === "UNLOADED") {
|
|
70
|
+
this.bodyScrollEnable();
|
|
71
|
+
window.removeEventListener("resize", this.handleResize);
|
|
72
|
+
this.refModalImg.current?.removeEventListener("transitionend", this.handleImgTransitionEnd);
|
|
73
|
+
this.refDialog.current?.close();
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
this.setId = () => {
|
|
77
|
+
const gen4 = () => Math.random().toString(16).slice(-4);
|
|
78
|
+
this.setState({ id: gen4() + gen4() + gen4() });
|
|
79
|
+
};
|
|
80
|
+
this.setAndTrackImg = () => {
|
|
81
|
+
const { refContent: { current: contentEl } } = this;
|
|
82
|
+
if (contentEl == null) return;
|
|
83
|
+
this.imgEl = contentEl.querySelector(IMAGE_QUERY);
|
|
84
|
+
if (this.imgEl !== null) {
|
|
85
|
+
this.contentNotFoundChangeObserver?.disconnect();
|
|
86
|
+
this.imgEl.addEventListener("load", this.handleImgLoad);
|
|
87
|
+
this.imgEl.addEventListener("click", this.handleZoom);
|
|
88
|
+
if (this.state.loadedImgEl == null) this.handleImgLoad();
|
|
89
|
+
this.imgElResizeObserver = new ResizeObserver((entries) => {
|
|
90
|
+
const [entry] = entries;
|
|
91
|
+
if (entry?.target !== void 0) {
|
|
92
|
+
this.imgEl = entry.target;
|
|
93
|
+
this.setState({ styleGhost: getStyleGhost(this.imgEl) });
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
this.imgElResizeObserver.observe(this.imgEl);
|
|
97
|
+
if (this.contentChangeObserver == null) {
|
|
98
|
+
this.contentChangeObserver = new MutationObserver(() => {
|
|
99
|
+
this.setState({ styleGhost: getStyleGhost(this.imgEl) });
|
|
100
|
+
});
|
|
101
|
+
this.contentChangeObserver.observe(contentEl, {
|
|
102
|
+
attributes: true,
|
|
103
|
+
childList: true,
|
|
104
|
+
subtree: true
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
} else if (this.contentNotFoundChangeObserver == null) {
|
|
108
|
+
this.contentNotFoundChangeObserver = new MutationObserver(this.setAndTrackImg);
|
|
109
|
+
this.contentNotFoundChangeObserver.observe(contentEl, {
|
|
110
|
+
childList: true,
|
|
111
|
+
subtree: true
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
this.handleIfZoomChanged = (prevIsZoomed) => {
|
|
116
|
+
const { props: { isZoomed } } = this;
|
|
117
|
+
if (!prevIsZoomed && isZoomed) this.zoom();
|
|
118
|
+
else if (prevIsZoomed && !isZoomed) this.unzoom();
|
|
119
|
+
};
|
|
120
|
+
this.handleImgLoad = () => {
|
|
121
|
+
const imgSrc = getImgSrc(this.imgEl);
|
|
122
|
+
if (imgSrc == null || imgSrc === "") return;
|
|
123
|
+
const img = new Image();
|
|
124
|
+
const { imgEl } = this;
|
|
125
|
+
if (testImg(imgEl)) {
|
|
126
|
+
const { sizes, srcset, crossOrigin } = imgEl;
|
|
127
|
+
img.sizes = sizes;
|
|
128
|
+
img.srcset = srcset;
|
|
129
|
+
img.crossOrigin = crossOrigin;
|
|
130
|
+
}
|
|
131
|
+
img.src = imgSrc;
|
|
132
|
+
const setLoaded = () => {
|
|
133
|
+
this.setState({
|
|
134
|
+
loadedImgEl: img,
|
|
135
|
+
styleGhost: getStyleGhost(this.imgEl)
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
img.decode().then(setLoaded).catch(() => {
|
|
139
|
+
if (testImgLoaded(img)) {
|
|
140
|
+
setLoaded();
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
img.onload = setLoaded;
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
this.handleZoom = (e) => {
|
|
147
|
+
if (this.props.isDisabled !== true && this.hasImage()) this.props.onZoomChange?.(true, { event: e });
|
|
148
|
+
};
|
|
149
|
+
this.handleUnzoom = (e) => {
|
|
150
|
+
if (this.props.isDisabled !== true) this.props.onZoomChange?.(false, { event: e });
|
|
151
|
+
};
|
|
152
|
+
this.handleBtnUnzoomClick = (e) => {
|
|
153
|
+
e.preventDefault();
|
|
154
|
+
e.stopPropagation();
|
|
155
|
+
this.handleUnzoom(e);
|
|
156
|
+
};
|
|
157
|
+
this.handleDialogClick = (e) => {
|
|
158
|
+
if (e.target === this.refModalContent.current || e.target === this.refModalImg.current) {
|
|
159
|
+
e.stopPropagation();
|
|
160
|
+
this.handleUnzoom(e);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
this.handleDialogClose = (e) => {
|
|
164
|
+
e.stopPropagation();
|
|
165
|
+
this.handleUnzoom(e);
|
|
166
|
+
};
|
|
167
|
+
this.handleKeyDown = (e) => {
|
|
168
|
+
if (e.key === "Escape") {
|
|
169
|
+
e.preventDefault();
|
|
170
|
+
e.stopPropagation();
|
|
171
|
+
this.handleUnzoom(e);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
this.handleWheel = (e) => {
|
|
175
|
+
if (e.ctrlKey) return;
|
|
176
|
+
e.stopPropagation();
|
|
177
|
+
queueMicrotask(() => {
|
|
178
|
+
this.handleUnzoom(e);
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
this.handleTouchStart = (e) => {
|
|
182
|
+
if (e.touches.length > 1) {
|
|
183
|
+
this.isScaling = true;
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const { changedTouches } = e;
|
|
187
|
+
const [changedTouch] = changedTouches;
|
|
188
|
+
if (changedTouches.length === 1 && changedTouch !== void 0) {
|
|
189
|
+
const { screenY } = changedTouch;
|
|
190
|
+
this.touchYStart = screenY;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
this.handleTouchMove = (e) => {
|
|
194
|
+
const browserScale = window.visualViewport?.scale ?? 1;
|
|
195
|
+
const { changedTouches: changedTouchesMove } = e;
|
|
196
|
+
const [changedTouchMove] = changedTouchesMove;
|
|
197
|
+
if (this.props.canSwipeToUnzoom && !this.isScaling && browserScale <= 1 && this.touchYStart != null && changedTouchMove !== void 0) {
|
|
198
|
+
const { screenY } = changedTouchMove;
|
|
199
|
+
this.touchYEnd = screenY;
|
|
200
|
+
const max = Math.max(this.touchYStart, this.touchYEnd);
|
|
201
|
+
const min = Math.min(this.touchYStart, this.touchYEnd);
|
|
202
|
+
if (Math.abs(max - min) > this.props.swipeToUnzoomThreshold) {
|
|
203
|
+
this.touchYStart = void 0;
|
|
204
|
+
this.touchYEnd = void 0;
|
|
205
|
+
this.handleUnzoom(e);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
this.handleTouchEnd = () => {
|
|
210
|
+
this.isScaling = false;
|
|
211
|
+
this.touchYStart = void 0;
|
|
212
|
+
this.touchYEnd = void 0;
|
|
213
|
+
};
|
|
214
|
+
this.handleTouchCancel = () => {
|
|
215
|
+
this.isScaling = false;
|
|
216
|
+
this.touchYStart = void 0;
|
|
217
|
+
this.touchYEnd = void 0;
|
|
218
|
+
};
|
|
219
|
+
this.handleResize = () => {
|
|
220
|
+
this.setState({ shouldRefresh: true });
|
|
221
|
+
};
|
|
222
|
+
this.hasImage = () => this.imgEl !== null && (this.state.loadedImgEl !== void 0 || testSvg(this.imgEl)) && window.getComputedStyle(this.imgEl).display !== "none";
|
|
223
|
+
this.zoom = () => {
|
|
224
|
+
this.bodyScrollDisable();
|
|
225
|
+
this.refDialog.current?.showModal();
|
|
226
|
+
this.refModalImg.current?.addEventListener("transitionend", this.handleImgTransitionEnd);
|
|
227
|
+
this.setState({ modalState: "LOADING" });
|
|
228
|
+
};
|
|
229
|
+
this.unzoom = () => {
|
|
230
|
+
this.setState({ modalState: "UNLOADING" });
|
|
231
|
+
};
|
|
232
|
+
this.handleImgTransitionEnd = () => {
|
|
233
|
+
clearTimeout(this.timeoutTransitionEnd);
|
|
234
|
+
if (this.state.modalState === "LOADING") this.setState({ modalState: "LOADED" });
|
|
235
|
+
else if (this.state.modalState === "UNLOADING") this.setState({
|
|
236
|
+
shouldRefresh: false,
|
|
237
|
+
modalState: "UNLOADED"
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
this.ensureImgTransitionEnd = () => {
|
|
241
|
+
if (this.refModalImg.current !== null) {
|
|
242
|
+
const { transitionDuration: td } = window.getComputedStyle(this.refModalImg.current);
|
|
243
|
+
const tdFloat = parseFloat(td);
|
|
244
|
+
if (tdFloat !== 0 && !Number.isNaN(tdFloat)) {
|
|
245
|
+
const tdMs = tdFloat * (td.endsWith("ms") ? 1 : 1e3) + 50;
|
|
246
|
+
this.timeoutTransitionEnd = setTimeout(this.handleImgTransitionEnd, tdMs);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
this.bodyScrollDisable = () => {
|
|
251
|
+
this.prevBodyAttrs = {
|
|
252
|
+
overflow: document.body.style.overflow,
|
|
253
|
+
width: document.body.style.width
|
|
254
|
+
};
|
|
255
|
+
const { body: { clientWidth } } = document;
|
|
256
|
+
document.body.style.overflow = "hidden";
|
|
257
|
+
document.body.style.width = `${clientWidth}px`;
|
|
258
|
+
};
|
|
259
|
+
this.bodyScrollEnable = () => {
|
|
260
|
+
const { prevBodyAttrs: { overflow, width } } = this;
|
|
261
|
+
document.body.style.width = width;
|
|
262
|
+
document.body.style.overflow = overflow;
|
|
263
|
+
this.prevBodyAttrs = defaultBodyAttrs;
|
|
264
|
+
};
|
|
265
|
+
this.loadZoomImg = () => {
|
|
266
|
+
const { props: { zoomImg } } = this;
|
|
267
|
+
if (zoomImg == null) return;
|
|
268
|
+
const { src: zoomImgSrc } = zoomImg;
|
|
269
|
+
if (zoomImgSrc !== void 0 && zoomImgSrc !== "") {
|
|
270
|
+
const img = new Image();
|
|
271
|
+
img.sizes = zoomImg.sizes ?? "";
|
|
272
|
+
img.srcset = zoomImg.srcSet ?? "";
|
|
273
|
+
img.crossOrigin = zoomImg.crossOrigin ?? void 0;
|
|
274
|
+
img.src = zoomImgSrc;
|
|
275
|
+
const setLoaded = () => {
|
|
276
|
+
this.setState({ isZoomImgLoaded: true });
|
|
277
|
+
};
|
|
278
|
+
img.decode().then(setLoaded).catch(() => {
|
|
279
|
+
if (testImgLoaded(img)) {
|
|
280
|
+
setLoaded();
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
img.onload = setLoaded;
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
this.UNSAFE_handleSvg = () => {
|
|
288
|
+
const { imgEl, refModalImg, styleModalImg } = this;
|
|
289
|
+
if (testSvg(imgEl)) {
|
|
290
|
+
const svgEl = imgEl.cloneNode(true);
|
|
291
|
+
adjustSvgIDs(svgEl);
|
|
292
|
+
svgEl.style.width = `${styleModalImg.width ?? 0}px`;
|
|
293
|
+
svgEl.style.height = `${styleModalImg.height ?? 0}px`;
|
|
294
|
+
svgEl.addEventListener("click", this.handleUnzoom);
|
|
295
|
+
refModalImg.current?.firstChild?.remove();
|
|
296
|
+
refModalImg.current?.appendChild(svgEl);
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
render() {
|
|
301
|
+
const { handleBtnUnzoomClick, handleDialogClick, handleDialogClose, handleUnzoom, handleZoom, imgEl, props: { a11yNameButtonUnzoom, a11yNameButtonZoom, children, classDialog, IconUnzoom, IconZoom, isZoomed, wrapElement: WrapElement, ZoomContent, zoomImg, zoomMargin }, refContent, refDialog, refModalContent, refModalImg, refWrap, state: { id, isZoomImgLoaded, loadedImgEl, modalState, shouldRefresh, styleGhost } } = this;
|
|
302
|
+
const idModal = `rmiz-modal-${id}`;
|
|
303
|
+
const idModalImg = `rmiz-modal-img-${id}`;
|
|
304
|
+
const isDiv = testDiv(imgEl);
|
|
305
|
+
const isImg = testImg(imgEl);
|
|
306
|
+
const isSvg = testSvg(imgEl);
|
|
307
|
+
const imgAlt = getImgAlt(imgEl);
|
|
308
|
+
const imgSrc = getImgSrc(imgEl);
|
|
309
|
+
const imgSizes = isImg ? imgEl.sizes : void 0;
|
|
310
|
+
const imgSrcSet = isImg ? imgEl.srcset : void 0;
|
|
311
|
+
const imgCrossOrigin = isImg ? imgEl.crossOrigin : void 0;
|
|
312
|
+
const hasZoomImg = zoomImg?.src !== void 0 && zoomImg.src !== "";
|
|
313
|
+
const hasImage = this.hasImage();
|
|
314
|
+
const labelBtnZoom = imgAlt !== void 0 && imgAlt !== "" ? `${a11yNameButtonZoom}: ${imgAlt}` : a11yNameButtonZoom;
|
|
315
|
+
const isModalActive = modalState === "LOADING" || modalState === "LOADED";
|
|
316
|
+
const dataContentState = hasImage ? "found" : "not-found";
|
|
317
|
+
const dataOverlayState = modalState === "UNLOADED" || modalState === "UNLOADING" ? "hidden" : "visible";
|
|
318
|
+
const styleContent = { visibility: modalState === "UNLOADED" ? "visible" : "hidden" };
|
|
319
|
+
this.styleModalImg = hasImage && imgEl !== null ? getStyleModalImg({
|
|
320
|
+
hasZoomImg,
|
|
321
|
+
imgSrc,
|
|
322
|
+
isSvg,
|
|
323
|
+
isZoomed: isZoomed && isModalActive,
|
|
324
|
+
loadedImgEl,
|
|
325
|
+
offset: zoomMargin,
|
|
326
|
+
shouldRefresh,
|
|
327
|
+
targetEl: imgEl
|
|
328
|
+
}) : {};
|
|
329
|
+
let modalContent = null;
|
|
330
|
+
if (hasImage) {
|
|
331
|
+
const modalImg = isImg || isDiv ? React.createElement("img", {
|
|
332
|
+
alt: imgAlt,
|
|
333
|
+
crossOrigin: imgCrossOrigin,
|
|
334
|
+
sizes: imgSizes,
|
|
335
|
+
src: imgSrc,
|
|
336
|
+
srcSet: imgSrcSet,
|
|
337
|
+
...isZoomImgLoaded && modalState === "LOADED" ? zoomImg : {},
|
|
338
|
+
"data-rmiz-modal-img": "",
|
|
339
|
+
height: this.styleModalImg.height ?? void 0,
|
|
340
|
+
id: idModalImg,
|
|
341
|
+
ref: refModalImg,
|
|
342
|
+
style: this.styleModalImg,
|
|
343
|
+
width: this.styleModalImg.width ?? void 0
|
|
344
|
+
}) : isSvg ? React.createElement("div", {
|
|
345
|
+
"data-rmiz-modal-img": true,
|
|
346
|
+
ref: refModalImg,
|
|
347
|
+
style: this.styleModalImg
|
|
348
|
+
}) : null;
|
|
349
|
+
const modalBtnUnzoom = React.createElement("button", {
|
|
350
|
+
"aria-label": a11yNameButtonUnzoom,
|
|
351
|
+
"data-rmiz-btn-unzoom": "",
|
|
352
|
+
onClick: handleBtnUnzoomClick,
|
|
353
|
+
type: "button"
|
|
354
|
+
}, React.createElement(IconUnzoom, null));
|
|
355
|
+
modalContent = ZoomContent == null ? React.createElement(React.Fragment, null, modalImg, modalBtnUnzoom) : React.createElement(ZoomContent, {
|
|
356
|
+
buttonUnzoom: modalBtnUnzoom,
|
|
357
|
+
modalState,
|
|
358
|
+
img: modalImg,
|
|
359
|
+
isZoomImgLoaded,
|
|
360
|
+
onUnzoom: handleUnzoom
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
return React.createElement(WrapElement, {
|
|
364
|
+
"aria-owns": idModal,
|
|
365
|
+
"data-rmiz": "",
|
|
366
|
+
ref: refWrap
|
|
367
|
+
}, React.createElement(WrapElement, {
|
|
368
|
+
"data-rmiz-content": dataContentState,
|
|
369
|
+
ref: refContent,
|
|
370
|
+
style: styleContent
|
|
371
|
+
}, children), hasImage && React.createElement(WrapElement, {
|
|
372
|
+
"data-rmiz-ghost": "",
|
|
373
|
+
style: styleGhost
|
|
374
|
+
}, React.createElement("button", {
|
|
375
|
+
"aria-label": labelBtnZoom,
|
|
376
|
+
"data-rmiz-btn-zoom": "",
|
|
377
|
+
onClick: handleZoom,
|
|
378
|
+
type: "button"
|
|
379
|
+
}, React.createElement(IconZoom, null))), hasImage && ReactDOM.createPortal(React.createElement("dialog", {
|
|
380
|
+
"aria-labelledby": idModalImg,
|
|
381
|
+
"aria-modal": "true",
|
|
382
|
+
className: classDialog,
|
|
383
|
+
"data-rmiz-modal": "",
|
|
384
|
+
id: idModal,
|
|
385
|
+
onClick: handleDialogClick,
|
|
386
|
+
onClose: handleDialogClose,
|
|
387
|
+
onCancel: handleDialogCancelStatic,
|
|
388
|
+
ref: refDialog,
|
|
389
|
+
role: "dialog"
|
|
390
|
+
}, React.createElement("div", { "data-rmiz-modal-overlay": dataOverlayState }), React.createElement("div", {
|
|
391
|
+
"data-rmiz-modal-content": "",
|
|
392
|
+
ref: refModalContent
|
|
393
|
+
}, modalContent)), getDialogContainer()));
|
|
394
|
+
}
|
|
395
|
+
componentDidMount() {
|
|
396
|
+
this.setId();
|
|
397
|
+
this.setAndTrackImg();
|
|
398
|
+
this.handleImgLoad();
|
|
399
|
+
this.UNSAFE_handleSvg();
|
|
400
|
+
}
|
|
401
|
+
componentWillUnmount() {
|
|
402
|
+
if (this.state.modalState !== "UNLOADED") this.bodyScrollEnable();
|
|
403
|
+
this.contentChangeObserver?.disconnect();
|
|
404
|
+
this.contentNotFoundChangeObserver?.disconnect();
|
|
405
|
+
this.imgElResizeObserver?.disconnect();
|
|
406
|
+
this.imgEl?.removeEventListener("load", this.handleImgLoad);
|
|
407
|
+
this.imgEl?.removeEventListener("click", this.handleZoom);
|
|
408
|
+
this.refModalImg.current?.removeEventListener("transitionend", this.handleImgTransitionEnd);
|
|
409
|
+
window.removeEventListener("wheel", this.handleWheel);
|
|
410
|
+
window.removeEventListener("touchstart", this.handleTouchStart);
|
|
411
|
+
window.removeEventListener("touchmove", this.handleTouchMove);
|
|
412
|
+
window.removeEventListener("touchend", this.handleTouchEnd);
|
|
413
|
+
window.removeEventListener("touchcancel", this.handleTouchCancel);
|
|
414
|
+
window.removeEventListener("resize", this.handleResize);
|
|
415
|
+
document.removeEventListener("keydown", this.handleKeyDown, true);
|
|
416
|
+
}
|
|
417
|
+
componentDidUpdate(prevProps, prevState) {
|
|
418
|
+
this.handleModalStateChange(prevState.modalState);
|
|
419
|
+
this.UNSAFE_handleSvg();
|
|
420
|
+
this.handleIfZoomChanged(prevProps.isZoomed);
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
ControlledBase.defaultProps = {
|
|
424
|
+
a11yNameButtonUnzoom: "Minimize image",
|
|
425
|
+
a11yNameButtonZoom: "Expand image",
|
|
426
|
+
canSwipeToUnzoom: true,
|
|
427
|
+
IconUnzoom: ICompress,
|
|
428
|
+
IconZoom: IEnlarge,
|
|
429
|
+
isDisabled: false,
|
|
430
|
+
swipeToUnzoomThreshold: 10,
|
|
431
|
+
wrapElement: "div",
|
|
432
|
+
zoomMargin: 0
|
|
433
|
+
};
|
|
434
|
+
//#endregion
|
|
435
|
+
export { Controlled };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ControlledProps } from "./Controlled.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
//#region ../../node_modules/.pnpm/react-medium-image-zoom@5.4.3_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/Uncontrolled.d.ts
|
|
5
|
+
type UncontrolledProps = Omit<ControlledProps, 'isZoomed'>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { UncontrolledProps };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Controlled } from "./Controlled.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
//#region ../../node_modules/.pnpm/react-medium-image-zoom@5.4.3_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/Uncontrolled.js
|
|
4
|
+
function Uncontrolled({ onZoomChange, ...props }) {
|
|
5
|
+
const [isZoomed, setIsZoomed] = React.useState(false);
|
|
6
|
+
const handleZoomChange = React.useCallback((value, { event }) => {
|
|
7
|
+
setIsZoomed(value);
|
|
8
|
+
onZoomChange?.(value, { event });
|
|
9
|
+
}, [onZoomChange]);
|
|
10
|
+
return React.createElement(Controlled, {
|
|
11
|
+
...props,
|
|
12
|
+
isZoomed,
|
|
13
|
+
onZoomChange: handleZoomChange
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { Uncontrolled };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
//#region ../../node_modules/.pnpm/react-medium-image-zoom@5.4.3_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/icons.js
|
|
3
|
+
function ICompress() {
|
|
4
|
+
return React.createElement("svg", {
|
|
5
|
+
"aria-hidden": "true",
|
|
6
|
+
"data-rmiz-btn-unzoom-icon": true,
|
|
7
|
+
fill: "currentColor",
|
|
8
|
+
focusable: "false",
|
|
9
|
+
viewBox: "0 0 16 16",
|
|
10
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
11
|
+
}, React.createElement("path", { d: "M 14.144531 1.148438 L 9 6.292969 L 9 3 L 8 3 L 8 8 L 13 8 L 13 7 L 9.707031 7 L 14.855469 1.851563 Z M 8 8 L 3 8 L 3 9 L 6.292969 9 L 1.148438 14.144531 L 1.851563 14.855469 L 7 9.707031 L 7 13 L 8 13 Z" }));
|
|
12
|
+
}
|
|
13
|
+
function IEnlarge() {
|
|
14
|
+
return React.createElement("svg", {
|
|
15
|
+
"aria-hidden": "true",
|
|
16
|
+
"data-rmiz-btn-zoom-icon": true,
|
|
17
|
+
fill: "currentColor",
|
|
18
|
+
focusable: "false",
|
|
19
|
+
viewBox: "0 0 16 16",
|
|
20
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
21
|
+
}, React.createElement("path", { d: "M 9 1 L 9 2 L 12.292969 2 L 2 12.292969 L 2 9 L 1 9 L 1 14 L 6 14 L 6 13 L 2.707031 13 L 13 2.707031 L 13 6 L 14 6 L 14 1 Z" }));
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { ICompress, IEnlarge };
|