@feugene/granularity 0.11.0 → 0.12.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/dist/GrTree.css +1 -1
- package/dist/chunks/config-1uSYl98Y2.js.map +1 -0
- package/dist/chunks/config-BIRO0vDJ.js.map +1 -0
- package/dist/chunks/config-BWiPnygb.js +5 -0
- package/dist/chunks/config-BWiPnygb.js.map +1 -0
- package/dist/chunks/config-BXtAmU3s2.js.map +1 -0
- package/dist/chunks/config-CGHLoBlH.js.map +1 -0
- package/dist/chunks/config-CrG1XiE72.js.map +1 -0
- package/dist/chunks/config-DUcu1D682.js.map +1 -0
- package/dist/chunks/config-Dlm49Jp5.js +5 -0
- package/dist/chunks/config-Dlm49Jp5.js.map +1 -0
- package/dist/chunks/config-DnvPqu4g2.js.map +1 -0
- package/dist/chunks/config-DpqOnJiz.js.map +1 -0
- package/dist/chunks/config-JpHA4Xx02.js.map +1 -0
- package/dist/chunks/config-LGrZIdaZ.js.map +1 -0
- package/dist/chunks/config-eXB87DOi2.js +9 -0
- package/dist/chunks/config-eXB87DOi2.js.map +1 -0
- package/dist/chunks/context-DdNIxa1w.js +9 -0
- package/dist/chunks/context-DdNIxa1w.js.map +1 -0
- package/dist/chunks/{en-BdtiS2d3.js → en-CfkDa4GX.js} +8 -2
- package/dist/chunks/{en-BdtiS2d3.js.map → en-CfkDa4GX.js.map} +1 -1
- package/dist/chunks/{es-DBhctWg-.js → es-CgaLnFYx.js} +3 -3
- package/dist/chunks/{es-DBhctWg-.js.map → es-CgaLnFYx.js.map} +1 -1
- package/dist/chunks/{es-BGRMZbe9.js → es-FkgECuCm.js} +8 -2
- package/dist/chunks/{es-BGRMZbe9.js.map → es-FkgECuCm.js.map} +1 -1
- package/dist/chunks/grModalEscStack-BXk-9mv7.js +43 -0
- package/dist/chunks/grModalEscStack-BXk-9mv7.js.map +1 -0
- package/dist/chunks/{ru-BFCnOiML.js → ru-Bl8CxpEa.js} +8 -2
- package/dist/chunks/{ru-BFCnOiML.js.map → ru-Bl8CxpEa.js.map} +1 -1
- package/dist/chunks/{shared-ChvcQgDl.js → shared-B6Ay2081.js} +17 -11
- package/dist/chunks/shared-B6Ay2081.js.map +1 -0
- package/dist/chunks/{transition-TLFw4KBn.js → useScrollLock-K7kaP2Ud.js} +52 -1
- package/dist/chunks/useScrollLock-K7kaP2Ud.js.map +1 -0
- package/dist/components/GrConfirmDialog/chunks/{GrConfirmDialog-BWYKCsHd.js → GrConfirmDialog-D8CkOtqv.js} +1 -1
- package/dist/components/GrConfirmDialog/chunks/{GrConfirmDialog-BWYKCsHd.js.map → GrConfirmDialog-D8CkOtqv.js.map} +1 -1
- package/dist/components/GrConfirmDialog/index.js +2 -2
- package/dist/components/GrDataTable/chunks/{GrDataTable-ptbARmJ3.js → GrDataTable-Ds5OeGat.js} +42 -16
- package/dist/components/GrDataTable/chunks/GrDataTable-Ds5OeGat.js.map +1 -0
- package/dist/components/GrDataTable/index.js +1 -1
- package/dist/components/GrDialog/chunks/{GrDialog-5DAS-1Lb.js → GrDialog-Ctucxju9.js} +2 -2
- package/dist/components/GrDialog/chunks/{GrDialog-5DAS-1Lb.js.map → GrDialog-Ctucxju9.js.map} +1 -1
- package/dist/components/GrDialog/index.js +1 -1
- package/dist/components/GrDialogService/chunks/{GrDialogService-DY_fmaMu.js → GrDialogService-CU1Fbonc.js} +2 -2
- package/dist/components/GrDialogService/chunks/{GrDialogService-DY_fmaMu.js.map → GrDialogService-CU1Fbonc.js.map} +1 -1
- package/dist/components/GrDialogService/index.js +1 -1
- package/dist/components/GrDivider/chunks/GrDivider-5bcE-BB4.js +54 -0
- package/dist/components/GrDivider/chunks/GrDivider-5bcE-BB4.js.map +1 -0
- package/dist/components/GrDivider/index.js +3 -0
- package/dist/components/GrDrawer/chunks/{GrDrawer-D1kzsjXN.js → GrDrawer-SLGKCY2A.js} +37 -13
- package/dist/components/GrDrawer/chunks/GrDrawer-SLGKCY2A.js.map +1 -0
- package/dist/components/GrDrawer/index.js +2 -2
- package/dist/components/GrDropdown/chunks/{GrDropdown-BXb5Cxxf.js → GrDropdown-BnDMYP8v.js} +90 -4
- package/dist/components/GrDropdown/chunks/GrDropdown-BnDMYP8v.js.map +1 -0
- package/dist/components/GrDropdown/index.js +1 -1
- package/dist/components/GrDropdownMenu/chunks/{GrDropdownMenu-DFEJLPcV.js → GrDropdownMenu--g9Vofcq.js} +1 -1
- package/dist/components/GrDropdownMenu/chunks/{GrDropdownMenu-DFEJLPcV.js.map → GrDropdownMenu--g9Vofcq.js.map} +1 -1
- package/dist/components/GrDropdownMenu/index.js +1 -1
- package/dist/components/GrFormField/chunks/GrFormField-DnfMHx_U.js +73 -0
- package/dist/components/GrFormField/chunks/GrFormField-DnfMHx_U.js.map +1 -0
- package/dist/components/GrFormField/index.js +3 -2
- package/dist/components/GrImageViewer/chunks/{GrImageViewer-OCUIrNh2.js → GrImageViewer-Dla9IBkd.js} +311 -222
- package/dist/components/GrImageViewer/chunks/GrImageViewer-Dla9IBkd.js.map +1 -0
- package/dist/components/GrImageViewer/index.js +1 -1
- package/dist/components/GrInput/chunks/GrInput-B8dd3JaA.js +334 -0
- package/dist/components/GrInput/chunks/GrInput-B8dd3JaA.js.map +1 -0
- package/dist/components/GrInput/index.js +1 -1
- package/dist/components/GrKbd/chunks/GrKbd-BEoYxWhE.js +22 -0
- package/dist/components/GrKbd/chunks/GrKbd-BEoYxWhE.js.map +1 -0
- package/dist/components/GrKbd/index.js +3 -0
- package/dist/components/GrModal/chunks/{GrModal-BkjW9jZS.js → GrModal-C0GZrHN3.js} +3 -56
- package/dist/components/GrModal/chunks/GrModal-C0GZrHN3.js.map +1 -0
- package/dist/components/GrModal/index.js +1 -1
- package/dist/components/GrNumberInput/chunks/{GrNumberInput-CldPIWQx.js → GrNumberInput-DxCEvL7V.js} +93 -11
- package/dist/components/GrNumberInput/chunks/GrNumberInput-DxCEvL7V.js.map +1 -0
- package/dist/components/GrNumberInput/index.js +1 -1
- package/dist/components/GrPagination/chunks/{GrPagination-Bu9wv6it.js → GrPagination-mlyfLjQY.js} +1 -1
- package/dist/components/GrPagination/chunks/{GrPagination-Bu9wv6it.js.map → GrPagination-mlyfLjQY.js.map} +1 -1
- package/dist/components/GrPagination/index.js +2 -2
- package/dist/components/GrProgressBar/index.js +1 -1
- package/dist/components/GrPromptDialog/chunks/{GrPromptDialog-TmWXbpEP.js → GrPromptDialog-C-_BMNuY.js} +3 -3
- package/dist/components/GrPromptDialog/chunks/{GrPromptDialog-TmWXbpEP.js.map → GrPromptDialog-C-_BMNuY.js.map} +1 -1
- package/dist/components/GrPromptDialog/index.js +1 -1
- package/dist/components/GrRadio/chunks/{GrRadio-CPTixXaY.js → GrRadio-Dr-pvs_9.js} +1 -1
- package/dist/components/GrRadio/chunks/{GrRadio-CPTixXaY.js.map → GrRadio-Dr-pvs_9.js.map} +1 -1
- package/dist/components/GrRadio/index.js +2 -2
- package/dist/components/GrRadioGroup/chunks/{GrRadioGroup-vKZCbkCp.js → GrRadioGroup-nOdvfV_g.js} +1 -1
- package/dist/components/GrRadioGroup/chunks/{GrRadioGroup-vKZCbkCp.js.map → GrRadioGroup-nOdvfV_g.js.map} +1 -1
- package/dist/components/GrRadioGroup/index.js +1 -1
- package/dist/components/GrSelect/chunks/{GrSelect-RShK21lK.js → GrSelect-BVCmitqa.js} +147 -27
- package/dist/components/GrSelect/chunks/GrSelect-BVCmitqa.js.map +1 -0
- package/dist/components/GrSelect/index.js +1 -1
- package/dist/components/GrSidebar/index.js +1 -1
- package/dist/components/GrTabPanels/chunks/GrTabPanels-DbKybwe-.js +68 -0
- package/dist/components/GrTabPanels/chunks/GrTabPanels-DbKybwe-.js.map +1 -0
- package/dist/components/GrTabPanels/index.js +3 -0
- package/dist/components/GrTabs/chunks/{GrTabs-Z-FDJUr_.js → GrTabs-DsLwWoRz.js} +6 -1
- package/dist/components/GrTabs/chunks/GrTabs-DsLwWoRz.js.map +1 -0
- package/dist/components/GrTabs/index.js +1 -1
- package/dist/components/GrTextarea/chunks/{GrTextarea-D56YxhKq.js → GrTextarea-CKukGlNl.js} +15 -5
- package/dist/components/GrTextarea/chunks/GrTextarea-CKukGlNl.js.map +1 -0
- package/dist/components/GrTextarea/index.js +2 -2
- package/dist/components/GrToaster/chunks/{GrToaster-eI8YvnIo.js → GrToaster-L2cu6cSR.js} +1 -1
- package/dist/components/GrToaster/chunks/{GrToaster-eI8YvnIo.js.map → GrToaster-L2cu6cSR.js.map} +1 -1
- package/dist/components/GrToaster/index.js +2 -2
- package/dist/components/GrTree/chunks/{GrTree-D3ODe2dB.js → GrTree-B2_yW6g1.js} +107 -8
- package/dist/components/GrTree/chunks/GrTree-B2_yW6g1.js.map +1 -0
- package/dist/components/GrTree/index.js +2 -2
- package/dist/components/GrTreeSelect/chunks/{GrTreeSelect-B2xBKs5Q.js → GrTreeSelect-0aM62xyu.js} +3 -3
- package/dist/components/GrTreeSelect/chunks/{GrTreeSelect-B2xBKs5Q.js.map → GrTreeSelect-0aM62xyu.js.map} +1 -1
- package/dist/components/GrTreeSelect/index.js +2 -2
- package/dist/granular-provider-node.js +2 -2
- package/dist/granular-provider.js +1 -1
- package/dist/i18n/all.js +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/index.js +40 -33
- package/dist/index.js.map +1 -1
- package/dist/styles/base.css +30 -8
- package/dist/styles/preflight.css +5 -1
- package/dist/types/src/components/GrDataTable/GrDataTable.vue.d.ts +28 -4
- package/dist/types/src/components/GrDivider/GrDivider.vue.d.ts +58 -0
- package/dist/types/src/components/GrDivider/config.d.ts +1 -0
- package/dist/types/src/components/GrDivider/index.d.ts +4 -0
- package/dist/types/src/components/GrDrawer/GrDrawer.vue.d.ts +4 -4
- package/dist/types/src/components/GrDropdown/GrDropdown.vue.d.ts +7 -0
- package/dist/types/src/components/GrDropdownMenu/GrDropdownMenu.vue.d.ts +6 -0
- package/dist/types/src/components/GrFormField/GrFormField.vue.d.ts +15 -2
- package/dist/types/src/components/GrFormField/context.d.ts +20 -0
- package/dist/types/src/components/GrFormField/index.d.ts +1 -0
- package/dist/types/src/components/GrImageViewer/GrImageViewer.vue.d.ts +4 -0
- package/dist/types/src/components/GrImageViewer/composables/useViewerKeyboard.d.ts +20 -0
- package/dist/types/src/components/GrImageViewer/composables/useWheelGesture.d.ts +16 -0
- package/dist/types/src/components/GrImageViewer/composables/useZoomPan.d.ts +50 -0
- package/dist/types/src/components/GrInput/GrInput.vue.d.ts +41 -2
- package/dist/types/src/components/GrKbd/GrKbd.vue.d.ts +46 -0
- package/dist/types/src/components/GrKbd/config.d.ts +1 -0
- package/dist/types/src/components/GrKbd/index.d.ts +4 -0
- package/dist/types/src/components/GrNumberInput/GrNumberInput.vue.d.ts +16 -0
- package/dist/types/src/components/GrSelect/GrSelect.vue.d.ts +2 -2
- package/dist/types/src/components/GrTabPanels/GrTabPanel.vue.d.ts +46 -0
- package/dist/types/src/components/GrTabPanels/GrTabPanels.vue.d.ts +51 -0
- package/dist/types/src/components/GrTabPanels/config.d.ts +5 -0
- package/dist/types/src/components/GrTabPanels/context.d.ts +9 -0
- package/dist/types/src/components/GrTabPanels/index.d.ts +6 -0
- package/dist/types/src/components/GrTabs/GrTabs.vue.d.ts +6 -0
- package/dist/types/src/components/GrTree/grTreeInteractionContext.d.ts +2 -0
- package/dist/types/src/composables/internal/useScrollLock.d.ts +24 -0
- package/dist/types/src/granular-provider/shared.d.ts +3 -0
- package/dist/types/src/i18n/messages/en.d.ts +10 -0
- package/dist/types/src/i18n/messages/es.d.ts +10 -0
- package/dist/types/src/i18n/messages/ru.d.ts +10 -0
- package/dist/types/src/index.d.ts +3 -0
- package/dist/web-types.json +275 -26
- package/package.json +13 -1
- package/dist/chunks/config-1uSYl98Y.js.map +0 -1
- package/dist/chunks/config-BIRO0vDJ2.js.map +0 -1
- package/dist/chunks/config-BXtAmU3s.js.map +0 -1
- package/dist/chunks/config-CGHLoBlH2.js.map +0 -1
- package/dist/chunks/config-CrG1XiE7.js.map +0 -1
- package/dist/chunks/config-DUcu1D68.js.map +0 -1
- package/dist/chunks/config-DnvPqu4g.js.map +0 -1
- package/dist/chunks/config-DpqOnJiz2.js.map +0 -1
- package/dist/chunks/config-JpHA4Xx0.js.map +0 -1
- package/dist/chunks/config-LGrZIdaZ2.js.map +0 -1
- package/dist/chunks/shared-ChvcQgDl.js.map +0 -1
- package/dist/chunks/transition-TLFw4KBn.js.map +0 -1
- package/dist/components/GrDataTable/chunks/GrDataTable-ptbARmJ3.js.map +0 -1
- package/dist/components/GrDrawer/chunks/GrDrawer-D1kzsjXN.js.map +0 -1
- package/dist/components/GrDropdown/chunks/GrDropdown-BXb5Cxxf.js.map +0 -1
- package/dist/components/GrFormField/chunks/GrFormField-BujNQrw8.js +0 -35
- package/dist/components/GrFormField/chunks/GrFormField-BujNQrw8.js.map +0 -1
- package/dist/components/GrImageViewer/chunks/GrImageViewer-OCUIrNh2.js.map +0 -1
- package/dist/components/GrInput/chunks/GrInput-C8pOJgCi.js +0 -188
- package/dist/components/GrInput/chunks/GrInput-C8pOJgCi.js.map +0 -1
- package/dist/components/GrModal/chunks/GrModal-BkjW9jZS.js.map +0 -1
- package/dist/components/GrNumberInput/chunks/GrNumberInput-CldPIWQx.js.map +0 -1
- package/dist/components/GrSelect/chunks/GrSelect-RShK21lK.js.map +0 -1
- package/dist/components/GrTabs/chunks/GrTabs-Z-FDJUr_.js.map +0 -1
- package/dist/components/GrTextarea/chunks/GrTextarea-D56YxhKq.js.map +0 -1
- package/dist/components/GrTree/chunks/GrTree-D3ODe2dB.js.map +0 -1
- /package/dist/chunks/{config-1uSYl98Y.js → config-1uSYl98Y2.js} +0 -0
- /package/dist/chunks/{config-BIRO0vDJ2.js → config-BIRO0vDJ.js} +0 -0
- /package/dist/chunks/{config-BXtAmU3s.js → config-BXtAmU3s2.js} +0 -0
- /package/dist/chunks/{config-CGHLoBlH2.js → config-CGHLoBlH.js} +0 -0
- /package/dist/chunks/{config-CrG1XiE7.js → config-CrG1XiE72.js} +0 -0
- /package/dist/chunks/{config-DUcu1D68.js → config-DUcu1D682.js} +0 -0
- /package/dist/chunks/{config-DnvPqu4g.js → config-DnvPqu4g2.js} +0 -0
- /package/dist/chunks/{config-DpqOnJiz2.js → config-DpqOnJiz.js} +0 -0
- /package/dist/chunks/{config-JpHA4Xx0.js → config-JpHA4Xx02.js} +0 -0
- /package/dist/chunks/{config-LGrZIdaZ2.js → config-LGrZIdaZ.js} +0 -0
package/dist/components/GrImageViewer/chunks/{GrImageViewer-OCUIrNh2.js → GrImageViewer-Dla9IBkd.js}
RENAMED
|
@@ -1,6 +1,250 @@
|
|
|
1
1
|
import { t as useGranularityTranslations } from "../../../chunks/granularityI18n-DoV7Ca2m.js";
|
|
2
|
-
import {
|
|
2
|
+
import { i as Ge, n as Se, r as he, s as Ye, t as useScrollLock } from "../../../chunks/useScrollLock-K7kaP2Ud.js";
|
|
3
3
|
import { Fragment, Teleport, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, guardReactiveProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onBeforeUnmount, openBlock, ref, renderSlot, toDisplayString, unref, watch, withCtx } from "vue";
|
|
4
|
+
//#region src/components/GrImageViewer/composables/useZoomPan.ts
|
|
5
|
+
var TRAILING_ZERO_DECIMAL_RE = /\.0$/;
|
|
6
|
+
function formatPercent(value) {
|
|
7
|
+
if (Number.isInteger(value)) return String(value);
|
|
8
|
+
return value.toFixed(1).replace(TRAILING_ZERO_DECIMAL_RE, "");
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* useZoomPan — состояние и логика масштаба/поворота/панорамирования картинки,
|
|
12
|
+
* а также метрики (натуральный/вписанный/фактический размер, реальный масштаб).
|
|
13
|
+
* Вынесено из монолитного `GrImageViewer.vue`.
|
|
14
|
+
*/
|
|
15
|
+
function useZoomPan(options) {
|
|
16
|
+
const scale = ref(1);
|
|
17
|
+
const rotation = ref(0);
|
|
18
|
+
const offsetX = ref(0);
|
|
19
|
+
const offsetY = ref(0);
|
|
20
|
+
const isDragging = ref(false);
|
|
21
|
+
let dragStartX = 0;
|
|
22
|
+
let dragStartY = 0;
|
|
23
|
+
let dragOffsetStartX = 0;
|
|
24
|
+
let dragOffsetStartY = 0;
|
|
25
|
+
const naturalWidth = ref(0);
|
|
26
|
+
const naturalHeight = ref(0);
|
|
27
|
+
const fittedWidth = ref(0);
|
|
28
|
+
const fittedHeight = ref(0);
|
|
29
|
+
let resizeObserver = null;
|
|
30
|
+
const imageStyle = computed(() => ({ transform: `translate3d(${offsetX.value}px, ${offsetY.value}px, 0) scale(${scale.value}) rotate(${rotation.value}deg)` }));
|
|
31
|
+
const zoomValueText = computed(() => formatPercent(scale.value * 100));
|
|
32
|
+
const renderedWidth = computed(() => Math.round(fittedWidth.value * scale.value));
|
|
33
|
+
const renderedHeight = computed(() => Math.round(fittedHeight.value * scale.value));
|
|
34
|
+
const realScale = computed(() => {
|
|
35
|
+
if (!naturalWidth.value) return 0;
|
|
36
|
+
return fittedWidth.value * scale.value / naturalWidth.value;
|
|
37
|
+
});
|
|
38
|
+
const realScalePercent = computed(() => formatPercent(realScale.value * 100));
|
|
39
|
+
function setScale(value) {
|
|
40
|
+
const clamped = Math.min(options.maxScale(), Math.max(options.minScale(), value));
|
|
41
|
+
scale.value = Number(clamped.toFixed(4));
|
|
42
|
+
}
|
|
43
|
+
function zoomIn() {
|
|
44
|
+
setScale(scale.value * options.zoomRate());
|
|
45
|
+
}
|
|
46
|
+
function zoomOut() {
|
|
47
|
+
setScale(scale.value / options.zoomRate());
|
|
48
|
+
}
|
|
49
|
+
function rotateLeft() {
|
|
50
|
+
rotation.value -= 90;
|
|
51
|
+
options.onRotate(rotation.value);
|
|
52
|
+
}
|
|
53
|
+
function rotateRight() {
|
|
54
|
+
rotation.value += 90;
|
|
55
|
+
options.onRotate(rotation.value);
|
|
56
|
+
}
|
|
57
|
+
function resetTransform() {
|
|
58
|
+
scale.value = 1;
|
|
59
|
+
rotation.value = 0;
|
|
60
|
+
offsetX.value = 0;
|
|
61
|
+
offsetY.value = 0;
|
|
62
|
+
isDragging.value = false;
|
|
63
|
+
}
|
|
64
|
+
function resetImageMetrics() {
|
|
65
|
+
naturalWidth.value = 0;
|
|
66
|
+
naturalHeight.value = 0;
|
|
67
|
+
fittedWidth.value = 0;
|
|
68
|
+
fittedHeight.value = 0;
|
|
69
|
+
}
|
|
70
|
+
function measureFitted() {
|
|
71
|
+
const el = options.imageEl.value;
|
|
72
|
+
if (!el) return;
|
|
73
|
+
fittedWidth.value = el.offsetWidth;
|
|
74
|
+
fittedHeight.value = el.offsetHeight;
|
|
75
|
+
}
|
|
76
|
+
function onImageLoad(event) {
|
|
77
|
+
const el = event.target;
|
|
78
|
+
naturalWidth.value = el.naturalWidth;
|
|
79
|
+
naturalHeight.value = el.naturalHeight;
|
|
80
|
+
measureFitted();
|
|
81
|
+
}
|
|
82
|
+
function startObservingImage() {
|
|
83
|
+
const el = options.imageEl.value;
|
|
84
|
+
if (!el || typeof ResizeObserver === "undefined") return;
|
|
85
|
+
if (!resizeObserver) resizeObserver = new ResizeObserver(() => measureFitted());
|
|
86
|
+
resizeObserver.observe(el);
|
|
87
|
+
if (el.complete && el.naturalWidth) {
|
|
88
|
+
naturalWidth.value = el.naturalWidth;
|
|
89
|
+
naturalHeight.value = el.naturalHeight;
|
|
90
|
+
}
|
|
91
|
+
measureFitted();
|
|
92
|
+
}
|
|
93
|
+
function stopObservingImage() {
|
|
94
|
+
resizeObserver?.disconnect();
|
|
95
|
+
}
|
|
96
|
+
function onPointerDown(event) {
|
|
97
|
+
if (!options.draggable() || event.button !== 0) return;
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
isDragging.value = true;
|
|
100
|
+
dragStartX = event.clientX;
|
|
101
|
+
dragStartY = event.clientY;
|
|
102
|
+
dragOffsetStartX = offsetX.value;
|
|
103
|
+
dragOffsetStartY = offsetY.value;
|
|
104
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
105
|
+
}
|
|
106
|
+
function onPointerMove(event) {
|
|
107
|
+
if (!isDragging.value) return;
|
|
108
|
+
offsetX.value = dragOffsetStartX + (event.clientX - dragStartX);
|
|
109
|
+
offsetY.value = dragOffsetStartY + (event.clientY - dragStartY);
|
|
110
|
+
}
|
|
111
|
+
function onPointerUp(event) {
|
|
112
|
+
if (!isDragging.value) return;
|
|
113
|
+
isDragging.value = false;
|
|
114
|
+
event.currentTarget.releasePointerCapture?.(event.pointerId);
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
scale,
|
|
118
|
+
rotation,
|
|
119
|
+
offsetX,
|
|
120
|
+
offsetY,
|
|
121
|
+
isDragging,
|
|
122
|
+
naturalWidth,
|
|
123
|
+
naturalHeight,
|
|
124
|
+
fittedWidth,
|
|
125
|
+
fittedHeight,
|
|
126
|
+
imageStyle,
|
|
127
|
+
zoomValueText,
|
|
128
|
+
renderedWidth,
|
|
129
|
+
renderedHeight,
|
|
130
|
+
realScale,
|
|
131
|
+
realScalePercent,
|
|
132
|
+
setScale,
|
|
133
|
+
zoomIn,
|
|
134
|
+
zoomOut,
|
|
135
|
+
rotateLeft,
|
|
136
|
+
rotateRight,
|
|
137
|
+
resetTransform,
|
|
138
|
+
resetImageMetrics,
|
|
139
|
+
measureFitted,
|
|
140
|
+
onImageLoad,
|
|
141
|
+
startObservingImage,
|
|
142
|
+
stopObservingImage,
|
|
143
|
+
onPointerDown,
|
|
144
|
+
onPointerMove,
|
|
145
|
+
onPointerUp
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/components/GrImageViewer/composables/useWheelGesture.ts
|
|
150
|
+
var WHEEL_ZOOM_SENSITIVITY = .0015;
|
|
151
|
+
var WHEEL_IDLE_MS = 120;
|
|
152
|
+
/**
|
|
153
|
+
* useWheelGesture — масштабирование колесом мыши / жестом трекпада с батчингом
|
|
154
|
+
* по `requestAnimationFrame` (рендер не чаще кадра — без «дёрганья»/наслоения) и
|
|
155
|
+
* временным отключением CSS-перехода на время жеста (`isWheelZooming`).
|
|
156
|
+
*/
|
|
157
|
+
function useWheelGesture(options) {
|
|
158
|
+
const isWheelZooming = ref(false);
|
|
159
|
+
let pendingWheelDelta = 0;
|
|
160
|
+
let wheelFrameId = null;
|
|
161
|
+
let wheelIdleTimer = null;
|
|
162
|
+
function cancelWheelFrame() {
|
|
163
|
+
if (wheelFrameId !== null) {
|
|
164
|
+
cancelAnimationFrame(wheelFrameId);
|
|
165
|
+
wheelFrameId = null;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function endWheelZoom() {
|
|
169
|
+
if (wheelIdleTimer !== null) {
|
|
170
|
+
clearTimeout(wheelIdleTimer);
|
|
171
|
+
wheelIdleTimer = null;
|
|
172
|
+
}
|
|
173
|
+
isWheelZooming.value = false;
|
|
174
|
+
pendingWheelDelta = 0;
|
|
175
|
+
cancelWheelFrame();
|
|
176
|
+
}
|
|
177
|
+
function flushWheelZoom() {
|
|
178
|
+
wheelFrameId = null;
|
|
179
|
+
const delta = pendingWheelDelta;
|
|
180
|
+
pendingWheelDelta = 0;
|
|
181
|
+
if (!delta) return;
|
|
182
|
+
const factor = Math.exp(-delta * WHEEL_ZOOM_SENSITIVITY);
|
|
183
|
+
options.applyZoomFactor(factor);
|
|
184
|
+
}
|
|
185
|
+
function onWheel(event) {
|
|
186
|
+
if (!options.enabled()) return;
|
|
187
|
+
event.preventDefault();
|
|
188
|
+
isWheelZooming.value = true;
|
|
189
|
+
pendingWheelDelta += event.deltaY;
|
|
190
|
+
if (wheelFrameId === null) wheelFrameId = requestAnimationFrame(flushWheelZoom);
|
|
191
|
+
if (wheelIdleTimer !== null) clearTimeout(wheelIdleTimer);
|
|
192
|
+
wheelIdleTimer = setTimeout(() => {
|
|
193
|
+
wheelIdleTimer = null;
|
|
194
|
+
isWheelZooming.value = false;
|
|
195
|
+
}, WHEEL_IDLE_MS);
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
isWheelZooming,
|
|
199
|
+
onWheel,
|
|
200
|
+
endWheelZoom
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region src/components/GrImageViewer/composables/useViewerKeyboard.ts
|
|
205
|
+
/**
|
|
206
|
+
* useViewerKeyboard — клавиатурное управление просмотрщиком:
|
|
207
|
+
* Esc — закрыть, стрелки — переключение, `+`/`-`/`0` — зум/сброс.
|
|
208
|
+
*/
|
|
209
|
+
function useViewerKeyboard(options) {
|
|
210
|
+
const { actions } = options;
|
|
211
|
+
function onKeydown(event) {
|
|
212
|
+
switch (event.key) {
|
|
213
|
+
case "Escape":
|
|
214
|
+
if (!options.closeOnEscape()) return;
|
|
215
|
+
event.preventDefault();
|
|
216
|
+
actions.close();
|
|
217
|
+
return;
|
|
218
|
+
case "ArrowLeft":
|
|
219
|
+
event.preventDefault();
|
|
220
|
+
actions.prev();
|
|
221
|
+
return;
|
|
222
|
+
case "ArrowRight":
|
|
223
|
+
event.preventDefault();
|
|
224
|
+
actions.next();
|
|
225
|
+
return;
|
|
226
|
+
case "+":
|
|
227
|
+
case "=":
|
|
228
|
+
case "Add":
|
|
229
|
+
event.preventDefault();
|
|
230
|
+
actions.zoomIn();
|
|
231
|
+
return;
|
|
232
|
+
case "-":
|
|
233
|
+
case "_":
|
|
234
|
+
case "Subtract":
|
|
235
|
+
event.preventDefault();
|
|
236
|
+
actions.zoomOut();
|
|
237
|
+
return;
|
|
238
|
+
case "0":
|
|
239
|
+
event.preventDefault();
|
|
240
|
+
actions.reset();
|
|
241
|
+
break;
|
|
242
|
+
default:
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return { onKeydown };
|
|
246
|
+
}
|
|
247
|
+
//#endregion
|
|
4
248
|
//#region src/components/GrImageViewer/GrImageViewer.vue?vue&type=script&setup=true&lang.ts
|
|
5
249
|
var _hoisted_1 = { class: "fixed inset-0 overflow-hidden" };
|
|
6
250
|
var _hoisted_2 = { class: "pointer-events-none absolute inset-x-0 top-0 z-30 px-3 py-3 sm:px-6" };
|
|
@@ -39,8 +283,6 @@ var _hoisted_19 = {
|
|
|
39
283
|
var _hoisted_20 = ["aria-label"];
|
|
40
284
|
var _hoisted_21 = ["aria-label"];
|
|
41
285
|
var DEFAULT_Z_INDEX = 2e3;
|
|
42
|
-
var WHEEL_ZOOM_SENSITIVITY = .0015;
|
|
43
|
-
var WHEEL_IDLE_MS = 120;
|
|
44
286
|
//#endregion
|
|
45
287
|
//#region src/components/GrImageViewer/GrImageViewer.vue
|
|
46
288
|
var GrImageViewer_default = /* @__PURE__ */ defineComponent({
|
|
@@ -106,114 +348,37 @@ var GrImageViewer_default = /* @__PURE__ */ defineComponent({
|
|
|
106
348
|
const resolvedRotateRightLabel = computed(() => props.rotateRightLabel ?? t("gr.imageViewer.rotateRight", "Rotate right"));
|
|
107
349
|
const resolvedEmptyText = computed(() => props.emptyText ?? t("gr.imageViewer.empty", "No image"));
|
|
108
350
|
const emit = __emit;
|
|
109
|
-
const TRAILING_ZERO_DECIMAL_RE = /\.0$/;
|
|
110
351
|
const open = computed(() => props.modelValue);
|
|
352
|
+
const isClient = typeof window !== "undefined";
|
|
353
|
+
const { lock: lockBodyScroll, unlock: unlockBodyScroll } = useScrollLock();
|
|
111
354
|
const total = computed(() => props.urlList.length);
|
|
112
355
|
const hasImages = computed(() => total.value > 0);
|
|
113
356
|
const currentIndex = ref(0);
|
|
114
|
-
const scale = ref(1);
|
|
115
|
-
const rotation = ref(0);
|
|
116
|
-
const offsetX = ref(0);
|
|
117
|
-
const offsetY = ref(0);
|
|
118
357
|
const imageEl = ref(null);
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
let dragOffsetStartX = 0;
|
|
127
|
-
let dragOffsetStartY = 0;
|
|
128
|
-
const naturalWidth = ref(0);
|
|
129
|
-
const naturalHeight = ref(0);
|
|
130
|
-
const fittedWidth = ref(0);
|
|
131
|
-
const fittedHeight = ref(0);
|
|
132
|
-
let resizeObserver = null;
|
|
133
|
-
const currentUrl = computed(() => {
|
|
134
|
-
if (!hasImages.value) return;
|
|
135
|
-
return props.urlList[currentIndex.value];
|
|
358
|
+
const { scale, rotation, isDragging, naturalWidth, naturalHeight, renderedWidth, renderedHeight, realScale, realScalePercent, imageStyle, zoomValueText, setScale, zoomIn, zoomOut, rotateLeft, rotateRight, resetTransform, resetImageMetrics, onImageLoad, startObservingImage, stopObservingImage, onPointerDown, onPointerMove, onPointerUp } = useZoomPan({
|
|
359
|
+
minScale: () => props.minScale,
|
|
360
|
+
maxScale: () => props.maxScale,
|
|
361
|
+
zoomRate: () => props.zoomRate,
|
|
362
|
+
draggable: () => props.draggable,
|
|
363
|
+
imageEl,
|
|
364
|
+
onRotate: (deg) => emit("rotate", deg)
|
|
136
365
|
});
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
366
|
+
const { isWheelZooming, onWheel, endWheelZoom } = useWheelGesture({
|
|
367
|
+
enabled: () => props.wheelZoom && hasImages.value,
|
|
368
|
+
applyZoomFactor: (factor) => setScale(scale.value * factor)
|
|
140
369
|
});
|
|
370
|
+
const currentUrl = computed(() => hasImages.value ? props.urlList[currentIndex.value] : void 0);
|
|
371
|
+
const displayIndex = computed(() => hasImages.value ? currentIndex.value + 1 : 0);
|
|
141
372
|
const viewerStyle = computed(() => ({ zIndex: String(Number.isFinite(props.zIndex) ? props.zIndex : DEFAULT_Z_INDEX) }));
|
|
142
|
-
const imageStyle = computed(() => ({ transform: `translate3d(${offsetX.value}px, ${offsetY.value}px, 0) scale(${scale.value}) rotate(${rotation.value}deg)` }));
|
|
143
373
|
const imageTransitionClass = computed(() => isWheelZooming.value || isDragging.value ? "" : "transition-transform duration-150 ease-out");
|
|
144
374
|
const imageCursorClass = computed(() => {
|
|
145
375
|
if (!props.draggable) return "";
|
|
146
376
|
return isDragging.value ? "cursor-grabbing" : "cursor-grab";
|
|
147
377
|
});
|
|
148
|
-
function formatPercent(value) {
|
|
149
|
-
if (Number.isInteger(value)) return String(value);
|
|
150
|
-
return value.toFixed(1).replace(TRAILING_ZERO_DECIMAL_RE, "");
|
|
151
|
-
}
|
|
152
|
-
const zoomValueText = computed(() => formatPercent(scale.value * 100));
|
|
153
|
-
const renderedWidth = computed(() => Math.round(fittedWidth.value * scale.value));
|
|
154
|
-
const renderedHeight = computed(() => Math.round(fittedHeight.value * scale.value));
|
|
155
|
-
const realScale = computed(() => {
|
|
156
|
-
if (!naturalWidth.value) return 0;
|
|
157
|
-
return fittedWidth.value * scale.value / naturalWidth.value;
|
|
158
|
-
});
|
|
159
|
-
const realScalePercent = computed(() => formatPercent(realScale.value * 100));
|
|
160
|
-
const toolbarSlotProps = computed(() => ({
|
|
161
|
-
index: currentIndex.value,
|
|
162
|
-
displayIndex: displayIndex.value,
|
|
163
|
-
total: total.value,
|
|
164
|
-
scale: scale.value,
|
|
165
|
-
rotation: rotation.value,
|
|
166
|
-
naturalWidth: naturalWidth.value,
|
|
167
|
-
naturalHeight: naturalHeight.value,
|
|
168
|
-
renderedWidth: renderedWidth.value,
|
|
169
|
-
renderedHeight: renderedHeight.value,
|
|
170
|
-
realScale: realScale.value,
|
|
171
|
-
realScalePercent: realScalePercent.value,
|
|
172
|
-
actions: toolbarActions
|
|
173
|
-
}));
|
|
174
378
|
function normalizeIndex(value) {
|
|
175
379
|
if (!hasImages.value) return 0;
|
|
176
380
|
return ((Number.isFinite(value) ? Math.trunc(value) : 0) % total.value + total.value) % total.value;
|
|
177
381
|
}
|
|
178
|
-
function resetTransform() {
|
|
179
|
-
scale.value = 1;
|
|
180
|
-
rotation.value = 0;
|
|
181
|
-
offsetX.value = 0;
|
|
182
|
-
offsetY.value = 0;
|
|
183
|
-
isDragging.value = false;
|
|
184
|
-
}
|
|
185
|
-
function resetImageMetrics() {
|
|
186
|
-
naturalWidth.value = 0;
|
|
187
|
-
naturalHeight.value = 0;
|
|
188
|
-
fittedWidth.value = 0;
|
|
189
|
-
fittedHeight.value = 0;
|
|
190
|
-
}
|
|
191
|
-
function measureFitted() {
|
|
192
|
-
const el = imageEl.value;
|
|
193
|
-
if (!el) return;
|
|
194
|
-
fittedWidth.value = el.offsetWidth;
|
|
195
|
-
fittedHeight.value = el.offsetHeight;
|
|
196
|
-
}
|
|
197
|
-
function onImageLoad(event) {
|
|
198
|
-
const el = event.target;
|
|
199
|
-
naturalWidth.value = el.naturalWidth;
|
|
200
|
-
naturalHeight.value = el.naturalHeight;
|
|
201
|
-
measureFitted();
|
|
202
|
-
}
|
|
203
|
-
function startObservingImage() {
|
|
204
|
-
const el = imageEl.value;
|
|
205
|
-
if (!el || typeof ResizeObserver === "undefined") return;
|
|
206
|
-
if (!resizeObserver) resizeObserver = new ResizeObserver(() => measureFitted());
|
|
207
|
-
resizeObserver.observe(el);
|
|
208
|
-
if (el.complete && el.naturalWidth) {
|
|
209
|
-
naturalWidth.value = el.naturalWidth;
|
|
210
|
-
naturalHeight.value = el.naturalHeight;
|
|
211
|
-
}
|
|
212
|
-
measureFitted();
|
|
213
|
-
}
|
|
214
|
-
function stopObservingImage() {
|
|
215
|
-
resizeObserver?.disconnect();
|
|
216
|
-
}
|
|
217
382
|
function setIndex(nextIndex, options) {
|
|
218
383
|
const normalizedIndex = normalizeIndex(nextIndex);
|
|
219
384
|
if (normalizedIndex === currentIndex.value) return;
|
|
@@ -250,79 +415,6 @@ var GrImageViewer_default = /* @__PURE__ */ defineComponent({
|
|
|
250
415
|
function next() {
|
|
251
416
|
setIndex(currentIndex.value + 1);
|
|
252
417
|
}
|
|
253
|
-
function setScale(value) {
|
|
254
|
-
const clamped = Math.min(props.maxScale, Math.max(props.minScale, value));
|
|
255
|
-
scale.value = Number(clamped.toFixed(4));
|
|
256
|
-
}
|
|
257
|
-
function zoomIn() {
|
|
258
|
-
setScale(scale.value * props.zoomRate);
|
|
259
|
-
}
|
|
260
|
-
function zoomOut() {
|
|
261
|
-
setScale(scale.value / props.zoomRate);
|
|
262
|
-
}
|
|
263
|
-
function cancelWheelFrame() {
|
|
264
|
-
if (wheelFrameId !== null) {
|
|
265
|
-
cancelAnimationFrame(wheelFrameId);
|
|
266
|
-
wheelFrameId = null;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
function endWheelZoom() {
|
|
270
|
-
if (wheelIdleTimer !== null) {
|
|
271
|
-
clearTimeout(wheelIdleTimer);
|
|
272
|
-
wheelIdleTimer = null;
|
|
273
|
-
}
|
|
274
|
-
isWheelZooming.value = false;
|
|
275
|
-
pendingWheelDelta = 0;
|
|
276
|
-
cancelWheelFrame();
|
|
277
|
-
}
|
|
278
|
-
function flushWheelZoom() {
|
|
279
|
-
wheelFrameId = null;
|
|
280
|
-
const delta = pendingWheelDelta;
|
|
281
|
-
pendingWheelDelta = 0;
|
|
282
|
-
if (!delta) return;
|
|
283
|
-
const factor = Math.exp(-delta * WHEEL_ZOOM_SENSITIVITY);
|
|
284
|
-
setScale(scale.value * factor);
|
|
285
|
-
}
|
|
286
|
-
function onWheel(event) {
|
|
287
|
-
if (!props.wheelZoom || !hasImages.value) return;
|
|
288
|
-
event.preventDefault();
|
|
289
|
-
isWheelZooming.value = true;
|
|
290
|
-
pendingWheelDelta += event.deltaY;
|
|
291
|
-
if (wheelFrameId === null) wheelFrameId = requestAnimationFrame(flushWheelZoom);
|
|
292
|
-
if (wheelIdleTimer !== null) clearTimeout(wheelIdleTimer);
|
|
293
|
-
wheelIdleTimer = setTimeout(() => {
|
|
294
|
-
wheelIdleTimer = null;
|
|
295
|
-
isWheelZooming.value = false;
|
|
296
|
-
}, WHEEL_IDLE_MS);
|
|
297
|
-
}
|
|
298
|
-
function onPointerDown(event) {
|
|
299
|
-
if (!props.draggable || !hasImages.value || event.button !== 0) return;
|
|
300
|
-
event.preventDefault();
|
|
301
|
-
isDragging.value = true;
|
|
302
|
-
dragStartX = event.clientX;
|
|
303
|
-
dragStartY = event.clientY;
|
|
304
|
-
dragOffsetStartX = offsetX.value;
|
|
305
|
-
dragOffsetStartY = offsetY.value;
|
|
306
|
-
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
307
|
-
}
|
|
308
|
-
function onPointerMove(event) {
|
|
309
|
-
if (!isDragging.value) return;
|
|
310
|
-
offsetX.value = dragOffsetStartX + (event.clientX - dragStartX);
|
|
311
|
-
offsetY.value = dragOffsetStartY + (event.clientY - dragStartY);
|
|
312
|
-
}
|
|
313
|
-
function onPointerUp(event) {
|
|
314
|
-
if (!isDragging.value) return;
|
|
315
|
-
isDragging.value = false;
|
|
316
|
-
event.currentTarget.releasePointerCapture?.(event.pointerId);
|
|
317
|
-
}
|
|
318
|
-
function rotateLeft() {
|
|
319
|
-
rotation.value -= 90;
|
|
320
|
-
emit("rotate", rotation.value);
|
|
321
|
-
}
|
|
322
|
-
function rotateRight() {
|
|
323
|
-
rotation.value += 90;
|
|
324
|
-
emit("rotate", rotation.value);
|
|
325
|
-
}
|
|
326
418
|
const toolbarActions = {
|
|
327
419
|
close: closeViewer,
|
|
328
420
|
prev,
|
|
@@ -333,51 +425,44 @@ var GrImageViewer_default = /* @__PURE__ */ defineComponent({
|
|
|
333
425
|
rotateLeft,
|
|
334
426
|
rotateRight
|
|
335
427
|
};
|
|
428
|
+
const toolbarSlotProps = computed(() => ({
|
|
429
|
+
index: currentIndex.value,
|
|
430
|
+
displayIndex: displayIndex.value,
|
|
431
|
+
total: total.value,
|
|
432
|
+
scale: scale.value,
|
|
433
|
+
rotation: rotation.value,
|
|
434
|
+
naturalWidth: naturalWidth.value,
|
|
435
|
+
naturalHeight: naturalHeight.value,
|
|
436
|
+
renderedWidth: renderedWidth.value,
|
|
437
|
+
renderedHeight: renderedHeight.value,
|
|
438
|
+
realScale: realScale.value,
|
|
439
|
+
realScalePercent: realScalePercent.value,
|
|
440
|
+
actions: toolbarActions
|
|
441
|
+
}));
|
|
336
442
|
function onBackdropClick() {
|
|
337
443
|
if (!props.hideOnClickModal) return;
|
|
338
444
|
closeViewer();
|
|
339
445
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
prev();
|
|
350
|
-
return;
|
|
351
|
-
case "ArrowRight":
|
|
352
|
-
event.preventDefault();
|
|
353
|
-
next();
|
|
354
|
-
return;
|
|
355
|
-
case "+":
|
|
356
|
-
case "=":
|
|
357
|
-
case "Add":
|
|
358
|
-
event.preventDefault();
|
|
359
|
-
zoomIn();
|
|
360
|
-
return;
|
|
361
|
-
case "-":
|
|
362
|
-
case "_":
|
|
363
|
-
case "Subtract":
|
|
364
|
-
event.preventDefault();
|
|
365
|
-
zoomOut();
|
|
366
|
-
return;
|
|
367
|
-
case "0":
|
|
368
|
-
event.preventDefault();
|
|
369
|
-
resetTransform();
|
|
370
|
-
break;
|
|
371
|
-
default:
|
|
446
|
+
const { onKeydown } = useViewerKeyboard({
|
|
447
|
+
closeOnEscape: () => props.closeOnPressEscape,
|
|
448
|
+
actions: {
|
|
449
|
+
close: closeViewer,
|
|
450
|
+
prev,
|
|
451
|
+
next,
|
|
452
|
+
zoomIn,
|
|
453
|
+
zoomOut,
|
|
454
|
+
reset: resetTransform
|
|
372
455
|
}
|
|
373
|
-
}
|
|
456
|
+
});
|
|
374
457
|
watch(() => props.modelValue, async (isOpen) => {
|
|
375
458
|
if (!isOpen) {
|
|
459
|
+
unlockBodyScroll();
|
|
376
460
|
stopObservingImage();
|
|
377
461
|
endWheelZoom();
|
|
378
462
|
isDragging.value = false;
|
|
379
463
|
return;
|
|
380
464
|
}
|
|
465
|
+
lockBodyScroll();
|
|
381
466
|
syncIndexFromInitial();
|
|
382
467
|
await nextTick();
|
|
383
468
|
startObservingImage();
|
|
@@ -396,11 +481,15 @@ var GrImageViewer_default = /* @__PURE__ */ defineComponent({
|
|
|
396
481
|
preloadAt(normalizeIndex(index + 1));
|
|
397
482
|
}, { immediate: true });
|
|
398
483
|
onBeforeUnmount(() => {
|
|
484
|
+
unlockBodyScroll();
|
|
399
485
|
stopObservingImage();
|
|
400
486
|
endWheelZoom();
|
|
401
487
|
});
|
|
402
488
|
return (_ctx, _cache) => {
|
|
403
|
-
return openBlock(), createBlock(Teleport, {
|
|
489
|
+
return openBlock(), createBlock(Teleport, {
|
|
490
|
+
to: "body",
|
|
491
|
+
disabled: !isClient
|
|
492
|
+
}, [createVNode(unref(Se), {
|
|
404
493
|
show: open.value,
|
|
405
494
|
as: "template"
|
|
406
495
|
}, {
|
|
@@ -411,7 +500,7 @@ var GrImageViewer_default = /* @__PURE__ */ defineComponent({
|
|
|
411
500
|
role: "dialog",
|
|
412
501
|
"aria-modal": "true",
|
|
413
502
|
static: true,
|
|
414
|
-
onKeydown
|
|
503
|
+
onKeydown: unref(onKeydown)
|
|
415
504
|
}, {
|
|
416
505
|
default: withCtx(() => [createElementVNode("div", _hoisted_1, [createVNode(unref(he), {
|
|
417
506
|
as: "template",
|
|
@@ -444,19 +533,19 @@ var GrImageViewer_default = /* @__PURE__ */ defineComponent({
|
|
|
444
533
|
tabindex: "-1"
|
|
445
534
|
}, {
|
|
446
535
|
default: withCtx(() => [
|
|
447
|
-
createElementVNode("div", _hoisted_2, [createElementVNode("div", _hoisted_3, [createElementVNode("div", _hoisted_4, [__props.showProgress ? (openBlock(), createElementBlock("div", _hoisted_5, toDisplayString(displayIndex.value) + " / " + toDisplayString(total.value), 1)) : createCommentVNode("", true), __props.showZoomValue ? (openBlock(), createElementBlock("div", _hoisted_6, toDisplayString(zoomValueText
|
|
536
|
+
createElementVNode("div", _hoisted_2, [createElementVNode("div", _hoisted_3, [createElementVNode("div", _hoisted_4, [__props.showProgress ? (openBlock(), createElementBlock("div", _hoisted_5, toDisplayString(displayIndex.value) + " / " + toDisplayString(total.value), 1)) : createCommentVNode("", true), __props.showZoomValue ? (openBlock(), createElementBlock("div", _hoisted_6, toDisplayString(unref(zoomValueText)) + "% ", 1)) : createCommentVNode("", true)]), createElementVNode("button", {
|
|
448
537
|
type: "button",
|
|
449
538
|
"data-gr-image-viewer-close": "",
|
|
450
539
|
"aria-label": resolvedCloseLabel.value,
|
|
451
540
|
class: "h-11 w-11 flex items-center justify-center rounded-full border border-white/20 bg-black/35 text-white transition-colors hover:bg-black/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/80",
|
|
452
541
|
onClick: closeViewer
|
|
453
|
-
}, [..._cache[
|
|
542
|
+
}, [..._cache[11] || (_cache[11] = [createElementVNode("span", {
|
|
454
543
|
"aria-hidden": "true",
|
|
455
544
|
class: "text-lg leading-none"
|
|
456
545
|
}, "✕", -1)])], 8, _hoisted_7)])]),
|
|
457
546
|
createElementVNode("div", {
|
|
458
547
|
class: "relative z-10 h-full w-full flex items-center justify-center px-16 py-16 sm:px-24 sm:py-20",
|
|
459
|
-
onWheel
|
|
548
|
+
onWheel: _cache[5] || (_cache[5] = (...args) => unref(onWheel) && unref(onWheel)(...args))
|
|
460
549
|
}, [
|
|
461
550
|
total.value > 1 ? (openBlock(), createElementBlock("button", {
|
|
462
551
|
key: 0,
|
|
@@ -465,7 +554,7 @@ var GrImageViewer_default = /* @__PURE__ */ defineComponent({
|
|
|
465
554
|
"aria-label": resolvedPrevLabel.value,
|
|
466
555
|
class: "absolute left-3 top-1/2 z-20 h-12 w-12 -translate-y-1/2 flex items-center justify-center rounded-full border border-white/20 bg-black/35 text-white transition-colors hover:bg-black/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/80 sm:left-6",
|
|
467
556
|
onClick: prev
|
|
468
|
-
}, [..._cache[
|
|
557
|
+
}, [..._cache[12] || (_cache[12] = [createElementVNode("span", {
|
|
469
558
|
"aria-hidden": "true",
|
|
470
559
|
class: "text-xl leading-none"
|
|
471
560
|
}, "‹", -1)])], 8, _hoisted_8)) : createCommentVNode("", true),
|
|
@@ -476,7 +565,7 @@ var GrImageViewer_default = /* @__PURE__ */ defineComponent({
|
|
|
476
565
|
"aria-label": resolvedNextLabel.value,
|
|
477
566
|
class: "absolute right-3 top-1/2 z-20 h-12 w-12 -translate-y-1/2 flex items-center justify-center rounded-full border border-white/20 bg-black/35 text-white transition-colors hover:bg-black/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/80 sm:right-6",
|
|
478
567
|
onClick: next
|
|
479
|
-
}, [..._cache[
|
|
568
|
+
}, [..._cache[13] || (_cache[13] = [createElementVNode("span", {
|
|
480
569
|
"aria-hidden": "true",
|
|
481
570
|
class: "text-xl leading-none"
|
|
482
571
|
}, "›", -1)])], 8, _hoisted_9)) : createCommentVNode("", true),
|
|
@@ -489,12 +578,12 @@ var GrImageViewer_default = /* @__PURE__ */ defineComponent({
|
|
|
489
578
|
alt: "",
|
|
490
579
|
draggable: "false",
|
|
491
580
|
class: normalizeClass(["max-h-full max-w-full select-none object-contain will-change-transform", [imageTransitionClass.value, imageCursorClass.value]]),
|
|
492
|
-
style: normalizeStyle(imageStyle
|
|
493
|
-
onLoad: onImageLoad,
|
|
494
|
-
onPointerdown: onPointerDown,
|
|
495
|
-
onPointermove: onPointerMove,
|
|
496
|
-
onPointerup: onPointerUp,
|
|
497
|
-
onPointercancel: onPointerUp
|
|
581
|
+
style: normalizeStyle(unref(imageStyle)),
|
|
582
|
+
onLoad: _cache[0] || (_cache[0] = (...args) => unref(onImageLoad) && unref(onImageLoad)(...args)),
|
|
583
|
+
onPointerdown: _cache[1] || (_cache[1] = (...args) => unref(onPointerDown) && unref(onPointerDown)(...args)),
|
|
584
|
+
onPointermove: _cache[2] || (_cache[2] = (...args) => unref(onPointerMove) && unref(onPointerMove)(...args)),
|
|
585
|
+
onPointerup: _cache[3] || (_cache[3] = (...args) => unref(onPointerUp) && unref(onPointerUp)(...args)),
|
|
586
|
+
onPointercancel: _cache[4] || (_cache[4] = (...args) => unref(onPointerUp) && unref(onPointerUp)(...args))
|
|
498
587
|
}, null, 46, _hoisted_11)) : (openBlock(), createElementBlock("div", _hoisted_12, toDisplayString(resolvedEmptyText.value), 1))])
|
|
499
588
|
], 32),
|
|
500
589
|
createElementVNode("div", _hoisted_13, [createElementVNode("div", _hoisted_14, [renderSlot(_ctx.$slots, "toolbar", normalizeProps(guardReactiveProps(toolbarSlotProps.value)), () => [createElementVNode("div", _hoisted_15, [
|
|
@@ -503,29 +592,29 @@ var GrImageViewer_default = /* @__PURE__ */ defineComponent({
|
|
|
503
592
|
"data-gr-image-viewer-zoom-out": "",
|
|
504
593
|
"aria-label": resolvedZoomOutLabel.value,
|
|
505
594
|
class: "h-11 min-w-11 px-2 flex items-center justify-center rounded-full text-sm font-600 text-white transition-colors hover:bg-white/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/80",
|
|
506
|
-
onClick: zoomOut
|
|
595
|
+
onClick: _cache[6] || (_cache[6] = (...args) => unref(zoomOut) && unref(zoomOut)(...args))
|
|
507
596
|
}, " − ", 8, _hoisted_16),
|
|
508
597
|
createElementVNode("button", {
|
|
509
598
|
type: "button",
|
|
510
599
|
"data-gr-image-viewer-zoom-reset": "",
|
|
511
600
|
"aria-label": resolvedResetZoomLabel.value,
|
|
512
601
|
class: "h-11 min-w-11 px-3 flex items-center justify-center rounded-full text-xs font-700 text-white transition-colors hover:bg-white/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/80",
|
|
513
|
-
onClick: resetTransform
|
|
602
|
+
onClick: _cache[7] || (_cache[7] = (...args) => unref(resetTransform) && unref(resetTransform)(...args))
|
|
514
603
|
}, " 100% ", 8, _hoisted_17),
|
|
515
604
|
createElementVNode("button", {
|
|
516
605
|
type: "button",
|
|
517
606
|
"data-gr-image-viewer-zoom-in": "",
|
|
518
607
|
"aria-label": resolvedZoomInLabel.value,
|
|
519
608
|
class: "h-11 min-w-11 px-2 flex items-center justify-center rounded-full text-sm font-600 text-white transition-colors hover:bg-white/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/80",
|
|
520
|
-
onClick: zoomIn
|
|
609
|
+
onClick: _cache[8] || (_cache[8] = (...args) => unref(zoomIn) && unref(zoomIn)(...args))
|
|
521
610
|
}, " + ", 8, _hoisted_18),
|
|
522
611
|
_ctx.$slots["toolbar-actions"] ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
523
|
-
_cache[
|
|
612
|
+
_cache[14] || (_cache[14] = createElementVNode("div", {
|
|
524
613
|
class: "mx-1 h-6 w-px bg-white/25",
|
|
525
614
|
"aria-hidden": "true"
|
|
526
615
|
}, null, -1)),
|
|
527
616
|
renderSlot(_ctx.$slots, "toolbar-actions", normalizeProps(guardReactiveProps(toolbarSlotProps.value))),
|
|
528
|
-
_cache[
|
|
617
|
+
_cache[15] || (_cache[15] = createElementVNode("div", {
|
|
529
618
|
class: "mx-1 h-6 w-px bg-white/25",
|
|
530
619
|
"aria-hidden": "true"
|
|
531
620
|
}, null, -1))
|
|
@@ -535,14 +624,14 @@ var GrImageViewer_default = /* @__PURE__ */ defineComponent({
|
|
|
535
624
|
"data-gr-image-viewer-rotate-left": "",
|
|
536
625
|
"aria-label": resolvedRotateLeftLabel.value,
|
|
537
626
|
class: "h-11 min-w-11 px-2 flex items-center justify-center rounded-full text-sm font-600 text-white transition-colors hover:bg-white/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/80",
|
|
538
|
-
onClick: rotateLeft
|
|
627
|
+
onClick: _cache[9] || (_cache[9] = (...args) => unref(rotateLeft) && unref(rotateLeft)(...args))
|
|
539
628
|
}, " ↺ ", 8, _hoisted_20),
|
|
540
629
|
createElementVNode("button", {
|
|
541
630
|
type: "button",
|
|
542
631
|
"data-gr-image-viewer-rotate-right": "",
|
|
543
632
|
"aria-label": resolvedRotateRightLabel.value,
|
|
544
633
|
class: "h-11 min-w-11 px-2 flex items-center justify-center rounded-full text-sm font-600 text-white transition-colors hover:bg-white/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/80",
|
|
545
|
-
onClick: rotateRight
|
|
634
|
+
onClick: _cache[10] || (_cache[10] = (...args) => unref(rotateRight) && unref(rotateRight)(...args))
|
|
546
635
|
}, " ↻ ", 8, _hoisted_21)
|
|
547
636
|
])])])])
|
|
548
637
|
]),
|
|
@@ -551,9 +640,9 @@ var GrImageViewer_default = /* @__PURE__ */ defineComponent({
|
|
|
551
640
|
_: 3
|
|
552
641
|
})])]),
|
|
553
642
|
_: 3
|
|
554
|
-
}, 8, ["style"])]),
|
|
643
|
+
}, 8, ["style", "onKeydown"])]),
|
|
555
644
|
_: 3
|
|
556
|
-
}, 8, ["show"])]);
|
|
645
|
+
}, 8, ["show"])], 8, ["disabled"]);
|
|
557
646
|
};
|
|
558
647
|
}
|
|
559
648
|
});
|