maz-ui 3.22.4 → 3.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/MazAvatar.mjs +2 -2
- package/components/MazBackdrop.mjs +67 -107
- package/components/MazBadge.mjs +41 -50
- package/components/MazBottomSheet.mjs +2 -2
- package/components/MazBtn.mjs +2 -2
- package/components/MazCard.mjs +2 -2
- package/components/MazCarousel.mjs +2 -2
- package/components/MazChart.mjs +53 -63
- package/components/MazCheckbox.mjs +84 -128
- package/components/MazDialog.mjs +2 -2
- package/components/MazDialogPromise.mjs +3 -3
- package/components/MazDrawer.mjs +2 -2
- package/components/MazDropdown.mjs +2 -2
- package/components/MazDropzone.mjs +2 -2
- package/components/MazFullscreenLoader.mjs +14 -18
- package/components/MazGallery.mjs +352 -558
- package/components/MazIcon.mjs +76 -140
- package/components/MazInput.mjs +2 -2
- package/components/MazInputNumber.mjs +72 -99
- package/components/MazInputPrice.mjs +2 -2
- package/components/MazInputTags.mjs +2 -2
- package/components/MazLazyImg.mjs +2 -2
- package/components/MazPhoneNumberInput.mjs +2 -2
- package/components/MazPicker.mjs +2 -2
- package/components/MazRadio.mjs +65 -94
- package/components/MazRadioButtons.mjs +64 -78
- package/components/MazSelect.mjs +2 -2
- package/components/MazSlider.mjs +213 -325
- package/components/MazSpinner.mjs +25 -34
- package/components/MazStepper.mjs +2 -2
- package/components/MazSwitch.mjs +43 -60
- package/components/MazTabs.mjs +16 -25
- package/components/MazTabsBar.mjs +2 -2
- package/components/MazTabsContent.mjs +34 -43
- package/components/MazTabsContentItem.mjs +49 -63
- package/components/MazTextarea.mjs +124 -169
- package/components/MazTransitionExpand.mjs +36 -54
- package/components/assets/MazBackdrop.css +1 -1
- package/components/assets/MazBottomSheet.css +1 -1
- package/components/assets/MazDialog.css +1 -1
- package/components/assets/MazDialogPromise.css +1 -1
- package/components/assets/MazDrawer.css +1 -1
- package/components/assets/MazPhoneNumberInput.css +1 -1
- package/components/assets/MazSelect.css +1 -1
- package/components/chunks/MazAvatar-1636f58b.mjs +126 -0
- package/components/chunks/MazBottomSheet-c24f92f8.mjs +217 -0
- package/components/chunks/MazBtn-124f3700.mjs +153 -0
- package/components/chunks/MazBtn-1e61862b.mjs +153 -0
- package/components/chunks/MazBtn-2d1d1ba5.mjs +153 -0
- package/components/chunks/MazBtn-3d74f737.mjs +153 -0
- package/components/chunks/MazBtn-4a447126.mjs +153 -0
- package/components/chunks/MazBtn-555928ed.mjs +153 -0
- package/components/chunks/MazBtn-571454f6.mjs +153 -0
- package/components/chunks/MazBtn-5e426592.mjs +153 -0
- package/components/chunks/MazBtn-683effc1.mjs +153 -0
- package/components/chunks/MazBtn-6905cc39.mjs +153 -0
- package/components/chunks/MazBtn-6ce4cfd3.mjs +153 -0
- package/components/chunks/MazBtn-74656d5b.mjs +153 -0
- package/components/chunks/MazBtn-7706b2da.mjs +158 -0
- package/components/chunks/MazBtn-a7a913dd.mjs +153 -0
- package/components/chunks/MazBtn-fb3c7af8.mjs +153 -0
- package/components/chunks/MazCard-bcc36489.mjs +214 -0
- package/components/chunks/MazCarousel-6da75122.mjs +107 -0
- package/components/chunks/MazCheckbox-040dc2c4.mjs +117 -0
- package/components/chunks/MazCheckbox-3a2b48b4.mjs +117 -0
- package/components/chunks/MazDialog-44eda544.mjs +250 -0
- package/components/chunks/MazDialogPromise-eec5acde.mjs +419 -0
- package/components/chunks/MazDrawer-b628b37e.mjs +206 -0
- package/components/chunks/MazDropdown-6f2248b0.mjs +345 -0
- package/components/chunks/MazDropzone-8cac10a6.mjs +242 -0
- package/components/chunks/MazGallery-6b8ecedf.mjs +617 -0
- package/components/chunks/MazIcon-52a76873.mjs +101 -0
- package/components/chunks/MazIcon-95e31ff8.mjs +96 -0
- package/components/chunks/MazInput-1ed4f946.mjs +283 -0
- package/components/chunks/MazInput-8a217995.mjs +271 -0
- package/components/chunks/MazInput-c51881ea.mjs +278 -0
- package/components/chunks/MazInputPrice-cd348d46.mjs +392 -0
- package/components/chunks/MazInputTags-aa95fae7.mjs +446 -0
- package/components/chunks/MazLazyImg-0412ab38.mjs +259 -0
- package/components/chunks/MazLazyImg-47d3449a.mjs +254 -0
- package/components/chunks/MazPhoneNumberInput-e1bf46f9.mjs +1216 -0
- package/components/chunks/MazPicker-e4620d8b.mjs +1140 -0
- package/components/chunks/MazPickerCalendar-da62262c.mjs +535 -0
- package/components/chunks/MazPickerHeader-a2e041eb.mjs +186 -0
- package/components/chunks/MazPickerMonthSwitcher-5bf8bd08.mjs +97 -0
- package/components/chunks/MazPickerShortcuts-7f95430e.mjs +74 -0
- package/components/chunks/MazPickerTime-717402ae.mjs +219 -0
- package/components/chunks/MazPickerYearSwitcher-85f97b6d.mjs +106 -0
- package/components/chunks/MazSelect-6ff6bb96.mjs +652 -0
- package/components/chunks/MazSpinner-054f948c.mjs +39 -0
- package/components/chunks/MazSpinner-059ee1d2.mjs +39 -0
- package/components/chunks/MazSpinner-08ee440b.mjs +39 -0
- package/components/chunks/MazSpinner-13403729.mjs +39 -0
- package/components/chunks/MazSpinner-44011019.mjs +39 -0
- package/components/chunks/MazSpinner-452a1534.mjs +39 -0
- package/components/chunks/MazSpinner-4c02cfd2.mjs +39 -0
- package/components/chunks/MazSpinner-51aa73ca.mjs +39 -0
- package/components/chunks/MazSpinner-6d1d24d5.mjs +39 -0
- package/components/chunks/MazSpinner-6e7c4705.mjs +39 -0
- package/components/chunks/MazSpinner-7895f54f.mjs +39 -0
- package/components/chunks/MazSpinner-7eee202e.mjs +39 -0
- package/components/chunks/MazSpinner-805e14a6.mjs +39 -0
- package/components/chunks/MazSpinner-85080b43.mjs +39 -0
- package/components/chunks/MazSpinner-a13a50c9.mjs +39 -0
- package/components/chunks/MazSpinner-a6d61cee.mjs +43 -0
- package/components/chunks/MazSpinner-c67b05bb.mjs +39 -0
- package/components/chunks/MazSpinner-caa33afc.mjs +39 -0
- package/components/chunks/MazSpinner-cb8fbe9a.mjs +39 -0
- package/components/chunks/MazSpinner-d9ef329f.mjs +39 -0
- package/components/chunks/MazStepper-39f018f3.mjs +191 -0
- package/components/chunks/MazTabsBar-27965f16.mjs +132 -0
- package/components/chunks/MazTransitionExpand-55cfbecb.mjs +41 -0
- package/components/chunks/MazTransitionExpand-cd24498f.mjs +41 -0
- package/components/chunks/_plugin-vue_export-helper-dad06003.mjs +9 -0
- package/components/chunks/check-31d7ba2f.mjs +30 -0
- package/components/chunks/check-c9b483c0.mjs +30 -0
- package/components/chunks/{check-circle-7acfa4c4.mjs → check-circle-59c383ed.mjs} +10 -12
- package/components/chunks/chevron-down-2b60111a.mjs +30 -0
- package/components/chunks/chevron-left-39b4621e.mjs +30 -0
- package/components/chunks/chevron-right-949a60fa.mjs +30 -0
- package/components/chunks/debounce-19c516b6.mjs +11 -0
- package/components/chunks/examples.mobile.json-f63d22fb.mjs +4 -0
- package/components/chunks/{exclamation-circle-2e115536.mjs → exclamation-circle-e2620aab.mjs} +10 -12
- package/components/chunks/{exclamation-triangle-10eb48dc.mjs → exclamation-triangle-21bf116a.mjs} +10 -12
- package/components/chunks/{eye-fbb13657.mjs → eye-dc12ce09.mjs} +12 -15
- package/components/chunks/{eye-slash-342420ff.mjs → eye-slash-fa42a017.mjs} +10 -12
- package/components/chunks/{magnifying-glass-5dffa35e.mjs → magnifying-glass-908981c0.mjs} +10 -12
- package/components/chunks/minus-e71140e1.mjs +30 -0
- package/components/chunks/no-photography-4c6c77cf.mjs +4 -0
- package/components/chunks/{no-photography-b0d08d6f.mjs → no-photography-be94ddda.mjs} +12 -15
- package/components/chunks/{no-symbol-975ce547.mjs → no-symbol-87477ad0.mjs} +10 -12
- package/components/chunks/{pencil-2f766dc8.mjs → pencil-4c35b4e7.mjs} +10 -12
- package/components/chunks/plus-c20544c3.mjs +30 -0
- package/components/chunks/x-mark-35f2f1e7.mjs +30 -0
- package/components/chunks/x-mark-7761acf4.mjs +29 -0
- package/modules/chunks/MazBtn-2f302422.cjs +1 -0
- package/modules/chunks/MazBtn-760c3b29.mjs +153 -0
- package/modules/chunks/MazIcon-0bd6b78e.mjs +96 -0
- package/modules/chunks/MazIcon-599a907f.cjs +1 -0
- package/modules/chunks/MazSpinner-03bd76bd.mjs +39 -0
- package/modules/chunks/MazSpinner-6ffa8db1.cjs +1 -0
- package/modules/chunks/{arrow-top-right-on-square-32bbe5a1.mjs → arrow-top-right-on-square-15191934.mjs} +10 -12
- package/modules/chunks/arrow-top-right-on-square-8e4ea6e2.cjs +1 -0
- package/modules/chunks/chevron-left-36731110.cjs +1 -0
- package/modules/chunks/chevron-left-39b4621e.mjs +30 -0
- package/modules/chunks/index-6a90ef88.mjs +1618 -0
- package/modules/chunks/index-794680d2.cjs +124 -0
- package/modules/chunks/{link-4eb05848.mjs → link-bb14441d.mjs} +10 -12
- package/modules/chunks/link-c7791a2a.cjs +1 -0
- package/modules/chunks/no-photography-0f6fcaf4.cjs +1 -0
- package/modules/chunks/no-photography-4c6c77cf.mjs +4 -0
- package/modules/chunks/x-mark-35f2f1e7.mjs +30 -0
- package/modules/chunks/x-mark-a28deca5.cjs +1 -0
- package/modules/index.cjs +1 -0
- package/modules/index.mjs +42 -42
- package/nuxt/index.json +1 -1
- package/package.json +14 -4
- package/types/resolvers/index.d.ts +1 -0
- package/types/resolvers/unplugin-vue-components-resolver.d.ts +8 -0
- package/types/utils/index.d.ts +3 -0
- package/components/chunks/MazAvatar-358d78d4.mjs +0 -138
- package/components/chunks/MazBottomSheet-61090f4a.mjs +0 -267
- package/components/chunks/MazBtn-0e02f0da.mjs +0 -184
- package/components/chunks/MazBtn-1daf9063.mjs +0 -184
- package/components/chunks/MazBtn-2f4fa942.mjs +0 -184
- package/components/chunks/MazBtn-31c6b731.mjs +0 -184
- package/components/chunks/MazBtn-48382169.mjs +0 -184
- package/components/chunks/MazBtn-4e1e116e.mjs +0 -184
- package/components/chunks/MazBtn-50abc4c5.mjs +0 -184
- package/components/chunks/MazBtn-84e12b6a.mjs +0 -184
- package/components/chunks/MazBtn-b42e3575.mjs +0 -184
- package/components/chunks/MazBtn-b56a7278.mjs +0 -184
- package/components/chunks/MazBtn-bbd6e9c8.mjs +0 -184
- package/components/chunks/MazBtn-cf0c8fcb.mjs +0 -184
- package/components/chunks/MazBtn-d92908b2.mjs +0 -191
- package/components/chunks/MazBtn-f48da79c.mjs +0 -184
- package/components/chunks/MazBtn-fec4c3b7.mjs +0 -184
- package/components/chunks/MazCard-4331dca0.mjs +0 -237
- package/components/chunks/MazCarousel-7825c7c9.mjs +0 -133
- package/components/chunks/MazCheckbox-ab5ddda2.mjs +0 -153
- package/components/chunks/MazCheckbox-e0bbe6ec.mjs +0 -153
- package/components/chunks/MazDialog-83e54b8c.mjs +0 -290
- package/components/chunks/MazDialogPromise-6967e821.mjs +0 -474
- package/components/chunks/MazDrawer-d778b3d2.mjs +0 -256
- package/components/chunks/MazDropdown-6f4482d7.mjs +0 -426
- package/components/chunks/MazDropzone-d1bb62dc.mjs +0 -325
- package/components/chunks/MazGallery-b2dc4286.mjs +0 -821
- package/components/chunks/MazIcon-b779da0a.mjs +0 -159
- package/components/chunks/MazIcon-bda198b4.mjs +0 -165
- package/components/chunks/MazInput-713b00d0.mjs +0 -326
- package/components/chunks/MazInput-b9386887.mjs +0 -341
- package/components/chunks/MazInput-c33627dd.mjs +0 -334
- package/components/chunks/MazInputPrice-452297f5.mjs +0 -481
- package/components/chunks/MazInputTags-7a463b81.mjs +0 -526
- package/components/chunks/MazLazyImg-6e395356.mjs +0 -336
- package/components/chunks/MazLazyImg-e0d8b6d0.mjs +0 -329
- package/components/chunks/MazPhoneNumberInput-48fe2445.mjs +0 -1536
- package/components/chunks/MazPicker-50fc11d1.mjs +0 -1352
- package/components/chunks/MazPickerCalendar-cacb361c.mjs +0 -689
- package/components/chunks/MazPickerHeader-63d45179.mjs +0 -216
- package/components/chunks/MazPickerMonthSwitcher-913c6e2c.mjs +0 -110
- package/components/chunks/MazPickerShortcuts-c6fabfc6.mjs +0 -88
- package/components/chunks/MazPickerTime-5e4475da.mjs +0 -301
- package/components/chunks/MazPickerYearSwitcher-dd4fa89c.mjs +0 -125
- package/components/chunks/MazSelect-2e5cd411.mjs +0 -850
- package/components/chunks/MazSpinner-022d7bee.mjs +0 -46
- package/components/chunks/MazSpinner-100c99b8.mjs +0 -46
- package/components/chunks/MazSpinner-191ad23b.mjs +0 -46
- package/components/chunks/MazSpinner-3155378b.mjs +0 -46
- package/components/chunks/MazSpinner-339a9006.mjs +0 -46
- package/components/chunks/MazSpinner-53979e96.mjs +0 -46
- package/components/chunks/MazSpinner-68d2f2ac.mjs +0 -46
- package/components/chunks/MazSpinner-6b563b22.mjs +0 -46
- package/components/chunks/MazSpinner-7cdc13e7.mjs +0 -46
- package/components/chunks/MazSpinner-8859d658.mjs +0 -46
- package/components/chunks/MazSpinner-8e180605.mjs +0 -52
- package/components/chunks/MazSpinner-9950424b.mjs +0 -46
- package/components/chunks/MazSpinner-c8270a93.mjs +0 -46
- package/components/chunks/MazSpinner-cb491238.mjs +0 -46
- package/components/chunks/MazSpinner-cb6f99f3.mjs +0 -46
- package/components/chunks/MazSpinner-ce4be8f1.mjs +0 -46
- package/components/chunks/MazSpinner-e5a9f319.mjs +0 -46
- package/components/chunks/MazSpinner-e92bd359.mjs +0 -46
- package/components/chunks/MazSpinner-eea9056d.mjs +0 -46
- package/components/chunks/MazSpinner-f1e69f29.mjs +0 -46
- package/components/chunks/MazStepper-4c19dbfc.mjs +0 -255
- package/components/chunks/MazTabsBar-3c2e2d69.mjs +0 -157
- package/components/chunks/MazTransitionExpand-474b00d4.mjs +0 -57
- package/components/chunks/MazTransitionExpand-f9e5a2d6.mjs +0 -57
- package/components/chunks/_plugin-vue_export-helper-cc2b3d55.mjs +0 -10
- package/components/chunks/check-8da249b1.mjs +0 -32
- package/components/chunks/check-f2fcce10.mjs +0 -32
- package/components/chunks/chevron-down-a78b9604.mjs +0 -32
- package/components/chunks/chevron-left-3365d59b.mjs +0 -32
- package/components/chunks/chevron-right-02f9e837.mjs +0 -32
- package/components/chunks/debounce-7d66ffa9.mjs +0 -12
- package/components/chunks/examples.mobile.json-618ba782.mjs +0 -4
- package/components/chunks/minus-c9cdee90.mjs +0 -32
- package/components/chunks/no-photography-7f2be516.mjs +0 -4
- package/components/chunks/plus-b1b0a5a8.mjs +0 -32
- package/components/chunks/x-mark-3b05101b.mjs +0 -31
- package/components/chunks/x-mark-c6ff45dd.mjs +0 -32
- package/modules/chunks/MazBtn-90ffd148.mjs +0 -184
- package/modules/chunks/MazIcon-988edef7.mjs +0 -159
- package/modules/chunks/MazSpinner-a16a3d8f.mjs +0 -46
- package/modules/chunks/chevron-left-3365d59b.mjs +0 -32
- package/modules/chunks/index-b1625fc2.mjs +0 -2315
- package/modules/chunks/no-photography-7f2be516.mjs +0 -4
- package/modules/chunks/x-mark-c6ff45dd.mjs +0 -32
|
@@ -1,1536 +0,0 @@
|
|
|
1
|
-
import "../assets/MazPhoneNumberInput.css";
|
|
2
|
-
import { computed, defineComponent, defineAsyncComponent, ref, getCurrentInstance, onMounted, useSlots, openBlock, createElementBlock, normalizeClass, normalizeStyle, createElementVNode, renderSlot, createVNode, unref, createCommentVNode, withDirectives, mergeProps, toHandlers, vModelDynamic, createTextVNode, toDisplayString, createBlock, withModifiers, withCtx, useCssVars, onBeforeMount, watch, Transition, Fragment, renderList, nextTick, reactive } from "vue";
|
|
3
|
-
import { isSupportedCountry, getCountryCallingCode, getExampleNumber, getCountries, parsePhoneNumberFromString, AsYouType } from "libphonenumber-js";
|
|
4
|
-
function truthyFilter(value) {
|
|
5
|
-
return !!value;
|
|
6
|
-
}
|
|
7
|
-
const useInstanceUniqId = ({
|
|
8
|
-
componentName,
|
|
9
|
-
instance,
|
|
10
|
-
providedId
|
|
11
|
-
}) => {
|
|
12
|
-
return computed(() => providedId ?? `${componentName}-${instance == null ? void 0 : instance.uid}`);
|
|
13
|
-
};
|
|
14
|
-
const defaultLocales = {
|
|
15
|
-
countrySelector: {
|
|
16
|
-
placeholder: "Country code",
|
|
17
|
-
error: "Choose country",
|
|
18
|
-
searchPlaceholder: "Search the country"
|
|
19
|
-
},
|
|
20
|
-
phoneInput: {
|
|
21
|
-
placeholder: "Phone number",
|
|
22
|
-
example: "Example:"
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
function countryCodeToUnicodeFlag(locale) {
|
|
26
|
-
const characters = [...locale];
|
|
27
|
-
return characters.map((letter) => letter.charCodeAt(0) % 32 + 127461).map((n) => String.fromCodePoint(n)).join("");
|
|
28
|
-
}
|
|
29
|
-
let displayNamesInstance = void 0;
|
|
30
|
-
function getCountryName(locale, code, customCountriesNameListByIsoCode) {
|
|
31
|
-
if (customCountriesNameListByIsoCode == null ? void 0 : customCountriesNameListByIsoCode[code]) {
|
|
32
|
-
return customCountriesNameListByIsoCode[code];
|
|
33
|
-
}
|
|
34
|
-
if (!displayNamesInstance) {
|
|
35
|
-
displayNamesInstance = new Intl.DisplayNames([locale], { type: "region" });
|
|
36
|
-
}
|
|
37
|
-
return displayNamesInstance.of(code);
|
|
38
|
-
}
|
|
39
|
-
const PHONE_CHAR_REGEX = /^[\d ().-]+$/;
|
|
40
|
-
const NON_ALPHA_REGEX = /^[^a-z]+$/i;
|
|
41
|
-
let examples;
|
|
42
|
-
async function loadPhoneNumberExamplesFile() {
|
|
43
|
-
const { default: data } = await import("./examples.mobile.json-618ba782.mjs");
|
|
44
|
-
examples = data;
|
|
45
|
-
return examples;
|
|
46
|
-
}
|
|
47
|
-
function isSameCountryCallingCode(countryCode, countryCode2) {
|
|
48
|
-
return getCountryCallingCode(countryCode) === getCountryCallingCode(countryCode2);
|
|
49
|
-
}
|
|
50
|
-
function getPhoneNumberExample(countryCode) {
|
|
51
|
-
var _a;
|
|
52
|
-
try {
|
|
53
|
-
return countryCode ? (_a = getExampleNumber(countryCode, examples)) == null ? void 0 : _a.formatNational() : void 0;
|
|
54
|
-
} catch (error) {
|
|
55
|
-
console.error(`[maz-ui](MazPhoneNumberInput) ${error}`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function sanitizePhoneNumber(input) {
|
|
59
|
-
if (!input) {
|
|
60
|
-
return "";
|
|
61
|
-
}
|
|
62
|
-
const hasNonAlpha = NON_ALPHA_REGEX.test(input);
|
|
63
|
-
const hasPhoneChar = PHONE_CHAR_REGEX.test(input);
|
|
64
|
-
if (!hasNonAlpha && !hasPhoneChar) {
|
|
65
|
-
return input.replaceAll(/[^\d.]/g, "");
|
|
66
|
-
}
|
|
67
|
-
return input;
|
|
68
|
-
}
|
|
69
|
-
function getCountriesList(locale, customCountriesNameListByIsoCode) {
|
|
70
|
-
const countriesList = [];
|
|
71
|
-
const isoList = getCountries();
|
|
72
|
-
locale = locale ?? browserLocale().browserLocale ?? "en-US";
|
|
73
|
-
for (const iso2 of isoList) {
|
|
74
|
-
const name = getCountryName(locale, iso2, customCountriesNameListByIsoCode);
|
|
75
|
-
if (name) {
|
|
76
|
-
try {
|
|
77
|
-
const dialCode = getCountryCallingCode(iso2);
|
|
78
|
-
countriesList.push({
|
|
79
|
-
iso2,
|
|
80
|
-
dialCode,
|
|
81
|
-
name
|
|
82
|
-
});
|
|
83
|
-
} catch (error) {
|
|
84
|
-
console.error(`[MazPhoneNumberInput](getCountryCallingCode) ${error}`);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return countriesList;
|
|
89
|
-
}
|
|
90
|
-
function browserLocale() {
|
|
91
|
-
if (typeof window === "undefined") {
|
|
92
|
-
return {};
|
|
93
|
-
}
|
|
94
|
-
const browserLocale2 = window.navigator.language;
|
|
95
|
-
if (!browserLocale2) {
|
|
96
|
-
return {};
|
|
97
|
-
}
|
|
98
|
-
let locale = browserLocale2.slice(3, 7).toUpperCase();
|
|
99
|
-
if (locale === "") {
|
|
100
|
-
locale = browserLocale2.slice(0, 2).toUpperCase();
|
|
101
|
-
}
|
|
102
|
-
if (locale === "EN") {
|
|
103
|
-
locale = "US";
|
|
104
|
-
}
|
|
105
|
-
if (locale === "JA") {
|
|
106
|
-
locale = "JP";
|
|
107
|
-
}
|
|
108
|
-
return { locale, browserLocale: browserLocale2 };
|
|
109
|
-
}
|
|
110
|
-
function isCountryAvailable(locale) {
|
|
111
|
-
try {
|
|
112
|
-
const response = isSupportedCountry(locale);
|
|
113
|
-
if (!response) {
|
|
114
|
-
console.error(`[maz-ui](MazPhoneNumberInput) The code country "${locale}" is not available`);
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
return response;
|
|
118
|
-
} catch (error) {
|
|
119
|
-
console.error(`[maz-ui](MazPhoneNumberInput) ${error}`);
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
const getResultsFromPhoneNumber = ({
|
|
124
|
-
phoneNumber,
|
|
125
|
-
countryCode
|
|
126
|
-
}) => {
|
|
127
|
-
try {
|
|
128
|
-
if (!phoneNumber) {
|
|
129
|
-
return {
|
|
130
|
-
isValid: false,
|
|
131
|
-
countryCode
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
const parsedNumber = parsePhoneNumberFromString(phoneNumber, countryCode);
|
|
135
|
-
return {
|
|
136
|
-
isValid: (parsedNumber == null ? void 0 : parsedNumber.isValid()) ?? false,
|
|
137
|
-
isPossible: parsedNumber == null ? void 0 : parsedNumber.isPossible(),
|
|
138
|
-
countryCode: parsedNumber == null ? void 0 : parsedNumber.country,
|
|
139
|
-
countryCallingCode: parsedNumber == null ? void 0 : parsedNumber.countryCallingCode,
|
|
140
|
-
nationalNumber: parsedNumber == null ? void 0 : parsedNumber.nationalNumber,
|
|
141
|
-
type: parsedNumber == null ? void 0 : parsedNumber.getType(),
|
|
142
|
-
formatInternational: parsedNumber == null ? void 0 : parsedNumber.formatInternational(),
|
|
143
|
-
formatNational: parsedNumber == null ? void 0 : parsedNumber.formatNational(),
|
|
144
|
-
uri: parsedNumber == null ? void 0 : parsedNumber.getURI(),
|
|
145
|
-
e164: parsedNumber == null ? void 0 : parsedNumber.format("E.164"),
|
|
146
|
-
rfc3966: parsedNumber == null ? void 0 : parsedNumber.format("RFC3966")
|
|
147
|
-
};
|
|
148
|
-
} catch (error) {
|
|
149
|
-
throw new Error(`[MazPhoneNumberInput](getResultsFromPhoneNumber) ${error}`);
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
function getAsYouTypeFormat(countryCode, phoneNumber) {
|
|
153
|
-
try {
|
|
154
|
-
if (!phoneNumber) {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
return new AsYouType(countryCode).input(phoneNumber);
|
|
158
|
-
} catch (error) {
|
|
159
|
-
throw new Error(`[MazPhoneNumberInput](getAsYouTypeFormat) ${error}`);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
async function fetchCountryCode() {
|
|
163
|
-
try {
|
|
164
|
-
const reponse = await fetch("https://ipwho.is");
|
|
165
|
-
const { country_code } = await reponse.json();
|
|
166
|
-
return country_code;
|
|
167
|
-
} catch (error) {
|
|
168
|
-
throw new Error(`[MazPhoneNumberInput](fetchCountryCode) ${error}`);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
function useLibphonenumber() {
|
|
172
|
-
return {
|
|
173
|
-
fetchCountryCode,
|
|
174
|
-
getAsYouTypeFormat,
|
|
175
|
-
getResultsFromPhoneNumber,
|
|
176
|
-
loadPhoneNumberExamplesFile,
|
|
177
|
-
getPhoneNumberExample,
|
|
178
|
-
sanitizePhoneNumber,
|
|
179
|
-
getCountriesList,
|
|
180
|
-
browserLocale,
|
|
181
|
-
isSameCountryCallingCode
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
function debounce(fn, delay) {
|
|
185
|
-
let timeout2;
|
|
186
|
-
return function(...args) {
|
|
187
|
-
clearTimeout(timeout2);
|
|
188
|
-
timeout2 = setTimeout(() => {
|
|
189
|
-
fn.apply(this, args);
|
|
190
|
-
}, delay);
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
const _hoisted_1$2 = {
|
|
194
|
-
key: 0,
|
|
195
|
-
class: "m-input-wrapper-left"
|
|
196
|
-
};
|
|
197
|
-
const _hoisted_2$2 = { class: "m-input-wrapper-input" };
|
|
198
|
-
const _hoisted_3$1 = ["id", "type", "name", "placeholder", "aria-label", "disabled", "readonly", "required"];
|
|
199
|
-
const _hoisted_4$1 = { key: 0 };
|
|
200
|
-
const _hoisted_5$1 = {
|
|
201
|
-
key: 1,
|
|
202
|
-
class: "m-input-wrapper-right"
|
|
203
|
-
};
|
|
204
|
-
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
205
|
-
...{
|
|
206
|
-
inheritAttrs: false
|
|
207
|
-
},
|
|
208
|
-
__name: "MazInput",
|
|
209
|
-
props: {
|
|
210
|
-
style: { type: [String, Array, Object], default: void 0 },
|
|
211
|
-
class: { type: String, default: void 0 },
|
|
212
|
-
modelValue: {
|
|
213
|
-
type: [String, Number, Boolean],
|
|
214
|
-
default: void 0
|
|
215
|
-
},
|
|
216
|
-
placeholder: { type: String, default: void 0 },
|
|
217
|
-
color: {
|
|
218
|
-
type: String,
|
|
219
|
-
default: "primary"
|
|
220
|
-
},
|
|
221
|
-
label: { type: String, default: void 0 },
|
|
222
|
-
name: { type: String, default: "input" },
|
|
223
|
-
type: {
|
|
224
|
-
type: String,
|
|
225
|
-
default: "text",
|
|
226
|
-
validator: (value) => {
|
|
227
|
-
return [
|
|
228
|
-
"text",
|
|
229
|
-
"date",
|
|
230
|
-
"number",
|
|
231
|
-
"tel",
|
|
232
|
-
"search",
|
|
233
|
-
"url",
|
|
234
|
-
"password",
|
|
235
|
-
"month",
|
|
236
|
-
"time",
|
|
237
|
-
"week",
|
|
238
|
-
"email"
|
|
239
|
-
].includes(value);
|
|
240
|
-
}
|
|
241
|
-
},
|
|
242
|
-
required: { type: Boolean, default: false },
|
|
243
|
-
disabled: { type: Boolean, default: false },
|
|
244
|
-
readonly: { type: Boolean, default: false },
|
|
245
|
-
id: { type: String, default: void 0 },
|
|
246
|
-
error: { type: Boolean, default: false },
|
|
247
|
-
success: { type: Boolean, default: false },
|
|
248
|
-
warning: { type: Boolean, default: false },
|
|
249
|
-
hint: { type: String, default: void 0 },
|
|
250
|
-
inputClasses: { type: String, default: void 0 },
|
|
251
|
-
noBorder: { type: Boolean, default: false },
|
|
252
|
-
noRadius: { type: Boolean, default: false },
|
|
253
|
-
size: {
|
|
254
|
-
type: String,
|
|
255
|
-
default: "md",
|
|
256
|
-
validator: (value) => {
|
|
257
|
-
return ["mini", "xs", "sm", "md", "lg", "xl"].includes(value);
|
|
258
|
-
}
|
|
259
|
-
},
|
|
260
|
-
debounce: { type: Boolean, default: false },
|
|
261
|
-
debounceDelay: { type: Number, default: 500 },
|
|
262
|
-
validButton: { type: Boolean, default: false },
|
|
263
|
-
validButtonLoading: { type: Boolean, default: false },
|
|
264
|
-
autoFocus: { type: Boolean, default: false },
|
|
265
|
-
borderActive: { type: Boolean, default: false },
|
|
266
|
-
leftIcon: { type: String, default: void 0 },
|
|
267
|
-
rightIcon: { type: String, default: void 0 }
|
|
268
|
-
},
|
|
269
|
-
emits: ["focus", "blur", "update:model-value", "click", "change", "update"],
|
|
270
|
-
setup(__props, { emit: __emit }) {
|
|
271
|
-
const MazBtn = defineAsyncComponent(() => import("./MazBtn-50abc4c5.mjs"));
|
|
272
|
-
const MazIcon = defineAsyncComponent(() => import("./MazIcon-bda198b4.mjs"));
|
|
273
|
-
const EyeOffIcon = defineAsyncComponent(() => import("./eye-slash-342420ff.mjs"));
|
|
274
|
-
const EyeIcon = defineAsyncComponent(() => import("./eye-fbb13657.mjs"));
|
|
275
|
-
const CheckIcon = defineAsyncComponent(() => import("./check-8da249b1.mjs"));
|
|
276
|
-
const props = __props;
|
|
277
|
-
const emits = __emit;
|
|
278
|
-
const hasPasswordVisible = ref(false);
|
|
279
|
-
const isFocused = ref(false);
|
|
280
|
-
const input = ref();
|
|
281
|
-
const instance = getCurrentInstance();
|
|
282
|
-
const instanceId = useInstanceUniqId({
|
|
283
|
-
componentName: "MazInput",
|
|
284
|
-
instance,
|
|
285
|
-
providedId: props.id
|
|
286
|
-
});
|
|
287
|
-
onMounted(() => {
|
|
288
|
-
var _a;
|
|
289
|
-
if (props.autoFocus) {
|
|
290
|
-
(_a = input.value) == null ? void 0 : _a.focus();
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
const inheritClasses = computed(() => props.class);
|
|
294
|
-
const isPasswordType = computed(() => props.type === "password");
|
|
295
|
-
const inputType = computed(() => hasPasswordVisible.value ? "text" : props.type);
|
|
296
|
-
const borderStyle = computed(() => {
|
|
297
|
-
if (props.noBorder)
|
|
298
|
-
return void 0;
|
|
299
|
-
if (props.error)
|
|
300
|
-
return "maz-border-danger";
|
|
301
|
-
if (props.success)
|
|
302
|
-
return "maz-border-success";
|
|
303
|
-
if (props.warning)
|
|
304
|
-
return "maz-border-warning";
|
|
305
|
-
if (isFocused.value || props.borderActive) {
|
|
306
|
-
if (props.color === "black")
|
|
307
|
-
return "maz-border-black";
|
|
308
|
-
if (props.color === "danger")
|
|
309
|
-
return "maz-border-danger";
|
|
310
|
-
if (props.color === "info")
|
|
311
|
-
return "maz-border-info";
|
|
312
|
-
if (props.color === "primary")
|
|
313
|
-
return "maz-border-primary";
|
|
314
|
-
if (props.color === "secondary")
|
|
315
|
-
return "maz-border-secondary";
|
|
316
|
-
if (props.color === "success")
|
|
317
|
-
return "maz-border-success";
|
|
318
|
-
if (props.color === "warning")
|
|
319
|
-
return "maz-border-warning";
|
|
320
|
-
if (props.color === "white")
|
|
321
|
-
return "maz-border-white";
|
|
322
|
-
}
|
|
323
|
-
return "--default-border";
|
|
324
|
-
});
|
|
325
|
-
const slots = useSlots();
|
|
326
|
-
const computedPlaceholder = computed(() => {
|
|
327
|
-
const { required, placeholder } = props;
|
|
328
|
-
if (!placeholder)
|
|
329
|
-
return void 0;
|
|
330
|
-
return required ? `${placeholder} *` : placeholder;
|
|
331
|
-
});
|
|
332
|
-
const hasValue = computed(() => props.modelValue !== void 0 && props.modelValue !== "");
|
|
333
|
-
const inputValue = computed({
|
|
334
|
-
get: () => props.modelValue,
|
|
335
|
-
set: (value) => emitValue(value)
|
|
336
|
-
});
|
|
337
|
-
const shouldUp = computed(() => {
|
|
338
|
-
return (!!props.label || !!props.hint) && (isFocused.value || !!hasValue.value || !!props.placeholder || ["date", "month", "week"].includes(props.type));
|
|
339
|
-
});
|
|
340
|
-
const hasLabel = computed(() => !!props.label || !!props.hint);
|
|
341
|
-
const hasRightPart = () => {
|
|
342
|
-
return !!slots["right-icon"] || isPasswordType.value || !!slots["valid-button"] || props.validButton || !!props.rightIcon;
|
|
343
|
-
};
|
|
344
|
-
const hasLeftPart = () => {
|
|
345
|
-
return !!slots["left-icon"] || !!props.leftIcon;
|
|
346
|
-
};
|
|
347
|
-
const focus = (event) => {
|
|
348
|
-
emits("focus", event);
|
|
349
|
-
isFocused.value = true;
|
|
350
|
-
};
|
|
351
|
-
const blur = (event) => {
|
|
352
|
-
emits("blur", event);
|
|
353
|
-
isFocused.value = false;
|
|
354
|
-
};
|
|
355
|
-
const change = (event) => emits("change", event);
|
|
356
|
-
const debounceEmitValue = debounce((value) => {
|
|
357
|
-
emits("update:model-value", value);
|
|
358
|
-
}, props.debounceDelay);
|
|
359
|
-
const emitValue = (value) => {
|
|
360
|
-
if (props.debounce)
|
|
361
|
-
return debounceEmitValue(value);
|
|
362
|
-
emits("update:model-value", value);
|
|
363
|
-
};
|
|
364
|
-
return (_ctx, _cache) => {
|
|
365
|
-
return openBlock(), createElementBlock(
|
|
366
|
-
"div",
|
|
367
|
-
{
|
|
368
|
-
class: normalizeClass(["m-input", [
|
|
369
|
-
{
|
|
370
|
-
"--is-focused": isFocused.value || __props.borderActive,
|
|
371
|
-
"--should-up": shouldUp.value,
|
|
372
|
-
"--has-label": hasLabel.value,
|
|
373
|
-
"--is-disabled": __props.disabled,
|
|
374
|
-
"--is-readonly": __props.readonly,
|
|
375
|
-
"--has-z-2": __props.error || __props.warning || __props.success,
|
|
376
|
-
"--has-state": __props.error || __props.warning || __props.success
|
|
377
|
-
},
|
|
378
|
-
inheritClasses.value,
|
|
379
|
-
`--${__props.color}`,
|
|
380
|
-
`--${__props.size}`
|
|
381
|
-
]]),
|
|
382
|
-
style: normalizeStyle(__props.style)
|
|
383
|
-
},
|
|
384
|
-
[
|
|
385
|
-
createElementVNode(
|
|
386
|
-
"div",
|
|
387
|
-
{
|
|
388
|
-
class: normalizeClass(["m-input-wrapper", [__props.inputClasses, borderStyle.value, { "maz-rounded": !__props.noRadius }]])
|
|
389
|
-
},
|
|
390
|
-
[
|
|
391
|
-
hasLeftPart() ? (openBlock(), createElementBlock("div", _hoisted_1$2, [
|
|
392
|
-
_ctx.$slots["left-icon"] || __props.leftIcon ? renderSlot(_ctx.$slots, "left-icon", { key: 0 }, () => [
|
|
393
|
-
createVNode(unref(MazIcon), {
|
|
394
|
-
name: __props.leftIcon,
|
|
395
|
-
class: "maz-text-xl maz-text-muted"
|
|
396
|
-
}, null, 8, ["name"])
|
|
397
|
-
], true) : createCommentVNode("v-if", true)
|
|
398
|
-
])) : createCommentVNode("v-if", true),
|
|
399
|
-
createElementVNode("div", _hoisted_2$2, [
|
|
400
|
-
withDirectives(createElementVNode("input", mergeProps({
|
|
401
|
-
id: unref(instanceId),
|
|
402
|
-
ref_key: "input",
|
|
403
|
-
ref: input,
|
|
404
|
-
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inputValue.value = $event),
|
|
405
|
-
type: inputType.value,
|
|
406
|
-
name: __props.name
|
|
407
|
-
}, _ctx.$attrs, {
|
|
408
|
-
placeholder: computedPlaceholder.value,
|
|
409
|
-
"aria-label": __props.label || __props.placeholder,
|
|
410
|
-
disabled: __props.disabled,
|
|
411
|
-
readonly: __props.readonly,
|
|
412
|
-
required: __props.required,
|
|
413
|
-
class: "m-input-input"
|
|
414
|
-
}, toHandlers({
|
|
415
|
-
blur,
|
|
416
|
-
focus,
|
|
417
|
-
change
|
|
418
|
-
}, true), {
|
|
419
|
-
onClick: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("click", $event))
|
|
420
|
-
}), null, 16, _hoisted_3$1), [
|
|
421
|
-
[vModelDynamic, inputValue.value]
|
|
422
|
-
]),
|
|
423
|
-
__props.label || __props.hint ? (openBlock(), createElementBlock(
|
|
424
|
-
"span",
|
|
425
|
-
{
|
|
426
|
-
key: 0,
|
|
427
|
-
ref: "label",
|
|
428
|
-
class: normalizeClass(["m-input-label", [
|
|
429
|
-
{
|
|
430
|
-
"maz-text-danger-600": __props.error,
|
|
431
|
-
"maz-text-success-600": __props.success,
|
|
432
|
-
"maz-text-warning-600": __props.warning
|
|
433
|
-
}
|
|
434
|
-
]])
|
|
435
|
-
},
|
|
436
|
-
[
|
|
437
|
-
createTextVNode(
|
|
438
|
-
toDisplayString(__props.hint || __props.label) + " ",
|
|
439
|
-
1
|
|
440
|
-
/* TEXT */
|
|
441
|
-
),
|
|
442
|
-
__props.required ? (openBlock(), createElementBlock("sup", _hoisted_4$1, "*")) : createCommentVNode("v-if", true)
|
|
443
|
-
],
|
|
444
|
-
2
|
|
445
|
-
/* CLASS */
|
|
446
|
-
)) : createCommentVNode("v-if", true)
|
|
447
|
-
]),
|
|
448
|
-
hasRightPart() ? (openBlock(), createElementBlock("div", _hoisted_5$1, [
|
|
449
|
-
_ctx.$slots["right-icon"] || __props.rightIcon ? renderSlot(_ctx.$slots, "right-icon", { key: 0 }, () => [
|
|
450
|
-
createVNode(unref(MazIcon), {
|
|
451
|
-
name: __props.rightIcon,
|
|
452
|
-
class: "maz-text-xl maz-text-muted"
|
|
453
|
-
}, null, 8, ["name"])
|
|
454
|
-
], true) : createCommentVNode("v-if", true),
|
|
455
|
-
isPasswordType.value ? (openBlock(), createBlock(unref(MazBtn), {
|
|
456
|
-
key: 1,
|
|
457
|
-
color: "transparent",
|
|
458
|
-
tabindex: "-1",
|
|
459
|
-
size: "mini",
|
|
460
|
-
onClick: _cache[2] || (_cache[2] = withModifiers(($event) => hasPasswordVisible.value = !hasPasswordVisible.value, ["stop"]))
|
|
461
|
-
}, {
|
|
462
|
-
default: withCtx(() => [
|
|
463
|
-
hasPasswordVisible.value ? (openBlock(), createBlock(unref(EyeOffIcon), {
|
|
464
|
-
key: 0,
|
|
465
|
-
class: "maz-text-xl maz-text-muted"
|
|
466
|
-
})) : (openBlock(), createBlock(unref(EyeIcon), {
|
|
467
|
-
key: 1,
|
|
468
|
-
class: "maz-text-xl maz-text-muted"
|
|
469
|
-
}))
|
|
470
|
-
]),
|
|
471
|
-
_: 1
|
|
472
|
-
/* STABLE */
|
|
473
|
-
})) : createCommentVNode("v-if", true),
|
|
474
|
-
_ctx.$slots["valid-button"] || __props.validButton ? renderSlot(_ctx.$slots, "valid-button", { key: 2 }, () => [
|
|
475
|
-
createVNode(unref(MazBtn), {
|
|
476
|
-
color: "transparent",
|
|
477
|
-
disabled: __props.disabled,
|
|
478
|
-
tabindex: "-1",
|
|
479
|
-
loading: __props.validButtonLoading,
|
|
480
|
-
class: "m-input-valid-button",
|
|
481
|
-
size: "mini",
|
|
482
|
-
type: "submit"
|
|
483
|
-
}, {
|
|
484
|
-
default: withCtx(() => [
|
|
485
|
-
createVNode(unref(CheckIcon), { class: "maz-text-2xl maz-text-normal" })
|
|
486
|
-
]),
|
|
487
|
-
_: 1
|
|
488
|
-
/* STABLE */
|
|
489
|
-
}, 8, ["disabled", "loading"])
|
|
490
|
-
], true) : createCommentVNode("v-if", true)
|
|
491
|
-
])) : createCommentVNode("v-if", true)
|
|
492
|
-
],
|
|
493
|
-
2
|
|
494
|
-
/* CLASS */
|
|
495
|
-
)
|
|
496
|
-
],
|
|
497
|
-
6
|
|
498
|
-
/* CLASS, STYLE */
|
|
499
|
-
);
|
|
500
|
-
};
|
|
501
|
-
}
|
|
502
|
-
});
|
|
503
|
-
const MazInput_vue_vue_type_style_index_0_scoped_32fa5093_lang = "";
|
|
504
|
-
const _export_sfc = (sfc, props) => {
|
|
505
|
-
const target = sfc.__vccOpts || sfc;
|
|
506
|
-
for (const [key, val] of props) {
|
|
507
|
-
target[key] = val;
|
|
508
|
-
}
|
|
509
|
-
return target;
|
|
510
|
-
};
|
|
511
|
-
const MazInput = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-32fa5093"]]);
|
|
512
|
-
ref("system");
|
|
513
|
-
ref("system");
|
|
514
|
-
ref();
|
|
515
|
-
ref([]);
|
|
516
|
-
let timeout = null;
|
|
517
|
-
function debounceCallback(callback, delay) {
|
|
518
|
-
if (timeout) {
|
|
519
|
-
clearTimeout(timeout);
|
|
520
|
-
}
|
|
521
|
-
timeout = setTimeout(callback, delay);
|
|
522
|
-
}
|
|
523
|
-
const _hoisted_1$1 = ["onClick"];
|
|
524
|
-
const _hoisted_2$1 = {
|
|
525
|
-
key: 0,
|
|
526
|
-
tabindex: "-1",
|
|
527
|
-
class: "m-select-list__search-wrapper"
|
|
528
|
-
};
|
|
529
|
-
const _hoisted_3 = { class: "m-select-list__no-results" };
|
|
530
|
-
const _hoisted_4 = {
|
|
531
|
-
key: 2,
|
|
532
|
-
class: "m-select-list__scroll-wrapper",
|
|
533
|
-
tabindex: "-1"
|
|
534
|
-
};
|
|
535
|
-
const _hoisted_5 = ["onClick"];
|
|
536
|
-
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
537
|
-
...{
|
|
538
|
-
inheritAttrs: false
|
|
539
|
-
},
|
|
540
|
-
__name: "MazSelect",
|
|
541
|
-
props: {
|
|
542
|
-
style: { type: [String, Array, Object], default: void 0 },
|
|
543
|
-
class: { type: String, default: void 0 },
|
|
544
|
-
modelValue: {
|
|
545
|
-
type: [Number, String, Boolean, Array],
|
|
546
|
-
default: void 0
|
|
547
|
-
},
|
|
548
|
-
id: { type: String, default: void 0 },
|
|
549
|
-
options: { type: Array, default: void 0 },
|
|
550
|
-
optionValueKey: { type: String, default: "value" },
|
|
551
|
-
optionLabelKey: { type: String, default: "label" },
|
|
552
|
-
optionInputValueKey: { type: String, default: "label" },
|
|
553
|
-
listPosition: {
|
|
554
|
-
type: String,
|
|
555
|
-
default: "bottom left",
|
|
556
|
-
validator: (value) => {
|
|
557
|
-
return ["top", "top right", "top left", "bottom", "bottom right", "bottom left"].includes(
|
|
558
|
-
value
|
|
559
|
-
);
|
|
560
|
-
}
|
|
561
|
-
},
|
|
562
|
-
required: { type: Boolean, default: false },
|
|
563
|
-
disabled: { type: Boolean, default: false },
|
|
564
|
-
open: { type: Boolean, default: false },
|
|
565
|
-
/** Choose color of the input */
|
|
566
|
-
color: {
|
|
567
|
-
type: String,
|
|
568
|
-
default: "primary"
|
|
569
|
-
},
|
|
570
|
-
/** Choose the option list item height */
|
|
571
|
-
itemHeight: { type: Number, default: 40 },
|
|
572
|
-
maxListHeight: { type: Number, default: 240 },
|
|
573
|
-
/** Add max-width value to option list */
|
|
574
|
-
maxListWidth: { type: Number, default: void 0 },
|
|
575
|
-
/** Choose size of the input */
|
|
576
|
-
size: {
|
|
577
|
-
type: String,
|
|
578
|
-
default: "md",
|
|
579
|
-
validator: (value) => {
|
|
580
|
-
return ["mini", "xs", "sm", "md", "lg", "xl"].includes(value);
|
|
581
|
-
}
|
|
582
|
-
},
|
|
583
|
-
/** Display search input in option list */
|
|
584
|
-
search: { type: Boolean, default: false },
|
|
585
|
-
/** Search input placeholder */
|
|
586
|
-
searchPlaceholder: { type: String, default: "Search in options" },
|
|
587
|
-
/** Enable feature to select multiple values */
|
|
588
|
-
multiple: { type: Boolean, default: false }
|
|
589
|
-
},
|
|
590
|
-
emits: [
|
|
591
|
-
"close",
|
|
592
|
-
"open",
|
|
593
|
-
"blur",
|
|
594
|
-
"focus",
|
|
595
|
-
"change",
|
|
596
|
-
"update:model-value",
|
|
597
|
-
/** On selected value, returns the option object */
|
|
598
|
-
"selected-option"
|
|
599
|
-
],
|
|
600
|
-
setup(__props, { emit: __emit }) {
|
|
601
|
-
useCssVars((_ctx) => ({
|
|
602
|
-
"0804a86d": keyboardSelectedBgColor.value,
|
|
603
|
-
"4502d2ec": selectedTextColor.value,
|
|
604
|
-
"381f7054": selectedBgColor.value
|
|
605
|
-
}));
|
|
606
|
-
const MazCheckbox = defineAsyncComponent(() => import("./MazCheckbox-ab5ddda2.mjs"));
|
|
607
|
-
const SearchIcon = defineAsyncComponent(() => import("./magnifying-glass-5dffa35e.mjs"));
|
|
608
|
-
const ChevronDownIcon = defineAsyncComponent(() => import("./chevron-down-a78b9604.mjs"));
|
|
609
|
-
const NoSymbolIcon = defineAsyncComponent(() => import("./no-symbol-975ce547.mjs"));
|
|
610
|
-
const instance = getCurrentInstance();
|
|
611
|
-
const props = __props;
|
|
612
|
-
const emits = __emit;
|
|
613
|
-
const listOpened = ref(false);
|
|
614
|
-
const tmpModelValueIndex = ref();
|
|
615
|
-
const isBlackOrTransparentColor = computed(
|
|
616
|
-
() => ["black", "transparent", "white"].includes(props.color)
|
|
617
|
-
);
|
|
618
|
-
const selectedTextColor = computed(
|
|
619
|
-
() => isBlackOrTransparentColor.value ? `var(--maz-color-black)` : `var(--maz-color-${props.color}-800)`
|
|
620
|
-
);
|
|
621
|
-
const selectedBgColor = computed(
|
|
622
|
-
() => isBlackOrTransparentColor.value ? "var(--maz-color-muted)" : `var(--maz-color-${props.color}-100)`
|
|
623
|
-
);
|
|
624
|
-
const keyboardSelectedBgColor = computed(
|
|
625
|
-
() => isBlackOrTransparentColor.value ? "var(--maz-color-muted)" : `var(--maz-color-${props.color}-200)`
|
|
626
|
-
);
|
|
627
|
-
const hasListOpened = computed(() => listOpened.value || props.open);
|
|
628
|
-
const instanceId = useInstanceUniqId({
|
|
629
|
-
componentName: "MazSelect",
|
|
630
|
-
instance,
|
|
631
|
-
providedId: props.id
|
|
632
|
-
});
|
|
633
|
-
const selectedOptions = computed(
|
|
634
|
-
() => {
|
|
635
|
-
var _a;
|
|
636
|
-
return ((_a = props.options) == null ? void 0 : _a.filter((option) => {
|
|
637
|
-
return props.multiple ? Array.isArray(props.modelValue) ? props.modelValue.includes(option[props.optionValueKey]) && !isNullOrUndefined(option[props.optionValueKey]) : false : props.modelValue === option[props.optionValueKey] && !isNullOrUndefined(option[props.optionValueKey]);
|
|
638
|
-
})) ?? [];
|
|
639
|
-
}
|
|
640
|
-
);
|
|
641
|
-
onBeforeMount(() => {
|
|
642
|
-
var _a;
|
|
643
|
-
if (!((_a = props.options) == null ? void 0 : _a.length)) {
|
|
644
|
-
console.warn("[maz-ui](MazSelect) you must provide options");
|
|
645
|
-
}
|
|
646
|
-
updateTmpModelValueIndex();
|
|
647
|
-
});
|
|
648
|
-
const mazSelectElement = ref();
|
|
649
|
-
const mazInputComponent = ref();
|
|
650
|
-
const searchInputComponent = ref();
|
|
651
|
-
const optionsListElement = ref();
|
|
652
|
-
const isNullOrUndefined = (value) => {
|
|
653
|
-
return value === void 0 || value === null;
|
|
654
|
-
};
|
|
655
|
-
function isSelectedOption(option) {
|
|
656
|
-
var _a;
|
|
657
|
-
const hasOption = ((_a = selectedOptions.value) == null ? void 0 : _a.some(
|
|
658
|
-
(selectedOption) => selectedOption[props.optionValueKey] === option[props.optionValueKey]
|
|
659
|
-
)) ?? false;
|
|
660
|
-
return hasOption && !isNullOrUndefined(option[props.optionValueKey]);
|
|
661
|
-
}
|
|
662
|
-
const mazInputValue = computed(() => {
|
|
663
|
-
var _a, _b;
|
|
664
|
-
if (props.multiple && props.modelValue && Array.isArray(props.modelValue)) {
|
|
665
|
-
return props.modelValue.map(
|
|
666
|
-
(value) => {
|
|
667
|
-
var _a2, _b2;
|
|
668
|
-
return (_b2 = (_a2 = props.options) == null ? void 0 : _a2.find((option) => option[props.optionValueKey] === value)) == null ? void 0 : _b2[props.optionInputValueKey];
|
|
669
|
-
}
|
|
670
|
-
).join(", ");
|
|
671
|
-
}
|
|
672
|
-
return (_b = (_a = props.options) == null ? void 0 : _a.find((option) => option[props.optionValueKey] === props.modelValue)) == null ? void 0 : _b[props.optionInputValueKey];
|
|
673
|
-
});
|
|
674
|
-
const listTransition = computed(
|
|
675
|
-
() => props.listPosition.includes("bottom") ? "maz-slide" : "maz-slideinvert"
|
|
676
|
-
);
|
|
677
|
-
const searchQuery = ref("");
|
|
678
|
-
const query = ref("");
|
|
679
|
-
function normalizeString(str) {
|
|
680
|
-
return str.normalize("NFD").replaceAll(/[\u0300-\u036F]/g, "").replaceAll(/[^\dA-Za-z]/g, "");
|
|
681
|
-
}
|
|
682
|
-
const searchInValue = (value, query2) => {
|
|
683
|
-
return query2 && value && normalizeString(value.toString().toLocaleLowerCase().trim()).includes(
|
|
684
|
-
normalizeString(query2.toLocaleLowerCase().trim())
|
|
685
|
-
);
|
|
686
|
-
};
|
|
687
|
-
watch(
|
|
688
|
-
() => props.modelValue,
|
|
689
|
-
(value, oldValue) => {
|
|
690
|
-
}
|
|
691
|
-
);
|
|
692
|
-
function getFilteredOptionWithQuery(query2) {
|
|
693
|
-
var _a;
|
|
694
|
-
return query2 ? (_a = props.options) == null ? void 0 : _a.filter((option) => {
|
|
695
|
-
const searchValue = option[props.optionLabelKey];
|
|
696
|
-
const searchValue3 = option[props.optionValueKey];
|
|
697
|
-
const searchValue2 = option[props.optionInputValueKey];
|
|
698
|
-
return searchInValue(searchValue, query2) || searchInValue(searchValue3, query2) || searchInValue(searchValue2, query2);
|
|
699
|
-
}) : props.options;
|
|
700
|
-
}
|
|
701
|
-
const optionsList = computed(() => getFilteredOptionWithQuery(searchQuery.value));
|
|
702
|
-
const closeList = async (event) => {
|
|
703
|
-
var _a;
|
|
704
|
-
if (event && ("relatedTarget" in event && ((_a = mazSelectElement.value) == null ? void 0 : _a.contains(event.relatedTarget)) || event.type === "keydown")) {
|
|
705
|
-
return event.preventDefault();
|
|
706
|
-
}
|
|
707
|
-
await nextTick();
|
|
708
|
-
listOpened.value = false;
|
|
709
|
-
tmpModelValueIndex.value = 0;
|
|
710
|
-
emits("close", event);
|
|
711
|
-
};
|
|
712
|
-
const openList = async (event) => {
|
|
713
|
-
if (props.disabled || hasListOpened.value)
|
|
714
|
-
return;
|
|
715
|
-
event == null ? void 0 : event.preventDefault();
|
|
716
|
-
listOpened.value = true;
|
|
717
|
-
await scrollToOptionIndex();
|
|
718
|
-
emits("focus", event);
|
|
719
|
-
emits("open", listOpened.value);
|
|
720
|
-
};
|
|
721
|
-
function focusMainInput() {
|
|
722
|
-
var _a, _b;
|
|
723
|
-
(_b = ((_a = mazInputComponent.value) == null ? void 0 : _a.$el).querySelector("input")) == null ? void 0 : _b.focus();
|
|
724
|
-
}
|
|
725
|
-
function toggleList(event) {
|
|
726
|
-
listOpened.value ? closeList(event) : focusMainInput();
|
|
727
|
-
}
|
|
728
|
-
function focusSearchInputAndSetQuery(q) {
|
|
729
|
-
var _a, _b;
|
|
730
|
-
searchQuery.value = q;
|
|
731
|
-
(_b = ((_a = searchInputComponent.value) == null ? void 0 : _a.$el).querySelector("input")) == null ? void 0 : _b.focus();
|
|
732
|
-
}
|
|
733
|
-
function searchOptionWithQuery(keyPressed) {
|
|
734
|
-
var _a;
|
|
735
|
-
if (keyPressed === "Backspace" && query.value.length > 0) {
|
|
736
|
-
query.value = query.value.slice(0, -1);
|
|
737
|
-
} else {
|
|
738
|
-
query.value += keyPressed;
|
|
739
|
-
}
|
|
740
|
-
const filteredOptions = getFilteredOptionWithQuery(query.value);
|
|
741
|
-
if (filteredOptions == null ? void 0 : filteredOptions.length) {
|
|
742
|
-
tmpModelValueIndex.value = (_a = optionsList.value) == null ? void 0 : _a.findIndex(
|
|
743
|
-
(option) => option[props.optionValueKey] === filteredOptions[0][props.optionValueKey]
|
|
744
|
-
);
|
|
745
|
-
if (typeof tmpModelValueIndex.value === "number" && tmpModelValueIndex.value >= 0) {
|
|
746
|
-
scrollToOptionIndex(tmpModelValueIndex.value);
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
debounceCallback(() => {
|
|
750
|
-
query.value = "";
|
|
751
|
-
}, 1e3);
|
|
752
|
-
}
|
|
753
|
-
const mainInputKeyboardHandler = (event) => {
|
|
754
|
-
const keyPressed = event.key;
|
|
755
|
-
if (/^[\dA-Za-z]$/.test(keyPressed)) {
|
|
756
|
-
event.preventDefault();
|
|
757
|
-
openList(event);
|
|
758
|
-
props.search ? focusSearchInputAndSetQuery(keyPressed) : searchOptionWithQuery(keyPressed);
|
|
759
|
-
} else {
|
|
760
|
-
keyboardHandler(event);
|
|
761
|
-
}
|
|
762
|
-
};
|
|
763
|
-
const keyboardHandler = (event) => {
|
|
764
|
-
const code = event.code;
|
|
765
|
-
const isArrow = ["ArrowUp", "ArrowDown"].includes(code);
|
|
766
|
-
const shouldSelect = ["Enter", "Space"].includes(code);
|
|
767
|
-
const shouldCloseList = "Escape" === code && hasListOpened.value;
|
|
768
|
-
if (isArrow) {
|
|
769
|
-
arrowHandler(event, tmpModelValueIndex.value);
|
|
770
|
-
} else if (shouldSelect) {
|
|
771
|
-
enterHandler(event, tmpModelValueIndex.value);
|
|
772
|
-
} else if (shouldCloseList) {
|
|
773
|
-
closeList();
|
|
774
|
-
}
|
|
775
|
-
};
|
|
776
|
-
const arrowHandler = (event, currentIndex) => {
|
|
777
|
-
var _a;
|
|
778
|
-
event.preventDefault();
|
|
779
|
-
const code = event.code;
|
|
780
|
-
if (!hasListOpened.value)
|
|
781
|
-
openList(event);
|
|
782
|
-
const optionsLength = (_a = optionsList.value) == null ? void 0 : _a.length;
|
|
783
|
-
if (!optionsLength) {
|
|
784
|
-
return;
|
|
785
|
-
}
|
|
786
|
-
if (typeof currentIndex === "number") {
|
|
787
|
-
if (currentIndex === optionsLength - 1 && code === "ArrowDown") {
|
|
788
|
-
tmpModelValueIndex.value = 0;
|
|
789
|
-
} else if (currentIndex === 0 && code === "ArrowUp") {
|
|
790
|
-
tmpModelValueIndex.value = optionsLength - 1;
|
|
791
|
-
} else {
|
|
792
|
-
tmpModelValueIndex.value = code === "ArrowDown" ? currentIndex + 1 : currentIndex - 1;
|
|
793
|
-
}
|
|
794
|
-
} else {
|
|
795
|
-
tmpModelValueIndex.value = code === "ArrowDown" ? 0 : optionsLength - 1;
|
|
796
|
-
}
|
|
797
|
-
scrollToOptionIndex(tmpModelValueIndex.value);
|
|
798
|
-
};
|
|
799
|
-
const enterHandler = (event, currentIndex) => {
|
|
800
|
-
var _a, _b, _c;
|
|
801
|
-
event.preventDefault();
|
|
802
|
-
if (!hasListOpened.value) {
|
|
803
|
-
return openList(event);
|
|
804
|
-
}
|
|
805
|
-
const newValue = currentIndex ? ((_a = optionsList.value) == null ? void 0 : _a[currentIndex]) ?? ((_b = optionsList.value) == null ? void 0 : _b[0]) : (_c = optionsList.value) == null ? void 0 : _c[0];
|
|
806
|
-
if (!isNullOrUndefined(newValue)) {
|
|
807
|
-
updateValue(newValue);
|
|
808
|
-
}
|
|
809
|
-
};
|
|
810
|
-
async function scrollToOptionIndex(index) {
|
|
811
|
-
var _a, _b;
|
|
812
|
-
await nextTick();
|
|
813
|
-
if (typeof index !== "number") {
|
|
814
|
-
updateTmpModelValueIndex();
|
|
815
|
-
}
|
|
816
|
-
const selectedIndex = index ?? tmpModelValueIndex.value;
|
|
817
|
-
if (typeof selectedIndex === "number" && selectedIndex >= 0) {
|
|
818
|
-
(_b = (_a = optionsListElement.value) == null ? void 0 : _a.querySelectorAll(".m-select-list-item")[selectedIndex]) == null ? void 0 : _b.scrollIntoView({
|
|
819
|
-
behavior: "auto",
|
|
820
|
-
block: "nearest",
|
|
821
|
-
inline: "start"
|
|
822
|
-
});
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
function updateTmpModelValueIndex(inputOption) {
|
|
826
|
-
var _a;
|
|
827
|
-
const index = (_a = optionsList.value) == null ? void 0 : _a.findIndex((option) => {
|
|
828
|
-
var _a2, _b;
|
|
829
|
-
if (props.multiple && Array.isArray(props.modelValue)) {
|
|
830
|
-
if (inputOption) {
|
|
831
|
-
return inputOption[props.optionValueKey] === option[props.optionValueKey];
|
|
832
|
-
}
|
|
833
|
-
const values = [...props.modelValue].reverse();
|
|
834
|
-
return values[0] === option[props.optionValueKey];
|
|
835
|
-
} else {
|
|
836
|
-
return ((_b = (_a2 = selectedOptions.value) == null ? void 0 : _a2[0]) == null ? void 0 : _b[props.optionValueKey]) === option[props.optionValueKey];
|
|
837
|
-
}
|
|
838
|
-
});
|
|
839
|
-
tmpModelValueIndex.value = index && index >= 0 ? index : 0;
|
|
840
|
-
}
|
|
841
|
-
const updateValue = (inputOption, mustCloseList = true) => {
|
|
842
|
-
var _a;
|
|
843
|
-
if (mustCloseList && !props.multiple) {
|
|
844
|
-
nextTick(() => closeList());
|
|
845
|
-
}
|
|
846
|
-
searchQuery.value = "";
|
|
847
|
-
const isAlreadySelected = (_a = selectedOptions.value) == null ? void 0 : _a.some(
|
|
848
|
-
(option) => option[props.optionValueKey] === inputOption[props.optionValueKey]
|
|
849
|
-
);
|
|
850
|
-
let newValue = selectedOptions.value;
|
|
851
|
-
if (isAlreadySelected && props.multiple) {
|
|
852
|
-
newValue = newValue == null ? void 0 : newValue.filter(
|
|
853
|
-
(option) => option[props.optionValueKey] !== inputOption[props.optionValueKey]
|
|
854
|
-
);
|
|
855
|
-
} else if (props.multiple) {
|
|
856
|
-
newValue.push(inputOption);
|
|
857
|
-
} else {
|
|
858
|
-
newValue = [inputOption];
|
|
859
|
-
}
|
|
860
|
-
const selectedValues = newValue.map((option) => option[props.optionValueKey]);
|
|
861
|
-
emits("update:model-value", props.multiple ? selectedValues : selectedValues[0]);
|
|
862
|
-
emits("selected-option", inputOption);
|
|
863
|
-
updateTmpModelValueIndex(inputOption);
|
|
864
|
-
focusMainInput();
|
|
865
|
-
};
|
|
866
|
-
return (_ctx, _cache) => {
|
|
867
|
-
return openBlock(), createElementBlock(
|
|
868
|
-
"div",
|
|
869
|
-
{
|
|
870
|
-
ref_key: "mazSelectElement",
|
|
871
|
-
ref: mazSelectElement,
|
|
872
|
-
class: normalizeClass(["m-select", [{ "--is-open": hasListOpened.value, "--disabled": __props.disabled }, props.class]]),
|
|
873
|
-
style: normalizeStyle(__props.style),
|
|
874
|
-
onBlurCapture: closeList
|
|
875
|
-
},
|
|
876
|
-
[
|
|
877
|
-
createVNode(MazInput, mergeProps({
|
|
878
|
-
id: unref(instanceId),
|
|
879
|
-
ref_key: "mazInputComponent",
|
|
880
|
-
ref: mazInputComponent,
|
|
881
|
-
class: "m-select-input"
|
|
882
|
-
}, _ctx.$attrs, {
|
|
883
|
-
required: __props.required,
|
|
884
|
-
"border-active": listOpened.value,
|
|
885
|
-
color: __props.color,
|
|
886
|
-
"model-value": mazInputValue.value,
|
|
887
|
-
autocomplete: "off",
|
|
888
|
-
size: __props.size,
|
|
889
|
-
disabled: __props.disabled,
|
|
890
|
-
onFocus: withModifiers(openList, ["prevent", "stop"]),
|
|
891
|
-
onClick: withModifiers(openList, ["prevent", "stop"]),
|
|
892
|
-
onChange: _cache[0] || (_cache[0] = ($event) => emits("change", $event)),
|
|
893
|
-
onKeydown: mainInputKeyboardHandler
|
|
894
|
-
}), {
|
|
895
|
-
"right-icon": withCtx(() => [
|
|
896
|
-
createElementVNode("button", {
|
|
897
|
-
tabindex: "-1",
|
|
898
|
-
type: "button",
|
|
899
|
-
class: "m-select-input__toggle-button maz-custom",
|
|
900
|
-
onClick: withModifiers(toggleList, ["stop"])
|
|
901
|
-
}, [
|
|
902
|
-
createVNode(unref(ChevronDownIcon), { class: "m-select-chevron maz-text-xl" })
|
|
903
|
-
], 8, _hoisted_1$1)
|
|
904
|
-
]),
|
|
905
|
-
_: 1
|
|
906
|
-
/* STABLE */
|
|
907
|
-
}, 16, ["id", "required", "border-active", "color", "model-value", "size", "disabled", "onFocus", "onClick"]),
|
|
908
|
-
createVNode(Transition, { name: listTransition.value }, {
|
|
909
|
-
default: withCtx(() => [
|
|
910
|
-
hasListOpened.value ? (openBlock(), createElementBlock(
|
|
911
|
-
"div",
|
|
912
|
-
{
|
|
913
|
-
key: 0,
|
|
914
|
-
ref_key: "optionsListElement",
|
|
915
|
-
ref: optionsListElement,
|
|
916
|
-
class: normalizeClass(["m-select-list", {
|
|
917
|
-
"--top": __props.listPosition.includes("top"),
|
|
918
|
-
"--left": __props.listPosition.includes("left"),
|
|
919
|
-
"--right": __props.listPosition.includes("right"),
|
|
920
|
-
"--bottom": __props.listPosition.includes("bottom")
|
|
921
|
-
}]),
|
|
922
|
-
style: normalizeStyle({
|
|
923
|
-
maxHeight: `${__props.maxListHeight}px`,
|
|
924
|
-
maxWidth: `${__props.maxListWidth}px`
|
|
925
|
-
})
|
|
926
|
-
},
|
|
927
|
-
[
|
|
928
|
-
__props.search ? (openBlock(), createElementBlock("div", _hoisted_2$1, [
|
|
929
|
-
createVNode(MazInput, {
|
|
930
|
-
ref_key: "searchInputComponent",
|
|
931
|
-
ref: searchInputComponent,
|
|
932
|
-
modelValue: searchQuery.value,
|
|
933
|
-
"onUpdate:modelValue": [
|
|
934
|
-
_cache[1] || (_cache[1] = ($event) => searchQuery.value = $event),
|
|
935
|
-
_cache[2] || (_cache[2] = ($event) => tmpModelValueIndex.value = 0)
|
|
936
|
-
],
|
|
937
|
-
size: "sm",
|
|
938
|
-
color: __props.color,
|
|
939
|
-
placeholder: __props.searchPlaceholder,
|
|
940
|
-
name: "search",
|
|
941
|
-
autocomplete: "off",
|
|
942
|
-
tabindex: "-1",
|
|
943
|
-
class: "m-select-list__search-input",
|
|
944
|
-
onKeydown: keyboardHandler
|
|
945
|
-
}, {
|
|
946
|
-
"left-icon": withCtx(() => [
|
|
947
|
-
createVNode(unref(SearchIcon), { class: "maz-h-[1.3rem] maz-w-[1.3rem]" })
|
|
948
|
-
]),
|
|
949
|
-
_: 1
|
|
950
|
-
/* STABLE */
|
|
951
|
-
}, 8, ["modelValue", "color", "placeholder"])
|
|
952
|
-
])) : createCommentVNode("v-if", true),
|
|
953
|
-
createCommentVNode("\n @slot No results slot - Displayed when no results corresponding with seeach query\n "),
|
|
954
|
-
!optionsList.value || optionsList.value.length <= 0 ? renderSlot(_ctx.$slots, "no-results", { key: 1 }, () => [
|
|
955
|
-
createElementVNode("span", _hoisted_3, [
|
|
956
|
-
createVNode(unref(NoSymbolIcon), { class: "maz-h-6 maz-w-6 maz-text-normal" })
|
|
957
|
-
])
|
|
958
|
-
], true) : (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
959
|
-
(openBlock(true), createElementBlock(
|
|
960
|
-
Fragment,
|
|
961
|
-
null,
|
|
962
|
-
renderList(optionsList.value, (option, i) => {
|
|
963
|
-
return openBlock(), createElementBlock("button", {
|
|
964
|
-
key: i,
|
|
965
|
-
tabindex: "-1",
|
|
966
|
-
type: "button",
|
|
967
|
-
class: normalizeClass(["m-select-list-item maz-custom", [
|
|
968
|
-
{
|
|
969
|
-
"--is-keyboard-selected": tmpModelValueIndex.value === i,
|
|
970
|
-
"--is-selected": isSelectedOption(option),
|
|
971
|
-
"--is-none-value": isNullOrUndefined(option[__props.optionValueKey])
|
|
972
|
-
}
|
|
973
|
-
]]),
|
|
974
|
-
style: normalizeStyle({ minHeight: `${__props.itemHeight}px` }),
|
|
975
|
-
onClick: withModifiers(($event) => updateValue(option), ["prevent", "stop"])
|
|
976
|
-
}, [
|
|
977
|
-
__props.multiple ? (openBlock(), createBlock(unref(MazCheckbox), {
|
|
978
|
-
key: 0,
|
|
979
|
-
tabindex: "-1",
|
|
980
|
-
"model-value": isSelectedOption(option),
|
|
981
|
-
size: "sm",
|
|
982
|
-
color: __props.color
|
|
983
|
-
}, null, 8, ["model-value", "color"])) : createCommentVNode("v-if", true),
|
|
984
|
-
createCommentVNode("\n @slot Custom option\n @binding {Object} option\n @binding {Boolean} is-selected\n "),
|
|
985
|
-
renderSlot(_ctx.$slots, "default", {
|
|
986
|
-
option,
|
|
987
|
-
isSelected: isSelectedOption(option)
|
|
988
|
-
}, () => [
|
|
989
|
-
createElementVNode(
|
|
990
|
-
"span",
|
|
991
|
-
null,
|
|
992
|
-
toDisplayString(option[__props.optionLabelKey]),
|
|
993
|
-
1
|
|
994
|
-
/* TEXT */
|
|
995
|
-
)
|
|
996
|
-
], true)
|
|
997
|
-
], 14, _hoisted_5);
|
|
998
|
-
}),
|
|
999
|
-
128
|
|
1000
|
-
/* KEYED_FRAGMENT */
|
|
1001
|
-
))
|
|
1002
|
-
]))
|
|
1003
|
-
],
|
|
1004
|
-
6
|
|
1005
|
-
/* CLASS, STYLE */
|
|
1006
|
-
)) : createCommentVNode("v-if", true)
|
|
1007
|
-
]),
|
|
1008
|
-
_: 3
|
|
1009
|
-
/* FORWARDED */
|
|
1010
|
-
}, 8, ["name"])
|
|
1011
|
-
],
|
|
1012
|
-
38
|
|
1013
|
-
/* CLASS, STYLE, HYDRATE_EVENTS */
|
|
1014
|
-
);
|
|
1015
|
-
};
|
|
1016
|
-
}
|
|
1017
|
-
});
|
|
1018
|
-
const MazSelect_vue_vue_type_style_index_0_scoped_c313b4a6_lang = "";
|
|
1019
|
-
const MazSelect = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-c313b4a6"]]);
|
|
1020
|
-
const _hoisted_1 = ["id"];
|
|
1021
|
-
const _hoisted_2 = {
|
|
1022
|
-
key: 0,
|
|
1023
|
-
class: "maz-text-lg"
|
|
1024
|
-
};
|
|
1025
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
1026
|
-
...{
|
|
1027
|
-
inheritAttrs: false
|
|
1028
|
-
},
|
|
1029
|
-
__name: "MazPhoneNumberInput",
|
|
1030
|
-
props: {
|
|
1031
|
-
style: { type: [String, Array, Object], default: void 0 },
|
|
1032
|
-
class: { type: String, default: void 0 },
|
|
1033
|
-
/** Country calling code + telephone number in international format */
|
|
1034
|
-
modelValue: {
|
|
1035
|
-
type: String,
|
|
1036
|
-
validator: (prop) => {
|
|
1037
|
-
return typeof prop === "string" || prop === void 0;
|
|
1038
|
-
},
|
|
1039
|
-
default: void 0
|
|
1040
|
-
},
|
|
1041
|
-
/** @deprecated */
|
|
1042
|
-
defaultPhoneNumber: { type: String, default: void 0 },
|
|
1043
|
-
/** Country code selected - Ex: "FR" */
|
|
1044
|
-
countryCode: {
|
|
1045
|
-
type: String,
|
|
1046
|
-
default: void 0,
|
|
1047
|
-
validator: (code) => isCountryAvailable(code)
|
|
1048
|
-
},
|
|
1049
|
-
/** @deprecated - use country-code or v-model:country-code */
|
|
1050
|
-
defaultCountryCode: {
|
|
1051
|
-
type: String,
|
|
1052
|
-
default: void 0,
|
|
1053
|
-
validator: (code) => isCountryAvailable(code)
|
|
1054
|
-
},
|
|
1055
|
-
id: { type: String, default: void 0 },
|
|
1056
|
-
placeholder: { type: String, default: void 0 },
|
|
1057
|
-
/** List of country codes to place first in the select list - Ex: ['FR', 'BE', 'GE'] */
|
|
1058
|
-
preferredCountries: { type: Array, default: void 0 },
|
|
1059
|
-
/** List of country codes to be removed from the select list - Ex: ['FR', 'BE', 'GE'] */
|
|
1060
|
-
ignoredCountries: { type: Array, default: void 0 },
|
|
1061
|
-
/** List of country codes to only have the countries selected in the select list - Ex: ['FR', 'BE', 'GE'] */
|
|
1062
|
-
onlyCountries: { type: Array, default: void 0 },
|
|
1063
|
-
/** Locale strings of the component */
|
|
1064
|
-
translations: { type: Object, default: void 0 },
|
|
1065
|
-
/** Position where the list of countries will be opened */
|
|
1066
|
-
listPosition: {
|
|
1067
|
-
type: String,
|
|
1068
|
-
default: "bottom left",
|
|
1069
|
-
validator: (value) => {
|
|
1070
|
-
return ["top", "top right", "top left", "bottom", "bottom right", "bottom left"].includes(
|
|
1071
|
-
value
|
|
1072
|
-
);
|
|
1073
|
-
}
|
|
1074
|
-
},
|
|
1075
|
-
/** Component color applied - Ex: "secondary" */
|
|
1076
|
-
color: { type: String, default: "primary" },
|
|
1077
|
-
/** Component size applied - Ex: "sm" */
|
|
1078
|
-
size: {
|
|
1079
|
-
type: String,
|
|
1080
|
-
default: "md",
|
|
1081
|
-
validator: (value) => {
|
|
1082
|
-
return ["mini", "xs", "sm", "md", "lg", "xl"].includes(value);
|
|
1083
|
-
}
|
|
1084
|
-
},
|
|
1085
|
-
/** Remove flags in country list */
|
|
1086
|
-
noFlags: { type: Boolean, default: false },
|
|
1087
|
-
/** Disable input */
|
|
1088
|
-
disabled: { type: Boolean, default: false },
|
|
1089
|
-
/** No show the phone number example */
|
|
1090
|
-
noExample: { type: Boolean, default: false },
|
|
1091
|
-
/** Disable search input in country list */
|
|
1092
|
-
noSearch: { type: Boolean, default: false },
|
|
1093
|
-
/** By default the component use the browser locale to set the default country code if not country code is provided */
|
|
1094
|
-
noUseBrowserLocale: { type: Boolean, default: false },
|
|
1095
|
-
/** The component will make a request to get the location of the user and use it to set the default country code */
|
|
1096
|
-
fetchCountry: { type: Boolean, default: false },
|
|
1097
|
-
/** No show the country selector */
|
|
1098
|
-
noCountrySelector: { type: Boolean, default: false },
|
|
1099
|
-
/** Show country calling code in the country list */
|
|
1100
|
-
showCodeOnList: { type: Boolean, default: false },
|
|
1101
|
-
/** Replace country names */
|
|
1102
|
-
customCountriesList: {
|
|
1103
|
-
type: Object,
|
|
1104
|
-
default: void 0
|
|
1105
|
-
},
|
|
1106
|
-
/** Disabled auto-format as you type */
|
|
1107
|
-
noFormattingAsYouType: { type: Boolean, default: false },
|
|
1108
|
-
/**
|
|
1109
|
-
* locale of country list - Ex: "fr-FR"
|
|
1110
|
-
* @default {string} browser locale
|
|
1111
|
-
*/
|
|
1112
|
-
countryLocale: { type: String, default: void 0 },
|
|
1113
|
-
/** Disable validation error UI */
|
|
1114
|
-
noValidationError: { type: Boolean, default: false },
|
|
1115
|
-
/** Disable validation success UI */
|
|
1116
|
-
noValidationSuccess: { type: Boolean, default: false },
|
|
1117
|
-
/** Add success UI */
|
|
1118
|
-
success: { type: Boolean, default: false },
|
|
1119
|
-
/** Add error UI */
|
|
1120
|
-
error: { type: Boolean, default: false },
|
|
1121
|
-
/** Will replace the calling code by the country name in the country selector */
|
|
1122
|
-
countrySelectorDisplayName: { type: Boolean, default: false },
|
|
1123
|
-
/** Choose the width of the country selector */
|
|
1124
|
-
countrySelectorWidth: { type: String, default: "9rem" }
|
|
1125
|
-
},
|
|
1126
|
-
emits: [
|
|
1127
|
-
/** emitted when country or phone number changes
|
|
1128
|
-
* @property {Result} results - meta info of current phone numnber
|
|
1129
|
-
*/
|
|
1130
|
-
"update",
|
|
1131
|
-
/** emitted when country or phone number changes
|
|
1132
|
-
* @property {Result} results - meta info of current phone numnber
|
|
1133
|
-
*/
|
|
1134
|
-
"data",
|
|
1135
|
-
/** emitted when selected country changes
|
|
1136
|
-
* @property {CountryCode} countryCode - Country code
|
|
1137
|
-
*/
|
|
1138
|
-
"country-code",
|
|
1139
|
-
/** emitted when country or phone number changes
|
|
1140
|
-
* @property {String} phoneNumber - phoneNumber formatted
|
|
1141
|
-
*/
|
|
1142
|
-
"update:model-value",
|
|
1143
|
-
/** emitted when country changes
|
|
1144
|
-
* @property {CountryCode} countryCode - Country code
|
|
1145
|
-
*/
|
|
1146
|
-
"update:country-code"
|
|
1147
|
-
],
|
|
1148
|
-
setup(__props, { emit: __emit }) {
|
|
1149
|
-
const {
|
|
1150
|
-
fetchCountryCode: fetchCountryCode2,
|
|
1151
|
-
browserLocale: browserLocale2,
|
|
1152
|
-
getResultsFromPhoneNumber: getResultsFromPhoneNumber2,
|
|
1153
|
-
getAsYouTypeFormat: getAsYouTypeFormat2,
|
|
1154
|
-
getCountriesList: getCountriesList2,
|
|
1155
|
-
getPhoneNumberExample: getPhoneNumberExample2,
|
|
1156
|
-
sanitizePhoneNumber: sanitizePhoneNumber2,
|
|
1157
|
-
loadPhoneNumberExamplesFile: loadPhoneNumberExamplesFile2
|
|
1158
|
-
} = useLibphonenumber();
|
|
1159
|
-
const emits = __emit;
|
|
1160
|
-
const props = __props;
|
|
1161
|
-
const instance = getCurrentInstance();
|
|
1162
|
-
const instanceId = useInstanceUniqId({
|
|
1163
|
-
componentName: "MazPhoneNumberInput",
|
|
1164
|
-
instance,
|
|
1165
|
-
providedId: props.id
|
|
1166
|
-
});
|
|
1167
|
-
const PhoneNumberInput = ref();
|
|
1168
|
-
const CountrySelector = ref();
|
|
1169
|
-
const selectionRange = reactive({
|
|
1170
|
-
start: 0,
|
|
1171
|
-
end: 0,
|
|
1172
|
-
cursorAtEnd: true
|
|
1173
|
-
});
|
|
1174
|
-
const examplesFileLoaded = ref(false);
|
|
1175
|
-
const inputFocused = ref(false);
|
|
1176
|
-
const countries = computed(() => getCountriesList2(props.countryLocale, props.customCountriesList));
|
|
1177
|
-
const countriesList = computed(() => {
|
|
1178
|
-
var _a;
|
|
1179
|
-
return (_a = countries.value) == null ? void 0 : _a.filter((item) => {
|
|
1180
|
-
var _a2;
|
|
1181
|
-
return !((_a2 = props.ignoredCountries) == null ? void 0 : _a2.includes(item.iso2));
|
|
1182
|
-
});
|
|
1183
|
-
});
|
|
1184
|
-
const countriesFiltered = computed(() => {
|
|
1185
|
-
const countries2 = props.onlyCountries || props.preferredCountries;
|
|
1186
|
-
return countries2 == null ? void 0 : countries2.map(
|
|
1187
|
-
(country) => {
|
|
1188
|
-
var _a;
|
|
1189
|
-
return (_a = countriesList.value) == null ? void 0 : _a.find((item) => item.iso2.includes(country));
|
|
1190
|
-
}
|
|
1191
|
-
);
|
|
1192
|
-
});
|
|
1193
|
-
const otherCountries = computed(() => {
|
|
1194
|
-
var _a;
|
|
1195
|
-
return (_a = countriesList.value) == null ? void 0 : _a.filter((item) => {
|
|
1196
|
-
var _a2;
|
|
1197
|
-
return !((_a2 = props.preferredCountries) == null ? void 0 : _a2.includes(item.iso2));
|
|
1198
|
-
});
|
|
1199
|
-
});
|
|
1200
|
-
const countriesSorted = computed(() => {
|
|
1201
|
-
return props.preferredCountries ? [...countriesFiltered.value ?? [], ...otherCountries.value ?? []] : props.onlyCountries ? countriesFiltered.value : countriesList.value;
|
|
1202
|
-
});
|
|
1203
|
-
const countryOptions = computed(() => {
|
|
1204
|
-
var _a;
|
|
1205
|
-
return (_a = countriesSorted.value) == null ? void 0 : _a.map((country) => {
|
|
1206
|
-
return country ? {
|
|
1207
|
-
...country,
|
|
1208
|
-
dialCode: `+${country.dialCode}`
|
|
1209
|
-
} : void 0;
|
|
1210
|
-
}).filter(truthyFilter);
|
|
1211
|
-
});
|
|
1212
|
-
const locales = computed(() => ({
|
|
1213
|
-
...defaultLocales,
|
|
1214
|
-
...props.translations
|
|
1215
|
-
}));
|
|
1216
|
-
const inputPlaceholder = computed(() => {
|
|
1217
|
-
if (props.placeholder) {
|
|
1218
|
-
return props.placeholder;
|
|
1219
|
-
}
|
|
1220
|
-
const defaultPlaceholder = locales.value.phoneInput.placeholder;
|
|
1221
|
-
if (props.noExample || !examplesFileLoaded.value) {
|
|
1222
|
-
return defaultPlaceholder;
|
|
1223
|
-
} else {
|
|
1224
|
-
const example = getPhoneNumberExample2(countryCode.value);
|
|
1225
|
-
return results.value.isValid || !example ? defaultPlaceholder : `${locales.value.phoneInput.example} ${example}`;
|
|
1226
|
-
}
|
|
1227
|
-
});
|
|
1228
|
-
const model = computed({
|
|
1229
|
-
get: () => props.modelValue || props.defaultPhoneNumber,
|
|
1230
|
-
set: (value) => {
|
|
1231
|
-
emits("update:model-value", value);
|
|
1232
|
-
}
|
|
1233
|
-
});
|
|
1234
|
-
const internalCountryCode = ref();
|
|
1235
|
-
const countryCode = computed({
|
|
1236
|
-
get: () => props.countryCode || props.defaultCountryCode || internalCountryCode.value,
|
|
1237
|
-
set: (value) => {
|
|
1238
|
-
emits("country-code", value);
|
|
1239
|
-
emits("update:country-code", value);
|
|
1240
|
-
internalCountryCode.value = value;
|
|
1241
|
-
}
|
|
1242
|
-
});
|
|
1243
|
-
const internalValue = ref(model.value);
|
|
1244
|
-
const results = ref(
|
|
1245
|
-
getResultsFromPhoneNumber2({
|
|
1246
|
-
phoneNumber: model.value,
|
|
1247
|
-
countryCode: countryCode.value
|
|
1248
|
-
})
|
|
1249
|
-
);
|
|
1250
|
-
const asYouTypeFormatted = ref();
|
|
1251
|
-
const inputValue = computed(() => {
|
|
1252
|
-
if (props.noFormattingAsYouType) {
|
|
1253
|
-
return internalValue.value ?? "";
|
|
1254
|
-
}
|
|
1255
|
-
return asYouTypeFormatted.value ?? internalValue.value ?? "";
|
|
1256
|
-
});
|
|
1257
|
-
async function setCountryFromIpWho() {
|
|
1258
|
-
const fetchedLocale = await fetchCountryCode2();
|
|
1259
|
-
if (fetchedLocale)
|
|
1260
|
-
setCountryCode(fetchedLocale);
|
|
1261
|
-
}
|
|
1262
|
-
async function loadExamples() {
|
|
1263
|
-
try {
|
|
1264
|
-
if (!props.noExample && !examplesFileLoaded.value) {
|
|
1265
|
-
await loadPhoneNumberExamplesFile2();
|
|
1266
|
-
examplesFileLoaded.value = true;
|
|
1267
|
-
}
|
|
1268
|
-
} catch {
|
|
1269
|
-
console.error("[maz-ui](MazPhoneNumberInput) while loading phone number examples file");
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
onMounted(async () => {
|
|
1273
|
-
await parseModel(model.value);
|
|
1274
|
-
await nextTick();
|
|
1275
|
-
if (props.fetchCountry && !countryCode.value) {
|
|
1276
|
-
await setCountryFromIpWho();
|
|
1277
|
-
}
|
|
1278
|
-
if (!props.defaultCountryCode && !props.noUseBrowserLocale && !countryCode.value) {
|
|
1279
|
-
setCountryCodeFromBrowserLocale();
|
|
1280
|
-
}
|
|
1281
|
-
await loadExamples();
|
|
1282
|
-
});
|
|
1283
|
-
watch(
|
|
1284
|
-
() => results.value,
|
|
1285
|
-
(newResults) => {
|
|
1286
|
-
emits("update", newResults);
|
|
1287
|
-
emits("data", newResults);
|
|
1288
|
-
},
|
|
1289
|
-
{ immediate: true, deep: true }
|
|
1290
|
-
);
|
|
1291
|
-
watch(
|
|
1292
|
-
() => countryCode.value,
|
|
1293
|
-
(newCountryCode, oldCountryCode) => {
|
|
1294
|
-
if (newCountryCode && newCountryCode !== oldCountryCode) {
|
|
1295
|
-
setCountryCode(newCountryCode);
|
|
1296
|
-
onInputValueChanged(inputValue.value);
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1299
|
-
);
|
|
1300
|
-
watch(
|
|
1301
|
-
() => model.value,
|
|
1302
|
-
async (newModel, oldModel) => {
|
|
1303
|
-
if (newModel !== oldModel) {
|
|
1304
|
-
parseModel(newModel);
|
|
1305
|
-
}
|
|
1306
|
-
}
|
|
1307
|
-
);
|
|
1308
|
-
watch(
|
|
1309
|
-
() => inputValue.value,
|
|
1310
|
-
async (newModel, oldModel) => {
|
|
1311
|
-
if (!props.noFormattingAsYouType && newModel && newModel !== oldModel) {
|
|
1312
|
-
const input = getPhoneNumberInput();
|
|
1313
|
-
if (input && !results.value.isValid && typeof selectionRange.start === "number" && !selectionRange.cursorAtEnd) {
|
|
1314
|
-
const start = selectionRange.start;
|
|
1315
|
-
const end = selectionRange.end;
|
|
1316
|
-
setTimeout(() => {
|
|
1317
|
-
input.setSelectionRange(start, end ?? start);
|
|
1318
|
-
}, 0);
|
|
1319
|
-
}
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
);
|
|
1323
|
-
function setCountryCodeFromBrowserLocale() {
|
|
1324
|
-
const { locale } = browserLocale2();
|
|
1325
|
-
if (locale) {
|
|
1326
|
-
setCountryCode(locale);
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
function updateResults(phoneNumber, countryCode2) {
|
|
1330
|
-
results.value = getResultsFromPhoneNumber2({
|
|
1331
|
-
phoneNumber,
|
|
1332
|
-
countryCode: countryCode2
|
|
1333
|
-
});
|
|
1334
|
-
}
|
|
1335
|
-
async function onInputValueChanged(phoneNumber) {
|
|
1336
|
-
const input = getPhoneNumberInput();
|
|
1337
|
-
selectionRange.start = input == null ? void 0 : input.selectionStart;
|
|
1338
|
-
selectionRange.end = input == null ? void 0 : input.selectionEnd;
|
|
1339
|
-
selectionRange.cursorAtEnd = selectionRange.start ? selectionRange.start >= phoneNumber.length : true;
|
|
1340
|
-
const sanitizedPhoneNumber = sanitizePhoneNumber2(phoneNumber);
|
|
1341
|
-
internalValue.value = sanitizedPhoneNumber;
|
|
1342
|
-
const newResults = getResultsFromPhoneNumber2({
|
|
1343
|
-
phoneNumber: sanitizedPhoneNumber,
|
|
1344
|
-
countryCode: countryCode.value
|
|
1345
|
-
});
|
|
1346
|
-
model.value = newResults.e164;
|
|
1347
|
-
}
|
|
1348
|
-
function onCountryChanged(codeCountry) {
|
|
1349
|
-
updateResults(inputValue.value, codeCountry);
|
|
1350
|
-
setCountryCode(codeCountry, true);
|
|
1351
|
-
}
|
|
1352
|
-
function setCountryCode(selectedCountryCode, autoFocusInput = false) {
|
|
1353
|
-
try {
|
|
1354
|
-
const countryAvailable = isCountryAvailable(selectedCountryCode);
|
|
1355
|
-
if (countryAvailable) {
|
|
1356
|
-
countryCode.value = selectedCountryCode;
|
|
1357
|
-
if (autoFocusInput) {
|
|
1358
|
-
focusPhoneNumberInput();
|
|
1359
|
-
}
|
|
1360
|
-
}
|
|
1361
|
-
} catch (error) {
|
|
1362
|
-
console.error(`[maz-ui](MazPhoneNumberInput) ${error}`);
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
async function parseModel(newModel) {
|
|
1366
|
-
updateResults(newModel, countryCode.value);
|
|
1367
|
-
await nextTick();
|
|
1368
|
-
if (props.noFormattingAsYouType) {
|
|
1369
|
-
internalValue.value = inputValue.value;
|
|
1370
|
-
} else {
|
|
1371
|
-
asYouTypeFormatted.value = selectionRange.cursorAtEnd || results.value.isValid ? internalValue.value = getAsYouTypeFormat2(
|
|
1372
|
-
results.value.countryCode ?? countryCode.value,
|
|
1373
|
-
results.value.formatNational ?? internalValue.value
|
|
1374
|
-
) : internalValue.value;
|
|
1375
|
-
}
|
|
1376
|
-
await nextTick();
|
|
1377
|
-
autoUpdateCountryCodeWithResults(results.value);
|
|
1378
|
-
}
|
|
1379
|
-
function autoUpdateCountryCodeWithResults(newResults) {
|
|
1380
|
-
if (newResults.countryCode && countryCode.value !== newResults.countryCode) {
|
|
1381
|
-
setCountryCode(newResults.countryCode);
|
|
1382
|
-
}
|
|
1383
|
-
}
|
|
1384
|
-
function getPhoneNumberInput() {
|
|
1385
|
-
var _a;
|
|
1386
|
-
return (_a = PhoneNumberInput.value) == null ? void 0 : _a.$el.querySelector("input");
|
|
1387
|
-
}
|
|
1388
|
-
function focusCountrySelector() {
|
|
1389
|
-
var _a, _b;
|
|
1390
|
-
(_b = (_a = CountrySelector.value) == null ? void 0 : _a.$el.querySelector("input")) == null ? void 0 : _b.focus();
|
|
1391
|
-
}
|
|
1392
|
-
async function focusPhoneNumberInput() {
|
|
1393
|
-
var _a;
|
|
1394
|
-
await nextTick();
|
|
1395
|
-
(_a = getPhoneNumberInput()) == null ? void 0 : _a.focus();
|
|
1396
|
-
}
|
|
1397
|
-
return (_ctx, _cache) => {
|
|
1398
|
-
var _a, _b, _c, _d;
|
|
1399
|
-
return openBlock(), createElementBlock("div", {
|
|
1400
|
-
id: unref(instanceId),
|
|
1401
|
-
class: normalizeClass(["m-phone-number-input", [
|
|
1402
|
-
props.class,
|
|
1403
|
-
{
|
|
1404
|
-
"--no-flags": __props.noFlags
|
|
1405
|
-
}
|
|
1406
|
-
]]),
|
|
1407
|
-
style: normalizeStyle(__props.style)
|
|
1408
|
-
}, [
|
|
1409
|
-
countryCode.value && !__props.noFlags && !__props.noCountrySelector ? (openBlock(), createElementBlock("button", {
|
|
1410
|
-
key: 0,
|
|
1411
|
-
class: "m-phone-number-input__country-flag maz-text-xl",
|
|
1412
|
-
tabindex: "-1",
|
|
1413
|
-
type: "button",
|
|
1414
|
-
onClick: focusCountrySelector
|
|
1415
|
-
}, [
|
|
1416
|
-
createCommentVNode('\n @slot Country selector flag\n @binding {String} country-code - current selected country code - Ex: `"FR"`\n '),
|
|
1417
|
-
renderSlot(_ctx.$slots, "selector-flag", { countryCode: countryCode.value }, () => [
|
|
1418
|
-
createTextVNode(
|
|
1419
|
-
toDisplayString(unref(countryCodeToUnicodeFlag)(countryCode.value)),
|
|
1420
|
-
1
|
|
1421
|
-
/* TEXT */
|
|
1422
|
-
)
|
|
1423
|
-
], true)
|
|
1424
|
-
])) : createCommentVNode("v-if", true),
|
|
1425
|
-
!__props.noCountrySelector ? (openBlock(), createBlock(MazSelect, {
|
|
1426
|
-
key: 1,
|
|
1427
|
-
ref_key: "CountrySelector",
|
|
1428
|
-
ref: CountrySelector,
|
|
1429
|
-
class: "m-phone-number-input__select",
|
|
1430
|
-
"model-value": countryCode.value,
|
|
1431
|
-
"option-value-key": "iso2",
|
|
1432
|
-
"option-label-key": "name",
|
|
1433
|
-
"option-input-value-key": __props.countrySelectorDisplayName ? "name" : "dialCode",
|
|
1434
|
-
"max-list-width": 250,
|
|
1435
|
-
disabled: __props.disabled,
|
|
1436
|
-
color: __props.color,
|
|
1437
|
-
size: __props.size,
|
|
1438
|
-
"list-position": __props.listPosition,
|
|
1439
|
-
search: !__props.noSearch,
|
|
1440
|
-
"search-placeholder": locales.value.countrySelector.searchPlaceholder,
|
|
1441
|
-
options: countryOptions.value,
|
|
1442
|
-
error: __props.error || (!__props.noValidationError ? !!inputValue.value && !countryCode.value : false),
|
|
1443
|
-
hint: !!inputValue.value && !countryCode.value ? locales.value.countrySelector.error : void 0,
|
|
1444
|
-
label: locales.value.countrySelector.placeholder,
|
|
1445
|
-
success: __props.success || (!__props.noValidationSuccess ? (_a = results.value) == null ? void 0 : _a.isValid : false),
|
|
1446
|
-
style: normalizeStyle({
|
|
1447
|
-
width: __props.countrySelectorWidth
|
|
1448
|
-
}),
|
|
1449
|
-
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => onCountryChanged($event)),
|
|
1450
|
-
onFocus: _cache[1] || (_cache[1] = ($event) => inputFocused.value = false)
|
|
1451
|
-
}, {
|
|
1452
|
-
default: withCtx(({ option, isSelected }) => [
|
|
1453
|
-
createElementVNode(
|
|
1454
|
-
"div",
|
|
1455
|
-
{
|
|
1456
|
-
class: normalizeClass(["m-phone-number-input__select__item maz-flex maz-items-center maz-gap-1 maz-truncate", {
|
|
1457
|
-
"m-phone-number-input__select__item--selected": isSelected
|
|
1458
|
-
}])
|
|
1459
|
-
},
|
|
1460
|
-
[
|
|
1461
|
-
!__props.noFlags && typeof option.iso2 === "string" ? (openBlock(), createElementBlock("span", _hoisted_2, [
|
|
1462
|
-
createCommentVNode('\n @slot Country list flag\n @binding {String} country-code - country code of option - Ex: `"FR"`\n @binding {{ iso2: string; dialCode: string; name: string; }} option - country data\n @binding {Boolean} is-selected - `true` if option is selected\n '),
|
|
1463
|
-
renderSlot(_ctx.$slots, "country-list-flag", {
|
|
1464
|
-
countryCode: option.iso2,
|
|
1465
|
-
option,
|
|
1466
|
-
isSelected
|
|
1467
|
-
}, () => [
|
|
1468
|
-
createTextVNode(
|
|
1469
|
-
toDisplayString(unref(countryCodeToUnicodeFlag)(option.iso2)),
|
|
1470
|
-
1
|
|
1471
|
-
/* TEXT */
|
|
1472
|
-
)
|
|
1473
|
-
], true)
|
|
1474
|
-
])) : createCommentVNode("v-if", true),
|
|
1475
|
-
__props.showCodeOnList ? (openBlock(), createElementBlock(
|
|
1476
|
-
"span",
|
|
1477
|
-
{
|
|
1478
|
-
key: 1,
|
|
1479
|
-
class: normalizeClass(["maz-w-9 maz-flex-none", { "maz-text-muted": !isSelected }])
|
|
1480
|
-
},
|
|
1481
|
-
toDisplayString(option.dialCode),
|
|
1482
|
-
3
|
|
1483
|
-
/* TEXT, CLASS */
|
|
1484
|
-
)) : createCommentVNode("v-if", true),
|
|
1485
|
-
createElementVNode(
|
|
1486
|
-
"span",
|
|
1487
|
-
{
|
|
1488
|
-
class: normalizeClass(["maz-flex-1 maz-truncate", { "maz-font-semibold": isSelected }])
|
|
1489
|
-
},
|
|
1490
|
-
toDisplayString(option.name),
|
|
1491
|
-
3
|
|
1492
|
-
/* TEXT, CLASS */
|
|
1493
|
-
)
|
|
1494
|
-
],
|
|
1495
|
-
2
|
|
1496
|
-
/* CLASS */
|
|
1497
|
-
)
|
|
1498
|
-
]),
|
|
1499
|
-
_: 3
|
|
1500
|
-
/* FORWARDED */
|
|
1501
|
-
}, 8, ["model-value", "option-input-value-key", "disabled", "color", "size", "list-position", "search", "search-placeholder", "options", "error", "hint", "label", "success", "style"])) : createCommentVNode("v-if", true),
|
|
1502
|
-
createVNode(MazInput, mergeProps({
|
|
1503
|
-
id: __props.id,
|
|
1504
|
-
ref_key: "PhoneNumberInput",
|
|
1505
|
-
ref: PhoneNumberInput,
|
|
1506
|
-
"model-value": inputValue.value,
|
|
1507
|
-
label: inputPlaceholder.value,
|
|
1508
|
-
disabled: __props.disabled,
|
|
1509
|
-
color: __props.color,
|
|
1510
|
-
error: __props.error || (!__props.noValidationError ? !!inputValue.value && !((_b = results.value) == null ? void 0 : _b.isValid) : false)
|
|
1511
|
-
}, _ctx.$attrs, {
|
|
1512
|
-
size: __props.size,
|
|
1513
|
-
"icon-name": "phone",
|
|
1514
|
-
type: "tel",
|
|
1515
|
-
clearable: "",
|
|
1516
|
-
success: __props.success || (!__props.noValidationSuccess ? (_c = results.value) == null ? void 0 : _c.isValid : false),
|
|
1517
|
-
class: ["m-phone-number-input__input maz-flex-1", {
|
|
1518
|
-
"--border-radius": !__props.noCountrySelector,
|
|
1519
|
-
"--error": __props.error || !((_d = results.value) == null ? void 0 : _d.isValid),
|
|
1520
|
-
"--focused": inputFocused.value
|
|
1521
|
-
}],
|
|
1522
|
-
onFocus: _cache[2] || (_cache[2] = ($event) => inputFocused.value = true),
|
|
1523
|
-
onBlur: _cache[3] || (_cache[3] = ($event) => inputFocused.value = false),
|
|
1524
|
-
"onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => onInputValueChanged($event))
|
|
1525
|
-
}), null, 16, ["id", "model-value", "label", "disabled", "color", "error", "size", "success", "class"])
|
|
1526
|
-
], 14, _hoisted_1);
|
|
1527
|
-
};
|
|
1528
|
-
}
|
|
1529
|
-
});
|
|
1530
|
-
const MazPhoneNumberInput_vue_vue_type_style_index_0_scoped_13c350c6_lang = "";
|
|
1531
|
-
const MazPhoneNumberInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-13c350c6"]]);
|
|
1532
|
-
export {
|
|
1533
|
-
MazPhoneNumberInput as M,
|
|
1534
|
-
_export_sfc as _,
|
|
1535
|
-
useInstanceUniqId as u
|
|
1536
|
-
};
|