@file-viewer/vue3 3.0.2 → 3.1.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.
@@ -1 +1,175 @@
1
- const an=g;(function(x,y){const am=g,z=x();while(!![]){try{const A=parseInt(am(0x139))/0x1+parseInt(am(0x114))/0x2*(-parseInt(am(0x11c))/0x3)+parseInt(am(0x127))/0x4+-parseInt(am(0x125))/0x5*(-parseInt(am(0x122))/0x6)+-parseInt(am(0x12f))/0x7*(parseInt(am(0x112))/0x8)+parseInt(am(0x110))/0x9*(parseInt(am(0x13b))/0xa)+parseInt(am(0x136))/0xb*(-parseInt(am(0x131))/0xc);if(A===y)break;else z['push'](z['shift']());}catch(B){z['push'](z['shift']());}}}(b,0xedebb));import{t as j}from'./asyncToGenerator.js';function g(a,c){a=a-0x10d;const d=b();let e=d[a];return e;}function b(){const aD=['tabIndex','img','style','observe','image.lightbox.close','dialog','1939LGedLZ','trim','5409708FQLQFs','image-stage','destroy','preventDefault','open','11lgSUKL','createElement','alt','496793gNqDAZ','viewportWidth','6070AtIsBC','setAttribute','auto','min','click','clientHeight','key','width','apply','11241KKVzGA','ownerDocument','9512IyJRCo','image','6KPlBFZ','scale','true','call','type','emit','image/tiff','scale-down','1762647itlutJ','round','Unable\x20to\x20read\x20image\x20data\x20URL.','aria-hidden','removeEventListener','src','414UzgnaB','dataset','zoom','48770iBZcxE','naturalHeight','6357480wugSnO','onload'];b=function(){return aD;};return b();}import{f as k,i as q,r,u as v}from'./fit.js';import{t as w}from'./messages.js';var o={'avif':'image/avif','bmp':'image/bmp','gif':'image/gif','heic':'image/heic','heif':'image/heif','ico':'image/x-icon','jxl':'image/jxl','jpg':'image/jpeg','jpeg':'image/jpeg','png':'image/png','svg':'image/svg+xml','tif':'image/tiff','tiff':an(0x11a),'webp':'image/webp'},s='\x0a.image-viewer{position:relative;width:100%;height:100%;overflow:auto;background:var(--file-viewer-render-surface-background,#eef1f4);box-sizing:border-box}\x0a.image-stage{min-width:100%;min-height:100%;display:flex;align-items:center;justify-content:center;padding:24px;box-sizing:border-box}\x0a.image-stage\x20img{display:block;width:auto;max-width:none;margin:0\x20auto;border:0;box-shadow:0\x2018px\x2048px\x20rgba(15,23,42,.16);background:#fff;cursor:zoom-in}\x0a.image-stage\x20img:focus-visible{outline:3px\x20solid\x20#2563eb;outline-offset:4px}\x0a.image-lightbox{position:absolute;inset:0;z-index:40;display:flex;align-items:center;justify-content:center;padding:40px;background:rgba(15,23,42,.9);box-sizing:border-box;opacity:0;visibility:hidden;pointer-events:none;transition:opacity\x20.18s\x20ease,visibility\x200s\x20linear\x20.18s}\x0a.image-lightbox[data-open=\x27true\x27]{opacity:1;visibility:visible;pointer-events:auto;transition-delay:0s}\x0a.image-lightbox\x20img{display:block;max-width:100%;max-height:100%;object-fit:contain;background:#fff;box-shadow:0\x2030px\x2080px\x20rgba(0,0,0,.4);cursor:default;transform:scale(.985);transition:transform\x20.18s\x20ease}\x0a.image-lightbox[data-open=\x27true\x27]\x20img{transform:scale(1)}\x0a.image-lightbox\x20button{position:absolute;top:16px;right:16px;display:grid;width:40px;height:40px;place-items:center;padding:0;border:1px\x20solid\x20rgba(255,255,255,.7);border-radius:999px;background:rgba(255,255,255,.96);color:#172033;font:400\x2027px/1\x20Arial,sans-serif;cursor:pointer;box-shadow:0\x2012px\x2028px\x20rgba(0,0,0,.24);transition:background-color\x20.14s\x20ease,transform\x20.14s\x20ease}\x0a.image-lightbox\x20button:hover{background:#fff;transform:scale(1.04)}\x0a.image-lightbox\x20button:focus-visible{outline:3px\x20solid\x20#60a5fa;outline-offset:2px}\x0a[data-viewer-theme=\x27dark\x27]\x20.image-viewer{background:var(--file-viewer-render-surface-background,#101820)}\x0a@media\x20(prefers-color-scheme:dark){[data-viewer-theme=\x27system\x27]\x20.image-viewer{background:var(--file-viewer-render-surface-background,#101820)}}\x0a@media\x20(max-width:767px){.image-stage{padding:12px}.image-lightbox{padding:16px}.image-lightbox\x20button{top:12px;right:12px}}\x0a@media\x20(prefers-reduced-motion:reduce){.image-lightbox,.image-lightbox\x20img,.image-lightbox\x20button{transition:none}}\x0a',c=x=>{const ao=an;let y=x[ao(0x137)](ao(0x12b));return y['textContent']=s,y;},l=x=>o[(x||'')[an(0x130)]()['toLowerCase']()]||'image/*',u=(function(){var x=j(function*(y){return yield new Promise((z,A)=>{const ap=g;let B=new FileReader();B[ap(0x128)]=C=>{const aq=ap;var D;let E=(D=C['target'])==null?void 0x0:D['result'];if(typeof E=='string'){z(E);return;}A(Error(aq(0x11e)));},B['onerror']=()=>A(B['error']||Error('Unable\x20to\x20read\x20image\x20data\x20URL.')),B['readAsDataURL'](y);});});return function(y){const ar=g;return x[ar(0x10f)](this,arguments);};}()),d=(function(){var x=j(function*(y,z){let A=(z||'')['trim']()['toLowerCase']();if(A==='heic'||A==='heif')throw Error('HEIC/HEIF\x20image\x20conversion\x20has\x20moved\x20out\x20of\x20@file-viewer/core.\x20Install\x20and\x20pass\x20@file-viewer/renderer-image,\x20or\x20use\x20@file-viewer/preset-all.');return u(new Blob([y],{'type':l(A)}));});return function(y,z){return x['apply'](this,arguments);};}()),f=x=>Number(x['toFixed'](0x3)),p=(x,y,z)=>{const as=an;let A=x['createElement']('div');A['className']='image-lightbox',A[as(0x123)]['open']='false',A['setAttribute']('role',as(0x12e)),A[as(0x13c)]('aria-modal',as(0x116)),A['setAttribute'](as(0x11f),'true');let B=x['createElement'](as(0x12a));B['alt']=z('image.lightbox.alt'),B[as(0x121)]=y;let C=x['createElement']('button');C[as(0x118)]='button',C['setAttribute']('aria-label',z(as(0x12d))),C['textContent']='×';let D=null,E=()=>{const at=as;A['dataset'][at(0x135)]==='true'&&(A['dataset']['open']='false',A['setAttribute']('aria-hidden','true'),D!=null&&D['isConnected']&&D['focus']({'preventScroll':!0x0}),D=null);},F=G=>{const au=as;G['key']==='Escape'&&A['dataset']['open']==='true'&&(G[au(0x134)](),E());};return C['addEventListener'](as(0x13f),E),A['addEventListener'](as(0x13f),G=>{G['target']===A&&E();}),x['addEventListener']('keydown',F),A['append'](B,C),{'element':A,'open'(G){const av=as;D=G||(x['activeElement']instanceof HTMLElement?x['activeElement']:null),A[av(0x123)]['open']='true',A['setAttribute']('aria-hidden','false'),C['focus']({'preventScroll':!0x0});},'destroy'(){C['removeEventListener']('click',E),x['removeEventListener']('keydown',F),A['remove']();}};};function m(x,y,z,A){return h['apply'](this,arguments);}function h(){return h=j(function*(z,B,G,H){const aw=g;var J,K;let Q=w(H==null?void 0x0:H['options']),R=B[aw(0x111)]||document,U=yield d(z,G);(J=H==null?void 0x0:H['registerThumbnailAdapter'])==null||J['call'](H,{'capture':()=>new Blob([z],{'type':l(G)})});let V=0x1,W=0x1,X=0x1,Y=0x0,Z=q(),a0=R['createElement']('div');a0['className']='image-viewer',a0['dataset']['viewerZoomProvider']=aw(0x113);let a1=R[aw(0x137)]('div');a1['className']=aw(0x132);let a2=R[aw(0x137)](aw(0x12a));a2[aw(0x138)]=Q('image.alt'),a2[aw(0x121)]=U,a2[aw(0x129)]=0x0,a2['setAttribute']('role','button'),a2['setAttribute']('aria-haspopup','dialog'),a1['append'](a2),a0['append'](a1);let a3=p(R,U,Q),a4=()=>a3['open'](a2),a5=ae=>{const ax=aw;(ae['key']==='Enter'||ae[ax(0x10d)]==='\x20')&&(ae[ax(0x134)](),a3['open'](a2));};a2['addEventListener'](aw(0x13f),a4),a2['addEventListener']('keydown',a5);let a6=()=>Math[aw(0x13e)](0.1,W||0.1),a7=ae=>{const ay=aw;let af=a6();return Math[ay(0x13e)](0x5,Math['max'](af,f(ae)));},a8=()=>{const az=aw;let ae=a2['naturalWidth']||0x0,af=a2['naturalHeight']||0x0;if(!ae||!af)return 0x1;let ag=Math['max']((a0['clientWidth']||0x0)-0x30,0x1),ah=Math['max']((a0[az(0x140)]||Y||0x0)-0x30,0x1);return Math['min'](0x1,ag/ae,ah/af);},a9=()=>{const aA=aw;if(W=a8(),X=a7(W*V),a2['naturalWidth']&&a2['naturalHeight']){a2[aA(0x12b)]['width']=Math['max'](0x1,Math['round'](a2['naturalWidth']*X))+'px',a2['style']['height']=Math['max'](0x1,Math['round'](a2['naturalHeight']*X))+'px';return;}a2['style'][aA(0x10e)]=aA(0x13d),a2['style']['height']=Y>0x0?Math['max'](0x1,Math[aA(0x11d)](Y*V))+'px':V*0x64+'%';},aa=()=>{Y=a0['clientHeight']||0x0,a9(),Z['emit']();},ab=new ResizeObserver(aa);ab[aw(0x12c)](a0),a2['addEventListener']('load',aa);let ac=()=>({'scale':X,'label':Math[aw(0x11d)](X*0x64)+'%','canZoomIn':X<0x5,'canZoomOut':X>a6(),'canReset':Math['abs'](V-0x1)>0.001,'minScale':a6(),'maxScale':0x5}),ad=ae=>(V=a7(ae)/Math['max'](W,0.001),a9(),Z['emit'](),ac());return v(a0,{'zoomIn':()=>ad(X+0.15),'zoomOut':()=>ad(X-0.15),'resetZoom':()=>(V=0x1,a9(),Z[aw(0x119)](),ac()),'setZoom':ad,'fit':ae=>{const aB=aw;var af,ag;let ah=a2['naturalWidth']||0x0,ai=a2[aB(0x126)]||0x0;if(!ah||!ai)return{'applied':!0x1,'mode':ae['mode'],'resize':ae['resize'],'source':ae['source'],'reason':'image-not-ready','provider':aB(0x124)};let aj=ae['mode']==='auto'?aB(0x11b):ae['mode'],ak=r({'mode':aj,'viewportWidth':Math['max'](0x1,ae[aB(0x13a)]||a0['clientWidth']||0x0),'viewportHeight':Math['max'](0x1,ae['viewportHeight']||a0['clientHeight']||Y||0x0),'contentWidth':ah,'contentHeight':ai,'currentScale':X,'minScale':(af=ae['minScale'])==null?a6():af,'maxScale':(ag=ae['maxScale'])==null?0x5:ag});if(!ak)return{'applied':!0x1,'mode':ae['mode'],'resize':ae['resize'],'source':ae['source'],'reason':'unmeasurable','provider':'zoom'};let al=ad(ak);return{'applied':!0x0,'mode':ae['mode'],'resize':ae['resize'],'scale':al[aB(0x115)],'source':ae['source'],'provider':'zoom'};},'getState':ac,'subscribe':Z['subscribe']}),B['replaceChildren'](c(R),a0),(((K=H==null?void 0x0:H['surface'])==null?void 0x0:K['shadowRoot'])||B)['append'](a3['element']),aa(),{'$el':B,'unmount'(){const aC=aw;var ae;(ae=H==null?void 0x0:H['registerThumbnailAdapter'])==null||ae[aC(0x117)](H,null),k(a0),ab['disconnect'](),a2[aC(0x120)]('load',aa),a2['removeEventListener']('click',a4),a2['removeEventListener']('keydown',a5),a3[aC(0x133)](),B['replaceChildren']();}};}),h['apply'](this,arguments);}export{m as default};
1
+ import { r as e } from "./objectSpread2.js";
2
+ import { f as t, i as n, r, u as i } from "./fit.js";
3
+ import { t as a } from "./messages.js";
4
+ //#region ../../core/dist/renderers/image.js
5
+ var o = {
6
+ avif: "image/avif",
7
+ bmp: "image/bmp",
8
+ gif: "image/gif",
9
+ heic: "image/heic",
10
+ heif: "image/heif",
11
+ ico: "image/x-icon",
12
+ jxl: "image/jxl",
13
+ jpg: "image/jpeg",
14
+ jpeg: "image/jpeg",
15
+ png: "image/png",
16
+ svg: "image/svg+xml",
17
+ tif: "image/tiff",
18
+ tiff: "image/tiff",
19
+ webp: "image/webp"
20
+ }, s = "\n.image-viewer{position:relative;width:100%;height:100%;overflow:auto;background:var(--file-viewer-render-surface-background,#eef1f4);box-sizing:border-box}\n.image-stage{min-width:100%;min-height:100%;display:flex;align-items:center;justify-content:center;padding:24px;box-sizing:border-box}\n.image-stage img{display:block;width:auto;max-width:none;margin:0 auto;border:0;box-shadow:0 18px 48px rgba(15,23,42,.16);background:#fff;cursor:zoom-in}\n.image-stage img:focus-visible{outline:3px solid #2563eb;outline-offset:4px}\n.image-lightbox{position:absolute;inset:0;z-index:40;display:flex;align-items:center;justify-content:center;padding:40px;background:rgba(15,23,42,.9);box-sizing:border-box;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .18s ease,visibility 0s linear .18s}\n.image-lightbox[data-open='true']{opacity:1;visibility:visible;pointer-events:auto;transition-delay:0s}\n.image-lightbox img{display:block;max-width:100%;max-height:100%;object-fit:contain;background:#fff;box-shadow:0 30px 80px rgba(0,0,0,.4);cursor:default;transform:scale(.985);transition:transform .18s ease}\n.image-lightbox[data-open='true'] img{transform:scale(1)}\n.image-lightbox button{position:absolute;top:16px;right:16px;display:grid;width:40px;height:40px;place-items:center;padding:0;border:1px solid rgba(255,255,255,.7);border-radius:999px;background:rgba(255,255,255,.96);color:#172033;font:400 27px/1 Arial,sans-serif;cursor:pointer;box-shadow:0 12px 28px rgba(0,0,0,.24);transition:background-color .14s ease,transform .14s ease}\n.image-lightbox button:hover{background:#fff;transform:scale(1.04)}\n.image-lightbox button:focus-visible{outline:3px solid #60a5fa;outline-offset:2px}\n[data-viewer-theme='dark'] .image-viewer{background:var(--file-viewer-render-surface-background,#101820)}\n@media (prefers-color-scheme:dark){[data-viewer-theme='system'] .image-viewer{background:var(--file-viewer-render-surface-background,#101820)}}\n@media (max-width:767px){.image-stage{padding:12px}.image-lightbox{padding:16px}.image-lightbox button{top:12px;right:12px}}\n@media (prefers-reduced-motion:reduce){.image-lightbox,.image-lightbox img,.image-lightbox button{transition:none}}\n", c = (e) => {
21
+ let t = e.createElement("style");
22
+ return t.textContent = s, t;
23
+ }, l = (e) => o[(e || "").trim().toLowerCase()] || "image/*", u = function() {
24
+ var t = e(function* (e) {
25
+ return yield new Promise((t, n) => {
26
+ let r = new FileReader();
27
+ r.onload = (e) => {
28
+ var r;
29
+ let i = (r = e.target) == null ? void 0 : r.result;
30
+ if (typeof i == "string") {
31
+ t(i);
32
+ return;
33
+ }
34
+ n(/* @__PURE__ */ Error("Unable to read image data URL."));
35
+ }, r.onerror = () => n(r.error || /* @__PURE__ */ Error("Unable to read image data URL.")), r.readAsDataURL(e);
36
+ });
37
+ });
38
+ return function(e) {
39
+ return t.apply(this, arguments);
40
+ };
41
+ }(), d = function() {
42
+ var t = e(function* (e, t) {
43
+ let n = (t || "").trim().toLowerCase();
44
+ if (n === "heic" || n === "heif") throw Error("HEIC/HEIF image conversion has moved out of @file-viewer/core. Install and pass @file-viewer/renderer-image, or use @file-viewer/preset-all.");
45
+ return u(new Blob([e], { type: l(n) }));
46
+ });
47
+ return function(e, n) {
48
+ return t.apply(this, arguments);
49
+ };
50
+ }(), f = (e) => Number(e.toFixed(3)), p = (e, t, n) => {
51
+ let r = e.createElement("div");
52
+ r.className = "image-lightbox", r.dataset.open = "false", r.setAttribute("role", "dialog"), r.setAttribute("aria-modal", "true"), r.setAttribute("aria-hidden", "true");
53
+ let i = e.createElement("img");
54
+ i.alt = n("image.lightbox.alt"), i.src = t;
55
+ let a = e.createElement("button");
56
+ a.type = "button", a.setAttribute("aria-label", n("image.lightbox.close")), a.textContent = "×";
57
+ let o = null, s = () => {
58
+ r.dataset.open === "true" && (r.dataset.open = "false", r.setAttribute("aria-hidden", "true"), o != null && o.isConnected && o.focus({ preventScroll: !0 }), o = null);
59
+ }, c = (e) => {
60
+ e.key === "Escape" && r.dataset.open === "true" && (e.preventDefault(), s());
61
+ };
62
+ return a.addEventListener("click", s), r.addEventListener("click", (e) => {
63
+ e.target === r && s();
64
+ }), e.addEventListener("keydown", c), r.append(i, a), {
65
+ element: r,
66
+ open(t) {
67
+ o = t || (e.activeElement instanceof HTMLElement ? e.activeElement : null), r.dataset.open = "true", r.setAttribute("aria-hidden", "false"), a.focus({ preventScroll: !0 });
68
+ },
69
+ destroy() {
70
+ a.removeEventListener("click", s), e.removeEventListener("keydown", c), r.remove();
71
+ }
72
+ };
73
+ };
74
+ function m(e, t, n, r) {
75
+ return h.apply(this, arguments);
76
+ }
77
+ function h() {
78
+ return h = e(function* (e, o, s, u) {
79
+ var m, h;
80
+ let g = a(u == null ? void 0 : u.options), _ = o.ownerDocument || document, v = yield d(e, s);
81
+ (m = u == null ? void 0 : u.registerThumbnailAdapter) == null || m.call(u, { capture: () => new Blob([e], { type: l(s) }) });
82
+ let y = 1, b = 1, x = 1, S = 0, C = n(), w = _.createElement("div");
83
+ w.className = "image-viewer", w.dataset.viewerZoomProvider = "image";
84
+ let T = _.createElement("div");
85
+ T.className = "image-stage";
86
+ let E = _.createElement("img");
87
+ E.alt = g("image.alt"), E.src = v, E.tabIndex = 0, E.setAttribute("role", "button"), E.setAttribute("aria-haspopup", "dialog"), T.append(E), w.append(T);
88
+ let D = p(_, v, g), O = () => D.open(E), k = (e) => {
89
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), D.open(E));
90
+ };
91
+ E.addEventListener("click", O), E.addEventListener("keydown", k);
92
+ let A = () => Math.min(.1, b || .1), j = (e) => {
93
+ let t = A();
94
+ return Math.min(5, Math.max(t, f(e)));
95
+ }, M = () => {
96
+ let e = E.naturalWidth || 0, t = E.naturalHeight || 0;
97
+ if (!e || !t) return 1;
98
+ let n = Math.max((w.clientWidth || 0) - 48, 1), r = Math.max((w.clientHeight || S || 0) - 48, 1);
99
+ return Math.min(1, n / e, r / t);
100
+ }, N = () => {
101
+ if (b = M(), x = j(b * y), E.naturalWidth && E.naturalHeight) {
102
+ E.style.width = `${Math.max(1, Math.round(E.naturalWidth * x))}px`, E.style.height = `${Math.max(1, Math.round(E.naturalHeight * x))}px`;
103
+ return;
104
+ }
105
+ E.style.width = "auto", E.style.height = S > 0 ? `${Math.max(1, Math.round(S * y))}px` : `${y * 100}%`;
106
+ }, P = () => {
107
+ S = w.clientHeight || 0, N(), C.emit();
108
+ }, F = new ResizeObserver(P);
109
+ F.observe(w), E.addEventListener("load", P);
110
+ let I = () => ({
111
+ scale: x,
112
+ label: `${Math.round(x * 100)}%`,
113
+ canZoomIn: x < 5,
114
+ canZoomOut: x > A(),
115
+ canReset: Math.abs(y - 1) > .001,
116
+ minScale: A(),
117
+ maxScale: 5
118
+ }), L = (e) => (y = j(e) / Math.max(b, .001), N(), C.emit(), I());
119
+ return i(w, {
120
+ zoomIn: () => L(x + .15),
121
+ zoomOut: () => L(x - .15),
122
+ resetZoom: () => (y = 1, N(), C.emit(), I()),
123
+ setZoom: L,
124
+ fit: (e) => {
125
+ var t, n;
126
+ let i = E.naturalWidth || 0, a = E.naturalHeight || 0;
127
+ if (!i || !a) return {
128
+ applied: !1,
129
+ mode: e.mode,
130
+ resize: e.resize,
131
+ source: e.source,
132
+ reason: "image-not-ready",
133
+ provider: "zoom"
134
+ };
135
+ let o = e.mode === "auto" ? "scale-down" : e.mode, s = r({
136
+ mode: o,
137
+ viewportWidth: Math.max(1, e.viewportWidth || w.clientWidth || 0),
138
+ viewportHeight: Math.max(1, e.viewportHeight || w.clientHeight || S || 0),
139
+ contentWidth: i,
140
+ contentHeight: a,
141
+ currentScale: x,
142
+ minScale: (t = e.minScale) == null ? A() : t,
143
+ maxScale: (n = e.maxScale) == null ? 5 : n
144
+ });
145
+ if (!s) return {
146
+ applied: !1,
147
+ mode: e.mode,
148
+ resize: e.resize,
149
+ source: e.source,
150
+ reason: "unmeasurable",
151
+ provider: "zoom"
152
+ };
153
+ let c = L(s);
154
+ return {
155
+ applied: !0,
156
+ mode: e.mode,
157
+ resize: e.resize,
158
+ scale: c.scale,
159
+ source: e.source,
160
+ provider: "zoom"
161
+ };
162
+ },
163
+ getState: I,
164
+ subscribe: C.subscribe
165
+ }), o.replaceChildren(c(_), w), (((h = u == null ? void 0 : u.surface) == null ? void 0 : h.shadowRoot) || o).append(D.element), P(), {
166
+ $el: o,
167
+ unmount() {
168
+ var e;
169
+ (e = u == null ? void 0 : u.registerThumbnailAdapter) == null || e.call(u, null), t(w), F.disconnect(), E.removeEventListener("load", P), E.removeEventListener("click", O), E.removeEventListener("keydown", k), D.destroy(), o.replaceChildren();
170
+ }
171
+ };
172
+ }), h.apply(this, arguments);
173
+ }
174
+ //#endregion
175
+ export { m as default };