@wssto2/vue-core 0.4.24 → 0.4.25

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,411 +0,0 @@
1
- import { defineComponent as Ae, useModel as Re, ref as _, useTemplateRef as se, watch as Q, computed as g, onBeforeUnmount as Ne, nextTick as ye, onMounted as Xe, openBlock as m, createBlock as Ve, Teleport as Ye, createElementBlock as f, createVNode as T, Transition as Ze, withCtx as Ee, unref as u, createElementVNode as h, toDisplayString as ee, createCommentVNode as k, renderSlot as Ke, normalizeClass as M, withModifiers as re, normalizeStyle as te, Fragment as We, renderList as je, mergeModels as be } from "vue";
2
- import { useI18n as Ue } from "vue-i18n";
3
- import { _ as S } from "./Icon.vue_vue_type_script_lang-D7oC-d-S.js";
4
- import { u as Fe } from "./useDialog-CXR3hN0G.js";
5
- const _e = [1, 1.5, 2, 3, 4, 5], ke = 1, ue = 5, He = (a) => Math.min(ue, Math.max(ke, a)), Me = (a, l) => l % 2 === 0 ? a : { width: a.height, height: a.width };
6
- function qe(a, l, s) {
7
- const i = Me(a, s);
8
- if (i.width <= 0 || i.height <= 0 || l.width <= 0 || l.height <= 0) return { width: 0, height: 0 };
9
- const o = Math.min(l.width / i.width, l.height / i.height);
10
- return { width: a.width * o, height: a.height * o };
11
- }
12
- function Ge(a, l, s) {
13
- return { x: Math.max(0, (a.width * s - l.width) / 2), y: Math.max(0, (a.height * s - l.height) / 2) };
14
- }
15
- function N(a, l, s, i) {
16
- const o = Ge(l, s, i);
17
- return { x: Math.min(o.x, Math.max(-o.x, a.x)) + 0, y: Math.min(o.y, Math.max(-o.y, a.y)) + 0 };
18
- }
19
- function Je(a, l, s, i, o) {
20
- const z = He(l), r = z / a.zoom, $ = { x: s.x - (s.x - a.pan.x) * r, y: s.y - (s.y - a.pan.y) * r };
21
- return { zoom: z, pan: N($, i, o, z) };
22
- }
23
- function Qe(a, l) {
24
- return l === 1 ? _e.find((i) => i > a + 1e-3) ?? ue : [..._e].reverse().find((i) => i < a - 1e-3) ?? ke;
25
- }
26
- function et(a, l, s, i, o) {
27
- const z = Math.min(o.width / a.width, o.height / a.height), r = { width: a.width * z, height: a.height * z }, $ = { width: a.width * s, height: a.height * s }, P = { width: Math.min(1, l.width / $.width), height: Math.min(1, l.height / $.height) }, E = { x: 0.5 - i.x / $.width, y: 0.5 - i.y / $.height };
28
- return {
29
- image: r,
30
- view: { x: (E.x - P.width / 2) * r.width, y: (E.y - P.height / 2) * r.height, width: P.width * r.width, height: P.height * r.height }
31
- };
32
- }
33
- function tt(a, l, s, i) {
34
- return N({ x: (0.5 - a.x) * l.width * i, y: (0.5 - a.y) * l.height * i }, l, s, i);
35
- }
36
- const at = {
37
- key: 0,
38
- class: "relative z-9999"
39
- }, it = ["aria-label"], ot = { class: "flex items-center gap-2 px-4 pt-[max(0.875rem,var(--app-safe-top))] pb-3.5 md:px-4.5" }, nt = { class: "min-w-0 truncate text-headline font-semibold" }, lt = { key: 0 }, st = {
40
- "aria-live": "polite",
41
- "data-test": "photo-counter"
42
- }, rt = ["aria-label", "aria-disabled"], ut = {
43
- class: "w-13 text-center text-subheadline tabular-nums compact:hidden",
44
- "data-test": "zoom-percent"
45
- }, dt = ["aria-label", "aria-disabled"], ct = ["aria-label"], ht = ["href", "download", "aria-label"], vt = ["aria-label"], mt = { class: "flex min-h-0 grow items-center gap-4 px-4 md:px-4.5" }, pt = ["aria-label", "aria-disabled"], ft = ["src", "alt"], gt = ["src"], xt = ["aria-label", "aria-disabled"], wt = ["aria-label", "aria-current", "onClick"], yt = ["src"], bt = {
46
- key: 1,
47
- class: "h-[max(1.25rem,var(--app-safe-bottom))] shrink-0"
48
- }, _t = {
49
- class: "sr-only",
50
- "aria-live": "polite"
51
- }, kt = 8, Mt = 300, I = "flex size-10 shrink-0 cursor-pointer items-center justify-center rounded-full bg-white/8 text-[#f1f5f3] transition-colors duration-motion-fast hover:bg-white/16 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#6ee7b7] aria-disabled:cursor-default aria-disabled:opacity-30 aria-disabled:hover:bg-white/8", Tt = /* @__PURE__ */ Ae({
52
- __name: "PhotoViewer",
53
- props: /* @__PURE__ */ be({
54
- items: {},
55
- title: { default: void 0 }
56
- }, {
57
- index: { default: 0 },
58
- indexModifiers: {}
59
- }),
60
- emits: /* @__PURE__ */ be(["presented", "dismissed"], ["update:index"]),
61
- setup(a, { expose: l, emit: s }) {
62
- const i = a, o = Re(a, "index"), z = s, { t: r } = Ue(), $ = _(null), P = se("stage"), E = se("image"), de = se("strip"), K = Fe($, { initialFocus: "panel", onPresented: () => z("presented"), onDismissed: () => z("dismissed") }), { isOpen: W } = K, ae = _(!1);
63
- Q(W, (e) => {
64
- e && (ae.value = !0);
65
- }, { flush: "sync" });
66
- const ze = () => {
67
- W.value || (ae.value = !1);
68
- }, c = _(1), d = _({ x: 0, y: 0 }), C = _(0), j = _({ width: 0, height: 0 }), x = _({ width: 0, height: 0 }), y = _(0), ie = _(!1), X = _(null), p = g(() => i.items[o.value]), B = g(() => qe(j.value, x.value, C.value)), O = g(() => Me(B.value, C.value)), ce = g(() => B.value.width > 0), $e = g(() => Math.round(c.value * 100)), D = g(() => c.value > 1.001), he = g(() => o.value > 0), ve = g(() => o.value < i.items.length - 1), Pe = g(() => ({
69
- width: `${B.value.width}px`,
70
- height: `${B.value.height}px`,
71
- marginLeft: `${-B.value.width / 2}px`,
72
- marginTop: `${-B.value.height / 2}px`,
73
- transform: `translate(${d.value.x + y.value}px, ${d.value.y}px) scale(${c.value}) rotate(${C.value * 90}deg)`
74
- }));
75
- function U() {
76
- c.value = 1, d.value = { x: 0, y: 0 }, y.value = 0;
77
- }
78
- function F() {
79
- const e = P.value;
80
- e && (x.value = { width: e.clientWidth, height: e.clientHeight }), oe();
81
- }
82
- function oe() {
83
- const e = E.value;
84
- e && e.naturalWidth > 0 && (j.value = { width: e.naturalWidth, height: e.naturalHeight });
85
- }
86
- let H = null;
87
- Q(P, (e) => {
88
- H?.disconnect(), e && (F(), typeof ResizeObserver < "u" && (H = new ResizeObserver(() => {
89
- F(), d.value = N(d.value, O.value, x.value, c.value);
90
- }), H.observe(e)));
91
- }), Ne(() => H?.disconnect()), Q(o, () => {
92
- U(), C.value = 0, j.value = { width: 0, height: 0 }, ye(() => {
93
- oe(), de.value?.querySelector("[aria-current=true]")?.scrollIntoView?.({ inline: "center", block: "nearest" });
94
- });
95
- }), Q(() => i.items.length, (e) => {
96
- e === 0 ? K.dismiss() : o.value > e - 1 && (o.value = e - 1);
97
- });
98
- function Ce(e = 0) {
99
- o.value = Math.min(Math.max(0, e), Math.max(0, i.items.length - 1)), U(), C.value = 0, j.value = { width: 0, height: 0 }, X.value = null, K.present(), ye(F);
100
- }
101
- const me = () => K.dismiss();
102
- l({ present: Ce, dismiss: me });
103
- function V(e) {
104
- const t = o.value + e;
105
- t < 0 || t > i.items.length - 1 || (X.value = e === 1 ? "forward" : "back", o.value = t);
106
- }
107
- function A(e) {
108
- q(Qe(c.value, e), { x: 0, y: 0 });
109
- }
110
- function q(e, t) {
111
- const n = Je({ zoom: c.value, pan: d.value }, e, t, O.value, x.value);
112
- c.value = n.zoom, d.value = n.pan;
113
- }
114
- function ne() {
115
- C.value = (C.value + 3) % 4, d.value = N(d.value, O.value, x.value, c.value);
116
- }
117
- function Te(e) {
118
- if (e.altKey || e.ctrlKey || e.metaKey) return;
119
- const n = {
120
- ArrowLeft: () => V(-1),
121
- ArrowRight: () => V(1),
122
- "+": () => A(1),
123
- "=": () => A(1),
124
- "-": () => A(-1),
125
- _: () => A(-1),
126
- 0: U,
127
- r: ne,
128
- R: ne
129
- }[e.key];
130
- n && (e.preventDefault(), n());
131
- }
132
- const le = (e) => {
133
- const t = P.value?.getBoundingClientRect();
134
- return { x: e.clientX - (t ? t.left + t.width / 2 : 0), y: e.clientY - (t ? t.top + t.height / 2 : 0) };
135
- }, b = /* @__PURE__ */ new Map();
136
- let Y = !1, pe = 0, R = { x: 0, y: 0 }, Z = null;
137
- const fe = () => {
138
- const [e, t] = [...b.values()];
139
- return { x: (e.x + t.x) / 2, y: (e.y + t.y) / 2 };
140
- }, ge = () => {
141
- const [e, t] = [...b.values()];
142
- return Math.hypot(e.x - t.x, e.y - t.y);
143
- };
144
- function Oe(e) {
145
- e.pointerType === "mouse" && e.button !== 0 || (P.value?.setPointerCapture?.(e.pointerId), b.set(e.pointerId, { x: e.clientX, y: e.clientY }), ie.value = !0, b.size === 1 ? (Y = !1, pe = Date.now(), R = { x: 0, y: 0 }) : Y = !0);
146
- }
147
- function Le(e) {
148
- const t = b.get(e.pointerId);
149
- if (!t) return;
150
- const n = { x: e.clientX, y: e.clientY };
151
- if (b.size === 2) {
152
- const [G, J] = [ge(), fe()];
153
- b.set(e.pointerId, n);
154
- const L = fe();
155
- q(c.value * (ge() / (G || 1)), le({ clientX: L.x, clientY: L.y })), d.value = N({ x: d.value.x + L.x - J.x, y: d.value.y + L.y - J.y }, O.value, x.value, c.value);
156
- return;
157
- }
158
- b.set(e.pointerId, n);
159
- const v = { x: n.x - t.x, y: n.y - t.y };
160
- R = { x: R.x + v.x, y: R.y + v.y }, !(!Y && Math.hypot(R.x, R.y) < kt) && (Y = !0, D.value ? d.value = N({ x: d.value.x + v.x, y: d.value.y + v.y }, O.value, x.value, c.value) : y.value = (y.value + v.x) * (y.value + v.x < 0 && !ve.value || y.value + v.x > 0 && !he.value ? 0.6 : 1));
161
- }
162
- function xe(e, t = !1) {
163
- if (!b.delete(e.pointerId) || b.size > 0) return;
164
- ie.value = !1;
165
- const n = le(e);
166
- if (!Y && !t) {
167
- const L = Z && Date.now() - Z.at < Mt && Math.hypot(n.x - Z.point.x, n.y - Z.point.y) < 32;
168
- Z = L ? null : { at: Date.now(), point: n }, L && (D.value ? U() : q(2, n));
169
- return;
170
- }
171
- const v = Date.now() - pe < 250 && Math.abs(y.value) > 30, G = Math.abs(y.value) > Math.max(50, x.value.width * 0.15), J = y.value;
172
- y.value = 0, !t && !D.value && (G || v) && V(J < 0 ? 1 : -1);
173
- }
174
- function Se(e) {
175
- const t = e.deltaMode === 1 ? 16 : 1;
176
- q(c.value * Math.exp(-e.deltaY * t * (e.ctrlKey ? 0.01 : 15e-4)), le(e));
177
- }
178
- const Ie = { width: 120, height: 80 }, w = g(() => ce.value ? et(O.value, x.value, c.value, d.value, Ie) : null);
179
- function we(e) {
180
- if (e.type === "pointermove" && e.buttons === 0) return;
181
- const t = e.currentTarget.getBoundingClientRect();
182
- t.width === 0 || t.height === 0 || (d.value = tt({ x: (e.clientX - t.left) / t.width, y: (e.clientY - t.top) / t.height }, O.value, x.value, c.value));
183
- }
184
- const Be = g(() => {
185
- if (!w.value) return {};
186
- const { width: e, height: t } = C.value % 2 === 0 ? w.value.image : { width: w.value.image.height, height: w.value.image.width };
187
- return { width: `${e}px`, height: `${t}px`, marginLeft: `${-e / 2}px`, marginTop: `${-t / 2}px`, transform: `rotate(${C.value * 90}deg)` };
188
- });
189
- Xe(() => {
190
- W.value && F();
191
- });
192
- const De = g(() => i.title ?? r("core.viewer.label"));
193
- return (e, t) => (m(), Ve(Ye, { to: "body" }, [
194
- ae.value ? (m(), f("div", at, [
195
- T(Ze, {
196
- appear: "",
197
- "enter-active-class": "transition-opacity duration-motion-normal ease-motion-standard",
198
- "enter-from-class": "opacity-0",
199
- "leave-active-class": "pointer-events-none transition-opacity duration-motion-normal ease-motion-standard",
200
- "leave-to-class": "opacity-0",
201
- onAfterLeave: ze
202
- }, {
203
- default: Ee(() => [
204
- u(W) ? (m(), f("div", {
205
- key: 0,
206
- ref_key: "panel",
207
- ref: $,
208
- role: "dialog",
209
- "aria-modal": "true",
210
- "aria-label": De.value,
211
- tabindex: "-1",
212
- "data-part": "panel",
213
- "data-test": "photo-viewer",
214
- class: "fixed inset-0 flex flex-col bg-[#0b1210] text-[#f1f5f3] outline-none",
215
- onKeydown: Te
216
- }, [
217
- h("div", ot, [
218
- h("h2", nt, [
219
- i.title ? (m(), f("span", lt, ee(i.title) + " · ", 1)) : k("", !0),
220
- h("span", st, ee(u(r)("core.viewer.counter", { current: o.value + 1, total: i.items.length })), 1)
221
- ]),
222
- t[6] || (t[6] = h("div", { class: "grow" }, null, -1)),
223
- p.value ? Ke(e.$slots, "actions", {
224
- item: p.value,
225
- index: o.value
226
- }, void 0, void 0, 0) : k("", !0),
227
- h("button", {
228
- type: "button",
229
- class: M([I, "compact:hidden"]),
230
- "aria-label": u(r)("core.viewer.zoom_out"),
231
- "aria-disabled": !D.value,
232
- "data-test": "zoom-out",
233
- onClick: t[0] || (t[0] = (n) => A(-1))
234
- }, [
235
- T(u(S), {
236
- name: "zoomOut",
237
- size: 18
238
- })
239
- ], 10, rt),
240
- h("p", ut, ee(u(r)("core.viewer.zoom_percent", { percent: $e.value })), 1),
241
- h("button", {
242
- type: "button",
243
- class: M([I, "compact:hidden"]),
244
- "aria-label": u(r)("core.viewer.zoom_in"),
245
- "aria-disabled": c.value >= u(ue),
246
- "data-test": "zoom-in",
247
- onClick: t[1] || (t[1] = (n) => A(1))
248
- }, [
249
- T(u(S), {
250
- name: "zoomIn",
251
- size: 18
252
- })
253
- ], 10, dt),
254
- h("button", {
255
- type: "button",
256
- class: M(I),
257
- "aria-label": u(r)("core.viewer.rotate"),
258
- "data-test": "rotate",
259
- onClick: ne
260
- }, [
261
- T(u(S), {
262
- name: "rotateCounterclockwise",
263
- size: 18
264
- })
265
- ], 8, ct),
266
- p.value ? (m(), f("a", {
267
- key: 1,
268
- href: p.value.src,
269
- download: p.value.downloadName ?? "",
270
- target: "_blank",
271
- rel: "noopener",
272
- class: M(I),
273
- "aria-label": u(r)("core.viewer.download"),
274
- "data-test": "download"
275
- }, [
276
- T(u(S), {
277
- name: "download",
278
- size: 18
279
- })
280
- ], 8, ht)) : k("", !0),
281
- h("button", {
282
- type: "button",
283
- class: M([I, "bg-white/16"]),
284
- "aria-label": u(r)("core.actions.close"),
285
- "data-test": "close",
286
- onClick: me
287
- }, [
288
- T(u(S), {
289
- name: "close",
290
- size: 18
291
- })
292
- ], 10, vt)
293
- ]),
294
- h("div", mt, [
295
- i.items.length > 1 ? (m(), f("button", {
296
- key: 0,
297
- type: "button",
298
- class: M([I, "size-12 compact:hidden"]),
299
- "aria-label": u(r)("core.viewer.previous"),
300
- "aria-disabled": !he.value,
301
- "data-test": "previous",
302
- onClick: t[2] || (t[2] = (n) => V(-1))
303
- }, [
304
- T(u(S), {
305
- name: "arrowLeftSLine",
306
- size: 22
307
- })
308
- ], 10, pt)) : k("", !0),
309
- h("div", {
310
- ref_key: "stage",
311
- ref: x,
312
- "data-test": "photo-stage",
313
- class: M(["relative h-full min-w-0 grow touch-none overflow-hidden rounded-md select-none", D.value ? "cursor-grab active:cursor-grabbing" : ""]),
314
- onPointerdown: Oe,
315
- onPointermove: Le,
316
- onPointerup: t[3] || (t[3] = (n) => xe(n)),
317
- onPointercancel: t[4] || (t[4] = (n) => xe(n, !0)),
318
- onWheel: re(Se, ["prevent"])
319
- }, [
320
- p.value ? (m(), f("img", {
321
- key: p.value.src,
322
- ref: "image",
323
- src: p.value.src,
324
- alt: p.value.alt,
325
- draggable: "false",
326
- "data-test": "photo",
327
- class: M(["absolute top-1/2 left-1/2 max-w-none", [ce.value ? "" : "opacity-0", ie.value ? "" : "transition-transform duration-motion-normal ease-motion-standard", X.value === "back" ? "animate-step-back" : X.value === "forward" ? "animate-step-in" : ""]]),
328
- style: te(Pe.value),
329
- onLoad: oe
330
- }, null, 46, ft)) : k("", !0),
331
- D.value && w.value ? (m(), f("div", {
332
- key: 1,
333
- "data-test": "mini-map",
334
- class: "absolute right-3.5 bottom-3.5 overflow-hidden rounded-md bg-black/50 ring-1 ring-white/20",
335
- style: te({ width: `${w.value.image.width}px`, height: `${w.value.image.height}px` }),
336
- onPointerdown: re(we, ["stop"]),
337
- onPointermove: re(we, ["stop"])
338
- }, [
339
- p.value ? (m(), f("img", {
340
- key: 0,
341
- src: p.value.thumb ?? p.value.src,
342
- alt: "",
343
- draggable: "false",
344
- class: "pointer-events-none absolute top-1/2 left-1/2 max-w-none opacity-80",
345
- style: te(Be.value)
346
- }, null, 12, gt)) : k("", !0),
347
- h("span", {
348
- class: "pointer-events-none absolute rounded-xs ring-2 ring-[#6ee7b7]",
349
- "data-test": "mini-map-view",
350
- style: te({ left: `${w.value.view.x}px`, top: `${w.value.view.y}px`, width: `${w.value.view.width}px`, height: `${w.value.view.height}px` })
351
- }, null, 4)
352
- ], 36)) : k("", !0)
353
- ], 34),
354
- i.items.length > 1 ? (m(), f("button", {
355
- key: 1,
356
- type: "button",
357
- class: M([I, "size-12 compact:hidden"]),
358
- "aria-label": u(r)("core.viewer.next"),
359
- "aria-disabled": !ve.value,
360
- "data-test": "next",
361
- onClick: t[5] || (t[5] = (n) => V(1))
362
- }, [
363
- T(u(S), {
364
- name: "arrowRightSLine",
365
- size: 22
366
- })
367
- ], 10, xt)) : k("", !0)
368
- ]),
369
- i.items.length > 1 ? (m(), f("ul", {
370
- key: 0,
371
- ref_key: "strip",
372
- ref: de,
373
- "data-test": "photo-strip",
374
- class: "flex shrink-0 justify-start gap-2 overflow-x-auto px-4 pt-4 pb-[max(1.25rem,var(--app-safe-bottom))] scrollbar-hide md:justify-center md:px-4.5"
375
- }, [
376
- (m(!0), f(We, null, je(i.items, (n, v) => (m(), f("li", {
377
- key: n.src,
378
- class: "shrink-0"
379
- }, [
380
- h("button", {
381
- type: "button",
382
- "aria-label": n.alt,
383
- "aria-current": v === o.value ? "true" : void 0,
384
- "data-test": "thumbnail",
385
- class: M(["block h-11 w-16 cursor-pointer overflow-hidden rounded-[5px] bg-[#2a3431] transition-opacity duration-motion-fast focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#6ee7b7]", v === o.value ? "ring-2 ring-[#6ee7b7]" : "opacity-60 hover:opacity-100"]),
386
- onClick: (G) => {
387
- X.value = v > o.value ? "forward" : "back", o.value = v;
388
- }
389
- }, [
390
- h("img", {
391
- src: n.thumb ?? n.src,
392
- alt: "",
393
- loading: "lazy",
394
- draggable: "false",
395
- class: "size-full object-cover"
396
- }, null, 8, yt)
397
- ], 10, wt)
398
- ]))), 128))
399
- ], 512)) : (m(), f("div", bt)),
400
- h("span", _t, ee(p.value?.alt), 1)
401
- ], 40, it)) : k("", !0)
402
- ]),
403
- _: 3
404
- })
405
- ])) : k("", !0)
406
- ]));
407
- }
408
- });
409
- export {
410
- Tt as _
411
- };