maz-ui 3.47.2-beta.20 → 3.47.2-beta.21
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/MazChecklist.mjs +1 -1
- package/components/MazInput.d.ts +2 -0
- package/components/MazInput.mjs +1 -1
- package/components/MazInputNumber.mjs +1 -1
- package/components/MazInputPrice.mjs +1 -1
- package/components/MazInputTags.mjs +1 -1
- package/components/MazPhoneNumberInput/PhoneInput.vue.d.ts +9 -20
- package/components/MazPhoneNumberInput/types.d.ts +2 -1
- package/components/MazPhoneNumberInput/useLibphonenumber.d.ts +8 -3
- package/components/MazPhoneNumberInput.mjs +1 -1
- package/components/MazPicker.mjs +1 -1
- package/components/MazSelect.mjs +1 -1
- package/components/MazTable.mjs +1 -1
- package/components/assets/MazInput.css +1 -1
- package/components/assets/MazInputNumber.css +1 -1
- package/components/assets/MazInputPrice.css +1 -1
- package/components/assets/MazInputTags.css +1 -1
- package/components/assets/MazPhoneNumberInput.css +1 -1
- package/components/assets/MazPicker.css +1 -1
- package/components/chunks/{MazBtn-Db6ai-Mv.mjs → MazBtn-4-B-zs6Y.mjs} +2 -2
- package/components/chunks/{MazBtn-B5ioqwkK.mjs → MazBtn-C6zsmGnw.mjs} +2 -2
- package/components/chunks/MazBtn-C7yEnuOD.mjs +103 -0
- package/components/chunks/{MazBtn-CElHmZjv.mjs → MazBtn-DAXwt847.mjs} +2 -2
- package/components/chunks/{MazBtn-BrfhtojY.mjs → MazBtn-DOWVQgpN.mjs} +2 -2
- package/components/chunks/{MazBtn-C4nwxs9T.mjs → MazBtn-DZaVjTvW.mjs} +2 -2
- package/components/chunks/{MazCheckbox-B5ZcWc3y.mjs → MazCheckbox-BNvSeNBP.mjs} +1 -1
- package/components/chunks/{MazCheckbox-BDPgDiU3.mjs → MazCheckbox-CCma_qyQ.mjs} +1 -1
- package/components/chunks/{MazCheckbox-BeLByOEa.mjs → MazCheckbox-eOEEACaM.mjs} +1 -1
- package/components/chunks/{MazChecklist-BurPprmw.mjs → MazChecklist-Bb_70sf5.mjs} +1 -1
- package/components/chunks/{MazIcon-CaXpmvN2.mjs → MazIcon-kLACGOa2.mjs} +1 -1
- package/components/chunks/{MazInput-BT-mbJfZ.mjs → MazInput-BM4n-byz.mjs} +18 -18
- package/components/chunks/{MazInput-BTIdtLkD.mjs → MazInput-BcutbP8N.mjs} +11 -11
- package/components/chunks/{MazInput-BfWJoPre.mjs → MazInput-C9Qh4Gt3.mjs} +10 -10
- package/components/chunks/{MazInputNumber-R0RzDeyD.mjs → MazInputNumber-DgjOMiOt.mjs} +40 -40
- package/components/chunks/{MazInputPrice-CKSdqO4X.mjs → MazInputPrice-D6fJN9yv.mjs} +41 -41
- package/components/chunks/{MazInputTags-D6jQ2-Ia.mjs → MazInputTags-DthGSyHQ.mjs} +51 -51
- package/components/chunks/{MazLoadingBar-D3pDBJSb.mjs → MazLoadingBar-C2qPjfEQ.mjs} +1 -1
- package/components/chunks/MazPhoneNumberInput-BQjByOtQ.mjs +1813 -0
- package/components/chunks/{MazPicker-CwiuW5Pv.mjs → MazPicker-BljfUneI.mjs} +11 -11
- package/components/chunks/{MazPickerMonthSwitcher-C65el7R0.mjs → MazPickerMonthSwitcher-CEVb4BXw.mjs} +1 -1
- package/components/chunks/{MazPickerShortcuts-DbrOoszH.mjs → MazPickerShortcuts-DayGMC9m.mjs} +1 -1
- package/components/chunks/{MazPickerYearSwitcher-D9lqntyR.mjs → MazPickerYearSwitcher-DC1lFIbp.mjs} +1 -1
- package/components/chunks/{MazSelect-CyWAOXo4.mjs → MazSelect-CH3JdigO.mjs} +54 -54
- package/components/chunks/{MazSelect-CbT4tFqV.mjs → MazSelect-D3KXcHJS.mjs} +3 -3
- package/components/chunks/MazSpinner-B5JChIrj.mjs +34 -0
- package/components/chunks/{MazSpinner-N-1gjTUE.mjs → MazSpinner-BBZoDxwq.mjs} +1 -1
- package/components/chunks/{MazSpinner-DYE8e9xl.mjs → MazSpinner-BIPm54-3.mjs} +1 -1
- package/components/chunks/{MazSpinner-CS1_l-tv.mjs → MazSpinner-C-ln9ldX.mjs} +1 -1
- package/components/chunks/{MazSpinner-BDda3YzZ.mjs → MazSpinner-C11EOZZd.mjs} +1 -1
- package/components/chunks/{MazSpinner-CwmaAuL1.mjs → MazSpinner-CCc9ajpj.mjs} +1 -1
- package/components/chunks/{MazSpinner-C2-JMhVh.mjs → MazSpinner-CgKOIkQQ.mjs} +1 -1
- package/components/chunks/{MazSpinner-mtv0dluJ.mjs → MazSpinner-CwdlrYSt.mjs} +1 -1
- package/components/chunks/MazSpinner-DoPIk0St.mjs +34 -0
- package/components/chunks/{MazTable-hA0HicaL.mjs → MazTable-BU3Hluiu.mjs} +1 -1
- package/components/chunks/{MazTableCell-DkCidYWY.mjs → MazTableCell-DKMZAanm.mjs} +1 -1
- package/components/chunks/{MazTableRow-BAl6Fzm8.mjs → MazTableRow-CDHpmXfw.mjs} +1 -1
- package/components/chunks/{MazTableTitle-CY_LNDOk.mjs → MazTableTitle-BSFZ84Ob.mjs} +1 -1
- package/components/chunks/examples.mobile.json-tW3aL0qI.mjs +4 -0
- package/nuxt/index.json +1 -1
- package/package.json +2 -2
- package/types/components/MazInput.vue.d.ts +2 -0
- package/types/components/MazPhoneNumberInput/PhoneInput.vue.d.ts +9 -20
- package/types/components/MazPhoneNumberInput/types.d.ts +2 -1
- package/types/components/MazPhoneNumberInput/useLibphonenumber.d.ts +8 -3
- package/components/MazPhoneNumberInput.d.ts +0 -283
- package/components/chunks/MazBtn-D4NOcykx.mjs +0 -103
- package/components/chunks/MazPhoneNumberInput-DibUhBpk.mjs +0 -1809
- package/components/chunks/MazSpinner-DudoF-cG.mjs +0 -34
- package/components/chunks/MazSpinner-EAz0nFxC.mjs +0 -34
- package/components/chunks/examples.mobile.json-JpNGylGv.mjs +0 -4
- package/types/components/MazPhoneNumberInput.vue.d.ts +0 -283
|
@@ -0,0 +1,1813 @@
|
|
|
1
|
+
import '../assets/MazPhoneNumberInput.css';var Ze = Object.defineProperty;
|
|
2
|
+
var Xe = (a, e, t) => e in a ? Ze(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
|
|
3
|
+
var X = (a, e, t) => Xe(a, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { computed as y, useId as xe, inject as _e, defineComponent as se, defineAsyncComponent as R, withDirectives as Ie, openBlock as b, createElementBlock as S, normalizeClass as O, normalizeStyle as x, Fragment as Ce, renderList as Oe, createElementVNode as q, mergeProps as ee, createVNode as U, unref as I, createCommentVNode as V, renderSlot as F, ref as k, onMounted as Ae, useSlots as eo, toDisplayString as _, createBlock as K, resolveDynamicComponent as Be, toHandlers as oo, vModelDynamic as to, createTextVNode as lo, withModifiers as ae, withCtx as W, onBeforeMount as Te, nextTick as de, Transition as ao, mergeModels as so, useModel as no, watch as ye, provide as ro } from "vue";
|
|
5
|
+
import { getCountries as Me, getCountryCallingCode as ce, isSupportedCountry as io, parsePhoneNumberFromString as uo, getExampleNumber as co, AsYouType as mo } from "libphonenumber-js";
|
|
6
|
+
function we({
|
|
7
|
+
componentName: a,
|
|
8
|
+
providedId: e
|
|
9
|
+
}) {
|
|
10
|
+
return y(() => e ?? `${a}-${xe().replace(/:/g, "")}`);
|
|
11
|
+
}
|
|
12
|
+
function Le(a, e = "20x15") {
|
|
13
|
+
return `https://flagcdn.com/${e}/${a.toLowerCase()}.png`;
|
|
14
|
+
}
|
|
15
|
+
function Fe(a, e) {
|
|
16
|
+
const t = _e(a, e);
|
|
17
|
+
if (!t)
|
|
18
|
+
throw new TypeError(`[maz-ui](injectStrict) Could not resolve ${a.toString()}`);
|
|
19
|
+
return t;
|
|
20
|
+
}
|
|
21
|
+
function po(a) {
|
|
22
|
+
return !!a;
|
|
23
|
+
}
|
|
24
|
+
const fo = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", ho = {
|
|
25
|
+
baseClass: "m-lazy-img",
|
|
26
|
+
loadedClass: "m-lazy-loaded",
|
|
27
|
+
loadingClass: "m-lazy-loading",
|
|
28
|
+
errorClass: "m-lazy-error",
|
|
29
|
+
noPhotoClass: "m-lazy-no-photo",
|
|
30
|
+
noPhoto: !1,
|
|
31
|
+
observerOnce: !0,
|
|
32
|
+
loadOnce: !1,
|
|
33
|
+
noUseErrorPhoto: !1,
|
|
34
|
+
observerOptions: {
|
|
35
|
+
threshold: 0.1
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
class yo {
|
|
39
|
+
constructor(e = {}) {
|
|
40
|
+
X(this, "observers", []);
|
|
41
|
+
X(this, "defaultOptions", ho);
|
|
42
|
+
X(this, "options");
|
|
43
|
+
X(this, "onImgLoadedCallback");
|
|
44
|
+
X(this, "onImgErrorCallback");
|
|
45
|
+
X(this, "hasImgLoaded", !1);
|
|
46
|
+
this.options = this.buildOptions(e), this.onImgLoadedCallback = this.imageIsLoaded.bind(this), this.onImgErrorCallback = this.imageHasError.bind(this);
|
|
47
|
+
}
|
|
48
|
+
async loadErrorPhoto() {
|
|
49
|
+
const { default: e } = await import("./no-photography-BJX8HSus.mjs");
|
|
50
|
+
return e;
|
|
51
|
+
}
|
|
52
|
+
buildOptions(e) {
|
|
53
|
+
return {
|
|
54
|
+
...this.defaultOptions,
|
|
55
|
+
...e,
|
|
56
|
+
observerOptions: {
|
|
57
|
+
...this.defaultOptions.observerOptions,
|
|
58
|
+
...e.observerOptions
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
removeClass(e, t) {
|
|
63
|
+
e.classList.remove(t);
|
|
64
|
+
}
|
|
65
|
+
addClass(e, t) {
|
|
66
|
+
e.classList.add(t);
|
|
67
|
+
}
|
|
68
|
+
removeAllStateClasses(e) {
|
|
69
|
+
this.removeClass(e, this.options.loadedClass), this.removeClass(e, this.options.loadingClass), this.removeClass(e, this.options.errorClass), this.removeClass(e, this.options.noPhotoClass);
|
|
70
|
+
}
|
|
71
|
+
setBaseClass(e) {
|
|
72
|
+
this.addClass(e, this.options.baseClass);
|
|
73
|
+
}
|
|
74
|
+
imageIsLoading(e) {
|
|
75
|
+
var t, o;
|
|
76
|
+
this.addClass(e, this.options.loadingClass), (o = (t = this.options).onLoading) == null || o.call(t, e);
|
|
77
|
+
}
|
|
78
|
+
imageHasNoPhoto(e) {
|
|
79
|
+
this.removeClass(e, this.options.loadingClass), this.addClass(e, this.options.noPhotoClass), this.setDefaultPhoto(e);
|
|
80
|
+
}
|
|
81
|
+
imageIsLoaded(e) {
|
|
82
|
+
var t, o;
|
|
83
|
+
this.hasImgLoaded = !0, this.removeClass(e, this.options.loadingClass), this.addClass(e, this.options.loadedClass), (o = (t = this.options).onLoaded) == null || o.call(t, e);
|
|
84
|
+
}
|
|
85
|
+
imageHasError(e) {
|
|
86
|
+
var t, o;
|
|
87
|
+
this.removeClass(e, this.options.loadingClass), this.addClass(e, this.options.errorClass), (o = (t = this.options).onError) == null || o.call(t, e), this.setDefaultPhoto(e);
|
|
88
|
+
}
|
|
89
|
+
getSrc(e) {
|
|
90
|
+
return typeof e.value == "object" ? e.value.src : e.value;
|
|
91
|
+
}
|
|
92
|
+
getImageUrl(e, t) {
|
|
93
|
+
const o = this.getImgElement(e).getAttribute("data-lazy-src");
|
|
94
|
+
return o || this.getSrc(t);
|
|
95
|
+
}
|
|
96
|
+
async setPictureSourceUrls(e) {
|
|
97
|
+
const t = e.querySelectorAll("source");
|
|
98
|
+
if (t.length > 0)
|
|
99
|
+
for await (const o of t) {
|
|
100
|
+
const i = o.getAttribute("data-lazy-srcset");
|
|
101
|
+
if (i)
|
|
102
|
+
o.srcset = i;
|
|
103
|
+
else
|
|
104
|
+
return this.imageHasError(e);
|
|
105
|
+
}
|
|
106
|
+
else
|
|
107
|
+
this.imageHasError(e);
|
|
108
|
+
}
|
|
109
|
+
hasBgImgMode(e) {
|
|
110
|
+
return e.arg === "bg-image";
|
|
111
|
+
}
|
|
112
|
+
isPictureElement(e) {
|
|
113
|
+
return e instanceof HTMLPictureElement;
|
|
114
|
+
}
|
|
115
|
+
getImgElement(e) {
|
|
116
|
+
return this.isPictureElement(e) ? e.querySelector("img") : e;
|
|
117
|
+
}
|
|
118
|
+
async setDefaultPhoto(e) {
|
|
119
|
+
if (this.options.noUseErrorPhoto)
|
|
120
|
+
return;
|
|
121
|
+
const t = this.options.fallbackSrc ?? this.options.errorPhoto;
|
|
122
|
+
typeof t == "string" && this.addClass(e, this.options.noPhotoClass);
|
|
123
|
+
const o = t ?? await this.loadErrorPhoto(), i = e.querySelectorAll("source");
|
|
124
|
+
if (i.length > 0)
|
|
125
|
+
for await (const r of i)
|
|
126
|
+
r.srcset = o;
|
|
127
|
+
else
|
|
128
|
+
this.setImgSrc(e, o);
|
|
129
|
+
}
|
|
130
|
+
addEventListenerToImg(e) {
|
|
131
|
+
const t = this.getImgElement(e);
|
|
132
|
+
t.addEventListener("load", () => this.onImgLoadedCallback(e), {
|
|
133
|
+
once: !0
|
|
134
|
+
}), t.addEventListener("error", (o) => this.onImgErrorCallback(e, o), { once: !0 });
|
|
135
|
+
}
|
|
136
|
+
async loadImage(e, t) {
|
|
137
|
+
if (this.imageIsLoading(e), this.isPictureElement(e))
|
|
138
|
+
this.addEventListenerToImg(e), await this.setPictureSourceUrls(e);
|
|
139
|
+
else {
|
|
140
|
+
const o = this.getImageUrl(e, t);
|
|
141
|
+
if (!o)
|
|
142
|
+
return this.imageHasError(e);
|
|
143
|
+
this.hasBgImgMode(t) ? (e.style.backgroundImage = `url('${o}')`, this.imageIsLoaded(e)) : (this.addEventListenerToImg(e), this.setImgSrc(e, o));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
setImgSrc(e, t) {
|
|
147
|
+
const o = this.getImgElement(e);
|
|
148
|
+
o.src = t;
|
|
149
|
+
}
|
|
150
|
+
handleIntersectionObserver(e, t, o, i) {
|
|
151
|
+
var r, g;
|
|
152
|
+
this.observers.push(i);
|
|
153
|
+
for (const v of o)
|
|
154
|
+
if (v.isIntersecting) {
|
|
155
|
+
if ((g = (r = this.options).onIntersecting) == null || g.call(r, v.target), this.options.observerOnce && i.unobserve(e), this.options.loadOnce && this.hasImgLoaded)
|
|
156
|
+
return;
|
|
157
|
+
this.loadImage(e, t);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
createObserver(e, t) {
|
|
161
|
+
const o = (g, v) => {
|
|
162
|
+
this.handleIntersectionObserver(e, t, g, v);
|
|
163
|
+
}, i = this.options.observerOptions;
|
|
164
|
+
new IntersectionObserver(o, i).observe(e);
|
|
165
|
+
}
|
|
166
|
+
async imageHandler(e, t, o) {
|
|
167
|
+
if (o === "update")
|
|
168
|
+
for await (const i of this.observers) i.unobserve(e);
|
|
169
|
+
window.IntersectionObserver ? this.createObserver(e, t) : this.loadImage(e, t);
|
|
170
|
+
}
|
|
171
|
+
async bindUpdateHandler(e, t, o) {
|
|
172
|
+
if (this.options.noPhoto)
|
|
173
|
+
return this.imageHasNoPhoto(e);
|
|
174
|
+
await this.imageHandler(e, t, o);
|
|
175
|
+
}
|
|
176
|
+
async add(e, t) {
|
|
177
|
+
if (this.hasBgImgMode(t) && this.isPictureElement(e))
|
|
178
|
+
throw new Error(`[MazLazyImg] You can't use the "bg-image" mode with "<picture />" element`);
|
|
179
|
+
setTimeout(() => this.setBaseClass(e), 0), e.getAttribute("src") || this.setImgSrc(e, fo), await this.bindUpdateHandler(e, t, "bind");
|
|
180
|
+
}
|
|
181
|
+
async update(e, t) {
|
|
182
|
+
t.value !== t.oldValue && (this.hasImgLoaded = !1, this.removeAllStateClasses(e), await this.bindUpdateHandler(e, t, "update"));
|
|
183
|
+
}
|
|
184
|
+
remove(e, t) {
|
|
185
|
+
this.hasImgLoaded = !1, this.hasBgImgMode(t) && (e.style.backgroundImage = ""), this.removeAllStateClasses(e);
|
|
186
|
+
for (const o of this.observers)
|
|
187
|
+
o.unobserve(e);
|
|
188
|
+
this.observers = [];
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
let ue;
|
|
192
|
+
const vo = {
|
|
193
|
+
created(a, e) {
|
|
194
|
+
const t = typeof e.value == "object" ? e.value : {};
|
|
195
|
+
ue = new yo(t), ue.add(a, e);
|
|
196
|
+
},
|
|
197
|
+
updated(a, e) {
|
|
198
|
+
ue.update(a, e);
|
|
199
|
+
},
|
|
200
|
+
unmounted(a, e) {
|
|
201
|
+
ue.remove(a, e);
|
|
202
|
+
}
|
|
203
|
+
}, go = ["data-lazy-srcset", "media"], bo = ["alt"], Co = {
|
|
204
|
+
key: 0,
|
|
205
|
+
class: "m-lazy-img-component-loader"
|
|
206
|
+
}, zo = /* @__PURE__ */ se({
|
|
207
|
+
inheritAttrs: !1,
|
|
208
|
+
__name: "MazLazyImg",
|
|
209
|
+
props: {
|
|
210
|
+
style: { default: void 0 },
|
|
211
|
+
class: { default: void 0 },
|
|
212
|
+
image: { default: void 0 },
|
|
213
|
+
src: { default: void 0 },
|
|
214
|
+
alt: { default: void 0 },
|
|
215
|
+
noPhoto: { type: Boolean },
|
|
216
|
+
noLoader: { type: Boolean },
|
|
217
|
+
noObserverOnce: { type: Boolean },
|
|
218
|
+
loadOnce: { type: Boolean },
|
|
219
|
+
imageHeightFull: { type: Boolean },
|
|
220
|
+
observerOptions: { default: void 0 },
|
|
221
|
+
fallbackSrc: { default: void 0 },
|
|
222
|
+
imgClass: {},
|
|
223
|
+
block: { type: Boolean }
|
|
224
|
+
},
|
|
225
|
+
emits: ["intersecting", "loading", "loaded", "error"],
|
|
226
|
+
setup(a) {
|
|
227
|
+
const e = a, t = R(() => import("./MazSpinner-DoPIk0St.mjs")), o = y(() => e.image || e.src), i = y(() => {
|
|
228
|
+
var r;
|
|
229
|
+
return typeof o.value == "string" ? [{ srcset: o.value }] : (r = o.value) == null ? void 0 : r.sources;
|
|
230
|
+
});
|
|
231
|
+
return (r, g) => Ie((b(), S(
|
|
232
|
+
"picture",
|
|
233
|
+
{
|
|
234
|
+
class: O(["m-lazy-img-component", [{ "--use-loader": !r.noLoader, "--height-full": r.imageHeightFull, "--block": r.block }, e.class]]),
|
|
235
|
+
style: x(r.style)
|
|
236
|
+
},
|
|
237
|
+
[
|
|
238
|
+
(b(!0), S(
|
|
239
|
+
Ce,
|
|
240
|
+
null,
|
|
241
|
+
Oe(i.value, ({ srcset: v, media: L }, C) => (b(), S("source", {
|
|
242
|
+
key: C,
|
|
243
|
+
"data-lazy-srcset": v,
|
|
244
|
+
media: L
|
|
245
|
+
}, null, 8, go))),
|
|
246
|
+
128
|
|
247
|
+
/* KEYED_FRAGMENT */
|
|
248
|
+
)),
|
|
249
|
+
q("img", ee(r.$attrs, {
|
|
250
|
+
src: "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
|
|
251
|
+
loading: "lazy",
|
|
252
|
+
alt: r.alt,
|
|
253
|
+
class: r.imgClass
|
|
254
|
+
}), null, 16, bo),
|
|
255
|
+
r.noLoader ? V("v-if", !0) : (b(), S("div", Co, [
|
|
256
|
+
U(I(t), { size: "2em" })
|
|
257
|
+
])),
|
|
258
|
+
F(r.$slots, "default", {}, void 0, !0)
|
|
259
|
+
],
|
|
260
|
+
6
|
|
261
|
+
/* CLASS, STYLE */
|
|
262
|
+
)), [
|
|
263
|
+
[I(vo), {
|
|
264
|
+
noPhoto: r.noPhoto,
|
|
265
|
+
loadOnce: r.loadOnce,
|
|
266
|
+
observerOptions: r.observerOptions,
|
|
267
|
+
fallbackSrc: r.fallbackSrc,
|
|
268
|
+
observerOnce: !r.noObserverOnce,
|
|
269
|
+
onIntersecting: (v) => r.$emit("intersecting", v),
|
|
270
|
+
onLoading: (v) => r.$emit("loading", v),
|
|
271
|
+
onLoaded: (v) => r.$emit("loaded", v),
|
|
272
|
+
onError: (v) => r.$emit("error", v)
|
|
273
|
+
}]
|
|
274
|
+
]);
|
|
275
|
+
}
|
|
276
|
+
}), ne = (a, e) => {
|
|
277
|
+
const t = a.__vccOpts || a;
|
|
278
|
+
for (const [o, i] of e)
|
|
279
|
+
t[o] = i;
|
|
280
|
+
return t;
|
|
281
|
+
}, Ee = /* @__PURE__ */ ne(zo, [["__scopeId", "data-v-83e40430"]]), Io = {
|
|
282
|
+
removeAccents: !0,
|
|
283
|
+
caseSensitive: !1,
|
|
284
|
+
replaceSpaces: !0,
|
|
285
|
+
removeSpecialCharacters: !1,
|
|
286
|
+
trim: !0,
|
|
287
|
+
normalizeSpaces: !0,
|
|
288
|
+
removeNumbers: !1,
|
|
289
|
+
customNormalizationForms: ["NFC", "NFKD"]
|
|
290
|
+
};
|
|
291
|
+
function me(a, e) {
|
|
292
|
+
const t = { ...Io, ...e }, o = {
|
|
293
|
+
À: "A",
|
|
294
|
+
Á: "A",
|
|
295
|
+
Â: "A",
|
|
296
|
+
Ã: "A",
|
|
297
|
+
Ä: "A",
|
|
298
|
+
Å: "A",
|
|
299
|
+
à: "a",
|
|
300
|
+
á: "a",
|
|
301
|
+
â: "a",
|
|
302
|
+
ã: "a",
|
|
303
|
+
ä: "a",
|
|
304
|
+
å: "a",
|
|
305
|
+
È: "E",
|
|
306
|
+
É: "E",
|
|
307
|
+
Ê: "E",
|
|
308
|
+
Ë: "E",
|
|
309
|
+
è: "e",
|
|
310
|
+
é: "e",
|
|
311
|
+
ê: "e",
|
|
312
|
+
ë: "e",
|
|
313
|
+
Î: "I",
|
|
314
|
+
Ï: "I",
|
|
315
|
+
í: "I",
|
|
316
|
+
î: "i",
|
|
317
|
+
ï: "i",
|
|
318
|
+
Ô: "O",
|
|
319
|
+
Õ: "O",
|
|
320
|
+
Ö: "O",
|
|
321
|
+
Ø: "O",
|
|
322
|
+
ô: "o",
|
|
323
|
+
õ: "o",
|
|
324
|
+
ö: "o",
|
|
325
|
+
ø: "o",
|
|
326
|
+
Ù: "U",
|
|
327
|
+
Ú: "U",
|
|
328
|
+
Û: "U",
|
|
329
|
+
Ü: "U",
|
|
330
|
+
ù: "u",
|
|
331
|
+
ú: "u",
|
|
332
|
+
û: "u",
|
|
333
|
+
ü: "u",
|
|
334
|
+
Ç: "C",
|
|
335
|
+
ç: "c",
|
|
336
|
+
ÿ: "y",
|
|
337
|
+
Ñ: "N",
|
|
338
|
+
ñ: "n",
|
|
339
|
+
ó: "o"
|
|
340
|
+
};
|
|
341
|
+
let i = a.toString();
|
|
342
|
+
if (t.trim && (i = i.trim()), t.normalizeSpaces && (i = i.replaceAll(/\s+/g, " ")), t.replaceSpaces && (i = i.replaceAll(" ", "-")), t.removeNumbers && (i = i.replaceAll(/\d/g, "")), t.removeAccents && (i = i.replaceAll(/[ÀÁÂÃÄÅÇÈÉÊËÎÏÑÔÕÖØÙÚÛÜàáâãäåçèéêëíîïñóôõöøùúûüÿ]/g, (r) => o[r] || r), i = i.replaceAll(/[\u0300-\u036F]/g, "")), t.caseSensitive === !1 && (i = i.toLowerCase()), t.removeSpecialCharacters && (i = i.replaceAll(/[^\dA-Z-]/gi, "")), t.trim && (i = i.trim()), t.customNormalizationForms)
|
|
343
|
+
for (const r of t.customNormalizationForms)
|
|
344
|
+
i = i.normalize(r);
|
|
345
|
+
return i;
|
|
346
|
+
}
|
|
347
|
+
function Ao(a, e) {
|
|
348
|
+
const t = a.length, o = e.length, i = [];
|
|
349
|
+
for (let r = 0; r <= t; r++)
|
|
350
|
+
i[r] = [r];
|
|
351
|
+
for (let r = 0; r <= o; r++)
|
|
352
|
+
i[0][r] = r;
|
|
353
|
+
for (let r = 1; r <= t; r++)
|
|
354
|
+
for (let g = 1; g <= o; g++) {
|
|
355
|
+
const v = a[r - 1] === e[g - 1] ? 0 : 1;
|
|
356
|
+
i[r][g] = Math.min(
|
|
357
|
+
i[r - 1][g] + 1,
|
|
358
|
+
i[r][g - 1] + 1,
|
|
359
|
+
i[r - 1][g - 1] + v
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
return i[t][o];
|
|
363
|
+
}
|
|
364
|
+
function Ne(a, e) {
|
|
365
|
+
const t = Ao(a, e), o = Math.max(a.length, e.length);
|
|
366
|
+
return 1 - t / o;
|
|
367
|
+
}
|
|
368
|
+
function wo(a, e, t = 0.75) {
|
|
369
|
+
return Ne(a, e) >= t;
|
|
370
|
+
}
|
|
371
|
+
function ve(a, e, t = 0.75) {
|
|
372
|
+
const o = y(
|
|
373
|
+
() => me(typeof a == "string" ? a : a.value)
|
|
374
|
+
), i = y(
|
|
375
|
+
() => me(typeof e == "string" ? e : e.value)
|
|
376
|
+
), r = y(() => typeof t == "number" ? t : t.value), g = y(() => Ne(o.value, i.value));
|
|
377
|
+
return {
|
|
378
|
+
isMatching: y(
|
|
379
|
+
() => wo(o.value, i.value, r.value)
|
|
380
|
+
),
|
|
381
|
+
score: g
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
function Ke(a, e, t) {
|
|
385
|
+
var g, v;
|
|
386
|
+
a.stopPropagation();
|
|
387
|
+
const o = typeof t.value == "function" ? t.value : t.value.handler, i = typeof t.value == "object" ? t.value.exclude : void 0;
|
|
388
|
+
let r = !1;
|
|
389
|
+
if (i && i.length > 0) {
|
|
390
|
+
for (const L of i)
|
|
391
|
+
if (!r && a.target instanceof HTMLElement) {
|
|
392
|
+
const C = (g = document.querySelector(L)) == null ? void 0 : g.getAttribute("id");
|
|
393
|
+
r = (a.target.getAttribute("id") === C || ((v = document.querySelector(L)) == null ? void 0 : v.contains(a.target))) ?? !1;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
!e.contains(a.target) && !r && (o == null || o(a));
|
|
397
|
+
}
|
|
398
|
+
function Ue() {
|
|
399
|
+
return document.ontouchstart === null ? "touchstart" : "click";
|
|
400
|
+
}
|
|
401
|
+
function So(a, e) {
|
|
402
|
+
const t = Ue();
|
|
403
|
+
document.removeEventListener(t, (o) => Ke(o, a, e));
|
|
404
|
+
}
|
|
405
|
+
function Vo(a, e) {
|
|
406
|
+
if (typeof e.value != "function" && typeof e.value == "object" && typeof e.value.handler != "function") {
|
|
407
|
+
console.error("[maz-ui](vClosable) v-closable directive requires a handler function");
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
const t = Ue();
|
|
411
|
+
document.addEventListener(t, (o) => Ke(o, a, e));
|
|
412
|
+
}
|
|
413
|
+
const ko = {
|
|
414
|
+
mounted: Vo,
|
|
415
|
+
unmounted: So
|
|
416
|
+
};
|
|
417
|
+
let ge = null;
|
|
418
|
+
function Po(a, e) {
|
|
419
|
+
ge && clearTimeout(ge), ge = setTimeout(a, e);
|
|
420
|
+
}
|
|
421
|
+
function Bo(a, e) {
|
|
422
|
+
let t;
|
|
423
|
+
return function(...o) {
|
|
424
|
+
clearTimeout(t), t = setTimeout(() => {
|
|
425
|
+
a.apply(this, o);
|
|
426
|
+
}, e);
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
const Lo = ["for"], Eo = {
|
|
430
|
+
key: 0,
|
|
431
|
+
class: "m-input-wrapper-left"
|
|
432
|
+
}, $o = ["id", "name", "placeholder", "aria-label", "type", "inputmode", "disabled", "readonly", "autocomplete", "required"], Oo = { key: 0 }, To = {
|
|
433
|
+
key: 1,
|
|
434
|
+
class: "m-input-wrapper-right"
|
|
435
|
+
}, Mo = /* @__PURE__ */ se({
|
|
436
|
+
inheritAttrs: !1,
|
|
437
|
+
__name: "MazInput",
|
|
438
|
+
props: {
|
|
439
|
+
style: { default: void 0 },
|
|
440
|
+
class: { default: void 0 },
|
|
441
|
+
modelValue: { default: void 0 },
|
|
442
|
+
placeholder: { default: void 0 },
|
|
443
|
+
label: { default: void 0 },
|
|
444
|
+
topLabel: {},
|
|
445
|
+
assistiveText: {},
|
|
446
|
+
name: { default: void 0 },
|
|
447
|
+
color: { default: "primary" },
|
|
448
|
+
type: { default: "text" },
|
|
449
|
+
required: { type: Boolean, default: !1 },
|
|
450
|
+
disabled: { type: Boolean, default: !1 },
|
|
451
|
+
readonly: { type: Boolean, default: !1 },
|
|
452
|
+
id: { default: void 0 },
|
|
453
|
+
error: { type: Boolean, default: !1 },
|
|
454
|
+
success: { type: Boolean, default: !1 },
|
|
455
|
+
warning: { type: Boolean, default: !1 },
|
|
456
|
+
hint: { default: void 0 },
|
|
457
|
+
inputClasses: { default: void 0 },
|
|
458
|
+
noBorder: { type: Boolean, default: !1 },
|
|
459
|
+
noRadius: { type: Boolean, default: !1 },
|
|
460
|
+
inputmode: { default: "text" },
|
|
461
|
+
size: { default: "md" },
|
|
462
|
+
debounce: { type: [Boolean, Number], default: !1 },
|
|
463
|
+
debounceDelay: { default: 500 },
|
|
464
|
+
validButton: { type: Boolean, default: !1 },
|
|
465
|
+
validButtonLoading: { type: Boolean, default: !1 },
|
|
466
|
+
autoFocus: { type: Boolean, default: !1 },
|
|
467
|
+
borderActive: { type: Boolean, default: !1 },
|
|
468
|
+
leftIcon: { type: [String, Function, Object], default: void 0 },
|
|
469
|
+
rightIcon: { type: [String, Function, Object], default: void 0 },
|
|
470
|
+
roundedSize: { default: void 0 },
|
|
471
|
+
block: { type: Boolean },
|
|
472
|
+
autocomplete: {}
|
|
473
|
+
},
|
|
474
|
+
emits: ["update:model-value", "focus", "blur", "click", "change", "input"],
|
|
475
|
+
setup(a, { emit: e }) {
|
|
476
|
+
const t = a, o = e, i = R(() => import("./MazBtn-C7yEnuOD.mjs")), r = R(() => import("./MazIcon-kLACGOa2.mjs")), g = R(() => import("./eye-slash-BoO00xzs.mjs")), v = R(() => import("./eye-f8zAUc30.mjs")), L = R(() => import("./check-C9Q_W85g.mjs")), C = k(!1), h = k(!1), T = k(), c = we({
|
|
477
|
+
componentName: "MazInput",
|
|
478
|
+
providedId: t.id
|
|
479
|
+
});
|
|
480
|
+
Ae(() => {
|
|
481
|
+
var s;
|
|
482
|
+
t.autoFocus && ((s = T.value) == null || s.focus());
|
|
483
|
+
});
|
|
484
|
+
const A = y(() => t.type === "password"), m = y(() => C.value ? "text" : t.type), p = y(() => {
|
|
485
|
+
if (!t.noBorder) {
|
|
486
|
+
if (t.error)
|
|
487
|
+
return "maz-border-danger";
|
|
488
|
+
if (t.success)
|
|
489
|
+
return "maz-border-success";
|
|
490
|
+
if (t.warning)
|
|
491
|
+
return "maz-border-warning";
|
|
492
|
+
if (h.value || t.borderActive) {
|
|
493
|
+
if (t.color === "black")
|
|
494
|
+
return "maz-border-black";
|
|
495
|
+
if (t.color === "danger")
|
|
496
|
+
return "maz-border-danger";
|
|
497
|
+
if (t.color === "info")
|
|
498
|
+
return "maz-border-info";
|
|
499
|
+
if (t.color === "primary")
|
|
500
|
+
return "maz-border-primary";
|
|
501
|
+
if (t.color === "secondary")
|
|
502
|
+
return "maz-border-secondary";
|
|
503
|
+
if (t.color === "success")
|
|
504
|
+
return "maz-border-success";
|
|
505
|
+
if (t.color === "warning")
|
|
506
|
+
return "maz-border-warning";
|
|
507
|
+
if (t.color === "white")
|
|
508
|
+
return "maz-border-white";
|
|
509
|
+
}
|
|
510
|
+
return "--default-border";
|
|
511
|
+
}
|
|
512
|
+
}), E = eo(), G = y(() => {
|
|
513
|
+
const { required: s, placeholder: M } = t;
|
|
514
|
+
if (M)
|
|
515
|
+
return s ? `${M} *` : M;
|
|
516
|
+
}), oe = y(() => H.value !== void 0 && H.value !== ""), j = Bo(
|
|
517
|
+
(s) => {
|
|
518
|
+
o("update:model-value", s);
|
|
519
|
+
},
|
|
520
|
+
typeof t.debounce == "number" ? t.debounce : t.debounceDelay ?? 500
|
|
521
|
+
);
|
|
522
|
+
function Q(s) {
|
|
523
|
+
if (t.debounce)
|
|
524
|
+
return j(s);
|
|
525
|
+
o("update:model-value", s);
|
|
526
|
+
}
|
|
527
|
+
const H = y({
|
|
528
|
+
get: () => t.modelValue,
|
|
529
|
+
set: (s) => Q(s)
|
|
530
|
+
}), N = y(() => (!!t.label || !!t.hint) && (h.value || !!oe.value || !!t.placeholder || ["date", "month", "week"].includes(t.type))), n = y(() => !!t.label || !!t.hint);
|
|
531
|
+
function w() {
|
|
532
|
+
return !!E["right-icon"] || A.value || !!E["valid-button"] || t.validButton || !!t.rightIcon;
|
|
533
|
+
}
|
|
534
|
+
function $() {
|
|
535
|
+
return !!E["left-icon"] || !!t.leftIcon;
|
|
536
|
+
}
|
|
537
|
+
function P(s) {
|
|
538
|
+
o("focus", s), h.value = !0;
|
|
539
|
+
}
|
|
540
|
+
function te(s) {
|
|
541
|
+
o("blur", s), h.value = !1;
|
|
542
|
+
}
|
|
543
|
+
function pe(s) {
|
|
544
|
+
return o("change", s);
|
|
545
|
+
}
|
|
546
|
+
function J(s) {
|
|
547
|
+
return o("input", s);
|
|
548
|
+
}
|
|
549
|
+
return (s, M) => (b(), S(
|
|
550
|
+
"div",
|
|
551
|
+
{
|
|
552
|
+
class: O(["m-input", [
|
|
553
|
+
{
|
|
554
|
+
"--is-focused": h.value || s.borderActive,
|
|
555
|
+
"--should-up": N.value,
|
|
556
|
+
"--has-label": n.value,
|
|
557
|
+
"--is-disabled": s.disabled,
|
|
558
|
+
"--is-readonly": s.readonly,
|
|
559
|
+
"--has-z-2": s.error || s.warning || s.success,
|
|
560
|
+
"--has-state": s.error || s.warning || s.success,
|
|
561
|
+
"--block": s.block
|
|
562
|
+
},
|
|
563
|
+
t.class,
|
|
564
|
+
`--${s.color}`
|
|
565
|
+
]]),
|
|
566
|
+
style: x(s.style)
|
|
567
|
+
},
|
|
568
|
+
[
|
|
569
|
+
s.topLabel ? (b(), S("label", {
|
|
570
|
+
key: 0,
|
|
571
|
+
for: I(c),
|
|
572
|
+
class: "m-input-top-label"
|
|
573
|
+
}, _(s.topLabel), 9, Lo)) : V("v-if", !0),
|
|
574
|
+
q(
|
|
575
|
+
"div",
|
|
576
|
+
{
|
|
577
|
+
class: O(["m-input-wrapper", [
|
|
578
|
+
s.inputClasses,
|
|
579
|
+
p.value,
|
|
580
|
+
s.roundedSize ? `--rounded-${s.roundedSize}` : { "maz-rounded": !s.noRadius },
|
|
581
|
+
{ "--block": s.block }
|
|
582
|
+
]])
|
|
583
|
+
},
|
|
584
|
+
[
|
|
585
|
+
$() ? (b(), S("div", Eo, [
|
|
586
|
+
s.$slots["left-icon"] || s.leftIcon ? F(s.$slots, "left-icon", { key: 0 }, () => [
|
|
587
|
+
typeof s.leftIcon == "string" ? (b(), K(I(r), {
|
|
588
|
+
key: 0,
|
|
589
|
+
name: s.leftIcon,
|
|
590
|
+
class: "maz-text-xl maz-text-muted"
|
|
591
|
+
}, null, 8, ["name"])) : s.leftIcon ? (b(), K(Be(s.leftIcon), {
|
|
592
|
+
key: 1,
|
|
593
|
+
class: "maz-text-xl maz-text-muted"
|
|
594
|
+
})) : V("v-if", !0)
|
|
595
|
+
], !0) : V("v-if", !0)
|
|
596
|
+
])) : V("v-if", !0),
|
|
597
|
+
q(
|
|
598
|
+
"div",
|
|
599
|
+
{
|
|
600
|
+
class: O(["m-input-wrapper-input", [`--${s.size}`, { "--top-label": !!s.topLabel }]])
|
|
601
|
+
},
|
|
602
|
+
[
|
|
603
|
+
Ie(q("input", ee({ id: I(c) }, s.$attrs, {
|
|
604
|
+
ref_key: "input",
|
|
605
|
+
ref: T,
|
|
606
|
+
"onUpdate:modelValue": M[0] || (M[0] = (Z) => H.value = Z),
|
|
607
|
+
name: s.name,
|
|
608
|
+
placeholder: G.value,
|
|
609
|
+
"aria-label": s.label || s.placeholder,
|
|
610
|
+
type: m.value,
|
|
611
|
+
inputmode: s.inputmode,
|
|
612
|
+
disabled: s.disabled,
|
|
613
|
+
readonly: s.readonly,
|
|
614
|
+
autocomplete: s.autocomplete,
|
|
615
|
+
required: s.required,
|
|
616
|
+
class: "m-input-input"
|
|
617
|
+
}, oo({
|
|
618
|
+
blur: te,
|
|
619
|
+
focus: P,
|
|
620
|
+
change: pe,
|
|
621
|
+
input: J
|
|
622
|
+
}, !0), {
|
|
623
|
+
onClick: M[1] || (M[1] = (Z) => s.$emit("click", Z))
|
|
624
|
+
}), null, 16, $o), [
|
|
625
|
+
[to, H.value]
|
|
626
|
+
]),
|
|
627
|
+
s.label || s.hint ? (b(), S(
|
|
628
|
+
"span",
|
|
629
|
+
{
|
|
630
|
+
key: 0,
|
|
631
|
+
class: O(["m-input-label", [
|
|
632
|
+
{
|
|
633
|
+
"maz-text-danger-600": s.error,
|
|
634
|
+
"maz-text-success-600": s.success,
|
|
635
|
+
"maz-text-warning-600": s.warning
|
|
636
|
+
}
|
|
637
|
+
]])
|
|
638
|
+
},
|
|
639
|
+
[
|
|
640
|
+
lo(
|
|
641
|
+
_(s.hint || s.label) + " ",
|
|
642
|
+
1
|
|
643
|
+
/* TEXT */
|
|
644
|
+
),
|
|
645
|
+
s.required ? (b(), S("sup", Oo, "*")) : V("v-if", !0)
|
|
646
|
+
],
|
|
647
|
+
2
|
|
648
|
+
/* CLASS */
|
|
649
|
+
)) : V("v-if", !0)
|
|
650
|
+
],
|
|
651
|
+
2
|
|
652
|
+
/* CLASS */
|
|
653
|
+
),
|
|
654
|
+
w() ? (b(), S("div", To, [
|
|
655
|
+
s.$slots["right-icon"] || s.rightIcon ? F(s.$slots, "right-icon", { key: 0 }, () => [
|
|
656
|
+
typeof s.rightIcon == "string" ? (b(), K(I(r), {
|
|
657
|
+
key: 0,
|
|
658
|
+
name: s.rightIcon,
|
|
659
|
+
class: "maz-text-xl maz-text-muted"
|
|
660
|
+
}, null, 8, ["name"])) : s.rightIcon ? (b(), K(Be(s.rightIcon), {
|
|
661
|
+
key: 1,
|
|
662
|
+
class: "maz-text-xl maz-text-muted"
|
|
663
|
+
})) : V("v-if", !0)
|
|
664
|
+
], !0) : V("v-if", !0),
|
|
665
|
+
A.value ? (b(), K(I(i), {
|
|
666
|
+
key: 1,
|
|
667
|
+
color: "transparent",
|
|
668
|
+
tabindex: "-1",
|
|
669
|
+
size: "mini",
|
|
670
|
+
onClick: M[2] || (M[2] = ae((Z) => C.value = !C.value, ["stop"]))
|
|
671
|
+
}, {
|
|
672
|
+
default: W(() => [
|
|
673
|
+
C.value ? (b(), K(I(g), {
|
|
674
|
+
key: 0,
|
|
675
|
+
class: "maz-text-xl maz-text-muted"
|
|
676
|
+
})) : (b(), K(I(v), {
|
|
677
|
+
key: 1,
|
|
678
|
+
class: "maz-text-xl maz-text-muted"
|
|
679
|
+
}))
|
|
680
|
+
]),
|
|
681
|
+
_: 1
|
|
682
|
+
/* STABLE */
|
|
683
|
+
})) : V("v-if", !0),
|
|
684
|
+
s.$slots["valid-button"] || s.validButton ? F(s.$slots, "valid-button", { key: 2 }, () => [
|
|
685
|
+
U(I(i), {
|
|
686
|
+
color: "transparent",
|
|
687
|
+
disabled: s.disabled,
|
|
688
|
+
tabindex: "-1",
|
|
689
|
+
loading: s.validButtonLoading,
|
|
690
|
+
class: "m-input-valid-button",
|
|
691
|
+
size: "mini",
|
|
692
|
+
type: "submit"
|
|
693
|
+
}, {
|
|
694
|
+
default: W(() => [
|
|
695
|
+
U(I(L), { class: "maz-text-2xl maz-text-normal" })
|
|
696
|
+
]),
|
|
697
|
+
_: 1
|
|
698
|
+
/* STABLE */
|
|
699
|
+
}, 8, ["disabled", "loading"])
|
|
700
|
+
], !0) : V("v-if", !0)
|
|
701
|
+
])) : V("v-if", !0)
|
|
702
|
+
],
|
|
703
|
+
2
|
|
704
|
+
/* CLASS */
|
|
705
|
+
),
|
|
706
|
+
s.assistiveText ? (b(), S(
|
|
707
|
+
"div",
|
|
708
|
+
{
|
|
709
|
+
key: 1,
|
|
710
|
+
class: O(["m-input-bottom-text", [
|
|
711
|
+
{
|
|
712
|
+
"maz-text-danger-600": s.error,
|
|
713
|
+
"maz-text-success-600": s.success,
|
|
714
|
+
"maz-text-warning-600": s.warning,
|
|
715
|
+
"maz-text-muted": !s.error && !s.success && !s.warning
|
|
716
|
+
}
|
|
717
|
+
]])
|
|
718
|
+
},
|
|
719
|
+
_(s.assistiveText),
|
|
720
|
+
3
|
|
721
|
+
/* TEXT, CLASS */
|
|
722
|
+
)) : V("v-if", !0)
|
|
723
|
+
],
|
|
724
|
+
6
|
|
725
|
+
/* CLASS, STYLE */
|
|
726
|
+
));
|
|
727
|
+
}
|
|
728
|
+
}), ze = /* @__PURE__ */ ne(Mo, [["__scopeId", "data-v-1443c13f"]]), Fo = ["aria-label"], No = { class: "m-select-list__no-results" }, Ko = {
|
|
729
|
+
key: 2,
|
|
730
|
+
class: "m-select-list__scroll-wrapper",
|
|
731
|
+
tabindex: "-1"
|
|
732
|
+
}, Uo = { class: "m-select-list-optgroup" }, Ho = ["onClick"], Do = /* @__PURE__ */ se({
|
|
733
|
+
inheritAttrs: !1,
|
|
734
|
+
__name: "MazSelect",
|
|
735
|
+
props: {
|
|
736
|
+
style: { default: void 0 },
|
|
737
|
+
class: { default: void 0 },
|
|
738
|
+
id: { default: void 0 },
|
|
739
|
+
modelValue: { default: void 0 },
|
|
740
|
+
options: { default: void 0 },
|
|
741
|
+
optionValueKey: { default: "value" },
|
|
742
|
+
optionLabelKey: { default: "label" },
|
|
743
|
+
optionInputValueKey: { default: "label" },
|
|
744
|
+
listPosition: { default: "bottom left" },
|
|
745
|
+
itemHeight: { default: void 0 },
|
|
746
|
+
maxListHeight: { default: 240 },
|
|
747
|
+
maxListWidth: { default: void 0 },
|
|
748
|
+
minListHeight: { default: void 0 },
|
|
749
|
+
minListWidth: { default: void 0 },
|
|
750
|
+
size: { default: "md" },
|
|
751
|
+
color: { default: "primary" },
|
|
752
|
+
search: { type: Boolean },
|
|
753
|
+
searchPlaceholder: { default: "Search in options" },
|
|
754
|
+
searchThreshold: { default: 0.75 },
|
|
755
|
+
open: { type: Boolean },
|
|
756
|
+
multiple: { type: Boolean, default: void 0 },
|
|
757
|
+
required: { type: Boolean },
|
|
758
|
+
disabled: { type: Boolean },
|
|
759
|
+
block: { type: Boolean },
|
|
760
|
+
excludeSelectors: { default: void 0 },
|
|
761
|
+
autocomplete: { default: "off" }
|
|
762
|
+
},
|
|
763
|
+
emits: ["close", "open", "blur", "focus", "change", "input", "update:model-value", "selected-option"],
|
|
764
|
+
setup(a, { expose: e, emit: t }) {
|
|
765
|
+
const o = a, i = t, r = R(() => import("./MazCheckbox-BNvSeNBP.mjs")), g = R(() => import("./magnifying-glass--nBiyXot.mjs")), v = R(() => import("./chevron-down-BkvtON3b.mjs")), L = R(() => import("./no-symbol-CIgKzsrB.mjs"));
|
|
766
|
+
e({
|
|
767
|
+
/** Method to open the option list */
|
|
768
|
+
openList: re,
|
|
769
|
+
/** Method to close the option list */
|
|
770
|
+
closeList: le
|
|
771
|
+
});
|
|
772
|
+
const C = k(!1), h = k(), T = y(
|
|
773
|
+
() => ["black", "transparent", "white"].includes(o.color)
|
|
774
|
+
), c = y(
|
|
775
|
+
() => T.value ? "var(--maz-color-black)" : `var(--maz-color-${o.color}-800)`
|
|
776
|
+
), A = y(
|
|
777
|
+
() => T.value ? "var(--maz-color-muted)" : `var(--maz-color-${o.color}-100)`
|
|
778
|
+
), m = y(
|
|
779
|
+
() => T.value ? "var(--maz-color-muted)" : `var(--maz-color-${o.color}-200)`
|
|
780
|
+
), p = y(() => C.value || o.open), E = we({
|
|
781
|
+
componentName: "MazSelect",
|
|
782
|
+
providedId: o.id
|
|
783
|
+
});
|
|
784
|
+
function G(l) {
|
|
785
|
+
return {
|
|
786
|
+
[o.optionValueKey]: l,
|
|
787
|
+
[o.optionLabelKey]: l,
|
|
788
|
+
[o.optionInputValueKey]: l
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
function oe(l) {
|
|
792
|
+
return {
|
|
793
|
+
...l,
|
|
794
|
+
[o.optionValueKey]: l[o.optionValueKey],
|
|
795
|
+
[o.optionLabelKey]: l[o.optionLabelKey],
|
|
796
|
+
[o.optionInputValueKey]: l[o.optionInputValueKey]
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
const j = y(() => {
|
|
800
|
+
var d;
|
|
801
|
+
const l = [];
|
|
802
|
+
if (!((d = o.options) != null && d.length))
|
|
803
|
+
return [];
|
|
804
|
+
for (const u of o.options)
|
|
805
|
+
typeof u == "string" || typeof u == "number" || typeof u == "boolean" ? l.push(G(u)) : typeof u == "object" && "options" in u && Array.isArray(u.options) ? l.push(
|
|
806
|
+
{ label: u.label, isOptGroup: !0 },
|
|
807
|
+
...u.options.map(
|
|
808
|
+
(f) => typeof f == "string" || typeof f == "number" || typeof f == "boolean" ? G(f) : oe(f)
|
|
809
|
+
)
|
|
810
|
+
) : l.push(oe(u));
|
|
811
|
+
return l;
|
|
812
|
+
}), Q = y(
|
|
813
|
+
() => {
|
|
814
|
+
var l;
|
|
815
|
+
return ((l = j.value) == null ? void 0 : l.filter((d) => o.multiple ? Array.isArray(o.modelValue) ? o.modelValue.includes(d[o.optionValueKey]) && !$(d[o.optionValueKey]) : !1 : o.modelValue === d[o.optionValueKey] && !$(d[o.optionValueKey]))) ?? [];
|
|
816
|
+
}
|
|
817
|
+
);
|
|
818
|
+
Te(() => {
|
|
819
|
+
var l;
|
|
820
|
+
(l = o.options) != null && l.length || console.warn("[maz-ui](MazSelect) you must provide options"), he();
|
|
821
|
+
});
|
|
822
|
+
const H = k(), N = k(), n = k(), w = k();
|
|
823
|
+
function $(l) {
|
|
824
|
+
return l == null;
|
|
825
|
+
}
|
|
826
|
+
function P(l) {
|
|
827
|
+
var u;
|
|
828
|
+
return (((u = Q.value) == null ? void 0 : u.some(
|
|
829
|
+
(f) => f[o.optionValueKey] === l[o.optionValueKey]
|
|
830
|
+
)) ?? !1) && !$(l[o.optionValueKey]);
|
|
831
|
+
}
|
|
832
|
+
const te = y(() => {
|
|
833
|
+
var d;
|
|
834
|
+
if (o.multiple && o.modelValue && Array.isArray(o.modelValue))
|
|
835
|
+
return o.modelValue.map(
|
|
836
|
+
(u) => {
|
|
837
|
+
var f, z;
|
|
838
|
+
return (z = (f = j.value) == null ? void 0 : f.find((B) => B[o.optionValueKey] === u)) == null ? void 0 : z[o.optionInputValueKey];
|
|
839
|
+
}
|
|
840
|
+
).join(", ");
|
|
841
|
+
const l = (d = j.value) == null ? void 0 : d.find(
|
|
842
|
+
(u) => u[o.optionValueKey] === o.modelValue
|
|
843
|
+
);
|
|
844
|
+
return $(o.modelValue) || l == null ? void 0 : l[o.optionInputValueKey];
|
|
845
|
+
}), pe = y(
|
|
846
|
+
() => o.listPosition.includes("bottom") ? "maz-slide" : "maz-slideinvert"
|
|
847
|
+
), J = k(""), s = k("");
|
|
848
|
+
function M(l, d) {
|
|
849
|
+
return d && l && me(l).includes(me(d));
|
|
850
|
+
}
|
|
851
|
+
function Z(l) {
|
|
852
|
+
var d;
|
|
853
|
+
return l ? (d = j.value) == null ? void 0 : d.filter((u) => {
|
|
854
|
+
const f = u[o.optionLabelKey], z = u[o.optionValueKey], B = u[o.optionInputValueKey], D = o.searchThreshold;
|
|
855
|
+
return M(f, l) || M(B, l) || M(z, l) || typeof f == "string" && ve(f, l, D).isMatching.value || typeof B == "string" && ve(B, l, D).isMatching.value || typeof z == "string" && ve(z, l, D).isMatching.value;
|
|
856
|
+
}) : j.value;
|
|
857
|
+
}
|
|
858
|
+
const Y = y(() => Z(J.value));
|
|
859
|
+
async function le(l) {
|
|
860
|
+
var u, f;
|
|
861
|
+
if (!p.value)
|
|
862
|
+
return;
|
|
863
|
+
if (l && ("relatedTarget" in l && ((u = H.value) != null && u.contains(l.relatedTarget)) || l.type === "keydown"))
|
|
864
|
+
return l.preventDefault();
|
|
865
|
+
const d = l && "relatedTarget" in l && l.relatedTarget instanceof HTMLElement && l.relatedTarget.getAttribute("id");
|
|
866
|
+
if ((f = o.excludeSelectors) != null && f.includes(`#${d}`))
|
|
867
|
+
return l == null ? void 0 : l.preventDefault();
|
|
868
|
+
await de(), C.value = !1, h.value = 0, i("close", l);
|
|
869
|
+
}
|
|
870
|
+
async function re(l) {
|
|
871
|
+
o.disabled || p.value || (l == null || l.preventDefault(), C.value = !0, await fe(), i("focus", l), i("open", C.value));
|
|
872
|
+
}
|
|
873
|
+
function Ve() {
|
|
874
|
+
var l, d;
|
|
875
|
+
(d = ((l = N.value) == null ? void 0 : l.$el).querySelector("input")) == null || d.focus();
|
|
876
|
+
}
|
|
877
|
+
function qe() {
|
|
878
|
+
var l, d;
|
|
879
|
+
(d = ((l = N.value) == null ? void 0 : l.$el).querySelector("input")) == null || d.dispatchEvent(new Event("input"));
|
|
880
|
+
}
|
|
881
|
+
function je(l) {
|
|
882
|
+
C.value ? le(l) : Ve();
|
|
883
|
+
}
|
|
884
|
+
function Ye(l) {
|
|
885
|
+
var d, u;
|
|
886
|
+
J.value = l, (u = ((d = n.value) == null ? void 0 : d.$el).querySelector("input")) == null || u.focus();
|
|
887
|
+
}
|
|
888
|
+
function We(l) {
|
|
889
|
+
var u;
|
|
890
|
+
l === "Backspace" && s.value.length > 0 ? s.value = s.value.slice(0, -1) : s.value += l;
|
|
891
|
+
const d = Z(s.value);
|
|
892
|
+
d != null && d.length && (h.value = (u = Y.value) == null ? void 0 : u.findIndex(
|
|
893
|
+
(f) => f[o.optionValueKey] === d[0][o.optionValueKey]
|
|
894
|
+
), typeof h.value == "number" && h.value >= 0 && fe(h.value)), Po(() => {
|
|
895
|
+
s.value = "";
|
|
896
|
+
}, 1e3);
|
|
897
|
+
}
|
|
898
|
+
function Qe(l) {
|
|
899
|
+
const d = l.key;
|
|
900
|
+
/^[\dA-Za-z\u0400-\u04FF]$/.test(d) ? (l.preventDefault(), re(l), o.search ? Ye(d) : We(d)) : ke(l);
|
|
901
|
+
}
|
|
902
|
+
function ke(l, d = !0) {
|
|
903
|
+
const u = l.code, f = ["ArrowUp", "ArrowDown"].includes(u), z = (d ? ["Enter", "Space"] : ["Enter"]).includes(u), B = u === "Escape" && p.value;
|
|
904
|
+
f ? Ge(l, h.value) : z ? Je(l, h.value) : B && le(l);
|
|
905
|
+
}
|
|
906
|
+
function Ge(l, d) {
|
|
907
|
+
var z;
|
|
908
|
+
l.preventDefault();
|
|
909
|
+
const u = l.code;
|
|
910
|
+
p.value || re(l);
|
|
911
|
+
const f = (z = Y.value) == null ? void 0 : z.length;
|
|
912
|
+
f && (typeof d == "number" ? d === f - 1 && u === "ArrowDown" ? h.value = 0 : d === 0 && u === "ArrowUp" ? h.value = f - 1 : h.value = u === "ArrowDown" ? d + 1 : d - 1 : h.value = u === "ArrowDown" ? 0 : f - 1, fe(h.value));
|
|
913
|
+
}
|
|
914
|
+
function Je(l, d) {
|
|
915
|
+
var f, z, B;
|
|
916
|
+
if (!p.value)
|
|
917
|
+
return;
|
|
918
|
+
l.preventDefault();
|
|
919
|
+
const u = d ? ((f = Y.value) == null ? void 0 : f[d]) ?? ((z = Y.value) == null ? void 0 : z[0]) : (B = Y.value) == null ? void 0 : B[0];
|
|
920
|
+
$(u) || Pe(u);
|
|
921
|
+
}
|
|
922
|
+
async function fe(l) {
|
|
923
|
+
var u, f;
|
|
924
|
+
await de(), typeof l != "number" && he();
|
|
925
|
+
const d = l ?? h.value;
|
|
926
|
+
if (typeof d == "number" && d >= 0) {
|
|
927
|
+
const z = (u = w.value) == null ? void 0 : u.querySelectorAll(".m-select-list-item");
|
|
928
|
+
(f = z == null ? void 0 : z[d]) == null || f.scrollIntoView({
|
|
929
|
+
behavior: "auto",
|
|
930
|
+
block: "nearest",
|
|
931
|
+
inline: "start"
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
function he(l) {
|
|
936
|
+
var u;
|
|
937
|
+
const d = (u = Y.value) == null ? void 0 : u.findIndex((f) => {
|
|
938
|
+
var z, B;
|
|
939
|
+
return o.multiple && Array.isArray(o.modelValue) ? l ? l[o.optionValueKey] === f[o.optionValueKey] : [...o.modelValue].reverse()[0] === f[o.optionValueKey] : ((B = (z = Q.value) == null ? void 0 : z[0]) == null ? void 0 : B[o.optionValueKey]) === f[o.optionValueKey];
|
|
940
|
+
});
|
|
941
|
+
h.value = d && d >= 0 ? d : 0;
|
|
942
|
+
}
|
|
943
|
+
function Pe(l, d = !0) {
|
|
944
|
+
var B;
|
|
945
|
+
d && !o.multiple && de(() => le()), J.value = "";
|
|
946
|
+
const u = (B = Q.value) == null ? void 0 : B.some(
|
|
947
|
+
(D) => D[o.optionValueKey] === l[o.optionValueKey]
|
|
948
|
+
);
|
|
949
|
+
let f = Q.value;
|
|
950
|
+
u && o.multiple ? f = f == null ? void 0 : f.filter(
|
|
951
|
+
(D) => D[o.optionValueKey] !== l[o.optionValueKey]
|
|
952
|
+
) : o.multiple ? f.push(l) : f = [l];
|
|
953
|
+
const z = f.map((D) => D[o.optionValueKey]);
|
|
954
|
+
i("update:model-value", o.multiple ? z : z[0]), i("selected-option", l), qe(), he(l), Ve();
|
|
955
|
+
}
|
|
956
|
+
return (l, d) => Ie((b(), S(
|
|
957
|
+
"div",
|
|
958
|
+
{
|
|
959
|
+
ref_key: "mazSelectElement",
|
|
960
|
+
ref: H,
|
|
961
|
+
class: O(["m-select", [
|
|
962
|
+
{ "--is-open": p.value, "--disabled": l.disabled, "--block": l.block },
|
|
963
|
+
o.class,
|
|
964
|
+
`--${l.size}`
|
|
965
|
+
]]),
|
|
966
|
+
style: x([l.style, { "--keyboard-selected-bg-color": m.value, "--selected-bg-color": A.value, "--selected-text-color": c.value }])
|
|
967
|
+
},
|
|
968
|
+
[
|
|
969
|
+
U(ze, ee({
|
|
970
|
+
id: I(E),
|
|
971
|
+
ref_key: "mazInputComponent",
|
|
972
|
+
ref: N,
|
|
973
|
+
class: "m-select-input"
|
|
974
|
+
}, l.$attrs, {
|
|
975
|
+
required: l.required,
|
|
976
|
+
"border-active": C.value,
|
|
977
|
+
color: l.color,
|
|
978
|
+
"model-value": te.value,
|
|
979
|
+
size: l.size,
|
|
980
|
+
block: "",
|
|
981
|
+
autocomplete: l.autocomplete,
|
|
982
|
+
disabled: l.disabled,
|
|
983
|
+
onFocus: ae(re, ["prevent", "stop"]),
|
|
984
|
+
onBlur: ae(le, ["prevent", "stop"]),
|
|
985
|
+
onClick: ae(re, ["prevent", "stop"]),
|
|
986
|
+
onChange: d[0] || (d[0] = (u) => i("change", u)),
|
|
987
|
+
onInput: d[1] || (d[1] = (u) => i("input", u)),
|
|
988
|
+
onKeydown: Qe
|
|
989
|
+
}), {
|
|
990
|
+
"right-icon": W(() => [
|
|
991
|
+
q("button", {
|
|
992
|
+
tabindex: "-1",
|
|
993
|
+
type: "button",
|
|
994
|
+
class: "m-select-input__toggle-button maz-custom",
|
|
995
|
+
"aria-label": `${p.value ? "collapse" : "expand"} list of options`,
|
|
996
|
+
onClick: ae(je, ["stop"])
|
|
997
|
+
}, [
|
|
998
|
+
U(I(v), { class: "m-select-chevron maz-text-xl" })
|
|
999
|
+
], 8, Fo)
|
|
1000
|
+
]),
|
|
1001
|
+
_: 1
|
|
1002
|
+
/* STABLE */
|
|
1003
|
+
}, 16, ["id", "required", "border-active", "color", "model-value", "size", "autocomplete", "disabled"]),
|
|
1004
|
+
U(ao, { name: pe.value }, {
|
|
1005
|
+
default: W(() => [
|
|
1006
|
+
p.value ? (b(), S(
|
|
1007
|
+
"div",
|
|
1008
|
+
{
|
|
1009
|
+
key: 0,
|
|
1010
|
+
ref_key: "optionsListElement",
|
|
1011
|
+
ref: w,
|
|
1012
|
+
class: O(["m-select-list", {
|
|
1013
|
+
"--top": l.listPosition.includes("top"),
|
|
1014
|
+
"--left": l.listPosition.includes("left"),
|
|
1015
|
+
"--right": l.listPosition.includes("right"),
|
|
1016
|
+
"--bottom": l.listPosition.includes("bottom")
|
|
1017
|
+
}]),
|
|
1018
|
+
style: x({
|
|
1019
|
+
maxHeight: `${l.maxListHeight}px`,
|
|
1020
|
+
maxWidth: `${l.maxListWidth}px`,
|
|
1021
|
+
minHeight: `${l.minListHeight}px`,
|
|
1022
|
+
minWidth: `${l.minListWidth}px`
|
|
1023
|
+
})
|
|
1024
|
+
},
|
|
1025
|
+
[
|
|
1026
|
+
l.search ? (b(), K(ze, {
|
|
1027
|
+
key: 0,
|
|
1028
|
+
ref_key: "searchInputComponent",
|
|
1029
|
+
ref: n,
|
|
1030
|
+
modelValue: J.value,
|
|
1031
|
+
"onUpdate:modelValue": [
|
|
1032
|
+
d[2] || (d[2] = (u) => J.value = u),
|
|
1033
|
+
d[4] || (d[4] = (u) => h.value = 0)
|
|
1034
|
+
],
|
|
1035
|
+
size: "sm",
|
|
1036
|
+
color: l.color,
|
|
1037
|
+
placeholder: l.searchPlaceholder,
|
|
1038
|
+
name: "search",
|
|
1039
|
+
inputmode: "search",
|
|
1040
|
+
block: "",
|
|
1041
|
+
autocomplete: "off",
|
|
1042
|
+
tabindex: "-1",
|
|
1043
|
+
class: "m-select-list__search-input maz-flex-none",
|
|
1044
|
+
"left-icon": I(g),
|
|
1045
|
+
onKeydown: d[3] || (d[3] = (u) => ke(u, !1))
|
|
1046
|
+
}, null, 8, ["modelValue", "color", "placeholder", "left-icon"])) : V("v-if", !0),
|
|
1047
|
+
!Y.value || Y.value.length <= 0 ? F(l.$slots, "no-results", { key: 1 }, () => [
|
|
1048
|
+
q("span", No, [
|
|
1049
|
+
U(I(L), { class: "maz-h-6 maz-w-6 maz-text-normal" })
|
|
1050
|
+
])
|
|
1051
|
+
], !0) : (b(), S("div", Ko, [
|
|
1052
|
+
(b(!0), S(
|
|
1053
|
+
Ce,
|
|
1054
|
+
null,
|
|
1055
|
+
Oe(Y.value, (u, f) => (b(), S(
|
|
1056
|
+
Ce,
|
|
1057
|
+
{ key: f },
|
|
1058
|
+
[
|
|
1059
|
+
u.label && u.isOptGroup ? F(l.$slots, "optgroup", {
|
|
1060
|
+
key: 0,
|
|
1061
|
+
label: u.label
|
|
1062
|
+
}, () => [
|
|
1063
|
+
q(
|
|
1064
|
+
"span",
|
|
1065
|
+
Uo,
|
|
1066
|
+
_(u.label),
|
|
1067
|
+
1
|
|
1068
|
+
/* TEXT */
|
|
1069
|
+
)
|
|
1070
|
+
], !0) : (b(), S("button", {
|
|
1071
|
+
key: 1,
|
|
1072
|
+
tabindex: "-1",
|
|
1073
|
+
type: "button",
|
|
1074
|
+
class: O(["m-select-list-item maz-custom maz-flex-none", [
|
|
1075
|
+
{
|
|
1076
|
+
"--is-keyboard-selected": h.value === f,
|
|
1077
|
+
"--is-selected": P(u),
|
|
1078
|
+
"--is-none-value": $(u[l.optionValueKey])
|
|
1079
|
+
}
|
|
1080
|
+
]]),
|
|
1081
|
+
style: x(l.itemHeight ? { height: `${l.itemHeight}px` } : void 0),
|
|
1082
|
+
onClick: ae((z) => Pe(u), ["prevent", "stop"])
|
|
1083
|
+
}, [
|
|
1084
|
+
l.multiple ? (b(), K(I(r), {
|
|
1085
|
+
key: 0,
|
|
1086
|
+
tabindex: "-1",
|
|
1087
|
+
"model-value": P(u),
|
|
1088
|
+
size: "sm",
|
|
1089
|
+
color: l.color
|
|
1090
|
+
}, null, 8, ["model-value", "color"])) : V("v-if", !0),
|
|
1091
|
+
F(l.$slots, "default", {
|
|
1092
|
+
option: u,
|
|
1093
|
+
isSelected: P(u)
|
|
1094
|
+
}, () => [
|
|
1095
|
+
q(
|
|
1096
|
+
"span",
|
|
1097
|
+
null,
|
|
1098
|
+
_(u[l.optionLabelKey]),
|
|
1099
|
+
1
|
|
1100
|
+
/* TEXT */
|
|
1101
|
+
)
|
|
1102
|
+
], !0)
|
|
1103
|
+
], 14, Ho))
|
|
1104
|
+
],
|
|
1105
|
+
64
|
|
1106
|
+
/* STABLE_FRAGMENT */
|
|
1107
|
+
))),
|
|
1108
|
+
128
|
|
1109
|
+
/* KEYED_FRAGMENT */
|
|
1110
|
+
))
|
|
1111
|
+
]))
|
|
1112
|
+
],
|
|
1113
|
+
6
|
|
1114
|
+
/* CLASS, STYLE */
|
|
1115
|
+
)) : V("v-if", !0)
|
|
1116
|
+
]),
|
|
1117
|
+
_: 3
|
|
1118
|
+
/* FORWARDED */
|
|
1119
|
+
}, 8, ["name"])
|
|
1120
|
+
],
|
|
1121
|
+
6
|
|
1122
|
+
/* CLASS, STYLE */
|
|
1123
|
+
)), [
|
|
1124
|
+
[I(ko), {
|
|
1125
|
+
exclude: l.excludeSelectors,
|
|
1126
|
+
handler: le
|
|
1127
|
+
}]
|
|
1128
|
+
]);
|
|
1129
|
+
}
|
|
1130
|
+
}), Ro = /* @__PURE__ */ ne(Do, [["__scopeId", "data-v-07cbef8c"]]);
|
|
1131
|
+
function He() {
|
|
1132
|
+
if (typeof window > "u")
|
|
1133
|
+
return;
|
|
1134
|
+
const a = window.navigator.language;
|
|
1135
|
+
if (!a)
|
|
1136
|
+
return;
|
|
1137
|
+
let e = a.slice(3, 7).toUpperCase();
|
|
1138
|
+
return e === "" && (e = a.slice(0, 2).toUpperCase()), e === "EN" && (e = "US"), e === "JA" && (e = "JP"), {
|
|
1139
|
+
locale: e,
|
|
1140
|
+
browserLocale: a
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
let be, $e;
|
|
1144
|
+
function qo(a, e, t) {
|
|
1145
|
+
return t != null && t[e] ? t[e] : (($e !== a || !be) && ($e = a, be = new Intl.DisplayNames([a], { type: "region" })), be.of(e));
|
|
1146
|
+
}
|
|
1147
|
+
function jo(a, e) {
|
|
1148
|
+
var i;
|
|
1149
|
+
const t = [], o = Me();
|
|
1150
|
+
a = a ?? ((i = He()) == null ? void 0 : i.browserLocale) ?? "en-US";
|
|
1151
|
+
for (const r of o) {
|
|
1152
|
+
const g = qo(a, r, e);
|
|
1153
|
+
if (g)
|
|
1154
|
+
try {
|
|
1155
|
+
const v = ce(r);
|
|
1156
|
+
t.push({
|
|
1157
|
+
iso2: r,
|
|
1158
|
+
dialCode: v,
|
|
1159
|
+
name: g
|
|
1160
|
+
});
|
|
1161
|
+
} catch (v) {
|
|
1162
|
+
console.error(`[MazPhoneNumberInput](getCountryCallingCode) ${v}`);
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
return t;
|
|
1166
|
+
}
|
|
1167
|
+
async function Yo() {
|
|
1168
|
+
try {
|
|
1169
|
+
const a = await fetch("https://ipwho.is"), { country_code: e } = await a.json();
|
|
1170
|
+
return e;
|
|
1171
|
+
} catch (a) {
|
|
1172
|
+
throw new Error(`[MazPhoneNumberInput](fetchCountryCode) ${a}`);
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
function Wo(a) {
|
|
1176
|
+
if (!a)
|
|
1177
|
+
return "";
|
|
1178
|
+
const e = new RegExp(/[^\d ()+-]/g);
|
|
1179
|
+
return a.replaceAll(e, "").trim();
|
|
1180
|
+
}
|
|
1181
|
+
function Se() {
|
|
1182
|
+
return {
|
|
1183
|
+
sanitizePhoneNumber: Wo,
|
|
1184
|
+
fetchCountryCode: Yo,
|
|
1185
|
+
getBrowserLocale: He,
|
|
1186
|
+
getCountriesList: jo
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
const Qo = ["id"], Go = {
|
|
1190
|
+
key: 0,
|
|
1191
|
+
class: "m-country-selector__select__item__flag-container"
|
|
1192
|
+
}, Jo = /* @__PURE__ */ se({
|
|
1193
|
+
__name: "CountrySelector",
|
|
1194
|
+
props: {
|
|
1195
|
+
style: { default: void 0 },
|
|
1196
|
+
class: { default: void 0 },
|
|
1197
|
+
modelValue: { default: void 0 },
|
|
1198
|
+
id: {},
|
|
1199
|
+
color: {},
|
|
1200
|
+
size: {},
|
|
1201
|
+
preferredCountries: { default: void 0 },
|
|
1202
|
+
ignoredCountries: { default: void 0 },
|
|
1203
|
+
onlyCountries: { default: void 0 },
|
|
1204
|
+
customCountriesList: { default: void 0 },
|
|
1205
|
+
locales: {},
|
|
1206
|
+
listPosition: { default: "bottom left" },
|
|
1207
|
+
noFlags: { type: Boolean },
|
|
1208
|
+
noSearch: { type: Boolean },
|
|
1209
|
+
disabled: { type: Boolean },
|
|
1210
|
+
showCodeOnList: { type: Boolean },
|
|
1211
|
+
countryLocale: { default: void 0 },
|
|
1212
|
+
success: { type: Boolean },
|
|
1213
|
+
error: { type: Boolean },
|
|
1214
|
+
countrySelectorDisplayName: { type: Boolean },
|
|
1215
|
+
searchThreshold: {},
|
|
1216
|
+
width: { default: "9rem" },
|
|
1217
|
+
excludeSelectors: { default: void 0 }
|
|
1218
|
+
},
|
|
1219
|
+
emits: ["update:model-value"],
|
|
1220
|
+
setup(a) {
|
|
1221
|
+
const e = a, { phoneNumber: t } = Fe("data"), o = k(), { getCountriesList: i } = Se(), r = y(() => i(e.countryLocale, e.customCountriesList)), g = y(
|
|
1222
|
+
() => {
|
|
1223
|
+
var c;
|
|
1224
|
+
return (c = r.value) == null ? void 0 : c.filter((A) => {
|
|
1225
|
+
var m;
|
|
1226
|
+
return !((m = e.ignoredCountries) != null && m.includes(A.iso2));
|
|
1227
|
+
});
|
|
1228
|
+
}
|
|
1229
|
+
), v = y(() => {
|
|
1230
|
+
const c = e.onlyCountries || e.preferredCountries;
|
|
1231
|
+
return c == null ? void 0 : c.map(
|
|
1232
|
+
(A) => {
|
|
1233
|
+
var m;
|
|
1234
|
+
return (m = g.value) == null ? void 0 : m.find((p) => p.iso2.includes(A));
|
|
1235
|
+
}
|
|
1236
|
+
);
|
|
1237
|
+
}), L = y(
|
|
1238
|
+
() => {
|
|
1239
|
+
var c;
|
|
1240
|
+
return (c = g.value) == null ? void 0 : c.filter((A) => {
|
|
1241
|
+
var m;
|
|
1242
|
+
return !((m = e.preferredCountries) != null && m.includes(A.iso2));
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
), C = y(
|
|
1246
|
+
() => e.preferredCountries ? [...v.value ?? [], ...L.value ?? []] : e.onlyCountries ? v.value : g.value
|
|
1247
|
+
), h = y(
|
|
1248
|
+
() => {
|
|
1249
|
+
var c;
|
|
1250
|
+
return (c = C.value) == null ? void 0 : c.map(
|
|
1251
|
+
(A) => A ? {
|
|
1252
|
+
...A,
|
|
1253
|
+
dialCode: `+${A.dialCode}`
|
|
1254
|
+
} : void 0
|
|
1255
|
+
).filter(po);
|
|
1256
|
+
}
|
|
1257
|
+
);
|
|
1258
|
+
function T() {
|
|
1259
|
+
var c;
|
|
1260
|
+
(c = o.value) == null || c.openList();
|
|
1261
|
+
}
|
|
1262
|
+
return (c, A) => (b(), S(
|
|
1263
|
+
"div",
|
|
1264
|
+
{
|
|
1265
|
+
class: O(["m-country-selector", [e.class, { "--no-flags": c.noFlags }]]),
|
|
1266
|
+
style: x(c.style)
|
|
1267
|
+
},
|
|
1268
|
+
[
|
|
1269
|
+
c.modelValue && !c.noFlags ? (b(), S("button", {
|
|
1270
|
+
key: 0,
|
|
1271
|
+
id: `country-selector-flag-button-${c.id}`,
|
|
1272
|
+
class: O(["m-country-selector__country-flag", {
|
|
1273
|
+
"--should-have-bottom-flag": c.locales.countrySelector.placeholder.length > 0
|
|
1274
|
+
}]),
|
|
1275
|
+
tabindex: "-1",
|
|
1276
|
+
type: "button",
|
|
1277
|
+
onClick: T
|
|
1278
|
+
}, [
|
|
1279
|
+
F(c.$slots, "selector-flag", { countryCode: c.modelValue }, () => [
|
|
1280
|
+
U(Ee, {
|
|
1281
|
+
src: I(Le)(c.modelValue, "h20"),
|
|
1282
|
+
alt: c.modelValue,
|
|
1283
|
+
width: "20",
|
|
1284
|
+
height: "20",
|
|
1285
|
+
"img-class": "maz-w-5 maz-h-4 maz-rounded-sm"
|
|
1286
|
+
}, null, 8, ["src", "alt"])
|
|
1287
|
+
], !0)
|
|
1288
|
+
], 10, Qo)) : V("v-if", !0),
|
|
1289
|
+
U(Ro, ee({
|
|
1290
|
+
id: `country-selector-${c.id}`,
|
|
1291
|
+
ref_key: "CountrySelectorRef",
|
|
1292
|
+
ref: o,
|
|
1293
|
+
"model-value": c.modelValue
|
|
1294
|
+
}, { ...c.$attrs }, {
|
|
1295
|
+
class: "m-country-selector__select",
|
|
1296
|
+
"option-value-key": "iso2",
|
|
1297
|
+
"option-label-key": "name",
|
|
1298
|
+
"option-input-value-key": c.countrySelectorDisplayName ? "name" : "dialCode",
|
|
1299
|
+
name: "country",
|
|
1300
|
+
"max-list-width": 250,
|
|
1301
|
+
"min-list-width": 200,
|
|
1302
|
+
disabled: c.disabled,
|
|
1303
|
+
color: c.color,
|
|
1304
|
+
size: c.size,
|
|
1305
|
+
error: c.error,
|
|
1306
|
+
"list-position": c.listPosition,
|
|
1307
|
+
"item-height": 38,
|
|
1308
|
+
success: c.success,
|
|
1309
|
+
search: !c.noSearch,
|
|
1310
|
+
"search-placeholder": c.locales.countrySelector.searchPlaceholder,
|
|
1311
|
+
"search-threshold": c.searchThreshold,
|
|
1312
|
+
options: h.value,
|
|
1313
|
+
hint: I(t) && !c.modelValue ? c.locales.countrySelector.error : void 0,
|
|
1314
|
+
label: c.locales.countrySelector.placeholder,
|
|
1315
|
+
style: {
|
|
1316
|
+
width: c.width
|
|
1317
|
+
},
|
|
1318
|
+
"exclude-selectors": [`#country-selector-flag-button-${c.id}`, ...c.excludeSelectors ?? []],
|
|
1319
|
+
"onUpdate:modelValue": A[0] || (A[0] = (m) => c.$emit("update:model-value", m))
|
|
1320
|
+
}), {
|
|
1321
|
+
"no-results": W(() => [
|
|
1322
|
+
F(c.$slots, "no-results", {}, void 0, !0)
|
|
1323
|
+
]),
|
|
1324
|
+
default: W(({ option: m, isSelected: p }) => [
|
|
1325
|
+
q(
|
|
1326
|
+
"div",
|
|
1327
|
+
{
|
|
1328
|
+
class: O(["m-country-selector__select__item", {
|
|
1329
|
+
"m-country-selector__select__item--selected": p
|
|
1330
|
+
}])
|
|
1331
|
+
},
|
|
1332
|
+
[
|
|
1333
|
+
!c.noFlags && typeof m.iso2 == "string" ? (b(), S("span", Go, [
|
|
1334
|
+
F(c.$slots, "country-list-flag", {
|
|
1335
|
+
countryCode: m.iso2,
|
|
1336
|
+
option: m,
|
|
1337
|
+
isSelected: p
|
|
1338
|
+
}, () => [
|
|
1339
|
+
U(Ee, {
|
|
1340
|
+
src: I(Le)(m.iso2, "h20"),
|
|
1341
|
+
alt: `${m.name} flag`,
|
|
1342
|
+
width: "20",
|
|
1343
|
+
height: "20",
|
|
1344
|
+
"img-class": "maz-rounded-full maz-w-5 maz-h-5"
|
|
1345
|
+
}, null, 8, ["src", "alt"])
|
|
1346
|
+
], !0)
|
|
1347
|
+
])) : V("v-if", !0),
|
|
1348
|
+
c.showCodeOnList ? (b(), S(
|
|
1349
|
+
"span",
|
|
1350
|
+
{
|
|
1351
|
+
key: 1,
|
|
1352
|
+
class: O(["maz-w-9 maz-flex-none", { "maz-text-muted": !p }])
|
|
1353
|
+
},
|
|
1354
|
+
_(m.dialCode),
|
|
1355
|
+
3
|
|
1356
|
+
/* TEXT, CLASS */
|
|
1357
|
+
)) : V("v-if", !0),
|
|
1358
|
+
q(
|
|
1359
|
+
"span",
|
|
1360
|
+
{
|
|
1361
|
+
class: O(["maz-flex-1 maz-truncate", { "maz-font-semibold": p }])
|
|
1362
|
+
},
|
|
1363
|
+
_(m.name),
|
|
1364
|
+
3
|
|
1365
|
+
/* TEXT, CLASS */
|
|
1366
|
+
)
|
|
1367
|
+
],
|
|
1368
|
+
2
|
|
1369
|
+
/* CLASS */
|
|
1370
|
+
)
|
|
1371
|
+
]),
|
|
1372
|
+
_: 3
|
|
1373
|
+
/* FORWARDED */
|
|
1374
|
+
}, 16, ["id", "model-value", "option-input-value-key", "disabled", "color", "size", "error", "list-position", "success", "search", "search-placeholder", "search-threshold", "options", "hint", "label", "style", "exclude-selectors"])
|
|
1375
|
+
],
|
|
1376
|
+
6
|
|
1377
|
+
/* CLASS, STYLE */
|
|
1378
|
+
));
|
|
1379
|
+
}
|
|
1380
|
+
}), Zo = /* @__PURE__ */ ne(Jo, [["__scopeId", "data-v-e2fee821"]]), Xo = {
|
|
1381
|
+
countrySelector: {
|
|
1382
|
+
placeholder: "Country code",
|
|
1383
|
+
error: "Choose country",
|
|
1384
|
+
searchPlaceholder: "Search the country"
|
|
1385
|
+
},
|
|
1386
|
+
phoneInput: {
|
|
1387
|
+
placeholder: "Phone number",
|
|
1388
|
+
example: "Example:"
|
|
1389
|
+
}
|
|
1390
|
+
}, ie = k();
|
|
1391
|
+
function xo(a) {
|
|
1392
|
+
try {
|
|
1393
|
+
const e = io(a);
|
|
1394
|
+
return e || (console.error(`[maz-ui](MazPhoneNumberInput) The code country "${a}" is not available`), !1);
|
|
1395
|
+
} catch (e) {
|
|
1396
|
+
return console.error(`[maz-ui](MazPhoneNumberInput) ${e}`), !1;
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
function _o({
|
|
1400
|
+
phoneNumber: a,
|
|
1401
|
+
countryCode: e,
|
|
1402
|
+
checkCountryCode: t = !1
|
|
1403
|
+
}) {
|
|
1404
|
+
try {
|
|
1405
|
+
if (!a)
|
|
1406
|
+
return {
|
|
1407
|
+
isValid: !1,
|
|
1408
|
+
countryCode: e
|
|
1409
|
+
};
|
|
1410
|
+
const o = uo(a, e ?? void 0), i = (o == null ? void 0 : o.isValid()) ?? !1, r = e && t ? (o == null ? void 0 : o.country) && e === o.country : !0;
|
|
1411
|
+
return {
|
|
1412
|
+
isValid: i && !!r,
|
|
1413
|
+
countryCode: e,
|
|
1414
|
+
parsedCountryCode: o == null ? void 0 : o.country,
|
|
1415
|
+
isPossible: o == null ? void 0 : o.isPossible(),
|
|
1416
|
+
countryCallingCode: o == null ? void 0 : o.countryCallingCode,
|
|
1417
|
+
nationalNumber: o == null ? void 0 : o.nationalNumber,
|
|
1418
|
+
type: o == null ? void 0 : o.getType(),
|
|
1419
|
+
formatInternational: o == null ? void 0 : o.formatInternational(),
|
|
1420
|
+
formatNational: o == null ? void 0 : o.formatNational(),
|
|
1421
|
+
uri: o == null ? void 0 : o.getURI(),
|
|
1422
|
+
e164: o == null ? void 0 : o.format("E.164"),
|
|
1423
|
+
rfc3966: o == null ? void 0 : o.format("RFC3966"),
|
|
1424
|
+
possibleCountries: o == null ? void 0 : o.getPossibleCountries(),
|
|
1425
|
+
phoneNumber: a
|
|
1426
|
+
};
|
|
1427
|
+
} catch (o) {
|
|
1428
|
+
throw new Error(`[MazPhoneNumberInput](getResultsFromPhoneNumber) ${o}`);
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
async function De() {
|
|
1432
|
+
const { default: a } = await import("./examples.mobile.json-tW3aL0qI.mjs");
|
|
1433
|
+
return a;
|
|
1434
|
+
}
|
|
1435
|
+
function et(a) {
|
|
1436
|
+
var e;
|
|
1437
|
+
try {
|
|
1438
|
+
return ie.value && a ? (e = co(a, ie.value)) == null ? void 0 : e.formatNational() : void 0;
|
|
1439
|
+
} catch (t) {
|
|
1440
|
+
console.error(`[maz-ui](MazPhoneNumberInput) ${t}`);
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
function ot(a, e) {
|
|
1444
|
+
try {
|
|
1445
|
+
return !e || !a ? void 0 : new mo(a).input(e);
|
|
1446
|
+
} catch (t) {
|
|
1447
|
+
throw new Error(`[MazPhoneNumberInput](getAsYouTypeFormat) ${t}`);
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
function tt(a, e) {
|
|
1451
|
+
return ce(a) === ce(e);
|
|
1452
|
+
}
|
|
1453
|
+
async function lt() {
|
|
1454
|
+
try {
|
|
1455
|
+
if (ie.value)
|
|
1456
|
+
return;
|
|
1457
|
+
ie.value = await De();
|
|
1458
|
+
} catch (a) {
|
|
1459
|
+
console.error("[maz-ui](MazPhoneNumberInput) while loading phone number examples file", a);
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
function Re() {
|
|
1463
|
+
return {
|
|
1464
|
+
examples: ie,
|
|
1465
|
+
getAsYouTypeFormat: ot,
|
|
1466
|
+
getPhoneNumberResults: _o,
|
|
1467
|
+
getPhoneNumberExamplesFile: De,
|
|
1468
|
+
getPhoneNumberExample: et,
|
|
1469
|
+
isSameCountryCallingCode: tt,
|
|
1470
|
+
isCountryAvailable: xo,
|
|
1471
|
+
getCountries: Me,
|
|
1472
|
+
getCountryCallingCode: ce,
|
|
1473
|
+
loadExamples: lt
|
|
1474
|
+
};
|
|
1475
|
+
}
|
|
1476
|
+
const at = /* @__PURE__ */ se({
|
|
1477
|
+
__name: "PhoneInput",
|
|
1478
|
+
props: /* @__PURE__ */ so({
|
|
1479
|
+
id: {},
|
|
1480
|
+
locales: {},
|
|
1481
|
+
noExample: { type: Boolean },
|
|
1482
|
+
hasRadius: { type: Boolean },
|
|
1483
|
+
autoFormat: { type: Boolean },
|
|
1484
|
+
style: {},
|
|
1485
|
+
class: {},
|
|
1486
|
+
placeholder: {},
|
|
1487
|
+
label: {},
|
|
1488
|
+
topLabel: {},
|
|
1489
|
+
assistiveText: {},
|
|
1490
|
+
name: {},
|
|
1491
|
+
color: {},
|
|
1492
|
+
type: {},
|
|
1493
|
+
required: { type: Boolean },
|
|
1494
|
+
disabled: { type: Boolean },
|
|
1495
|
+
readonly: { type: Boolean },
|
|
1496
|
+
error: { type: Boolean },
|
|
1497
|
+
success: { type: Boolean },
|
|
1498
|
+
warning: { type: Boolean },
|
|
1499
|
+
hint: {},
|
|
1500
|
+
inputClasses: {},
|
|
1501
|
+
noBorder: { type: Boolean },
|
|
1502
|
+
noRadius: { type: Boolean },
|
|
1503
|
+
inputmode: {},
|
|
1504
|
+
size: {},
|
|
1505
|
+
debounce: { type: [Boolean, Number] },
|
|
1506
|
+
debounceDelay: {},
|
|
1507
|
+
validButton: { type: Boolean },
|
|
1508
|
+
validButtonLoading: { type: Boolean },
|
|
1509
|
+
autoFocus: { type: Boolean },
|
|
1510
|
+
borderActive: { type: Boolean },
|
|
1511
|
+
leftIcon: { type: [String, Function, Object] },
|
|
1512
|
+
rightIcon: { type: [String, Function, Object] },
|
|
1513
|
+
roundedSize: {},
|
|
1514
|
+
block: { type: Boolean },
|
|
1515
|
+
autocomplete: {}
|
|
1516
|
+
}, {
|
|
1517
|
+
modelValue: {},
|
|
1518
|
+
modelModifiers: {}
|
|
1519
|
+
}),
|
|
1520
|
+
emits: ["update:modelValue"],
|
|
1521
|
+
setup(a) {
|
|
1522
|
+
const { getPhoneNumberExample: e, getAsYouTypeFormat: t, loadExamples: o } = Re(), { sanitizePhoneNumber: i } = Se(), { results: r, selectedCountry: g } = Fe("data"), v = no(a, "modelValue"), L = y(() => {
|
|
1523
|
+
const m = r.value.isValid ? r.value.formatNational : v.value;
|
|
1524
|
+
return t(g.value, m) || m;
|
|
1525
|
+
}), C = k(!1), h = y({
|
|
1526
|
+
get: () => !C.value && a.autoFormat ? L.value : v.value,
|
|
1527
|
+
set: (m) => {
|
|
1528
|
+
v.value = i(m);
|
|
1529
|
+
}
|
|
1530
|
+
});
|
|
1531
|
+
function T(m) {
|
|
1532
|
+
const p = e(m);
|
|
1533
|
+
return p ? `${a.locales.phoneInput.example} ${p}` : void 0;
|
|
1534
|
+
}
|
|
1535
|
+
const c = y(() => {
|
|
1536
|
+
var p;
|
|
1537
|
+
if (a.label || a.placeholder)
|
|
1538
|
+
return a.label || a.placeholder;
|
|
1539
|
+
const m = a.locales.phoneInput.placeholder;
|
|
1540
|
+
if (a.noExample || !C.value)
|
|
1541
|
+
return m;
|
|
1542
|
+
{
|
|
1543
|
+
const E = T(g.value);
|
|
1544
|
+
return (p = r.value) != null && p.isValid || !E ? m : E;
|
|
1545
|
+
}
|
|
1546
|
+
}), A = y(() => a.placeholder ? { placeholder: c.value } : { label: c.value });
|
|
1547
|
+
return Ae(() => {
|
|
1548
|
+
a.noExample || o();
|
|
1549
|
+
}), (m, p) => (b(), K(ze, ee({
|
|
1550
|
+
id: m.id,
|
|
1551
|
+
modelValue: h.value,
|
|
1552
|
+
"onUpdate:modelValue": p[0] || (p[0] = (E) => h.value = E)
|
|
1553
|
+
}, { ...m.$attrs, ...A.value }, {
|
|
1554
|
+
disabled: m.disabled,
|
|
1555
|
+
color: m.color,
|
|
1556
|
+
error: m.error,
|
|
1557
|
+
size: m.size,
|
|
1558
|
+
success: m.success,
|
|
1559
|
+
name: m.name,
|
|
1560
|
+
inputmode: m.inputmode,
|
|
1561
|
+
autocomplete: m.autocomplete,
|
|
1562
|
+
class: ["m-phone-input", [
|
|
1563
|
+
{
|
|
1564
|
+
"--border-radius": m.hasRadius,
|
|
1565
|
+
"--error": m.error || !I(r).isValid,
|
|
1566
|
+
"--focused": C.value
|
|
1567
|
+
}
|
|
1568
|
+
]],
|
|
1569
|
+
onFocus: p[1] || (p[1] = (E) => C.value = !0),
|
|
1570
|
+
onBlur: p[2] || (p[2] = (E) => C.value = !1)
|
|
1571
|
+
}), null, 16, ["id", "modelValue", "disabled", "color", "error", "size", "success", "name", "inputmode", "autocomplete", "class"]));
|
|
1572
|
+
}
|
|
1573
|
+
}), st = /* @__PURE__ */ ne(at, [["__scopeId", "data-v-a447a345"]]), nt = /* @__PURE__ */ se({
|
|
1574
|
+
name: "MazPhoneNumberInput",
|
|
1575
|
+
inheritAttrs: !1,
|
|
1576
|
+
__name: "MazPhoneNumberInput",
|
|
1577
|
+
props: {
|
|
1578
|
+
style: { default: void 0 },
|
|
1579
|
+
class: { default: void 0 },
|
|
1580
|
+
modelValue: { default: void 0 },
|
|
1581
|
+
defaultPhoneNumber: { default: void 0 },
|
|
1582
|
+
countryCode: { default: void 0 },
|
|
1583
|
+
defaultCountryCode: { default: void 0 },
|
|
1584
|
+
id: { default: void 0 },
|
|
1585
|
+
placeholder: { default: void 0 },
|
|
1586
|
+
label: { default: void 0 },
|
|
1587
|
+
preferredCountries: { default: void 0 },
|
|
1588
|
+
ignoredCountries: { default: void 0 },
|
|
1589
|
+
onlyCountries: { default: void 0 },
|
|
1590
|
+
translations: { default: void 0 },
|
|
1591
|
+
listPosition: { default: "bottom left" },
|
|
1592
|
+
color: { default: "primary" },
|
|
1593
|
+
size: { default: "md" },
|
|
1594
|
+
noFlags: { type: Boolean },
|
|
1595
|
+
disabled: { type: Boolean },
|
|
1596
|
+
noExample: { type: Boolean, default: !1 },
|
|
1597
|
+
noSearch: { type: Boolean },
|
|
1598
|
+
searchThreshold: { default: 0.75 },
|
|
1599
|
+
noUseBrowserLocale: { type: Boolean },
|
|
1600
|
+
fetchCountry: { type: Boolean },
|
|
1601
|
+
noCountrySelector: { type: Boolean },
|
|
1602
|
+
showCodeOnList: { type: Boolean },
|
|
1603
|
+
customCountriesList: { default: void 0 },
|
|
1604
|
+
autoFormat: { type: Boolean, default: !0 },
|
|
1605
|
+
noFormattingAsYouType: { type: Boolean, default: !1 },
|
|
1606
|
+
countryLocale: { default: void 0 },
|
|
1607
|
+
noValidationError: { type: Boolean },
|
|
1608
|
+
noValidationSuccess: { type: Boolean },
|
|
1609
|
+
success: { type: Boolean },
|
|
1610
|
+
error: { type: Boolean },
|
|
1611
|
+
countrySelectorDisplayName: { type: Boolean },
|
|
1612
|
+
countrySelectorWidth: { default: "9rem" },
|
|
1613
|
+
block: { type: Boolean },
|
|
1614
|
+
excludeSelectors: { default: void 0 },
|
|
1615
|
+
orientation: { default: "responsive" },
|
|
1616
|
+
countrySelectAttributes: { default: () => ({
|
|
1617
|
+
name: "country",
|
|
1618
|
+
autocomplete: "off"
|
|
1619
|
+
}) },
|
|
1620
|
+
phoneInputAttributes: { default: () => ({
|
|
1621
|
+
name: "phone",
|
|
1622
|
+
autocomplete: "tel",
|
|
1623
|
+
inputmode: "tel"
|
|
1624
|
+
}) }
|
|
1625
|
+
},
|
|
1626
|
+
emits: ["update:model-value", "country-code", "update:country-code", "update", "data"],
|
|
1627
|
+
setup(a, { emit: e }) {
|
|
1628
|
+
const t = a, o = e, { fetchCountryCode: i, getBrowserLocale: r } = Se(), { isCountryAvailable: g, getPhoneNumberResults: v } = Re(), L = we({
|
|
1629
|
+
componentName: "MazPhoneNumberInput",
|
|
1630
|
+
providedId: t.id
|
|
1631
|
+
}), C = k(), h = k(), T = k(!1), c = k(!1), A = y(() => ({
|
|
1632
|
+
...Xo,
|
|
1633
|
+
...t.translations
|
|
1634
|
+
})), m = y(() => t.autoFormat && !t.noFormattingAsYouType), p = k({
|
|
1635
|
+
isValid: !1,
|
|
1636
|
+
countryCode: t.countryCode ?? t.defaultCountryCode,
|
|
1637
|
+
phoneNumber: t.modelValue
|
|
1638
|
+
}), E = k();
|
|
1639
|
+
Te(async () => {
|
|
1640
|
+
if (N({ countryCode: t.countryCode ?? t.defaultCountryCode }), t.fetchCountry && !h.value) {
|
|
1641
|
+
const n = await i();
|
|
1642
|
+
N({ countryCode: n });
|
|
1643
|
+
}
|
|
1644
|
+
}), Ae(() => {
|
|
1645
|
+
var n;
|
|
1646
|
+
if (!t.defaultCountryCode && !t.countryCode && !t.noUseBrowserLocale) {
|
|
1647
|
+
const w = (n = r()) == null ? void 0 : n.locale;
|
|
1648
|
+
N({ countryCode: w });
|
|
1649
|
+
}
|
|
1650
|
+
});
|
|
1651
|
+
function G({
|
|
1652
|
+
phone: n = C.value || t.modelValue,
|
|
1653
|
+
countryCode: w = h.value,
|
|
1654
|
+
checkCountryCode: $ = !1
|
|
1655
|
+
}) {
|
|
1656
|
+
p.value = v({
|
|
1657
|
+
phoneNumber: n,
|
|
1658
|
+
countryCode: w,
|
|
1659
|
+
checkCountryCode: $
|
|
1660
|
+
});
|
|
1661
|
+
}
|
|
1662
|
+
function oe() {
|
|
1663
|
+
var n;
|
|
1664
|
+
return (n = E.value) == null ? void 0 : n.$el.querySelector("input");
|
|
1665
|
+
}
|
|
1666
|
+
async function j() {
|
|
1667
|
+
var n;
|
|
1668
|
+
await de(), (n = oe()) == null || n.select();
|
|
1669
|
+
}
|
|
1670
|
+
function Q(n) {
|
|
1671
|
+
if (n) {
|
|
1672
|
+
if (!g(n)) {
|
|
1673
|
+
console.warn(`[MazPhoneNumberInput] Country code not available: "${n}"`), h.value = void 0;
|
|
1674
|
+
return;
|
|
1675
|
+
}
|
|
1676
|
+
h.value = n;
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
function H({
|
|
1680
|
+
newPhoneNumber: n
|
|
1681
|
+
}) {
|
|
1682
|
+
var w;
|
|
1683
|
+
G({ phone: n }), p.value.parsedCountryCode && p.value.parsedCountryCode !== h.value && N({
|
|
1684
|
+
countryCode: p.value.parsedCountryCode,
|
|
1685
|
+
updateResults: !1
|
|
1686
|
+
}), T.value = !0, p.value.isValid && m.value ? C.value = (w = p.value.formatNational) == null ? void 0 : w.trim().replaceAll(new RegExp(/\D/g), "") : C.value = n, p.value.e164 ? o("update:model-value", p.value.e164) : o("update:model-value", p.value.phoneNumber), setTimeout(() => {
|
|
1687
|
+
T.value = !1;
|
|
1688
|
+
}, 0);
|
|
1689
|
+
}
|
|
1690
|
+
function N({
|
|
1691
|
+
countryCode: n,
|
|
1692
|
+
updateResults: w = !0,
|
|
1693
|
+
selectPhoneNumber: $ = !1
|
|
1694
|
+
}) {
|
|
1695
|
+
if (!n) {
|
|
1696
|
+
h.value = void 0;
|
|
1697
|
+
return;
|
|
1698
|
+
}
|
|
1699
|
+
c.value = !0, n !== h.value && Q(n), w && G({
|
|
1700
|
+
countryCode: h.value,
|
|
1701
|
+
checkCountryCode: !0
|
|
1702
|
+
});
|
|
1703
|
+
const P = p.value.countryCode || p.value.parsedCountryCode;
|
|
1704
|
+
o("country-code", P), o("update:country-code", P), $ && !p.value.isValid && j(), setTimeout(() => {
|
|
1705
|
+
c.value = !1;
|
|
1706
|
+
}, 0);
|
|
1707
|
+
}
|
|
1708
|
+
return ye(
|
|
1709
|
+
() => t.modelValue ?? t.defaultPhoneNumber,
|
|
1710
|
+
(n, w) => {
|
|
1711
|
+
!T.value && n !== w && n !== C.value && H({ newPhoneNumber: n });
|
|
1712
|
+
},
|
|
1713
|
+
{ immediate: !0 }
|
|
1714
|
+
), ye(
|
|
1715
|
+
() => t.countryCode ?? t.defaultCountryCode,
|
|
1716
|
+
(n, w) => {
|
|
1717
|
+
!c.value && n && n !== w && n !== h.value && N({ countryCode: n });
|
|
1718
|
+
},
|
|
1719
|
+
{ immediate: !0 }
|
|
1720
|
+
), ye(
|
|
1721
|
+
p,
|
|
1722
|
+
(n) => {
|
|
1723
|
+
o("update", n), o("data", n);
|
|
1724
|
+
},
|
|
1725
|
+
{ immediate: !0 }
|
|
1726
|
+
), ro("data", {
|
|
1727
|
+
selectedCountry: h,
|
|
1728
|
+
phoneNumber: C,
|
|
1729
|
+
results: p
|
|
1730
|
+
}), (n, w) => {
|
|
1731
|
+
var $;
|
|
1732
|
+
return b(), S(
|
|
1733
|
+
"div",
|
|
1734
|
+
{
|
|
1735
|
+
class: O(["m-phone-number-input", [t.class, { "--block": n.block }, n.orientation ? `--${n.orientation}` : void 0]]),
|
|
1736
|
+
style: x(n.style)
|
|
1737
|
+
},
|
|
1738
|
+
[
|
|
1739
|
+
n.noCountrySelector ? V("v-if", !0) : (b(), K(Zo, ee({
|
|
1740
|
+
key: 0,
|
|
1741
|
+
id: I(L)
|
|
1742
|
+
}, n.countrySelectAttributes, {
|
|
1743
|
+
"model-value": h.value,
|
|
1744
|
+
color: n.color,
|
|
1745
|
+
size: n.size,
|
|
1746
|
+
"country-locale": n.countryLocale,
|
|
1747
|
+
"country-selector-display-name": n.countrySelectorDisplayName,
|
|
1748
|
+
"custom-countries-list": n.customCountriesList,
|
|
1749
|
+
"ignored-countries": n.ignoredCountries,
|
|
1750
|
+
"list-position": n.listPosition,
|
|
1751
|
+
"no-flags": n.noFlags,
|
|
1752
|
+
"no-search": n.noSearch,
|
|
1753
|
+
"exclude-selectors": n.excludeSelectors,
|
|
1754
|
+
error: n.error || (n.noValidationError ? !1 : !!C.value && !h.value),
|
|
1755
|
+
success: n.success || (n.noValidationSuccess ? !1 : ($ = p.value) == null ? void 0 : $.isValid),
|
|
1756
|
+
locales: A.value,
|
|
1757
|
+
disabled: n.disabled,
|
|
1758
|
+
"search-threshold": n.searchThreshold,
|
|
1759
|
+
"show-code-on-list": n.showCodeOnList,
|
|
1760
|
+
"only-countries": n.onlyCountries,
|
|
1761
|
+
"preferred-countries": n.preferredCountries,
|
|
1762
|
+
width: n.countrySelectorWidth,
|
|
1763
|
+
"onUpdate:modelValue": w[0] || (w[0] = (P) => N({ countryCode: P, selectPhoneNumber: !0 }))
|
|
1764
|
+
}), {
|
|
1765
|
+
"no-results": W(() => [
|
|
1766
|
+
F(n.$slots, "no-results", {}, void 0, !0)
|
|
1767
|
+
]),
|
|
1768
|
+
"selector-flag": W(({ countryCode: P }) => [
|
|
1769
|
+
F(n.$slots, "selector-flag", { countryCode: P }, void 0, !0)
|
|
1770
|
+
]),
|
|
1771
|
+
"country-list-flag": W(({ isSelected: P, option: te }) => [
|
|
1772
|
+
F(n.$slots, "country-list-flag", {
|
|
1773
|
+
countryCode: te.iso2,
|
|
1774
|
+
option: te,
|
|
1775
|
+
isSelected: P
|
|
1776
|
+
}, void 0, !0)
|
|
1777
|
+
]),
|
|
1778
|
+
_: 3
|
|
1779
|
+
/* FORWARDED */
|
|
1780
|
+
}, 16, ["id", "model-value", "color", "size", "country-locale", "country-selector-display-name", "custom-countries-list", "ignored-countries", "list-position", "no-flags", "no-search", "exclude-selectors", "error", "success", "locales", "disabled", "search-threshold", "show-code-on-list", "only-countries", "preferred-countries", "width"])),
|
|
1781
|
+
U(st, ee({
|
|
1782
|
+
id: I(L),
|
|
1783
|
+
ref_key: "PhoneInputRef",
|
|
1784
|
+
ref: E,
|
|
1785
|
+
"model-value": C.value
|
|
1786
|
+
}, { ...n.$attrs, ...n.phoneInputAttributes }, {
|
|
1787
|
+
color: n.color,
|
|
1788
|
+
size: n.size,
|
|
1789
|
+
"auto-format": m.value,
|
|
1790
|
+
"no-example": n.noExample,
|
|
1791
|
+
block: "",
|
|
1792
|
+
disabled: n.disabled,
|
|
1793
|
+
"has-radius": !n.noCountrySelector,
|
|
1794
|
+
success: n.success || (n.noValidationSuccess ? !1 : p.value.isValid),
|
|
1795
|
+
error: n.error || (n.noValidationError ? !1 : !!C.value && !p.value.isValid),
|
|
1796
|
+
locales: A.value,
|
|
1797
|
+
label: n.label,
|
|
1798
|
+
placeholder: n.placeholder,
|
|
1799
|
+
"onUpdate:modelValue": w[1] || (w[1] = (P) => H({ newPhoneNumber: P }))
|
|
1800
|
+
}), null, 16, ["id", "model-value", "color", "size", "auto-format", "no-example", "disabled", "has-radius", "success", "error", "locales", "label", "placeholder"])
|
|
1801
|
+
],
|
|
1802
|
+
6
|
|
1803
|
+
/* CLASS, STYLE */
|
|
1804
|
+
);
|
|
1805
|
+
};
|
|
1806
|
+
}
|
|
1807
|
+
}), dt = /* @__PURE__ */ ne(nt, [["__scopeId", "data-v-d8d7fc2e"]]);
|
|
1808
|
+
export {
|
|
1809
|
+
dt as M,
|
|
1810
|
+
ne as _,
|
|
1811
|
+
Fe as i,
|
|
1812
|
+
we as u
|
|
1813
|
+
};
|