maz-ui 3.22.4 → 3.23.1
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/components/MazAvatar.mjs +2 -2
- package/components/MazBackdrop.mjs +67 -107
- package/components/MazBadge.mjs +41 -50
- package/components/MazBottomSheet.mjs +2 -2
- package/components/MazBtn.mjs +2 -2
- package/components/MazCard.mjs +2 -2
- package/components/MazCarousel.mjs +2 -2
- package/components/MazChart.mjs +53 -63
- package/components/MazCheckbox.mjs +84 -128
- package/components/MazDialog.mjs +2 -2
- package/components/MazDialogPromise.mjs +3 -3
- package/components/MazDrawer.mjs +2 -2
- package/components/MazDropdown.mjs +2 -2
- package/components/MazDropzone.mjs +2 -2
- package/components/MazFullscreenLoader.mjs +14 -18
- package/components/MazGallery.mjs +352 -558
- package/components/MazIcon.mjs +76 -140
- package/components/MazInput.mjs +2 -2
- package/components/MazInputNumber.mjs +72 -99
- package/components/MazInputPrice.mjs +2 -2
- package/components/MazInputTags.mjs +2 -2
- package/components/MazLazyImg.mjs +2 -2
- package/components/MazPhoneNumberInput.mjs +2 -2
- package/components/MazPicker.mjs +2 -2
- package/components/MazRadio.mjs +65 -94
- package/components/MazRadioButtons.mjs +64 -78
- package/components/MazSelect.mjs +2 -2
- package/components/MazSlider.mjs +213 -325
- package/components/MazSpinner.mjs +25 -34
- package/components/MazStepper.mjs +2 -2
- package/components/MazSwitch.mjs +43 -60
- package/components/MazTabs.mjs +16 -25
- package/components/MazTabsBar.mjs +2 -2
- package/components/MazTabsContent.mjs +34 -43
- package/components/MazTabsContentItem.mjs +49 -63
- package/components/MazTextarea.mjs +124 -169
- package/components/MazTransitionExpand.mjs +36 -54
- package/components/assets/MazBackdrop.css +1 -1
- package/components/assets/MazBottomSheet.css +1 -1
- package/components/assets/MazDialog.css +1 -1
- package/components/assets/MazDialogPromise.css +1 -1
- package/components/assets/MazDrawer.css +1 -1
- package/components/assets/MazPhoneNumberInput.css +1 -1
- package/components/assets/MazSelect.css +1 -1
- package/components/chunks/MazAvatar-1636f58b.mjs +126 -0
- package/components/chunks/MazBottomSheet-c24f92f8.mjs +217 -0
- package/components/chunks/MazBtn-124f3700.mjs +153 -0
- package/components/chunks/MazBtn-1e61862b.mjs +153 -0
- package/components/chunks/MazBtn-2d1d1ba5.mjs +153 -0
- package/components/chunks/MazBtn-3d74f737.mjs +153 -0
- package/components/chunks/MazBtn-4a447126.mjs +153 -0
- package/components/chunks/MazBtn-555928ed.mjs +153 -0
- package/components/chunks/MazBtn-571454f6.mjs +153 -0
- package/components/chunks/MazBtn-5e426592.mjs +153 -0
- package/components/chunks/MazBtn-683effc1.mjs +153 -0
- package/components/chunks/MazBtn-6905cc39.mjs +153 -0
- package/components/chunks/MazBtn-6ce4cfd3.mjs +153 -0
- package/components/chunks/MazBtn-74656d5b.mjs +153 -0
- package/components/chunks/MazBtn-7706b2da.mjs +158 -0
- package/components/chunks/MazBtn-a7a913dd.mjs +153 -0
- package/components/chunks/MazBtn-fb3c7af8.mjs +153 -0
- package/components/chunks/MazCard-bcc36489.mjs +214 -0
- package/components/chunks/MazCarousel-6da75122.mjs +107 -0
- package/components/chunks/MazCheckbox-040dc2c4.mjs +117 -0
- package/components/chunks/MazCheckbox-3a2b48b4.mjs +117 -0
- package/components/chunks/MazDialog-44eda544.mjs +250 -0
- package/components/chunks/MazDialogPromise-eec5acde.mjs +419 -0
- package/components/chunks/MazDrawer-b628b37e.mjs +206 -0
- package/components/chunks/MazDropdown-6f2248b0.mjs +345 -0
- package/components/chunks/MazDropzone-8cac10a6.mjs +242 -0
- package/components/chunks/MazGallery-6b8ecedf.mjs +617 -0
- package/components/chunks/MazIcon-52a76873.mjs +101 -0
- package/components/chunks/MazIcon-95e31ff8.mjs +96 -0
- package/components/chunks/MazInput-1ed4f946.mjs +283 -0
- package/components/chunks/MazInput-8a217995.mjs +271 -0
- package/components/chunks/MazInput-c51881ea.mjs +278 -0
- package/components/chunks/MazInputPrice-cd348d46.mjs +392 -0
- package/components/chunks/MazInputTags-aa95fae7.mjs +446 -0
- package/components/chunks/MazLazyImg-0412ab38.mjs +259 -0
- package/components/chunks/MazLazyImg-47d3449a.mjs +254 -0
- package/components/chunks/MazPhoneNumberInput-e1bf46f9.mjs +1216 -0
- package/components/chunks/MazPicker-e4620d8b.mjs +1140 -0
- package/components/chunks/MazPickerCalendar-da62262c.mjs +535 -0
- package/components/chunks/MazPickerHeader-a2e041eb.mjs +186 -0
- package/components/chunks/MazPickerMonthSwitcher-5bf8bd08.mjs +97 -0
- package/components/chunks/MazPickerShortcuts-7f95430e.mjs +74 -0
- package/components/chunks/MazPickerTime-717402ae.mjs +219 -0
- package/components/chunks/MazPickerYearSwitcher-85f97b6d.mjs +106 -0
- package/components/chunks/MazSelect-6ff6bb96.mjs +652 -0
- package/components/chunks/MazSpinner-054f948c.mjs +39 -0
- package/components/chunks/MazSpinner-059ee1d2.mjs +39 -0
- package/components/chunks/MazSpinner-08ee440b.mjs +39 -0
- package/components/chunks/MazSpinner-13403729.mjs +39 -0
- package/components/chunks/MazSpinner-44011019.mjs +39 -0
- package/components/chunks/MazSpinner-452a1534.mjs +39 -0
- package/components/chunks/MazSpinner-4c02cfd2.mjs +39 -0
- package/components/chunks/MazSpinner-51aa73ca.mjs +39 -0
- package/components/chunks/MazSpinner-6d1d24d5.mjs +39 -0
- package/components/chunks/MazSpinner-6e7c4705.mjs +39 -0
- package/components/chunks/MazSpinner-7895f54f.mjs +39 -0
- package/components/chunks/MazSpinner-7eee202e.mjs +39 -0
- package/components/chunks/MazSpinner-805e14a6.mjs +39 -0
- package/components/chunks/MazSpinner-85080b43.mjs +39 -0
- package/components/chunks/MazSpinner-a13a50c9.mjs +39 -0
- package/components/chunks/MazSpinner-a6d61cee.mjs +43 -0
- package/components/chunks/MazSpinner-c67b05bb.mjs +39 -0
- package/components/chunks/MazSpinner-caa33afc.mjs +39 -0
- package/components/chunks/MazSpinner-cb8fbe9a.mjs +39 -0
- package/components/chunks/MazSpinner-d9ef329f.mjs +39 -0
- package/components/chunks/MazStepper-39f018f3.mjs +191 -0
- package/components/chunks/MazTabsBar-27965f16.mjs +132 -0
- package/components/chunks/MazTransitionExpand-55cfbecb.mjs +41 -0
- package/components/chunks/MazTransitionExpand-cd24498f.mjs +41 -0
- package/components/chunks/_plugin-vue_export-helper-dad06003.mjs +9 -0
- package/components/chunks/check-31d7ba2f.mjs +30 -0
- package/components/chunks/check-c9b483c0.mjs +30 -0
- package/components/chunks/{check-circle-7acfa4c4.mjs → check-circle-59c383ed.mjs} +10 -12
- package/components/chunks/chevron-down-2b60111a.mjs +30 -0
- package/components/chunks/chevron-left-39b4621e.mjs +30 -0
- package/components/chunks/chevron-right-949a60fa.mjs +30 -0
- package/components/chunks/debounce-19c516b6.mjs +11 -0
- package/components/chunks/examples.mobile.json-f63d22fb.mjs +4 -0
- package/components/chunks/{exclamation-circle-2e115536.mjs → exclamation-circle-e2620aab.mjs} +10 -12
- package/components/chunks/{exclamation-triangle-10eb48dc.mjs → exclamation-triangle-21bf116a.mjs} +10 -12
- package/components/chunks/{eye-fbb13657.mjs → eye-dc12ce09.mjs} +12 -15
- package/components/chunks/{eye-slash-342420ff.mjs → eye-slash-fa42a017.mjs} +10 -12
- package/components/chunks/{magnifying-glass-5dffa35e.mjs → magnifying-glass-908981c0.mjs} +10 -12
- package/components/chunks/minus-e71140e1.mjs +30 -0
- package/components/chunks/no-photography-4c6c77cf.mjs +4 -0
- package/components/chunks/{no-photography-b0d08d6f.mjs → no-photography-be94ddda.mjs} +12 -15
- package/components/chunks/{no-symbol-975ce547.mjs → no-symbol-87477ad0.mjs} +10 -12
- package/components/chunks/{pencil-2f766dc8.mjs → pencil-4c35b4e7.mjs} +10 -12
- package/components/chunks/plus-c20544c3.mjs +30 -0
- package/components/chunks/x-mark-35f2f1e7.mjs +30 -0
- package/components/chunks/x-mark-7761acf4.mjs +29 -0
- package/modules/chunks/MazBtn-2f302422.cjs +1 -0
- package/modules/chunks/MazBtn-760c3b29.mjs +153 -0
- package/modules/chunks/MazIcon-0bd6b78e.mjs +96 -0
- package/modules/chunks/MazIcon-599a907f.cjs +1 -0
- package/modules/chunks/MazSpinner-03bd76bd.mjs +39 -0
- package/modules/chunks/MazSpinner-6ffa8db1.cjs +1 -0
- package/modules/chunks/{arrow-top-right-on-square-32bbe5a1.mjs → arrow-top-right-on-square-15191934.mjs} +10 -12
- package/modules/chunks/arrow-top-right-on-square-8e4ea6e2.cjs +1 -0
- package/modules/chunks/chevron-left-36731110.cjs +1 -0
- package/modules/chunks/chevron-left-39b4621e.mjs +30 -0
- package/modules/chunks/index-6a90ef88.mjs +1618 -0
- package/modules/chunks/index-794680d2.cjs +124 -0
- package/modules/chunks/{link-4eb05848.mjs → link-bb14441d.mjs} +10 -12
- package/modules/chunks/link-c7791a2a.cjs +1 -0
- package/modules/chunks/no-photography-0f6fcaf4.cjs +1 -0
- package/modules/chunks/no-photography-4c6c77cf.mjs +4 -0
- package/modules/chunks/x-mark-35f2f1e7.mjs +30 -0
- package/modules/chunks/x-mark-a28deca5.cjs +1 -0
- package/modules/index.cjs +1 -0
- package/modules/index.mjs +42 -42
- package/nuxt/index.json +1 -1
- package/package.json +14 -4
- package/types/resolvers/index.d.ts +1 -0
- package/types/resolvers/unplugin-vue-components-resolver.d.ts +8 -0
- package/types/utils/index.d.ts +3 -0
- package/components/chunks/MazAvatar-358d78d4.mjs +0 -138
- package/components/chunks/MazBottomSheet-61090f4a.mjs +0 -267
- package/components/chunks/MazBtn-0e02f0da.mjs +0 -184
- package/components/chunks/MazBtn-1daf9063.mjs +0 -184
- package/components/chunks/MazBtn-2f4fa942.mjs +0 -184
- package/components/chunks/MazBtn-31c6b731.mjs +0 -184
- package/components/chunks/MazBtn-48382169.mjs +0 -184
- package/components/chunks/MazBtn-4e1e116e.mjs +0 -184
- package/components/chunks/MazBtn-50abc4c5.mjs +0 -184
- package/components/chunks/MazBtn-84e12b6a.mjs +0 -184
- package/components/chunks/MazBtn-b42e3575.mjs +0 -184
- package/components/chunks/MazBtn-b56a7278.mjs +0 -184
- package/components/chunks/MazBtn-bbd6e9c8.mjs +0 -184
- package/components/chunks/MazBtn-cf0c8fcb.mjs +0 -184
- package/components/chunks/MazBtn-d92908b2.mjs +0 -191
- package/components/chunks/MazBtn-f48da79c.mjs +0 -184
- package/components/chunks/MazBtn-fec4c3b7.mjs +0 -184
- package/components/chunks/MazCard-4331dca0.mjs +0 -237
- package/components/chunks/MazCarousel-7825c7c9.mjs +0 -133
- package/components/chunks/MazCheckbox-ab5ddda2.mjs +0 -153
- package/components/chunks/MazCheckbox-e0bbe6ec.mjs +0 -153
- package/components/chunks/MazDialog-83e54b8c.mjs +0 -290
- package/components/chunks/MazDialogPromise-6967e821.mjs +0 -474
- package/components/chunks/MazDrawer-d778b3d2.mjs +0 -256
- package/components/chunks/MazDropdown-6f4482d7.mjs +0 -426
- package/components/chunks/MazDropzone-d1bb62dc.mjs +0 -325
- package/components/chunks/MazGallery-b2dc4286.mjs +0 -821
- package/components/chunks/MazIcon-b779da0a.mjs +0 -159
- package/components/chunks/MazIcon-bda198b4.mjs +0 -165
- package/components/chunks/MazInput-713b00d0.mjs +0 -326
- package/components/chunks/MazInput-b9386887.mjs +0 -341
- package/components/chunks/MazInput-c33627dd.mjs +0 -334
- package/components/chunks/MazInputPrice-452297f5.mjs +0 -481
- package/components/chunks/MazInputTags-7a463b81.mjs +0 -526
- package/components/chunks/MazLazyImg-6e395356.mjs +0 -336
- package/components/chunks/MazLazyImg-e0d8b6d0.mjs +0 -329
- package/components/chunks/MazPhoneNumberInput-48fe2445.mjs +0 -1536
- package/components/chunks/MazPicker-50fc11d1.mjs +0 -1352
- package/components/chunks/MazPickerCalendar-cacb361c.mjs +0 -689
- package/components/chunks/MazPickerHeader-63d45179.mjs +0 -216
- package/components/chunks/MazPickerMonthSwitcher-913c6e2c.mjs +0 -110
- package/components/chunks/MazPickerShortcuts-c6fabfc6.mjs +0 -88
- package/components/chunks/MazPickerTime-5e4475da.mjs +0 -301
- package/components/chunks/MazPickerYearSwitcher-dd4fa89c.mjs +0 -125
- package/components/chunks/MazSelect-2e5cd411.mjs +0 -850
- package/components/chunks/MazSpinner-022d7bee.mjs +0 -46
- package/components/chunks/MazSpinner-100c99b8.mjs +0 -46
- package/components/chunks/MazSpinner-191ad23b.mjs +0 -46
- package/components/chunks/MazSpinner-3155378b.mjs +0 -46
- package/components/chunks/MazSpinner-339a9006.mjs +0 -46
- package/components/chunks/MazSpinner-53979e96.mjs +0 -46
- package/components/chunks/MazSpinner-68d2f2ac.mjs +0 -46
- package/components/chunks/MazSpinner-6b563b22.mjs +0 -46
- package/components/chunks/MazSpinner-7cdc13e7.mjs +0 -46
- package/components/chunks/MazSpinner-8859d658.mjs +0 -46
- package/components/chunks/MazSpinner-8e180605.mjs +0 -52
- package/components/chunks/MazSpinner-9950424b.mjs +0 -46
- package/components/chunks/MazSpinner-c8270a93.mjs +0 -46
- package/components/chunks/MazSpinner-cb491238.mjs +0 -46
- package/components/chunks/MazSpinner-cb6f99f3.mjs +0 -46
- package/components/chunks/MazSpinner-ce4be8f1.mjs +0 -46
- package/components/chunks/MazSpinner-e5a9f319.mjs +0 -46
- package/components/chunks/MazSpinner-e92bd359.mjs +0 -46
- package/components/chunks/MazSpinner-eea9056d.mjs +0 -46
- package/components/chunks/MazSpinner-f1e69f29.mjs +0 -46
- package/components/chunks/MazStepper-4c19dbfc.mjs +0 -255
- package/components/chunks/MazTabsBar-3c2e2d69.mjs +0 -157
- package/components/chunks/MazTransitionExpand-474b00d4.mjs +0 -57
- package/components/chunks/MazTransitionExpand-f9e5a2d6.mjs +0 -57
- package/components/chunks/_plugin-vue_export-helper-cc2b3d55.mjs +0 -10
- package/components/chunks/check-8da249b1.mjs +0 -32
- package/components/chunks/check-f2fcce10.mjs +0 -32
- package/components/chunks/chevron-down-a78b9604.mjs +0 -32
- package/components/chunks/chevron-left-3365d59b.mjs +0 -32
- package/components/chunks/chevron-right-02f9e837.mjs +0 -32
- package/components/chunks/debounce-7d66ffa9.mjs +0 -12
- package/components/chunks/examples.mobile.json-618ba782.mjs +0 -4
- package/components/chunks/minus-c9cdee90.mjs +0 -32
- package/components/chunks/no-photography-7f2be516.mjs +0 -4
- package/components/chunks/plus-b1b0a5a8.mjs +0 -32
- package/components/chunks/x-mark-3b05101b.mjs +0 -31
- package/components/chunks/x-mark-c6ff45dd.mjs +0 -32
- package/modules/chunks/MazBtn-90ffd148.mjs +0 -184
- package/modules/chunks/MazIcon-988edef7.mjs +0 -159
- package/modules/chunks/MazSpinner-a16a3d8f.mjs +0 -46
- package/modules/chunks/chevron-left-3365d59b.mjs +0 -32
- package/modules/chunks/index-b1625fc2.mjs +0 -2315
- package/modules/chunks/no-photography-7f2be516.mjs +0 -4
- package/modules/chunks/x-mark-c6ff45dd.mjs +0 -32
|
@@ -1,2315 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => {
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
7
|
-
import "../assets/index.css";
|
|
8
|
-
import { inject, createVNode, render, nextTick, defineComponent, defineAsyncComponent, onBeforeMount, ref, computed, onMounted as onMounted$1, onBeforeUnmount, openBlock, createElementBlock, normalizeClass, withModifiers, withKeys, withDirectives, unref, vShow, createCommentVNode, createElementVNode, Transition, withCtx, createBlock, toDisplayString, createTextVNode } from "vue";
|
|
9
|
-
function injectStrict(key, fallback) {
|
|
10
|
-
const resolved = inject(key, fallback);
|
|
11
|
-
if (!resolved) {
|
|
12
|
-
throw new TypeError(`[maz-ui](injectStrict) Could not resolve ${key}`);
|
|
13
|
-
}
|
|
14
|
-
return resolved;
|
|
15
|
-
}
|
|
16
|
-
function debounce(fn, delay) {
|
|
17
|
-
let timeout;
|
|
18
|
-
return function(...args) {
|
|
19
|
-
clearTimeout(timeout);
|
|
20
|
-
timeout = setTimeout(() => {
|
|
21
|
-
fn.apply(this, args);
|
|
22
|
-
}, delay);
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
function truthyFilter(value) {
|
|
26
|
-
return !!value;
|
|
27
|
-
}
|
|
28
|
-
function mount(component, options) {
|
|
29
|
-
let el = options == null ? void 0 : options.element;
|
|
30
|
-
function destroy() {
|
|
31
|
-
if (el)
|
|
32
|
-
render(null, el);
|
|
33
|
-
}
|
|
34
|
-
const vNode = createVNode(
|
|
35
|
-
component,
|
|
36
|
-
{ ...options == null ? void 0 : options.props, ...(options == null ? void 0 : options.addDestroyInProps) ? { destroy } : {} },
|
|
37
|
-
options == null ? void 0 : options.children
|
|
38
|
-
);
|
|
39
|
-
if (options == null ? void 0 : options.app) {
|
|
40
|
-
vNode.appContext = options.app._context;
|
|
41
|
-
if (el) {
|
|
42
|
-
render(vNode, el);
|
|
43
|
-
} else if (typeof document !== "undefined") {
|
|
44
|
-
el = document.createElement("div");
|
|
45
|
-
render(vNode, el);
|
|
46
|
-
}
|
|
47
|
-
} else {
|
|
48
|
-
el = el ?? document.body;
|
|
49
|
-
render(vNode, el);
|
|
50
|
-
}
|
|
51
|
-
return { vNode, destroy, el };
|
|
52
|
-
}
|
|
53
|
-
function isClient() {
|
|
54
|
-
return typeof document !== "undefined";
|
|
55
|
-
}
|
|
56
|
-
class IdleTimeout {
|
|
57
|
-
constructor(callback, options) {
|
|
58
|
-
__publicField(this, "defaultOptions", {
|
|
59
|
-
element: void 0,
|
|
60
|
-
timeout: 60 * 1e3 * 5,
|
|
61
|
-
// 5 minutes
|
|
62
|
-
once: false,
|
|
63
|
-
immediate: true
|
|
64
|
-
});
|
|
65
|
-
__publicField(this, "options");
|
|
66
|
-
__publicField(this, "timeoutHandler");
|
|
67
|
-
__publicField(this, "isIdle", false);
|
|
68
|
-
__publicField(this, "isDestroy", false);
|
|
69
|
-
__publicField(this, "startTime", 0);
|
|
70
|
-
__publicField(this, "remainingTime", 0);
|
|
71
|
-
__publicField(this, "lastClientX", -1);
|
|
72
|
-
__publicField(this, "lastClientY", -1);
|
|
73
|
-
__publicField(this, "eventNames", [
|
|
74
|
-
"DOMMouseScroll",
|
|
75
|
-
"mousedown",
|
|
76
|
-
"mousemove",
|
|
77
|
-
"mousewheel",
|
|
78
|
-
"MSPointerDown",
|
|
79
|
-
"MSPointerMove",
|
|
80
|
-
"keydown",
|
|
81
|
-
"touchmove",
|
|
82
|
-
"touchstart",
|
|
83
|
-
"wheel",
|
|
84
|
-
"click"
|
|
85
|
-
]);
|
|
86
|
-
__publicField(this, "handleEvent", (event) => {
|
|
87
|
-
try {
|
|
88
|
-
if (this.remainingTime > 0) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
if (event.type === "mousemove") {
|
|
92
|
-
const { clientX, clientY } = event;
|
|
93
|
-
if (clientX === void 0 && clientY === void 0 || clientX === this.lastClientX && clientY === this.lastClientY) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
this.lastClientX = clientX;
|
|
97
|
-
this.lastClientY = clientY;
|
|
98
|
-
}
|
|
99
|
-
this.resetTimeout();
|
|
100
|
-
this.callback({ isIdle: this.isIdle, eventType: event.type });
|
|
101
|
-
} catch (error) {
|
|
102
|
-
throw new Error(`[IdleTimeout](handleEvent) ${error}`);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
this.callback = callback;
|
|
106
|
-
this.options = {
|
|
107
|
-
...this.defaultOptions,
|
|
108
|
-
...options
|
|
109
|
-
};
|
|
110
|
-
if (isClient()) {
|
|
111
|
-
this.start();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
get element() {
|
|
115
|
-
return this.options.element ?? document.body;
|
|
116
|
-
}
|
|
117
|
-
start() {
|
|
118
|
-
if (!isClient()) {
|
|
119
|
-
console.warn(`[IdleTimeout](start) you should run this method on client side`);
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
for (const eventName of this.eventNames) {
|
|
123
|
-
this.element.addEventListener(eventName, this.handleEvent);
|
|
124
|
-
}
|
|
125
|
-
this.resetTimeout();
|
|
126
|
-
if (this.options.immediate) {
|
|
127
|
-
this.callback({ isIdle: false });
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
pause() {
|
|
131
|
-
const remainingTime = this.startTime + this.options.timeout - Date.now();
|
|
132
|
-
if (remainingTime <= 0) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
this.remainingTime = remainingTime;
|
|
136
|
-
if (this.timeoutHandler) {
|
|
137
|
-
clearTimeout(this.timeoutHandler);
|
|
138
|
-
this.timeoutHandler = void 0;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
resume() {
|
|
142
|
-
if (this.remainingTime <= 0) {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
this.resetTimeout();
|
|
146
|
-
this.callback({ isIdle: this.isIdle });
|
|
147
|
-
this.remainingTime = 0;
|
|
148
|
-
}
|
|
149
|
-
reset() {
|
|
150
|
-
this.isDestroy = false;
|
|
151
|
-
this.isIdle = false;
|
|
152
|
-
this.remainingTime = 0;
|
|
153
|
-
this.resetTimeout();
|
|
154
|
-
this.callback({ isIdle: this.isIdle });
|
|
155
|
-
}
|
|
156
|
-
destroy() {
|
|
157
|
-
if (!isClient()) {
|
|
158
|
-
console.warn(`[IdleTimeout](destroy) you should run this method on client side`);
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
this.isDestroy = true;
|
|
162
|
-
for (const eventName of this.eventNames) {
|
|
163
|
-
this.element.removeEventListener(eventName, this.handleEvent);
|
|
164
|
-
}
|
|
165
|
-
if (this.timeoutHandler) {
|
|
166
|
-
clearTimeout(this.timeoutHandler);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
resetTimeout() {
|
|
170
|
-
this.isIdle = false;
|
|
171
|
-
if (this.timeoutHandler) {
|
|
172
|
-
clearTimeout(this.timeoutHandler);
|
|
173
|
-
this.timeoutHandler = void 0;
|
|
174
|
-
}
|
|
175
|
-
this.timeoutHandler = setTimeout(
|
|
176
|
-
this.handleTimeout.bind(this),
|
|
177
|
-
this.remainingTime || this.options.timeout
|
|
178
|
-
);
|
|
179
|
-
this.startTime = Date.now();
|
|
180
|
-
}
|
|
181
|
-
handleTimeout() {
|
|
182
|
-
this.isIdle = true;
|
|
183
|
-
this.callback({ isIdle: this.isIdle });
|
|
184
|
-
if (this.options.once) {
|
|
185
|
-
this.destroy();
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
get destroyed() {
|
|
189
|
-
return this.isDestroy;
|
|
190
|
-
}
|
|
191
|
-
get timeout() {
|
|
192
|
-
return this.options.timeout;
|
|
193
|
-
}
|
|
194
|
-
set timeout(value) {
|
|
195
|
-
this.options.timeout = value;
|
|
196
|
-
}
|
|
197
|
-
get idle() {
|
|
198
|
-
return this.isIdle;
|
|
199
|
-
}
|
|
200
|
-
set idle(value) {
|
|
201
|
-
if (value) {
|
|
202
|
-
this.handleTimeout();
|
|
203
|
-
} else {
|
|
204
|
-
this.reset();
|
|
205
|
-
}
|
|
206
|
-
this.callback({ isIdle: this.isIdle });
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
class UserVisibility {
|
|
210
|
-
constructor(callback, options) {
|
|
211
|
-
__publicField(this, "eventHandlerFunction");
|
|
212
|
-
__publicField(this, "event", "visibilitychange");
|
|
213
|
-
__publicField(this, "timeoutHandler");
|
|
214
|
-
__publicField(this, "options");
|
|
215
|
-
__publicField(this, "defaultOptions", {
|
|
216
|
-
timeout: 5e3,
|
|
217
|
-
once: false,
|
|
218
|
-
immediate: true
|
|
219
|
-
});
|
|
220
|
-
__publicField(this, "isVisible", false);
|
|
221
|
-
this.callback = callback;
|
|
222
|
-
this.options = {
|
|
223
|
-
...this.defaultOptions,
|
|
224
|
-
...options
|
|
225
|
-
};
|
|
226
|
-
this.eventHandlerFunction = this.eventHandler.bind(this);
|
|
227
|
-
if (isClient()) {
|
|
228
|
-
this.start();
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
start() {
|
|
232
|
-
if (!isClient()) {
|
|
233
|
-
console.warn(`[UserVisibility](start) you should run this method on client side`);
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
if (this.options.immediate) {
|
|
237
|
-
this.emitCallback();
|
|
238
|
-
}
|
|
239
|
-
this.addEventListener();
|
|
240
|
-
}
|
|
241
|
-
emitCallback() {
|
|
242
|
-
this.isVisible = document.visibilityState === "visible";
|
|
243
|
-
this.callback({ isVisible: this.isVisible });
|
|
244
|
-
if (this.options.once) {
|
|
245
|
-
this.destroy();
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
eventHandler() {
|
|
249
|
-
if (document.visibilityState === "visible" && !this.isVisible) {
|
|
250
|
-
this.clearTimeout();
|
|
251
|
-
this.emitCallback();
|
|
252
|
-
} else if (document.visibilityState === "hidden") {
|
|
253
|
-
this.initTimeout();
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
clearTimeout() {
|
|
257
|
-
if (this.timeoutHandler) {
|
|
258
|
-
clearTimeout(this.timeoutHandler);
|
|
259
|
-
this.timeoutHandler = void 0;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
initTimeout() {
|
|
263
|
-
this.clearTimeout();
|
|
264
|
-
this.timeoutHandler = setTimeout(this.emitCallback.bind(this), this.options.timeout);
|
|
265
|
-
}
|
|
266
|
-
addEventListener() {
|
|
267
|
-
document.addEventListener(this.event, this.eventHandlerFunction);
|
|
268
|
-
}
|
|
269
|
-
removeEventListener() {
|
|
270
|
-
document.removeEventListener(this.event, this.eventHandlerFunction);
|
|
271
|
-
}
|
|
272
|
-
destroy() {
|
|
273
|
-
this.removeEventListener();
|
|
274
|
-
if (this.timeoutHandler) {
|
|
275
|
-
clearTimeout(this.timeoutHandler);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
const sleep = (duration) => {
|
|
280
|
-
return new Promise((resolve) => {
|
|
281
|
-
setTimeout(resolve, duration);
|
|
282
|
-
});
|
|
283
|
-
};
|
|
284
|
-
class ScriptLoader {
|
|
285
|
-
constructor({ src, identifier, once = true, async = true, defer = true }) {
|
|
286
|
-
__publicField(this, "src");
|
|
287
|
-
__publicField(this, "script");
|
|
288
|
-
__publicField(this, "once");
|
|
289
|
-
__publicField(this, "async");
|
|
290
|
-
__publicField(this, "defer");
|
|
291
|
-
__publicField(this, "identifier");
|
|
292
|
-
if (typeof window === "undefined") {
|
|
293
|
-
throw new TypeError("[ScriptLoader]: Is supported only on browser side");
|
|
294
|
-
}
|
|
295
|
-
if (!src) {
|
|
296
|
-
throw new Error('[ScriptLoader]: You should provide the attribut "src"');
|
|
297
|
-
}
|
|
298
|
-
if (!identifier) {
|
|
299
|
-
throw new Error('[ScriptLoader]: You should provide the attribut "identifier"');
|
|
300
|
-
}
|
|
301
|
-
this.src = src;
|
|
302
|
-
this.identifier = identifier;
|
|
303
|
-
this.once = once;
|
|
304
|
-
this.async = async;
|
|
305
|
-
this.defer = defer;
|
|
306
|
-
}
|
|
307
|
-
removeTag(tag) {
|
|
308
|
-
var _a;
|
|
309
|
-
if (typeof tag === "string") {
|
|
310
|
-
(_a = document.head.querySelector(`[data-identifier="${tag}"]`)) == null ? void 0 : _a.remove();
|
|
311
|
-
} else {
|
|
312
|
-
tag.remove();
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
load() {
|
|
316
|
-
const windowInstance = window;
|
|
317
|
-
const scriptTags = document.head.querySelectorAll(`[data-identifier="${this.identifier}"]`);
|
|
318
|
-
if (this.once && windowInstance[this.identifier] && scriptTags.length > 0) {
|
|
319
|
-
this.script = windowInstance[this.identifier];
|
|
320
|
-
return Promise.resolve(this.script);
|
|
321
|
-
}
|
|
322
|
-
if (!this.once && scriptTags.length > 0) {
|
|
323
|
-
for (const tag of scriptTags) {
|
|
324
|
-
this.removeTag(tag);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
return this.injectScript();
|
|
328
|
-
}
|
|
329
|
-
injectScript() {
|
|
330
|
-
const windowInstance = window;
|
|
331
|
-
return new Promise((resolve, reject) => {
|
|
332
|
-
try {
|
|
333
|
-
const script = document.createElement("script");
|
|
334
|
-
script.src = this.src;
|
|
335
|
-
script.async = this.async;
|
|
336
|
-
script.defer = this.defer;
|
|
337
|
-
script.dataset.identifier = this.identifier;
|
|
338
|
-
script.addEventListener("error", (error) => {
|
|
339
|
-
return reject(new Error(`[ScriptLoader](injectScript) ${error.message}`));
|
|
340
|
-
});
|
|
341
|
-
script.addEventListener("load", (success) => {
|
|
342
|
-
this.script = success;
|
|
343
|
-
windowInstance[this.identifier] = success;
|
|
344
|
-
return resolve(success);
|
|
345
|
-
});
|
|
346
|
-
document.head.append(script);
|
|
347
|
-
} catch (error) {
|
|
348
|
-
throw new Error(`[ScriptLoader](init) ${error}`);
|
|
349
|
-
}
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
function countryCodeToUnicodeFlag(locale) {
|
|
354
|
-
const characters = [...locale];
|
|
355
|
-
return characters.map((letter) => letter.charCodeAt(0) % 32 + 127461).map((n) => String.fromCodePoint(n)).join("");
|
|
356
|
-
}
|
|
357
|
-
const UNIQUE_ID = "__vue_click_away__";
|
|
358
|
-
const getEventType$1 = () => {
|
|
359
|
-
return document.ontouchstart === null ? "touchstart" : "click";
|
|
360
|
-
};
|
|
361
|
-
const onMounted = async (el, binding) => {
|
|
362
|
-
onUnmounted(el);
|
|
363
|
-
const vm = binding.instance;
|
|
364
|
-
const callback = binding.value;
|
|
365
|
-
const isCallbackFunction = typeof callback === "function";
|
|
366
|
-
if (!isCallbackFunction) {
|
|
367
|
-
throw new Error("[maz-ui](vClickOutside) the callback should be a function");
|
|
368
|
-
}
|
|
369
|
-
await nextTick();
|
|
370
|
-
el[UNIQUE_ID] = (event) => {
|
|
371
|
-
if ((!el || !el.contains(event.target)) && callback && isCallbackFunction) {
|
|
372
|
-
return callback.call(vm, event);
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
const eventType = getEventType$1();
|
|
376
|
-
document.addEventListener(eventType, el[UNIQUE_ID], false);
|
|
377
|
-
};
|
|
378
|
-
const onUnmounted = (el) => {
|
|
379
|
-
const eventType = getEventType$1();
|
|
380
|
-
document.removeEventListener(eventType, el[UNIQUE_ID], false);
|
|
381
|
-
delete el[UNIQUE_ID];
|
|
382
|
-
};
|
|
383
|
-
const onUpdated = (el, binding) => {
|
|
384
|
-
if (binding.value === binding.oldValue) {
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
onMounted(el, binding);
|
|
388
|
-
};
|
|
389
|
-
const directive$1 = {
|
|
390
|
-
mounted: onMounted,
|
|
391
|
-
updated: onUpdated,
|
|
392
|
-
unmounted: onUnmounted
|
|
393
|
-
};
|
|
394
|
-
const plugin$5 = {
|
|
395
|
-
install: (app) => {
|
|
396
|
-
app.directive("click-outside", directive$1);
|
|
397
|
-
}
|
|
398
|
-
};
|
|
399
|
-
const handleOutsideClick = (event, element, binding, vnode) => {
|
|
400
|
-
event.stopPropagation();
|
|
401
|
-
const { handler, exclude } = binding.value;
|
|
402
|
-
let clickedOnExcludedElement = false;
|
|
403
|
-
if (exclude && exclude.length > 0) {
|
|
404
|
-
for (const referenceName of exclude) {
|
|
405
|
-
if (!clickedOnExcludedElement) {
|
|
406
|
-
const excludedElement = vnode.context.$refs[referenceName];
|
|
407
|
-
clickedOnExcludedElement = excludedElement.contains(event.target);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
if (!element.contains(event.target) && !clickedOnExcludedElement) {
|
|
412
|
-
vnode.context[handler]();
|
|
413
|
-
}
|
|
414
|
-
};
|
|
415
|
-
const getEventType = () => {
|
|
416
|
-
return document.ontouchstart === null ? "touchstart" : "click";
|
|
417
|
-
};
|
|
418
|
-
const unbind = (element, binding, vnode) => {
|
|
419
|
-
const eventType = getEventType();
|
|
420
|
-
document.removeEventListener(
|
|
421
|
-
eventType,
|
|
422
|
-
(event) => handleOutsideClick(event, element, binding, vnode)
|
|
423
|
-
);
|
|
424
|
-
};
|
|
425
|
-
const bind = (element, binding, vnode) => {
|
|
426
|
-
const eventType = getEventType();
|
|
427
|
-
document.addEventListener(
|
|
428
|
-
eventType,
|
|
429
|
-
(event) => handleOutsideClick(event, element, binding, vnode)
|
|
430
|
-
);
|
|
431
|
-
};
|
|
432
|
-
const directive = {
|
|
433
|
-
mounted: bind,
|
|
434
|
-
unmounted: unbind
|
|
435
|
-
};
|
|
436
|
-
const plugin$4 = {
|
|
437
|
-
install: (app) => {
|
|
438
|
-
app.directive("closable", directive);
|
|
439
|
-
}
|
|
440
|
-
};
|
|
441
|
-
const style = `
|
|
442
|
-
.maz-zoom-img {
|
|
443
|
-
position: fixed;
|
|
444
|
-
top: 0;
|
|
445
|
-
bottom: 0;
|
|
446
|
-
left: 0;
|
|
447
|
-
right: 0;
|
|
448
|
-
padding: 1rem;
|
|
449
|
-
z-index: 1050;
|
|
450
|
-
background-color: hsla(238, 15%, 40%, 0.7);
|
|
451
|
-
display: flex;
|
|
452
|
-
align-items: center;
|
|
453
|
-
justify-content: center;
|
|
454
|
-
flex-direction: column;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
.maz-zoom-img,
|
|
458
|
-
.maz-zoom-img * {
|
|
459
|
-
box-sizing: border-box;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
.maz-zoom-img .maz-zoom-img__wrapper {
|
|
463
|
-
position: relative;
|
|
464
|
-
display: flex;
|
|
465
|
-
justify-content: center;
|
|
466
|
-
align-items: center;
|
|
467
|
-
min-width: 0;
|
|
468
|
-
min-height: 0;
|
|
469
|
-
max-width: 100%;
|
|
470
|
-
max-height: 100%;
|
|
471
|
-
transition: all 300ms ease-in-out;
|
|
472
|
-
opacity: 0;
|
|
473
|
-
transform: scale(0.5);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
.maz-zoom-img.maz-animate .maz-zoom-img__wrapper {
|
|
477
|
-
opacity: 1;
|
|
478
|
-
transform: scale(1);
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
.maz-zoom-img.maz-animate .maz-zoom-img__loader {
|
|
482
|
-
position: absolute;
|
|
483
|
-
top: 0;
|
|
484
|
-
bottom: 0;
|
|
485
|
-
left: 0;
|
|
486
|
-
right: 0;
|
|
487
|
-
display: flex;
|
|
488
|
-
align-items: center;
|
|
489
|
-
justify-content: center;
|
|
490
|
-
background-color: hsla(238, 15%, 40%, 0.7);
|
|
491
|
-
border-radius: 1rem;
|
|
492
|
-
z-index: 2;
|
|
493
|
-
min-width: 60px;
|
|
494
|
-
min-height: 60px;
|
|
495
|
-
}
|
|
496
|
-
.maz-zoom-img.maz-animate .maz-zoom-img__loader[hidden] {
|
|
497
|
-
display: none;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
@-webkit-keyframes spin {
|
|
501
|
-
0% { transform: rotate(0deg); }
|
|
502
|
-
100% { transform: rotate(360deg); }
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
@keyframes spin {
|
|
506
|
-
0% { transform: rotate(0deg); }
|
|
507
|
-
100% { transform: rotate(360deg); }
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
.maz-zoom-img.maz-animate .maz-zoom-img__loader__svg {
|
|
511
|
-
animation: spin .6s linear infinite;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
.maz-zoom-img img {
|
|
515
|
-
max-width: 100%;
|
|
516
|
-
max-height: 100%;
|
|
517
|
-
min-width: 0;
|
|
518
|
-
border-radius: 1rem;
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
.maz-zoom-img .maz-zoom-btn {
|
|
522
|
-
margin: 0 auto;
|
|
523
|
-
border: none;
|
|
524
|
-
background-color: hsla(0, 0%, 7%, 0.5);
|
|
525
|
-
box-shadow: 0 0 0.5rem 0 hsla(0, 0%, 0%, 0.2);
|
|
526
|
-
height: 2.2rem;
|
|
527
|
-
min-height: 2.2rem;
|
|
528
|
-
width: 2.2rem;
|
|
529
|
-
min-width: 2.2rem;
|
|
530
|
-
display: flex;
|
|
531
|
-
align-items: center;
|
|
532
|
-
justify-content: center;
|
|
533
|
-
border-radius: 2.2rem;
|
|
534
|
-
cursor: pointer;
|
|
535
|
-
flex: 0 0 auto;
|
|
536
|
-
outline: none;
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
.maz-zoom-img .maz-zoom-btn svg {
|
|
540
|
-
fill: white;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
.maz-zoom-img .maz-zoom-btn.maz-zoom-btn--close {
|
|
544
|
-
position: absolute;
|
|
545
|
-
top: 0.5rem;
|
|
546
|
-
right: 0.5rem;
|
|
547
|
-
z-index: 1;
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
.maz-zoom-img .maz-zoom-btn.maz-zoom-btn--previous {
|
|
551
|
-
position: absolute;
|
|
552
|
-
left: 0.5rem;
|
|
553
|
-
z-index: 1;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
.maz-zoom-img .maz-zoom-btn.maz-zoom-btn--next {
|
|
557
|
-
position: absolute;
|
|
558
|
-
right: 0.5rem;
|
|
559
|
-
z-index: 1;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
.maz-zoom-img .maz-zoom-btn:hover {
|
|
563
|
-
background-color: hsl(0, 0%, 0%);
|
|
564
|
-
}`;
|
|
565
|
-
const svgs = {
|
|
566
|
-
close: '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>',
|
|
567
|
-
next: '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg>',
|
|
568
|
-
previous: '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/></svg>',
|
|
569
|
-
spinner: '<svg width="40px" height="40px" version="1.1" xmlns="http://www.w3.org/2000/svg" fill="currentColor" x="0px" y="0px" viewBox="0 0 50 50" xml:space="preserve" class="maz-zoom-img__loader__svg" data-v-6d1cb50c=""><path d="M43.935,25.145c0-10.318-8.364-18.683-18.683-18.683c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615c8.072,0,14.615,6.543,14.615,14.615H43.935z"></path></svg>'
|
|
570
|
-
};
|
|
571
|
-
class VueZoomImg {
|
|
572
|
-
constructor(binding) {
|
|
573
|
-
__publicField(this, "options");
|
|
574
|
-
__publicField(this, "loader");
|
|
575
|
-
__publicField(this, "wrapper");
|
|
576
|
-
__publicField(this, "img");
|
|
577
|
-
__publicField(this, "keydownHandler");
|
|
578
|
-
__publicField(this, "onImgLoadedCallback");
|
|
579
|
-
__publicField(this, "buttonsAdded");
|
|
580
|
-
__publicField(this, "defaultOptions", {
|
|
581
|
-
scale: true,
|
|
582
|
-
blur: true,
|
|
583
|
-
disabled: false
|
|
584
|
-
});
|
|
585
|
-
__publicField(this, "mouseEnterListener");
|
|
586
|
-
__publicField(this, "mouseLeaveListener");
|
|
587
|
-
__publicField(this, "renderPreviewListener");
|
|
588
|
-
if (!binding.value) {
|
|
589
|
-
throw new Error(
|
|
590
|
-
'[MazUI](zoom-img) Image path must be defined. Ex: `v-zoom-img="<PATH_TO_IMAGE>"`'
|
|
591
|
-
);
|
|
592
|
-
}
|
|
593
|
-
if (typeof binding.value === "object" && !binding.value.src) {
|
|
594
|
-
throw new Error("[maz-ui](zoom-img) src of image must be provided");
|
|
595
|
-
}
|
|
596
|
-
this.buttonsAdded = false;
|
|
597
|
-
this.options = this.buildOptions(binding);
|
|
598
|
-
this.keydownHandler = this.keydownLister.bind(this);
|
|
599
|
-
this.loader = this.getLoader();
|
|
600
|
-
this.wrapper = document.createElement("div");
|
|
601
|
-
this.wrapper.classList.add("maz-zoom-img__wrapper");
|
|
602
|
-
this.wrapper.prepend(this.loader);
|
|
603
|
-
this.img = document.createElement("img");
|
|
604
|
-
this.onImgLoadedCallback = this.onImgLoaded.bind(this);
|
|
605
|
-
this.imgEventHandler(true);
|
|
606
|
-
}
|
|
607
|
-
buildOptions(binding) {
|
|
608
|
-
return {
|
|
609
|
-
...this.defaultOptions,
|
|
610
|
-
...typeof binding.value === "object" ? binding.value : { src: binding.value }
|
|
611
|
-
};
|
|
612
|
-
}
|
|
613
|
-
get allInstances() {
|
|
614
|
-
return [...document.querySelectorAll(".maz-zoom-img-instance")];
|
|
615
|
-
}
|
|
616
|
-
create(el) {
|
|
617
|
-
if (this.options.disabled)
|
|
618
|
-
return;
|
|
619
|
-
el.style.cursor = "pointer";
|
|
620
|
-
setTimeout(() => el.classList.add("maz-zoom-img-instance"));
|
|
621
|
-
el.setAttribute("data-zoom-src", this.options.src);
|
|
622
|
-
if (this.options.alt)
|
|
623
|
-
el.setAttribute("data-zoom-alt", this.options.alt);
|
|
624
|
-
el.style.transition = "all 300ms ease-in-out";
|
|
625
|
-
this.mouseEnterListener = () => this.mouseEnter(el);
|
|
626
|
-
this.mouseLeaveListener = () => this.mouseLeave(el);
|
|
627
|
-
this.renderPreviewListener = () => this.renderPreview(el, this.options);
|
|
628
|
-
el.addEventListener("mouseenter", this.mouseEnterListener);
|
|
629
|
-
el.addEventListener("mouseleave", this.mouseLeaveListener);
|
|
630
|
-
el.addEventListener("click", this.renderPreviewListener);
|
|
631
|
-
}
|
|
632
|
-
update(binding) {
|
|
633
|
-
this.options = this.buildOptions(binding);
|
|
634
|
-
}
|
|
635
|
-
remove(el) {
|
|
636
|
-
this.imgEventHandler(false);
|
|
637
|
-
el.removeEventListener("mouseenter", this.mouseEnterListener);
|
|
638
|
-
el.removeEventListener("mouseleave", this.mouseLeaveListener);
|
|
639
|
-
el.removeEventListener("click", this.renderPreviewListener);
|
|
640
|
-
el.classList.remove("maz-zoom-img-instance");
|
|
641
|
-
el.removeAttribute("data-zoom-src");
|
|
642
|
-
el.removeAttribute("data-zoom-alt");
|
|
643
|
-
el.style.cursor = "";
|
|
644
|
-
}
|
|
645
|
-
renderPreview(el, options) {
|
|
646
|
-
el.classList.add(
|
|
647
|
-
"maz-is-open"
|
|
648
|
-
/* OPEN */
|
|
649
|
-
);
|
|
650
|
-
this.addStyle(style);
|
|
651
|
-
const container = document.createElement("div");
|
|
652
|
-
container.classList.add("maz-zoom-img");
|
|
653
|
-
container.setAttribute("id", "MazImgPreviewFullsize");
|
|
654
|
-
container.addEventListener("click", (e) => {
|
|
655
|
-
if (container.isEqualNode(e.target)) {
|
|
656
|
-
this.closePreview();
|
|
657
|
-
}
|
|
658
|
-
});
|
|
659
|
-
if (typeof options === "object") {
|
|
660
|
-
this.img.setAttribute("src", options.src);
|
|
661
|
-
if (options.alt)
|
|
662
|
-
this.img.setAttribute("alt", options.alt);
|
|
663
|
-
this.img.id = "MazImgElement";
|
|
664
|
-
}
|
|
665
|
-
this.wrapper.append(this.img);
|
|
666
|
-
container.append(this.wrapper);
|
|
667
|
-
document.body.append(container);
|
|
668
|
-
this.keyboardEventHandler(true);
|
|
669
|
-
setTimeout(() => {
|
|
670
|
-
if (container)
|
|
671
|
-
container.classList.add("maz-animate");
|
|
672
|
-
}, 100);
|
|
673
|
-
}
|
|
674
|
-
onImgLoaded() {
|
|
675
|
-
this.wrapper.style.width = `${this.img.width}px`;
|
|
676
|
-
this.wrapper.style.minWidth = `200px`;
|
|
677
|
-
this.loader.hidden = true;
|
|
678
|
-
const closeButton = this.getButton();
|
|
679
|
-
const buttons = [];
|
|
680
|
-
const hasMultipleInstance = this.allInstances.length > 1;
|
|
681
|
-
if (!this.buttonsAdded) {
|
|
682
|
-
this.buttonsAdded = true;
|
|
683
|
-
if (hasMultipleInstance) {
|
|
684
|
-
const previousButton = this.getButton("previous");
|
|
685
|
-
const nextButton = this.getButton("next");
|
|
686
|
-
buttons.push(previousButton, nextButton);
|
|
687
|
-
}
|
|
688
|
-
this.wrapper.append(closeButton);
|
|
689
|
-
if (hasMultipleInstance) {
|
|
690
|
-
this.wrapper.prepend(buttons[0]);
|
|
691
|
-
this.wrapper.append(buttons[1]);
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
getLoader() {
|
|
696
|
-
const loader = document.createElement("div");
|
|
697
|
-
loader.classList.add("maz-zoom-img__loader");
|
|
698
|
-
loader.innerHTML = svgs.spinner;
|
|
699
|
-
return loader;
|
|
700
|
-
}
|
|
701
|
-
mouseLeave(el) {
|
|
702
|
-
if (this.options.scale)
|
|
703
|
-
el.style.transform = "";
|
|
704
|
-
if (this.options.blur)
|
|
705
|
-
el.style.filter = "";
|
|
706
|
-
el.style.zIndex = "";
|
|
707
|
-
}
|
|
708
|
-
mouseEnter(el) {
|
|
709
|
-
el.style.zIndex = "1";
|
|
710
|
-
if (this.options.scale)
|
|
711
|
-
el.style.transform = "scale(1.1)";
|
|
712
|
-
if (this.options.blur)
|
|
713
|
-
el.style.filter = "blur(2px)";
|
|
714
|
-
}
|
|
715
|
-
keydownLister(e) {
|
|
716
|
-
e.preventDefault();
|
|
717
|
-
if (e.key === "Escape" || e.key === " ") {
|
|
718
|
-
this.closePreview();
|
|
719
|
-
}
|
|
720
|
-
if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
|
|
721
|
-
this.nextPreviousImage(e.key === "ArrowRight");
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
getButton(iconName = "close") {
|
|
725
|
-
const button = document.createElement("button");
|
|
726
|
-
button.innerHTML = svgs[iconName];
|
|
727
|
-
button.addEventListener("click", () => {
|
|
728
|
-
iconName === "close" ? this.closePreview() : this.allInstances ? this.nextPreviousImage(iconName === "next") : null;
|
|
729
|
-
});
|
|
730
|
-
button.classList.add("maz-zoom-btn");
|
|
731
|
-
button.classList.add(`maz-zoom-btn--${iconName}`);
|
|
732
|
-
return button;
|
|
733
|
-
}
|
|
734
|
-
closePreview() {
|
|
735
|
-
const container = document.querySelector("#MazImgPreviewFullsize");
|
|
736
|
-
const style2 = document.querySelector("#MazPreviewStyle");
|
|
737
|
-
const instance2 = document.querySelector(
|
|
738
|
-
".maz-zoom-img-instance.maz-is-open"
|
|
739
|
-
);
|
|
740
|
-
if (instance2)
|
|
741
|
-
instance2.classList.remove(
|
|
742
|
-
"maz-is-open"
|
|
743
|
-
/* OPEN */
|
|
744
|
-
);
|
|
745
|
-
if (container)
|
|
746
|
-
container.classList.remove("maz-animate");
|
|
747
|
-
this.keyboardEventHandler(false);
|
|
748
|
-
setTimeout(() => {
|
|
749
|
-
if (container)
|
|
750
|
-
container.remove();
|
|
751
|
-
if (style2)
|
|
752
|
-
style2.remove();
|
|
753
|
-
}, 300);
|
|
754
|
-
}
|
|
755
|
-
getNewInstanceIndex(newInstanceIndex) {
|
|
756
|
-
return newInstanceIndex < 0 ? this.allInstances.length - 1 : newInstanceIndex >= this.allInstances.length ? 0 : newInstanceIndex;
|
|
757
|
-
}
|
|
758
|
-
nextPreviousImage(isNext) {
|
|
759
|
-
const selectNextInstance = isNext;
|
|
760
|
-
const currentInstance = document.querySelector(
|
|
761
|
-
".maz-zoom-img-instance.maz-is-open"
|
|
762
|
-
);
|
|
763
|
-
if (currentInstance) {
|
|
764
|
-
const currentInstanceIndex = this.allInstances.indexOf(currentInstance);
|
|
765
|
-
const newInstanceIndex = selectNextInstance ? currentInstanceIndex + 1 : currentInstanceIndex - 1;
|
|
766
|
-
const nextInstance = this.allInstances[this.getNewInstanceIndex(newInstanceIndex)];
|
|
767
|
-
if (nextInstance) {
|
|
768
|
-
this.useNextInstance(currentInstance, nextInstance);
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
useNextInstance(currentInstance, nextInstance) {
|
|
773
|
-
currentInstance.classList.remove(
|
|
774
|
-
"maz-is-open"
|
|
775
|
-
/* OPEN */
|
|
776
|
-
);
|
|
777
|
-
nextInstance.classList.add(
|
|
778
|
-
"maz-is-open"
|
|
779
|
-
/* OPEN */
|
|
780
|
-
);
|
|
781
|
-
const src = nextInstance.getAttribute("data-zoom-src");
|
|
782
|
-
const alt = nextInstance.getAttribute("data-zoom-alt");
|
|
783
|
-
this.wrapper.style.width = "";
|
|
784
|
-
this.loader.hidden = false;
|
|
785
|
-
if (src)
|
|
786
|
-
this.img.setAttribute("src", src);
|
|
787
|
-
if (alt)
|
|
788
|
-
this.img.setAttribute("alt", alt);
|
|
789
|
-
}
|
|
790
|
-
addStyle(styleString) {
|
|
791
|
-
const style2 = document.createElement("style");
|
|
792
|
-
style2.id = "MazPreviewStyle";
|
|
793
|
-
style2.textContent = styleString;
|
|
794
|
-
document.head.append(style2);
|
|
795
|
-
}
|
|
796
|
-
keyboardEventHandler(add) {
|
|
797
|
-
if (add)
|
|
798
|
-
return document.addEventListener("keydown", this.keydownHandler);
|
|
799
|
-
document.removeEventListener("keydown", this.keydownHandler);
|
|
800
|
-
}
|
|
801
|
-
imgEventHandler(add) {
|
|
802
|
-
if (add)
|
|
803
|
-
return this.img.addEventListener("load", this.onImgLoadedCallback);
|
|
804
|
-
this.img.removeEventListener("load", this.onImgLoadedCallback);
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
let instance$4;
|
|
808
|
-
const vZoomImg = {
|
|
809
|
-
created(el, binding) {
|
|
810
|
-
instance$4 = new VueZoomImg(binding);
|
|
811
|
-
instance$4.create(el);
|
|
812
|
-
},
|
|
813
|
-
updated(_el, binding) {
|
|
814
|
-
instance$4.update(binding);
|
|
815
|
-
},
|
|
816
|
-
unmounted(el) {
|
|
817
|
-
instance$4.remove(el);
|
|
818
|
-
}
|
|
819
|
-
};
|
|
820
|
-
const plugin$3 = {
|
|
821
|
-
install(app) {
|
|
822
|
-
app.directive("zoom-img", vZoomImg);
|
|
823
|
-
}
|
|
824
|
-
};
|
|
825
|
-
const EMPTY_PHOTO = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
|
826
|
-
const DEFAULT_OPTIONS$6 = {
|
|
827
|
-
baseClass: "m-lazy-img",
|
|
828
|
-
loadedClass: "m-lazy-loaded",
|
|
829
|
-
loadingClass: "m-lazy-loading",
|
|
830
|
-
errorClass: "m-lazy-error",
|
|
831
|
-
noPhotoClass: "m-lazy-no-photo",
|
|
832
|
-
noPhoto: false,
|
|
833
|
-
observerOnce: true,
|
|
834
|
-
loadOnce: false,
|
|
835
|
-
noUseErrorPhoto: false,
|
|
836
|
-
observerOptions: {
|
|
837
|
-
threshold: 0.1
|
|
838
|
-
}
|
|
839
|
-
};
|
|
840
|
-
class LazyImg {
|
|
841
|
-
constructor(opts = {}) {
|
|
842
|
-
__publicField(this, "observers", []);
|
|
843
|
-
__publicField(this, "defaultOptions", DEFAULT_OPTIONS$6);
|
|
844
|
-
__publicField(this, "options");
|
|
845
|
-
__publicField(this, "onImgLoadedCallback");
|
|
846
|
-
__publicField(this, "onImgErrorCallback");
|
|
847
|
-
__publicField(this, "hasImgLoaded", false);
|
|
848
|
-
this.options = this.buildOptions(opts);
|
|
849
|
-
this.onImgLoadedCallback = this.imageIsLoaded.bind(this);
|
|
850
|
-
this.onImgErrorCallback = this.imageHasError.bind(this);
|
|
851
|
-
}
|
|
852
|
-
async loadErrorPhoto() {
|
|
853
|
-
const { default: photo } = await import("./no-photography-7f2be516.mjs");
|
|
854
|
-
return photo;
|
|
855
|
-
}
|
|
856
|
-
buildOptions(opts) {
|
|
857
|
-
return {
|
|
858
|
-
...this.defaultOptions,
|
|
859
|
-
...opts,
|
|
860
|
-
observerOptions: {
|
|
861
|
-
...this.defaultOptions.observerOptions,
|
|
862
|
-
...opts.observerOptions
|
|
863
|
-
}
|
|
864
|
-
};
|
|
865
|
-
}
|
|
866
|
-
removeClass(el, className) {
|
|
867
|
-
el.classList.remove(className);
|
|
868
|
-
}
|
|
869
|
-
addClass(el, className) {
|
|
870
|
-
el.classList.add(className);
|
|
871
|
-
}
|
|
872
|
-
removeAllStateClasses(el) {
|
|
873
|
-
this.removeClass(el, this.options.loadedClass);
|
|
874
|
-
this.removeClass(el, this.options.loadingClass);
|
|
875
|
-
this.removeClass(el, this.options.errorClass);
|
|
876
|
-
this.removeClass(el, this.options.noPhotoClass);
|
|
877
|
-
}
|
|
878
|
-
setBaseClass(el) {
|
|
879
|
-
this.addClass(el, this.options.baseClass);
|
|
880
|
-
}
|
|
881
|
-
imageIsLoading(el) {
|
|
882
|
-
var _a, _b;
|
|
883
|
-
this.addClass(el, this.options.loadingClass);
|
|
884
|
-
(_b = (_a = this.options).onLoading) == null ? void 0 : _b.call(_a, el);
|
|
885
|
-
}
|
|
886
|
-
imageHasNoPhoto(el) {
|
|
887
|
-
this.removeClass(el, this.options.loadingClass);
|
|
888
|
-
this.addClass(el, this.options.noPhotoClass);
|
|
889
|
-
this.setDefaultPhoto(el);
|
|
890
|
-
}
|
|
891
|
-
imageIsLoaded(el) {
|
|
892
|
-
var _a, _b;
|
|
893
|
-
this.hasImgLoaded = true;
|
|
894
|
-
this.removeClass(el, this.options.loadingClass);
|
|
895
|
-
this.addClass(el, this.options.loadedClass);
|
|
896
|
-
(_b = (_a = this.options).onLoaded) == null ? void 0 : _b.call(_a, el);
|
|
897
|
-
}
|
|
898
|
-
imageHasError(el, event) {
|
|
899
|
-
var _a, _b;
|
|
900
|
-
console.warn(`[maz-ui][MazLazyImg] Error while loading image`, event);
|
|
901
|
-
this.removeClass(el, this.options.loadingClass);
|
|
902
|
-
this.addClass(el, this.options.errorClass);
|
|
903
|
-
(_b = (_a = this.options).onError) == null ? void 0 : _b.call(_a, el);
|
|
904
|
-
this.setDefaultPhoto(el);
|
|
905
|
-
}
|
|
906
|
-
getImageUrl(el, binding) {
|
|
907
|
-
const dataSrc = this.getImgElement(el).getAttribute("data-lazy-src");
|
|
908
|
-
if (dataSrc)
|
|
909
|
-
return dataSrc;
|
|
910
|
-
binding.value;
|
|
911
|
-
const bindingSrc = typeof binding.value === "object" ? binding.value.src : binding.value;
|
|
912
|
-
if (!bindingSrc)
|
|
913
|
-
console.warn(`[maz-ui][MazLazyImg] src url is not defined`);
|
|
914
|
-
return bindingSrc;
|
|
915
|
-
}
|
|
916
|
-
async setPictureSourceUrls(el) {
|
|
917
|
-
const sourceElements = el.querySelectorAll("source");
|
|
918
|
-
if (sourceElements.length > 0) {
|
|
919
|
-
for await (const source of sourceElements) {
|
|
920
|
-
const srcSet = source.getAttribute("data-lazy-srcset");
|
|
921
|
-
if (srcSet) {
|
|
922
|
-
source.srcset = srcSet;
|
|
923
|
-
} else {
|
|
924
|
-
console.warn(
|
|
925
|
-
'[maz-ui][MazLazyImg] the "[data-lazy-srcset]" attribute is not provided on "<source />"'
|
|
926
|
-
);
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
} else {
|
|
930
|
-
console.warn(
|
|
931
|
-
'[maz-ui][MazLazyImg] No "<source />" elements provided into the "<picture />" element'
|
|
932
|
-
);
|
|
933
|
-
this.imageHasError(el);
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
hasBgImgMode(binding) {
|
|
937
|
-
return binding.arg === "bg-image";
|
|
938
|
-
}
|
|
939
|
-
isPictureElement(el) {
|
|
940
|
-
return el instanceof HTMLPictureElement;
|
|
941
|
-
}
|
|
942
|
-
getImgElement(el) {
|
|
943
|
-
const isPictureElement = this.isPictureElement(el);
|
|
944
|
-
return isPictureElement ? el.querySelector("img") : el;
|
|
945
|
-
}
|
|
946
|
-
async setDefaultPhoto(el) {
|
|
947
|
-
if (this.options.noUseErrorPhoto)
|
|
948
|
-
return;
|
|
949
|
-
const errorPhoto = this.options.errorPhoto ?? await this.loadErrorPhoto();
|
|
950
|
-
const sourceElements = el.querySelectorAll("source");
|
|
951
|
-
if (sourceElements.length > 0) {
|
|
952
|
-
for await (const source of sourceElements) {
|
|
953
|
-
source.srcset = errorPhoto;
|
|
954
|
-
}
|
|
955
|
-
} else {
|
|
956
|
-
this.setImgSrc(el, errorPhoto);
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
addEventListenerToImg(el) {
|
|
960
|
-
const imgElement = this.getImgElement(el);
|
|
961
|
-
imgElement.addEventListener("load", () => this.onImgLoadedCallback(el), {
|
|
962
|
-
once: true
|
|
963
|
-
});
|
|
964
|
-
imgElement.addEventListener("error", (err) => this.onImgErrorCallback(el, err), { once: true });
|
|
965
|
-
}
|
|
966
|
-
async loadImage(el, binding) {
|
|
967
|
-
this.imageIsLoading(el);
|
|
968
|
-
if (this.isPictureElement(el)) {
|
|
969
|
-
this.addEventListenerToImg(el);
|
|
970
|
-
await this.setPictureSourceUrls(el);
|
|
971
|
-
} else {
|
|
972
|
-
const imageUrl = this.getImageUrl(el, binding);
|
|
973
|
-
if (!imageUrl)
|
|
974
|
-
return this.imageHasError(el);
|
|
975
|
-
if (this.hasBgImgMode(binding)) {
|
|
976
|
-
el.style.backgroundImage = `url('${imageUrl}')`;
|
|
977
|
-
this.imageIsLoaded(el);
|
|
978
|
-
} else {
|
|
979
|
-
this.addEventListenerToImg(el);
|
|
980
|
-
this.setImgSrc(el, imageUrl);
|
|
981
|
-
}
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
setImgSrc(el, src) {
|
|
985
|
-
const imgElement = this.getImgElement(el);
|
|
986
|
-
imgElement.src = src;
|
|
987
|
-
}
|
|
988
|
-
handleIntersectionObserver(el, binding, entries, observer) {
|
|
989
|
-
var _a, _b;
|
|
990
|
-
this.observers.push(observer);
|
|
991
|
-
for (const entry of entries) {
|
|
992
|
-
if (entry.isIntersecting) {
|
|
993
|
-
(_b = (_a = this.options).onIntersecting) == null ? void 0 : _b.call(_a, entry.target);
|
|
994
|
-
if (this.options.observerOnce) {
|
|
995
|
-
observer.unobserve(el);
|
|
996
|
-
}
|
|
997
|
-
if (this.options.loadOnce && this.hasImgLoaded)
|
|
998
|
-
return;
|
|
999
|
-
this.loadImage(el, binding);
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
createObserver(el, binding) {
|
|
1004
|
-
const observerCallback = (entries, intersectionObserver) => {
|
|
1005
|
-
this.handleIntersectionObserver(el, binding, entries, intersectionObserver);
|
|
1006
|
-
};
|
|
1007
|
-
const observerOptions = this.options.observerOptions;
|
|
1008
|
-
const observer = new IntersectionObserver(observerCallback, observerOptions);
|
|
1009
|
-
observer.observe(el);
|
|
1010
|
-
}
|
|
1011
|
-
async imageHandler(el, binding, type) {
|
|
1012
|
-
if (type === "update") {
|
|
1013
|
-
for await (const observer of this.observers)
|
|
1014
|
-
observer.unobserve(el);
|
|
1015
|
-
}
|
|
1016
|
-
if (window.IntersectionObserver) {
|
|
1017
|
-
this.createObserver(el, binding);
|
|
1018
|
-
} else {
|
|
1019
|
-
this.loadImage(el, binding);
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
async bindUpdateHandler(el, binding, type) {
|
|
1023
|
-
if (this.options.noPhoto)
|
|
1024
|
-
return this.imageHasNoPhoto(el);
|
|
1025
|
-
await this.imageHandler(el, binding, type);
|
|
1026
|
-
}
|
|
1027
|
-
async add(el, binding) {
|
|
1028
|
-
if (this.hasBgImgMode(binding) && this.isPictureElement(el)) {
|
|
1029
|
-
throw new Error(`[MazLazyImg] You can't use the "bg-image" mode with "<picture />" element`);
|
|
1030
|
-
}
|
|
1031
|
-
setTimeout(() => this.setBaseClass(el), 0);
|
|
1032
|
-
if (!el.getAttribute("src"))
|
|
1033
|
-
this.setImgSrc(el, EMPTY_PHOTO);
|
|
1034
|
-
await this.bindUpdateHandler(el, binding, "bind");
|
|
1035
|
-
}
|
|
1036
|
-
async update(el, binding) {
|
|
1037
|
-
if (binding.value !== binding.oldValue) {
|
|
1038
|
-
this.hasImgLoaded = false;
|
|
1039
|
-
this.removeAllStateClasses(el);
|
|
1040
|
-
await this.bindUpdateHandler(el, binding, "update");
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
remove(el, binding) {
|
|
1044
|
-
this.hasImgLoaded = false;
|
|
1045
|
-
if (this.hasBgImgMode(binding))
|
|
1046
|
-
el.style.backgroundImage = "";
|
|
1047
|
-
this.removeAllStateClasses(el);
|
|
1048
|
-
for (const observer of this.observers)
|
|
1049
|
-
observer.unobserve(el);
|
|
1050
|
-
this.observers = [];
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
let instance$3;
|
|
1054
|
-
const vLazyImg = {
|
|
1055
|
-
created(el, binding) {
|
|
1056
|
-
const options = typeof binding.value === "object" ? binding.value : {};
|
|
1057
|
-
instance$3 = new LazyImg(options);
|
|
1058
|
-
instance$3.add(el, binding);
|
|
1059
|
-
},
|
|
1060
|
-
updated(el, binding) {
|
|
1061
|
-
instance$3.update(el, binding);
|
|
1062
|
-
},
|
|
1063
|
-
unmounted(el, binding) {
|
|
1064
|
-
instance$3.remove(el, binding);
|
|
1065
|
-
}
|
|
1066
|
-
};
|
|
1067
|
-
const DIRECTIVE_NAME = "lazy-img";
|
|
1068
|
-
const plugin$2 = {
|
|
1069
|
-
install(app, opts = {}) {
|
|
1070
|
-
const options = {
|
|
1071
|
-
...DEFAULT_OPTIONS$6,
|
|
1072
|
-
...opts,
|
|
1073
|
-
observerOptions: {
|
|
1074
|
-
...DEFAULT_OPTIONS$6.observerOptions,
|
|
1075
|
-
...opts.observerOptions
|
|
1076
|
-
}
|
|
1077
|
-
};
|
|
1078
|
-
const instance2 = new LazyImg(options);
|
|
1079
|
-
app.directive(DIRECTIVE_NAME, {
|
|
1080
|
-
created: instance2.add.bind(instance2),
|
|
1081
|
-
updated: instance2.update.bind(instance2),
|
|
1082
|
-
unmounted: instance2.remove.bind(instance2)
|
|
1083
|
-
});
|
|
1084
|
-
}
|
|
1085
|
-
};
|
|
1086
|
-
const _hoisted_1$1 = ["onClick", "onKeypress"];
|
|
1087
|
-
const _hoisted_2$1 = { class: "m-fullscreen-img-scroller" };
|
|
1088
|
-
const _hoisted_3$1 = ["src", "alt"];
|
|
1089
|
-
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
1090
|
-
__name: "MazFullscreenImg",
|
|
1091
|
-
props: {
|
|
1092
|
-
destroy: { type: Function, default: void 0 },
|
|
1093
|
-
src: {},
|
|
1094
|
-
alt: { default: void 0 },
|
|
1095
|
-
openInstanceClass: {},
|
|
1096
|
-
zoom: { type: Boolean, default: true },
|
|
1097
|
-
disabled: { type: Boolean },
|
|
1098
|
-
clickedElementBounds: {},
|
|
1099
|
-
clickedElement: {},
|
|
1100
|
-
animated: { type: Boolean, default: true },
|
|
1101
|
-
scaleAnimation: { type: Boolean }
|
|
1102
|
-
},
|
|
1103
|
-
emits: ["close", "previous", "next", "before-close"],
|
|
1104
|
-
setup(__props, { emit: __emit }) {
|
|
1105
|
-
const emits = __emit;
|
|
1106
|
-
const MazSpinner = defineAsyncComponent(() => import("./MazSpinner-a16a3d8f.mjs"));
|
|
1107
|
-
const XMark = defineAsyncComponent(() => import("./x-mark-c6ff45dd.mjs"));
|
|
1108
|
-
const ChevronLeft = defineAsyncComponent(() => import("./chevron-left-3365d59b.mjs"));
|
|
1109
|
-
let vueScrollTo;
|
|
1110
|
-
onBeforeMount(async () => {
|
|
1111
|
-
vueScrollTo = await import("vue-scrollto");
|
|
1112
|
-
});
|
|
1113
|
-
const props = __props;
|
|
1114
|
-
const showFullscreenImg = ref(false);
|
|
1115
|
-
const imageLoaded = ref(false);
|
|
1116
|
-
const showLoader = ref(false);
|
|
1117
|
-
const loadedOnce = ref(false);
|
|
1118
|
-
const hasMultipleInstances = ref(false);
|
|
1119
|
-
const isZoomed = ref(false);
|
|
1120
|
-
const animationActive = ref(false);
|
|
1121
|
-
const isImageElement = ref(props.clickedElement instanceof HTMLImageElement);
|
|
1122
|
-
const currentSrc = ref(props.src);
|
|
1123
|
-
const currentAlt = ref(props.alt);
|
|
1124
|
-
const FullscreenImgElement = ref();
|
|
1125
|
-
const ImgElement = ref();
|
|
1126
|
-
const hasAnimationBasedOnImageClicked = computed(
|
|
1127
|
-
() => isImageElement.value && props.animated && !props.scaleAnimation
|
|
1128
|
-
);
|
|
1129
|
-
const hasBasicScaleAnimation = computed(
|
|
1130
|
-
() => (isImageElement.value || !props.animated) && !props.scaleAnimation
|
|
1131
|
-
);
|
|
1132
|
-
const isLandscapeImage = ref(false);
|
|
1133
|
-
const imageZoomClasses = computed(() => {
|
|
1134
|
-
if (isZoomed.value) {
|
|
1135
|
-
return `--is-zoomed maz-cursor-zoom-in maz-max-w-[none] ${isLandscapeImage.value ? "maz-h-screen maz-w-auto" : "maz-h-auto maz-w-screen"}`;
|
|
1136
|
-
}
|
|
1137
|
-
return `cursor-zoom-out ${isLandscapeImage.value ? "maz-w-screen maz-h-screen --is-landscape" : "maz-h-screen maz-w-auto"}`;
|
|
1138
|
-
});
|
|
1139
|
-
function onImageLoaded() {
|
|
1140
|
-
imageLoaded.value = true;
|
|
1141
|
-
showLoader.value = false;
|
|
1142
|
-
loadedOnce.value = true;
|
|
1143
|
-
}
|
|
1144
|
-
function close() {
|
|
1145
|
-
emits("before-close");
|
|
1146
|
-
showFullscreenImg.value = false;
|
|
1147
|
-
}
|
|
1148
|
-
function keydownLister(e) {
|
|
1149
|
-
if (e.key === "Escape") {
|
|
1150
|
-
e.preventDefault();
|
|
1151
|
-
close();
|
|
1152
|
-
}
|
|
1153
|
-
if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
|
|
1154
|
-
e.preventDefault();
|
|
1155
|
-
nextPreviousImage(e.key === "ArrowRight");
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
function addClassToDocument() {
|
|
1159
|
-
document.documentElement.classList.add("--m-fullscreen-open");
|
|
1160
|
-
}
|
|
1161
|
-
function removeClassFromDocument() {
|
|
1162
|
-
document.documentElement.classList.remove("--m-fullscreen-open");
|
|
1163
|
-
}
|
|
1164
|
-
function getAllInstances() {
|
|
1165
|
-
return [...document.querySelectorAll(".m-fullscreen-img-instance")];
|
|
1166
|
-
}
|
|
1167
|
-
function getNewInstanceIndex(allInstances, newInstanceIndex) {
|
|
1168
|
-
return newInstanceIndex < 0 ? allInstances.length - 1 : newInstanceIndex >= allInstances.length ? 0 : newInstanceIndex;
|
|
1169
|
-
}
|
|
1170
|
-
async function useNextInstance(currentInstance, nextInstance) {
|
|
1171
|
-
currentInstance.classList.remove(props.openInstanceClass);
|
|
1172
|
-
nextInstance.classList.add(props.openInstanceClass);
|
|
1173
|
-
const src = nextInstance.getAttribute("data-src");
|
|
1174
|
-
const alt = nextInstance.getAttribute("data-alt");
|
|
1175
|
-
currentAlt.value = alt ?? void 0;
|
|
1176
|
-
if (src) {
|
|
1177
|
-
currentSrc.value = src;
|
|
1178
|
-
}
|
|
1179
|
-
imageLoaded.value = false;
|
|
1180
|
-
await sleep(300);
|
|
1181
|
-
if (!imageLoaded.value) {
|
|
1182
|
-
showLoader.value = true;
|
|
1183
|
-
}
|
|
1184
|
-
}
|
|
1185
|
-
function nextPreviousImage(isNext) {
|
|
1186
|
-
const currentInstance = document.querySelector(
|
|
1187
|
-
`.m-fullscreen-img-instance.${props.openInstanceClass}`
|
|
1188
|
-
);
|
|
1189
|
-
if (currentInstance) {
|
|
1190
|
-
const allInstances = getAllInstances();
|
|
1191
|
-
const currentInstanceIndex = allInstances.indexOf(currentInstance);
|
|
1192
|
-
const newInstanceIndex = isNext ? currentInstanceIndex + 1 : currentInstanceIndex - 1;
|
|
1193
|
-
const nextInstance = allInstances[getNewInstanceIndex(allInstances, newInstanceIndex)];
|
|
1194
|
-
if (nextInstance) {
|
|
1195
|
-
useNextInstance(currentInstance, nextInstance);
|
|
1196
|
-
}
|
|
1197
|
-
emits(isNext ? "next" : "previous");
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1200
|
-
async function toogleZoom(event) {
|
|
1201
|
-
const imgElement = event.target;
|
|
1202
|
-
imgElement.style.width = `${imgElement.clientWidth}px`;
|
|
1203
|
-
imgElement.style.height = `${imgElement.clientHeight}px`;
|
|
1204
|
-
await sleep(0);
|
|
1205
|
-
isZoomed.value = !isZoomed.value;
|
|
1206
|
-
imgElement.style.removeProperty("width");
|
|
1207
|
-
imgElement.style.removeProperty("height");
|
|
1208
|
-
await sleep(0);
|
|
1209
|
-
const zoomTargetRatio = imgElement.clientWidth / event.clientY;
|
|
1210
|
-
const height = window.innerWidth / zoomTargetRatio;
|
|
1211
|
-
const offset = height - window.innerHeight / 2;
|
|
1212
|
-
vueScrollTo.scrollTo(imgElement, 200, {
|
|
1213
|
-
container: imgElement.parentElement,
|
|
1214
|
-
easing: "linear",
|
|
1215
|
-
offset: isZoomed.value ? offset : 0
|
|
1216
|
-
});
|
|
1217
|
-
}
|
|
1218
|
-
onMounted$1(async () => {
|
|
1219
|
-
await nextTick();
|
|
1220
|
-
document.addEventListener("keydown", keydownLister);
|
|
1221
|
-
showFullscreenImg.value = true;
|
|
1222
|
-
showLoader.value = true;
|
|
1223
|
-
addClassToDocument();
|
|
1224
|
-
hasMultipleInstances.value = getAllInstances().length > 1;
|
|
1225
|
-
if (ImgElement.value) {
|
|
1226
|
-
isLandscapeImage.value = props.clickedElementBounds.height < props.clickedElementBounds.width;
|
|
1227
|
-
}
|
|
1228
|
-
});
|
|
1229
|
-
function setClikedElementProperties() {
|
|
1230
|
-
if (ImgElement.value) {
|
|
1231
|
-
animationActive.value = true;
|
|
1232
|
-
ImgElement.value.style.removeProperty("margin-left");
|
|
1233
|
-
ImgElement.value.style.removeProperty("margin-right");
|
|
1234
|
-
ImgElement.value.style.opacity = "0.5";
|
|
1235
|
-
ImgElement.value.style.width = `${props.clickedElementBounds.width}px`;
|
|
1236
|
-
ImgElement.value.style.height = `${props.clickedElementBounds.height}px`;
|
|
1237
|
-
ImgElement.value.style.top = `${props.clickedElementBounds.top}px`;
|
|
1238
|
-
ImgElement.value.style.left = `${props.clickedElementBounds.left}px`;
|
|
1239
|
-
}
|
|
1240
|
-
}
|
|
1241
|
-
async function onAnimationEnter() {
|
|
1242
|
-
await sleep(0);
|
|
1243
|
-
if (ImgElement.value) {
|
|
1244
|
-
ImgElement.value.style.opacity = "1";
|
|
1245
|
-
ImgElement.value.style.removeProperty("height");
|
|
1246
|
-
ImgElement.value.style.removeProperty("width");
|
|
1247
|
-
ImgElement.value.style.removeProperty("transform");
|
|
1248
|
-
const windowWidth = window.innerWidth;
|
|
1249
|
-
const windowHeight = window.innerHeight;
|
|
1250
|
-
const initalElementHeight = props.clickedElementBounds.height;
|
|
1251
|
-
const initalElementWidth = props.clickedElementBounds.width;
|
|
1252
|
-
if (isLandscapeImage.value) {
|
|
1253
|
-
ImgElement.value.style.left = `0px`;
|
|
1254
|
-
const imageHeight = initalElementHeight * windowWidth / initalElementWidth;
|
|
1255
|
-
const top = (windowHeight - imageHeight) / 2;
|
|
1256
|
-
ImgElement.value.style.top = `${top <= 0 ? 0 : top}px`;
|
|
1257
|
-
} else {
|
|
1258
|
-
ImgElement.value.style.top = "0px";
|
|
1259
|
-
const imageWidth = initalElementWidth * windowHeight / initalElementHeight;
|
|
1260
|
-
const left = (windowWidth - imageWidth) / 2;
|
|
1261
|
-
ImgElement.value.style.left = `${left <= 0 ? 0 : left}px`;
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
function onAnimationEnterFinish() {
|
|
1266
|
-
if (ImgElement.value) {
|
|
1267
|
-
ImgElement.value.style.removeProperty("top");
|
|
1268
|
-
ImgElement.value.style.removeProperty("left");
|
|
1269
|
-
ImgElement.value.style.marginLeft = "auto";
|
|
1270
|
-
ImgElement.value.style.marginRight = "auto";
|
|
1271
|
-
ImgElement.value.style.removeProperty("opacity");
|
|
1272
|
-
}
|
|
1273
|
-
animationActive.value = false;
|
|
1274
|
-
}
|
|
1275
|
-
function onAnimationBeforeLeave() {
|
|
1276
|
-
if (ImgElement.value) {
|
|
1277
|
-
const { left, top } = ImgElement.value.getBoundingClientRect();
|
|
1278
|
-
ImgElement.value.style.left = `${left}px`;
|
|
1279
|
-
ImgElement.value.style.top = `${top}px`;
|
|
1280
|
-
ImgElement.value.style.width = `${ImgElement.value.width}px`;
|
|
1281
|
-
ImgElement.value.style.height = `${ImgElement.value.height}px`;
|
|
1282
|
-
animationActive.value = true;
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
function onAnimationLeaveFinish() {
|
|
1286
|
-
var _a, _b;
|
|
1287
|
-
emits("close");
|
|
1288
|
-
(_a = FullscreenImgElement.value) == null ? void 0 : _a.remove();
|
|
1289
|
-
(_b = props.destroy) == null ? void 0 : _b.call(props);
|
|
1290
|
-
}
|
|
1291
|
-
onBeforeUnmount(() => {
|
|
1292
|
-
document.removeEventListener("keydown", keydownLister);
|
|
1293
|
-
removeClassFromDocument();
|
|
1294
|
-
});
|
|
1295
|
-
return (_ctx, _cache) => {
|
|
1296
|
-
return openBlock(), createElementBlock("div", {
|
|
1297
|
-
ref_key: "FullscreenImgElement",
|
|
1298
|
-
ref: FullscreenImgElement,
|
|
1299
|
-
role: "button",
|
|
1300
|
-
class: normalizeClass(["m-fullscreen-img", { "--animation-active": animationActive.value }]),
|
|
1301
|
-
tabindex: "0",
|
|
1302
|
-
onClick: withModifiers(close, ["self"]),
|
|
1303
|
-
onKeypress: withKeys(withModifiers(close, ["prevent"]), ["esc"])
|
|
1304
|
-
}, [
|
|
1305
|
-
withDirectives(createVNode(
|
|
1306
|
-
unref(MazSpinner),
|
|
1307
|
-
{ class: "m-fullscreen-img-loader maz-h-16" },
|
|
1308
|
-
null,
|
|
1309
|
-
512
|
|
1310
|
-
/* NEED_PATCH */
|
|
1311
|
-
), [
|
|
1312
|
-
[vShow, showLoader.value]
|
|
1313
|
-
]),
|
|
1314
|
-
loadedOnce.value && hasMultipleInstances.value ? (openBlock(), createElementBlock("button", {
|
|
1315
|
-
key: 0,
|
|
1316
|
-
type: "button",
|
|
1317
|
-
class: "m-fullscreen-btn --next",
|
|
1318
|
-
onClick: _cache[0] || (_cache[0] = withModifiers(($event) => nextPreviousImage(true), ["stop"]))
|
|
1319
|
-
}, [
|
|
1320
|
-
createVNode(unref(ChevronLeft), { class: "maz-rotate-90 maz-text-2xl" })
|
|
1321
|
-
])) : createCommentVNode("v-if", true),
|
|
1322
|
-
showFullscreenImg.value && loadedOnce.value && hasMultipleInstances.value ? (openBlock(), createElementBlock("button", {
|
|
1323
|
-
key: 1,
|
|
1324
|
-
type: "button",
|
|
1325
|
-
class: "m-fullscreen-btn --previous",
|
|
1326
|
-
onClick: _cache[1] || (_cache[1] = withModifiers(($event) => nextPreviousImage(false), ["stop"]))
|
|
1327
|
-
}, [
|
|
1328
|
-
createVNode(unref(ChevronLeft), { class: "maz-text-2xl" })
|
|
1329
|
-
])) : createCommentVNode("v-if", true),
|
|
1330
|
-
createElementVNode("button", {
|
|
1331
|
-
type: "button",
|
|
1332
|
-
class: "m-fullscreen-btn --close",
|
|
1333
|
-
onClick: close
|
|
1334
|
-
}, [
|
|
1335
|
-
createVNode(unref(XMark), { class: "maz-text-2xl" })
|
|
1336
|
-
]),
|
|
1337
|
-
createElementVNode("div", _hoisted_2$1, [
|
|
1338
|
-
createVNode(Transition, {
|
|
1339
|
-
name: hasBasicScaleAnimation.value ? void 0 : "maz-scale-fade",
|
|
1340
|
-
onBeforeEnter: _cache[3] || (_cache[3] = ($event) => hasAnimationBasedOnImageClicked.value && setClikedElementProperties()),
|
|
1341
|
-
onEnter: _cache[4] || (_cache[4] = ($event) => hasAnimationBasedOnImageClicked.value && onAnimationEnter()),
|
|
1342
|
-
onAfterEnter: _cache[5] || (_cache[5] = ($event) => hasAnimationBasedOnImageClicked.value && onAnimationEnterFinish()),
|
|
1343
|
-
onBeforeLeave: _cache[6] || (_cache[6] = ($event) => hasAnimationBasedOnImageClicked.value && onAnimationBeforeLeave()),
|
|
1344
|
-
onLeave: _cache[7] || (_cache[7] = ($event) => hasAnimationBasedOnImageClicked.value && setClikedElementProperties()),
|
|
1345
|
-
onAfterLeave: onAnimationLeaveFinish,
|
|
1346
|
-
persisted: ""
|
|
1347
|
-
}, {
|
|
1348
|
-
default: withCtx(() => [
|
|
1349
|
-
withDirectives(createElementVNode("img", {
|
|
1350
|
-
id: "ZvImgElement",
|
|
1351
|
-
ref_key: "ImgElement",
|
|
1352
|
-
ref: ImgElement,
|
|
1353
|
-
src: currentSrc.value,
|
|
1354
|
-
alt: currentAlt.value,
|
|
1355
|
-
tabindex: "0",
|
|
1356
|
-
class: normalizeClass([{ zoomable: _ctx.zoom }, imageZoomClasses.value]),
|
|
1357
|
-
onLoad: onImageLoaded,
|
|
1358
|
-
onClick: _cache[2] || (_cache[2] = ($event) => _ctx.zoom ? toogleZoom($event) : void 0)
|
|
1359
|
-
}, null, 42, _hoisted_3$1), [
|
|
1360
|
-
[vShow, showFullscreenImg.value]
|
|
1361
|
-
])
|
|
1362
|
-
]),
|
|
1363
|
-
_: 1
|
|
1364
|
-
/* STABLE */
|
|
1365
|
-
}, 8, ["name"])
|
|
1366
|
-
])
|
|
1367
|
-
], 42, _hoisted_1$1);
|
|
1368
|
-
};
|
|
1369
|
-
}
|
|
1370
|
-
});
|
|
1371
|
-
const MazFullscreenImg_vue_vue_type_style_index_0_lang = "";
|
|
1372
|
-
const MazFullscreenImg_vue_vue_type_style_index_1_scoped_1b5808d8_lang = "";
|
|
1373
|
-
const _export_sfc = (sfc, props) => {
|
|
1374
|
-
const target = sfc.__vccOpts || sfc;
|
|
1375
|
-
for (const [key, val] of props) {
|
|
1376
|
-
target[key] = val;
|
|
1377
|
-
}
|
|
1378
|
-
return target;
|
|
1379
|
-
};
|
|
1380
|
-
const MazFullscreenImg = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-1b5808d8"]]);
|
|
1381
|
-
const STATE_OPEN_CLASS = "m-fullscreen-is-open";
|
|
1382
|
-
class FullscreenImgHandler {
|
|
1383
|
-
constructor() {
|
|
1384
|
-
__publicField(this, "options");
|
|
1385
|
-
__publicField(this, "defaultOptions", {
|
|
1386
|
-
scaleOnHover: false,
|
|
1387
|
-
blurOnHover: false,
|
|
1388
|
-
disabled: false,
|
|
1389
|
-
animated: true,
|
|
1390
|
-
zoom: true,
|
|
1391
|
-
scaleAnimation: false
|
|
1392
|
-
});
|
|
1393
|
-
__publicField(this, "mouseEnterListener");
|
|
1394
|
-
__publicField(this, "mouseLeaveListener");
|
|
1395
|
-
__publicField(this, "renderPreviewListener");
|
|
1396
|
-
}
|
|
1397
|
-
buildOptions(el, binding) {
|
|
1398
|
-
const options = typeof binding.value === "object" ? binding.value : { src: binding.value, alt: void 0 };
|
|
1399
|
-
const src = (options == null ? void 0 : options.src) ?? this.getImgSrc(el);
|
|
1400
|
-
const alt = (options == null ? void 0 : options.alt) ?? this.getImgAlt(el);
|
|
1401
|
-
return {
|
|
1402
|
-
...this.defaultOptions,
|
|
1403
|
-
...options,
|
|
1404
|
-
src,
|
|
1405
|
-
alt
|
|
1406
|
-
};
|
|
1407
|
-
}
|
|
1408
|
-
get allInstances() {
|
|
1409
|
-
return [...document.querySelectorAll(".m-fullscreen-img-instance")];
|
|
1410
|
-
}
|
|
1411
|
-
getImgSrc(el) {
|
|
1412
|
-
var _a;
|
|
1413
|
-
const imgSrc = ((_a = this.options) == null ? void 0 : _a.src) || el.getAttribute("src") || el.getAttribute("data-src");
|
|
1414
|
-
if (!imgSrc) {
|
|
1415
|
-
throw new Error(
|
|
1416
|
-
'[maz-ui](fullscreen-img) src of image must be provided by `v-fullscreen=""`, `v-fullscreen="{ src: "" }"`, `src=""` or `data-src=""` atributes'
|
|
1417
|
-
);
|
|
1418
|
-
}
|
|
1419
|
-
return imgSrc;
|
|
1420
|
-
}
|
|
1421
|
-
getImgAlt(el) {
|
|
1422
|
-
var _a;
|
|
1423
|
-
return ((_a = this.options) == null ? void 0 : _a.alt) || el.getAttribute("alt") || el.getAttribute("data-alt");
|
|
1424
|
-
}
|
|
1425
|
-
create(el, binding) {
|
|
1426
|
-
this.options = this.buildOptions(el, binding);
|
|
1427
|
-
if (this.options.disabled)
|
|
1428
|
-
return;
|
|
1429
|
-
el.style.cursor = "move";
|
|
1430
|
-
if (this.options.scaleOnHover || this.options.blurOnHover) {
|
|
1431
|
-
el.style.transition = "all 300ms ease-in-out";
|
|
1432
|
-
}
|
|
1433
|
-
el.classList.add("m-fullscreen-img-instance");
|
|
1434
|
-
el.setAttribute("data-src", this.getImgSrc(el));
|
|
1435
|
-
const alt = this.getImgAlt(el);
|
|
1436
|
-
if (alt) {
|
|
1437
|
-
el.setAttribute("data-alt", alt);
|
|
1438
|
-
}
|
|
1439
|
-
this.mouseEnterListener = () => this.mouseEnter(el);
|
|
1440
|
-
this.mouseLeaveListener = () => this.mouseLeave(el);
|
|
1441
|
-
this.renderPreviewListener = () => this.renderPreview(el);
|
|
1442
|
-
el.addEventListener("mouseenter", this.mouseEnterListener);
|
|
1443
|
-
el.addEventListener("mouseleave", this.mouseLeaveListener);
|
|
1444
|
-
el.addEventListener("click", this.renderPreviewListener);
|
|
1445
|
-
}
|
|
1446
|
-
update(el, binding) {
|
|
1447
|
-
this.options = this.buildOptions(el, binding);
|
|
1448
|
-
}
|
|
1449
|
-
remove(el) {
|
|
1450
|
-
el.removeEventListener("mouseenter", this.mouseEnterListener);
|
|
1451
|
-
el.removeEventListener("mouseleave", this.mouseLeaveListener);
|
|
1452
|
-
el.removeEventListener("click", this.renderPreviewListener);
|
|
1453
|
-
el.classList.remove("m-fullscreen-img-instance");
|
|
1454
|
-
el.style.cursor = "";
|
|
1455
|
-
}
|
|
1456
|
-
renderPreview(el) {
|
|
1457
|
-
el.classList.add(STATE_OPEN_CLASS);
|
|
1458
|
-
return mount(MazFullscreenImg, {
|
|
1459
|
-
props: {
|
|
1460
|
-
...this.options,
|
|
1461
|
-
openInstanceClass: STATE_OPEN_CLASS,
|
|
1462
|
-
clickedElement: el,
|
|
1463
|
-
clickedElementBounds: el.getBoundingClientRect()
|
|
1464
|
-
},
|
|
1465
|
-
addDestroyInProps: true
|
|
1466
|
-
});
|
|
1467
|
-
}
|
|
1468
|
-
mouseLeave(el) {
|
|
1469
|
-
if (this.options.scaleOnHover)
|
|
1470
|
-
el.style.transform = "";
|
|
1471
|
-
if (this.options.blurOnHover)
|
|
1472
|
-
el.style.filter = "";
|
|
1473
|
-
el.style.zIndex = "";
|
|
1474
|
-
}
|
|
1475
|
-
mouseEnter(el) {
|
|
1476
|
-
el.style.zIndex = "1";
|
|
1477
|
-
if (this.options.scaleOnHover)
|
|
1478
|
-
el.style.transform = "scale(1.05)";
|
|
1479
|
-
if (this.options.blurOnHover)
|
|
1480
|
-
el.style.filter = "blur(3px)";
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1483
|
-
let instance$2;
|
|
1484
|
-
const vFullscreenImg = {
|
|
1485
|
-
mounted(el, binding) {
|
|
1486
|
-
instance$2 = new FullscreenImgHandler();
|
|
1487
|
-
return instance$2.create(el, binding);
|
|
1488
|
-
},
|
|
1489
|
-
updated(el, binding) {
|
|
1490
|
-
return instance$2.update(el, binding);
|
|
1491
|
-
},
|
|
1492
|
-
unmounted(el) {
|
|
1493
|
-
return instance$2.remove(el);
|
|
1494
|
-
}
|
|
1495
|
-
};
|
|
1496
|
-
const vFullscreenImgInstall = {
|
|
1497
|
-
install(app) {
|
|
1498
|
-
app.directive("fullscreen-img", vFullscreenImg);
|
|
1499
|
-
}
|
|
1500
|
-
};
|
|
1501
|
-
const directives = [
|
|
1502
|
-
{
|
|
1503
|
-
name: "click-outside",
|
|
1504
|
-
directive: directive$1
|
|
1505
|
-
},
|
|
1506
|
-
{
|
|
1507
|
-
name: "closable",
|
|
1508
|
-
directive
|
|
1509
|
-
},
|
|
1510
|
-
{
|
|
1511
|
-
name: "zoom-img",
|
|
1512
|
-
directive: vZoomImg
|
|
1513
|
-
},
|
|
1514
|
-
{
|
|
1515
|
-
name: "lazy-img",
|
|
1516
|
-
directive: vLazyImg
|
|
1517
|
-
},
|
|
1518
|
-
{
|
|
1519
|
-
name: "fullscreen-img",
|
|
1520
|
-
directive: vFullscreenImg
|
|
1521
|
-
}
|
|
1522
|
-
];
|
|
1523
|
-
const installDirectives = {
|
|
1524
|
-
install(app) {
|
|
1525
|
-
for (const { name, directive: directive2 } of directives) {
|
|
1526
|
-
app.directive(name, directive2);
|
|
1527
|
-
}
|
|
1528
|
-
}
|
|
1529
|
-
};
|
|
1530
|
-
const capitalize = (value) => {
|
|
1531
|
-
if (!value)
|
|
1532
|
-
return "";
|
|
1533
|
-
value = value.toString();
|
|
1534
|
-
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
1535
|
-
};
|
|
1536
|
-
const DEFAULT_OPTIONS$5 = {
|
|
1537
|
-
style: "currency",
|
|
1538
|
-
minimumFractionDigits: 2,
|
|
1539
|
-
round: false
|
|
1540
|
-
};
|
|
1541
|
-
const getFormattedCurrency = (number2, locale, options) => {
|
|
1542
|
-
let numberToFormat = Number(number2);
|
|
1543
|
-
if (options.round) {
|
|
1544
|
-
numberToFormat = Math.floor(numberToFormat);
|
|
1545
|
-
options.minimumFractionDigits = 0;
|
|
1546
|
-
}
|
|
1547
|
-
return new Intl.NumberFormat(locale, options).format(numberToFormat);
|
|
1548
|
-
};
|
|
1549
|
-
const validRequiredAttributes = (number2, locale, options) => {
|
|
1550
|
-
if (number2 === void 0)
|
|
1551
|
-
throw new TypeError("[maz-ui](FilterCurrency) The `number` attribute is required.");
|
|
1552
|
-
if (locale === void 0)
|
|
1553
|
-
throw new TypeError("[maz-ui](FilterCurrency) The `locale` attribute is required.");
|
|
1554
|
-
if (typeof locale !== "string")
|
|
1555
|
-
throw new TypeError("[maz-ui](FilterCurrency) The `locale` attribute must be a string.");
|
|
1556
|
-
if (options.currency === void 0)
|
|
1557
|
-
throw new TypeError("[maz-ui](FilterCurrency) The `options.currency` attribute is required.");
|
|
1558
|
-
};
|
|
1559
|
-
const currency = (number2, locale, options) => {
|
|
1560
|
-
const options_ = {
|
|
1561
|
-
...DEFAULT_OPTIONS$5,
|
|
1562
|
-
...options
|
|
1563
|
-
};
|
|
1564
|
-
validRequiredAttributes(number2, locale, options_);
|
|
1565
|
-
try {
|
|
1566
|
-
return getFormattedCurrency(number2, locale, options_);
|
|
1567
|
-
} catch (error) {
|
|
1568
|
-
throw new Error(`[maz-ui](FilterCurrency) ${error}`);
|
|
1569
|
-
}
|
|
1570
|
-
};
|
|
1571
|
-
const DEFAULT_OPTIONS$4 = {
|
|
1572
|
-
month: "short",
|
|
1573
|
-
day: "numeric",
|
|
1574
|
-
year: "numeric"
|
|
1575
|
-
};
|
|
1576
|
-
const date = (date2, locale, options) => {
|
|
1577
|
-
if (locale === void 0) {
|
|
1578
|
-
throw new TypeError("[maz-ui](FilterDate) The `locale` attribute is required.");
|
|
1579
|
-
}
|
|
1580
|
-
if (typeof locale !== "string") {
|
|
1581
|
-
throw new TypeError("[maz-ui](FilterDate) The `locale` attribute must be a string.");
|
|
1582
|
-
}
|
|
1583
|
-
const opts = options ?? DEFAULT_OPTIONS$4;
|
|
1584
|
-
try {
|
|
1585
|
-
const usedDate = date2 instanceof Date ? date2 : new Date(date2);
|
|
1586
|
-
return new Intl.DateTimeFormat(locale, opts).format(usedDate);
|
|
1587
|
-
} catch (error) {
|
|
1588
|
-
throw new Error(`[maz-ui](FilterDate) ${error}`);
|
|
1589
|
-
}
|
|
1590
|
-
};
|
|
1591
|
-
const DEFAULT_OPTIONS$3 = {
|
|
1592
|
-
minimumFractionDigits: 2
|
|
1593
|
-
};
|
|
1594
|
-
const number = (number2, locale, options) => {
|
|
1595
|
-
const filterOptions = {
|
|
1596
|
-
...DEFAULT_OPTIONS$3,
|
|
1597
|
-
...options
|
|
1598
|
-
};
|
|
1599
|
-
if (number2 === void 0) {
|
|
1600
|
-
throw new TypeError("[maz-ui](FilterNumber) The `number` attribute is required.");
|
|
1601
|
-
}
|
|
1602
|
-
if (locale === void 0) {
|
|
1603
|
-
throw new TypeError("[maz-ui](FilterNumber) The `locale` attribute is required.");
|
|
1604
|
-
}
|
|
1605
|
-
if (typeof locale !== "string") {
|
|
1606
|
-
throw new TypeError("[maz-ui](FilterNumber) The `locale` attribute must be a string.");
|
|
1607
|
-
}
|
|
1608
|
-
try {
|
|
1609
|
-
return new Intl.NumberFormat(locale, filterOptions).format(Number(number2));
|
|
1610
|
-
} catch (error) {
|
|
1611
|
-
throw new Error(`[maz-ui](FilterNumber) ${error}`);
|
|
1612
|
-
}
|
|
1613
|
-
};
|
|
1614
|
-
const filters = {
|
|
1615
|
-
capitalize,
|
|
1616
|
-
currency,
|
|
1617
|
-
date,
|
|
1618
|
-
number
|
|
1619
|
-
};
|
|
1620
|
-
const installFilters = {
|
|
1621
|
-
install(app) {
|
|
1622
|
-
app.provide("filters", filters);
|
|
1623
|
-
}
|
|
1624
|
-
};
|
|
1625
|
-
class ToasterTimer {
|
|
1626
|
-
constructor(callback, delay) {
|
|
1627
|
-
__publicField(this, "callback");
|
|
1628
|
-
__publicField(this, "delay");
|
|
1629
|
-
__publicField(this, "timer");
|
|
1630
|
-
__publicField(this, "startedAt");
|
|
1631
|
-
this.startedAt = Date.now();
|
|
1632
|
-
this.callback = callback;
|
|
1633
|
-
this.delay = delay;
|
|
1634
|
-
this.start();
|
|
1635
|
-
}
|
|
1636
|
-
pause() {
|
|
1637
|
-
this.stop();
|
|
1638
|
-
this.delay -= Date.now() - this.startedAt;
|
|
1639
|
-
}
|
|
1640
|
-
resume() {
|
|
1641
|
-
this.startedAt = Date.now();
|
|
1642
|
-
this.start();
|
|
1643
|
-
}
|
|
1644
|
-
start() {
|
|
1645
|
-
this.timer = setTimeout(this.callback, this.delay);
|
|
1646
|
-
}
|
|
1647
|
-
stop() {
|
|
1648
|
-
clearTimeout(this.timer);
|
|
1649
|
-
}
|
|
1650
|
-
}
|
|
1651
|
-
const _hoisted_1 = { class: "m-toast__message-wrapper" };
|
|
1652
|
-
const _hoisted_2 = { class: "m-toast__message" };
|
|
1653
|
-
const _hoisted_3 = { class: "maz-flex maz-items-center maz-gap-2" };
|
|
1654
|
-
const _hoisted_4 = { key: 0 };
|
|
1655
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
1656
|
-
__name: "MazToast",
|
|
1657
|
-
props: {
|
|
1658
|
-
position: {
|
|
1659
|
-
type: String,
|
|
1660
|
-
default: "bottom-right"
|
|
1661
|
-
},
|
|
1662
|
-
maxToasts: { type: [Number, Boolean], default: false },
|
|
1663
|
-
timeout: { type: Number, default: 1e4 },
|
|
1664
|
-
queue: { type: Boolean, default: false },
|
|
1665
|
-
noPauseOnHover: { type: Boolean, default: false },
|
|
1666
|
-
type: {
|
|
1667
|
-
type: String,
|
|
1668
|
-
default: "info",
|
|
1669
|
-
validator: (value) => {
|
|
1670
|
-
return ["info", "success", "warning", "danger"].includes(value);
|
|
1671
|
-
}
|
|
1672
|
-
},
|
|
1673
|
-
message: { type: String, required: true },
|
|
1674
|
-
link: { type: Object, default: void 0 },
|
|
1675
|
-
action: { type: Object, default: void 0 },
|
|
1676
|
-
persistent: { type: Boolean, default: false }
|
|
1677
|
-
},
|
|
1678
|
-
emits: ["close", "click"],
|
|
1679
|
-
setup(__props, { emit: __emit }) {
|
|
1680
|
-
const XIcon = defineAsyncComponent(() => import("./x-mark-c6ff45dd.mjs"));
|
|
1681
|
-
const ExternalLink = defineAsyncComponent(
|
|
1682
|
-
() => import("./arrow-top-right-on-square-32bbe5a1.mjs")
|
|
1683
|
-
);
|
|
1684
|
-
const Link = defineAsyncComponent(() => import("./link-4eb05848.mjs"));
|
|
1685
|
-
const MazBtn = defineAsyncComponent(() => import("./MazBtn-90ffd148.mjs"));
|
|
1686
|
-
const Toaster = ref();
|
|
1687
|
-
const props = __props;
|
|
1688
|
-
const emits = __emit;
|
|
1689
|
-
const positionY = computed(() => props.position.includes("top") ? "top" : "bottom");
|
|
1690
|
-
const positionX = computed(() => {
|
|
1691
|
-
if (props.position.includes("left"))
|
|
1692
|
-
return "left";
|
|
1693
|
-
if (props.position.includes("right"))
|
|
1694
|
-
return "right";
|
|
1695
|
-
return "center";
|
|
1696
|
-
});
|
|
1697
|
-
const transitionName = computed(() => {
|
|
1698
|
-
if (positionX.value !== "center") {
|
|
1699
|
-
return positionX.value === "right" ? "m-slide-right" : "m-slide-left";
|
|
1700
|
-
}
|
|
1701
|
-
return positionY.value === "top" ? "m-slide-top" : "m-slide-bottom";
|
|
1702
|
-
});
|
|
1703
|
-
const actionLoading = ref(false);
|
|
1704
|
-
const isActive = ref(false);
|
|
1705
|
-
const timer = ref();
|
|
1706
|
-
const queueTimer = ref();
|
|
1707
|
-
const containerClassName = `m-toast-container --${positionY.value} --${positionX.value}`;
|
|
1708
|
-
const selectorContainerClass = `.${containerClassName.replaceAll(" ", ".")}`;
|
|
1709
|
-
const createParents = () => {
|
|
1710
|
-
const container = document.querySelector(selectorContainerClass);
|
|
1711
|
-
if (container)
|
|
1712
|
-
return;
|
|
1713
|
-
if (!container) {
|
|
1714
|
-
const body = document.body;
|
|
1715
|
-
const toCreate = document.createElement("div");
|
|
1716
|
-
toCreate.className = containerClassName;
|
|
1717
|
-
body.append(toCreate);
|
|
1718
|
-
}
|
|
1719
|
-
};
|
|
1720
|
-
const shouldQueue = () => {
|
|
1721
|
-
const container = document.querySelector(selectorContainerClass);
|
|
1722
|
-
if (!props.queue && props.maxToasts === false) {
|
|
1723
|
-
return false;
|
|
1724
|
-
}
|
|
1725
|
-
if (typeof props.maxToasts === "number" && container) {
|
|
1726
|
-
return props.maxToasts <= container.childElementCount;
|
|
1727
|
-
}
|
|
1728
|
-
return container && container.childElementCount > 0;
|
|
1729
|
-
};
|
|
1730
|
-
const showNotice = () => {
|
|
1731
|
-
if (shouldQueue()) {
|
|
1732
|
-
queueTimer.value = setTimeout(showNotice, 250);
|
|
1733
|
-
return;
|
|
1734
|
-
}
|
|
1735
|
-
const container = document.querySelector(selectorContainerClass);
|
|
1736
|
-
if (Toaster.value && container) {
|
|
1737
|
-
container.prepend(Toaster.value);
|
|
1738
|
-
}
|
|
1739
|
-
isActive.value = true;
|
|
1740
|
-
timer.value = props.timeout ? new ToasterTimer(close, props.timeout) : void 0;
|
|
1741
|
-
};
|
|
1742
|
-
function click(event) {
|
|
1743
|
-
emits("click", event);
|
|
1744
|
-
if (!props.persistent) {
|
|
1745
|
-
close();
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
1748
|
-
async function clickOnAction(func, event) {
|
|
1749
|
-
var _a;
|
|
1750
|
-
actionLoading.value = true;
|
|
1751
|
-
await func();
|
|
1752
|
-
actionLoading.value = false;
|
|
1753
|
-
if ((_a = props.action) == null ? void 0 : _a.closeToast) {
|
|
1754
|
-
click(event);
|
|
1755
|
-
}
|
|
1756
|
-
}
|
|
1757
|
-
const toggleTimer = (newVal) => {
|
|
1758
|
-
if (timer.value && !props.noPauseOnHover) {
|
|
1759
|
-
newVal ? timer.value.pause() : timer.value.resume();
|
|
1760
|
-
}
|
|
1761
|
-
};
|
|
1762
|
-
const stopTimer = () => {
|
|
1763
|
-
timer.value && timer.value.stop();
|
|
1764
|
-
if (queueTimer.value) {
|
|
1765
|
-
clearTimeout(queueTimer.value);
|
|
1766
|
-
}
|
|
1767
|
-
};
|
|
1768
|
-
const close = () => {
|
|
1769
|
-
stopTimer();
|
|
1770
|
-
isActive.value = false;
|
|
1771
|
-
setTimeout(() => {
|
|
1772
|
-
var _a;
|
|
1773
|
-
emits("close");
|
|
1774
|
-
(_a = Toaster.value) == null ? void 0 : _a.remove();
|
|
1775
|
-
const container = document.querySelector(selectorContainerClass);
|
|
1776
|
-
if (container && !(container == null ? void 0 : container.hasChildNodes())) {
|
|
1777
|
-
container.remove();
|
|
1778
|
-
}
|
|
1779
|
-
}, 300);
|
|
1780
|
-
};
|
|
1781
|
-
onMounted$1(() => {
|
|
1782
|
-
createParents();
|
|
1783
|
-
showNotice();
|
|
1784
|
-
});
|
|
1785
|
-
return (_ctx, _cache) => {
|
|
1786
|
-
return openBlock(), createBlock(Transition, {
|
|
1787
|
-
name: transitionName.value,
|
|
1788
|
-
persisted: ""
|
|
1789
|
-
}, {
|
|
1790
|
-
default: withCtx(() => [
|
|
1791
|
-
withDirectives(createElementVNode(
|
|
1792
|
-
"button",
|
|
1793
|
-
{
|
|
1794
|
-
ref_key: "Toaster",
|
|
1795
|
-
ref: Toaster,
|
|
1796
|
-
class: normalizeClass(["m-toast", [`--${__props.type}`, `--${positionY.value}`, `--${positionX.value}`]]),
|
|
1797
|
-
role: "alert",
|
|
1798
|
-
onMouseover: _cache[2] || (_cache[2] = ($event) => toggleTimer(true)),
|
|
1799
|
-
onMouseleave: _cache[3] || (_cache[3] = ($event) => toggleTimer(false)),
|
|
1800
|
-
onClick: _cache[4] || (_cache[4] = withModifiers(($event) => {
|
|
1801
|
-
var _a;
|
|
1802
|
-
return __props.link && !((_a = __props.link) == null ? void 0 : _a.closeToast) ? void 0 : click($event);
|
|
1803
|
-
}, ["stop"]))
|
|
1804
|
-
},
|
|
1805
|
-
[
|
|
1806
|
-
createElementVNode("div", _hoisted_1, [
|
|
1807
|
-
createElementVNode(
|
|
1808
|
-
"p",
|
|
1809
|
-
_hoisted_2,
|
|
1810
|
-
toDisplayString(__props.message),
|
|
1811
|
-
1
|
|
1812
|
-
/* TEXT */
|
|
1813
|
-
)
|
|
1814
|
-
]),
|
|
1815
|
-
__props.action ? (openBlock(), createBlock(unref(MazBtn), {
|
|
1816
|
-
key: 0,
|
|
1817
|
-
color: __props.type,
|
|
1818
|
-
pastel: "",
|
|
1819
|
-
loading: actionLoading.value,
|
|
1820
|
-
size: "sm",
|
|
1821
|
-
onClick: _cache[0] || (_cache[0] = withModifiers(($event) => clickOnAction(__props.action.func, $event), ["stop"]))
|
|
1822
|
-
}, {
|
|
1823
|
-
default: withCtx(() => [
|
|
1824
|
-
createTextVNode(
|
|
1825
|
-
toDisplayString(__props.action.text),
|
|
1826
|
-
1
|
|
1827
|
-
/* TEXT */
|
|
1828
|
-
)
|
|
1829
|
-
]),
|
|
1830
|
-
_: 1
|
|
1831
|
-
/* STABLE */
|
|
1832
|
-
}, 8, ["color", "loading"])) : createCommentVNode("v-if", true),
|
|
1833
|
-
__props.link ? (openBlock(), createBlock(unref(MazBtn), {
|
|
1834
|
-
key: 1,
|
|
1835
|
-
color: __props.type,
|
|
1836
|
-
pastel: "",
|
|
1837
|
-
size: "xs",
|
|
1838
|
-
href: __props.link.href,
|
|
1839
|
-
target: __props.link.target ?? "_self"
|
|
1840
|
-
}, {
|
|
1841
|
-
default: withCtx(() => {
|
|
1842
|
-
var _a;
|
|
1843
|
-
return [
|
|
1844
|
-
createElementVNode("div", _hoisted_3, [
|
|
1845
|
-
__props.link.text ? (openBlock(), createElementBlock(
|
|
1846
|
-
"span",
|
|
1847
|
-
_hoisted_4,
|
|
1848
|
-
toDisplayString(__props.link.text),
|
|
1849
|
-
1
|
|
1850
|
-
/* TEXT */
|
|
1851
|
-
)) : createCommentVNode("v-if", true),
|
|
1852
|
-
((_a = __props.link) == null ? void 0 : _a.target) == "_blank" ? (openBlock(), createBlock(unref(ExternalLink), {
|
|
1853
|
-
key: 1,
|
|
1854
|
-
class: "maz-text-xl"
|
|
1855
|
-
})) : (openBlock(), createBlock(unref(Link), {
|
|
1856
|
-
key: 2,
|
|
1857
|
-
class: "maz-text-xl"
|
|
1858
|
-
}))
|
|
1859
|
-
])
|
|
1860
|
-
];
|
|
1861
|
-
}),
|
|
1862
|
-
_: 1
|
|
1863
|
-
/* STABLE */
|
|
1864
|
-
}, 8, ["color", "href", "target"])) : createCommentVNode("v-if", true),
|
|
1865
|
-
!__props.persistent ? (openBlock(), createElementBlock("button", {
|
|
1866
|
-
key: 2,
|
|
1867
|
-
class: "--close",
|
|
1868
|
-
onClick: _cache[1] || (_cache[1] = withModifiers(($event) => click($event), ["stop"]))
|
|
1869
|
-
}, [
|
|
1870
|
-
createVNode(unref(XIcon), { class: "--icon maz-text-xl" })
|
|
1871
|
-
])) : createCommentVNode("v-if", true)
|
|
1872
|
-
],
|
|
1873
|
-
34
|
|
1874
|
-
/* CLASS, HYDRATE_EVENTS */
|
|
1875
|
-
), [
|
|
1876
|
-
[vShow, isActive.value]
|
|
1877
|
-
])
|
|
1878
|
-
]),
|
|
1879
|
-
_: 1
|
|
1880
|
-
/* STABLE */
|
|
1881
|
-
}, 8, ["name"]);
|
|
1882
|
-
};
|
|
1883
|
-
}
|
|
1884
|
-
});
|
|
1885
|
-
const MazToast_vue_vue_type_style_index_0_lang = "";
|
|
1886
|
-
const MazToast_vue_vue_type_style_index_1_scoped_27a7b86f_lang = "";
|
|
1887
|
-
const MazToast = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-27a7b86f"]]);
|
|
1888
|
-
const DEFAULT_OPTIONS$2 = {
|
|
1889
|
-
position: "bottom-right",
|
|
1890
|
-
timeout: 1e4,
|
|
1891
|
-
persistent: false
|
|
1892
|
-
};
|
|
1893
|
-
class ToasterHandler {
|
|
1894
|
-
constructor(app, globalOptions) {
|
|
1895
|
-
this.app = app;
|
|
1896
|
-
this.globalOptions = globalOptions;
|
|
1897
|
-
}
|
|
1898
|
-
show(message, options) {
|
|
1899
|
-
const localOptions = { message, ...options };
|
|
1900
|
-
const propsData = {
|
|
1901
|
-
...DEFAULT_OPTIONS$2,
|
|
1902
|
-
...localOptions,
|
|
1903
|
-
...this.globalOptions,
|
|
1904
|
-
...options
|
|
1905
|
-
};
|
|
1906
|
-
mount(MazToast, {
|
|
1907
|
-
props: propsData,
|
|
1908
|
-
app: this.app
|
|
1909
|
-
});
|
|
1910
|
-
}
|
|
1911
|
-
getLocalOptions(type, options) {
|
|
1912
|
-
return {
|
|
1913
|
-
type,
|
|
1914
|
-
...options
|
|
1915
|
-
};
|
|
1916
|
-
}
|
|
1917
|
-
success(message, options) {
|
|
1918
|
-
return this.show(message, this.getLocalOptions("success", options));
|
|
1919
|
-
}
|
|
1920
|
-
error(message, options) {
|
|
1921
|
-
return this.show(message, this.getLocalOptions("danger", options));
|
|
1922
|
-
}
|
|
1923
|
-
info(message, options) {
|
|
1924
|
-
return this.show(message, this.getLocalOptions("info", options));
|
|
1925
|
-
}
|
|
1926
|
-
warning(message, options) {
|
|
1927
|
-
return this.show(message, this.getLocalOptions("warning", options));
|
|
1928
|
-
}
|
|
1929
|
-
}
|
|
1930
|
-
let toastInstance;
|
|
1931
|
-
const installToaster = {
|
|
1932
|
-
install(app, options) {
|
|
1933
|
-
toastInstance = new ToasterHandler(app, options);
|
|
1934
|
-
app.provide("toast", toastInstance);
|
|
1935
|
-
}
|
|
1936
|
-
};
|
|
1937
|
-
const DEFAULT_LOADER = "";
|
|
1938
|
-
const uniq = (array) => {
|
|
1939
|
-
return array.filter((el, index, arr) => index === arr.indexOf(el));
|
|
1940
|
-
};
|
|
1941
|
-
const contains = (array) => (predicate = DEFAULT_LOADER) => {
|
|
1942
|
-
return typeof predicate === "function" ? array.findIndex((...args) => predicate(...args)) > -1 : array.includes(predicate);
|
|
1943
|
-
};
|
|
1944
|
-
const hasItems = (array) => array.length > 0;
|
|
1945
|
-
const push = (array) => (item = DEFAULT_LOADER) => uniq([...array, item]);
|
|
1946
|
-
const pop = (array) => (item = DEFAULT_LOADER) => array.filter((_item) => _item !== item);
|
|
1947
|
-
class WaitHandler {
|
|
1948
|
-
constructor() {
|
|
1949
|
-
__publicField(this, "_loaders", ref([]));
|
|
1950
|
-
}
|
|
1951
|
-
get loaders() {
|
|
1952
|
-
return computed(() => this._loaders.value);
|
|
1953
|
-
}
|
|
1954
|
-
stop(loaderId = DEFAULT_LOADER) {
|
|
1955
|
-
this._loaders.value = pop(this._loaders.value)(loaderId);
|
|
1956
|
-
}
|
|
1957
|
-
start(loaderId = DEFAULT_LOADER) {
|
|
1958
|
-
this._loaders.value = push(this._loaders.value)(loaderId);
|
|
1959
|
-
return () => this.stop(loaderId);
|
|
1960
|
-
}
|
|
1961
|
-
get anyLoading() {
|
|
1962
|
-
return computed(() => hasItems(this._loaders.value));
|
|
1963
|
-
}
|
|
1964
|
-
isLoading(loaderId = DEFAULT_LOADER) {
|
|
1965
|
-
const isLoading = computed(() => contains(this._loaders.value)(loaderId));
|
|
1966
|
-
return isLoading.value;
|
|
1967
|
-
}
|
|
1968
|
-
}
|
|
1969
|
-
const instance$1 = new WaitHandler();
|
|
1970
|
-
const plugin$1 = {
|
|
1971
|
-
install: (app) => {
|
|
1972
|
-
app.provide("wait", instance$1);
|
|
1973
|
-
}
|
|
1974
|
-
};
|
|
1975
|
-
const DEFAULT_OPTIONS$1 = {
|
|
1976
|
-
delay: 100,
|
|
1977
|
-
observer: {
|
|
1978
|
-
root: void 0,
|
|
1979
|
-
rootMargin: "0px",
|
|
1980
|
-
threshold: 0.2
|
|
1981
|
-
},
|
|
1982
|
-
animation: {
|
|
1983
|
-
once: true,
|
|
1984
|
-
duration: 300,
|
|
1985
|
-
delay: 0
|
|
1986
|
-
}
|
|
1987
|
-
};
|
|
1988
|
-
class AosHandler {
|
|
1989
|
-
constructor(options) {
|
|
1990
|
-
__publicField(this, "options");
|
|
1991
|
-
this.options = {
|
|
1992
|
-
delay: (options == null ? void 0 : options.delay) ?? DEFAULT_OPTIONS$1.delay,
|
|
1993
|
-
observer: {
|
|
1994
|
-
...DEFAULT_OPTIONS$1.observer,
|
|
1995
|
-
...options == null ? void 0 : options.observer
|
|
1996
|
-
},
|
|
1997
|
-
animation: {
|
|
1998
|
-
...DEFAULT_OPTIONS$1.animation,
|
|
1999
|
-
...options == null ? void 0 : options.animation
|
|
2000
|
-
}
|
|
2001
|
-
};
|
|
2002
|
-
}
|
|
2003
|
-
async handleObserver() {
|
|
2004
|
-
await sleep(this.options.delay);
|
|
2005
|
-
const observer = new IntersectionObserver(this.handleIntersect.bind(this), {
|
|
2006
|
-
...this.options.observer
|
|
2007
|
-
});
|
|
2008
|
-
for (const element of document.querySelectorAll("[data-maz-aos]")) {
|
|
2009
|
-
const anchorAttr = element.getAttribute("data-maz-aos-anchor");
|
|
2010
|
-
if (anchorAttr) {
|
|
2011
|
-
const anchorElement = document.querySelector(anchorAttr);
|
|
2012
|
-
if (anchorElement) {
|
|
2013
|
-
anchorElement.setAttribute("data-maz-aos-children", "true");
|
|
2014
|
-
observer.observe(anchorElement);
|
|
2015
|
-
} else {
|
|
2016
|
-
console.warn(`[maz-ui](aos) no element found with selector "${anchorAttr}"`);
|
|
2017
|
-
}
|
|
2018
|
-
} else {
|
|
2019
|
-
observer.observe(element);
|
|
2020
|
-
}
|
|
2021
|
-
}
|
|
2022
|
-
}
|
|
2023
|
-
runAnimations() {
|
|
2024
|
-
if (isClient()) {
|
|
2025
|
-
return this.handleObserver();
|
|
2026
|
-
} else {
|
|
2027
|
-
console.warn("[MazAos](runAnimations) should be executed on client side");
|
|
2028
|
-
}
|
|
2029
|
-
}
|
|
2030
|
-
handleIntersect(entries, observer) {
|
|
2031
|
-
for (const entry of entries) {
|
|
2032
|
-
const target = entry.target;
|
|
2033
|
-
const hasChildren = target.getAttribute("data-maz-aos-children") === "true";
|
|
2034
|
-
const animateElements = entry.target.getAttribute("data-maz-aos") ? [entry.target] : [];
|
|
2035
|
-
if (hasChildren) {
|
|
2036
|
-
const children = [...document.querySelectorAll("[data-maz-aos-anchor]")].map(
|
|
2037
|
-
(child) => child.getAttribute("data-maz-aos-anchor") === `#${entry.target.id}` ? child : void 0
|
|
2038
|
-
);
|
|
2039
|
-
for (const child of children) {
|
|
2040
|
-
if (child) {
|
|
2041
|
-
animateElements.push(child);
|
|
2042
|
-
}
|
|
2043
|
-
}
|
|
2044
|
-
}
|
|
2045
|
-
for (const element of animateElements) {
|
|
2046
|
-
const once = element.getAttribute("data-maz-aos-once");
|
|
2047
|
-
const useOnce = typeof once === "string" ? once === "true" : this.options.animation.once;
|
|
2048
|
-
if (typeof this.options.observer.threshold === "number" && entry.intersectionRatio > this.options.observer.threshold) {
|
|
2049
|
-
const duration = element.getAttribute("data-maz-aos-duration");
|
|
2050
|
-
const delay = element.getAttribute("data-maz-aos-delay");
|
|
2051
|
-
if (!duration) {
|
|
2052
|
-
element.style.transitionDuration = `${this.options.animation.duration}ms`;
|
|
2053
|
-
setTimeout(() => {
|
|
2054
|
-
element.style.transitionDuration = "0";
|
|
2055
|
-
}, 1e3);
|
|
2056
|
-
}
|
|
2057
|
-
if (!delay) {
|
|
2058
|
-
element.style.transitionDelay = `${this.options.animation.delay}ms`;
|
|
2059
|
-
setTimeout(() => {
|
|
2060
|
-
element.style.transitionDelay = "0";
|
|
2061
|
-
}, 1e3);
|
|
2062
|
-
}
|
|
2063
|
-
element.classList.add("maz-aos-animate");
|
|
2064
|
-
if (useOnce) {
|
|
2065
|
-
observer.unobserve(element);
|
|
2066
|
-
}
|
|
2067
|
-
} else {
|
|
2068
|
-
element.classList.remove("maz-aos-animate");
|
|
2069
|
-
}
|
|
2070
|
-
}
|
|
2071
|
-
}
|
|
2072
|
-
}
|
|
2073
|
-
}
|
|
2074
|
-
let instance;
|
|
2075
|
-
const plugin = {
|
|
2076
|
-
install: (app, options) => {
|
|
2077
|
-
instance = new AosHandler(options);
|
|
2078
|
-
app.provide("aos", instance);
|
|
2079
|
-
if (!isClient()) {
|
|
2080
|
-
return;
|
|
2081
|
-
}
|
|
2082
|
-
if (options == null ? void 0 : options.router) {
|
|
2083
|
-
options.router.afterEach(async () => {
|
|
2084
|
-
instance.runAnimations();
|
|
2085
|
-
});
|
|
2086
|
-
} else {
|
|
2087
|
-
instance.runAnimations();
|
|
2088
|
-
}
|
|
2089
|
-
}
|
|
2090
|
-
};
|
|
2091
|
-
const DEFAULT_OPTIONS = {
|
|
2092
|
-
darkClass: "dark",
|
|
2093
|
-
lightClass: "light",
|
|
2094
|
-
storageThemeKey: "theme",
|
|
2095
|
-
storageThemeValueDark: "dark",
|
|
2096
|
-
storageThemeValueLight: "light",
|
|
2097
|
-
storageThemeValueSystem: "system"
|
|
2098
|
-
};
|
|
2099
|
-
const theme = ref("system");
|
|
2100
|
-
const selectedTheme = ref("system");
|
|
2101
|
-
function setDarkTheme({
|
|
2102
|
-
darkClass,
|
|
2103
|
-
lightClass,
|
|
2104
|
-
storageThemeKey,
|
|
2105
|
-
storageThemeValueDark,
|
|
2106
|
-
setLocalStorageValue = true,
|
|
2107
|
-
setSelectedTheme = true
|
|
2108
|
-
}) {
|
|
2109
|
-
document.documentElement.classList.remove(lightClass);
|
|
2110
|
-
document.documentElement.classList.add(darkClass);
|
|
2111
|
-
theme.value = storageThemeValueDark;
|
|
2112
|
-
if (setSelectedTheme)
|
|
2113
|
-
selectedTheme.value = storageThemeValueDark;
|
|
2114
|
-
if (setLocalStorageValue) {
|
|
2115
|
-
localStorage[storageThemeKey] = storageThemeValueDark;
|
|
2116
|
-
}
|
|
2117
|
-
}
|
|
2118
|
-
function setLightTheme({
|
|
2119
|
-
darkClass,
|
|
2120
|
-
lightClass,
|
|
2121
|
-
storageThemeKey,
|
|
2122
|
-
storageThemeValueLight,
|
|
2123
|
-
setLocalStorageValue = true,
|
|
2124
|
-
setSelectedTheme = true
|
|
2125
|
-
}) {
|
|
2126
|
-
document.documentElement.classList.remove(darkClass);
|
|
2127
|
-
document.documentElement.classList.add(lightClass);
|
|
2128
|
-
theme.value = storageThemeValueLight;
|
|
2129
|
-
if (setSelectedTheme)
|
|
2130
|
-
selectedTheme.value = storageThemeValueLight;
|
|
2131
|
-
if (setLocalStorageValue) {
|
|
2132
|
-
localStorage[storageThemeKey] = storageThemeValueLight;
|
|
2133
|
-
}
|
|
2134
|
-
}
|
|
2135
|
-
function setSytemTheme(options) {
|
|
2136
|
-
document.documentElement.classList.remove(options.darkClass);
|
|
2137
|
-
document.documentElement.classList.remove(options.lightClass);
|
|
2138
|
-
theme.value = options.storageThemeValueSystem;
|
|
2139
|
-
selectedTheme.value = options.storageThemeValueSystem;
|
|
2140
|
-
if (options.setLocalStorageValue) {
|
|
2141
|
-
localStorage[options.storageThemeKey] = options.storageThemeValueSystem;
|
|
2142
|
-
}
|
|
2143
|
-
autoSetTheme({ ...options, setSelectedTheme: false });
|
|
2144
|
-
}
|
|
2145
|
-
function getPrefDark() {
|
|
2146
|
-
return window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
2147
|
-
}
|
|
2148
|
-
function autoSetTheme(options) {
|
|
2149
|
-
if (localStorage[options.storageThemeKey] === options.storageThemeValueDark || !(options.storageThemeKey in localStorage) && getPrefDark() || localStorage[options.storageThemeKey] === options.storageThemeValueSystem && getPrefDark()) {
|
|
2150
|
-
setDarkTheme({
|
|
2151
|
-
...options,
|
|
2152
|
-
setLocalStorageValue: false,
|
|
2153
|
-
setSelectedTheme: false
|
|
2154
|
-
});
|
|
2155
|
-
} else {
|
|
2156
|
-
setLightTheme({
|
|
2157
|
-
...options,
|
|
2158
|
-
setLocalStorageValue: false,
|
|
2159
|
-
setSelectedTheme: false
|
|
2160
|
-
});
|
|
2161
|
-
}
|
|
2162
|
-
}
|
|
2163
|
-
function setTheme({
|
|
2164
|
-
shouldSetDarkMode,
|
|
2165
|
-
...rest
|
|
2166
|
-
}) {
|
|
2167
|
-
if (typeof shouldSetDarkMode !== "boolean") {
|
|
2168
|
-
return setSytemTheme(rest);
|
|
2169
|
-
}
|
|
2170
|
-
return shouldSetDarkMode ? setDarkTheme(rest) : setLightTheme(rest);
|
|
2171
|
-
}
|
|
2172
|
-
function toggleTheme(options) {
|
|
2173
|
-
return theme.value === options.storageThemeValueDark ? setLightTheme(options) : setDarkTheme(options);
|
|
2174
|
-
}
|
|
2175
|
-
function useThemeHandler(opts = DEFAULT_OPTIONS) {
|
|
2176
|
-
const options = {
|
|
2177
|
-
...DEFAULT_OPTIONS,
|
|
2178
|
-
...opts
|
|
2179
|
-
};
|
|
2180
|
-
const hasDarkTheme = computed(() => selectedTheme.value === options.storageThemeValueDark);
|
|
2181
|
-
const hasLightTheme = computed(() => selectedTheme.value === options.storageThemeValueLight);
|
|
2182
|
-
const hasSystemTheme = computed(() => selectedTheme.value === options.storageThemeValueSystem);
|
|
2183
|
-
onMounted$1(() => {
|
|
2184
|
-
if (localStorage[options.storageThemeKey]) {
|
|
2185
|
-
theme.value = localStorage[options.storageThemeKey];
|
|
2186
|
-
selectedTheme.value = localStorage[options.storageThemeKey];
|
|
2187
|
-
}
|
|
2188
|
-
});
|
|
2189
|
-
return {
|
|
2190
|
-
autoSetTheme: () => autoSetTheme(options),
|
|
2191
|
-
toggleTheme: () => toggleTheme(options),
|
|
2192
|
-
setSystemTheme: () => setSytemTheme({ ...options, setLocalStorageValue: true }),
|
|
2193
|
-
setDarkTheme: () => setTheme({ ...options, shouldSetDarkMode: true }),
|
|
2194
|
-
setLightTheme: () => setTheme({ ...options, shouldSetDarkMode: false }),
|
|
2195
|
-
hasDarkTheme,
|
|
2196
|
-
hasLightTheme,
|
|
2197
|
-
hasSystemTheme,
|
|
2198
|
-
theme,
|
|
2199
|
-
selectedTheme
|
|
2200
|
-
};
|
|
2201
|
-
}
|
|
2202
|
-
const useInstanceUniqId = ({
|
|
2203
|
-
componentName,
|
|
2204
|
-
instance: instance2,
|
|
2205
|
-
providedId
|
|
2206
|
-
}) => {
|
|
2207
|
-
return computed(() => providedId ?? `${componentName}-${instance2 == null ? void 0 : instance2.uid}`);
|
|
2208
|
-
};
|
|
2209
|
-
const useAos = () => {
|
|
2210
|
-
return injectStrict("aos");
|
|
2211
|
-
};
|
|
2212
|
-
const useWait = () => {
|
|
2213
|
-
return injectStrict("wait");
|
|
2214
|
-
};
|
|
2215
|
-
const useToast = () => {
|
|
2216
|
-
return injectStrict("toast");
|
|
2217
|
-
};
|
|
2218
|
-
const useIdleTimeout = ({
|
|
2219
|
-
callback,
|
|
2220
|
-
options
|
|
2221
|
-
}) => {
|
|
2222
|
-
return new IdleTimeout(callback, options);
|
|
2223
|
-
};
|
|
2224
|
-
const useUserVisibility = ({
|
|
2225
|
-
callback,
|
|
2226
|
-
options
|
|
2227
|
-
}) => {
|
|
2228
|
-
return new UserVisibility(callback, options);
|
|
2229
|
-
};
|
|
2230
|
-
const confirmDialogData = ref();
|
|
2231
|
-
const dialogState = ref([]);
|
|
2232
|
-
const showDialogAndWaitChoice = (identifier, callback) => {
|
|
2233
|
-
return new Promise((resolve, reject) => {
|
|
2234
|
-
dialogState.value = [
|
|
2235
|
-
...dialogState.value,
|
|
2236
|
-
{
|
|
2237
|
-
id: identifier,
|
|
2238
|
-
isActive: true,
|
|
2239
|
-
resolve: async () => {
|
|
2240
|
-
await (callback == null ? void 0 : callback());
|
|
2241
|
-
resolve(true);
|
|
2242
|
-
},
|
|
2243
|
-
reject
|
|
2244
|
-
}
|
|
2245
|
-
];
|
|
2246
|
-
});
|
|
2247
|
-
};
|
|
2248
|
-
const removeDialogFromState = (identifier) => {
|
|
2249
|
-
dialogState.value = dialogState.value.filter(({ id }) => id !== identifier);
|
|
2250
|
-
return dialogState.value;
|
|
2251
|
-
};
|
|
2252
|
-
const responseDialog = (type, currentDialog, response = false) => {
|
|
2253
|
-
var _a;
|
|
2254
|
-
if (currentDialog) {
|
|
2255
|
-
(_a = currentDialog[type]) == null ? void 0 : _a.call(currentDialog, response);
|
|
2256
|
-
currentDialog.isActive = false;
|
|
2257
|
-
setTimeout(() => {
|
|
2258
|
-
removeDialogFromState(currentDialog.id);
|
|
2259
|
-
}, 500);
|
|
2260
|
-
}
|
|
2261
|
-
};
|
|
2262
|
-
const useMazDialogPromise = () => ({
|
|
2263
|
-
confirmDialogData,
|
|
2264
|
-
dialogState,
|
|
2265
|
-
showDialogAndWaitChoice,
|
|
2266
|
-
removeDialogFromState,
|
|
2267
|
-
rejectDialog: (currentDialog, response = false) => responseDialog("reject", currentDialog, response),
|
|
2268
|
-
resolveDialog: (currentDialog, response = false) => responseDialog("resolve", currentDialog, response)
|
|
2269
|
-
});
|
|
2270
|
-
export {
|
|
2271
|
-
instance$1 as A,
|
|
2272
|
-
AosHandler as B,
|
|
2273
|
-
plugin as C,
|
|
2274
|
-
instance as D,
|
|
2275
|
-
useThemeHandler as E,
|
|
2276
|
-
useInstanceUniqId as F,
|
|
2277
|
-
useAos as G,
|
|
2278
|
-
useWait as H,
|
|
2279
|
-
IdleTimeout as I,
|
|
2280
|
-
useToast as J,
|
|
2281
|
-
useIdleTimeout as K,
|
|
2282
|
-
useUserVisibility as L,
|
|
2283
|
-
useMazDialogPromise as M,
|
|
2284
|
-
ScriptLoader as S,
|
|
2285
|
-
ToasterHandler as T,
|
|
2286
|
-
UserVisibility as U,
|
|
2287
|
-
WaitHandler as W,
|
|
2288
|
-
_export_sfc as _,
|
|
2289
|
-
isClient as a,
|
|
2290
|
-
installDirectives as b,
|
|
2291
|
-
countryCodeToUnicodeFlag as c,
|
|
2292
|
-
debounce as d,
|
|
2293
|
-
directive$1 as e,
|
|
2294
|
-
plugin$2 as f,
|
|
2295
|
-
vZoomImg as g,
|
|
2296
|
-
plugin$3 as h,
|
|
2297
|
-
injectStrict as i,
|
|
2298
|
-
vFullscreenImg as j,
|
|
2299
|
-
vFullscreenImgInstall as k,
|
|
2300
|
-
directive as l,
|
|
2301
|
-
mount as m,
|
|
2302
|
-
plugin$4 as n,
|
|
2303
|
-
installFilters as o,
|
|
2304
|
-
plugin$5 as p,
|
|
2305
|
-
capitalize as q,
|
|
2306
|
-
currency as r,
|
|
2307
|
-
sleep as s,
|
|
2308
|
-
truthyFilter as t,
|
|
2309
|
-
date as u,
|
|
2310
|
-
vLazyImg as v,
|
|
2311
|
-
number as w,
|
|
2312
|
-
installToaster as x,
|
|
2313
|
-
toastInstance as y,
|
|
2314
|
-
plugin$1 as z
|
|
2315
|
-
};
|