maz-ui 3.4.5 → 3.6.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.d.ts +156 -149
- package/components/MazAvatar.mjs +656 -0
- package/components/MazAvatar.umd.js +2 -0
- package/components/MazBackdrop.d.ts +89 -89
- package/components/MazBackdrop.mjs +140 -0
- package/components/MazBackdrop.umd.js +2 -0
- package/components/MazBadge.d.ts +73 -68
- package/components/MazBadge.mjs +61 -0
- package/components/MazBadge.umd.js +2 -0
- package/components/MazBottomSheet.d.ts +36 -29
- package/components/MazBottomSheet.mjs +553 -0
- package/components/MazBottomSheet.umd.js +2 -0
- package/components/MazBtn.d.ts +178 -171
- package/components/MazBtn.mjs +371 -0
- package/components/MazBtn.umd.js +2 -0
- package/components/MazCard.d.ts +194 -183
- package/components/MazCard.mjs +1390 -0
- package/components/MazCard.umd.js +2 -0
- package/components/MazCarousel.d.ts +24 -16
- package/components/MazCarousel.mjs +469 -0
- package/components/MazCarousel.umd.js +2 -0
- package/components/MazChart/includes.d.ts +11 -11
- package/components/MazChart.d.ts +114 -114
- package/components/MazChart.mjs +135 -0
- package/components/MazChart.umd.js +2 -0
- package/components/MazCheckbox.d.ts +54 -49
- package/components/MazCheckbox.mjs +86 -0
- package/components/MazCheckbox.umd.js +2 -0
- package/components/MazDialog.d.ts +40 -29
- package/components/MazDialog.mjs +566 -0
- package/components/MazDialog.umd.js +2 -0
- package/components/MazDialogPromise/use-maz-dialog-promise.d.ts +30 -30
- package/components/MazDialogPromise.d.ts +36 -28
- package/components/MazDialogPromise.mjs +692 -0
- package/components/MazDialogPromise.umd.js +2 -0
- package/components/MazDrawer.d.ts +69 -59
- package/components/MazDrawer.mjs +572 -0
- package/components/MazDrawer.umd.js +2 -0
- package/components/MazDropzone.d.ts +128 -128
- package/components/MazDropzone.mjs +369 -0
- package/components/MazDropzone.umd.js +2 -0
- package/components/MazGallery.d.ts +144 -144
- package/components/MazGallery.mjs +948 -0
- package/components/MazGallery.umd.js +2 -0
- package/components/MazIcon.d.ts +64 -66
- package/components/MazIcon.mjs +161 -0
- package/components/MazIcon.umd.js +2 -0
- package/components/MazInput.d.ts +276 -276
- package/components/MazInput.mjs +750 -0
- package/components/MazInput.umd.js +2 -0
- package/components/MazInputNumber.d.ts +65 -67
- package/components/MazInputNumber.mjs +857 -0
- package/components/MazInputNumber.umd.js +2 -0
- package/components/MazInputPrice.d.ts +69 -64
- package/components/MazInputPrice.mjs +889 -0
- package/components/MazInputPrice.umd.js +2 -0
- package/components/MazInputTags.d.ts +94 -96
- package/components/MazInputTags.mjs +904 -0
- package/components/MazInputTags.umd.js +2 -0
- package/components/MazLazyImg.d.ts +85 -80
- package/components/MazLazyImg.mjs +376 -0
- package/components/MazLazyImg.umd.js +2 -0
- package/components/MazPhoneNumberInput/constantes/locales.d.ts +12 -12
- package/components/MazPhoneNumberInput/types.d.ts +21 -21
- package/components/MazPhoneNumberInput/utils/countries-name-list-by-iso-code.d.ts +2 -2
- package/components/MazPhoneNumberInput/utils/index.d.ts +12 -12
- package/components/MazPhoneNumberInput.d.ts +253 -255
- package/components/MazPhoneNumberInput.mjs +1904 -0
- package/components/MazPhoneNumberInput.umd.js +2 -0
- package/components/MazPicker/MazPickerCalendar.vue.d.ts +135 -137
- package/components/MazPicker/MazPickerCalendarMonth/MazPickerCalendarDays.vue.d.ts +20 -22
- package/components/MazPicker/MazPickerCalendarMonth/MazPickerCalendarGrid.vue.d.ts +112 -114
- package/components/MazPicker/MazPickerCalendarMonth/MazPickerCalendarMonth.vue.d.ts +122 -124
- package/components/MazPicker/MazPickerCalendarSwitcher.vue.d.ts +36 -38
- package/components/MazPicker/MazPickerContainer.vue.d.ts +210 -212
- package/components/MazPicker/MazPickerFooter.vue.d.ts +16 -0
- package/components/MazPicker/MazPickerHeader.vue.d.ts +82 -84
- package/components/MazPicker/MazPickerMonthSwitcher.vue.d.ts +41 -43
- package/components/MazPicker/MazPickerShortcuts.vue.d.ts +60 -62
- package/components/MazPicker/MazPickerTime.vue.d.ts +127 -129
- package/components/MazPicker/MazPickerYearSwitcher.vue.d.ts +33 -35
- package/components/MazPicker/types.d.ts +15 -15
- package/components/MazPicker/utils.d.ts +54 -54
- package/components/MazPicker.d.ts +311 -313
- package/components/MazPicker.mjs +2942 -0
- package/components/MazPicker.umd.js +2 -0
- package/components/MazRadioButtons.d.ts +77 -69
- package/components/MazRadioButtons.mjs +80 -0
- package/components/MazRadioButtons.umd.js +2 -0
- package/components/MazSelect.d.ts +185 -176
- package/components/MazSelect.mjs +1082 -0
- package/components/MazSelect.umd.js +2 -0
- package/components/MazSlider/utils.d.ts +15 -15
- package/components/MazSlider.d.ts +94 -96
- package/components/MazSlider.mjs +377 -0
- package/components/MazSlider.umd.js +2 -0
- package/components/MazSpinner.d.ts +28 -30
- package/components/MazSpinner.mjs +59 -0
- package/components/MazSpinner.umd.js +2 -0
- package/components/MazStepper.d.ts +71 -73
- package/components/MazStepper.mjs +227 -0
- package/components/MazStepper.umd.js +2 -0
- package/components/MazSwitch.d.ts +54 -56
- package/components/MazSwitch.mjs +61 -0
- package/components/MazSwitch.umd.js +2 -0
- package/components/MazTabsBar.d.ts +47 -49
- package/components/MazTabsBar.mjs +470 -0
- package/components/MazTabsBar.umd.js +2 -0
- package/components/MazTabsContent.d.ts +21 -16
- package/components/MazTabsContent.mjs +89 -0
- package/components/MazTabsContent.umd.js +2 -0
- package/components/MazTabsContentItem.d.ts +19 -14
- package/components/MazTabsContentItem.mjs +61 -0
- package/components/MazTabsContentItem.umd.js +2 -0
- package/components/MazTextarea/textarea-autogrow.d.ts +9 -9
- package/components/MazTextarea.d.ts +123 -125
- package/components/MazTextarea.mjs +260 -0
- package/components/MazTextarea.umd.js +2 -0
- package/components/MazTransitionExpand.d.ts +9 -4
- package/components/MazTransitionExpand.mjs +62 -0
- package/components/MazTransitionExpand.umd.js +2 -0
- package/components/index.d.ts +33 -34
- package/components/index.mjs +35 -0
- package/components/index.umd.js +35 -0
- package/components/no_photo-410a8f01.mjs +4 -0
- package/components/types.d.ts +17 -17
- package/css/main.css +1 -1
- package/maz-ui.d.ts +234 -231
- package/modules/maz-ui.mjs +1892 -0
- package/modules/maz-ui.umd.js +2 -0
- package/modules/no_photo-410a8f01.mjs +4 -0
- package/package.json +45 -54
- package/tailwindcss/tailwind.config.js +6 -7
- package/tailwindcss/utils/colors.js +1 -3
- package/tailwindcss/variables/breakpoints.js +1 -2
- package/tailwindcss/variables/utilities.js +1 -2
- package/tailwindcss/variables/z-indexes.js +1 -1
- package/components/MazArrowIcon.d.ts +0 -43
- package/components/MazArrowIcon.js +0 -1
- package/components/MazAvatar.js +0 -3
- package/components/MazBackdrop.js +0 -3
- package/components/MazBadge.js +0 -1
- package/components/MazBottomSheet.js +0 -3
- package/components/MazBtn.js +0 -3
- package/components/MazCard.js +0 -3
- package/components/MazCarousel.js +0 -3
- package/components/MazChart.js +0 -1
- package/components/MazCheckbox.js +0 -1
- package/components/MazDialog.js +0 -3
- package/components/MazDialogPromise.js +0 -3
- package/components/MazDrawer.js +0 -3
- package/components/MazDropzone.js +0 -3
- package/components/MazGallery.js +0 -3
- package/components/MazIcon.js +0 -3
- package/components/MazInput.js +0 -3
- package/components/MazInputNumber.js +0 -3
- package/components/MazInputPrice.js +0 -3
- package/components/MazInputTags.js +0 -3
- package/components/MazLazyImg.js +0 -3
- package/components/MazPhoneNumberInput.js +0 -3
- package/components/MazPicker.js +0 -3
- package/components/MazRadioButtons.js +0 -1
- package/components/MazSelect.js +0 -3
- package/components/MazSlider.js +0 -3
- package/components/MazSpinner.js +0 -1
- package/components/MazStepper.js +0 -1
- package/components/MazSwitch.js +0 -1
- package/components/MazTabsBar.js +0 -3
- package/components/MazTabsContent.js +0 -1
- package/components/MazTabsContentItem.js +0 -3
- package/components/MazTextarea.js +0 -1
- package/components/MazTransitionExpand.js +0 -1
- package/components/index.js +0 -36
- package/components/no_photo-a72545e4.js +0 -1
- package/modules/index.js +0 -3
- package/modules/no_photo-a72545e4.js +0 -1
|
@@ -0,0 +1,948 @@
|
|
|
1
|
+
(function(){"use strict";try{if(typeof document!="undefined"){var a=document.createElement("style");a.appendChild(document.createTextNode(".m-gallery[data-v-680a27a0]{position:relative;overflow:hidden}.m-gallery__hidden[data-v-680a27a0]{display:none}.m-gallery__item[data-v-680a27a0]{position:absolute;top:0px;margin:0;height:50%;width:100%;overflow:hidden;border-left-width:2px;border-color:transparent;padding:0}.m-gallery__item--1[data-v-680a27a0]{left:0;height:100%}.m-gallery__item--1[data-v-680a27a0]:not(:last-child){width:50%}.m-gallery__item--2[data-v-680a27a0]{left:50%;width:50%;height:50%}.m-gallery__item--2[data-v-680a27a0]:last-child{height:100%}.m-gallery__item--2[data-v-680a27a0]:nth-last-child(4){width:25%}.m-gallery__item--3[data-v-680a27a0]{top:50%;left:50%;width:25%}.m-gallery__item--3[data-v-680a27a0]:last-child{width:50%}.m-gallery__item--3[data-v-680a27a0]:nth-last-child(3){top:0;left:75%}.m-gallery__item--4[data-v-680a27a0]{border-top-width:2px;border-color:transparent;top:50%;left:50%;width:25%}.m-gallery__item--4[data-v-680a27a0]:last-child{left:75%;width:25%}.m-gallery__item--5[data-v-680a27a0]{border-top-width:2px;border-color:transparent;top:50%;left:75%;width:25%}.m-gallery__item[data-v-680a27a0]:first-child{border-left:0}.m-gallery__item--3[data-v-680a27a0]:last-child,.m-gallery__item--3[data-v-680a27a0]:nth-last-child(2),.m-gallery__item--4[data-v-680a27a0]:last-child,.m-gallery__item--5[data-v-680a27a0]{border-top-width:2px;border-color:transparent}.m-gallery__item__image[data-v-680a27a0]{height:100%;max-width:100%;width:100%;background-position:center center;background-size:cover;background-repeat:no-repeat;background-color:#0000007f}.m-gallery__remaining-layer[data-v-680a27a0]{position:absolute;top:0;bottom:0;right:0;left:0}.m-gallery__remaining-layer a span[data-v-680a27a0]{color:#fff;font-size:2rem}")),document.head.appendChild(a)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => {
|
|
5
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
|
+
return value;
|
|
7
|
+
};
|
|
8
|
+
import { inject, defineComponent, ref, computed, onMounted, watchEffect, openBlock, createElementBlock, mergeProps, createCommentVNode, nextTick, onBeforeMount, resolveComponent, resolveDirective, normalizeClass, normalizeStyle, createElementVNode, Fragment, renderList, withDirectives, toDisplayString, createVNode } from "vue";
|
|
9
|
+
const style = `
|
|
10
|
+
.maz-zoom-img {
|
|
11
|
+
position: fixed;
|
|
12
|
+
top: 0;
|
|
13
|
+
bottom: 0;
|
|
14
|
+
left: 0;
|
|
15
|
+
right: 0;
|
|
16
|
+
padding: 2.5rem;
|
|
17
|
+
z-index: 1050;
|
|
18
|
+
background-color: hsla(238, 15%, 40%, 0.7);
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.maz-zoom-img,
|
|
26
|
+
.maz-zoom-img * {
|
|
27
|
+
box-sizing: border-box;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.maz-zoom-img .maz-zoom-img__wrapper {
|
|
31
|
+
position: relative;
|
|
32
|
+
display: flex;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
align-items: center;
|
|
35
|
+
min-width: 0;
|
|
36
|
+
min-height: 0;
|
|
37
|
+
max-width: 100%;
|
|
38
|
+
max-height: 100%;
|
|
39
|
+
transition: all 300ms ease-in-out;
|
|
40
|
+
opacity: 0;
|
|
41
|
+
transform: scale(0.5);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.maz-zoom-img.maz-animate .maz-zoom-img__wrapper {
|
|
45
|
+
opacity: 1;
|
|
46
|
+
transform: scale(1);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.maz-zoom-img.maz-animate .maz-zoom-img__loader {
|
|
50
|
+
position: absolute;
|
|
51
|
+
top: 0;
|
|
52
|
+
bottom: 0;
|
|
53
|
+
left: 0;
|
|
54
|
+
right: 0;
|
|
55
|
+
display: flex;
|
|
56
|
+
align-items: center;
|
|
57
|
+
justify-content: center;
|
|
58
|
+
background-color: hsla(238, 15%, 40%, 0.7);
|
|
59
|
+
border-radius: 1rem;
|
|
60
|
+
z-index: 2;
|
|
61
|
+
min-width: 60px;
|
|
62
|
+
min-height: 60px;
|
|
63
|
+
}
|
|
64
|
+
.maz-zoom-img.maz-animate .maz-zoom-img__loader[hidden] {
|
|
65
|
+
display: none;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@-webkit-keyframes spin {
|
|
69
|
+
0% { transform: rotate(0deg); }
|
|
70
|
+
100% { transform: rotate(360deg); }
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@keyframes spin {
|
|
74
|
+
0% { transform: rotate(0deg); }
|
|
75
|
+
100% { transform: rotate(360deg); }
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.maz-zoom-img.maz-animate .maz-zoom-img__loader__svg {
|
|
79
|
+
animation: spin .6s linear infinite;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.maz-zoom-img img {
|
|
83
|
+
max-width: 100%;
|
|
84
|
+
max-height: 100%;
|
|
85
|
+
min-width: 0;
|
|
86
|
+
border-radius: 1rem;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.maz-zoom-img .maz-zoom-btn {
|
|
90
|
+
margin: 0 auto;
|
|
91
|
+
border: none;
|
|
92
|
+
background-color: hsla(0, 0%, 7%, 0.5);
|
|
93
|
+
box-shadow: 0 0 0.5rem 0 hsla(0, 0%, 0%, 0.2);
|
|
94
|
+
height: 2.2rem;
|
|
95
|
+
min-height: 2.2rem;
|
|
96
|
+
width: 2.2rem;
|
|
97
|
+
min-width: 2.2rem;
|
|
98
|
+
display: flex;
|
|
99
|
+
align-items: center;
|
|
100
|
+
justify-content: center;
|
|
101
|
+
border-radius: 2.2rem;
|
|
102
|
+
cursor: pointer;
|
|
103
|
+
flex: 0 0 auto;
|
|
104
|
+
outline: none;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.maz-zoom-img .maz-zoom-btn svg {
|
|
108
|
+
fill: white;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.maz-zoom-img .maz-zoom-btn.maz-zoom-btn--close {
|
|
112
|
+
position: absolute;
|
|
113
|
+
top: 0.5rem;
|
|
114
|
+
right: 0.5rem;
|
|
115
|
+
z-index: 1;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.maz-zoom-img .maz-zoom-btn.maz-zoom-btn--previous {
|
|
119
|
+
position: absolute;
|
|
120
|
+
left: 0.5rem;
|
|
121
|
+
z-index: 1;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.maz-zoom-img .maz-zoom-btn.maz-zoom-btn--next {
|
|
125
|
+
position: absolute;
|
|
126
|
+
right: 0.5rem;
|
|
127
|
+
z-index: 1;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.maz-zoom-img .maz-zoom-btn:hover {
|
|
131
|
+
background-color: hsl(0, 0%, 0%);
|
|
132
|
+
}`;
|
|
133
|
+
const svgs = {
|
|
134
|
+
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>',
|
|
135
|
+
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>',
|
|
136
|
+
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>',
|
|
137
|
+
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>'
|
|
138
|
+
};
|
|
139
|
+
class VueZoomImg {
|
|
140
|
+
constructor(binding) {
|
|
141
|
+
__publicField(this, "options");
|
|
142
|
+
__publicField(this, "loader");
|
|
143
|
+
__publicField(this, "wrapper");
|
|
144
|
+
__publicField(this, "img");
|
|
145
|
+
__publicField(this, "keydownHandler");
|
|
146
|
+
__publicField(this, "onImgLoadedCallback");
|
|
147
|
+
__publicField(this, "buttonsAdded");
|
|
148
|
+
__publicField(this, "defaultOptions", {
|
|
149
|
+
scale: true,
|
|
150
|
+
blur: true,
|
|
151
|
+
disabled: false
|
|
152
|
+
});
|
|
153
|
+
__publicField(this, "mouseEnterListener");
|
|
154
|
+
__publicField(this, "mouseLeaveListener");
|
|
155
|
+
__publicField(this, "renderPreviewListener");
|
|
156
|
+
if (!binding.value) {
|
|
157
|
+
throw new Error(
|
|
158
|
+
'[MazUI](zoom-img) Image path must be defined. Ex: `v-zoom-img="<PATH_TO_IMAGE>"`'
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
if (typeof binding.value === "object" && !binding.value.src) {
|
|
162
|
+
throw new Error("[maz-ui](zoom-img) src of image must be provided");
|
|
163
|
+
}
|
|
164
|
+
this.buttonsAdded = false;
|
|
165
|
+
this.options = this.buildOptions(binding);
|
|
166
|
+
this.keydownHandler = this.keydownLister.bind(this);
|
|
167
|
+
this.loader = this.getLoader();
|
|
168
|
+
this.wrapper = document.createElement("div");
|
|
169
|
+
this.wrapper.classList.add("maz-zoom-img__wrapper");
|
|
170
|
+
this.wrapper.prepend(this.loader);
|
|
171
|
+
this.img = document.createElement("img");
|
|
172
|
+
this.onImgLoadedCallback = this.onImgLoaded.bind(this);
|
|
173
|
+
this.imgEventHandler(true);
|
|
174
|
+
}
|
|
175
|
+
buildOptions(binding) {
|
|
176
|
+
return {
|
|
177
|
+
...this.defaultOptions,
|
|
178
|
+
...typeof binding.value === "object" ? binding.value : { src: binding.value }
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
get allInstances() {
|
|
182
|
+
return [
|
|
183
|
+
...document.querySelectorAll(".maz-zoom-img-instance")
|
|
184
|
+
];
|
|
185
|
+
}
|
|
186
|
+
create(el) {
|
|
187
|
+
if (this.options.disabled)
|
|
188
|
+
return;
|
|
189
|
+
el.style.cursor = "pointer";
|
|
190
|
+
setTimeout(() => el.classList.add("maz-zoom-img-instance"));
|
|
191
|
+
el.setAttribute("data-src", this.options.src);
|
|
192
|
+
if (this.options.alt)
|
|
193
|
+
el.setAttribute("data-alt", this.options.alt);
|
|
194
|
+
el.style.transition = "all 300ms ease-in-out";
|
|
195
|
+
this.mouseEnterListener = () => this.mouseEnter(el);
|
|
196
|
+
this.mouseLeaveListener = () => this.mouseLeave(el);
|
|
197
|
+
this.renderPreviewListener = () => this.renderPreview(el, this.options);
|
|
198
|
+
el.addEventListener("mouseenter", this.mouseEnterListener);
|
|
199
|
+
el.addEventListener("mouseleave", this.mouseLeaveListener);
|
|
200
|
+
el.addEventListener("click", this.renderPreviewListener);
|
|
201
|
+
}
|
|
202
|
+
update(binding) {
|
|
203
|
+
this.options = this.buildOptions(binding);
|
|
204
|
+
}
|
|
205
|
+
remove(el) {
|
|
206
|
+
this.imgEventHandler(false);
|
|
207
|
+
el.removeEventListener("mouseenter", this.mouseEnterListener);
|
|
208
|
+
el.removeEventListener("mouseleave", this.mouseLeaveListener);
|
|
209
|
+
el.removeEventListener("click", this.renderPreviewListener);
|
|
210
|
+
el.classList.remove("maz-zoom-img-instance");
|
|
211
|
+
el.removeAttribute("data-src");
|
|
212
|
+
el.removeAttribute("data-alt");
|
|
213
|
+
el.style.cursor = "";
|
|
214
|
+
}
|
|
215
|
+
renderPreview(el, options) {
|
|
216
|
+
el.classList.add("maz-is-open");
|
|
217
|
+
this.addStyle(style);
|
|
218
|
+
const container = document.createElement("div");
|
|
219
|
+
container.classList.add("maz-zoom-img");
|
|
220
|
+
container.setAttribute("id", "MazImgPreviewFullsize");
|
|
221
|
+
container.addEventListener("click", (e) => {
|
|
222
|
+
if (container.isEqualNode(e.target)) {
|
|
223
|
+
this.closePreview();
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
if (typeof options === "object") {
|
|
227
|
+
this.img.setAttribute("src", options.src);
|
|
228
|
+
if (options.alt)
|
|
229
|
+
this.img.setAttribute("alt", options.alt);
|
|
230
|
+
this.img.id = "MazImgElement";
|
|
231
|
+
}
|
|
232
|
+
this.wrapper.append(this.img);
|
|
233
|
+
container.append(this.wrapper);
|
|
234
|
+
document.body.append(container);
|
|
235
|
+
this.keyboardEventHandler(true);
|
|
236
|
+
setTimeout(() => {
|
|
237
|
+
if (container)
|
|
238
|
+
container.classList.add("maz-animate");
|
|
239
|
+
}, 100);
|
|
240
|
+
}
|
|
241
|
+
onImgLoaded() {
|
|
242
|
+
this.wrapper.style.width = `${this.img.width}px`;
|
|
243
|
+
this.wrapper.style.minWidth = `200px`;
|
|
244
|
+
this.loader.hidden = true;
|
|
245
|
+
const closeButton = this.getButton();
|
|
246
|
+
const buttons = [];
|
|
247
|
+
const hasMultipleInstance = this.allInstances.length > 1;
|
|
248
|
+
if (!this.buttonsAdded) {
|
|
249
|
+
this.buttonsAdded = true;
|
|
250
|
+
if (hasMultipleInstance) {
|
|
251
|
+
const previousButton = this.getButton("previous");
|
|
252
|
+
const nextButton = this.getButton("next");
|
|
253
|
+
buttons.push(previousButton, nextButton);
|
|
254
|
+
}
|
|
255
|
+
this.wrapper.append(closeButton);
|
|
256
|
+
if (hasMultipleInstance) {
|
|
257
|
+
this.wrapper.prepend(buttons[0]);
|
|
258
|
+
this.wrapper.append(buttons[1]);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
getLoader() {
|
|
263
|
+
const loader = document.createElement("div");
|
|
264
|
+
loader.classList.add("maz-zoom-img__loader");
|
|
265
|
+
loader.innerHTML = svgs.spinner;
|
|
266
|
+
return loader;
|
|
267
|
+
}
|
|
268
|
+
mouseLeave(el) {
|
|
269
|
+
if (this.options.scale)
|
|
270
|
+
el.style.transform = "";
|
|
271
|
+
if (this.options.blur)
|
|
272
|
+
el.style.filter = "";
|
|
273
|
+
el.style.zIndex = "";
|
|
274
|
+
}
|
|
275
|
+
mouseEnter(el) {
|
|
276
|
+
el.style.zIndex = "1";
|
|
277
|
+
if (this.options.scale)
|
|
278
|
+
el.style.transform = "scale(1.1)";
|
|
279
|
+
if (this.options.blur)
|
|
280
|
+
el.style.filter = "blur(2px)";
|
|
281
|
+
}
|
|
282
|
+
keydownLister(e) {
|
|
283
|
+
e.preventDefault();
|
|
284
|
+
if (e.key === "Escape" || e.key === " ") {
|
|
285
|
+
this.closePreview();
|
|
286
|
+
}
|
|
287
|
+
if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
|
|
288
|
+
this.nextPreviousImage(e.key === "ArrowRight");
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
getButton(iconName = "close") {
|
|
292
|
+
const button = document.createElement("button");
|
|
293
|
+
button.innerHTML = svgs[iconName];
|
|
294
|
+
button.addEventListener("click", () => {
|
|
295
|
+
iconName === "close" ? this.closePreview() : this.allInstances ? this.nextPreviousImage(iconName === "next") : null;
|
|
296
|
+
});
|
|
297
|
+
button.classList.add("maz-zoom-btn");
|
|
298
|
+
button.classList.add(`maz-zoom-btn--${iconName}`);
|
|
299
|
+
return button;
|
|
300
|
+
}
|
|
301
|
+
closePreview() {
|
|
302
|
+
const container = document.querySelector(
|
|
303
|
+
"#MazImgPreviewFullsize"
|
|
304
|
+
);
|
|
305
|
+
const style2 = document.querySelector("#MazPreviewStyle");
|
|
306
|
+
const instance2 = document.querySelector(
|
|
307
|
+
".maz-zoom-img-instance.maz-is-open"
|
|
308
|
+
);
|
|
309
|
+
if (instance2)
|
|
310
|
+
instance2.classList.remove("maz-is-open");
|
|
311
|
+
if (container)
|
|
312
|
+
container.classList.remove("maz-animate");
|
|
313
|
+
this.keyboardEventHandler(false);
|
|
314
|
+
setTimeout(() => {
|
|
315
|
+
if (container)
|
|
316
|
+
container.remove();
|
|
317
|
+
if (style2)
|
|
318
|
+
style2.remove();
|
|
319
|
+
}, 300);
|
|
320
|
+
}
|
|
321
|
+
getNewInstanceIndex(newInstanceIndex) {
|
|
322
|
+
return newInstanceIndex < 0 ? this.allInstances.length - 1 : newInstanceIndex >= this.allInstances.length ? 0 : newInstanceIndex;
|
|
323
|
+
}
|
|
324
|
+
nextPreviousImage(isNext) {
|
|
325
|
+
const selectNextInstance = isNext;
|
|
326
|
+
const currentInstance = document.querySelector(
|
|
327
|
+
".maz-zoom-img-instance.maz-is-open"
|
|
328
|
+
);
|
|
329
|
+
if (currentInstance) {
|
|
330
|
+
const currentInstanceIndex = this.allInstances.indexOf(currentInstance);
|
|
331
|
+
const newInstanceIndex = selectNextInstance ? currentInstanceIndex + 1 : currentInstanceIndex - 1;
|
|
332
|
+
const nextInstance = this.allInstances[this.getNewInstanceIndex(newInstanceIndex)];
|
|
333
|
+
if (nextInstance) {
|
|
334
|
+
this.useNextInstance(currentInstance, nextInstance);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
useNextInstance(currentInstance, nextInstance) {
|
|
339
|
+
currentInstance.classList.remove("maz-is-open");
|
|
340
|
+
nextInstance.classList.add("maz-is-open");
|
|
341
|
+
const src = nextInstance.getAttribute("data-src");
|
|
342
|
+
const alt = nextInstance.getAttribute("data-alt");
|
|
343
|
+
this.wrapper.style.width = "";
|
|
344
|
+
this.loader.hidden = false;
|
|
345
|
+
if (src)
|
|
346
|
+
this.img.setAttribute("src", src);
|
|
347
|
+
if (alt)
|
|
348
|
+
this.img.setAttribute("alt", alt);
|
|
349
|
+
}
|
|
350
|
+
addStyle(styleString) {
|
|
351
|
+
const style2 = document.createElement("style");
|
|
352
|
+
style2.id = "MazPreviewStyle";
|
|
353
|
+
style2.textContent = styleString;
|
|
354
|
+
document.head.append(style2);
|
|
355
|
+
}
|
|
356
|
+
keyboardEventHandler(add) {
|
|
357
|
+
if (add)
|
|
358
|
+
return document.addEventListener("keydown", this.keydownHandler);
|
|
359
|
+
document.removeEventListener("keydown", this.keydownHandler);
|
|
360
|
+
}
|
|
361
|
+
imgEventHandler(add) {
|
|
362
|
+
if (add)
|
|
363
|
+
return this.img.addEventListener("load", this.onImgLoadedCallback);
|
|
364
|
+
this.img.removeEventListener("load", this.onImgLoadedCallback);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
let instance$1;
|
|
368
|
+
const vZoomImg = {
|
|
369
|
+
created(el, binding) {
|
|
370
|
+
instance$1 = new VueZoomImg(binding);
|
|
371
|
+
instance$1.create(el);
|
|
372
|
+
},
|
|
373
|
+
updated(_el, binding) {
|
|
374
|
+
instance$1.update(binding);
|
|
375
|
+
},
|
|
376
|
+
unmounted(el) {
|
|
377
|
+
instance$1.remove(el);
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
const EMPTY_PHOTO = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
|
381
|
+
const DEFAULT_OPTIONS = {
|
|
382
|
+
baseClass: "m-lazy-img",
|
|
383
|
+
loadedClass: "m-lazy-loaded",
|
|
384
|
+
loadingClass: "m-lazy-loading",
|
|
385
|
+
errorClass: "m-lazy-error",
|
|
386
|
+
noPhotoClass: "m-lazy-no-photo",
|
|
387
|
+
noPhoto: false,
|
|
388
|
+
observerOnce: true,
|
|
389
|
+
loadOnce: false,
|
|
390
|
+
noUseErrorPhoto: false,
|
|
391
|
+
observerOptions: {
|
|
392
|
+
threshold: 0.1
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
class LazyImg {
|
|
396
|
+
constructor(opts = {}) {
|
|
397
|
+
__publicField(this, "observers", []);
|
|
398
|
+
__publicField(this, "defaultOptions", DEFAULT_OPTIONS);
|
|
399
|
+
__publicField(this, "options");
|
|
400
|
+
__publicField(this, "onImgLoadedCallback");
|
|
401
|
+
__publicField(this, "onImgErrorCallback");
|
|
402
|
+
__publicField(this, "hasImgLoaded", false);
|
|
403
|
+
this.options = this.buildOptions(opts);
|
|
404
|
+
this.onImgLoadedCallback = this.imageIsLoaded.bind(this);
|
|
405
|
+
this.onImgErrorCallback = this.imageHasError.bind(this);
|
|
406
|
+
}
|
|
407
|
+
async loadErrorPhoto() {
|
|
408
|
+
const { default: photo } = await import("./no_photo-410a8f01.mjs");
|
|
409
|
+
return photo;
|
|
410
|
+
}
|
|
411
|
+
buildOptions(opts) {
|
|
412
|
+
return {
|
|
413
|
+
...this.defaultOptions,
|
|
414
|
+
...opts,
|
|
415
|
+
observerOptions: {
|
|
416
|
+
...this.defaultOptions.observerOptions,
|
|
417
|
+
...opts.observerOptions
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
removeClass(el, className) {
|
|
422
|
+
el.classList.remove(className);
|
|
423
|
+
}
|
|
424
|
+
addClass(el, className) {
|
|
425
|
+
el.classList.add(className);
|
|
426
|
+
}
|
|
427
|
+
removeAllStateClasses(el) {
|
|
428
|
+
this.removeClass(el, this.options.loadedClass);
|
|
429
|
+
this.removeClass(el, this.options.loadingClass);
|
|
430
|
+
this.removeClass(el, this.options.errorClass);
|
|
431
|
+
this.removeClass(el, this.options.noPhotoClass);
|
|
432
|
+
}
|
|
433
|
+
setBaseClass(el) {
|
|
434
|
+
this.addClass(el, this.options.baseClass);
|
|
435
|
+
}
|
|
436
|
+
imageIsLoading(el) {
|
|
437
|
+
var _a, _b;
|
|
438
|
+
this.addClass(el, this.options.loadingClass);
|
|
439
|
+
(_b = (_a = this.options).onLoading) == null ? void 0 : _b.call(_a, el);
|
|
440
|
+
}
|
|
441
|
+
imageHasNoPhoto(el) {
|
|
442
|
+
this.removeClass(el, this.options.loadingClass);
|
|
443
|
+
this.addClass(el, this.options.noPhotoClass);
|
|
444
|
+
this.setDefaultPhoto(el);
|
|
445
|
+
}
|
|
446
|
+
imageIsLoaded(el) {
|
|
447
|
+
var _a, _b;
|
|
448
|
+
this.hasImgLoaded = true;
|
|
449
|
+
this.removeClass(el, this.options.loadingClass);
|
|
450
|
+
this.addClass(el, this.options.loadedClass);
|
|
451
|
+
(_b = (_a = this.options).onLoaded) == null ? void 0 : _b.call(_a, el);
|
|
452
|
+
}
|
|
453
|
+
imageHasError(el, event) {
|
|
454
|
+
var _a, _b;
|
|
455
|
+
console.warn(`[maz-ui][MazLazyImg] Error while loading image`, event);
|
|
456
|
+
this.removeClass(el, this.options.loadingClass);
|
|
457
|
+
this.addClass(el, this.options.errorClass);
|
|
458
|
+
(_b = (_a = this.options).onError) == null ? void 0 : _b.call(_a, el);
|
|
459
|
+
this.setDefaultPhoto(el);
|
|
460
|
+
}
|
|
461
|
+
getImageUrl(el, binding) {
|
|
462
|
+
const dataSrc = this.getImgElement(el).getAttribute("data-src");
|
|
463
|
+
if (dataSrc)
|
|
464
|
+
return dataSrc;
|
|
465
|
+
const bindingSrc = typeof binding.value === "object" ? binding.value.src : binding.value;
|
|
466
|
+
if (!bindingSrc)
|
|
467
|
+
console.warn(`[maz-ui][MazLazyImg] src url is not defined`);
|
|
468
|
+
return bindingSrc;
|
|
469
|
+
}
|
|
470
|
+
async setPictureSourceUrls(el) {
|
|
471
|
+
const sourceElements = el.querySelectorAll("source");
|
|
472
|
+
if (sourceElements.length > 0) {
|
|
473
|
+
for await (const source of sourceElements) {
|
|
474
|
+
const srcSet = source.getAttribute("data-srcset");
|
|
475
|
+
if (srcSet) {
|
|
476
|
+
source.srcset = srcSet;
|
|
477
|
+
} else {
|
|
478
|
+
console.warn(
|
|
479
|
+
'[maz-ui][MazLazyImg] the "[data-srcset]" attribute is not provided on "<source />"'
|
|
480
|
+
);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
} else {
|
|
484
|
+
console.warn(
|
|
485
|
+
'[maz-ui][MazLazyImg] No "<source />" elements provided into the "<picture />" element'
|
|
486
|
+
);
|
|
487
|
+
this.imageHasError(el);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
hasBgImgMode(binding) {
|
|
491
|
+
return binding.arg === "bg-image";
|
|
492
|
+
}
|
|
493
|
+
isPictureElement(el) {
|
|
494
|
+
return el instanceof HTMLPictureElement;
|
|
495
|
+
}
|
|
496
|
+
getImgElement(el) {
|
|
497
|
+
const isPictureElement = this.isPictureElement(el);
|
|
498
|
+
return isPictureElement ? el.querySelector("img") : el;
|
|
499
|
+
}
|
|
500
|
+
async setDefaultPhoto(el) {
|
|
501
|
+
if (this.options.noUseErrorPhoto)
|
|
502
|
+
return;
|
|
503
|
+
const errorPhoto = this.options.errorPhoto ?? await this.loadErrorPhoto();
|
|
504
|
+
const sourceElements = el.querySelectorAll("source");
|
|
505
|
+
if (sourceElements.length > 0) {
|
|
506
|
+
for await (const source of sourceElements) {
|
|
507
|
+
source.srcset = errorPhoto;
|
|
508
|
+
}
|
|
509
|
+
} else {
|
|
510
|
+
this.setImgSrc(el, errorPhoto);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
addEventListenerToImg(el) {
|
|
514
|
+
const imgElement = this.getImgElement(el);
|
|
515
|
+
imgElement.addEventListener("load", () => this.onImgLoadedCallback(el), {
|
|
516
|
+
once: true
|
|
517
|
+
});
|
|
518
|
+
imgElement.addEventListener(
|
|
519
|
+
"error",
|
|
520
|
+
(err) => this.onImgErrorCallback(el, err),
|
|
521
|
+
{ once: true }
|
|
522
|
+
);
|
|
523
|
+
}
|
|
524
|
+
async loadImage(el, binding) {
|
|
525
|
+
this.imageIsLoading(el);
|
|
526
|
+
if (this.isPictureElement(el)) {
|
|
527
|
+
this.addEventListenerToImg(el);
|
|
528
|
+
await this.setPictureSourceUrls(el);
|
|
529
|
+
} else {
|
|
530
|
+
const imageUrl = this.getImageUrl(el, binding);
|
|
531
|
+
if (!imageUrl)
|
|
532
|
+
return this.imageHasError(el);
|
|
533
|
+
if (this.hasBgImgMode(binding)) {
|
|
534
|
+
el.style.backgroundImage = `url('${imageUrl}')`;
|
|
535
|
+
this.imageIsLoaded(el);
|
|
536
|
+
} else {
|
|
537
|
+
this.addEventListenerToImg(el);
|
|
538
|
+
this.setImgSrc(el, imageUrl);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
setImgSrc(el, src) {
|
|
543
|
+
const imgElement = this.getImgElement(el);
|
|
544
|
+
imgElement.src = src;
|
|
545
|
+
}
|
|
546
|
+
handleIntersectionObserver(el, binding, entries, observer) {
|
|
547
|
+
var _a, _b;
|
|
548
|
+
this.observers.push(observer);
|
|
549
|
+
for (const entry of entries) {
|
|
550
|
+
if (entry.isIntersecting) {
|
|
551
|
+
(_b = (_a = this.options).onIntersecting) == null ? void 0 : _b.call(_a, entry.target);
|
|
552
|
+
if (this.options.observerOnce) {
|
|
553
|
+
observer.unobserve(el);
|
|
554
|
+
}
|
|
555
|
+
if (this.options.loadOnce && this.hasImgLoaded)
|
|
556
|
+
return;
|
|
557
|
+
this.loadImage(el, binding);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
createObserver(el, binding) {
|
|
562
|
+
const observerCallback = (entries, intersectionObserver) => {
|
|
563
|
+
this.handleIntersectionObserver(
|
|
564
|
+
el,
|
|
565
|
+
binding,
|
|
566
|
+
entries,
|
|
567
|
+
intersectionObserver
|
|
568
|
+
);
|
|
569
|
+
};
|
|
570
|
+
const observerOptions = this.options.observerOptions;
|
|
571
|
+
const observer = new IntersectionObserver(observerCallback, observerOptions);
|
|
572
|
+
observer.observe(el);
|
|
573
|
+
}
|
|
574
|
+
async imageHandler(el, binding, type) {
|
|
575
|
+
if (type === "update") {
|
|
576
|
+
for await (const observer of this.observers)
|
|
577
|
+
observer.unobserve(el);
|
|
578
|
+
}
|
|
579
|
+
if (window.IntersectionObserver) {
|
|
580
|
+
this.createObserver(el, binding);
|
|
581
|
+
} else {
|
|
582
|
+
this.loadImage(el, binding);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
async bindUpdateHandler(el, binding, type) {
|
|
586
|
+
if (this.options.noPhoto)
|
|
587
|
+
return this.imageHasNoPhoto(el);
|
|
588
|
+
await this.imageHandler(el, binding, type);
|
|
589
|
+
}
|
|
590
|
+
async add(el, binding) {
|
|
591
|
+
if (this.hasBgImgMode(binding) && this.isPictureElement(el)) {
|
|
592
|
+
throw new Error(
|
|
593
|
+
`[MazLazyImg] You can't use the "bg-image" mode with "<picture />" element`
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
setTimeout(() => this.setBaseClass(el), 0);
|
|
597
|
+
if (!el.getAttribute("src"))
|
|
598
|
+
this.setImgSrc(el, EMPTY_PHOTO);
|
|
599
|
+
await this.bindUpdateHandler(el, binding, "bind");
|
|
600
|
+
}
|
|
601
|
+
async update(el, binding) {
|
|
602
|
+
if (binding.value !== binding.oldValue) {
|
|
603
|
+
this.hasImgLoaded = false;
|
|
604
|
+
this.removeAllStateClasses(el);
|
|
605
|
+
await this.bindUpdateHandler(el, binding, "update");
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
remove(el, binding) {
|
|
609
|
+
this.hasImgLoaded = false;
|
|
610
|
+
if (this.hasBgImgMode(binding))
|
|
611
|
+
el.style.backgroundImage = "";
|
|
612
|
+
this.removeAllStateClasses(el);
|
|
613
|
+
for (const observer of this.observers)
|
|
614
|
+
observer.unobserve(el);
|
|
615
|
+
this.observers = [];
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
let instance;
|
|
619
|
+
const vLazyImg = {
|
|
620
|
+
created(el, binding) {
|
|
621
|
+
const options = typeof binding.value === "object" ? binding.value : {};
|
|
622
|
+
instance = new LazyImg(options);
|
|
623
|
+
instance.add(el, binding);
|
|
624
|
+
},
|
|
625
|
+
updated(el, binding) {
|
|
626
|
+
instance.update(el, binding);
|
|
627
|
+
},
|
|
628
|
+
unmounted(el, binding) {
|
|
629
|
+
instance.remove(el, binding);
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
function injectStrict(key, fallback) {
|
|
633
|
+
const resolved = inject(key, fallback);
|
|
634
|
+
if (!resolved) {
|
|
635
|
+
throw new Error(`[maz-ui](injectStrict) Could not resolve ${key}`);
|
|
636
|
+
}
|
|
637
|
+
return resolved;
|
|
638
|
+
}
|
|
639
|
+
const _hoisted_1$1 = ["innerHTML"];
|
|
640
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
641
|
+
__name: "MazIcon",
|
|
642
|
+
props: {
|
|
643
|
+
src: { type: String, default: void 0 },
|
|
644
|
+
path: { type: String, default: void 0 },
|
|
645
|
+
name: { type: String, default: void 0 },
|
|
646
|
+
size: { type: String, default: "1.5rem" },
|
|
647
|
+
title: { type: String, default: void 0 },
|
|
648
|
+
transformSource: {
|
|
649
|
+
type: Function,
|
|
650
|
+
default: (svg) => svg
|
|
651
|
+
}
|
|
652
|
+
},
|
|
653
|
+
emits: ["loaded", "unloaded", "error"],
|
|
654
|
+
setup(__props, { emit: emits }) {
|
|
655
|
+
const props = __props;
|
|
656
|
+
const cache = {};
|
|
657
|
+
const svgElSource = ref();
|
|
658
|
+
const svgElem = ref();
|
|
659
|
+
const getMazIconPath = () => {
|
|
660
|
+
try {
|
|
661
|
+
return injectStrict("mazIconPath");
|
|
662
|
+
} catch {
|
|
663
|
+
return void 0;
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
const iconPath = computed(() => props.path ?? getMazIconPath());
|
|
667
|
+
const fullSrc = computed(() => {
|
|
668
|
+
if (props.src) {
|
|
669
|
+
return props.src;
|
|
670
|
+
} else if (iconPath.value) {
|
|
671
|
+
return `${iconPath.value}/${props.name}.svg`;
|
|
672
|
+
} else {
|
|
673
|
+
return `/${props.name}.svg`;
|
|
674
|
+
}
|
|
675
|
+
});
|
|
676
|
+
onMounted(() => {
|
|
677
|
+
if (!props.name && !props.src) {
|
|
678
|
+
console.error(
|
|
679
|
+
'[maz-ui](MazIcon) you should provide "name" or "src" as prop'
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
});
|
|
683
|
+
const setTitle = (svg, title) => {
|
|
684
|
+
const titleTags = svg.querySelectorAll("title");
|
|
685
|
+
if (titleTags.length > 0) {
|
|
686
|
+
titleTags[0].textContent = title;
|
|
687
|
+
} else {
|
|
688
|
+
const titleEl = document.createElementNS(
|
|
689
|
+
"http://www.w3.org/2000/svg",
|
|
690
|
+
"title"
|
|
691
|
+
);
|
|
692
|
+
titleEl.textContent = title;
|
|
693
|
+
svg.append(titleEl);
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
const filterAttrs = (attrs) => {
|
|
697
|
+
return Object.keys(attrs).reduce((result, key) => {
|
|
698
|
+
if (attrs[key] !== false && attrs[key] !== null && attrs[key] !== void 0) {
|
|
699
|
+
result[key] = attrs[key];
|
|
700
|
+
}
|
|
701
|
+
return result;
|
|
702
|
+
}, {});
|
|
703
|
+
};
|
|
704
|
+
const getSvgAttrs = (svgEl) => {
|
|
705
|
+
const svgAttrs = {};
|
|
706
|
+
const attrs = svgEl.attributes;
|
|
707
|
+
if (!attrs) {
|
|
708
|
+
return svgAttrs;
|
|
709
|
+
}
|
|
710
|
+
for (let i = attrs.length - 1; i >= 0; i--) {
|
|
711
|
+
svgAttrs[attrs[i].name] = attrs[i].value;
|
|
712
|
+
}
|
|
713
|
+
return svgAttrs;
|
|
714
|
+
};
|
|
715
|
+
const getSvgContent = (svgEl) => {
|
|
716
|
+
let svgElNode = svgEl.cloneNode(true);
|
|
717
|
+
svgElNode = props.transformSource(svgEl);
|
|
718
|
+
if (props.title) {
|
|
719
|
+
setTitle(svgElNode, props.title);
|
|
720
|
+
}
|
|
721
|
+
return svgEl.innerHTML;
|
|
722
|
+
};
|
|
723
|
+
const getSource = async (src) => {
|
|
724
|
+
if (!cache[src]) {
|
|
725
|
+
cache[src] = download(src);
|
|
726
|
+
}
|
|
727
|
+
try {
|
|
728
|
+
svgElSource.value = await cache[src];
|
|
729
|
+
await nextTick();
|
|
730
|
+
emits("loaded", svgElem.value);
|
|
731
|
+
} catch (error) {
|
|
732
|
+
if (svgElSource.value) {
|
|
733
|
+
svgElSource.value = void 0;
|
|
734
|
+
emits("unloaded");
|
|
735
|
+
}
|
|
736
|
+
delete cache[src];
|
|
737
|
+
emits("error", error);
|
|
738
|
+
}
|
|
739
|
+
};
|
|
740
|
+
const download = (url) => {
|
|
741
|
+
return new Promise((resolve, reject) => {
|
|
742
|
+
const request = new XMLHttpRequest();
|
|
743
|
+
request.open("GET", url, true);
|
|
744
|
+
request.addEventListener("load", () => {
|
|
745
|
+
if (request.status >= 200 && request.status < 400) {
|
|
746
|
+
try {
|
|
747
|
+
const parser = new DOMParser();
|
|
748
|
+
const result = parser.parseFromString(
|
|
749
|
+
request.responseText,
|
|
750
|
+
"text/xml"
|
|
751
|
+
);
|
|
752
|
+
let svgEl = result.querySelectorAll("svg")[0];
|
|
753
|
+
if (svgEl) {
|
|
754
|
+
svgEl = props.transformSource(svgEl);
|
|
755
|
+
resolve(svgEl);
|
|
756
|
+
} else {
|
|
757
|
+
reject(new Error('Loaded file is not valid SVG"'));
|
|
758
|
+
}
|
|
759
|
+
} catch (error) {
|
|
760
|
+
reject(error);
|
|
761
|
+
}
|
|
762
|
+
} else {
|
|
763
|
+
reject(new Error("Error loading SVG"));
|
|
764
|
+
}
|
|
765
|
+
});
|
|
766
|
+
request.addEventListener("error", () => reject());
|
|
767
|
+
request.send();
|
|
768
|
+
});
|
|
769
|
+
};
|
|
770
|
+
watchEffect(() => getSource(fullSrc.value));
|
|
771
|
+
return (_ctx, _cache) => {
|
|
772
|
+
return svgElSource.value ? (openBlock(), createElementBlock("svg", mergeProps({
|
|
773
|
+
key: 0,
|
|
774
|
+
ref_key: "svgElem",
|
|
775
|
+
ref: svgElem,
|
|
776
|
+
width: "1em",
|
|
777
|
+
height: "1em"
|
|
778
|
+
}, {
|
|
779
|
+
...getSvgAttrs(svgElSource.value),
|
|
780
|
+
...filterAttrs(_ctx.$attrs)
|
|
781
|
+
}, {
|
|
782
|
+
style: `font-size: ${__props.size}`,
|
|
783
|
+
innerHTML: getSvgContent(svgElSource.value)
|
|
784
|
+
}), null, 16, _hoisted_1$1)) : createCommentVNode("", true);
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
});
|
|
788
|
+
const NoPhotographyIcon = "data:image/svg+xml;base64,PHN2ZwogIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCAyNCAyNCIKICB2aWV3Qm94PSIwIDAgMjQgMjQiCiAgZmlsbD0iY3VycmVudENvbG9yIgo+CiAgPGc+CiAgICA8cmVjdCBmaWxsPSJub25lIiBoZWlnaHQ9IjI0IiB3aWR0aD0iMjQiIC8+CiAgICA8Zz4KICAgICAgPHBhdGgKICAgICAgICBkPSJNOC45LDYuMDdMNy40OCw0LjY2TDksM2g2bDEuODMsMkgyMGMxLjEsMCwyLDAuOSwyLDJ2MTJjMCwwLjA1LTAuMDEsMC4xLTAuMDIsMC4xNkwyMCwxNy4xN1Y3aC00LjA1bC0xLjgzLTJIOS44OCBMOC45LDYuMDd6IE0yMC40OSwyMy4zMUwxOC4xNywyMUg0Yy0xLjEsMC0yLTAuOS0yLTJWN2MwLTAuNTksMC4yNy0xLjEyLDAuNjgtMS40OWwtMi0yTDIuMSwyLjFsMTkuOCwxOS44TDIwLjQ5LDIzLjMxeiBNOS4xOSwxMi4wMkM5LjA4LDEyLjMzLDksMTIuNjUsOSwxM2MwLDEuNjYsMS4zNCwzLDMsM2MwLjM1LDAsMC42Ny0wLjA4LDAuOTgtMC4xOUw5LjE5LDEyLjAyeiBNMTYuMTcsMTlsLTEuNjgtMS42OCBDMTMuNzYsMTcuNzUsMTIuOTEsMTgsMTIsMThjLTIuNzYsMC01LTIuMjQtNS01YzAtMC45MSwwLjI1LTEuNzYsMC42OC0yLjQ5TDQuMTcsN0g0djEySDE2LjE3eiBNMTQuODEsMTEuOThsMi4wNywyLjA3IEMxNi45NiwxMy43MSwxNywxMy4zNiwxNywxM2MwLTIuNzYtMi4yNC01LTUtNWMtMC4zNiwwLTAuNzEsMC4wNC0xLjA2LDAuMTJsMi4wNywyLjA3QzEzLjg1LDEwLjQ5LDE0LjUxLDExLjE1LDE0LjgxLDExLjk4eiIKICAgICAgLz4KICAgIDwvZz4KICA8L2c+Cjwvc3ZnPgo=";
|
|
789
|
+
const _sfc_main = defineComponent({
|
|
790
|
+
components: { MazIcon: _sfc_main$1 },
|
|
791
|
+
directives: {
|
|
792
|
+
"zoom-img": vZoomImg,
|
|
793
|
+
"lazy-img": vLazyImg
|
|
794
|
+
},
|
|
795
|
+
props: {
|
|
796
|
+
images: {
|
|
797
|
+
type: Array,
|
|
798
|
+
default: () => []
|
|
799
|
+
},
|
|
800
|
+
imagesShownCount: { type: Number, default: 5 },
|
|
801
|
+
noRemaining: { type: Boolean, default: false },
|
|
802
|
+
height: { type: [Number, String], default: 150 },
|
|
803
|
+
noHeight: { type: Boolean, default: false },
|
|
804
|
+
width: { type: [Number, String], default: "100%" },
|
|
805
|
+
noWidth: { type: Boolean, default: false },
|
|
806
|
+
noRadius: { type: Boolean, default: false },
|
|
807
|
+
noZoom: { type: Boolean, default: false },
|
|
808
|
+
hasEmptyLayer: { type: Boolean, default: true },
|
|
809
|
+
lazy: { type: Boolean, default: true },
|
|
810
|
+
blur: { type: Boolean, default: true },
|
|
811
|
+
scale: { type: Boolean, default: true }
|
|
812
|
+
},
|
|
813
|
+
setup(props) {
|
|
814
|
+
onBeforeMount(() => {
|
|
815
|
+
if (props.imagesShownCount > 5)
|
|
816
|
+
console.warn(
|
|
817
|
+
'[MazUI](m-gallery) The maximum of "images-shown-count" is 5'
|
|
818
|
+
);
|
|
819
|
+
});
|
|
820
|
+
const sizeStyle = computed(() => {
|
|
821
|
+
const { height, width, noWidth, noHeight } = props;
|
|
822
|
+
return {
|
|
823
|
+
...noWidth ? {} : {
|
|
824
|
+
flex: "0 0 " + typeof width === "number" ? `${width}px` : width,
|
|
825
|
+
width: typeof width === "number" ? `${width}px` : width
|
|
826
|
+
},
|
|
827
|
+
...noHeight ? {} : {
|
|
828
|
+
height: typeof height === "number" ? `${height}px` : `${height}`,
|
|
829
|
+
minHeight: typeof height === "number" ? `${height}px` : `${height}`
|
|
830
|
+
}
|
|
831
|
+
};
|
|
832
|
+
});
|
|
833
|
+
const imagesCount = computed(() => {
|
|
834
|
+
return props.imagesShownCount <= 5 ? props.imagesShownCount : 5;
|
|
835
|
+
});
|
|
836
|
+
const numberImagesRemaining = computed(() => {
|
|
837
|
+
return props.images.length - (props.images.length < imagesCount.value ? props.images.length : imagesCount.value);
|
|
838
|
+
});
|
|
839
|
+
const imagesNormalized = computed(() => {
|
|
840
|
+
return props.images.map(
|
|
841
|
+
(image) => typeof image === "object" ? image : { src: image, alt: void 0 }
|
|
842
|
+
);
|
|
843
|
+
});
|
|
844
|
+
const imagesShown = computed(() => {
|
|
845
|
+
return imagesNormalized.value.slice(0, imagesCount.value);
|
|
846
|
+
});
|
|
847
|
+
const imagesHidden = computed(() => {
|
|
848
|
+
return imagesNormalized.value.slice(
|
|
849
|
+
imagesCount.value,
|
|
850
|
+
props.images.length
|
|
851
|
+
);
|
|
852
|
+
});
|
|
853
|
+
const shouldHaveRemainingLayer = (index) => {
|
|
854
|
+
return numberImagesRemaining.value && index + 1 === imagesShown.value.length && !props.noRemaining;
|
|
855
|
+
};
|
|
856
|
+
return {
|
|
857
|
+
sizeStyle,
|
|
858
|
+
imagesCount,
|
|
859
|
+
shouldHaveRemainingLayer,
|
|
860
|
+
imagesShown,
|
|
861
|
+
numberImagesRemaining,
|
|
862
|
+
imagesHidden,
|
|
863
|
+
NoPhotographyIcon
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
});
|
|
867
|
+
const MazGallery_vue_vue_type_style_index_0_scoped_680a27a0_lang = "";
|
|
868
|
+
const _export_sfc = (sfc, props) => {
|
|
869
|
+
const target = sfc.__vccOpts || sfc;
|
|
870
|
+
for (const [key, val] of props) {
|
|
871
|
+
target[key] = val;
|
|
872
|
+
}
|
|
873
|
+
return target;
|
|
874
|
+
};
|
|
875
|
+
const _hoisted_1 = { class: "m-gallery__wrapper maz-flex maz-flex-1" };
|
|
876
|
+
const _hoisted_2 = ["alt"];
|
|
877
|
+
const _hoisted_3 = {
|
|
878
|
+
key: 0,
|
|
879
|
+
class: "m-gallery__remaining-layer maz-flex maz-bg-overlay maz-flex-center"
|
|
880
|
+
};
|
|
881
|
+
const _hoisted_4 = { class: "maz-text-2xl maz-text-white" };
|
|
882
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
883
|
+
const _component_MazIcon = resolveComponent("MazIcon");
|
|
884
|
+
const _directive_zoom_img = resolveDirective("zoom-img");
|
|
885
|
+
const _directive_lazy_img = resolveDirective("lazy-img");
|
|
886
|
+
return _ctx.images.length > 0 || _ctx.hasEmptyLayer ? (openBlock(), createElementBlock("div", {
|
|
887
|
+
key: 0,
|
|
888
|
+
class: normalizeClass(["m-gallery maz-flex", { "maz-rounded-xl": !_ctx.noRadius }]),
|
|
889
|
+
style: normalizeStyle([_ctx.sizeStyle])
|
|
890
|
+
}, [
|
|
891
|
+
createElementVNode("section", _hoisted_1, [
|
|
892
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.imagesShown, (image, i) => {
|
|
893
|
+
return openBlock(), createElementBlock("figure", {
|
|
894
|
+
key: i,
|
|
895
|
+
class: normalizeClass(["m-gallery__item !maz-my-0 maz-flex maz-flex-center", [`m-gallery__item--${i + 1}`]])
|
|
896
|
+
}, [
|
|
897
|
+
withDirectives(createElementVNode("img", {
|
|
898
|
+
class: "m-gallery__item__image maz-flex-1",
|
|
899
|
+
src: "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
|
|
900
|
+
alt: image.alt
|
|
901
|
+
}, null, 8, _hoisted_2), [
|
|
902
|
+
[_directive_zoom_img, {
|
|
903
|
+
src: image.src,
|
|
904
|
+
alt: image.alt,
|
|
905
|
+
disabled: _ctx.noZoom || _ctx.shouldHaveRemainingLayer(i),
|
|
906
|
+
blur: _ctx.blur,
|
|
907
|
+
scale: _ctx.scale
|
|
908
|
+
}],
|
|
909
|
+
[_directive_lazy_img, { src: image.src, disabled: !_ctx.lazy }, "bg-image"]
|
|
910
|
+
]),
|
|
911
|
+
_ctx.shouldHaveRemainingLayer(i) ? withDirectives((openBlock(), createElementBlock("div", _hoisted_3, [
|
|
912
|
+
createElementVNode("span", _hoisted_4, "+" + toDisplayString(_ctx.numberImagesRemaining), 1)
|
|
913
|
+
])), [
|
|
914
|
+
[_directive_zoom_img, {
|
|
915
|
+
src: image.src,
|
|
916
|
+
alt: image.alt,
|
|
917
|
+
disabled: _ctx.noZoom,
|
|
918
|
+
blur: false,
|
|
919
|
+
scale: _ctx.scale
|
|
920
|
+
}]
|
|
921
|
+
]) : createCommentVNode("", true)
|
|
922
|
+
], 2);
|
|
923
|
+
}), 128)),
|
|
924
|
+
_ctx.hasEmptyLayer && _ctx.images.length === 0 ? (openBlock(), createElementBlock("div", {
|
|
925
|
+
key: 0,
|
|
926
|
+
class: normalizeClass(["flex-center maz-flex maz-w-full maz-bg-color-light maz-text-normal", { "maz-rounded-xl": !_ctx.noRadius }]),
|
|
927
|
+
style: normalizeStyle([_ctx.sizeStyle])
|
|
928
|
+
}, [
|
|
929
|
+
createVNode(_component_MazIcon, {
|
|
930
|
+
src: _ctx.NoPhotographyIcon,
|
|
931
|
+
size: "2rem"
|
|
932
|
+
}, null, 8, ["src"])
|
|
933
|
+
], 6)) : createCommentVNode("", true)
|
|
934
|
+
]),
|
|
935
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.imagesHidden, (image, i) => {
|
|
936
|
+
return withDirectives((openBlock(), createElementBlock("div", {
|
|
937
|
+
key: i,
|
|
938
|
+
class: "m-gallery__hidden"
|
|
939
|
+
})), [
|
|
940
|
+
[_directive_zoom_img, { src: image.src, disabled: _ctx.noZoom }]
|
|
941
|
+
]);
|
|
942
|
+
}), 128))
|
|
943
|
+
], 6)) : createCommentVNode("", true);
|
|
944
|
+
}
|
|
945
|
+
const MazGallery = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-680a27a0"]]);
|
|
946
|
+
export {
|
|
947
|
+
MazGallery as default
|
|
948
|
+
};
|