maz-ui 3.19.3 → 3.20.0
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/MazCheckbox.d.ts +22 -2
- package/components/MazCheckbox.mjs +144 -32
- package/components/MazPhoneNumberInput.mjs +1 -1
- package/components/MazSelect.d.ts +12 -4
- package/components/MazSelect.mjs +1 -1
- package/components/assets/MazCheckbox.css +1 -1
- package/components/assets/MazPhoneNumberInput.css +1 -1
- package/components/assets/MazSelect.css +1 -1
- package/components/chunks/{MazBtn-16ab35fe.mjs → MazBtn-090f5ced.mjs} +2 -2
- package/components/chunks/{MazBtn-b29e3116.mjs → MazBtn-e578aab0.mjs} +2 -2
- package/components/chunks/MazCheckbox-12a37b71.mjs +144 -0
- package/components/chunks/MazCheckbox-aeada499.mjs +144 -0
- package/components/chunks/{MazPhoneNumberInput-e4f90230.mjs → MazPhoneNumberInput-94d7c29b.mjs} +132 -73
- package/components/chunks/{MazSelect-1f4d1193.mjs → MazSelect-5c3b7a30.mjs} +128 -70
- package/components/chunks/{MazSpinner-5fdafc97.mjs → MazSpinner-5be69292.mjs} +1 -1
- package/components/chunks/{MazSpinner-c9df761f.mjs → MazSpinner-f1454eeb.mjs} +1 -1
- package/components/chunks/check-77afbaee.mjs +32 -0
- package/css/main.css +1 -1
- package/nuxt/index.json +1 -1
- package/package.json +8 -8
- package/types/components/MazCheckbox.vue.d.ts +22 -2
- package/types/components/MazSelect.vue.d.ts +12 -4
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import "../assets/MazCheckbox.css";
|
|
2
|
+
import { defineComponent, useCssVars, getCurrentInstance, computed, openBlock, createElementBlock, unref, normalizeClass, createElementVNode, mergeProps, createVNode, Transition, withCtx, withDirectives, vShow, renderSlot } from "vue";
|
|
3
|
+
import { u as useInstanceUniqId, _ as _export_sfc } from "./MazPhoneNumberInput-94d7c29b.mjs";
|
|
4
|
+
import CheckIcon from "./check-77afbaee.mjs";
|
|
5
|
+
const _hoisted_1 = ["for"];
|
|
6
|
+
const _hoisted_2 = ["id", "checked", "disabled", "name"];
|
|
7
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
8
|
+
__name: "MazCheckbox",
|
|
9
|
+
props: {
|
|
10
|
+
modelValue: { type: Boolean, required: true },
|
|
11
|
+
id: { type: String, default: void 0 },
|
|
12
|
+
color: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: "primary"
|
|
15
|
+
},
|
|
16
|
+
name: { type: String, default: "m-checkbox" },
|
|
17
|
+
size: { type: String, default: "md" },
|
|
18
|
+
disabled: { type: Boolean, default: false }
|
|
19
|
+
},
|
|
20
|
+
emits: [
|
|
21
|
+
/* emitted when value change */
|
|
22
|
+
"update:model-value",
|
|
23
|
+
/* emited when value change */
|
|
24
|
+
"change"
|
|
25
|
+
],
|
|
26
|
+
setup(__props, { emit: __emit }) {
|
|
27
|
+
useCssVars((_ctx) => ({
|
|
28
|
+
"848d9fe6": checkIconColor.value,
|
|
29
|
+
"fb0e9a22": checkboxSize.value,
|
|
30
|
+
"cf55634c": checkboxSelectedColor.value,
|
|
31
|
+
"99c81ec6": checkboxBoxShadow.value
|
|
32
|
+
}));
|
|
33
|
+
const instance = getCurrentInstance();
|
|
34
|
+
const props = __props;
|
|
35
|
+
const emits = __emit;
|
|
36
|
+
const instanceId = useInstanceUniqId({
|
|
37
|
+
componentName: "MazCheckbox",
|
|
38
|
+
instance,
|
|
39
|
+
providedId: props.id
|
|
40
|
+
});
|
|
41
|
+
const checkboxSize = computed(() => {
|
|
42
|
+
switch (props.size) {
|
|
43
|
+
case "xl": {
|
|
44
|
+
return "2.25rem";
|
|
45
|
+
}
|
|
46
|
+
case "lg": {
|
|
47
|
+
return "2rem";
|
|
48
|
+
}
|
|
49
|
+
default: {
|
|
50
|
+
return "1.625rem";
|
|
51
|
+
}
|
|
52
|
+
case "sm": {
|
|
53
|
+
return "1.425rem";
|
|
54
|
+
}
|
|
55
|
+
case "xs": {
|
|
56
|
+
return "1.325rem";
|
|
57
|
+
}
|
|
58
|
+
case "mini": {
|
|
59
|
+
return "1.2rem";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
const checkIconSize = computed(() => {
|
|
64
|
+
switch (props.size) {
|
|
65
|
+
case "xl": {
|
|
66
|
+
return "maz-text-2xl";
|
|
67
|
+
}
|
|
68
|
+
case "lg": {
|
|
69
|
+
return "maz-text-xl";
|
|
70
|
+
}
|
|
71
|
+
default: {
|
|
72
|
+
return "maz-text-lg";
|
|
73
|
+
}
|
|
74
|
+
case "sm": {
|
|
75
|
+
return "maz-text-base";
|
|
76
|
+
}
|
|
77
|
+
case "xs": {
|
|
78
|
+
return "maz-text-sm";
|
|
79
|
+
}
|
|
80
|
+
case "mini": {
|
|
81
|
+
return "maz-text-xs";
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
const checkIconColor = computed(() => `var(--maz-color-${props.color}-contrast)`);
|
|
86
|
+
const checkboxSelectedColor = computed(() => `var(--maz-color-${props.color})`);
|
|
87
|
+
const checkboxBoxShadow = computed(
|
|
88
|
+
() => ["black", "transparent"].includes(props.color) ? `var(--maz-color-muted)` : `var(--maz-color-${props.color}-alpha)`
|
|
89
|
+
);
|
|
90
|
+
function keyboardHandler(event) {
|
|
91
|
+
if (["Enter", "Space"].includes(event.code)) {
|
|
92
|
+
event.preventDefault();
|
|
93
|
+
emitValue(!props.modelValue);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function emitValue(value) {
|
|
97
|
+
emits("update:model-value", value);
|
|
98
|
+
emits("change", value);
|
|
99
|
+
}
|
|
100
|
+
return (_ctx, _cache) => {
|
|
101
|
+
return openBlock(), createElementBlock("label", {
|
|
102
|
+
for: unref(instanceId),
|
|
103
|
+
class: normalizeClass(["m-checkbox", { "--disabled": __props.disabled }]),
|
|
104
|
+
tabindex: "1",
|
|
105
|
+
onKeydown: keyboardHandler
|
|
106
|
+
}, [
|
|
107
|
+
createElementVNode("input", mergeProps({
|
|
108
|
+
id: unref(instanceId),
|
|
109
|
+
checked: __props.modelValue
|
|
110
|
+
}, _ctx.$attrs, {
|
|
111
|
+
disabled: __props.disabled,
|
|
112
|
+
name: __props.name,
|
|
113
|
+
type: "checkbox",
|
|
114
|
+
onChange: _cache[0] || (_cache[0] = ($event) => {
|
|
115
|
+
var _a;
|
|
116
|
+
return emitValue((_a = $event == null ? void 0 : $event.target) == null ? void 0 : _a.checked);
|
|
117
|
+
})
|
|
118
|
+
}), null, 16, _hoisted_2),
|
|
119
|
+
createElementVNode("span", null, [
|
|
120
|
+
createVNode(Transition, {
|
|
121
|
+
name: "maz-scale",
|
|
122
|
+
persisted: ""
|
|
123
|
+
}, {
|
|
124
|
+
default: withCtx(() => [
|
|
125
|
+
withDirectives(createVNode(unref(CheckIcon), {
|
|
126
|
+
class: normalizeClass(["check-icon", checkIconSize.value])
|
|
127
|
+
}, null, 8, ["class"]), [
|
|
128
|
+
[vShow, __props.modelValue]
|
|
129
|
+
])
|
|
130
|
+
]),
|
|
131
|
+
_: 1
|
|
132
|
+
/* STABLE */
|
|
133
|
+
})
|
|
134
|
+
]),
|
|
135
|
+
renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
136
|
+
], 42, _hoisted_1);
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
const MazCheckbox_vue_vue_type_style_index_0_scoped_5b54604c_lang = "";
|
|
141
|
+
const MazCheckbox = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-5b54604c"]]);
|
|
142
|
+
export {
|
|
143
|
+
MazCheckbox as default
|
|
144
|
+
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import "../assets/MazCheckbox.css";
|
|
2
|
+
import { defineComponent, useCssVars, getCurrentInstance, computed, openBlock, createElementBlock, unref, normalizeClass, createElementVNode, mergeProps, createVNode, Transition, withCtx, withDirectives, vShow, renderSlot } from "vue";
|
|
3
|
+
import { u as useInstanceUniqId, _ as _export_sfc } from "./MazSelect-5c3b7a30.mjs";
|
|
4
|
+
import CheckIcon from "./check-77afbaee.mjs";
|
|
5
|
+
const _hoisted_1 = ["for"];
|
|
6
|
+
const _hoisted_2 = ["id", "checked", "disabled", "name"];
|
|
7
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
8
|
+
__name: "MazCheckbox",
|
|
9
|
+
props: {
|
|
10
|
+
modelValue: { type: Boolean, required: true },
|
|
11
|
+
id: { type: String, default: void 0 },
|
|
12
|
+
color: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: "primary"
|
|
15
|
+
},
|
|
16
|
+
name: { type: String, default: "m-checkbox" },
|
|
17
|
+
size: { type: String, default: "md" },
|
|
18
|
+
disabled: { type: Boolean, default: false }
|
|
19
|
+
},
|
|
20
|
+
emits: [
|
|
21
|
+
/* emitted when value change */
|
|
22
|
+
"update:model-value",
|
|
23
|
+
/* emited when value change */
|
|
24
|
+
"change"
|
|
25
|
+
],
|
|
26
|
+
setup(__props, { emit: __emit }) {
|
|
27
|
+
useCssVars((_ctx) => ({
|
|
28
|
+
"848d9fe6": checkIconColor.value,
|
|
29
|
+
"fb0e9a22": checkboxSize.value,
|
|
30
|
+
"cf55634c": checkboxSelectedColor.value,
|
|
31
|
+
"99c81ec6": checkboxBoxShadow.value
|
|
32
|
+
}));
|
|
33
|
+
const instance = getCurrentInstance();
|
|
34
|
+
const props = __props;
|
|
35
|
+
const emits = __emit;
|
|
36
|
+
const instanceId = useInstanceUniqId({
|
|
37
|
+
componentName: "MazCheckbox",
|
|
38
|
+
instance,
|
|
39
|
+
providedId: props.id
|
|
40
|
+
});
|
|
41
|
+
const checkboxSize = computed(() => {
|
|
42
|
+
switch (props.size) {
|
|
43
|
+
case "xl": {
|
|
44
|
+
return "2.25rem";
|
|
45
|
+
}
|
|
46
|
+
case "lg": {
|
|
47
|
+
return "2rem";
|
|
48
|
+
}
|
|
49
|
+
default: {
|
|
50
|
+
return "1.625rem";
|
|
51
|
+
}
|
|
52
|
+
case "sm": {
|
|
53
|
+
return "1.425rem";
|
|
54
|
+
}
|
|
55
|
+
case "xs": {
|
|
56
|
+
return "1.325rem";
|
|
57
|
+
}
|
|
58
|
+
case "mini": {
|
|
59
|
+
return "1.2rem";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
const checkIconSize = computed(() => {
|
|
64
|
+
switch (props.size) {
|
|
65
|
+
case "xl": {
|
|
66
|
+
return "maz-text-2xl";
|
|
67
|
+
}
|
|
68
|
+
case "lg": {
|
|
69
|
+
return "maz-text-xl";
|
|
70
|
+
}
|
|
71
|
+
default: {
|
|
72
|
+
return "maz-text-lg";
|
|
73
|
+
}
|
|
74
|
+
case "sm": {
|
|
75
|
+
return "maz-text-base";
|
|
76
|
+
}
|
|
77
|
+
case "xs": {
|
|
78
|
+
return "maz-text-sm";
|
|
79
|
+
}
|
|
80
|
+
case "mini": {
|
|
81
|
+
return "maz-text-xs";
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
const checkIconColor = computed(() => `var(--maz-color-${props.color}-contrast)`);
|
|
86
|
+
const checkboxSelectedColor = computed(() => `var(--maz-color-${props.color})`);
|
|
87
|
+
const checkboxBoxShadow = computed(
|
|
88
|
+
() => ["black", "transparent"].includes(props.color) ? `var(--maz-color-muted)` : `var(--maz-color-${props.color}-alpha)`
|
|
89
|
+
);
|
|
90
|
+
function keyboardHandler(event) {
|
|
91
|
+
if (["Enter", "Space"].includes(event.code)) {
|
|
92
|
+
event.preventDefault();
|
|
93
|
+
emitValue(!props.modelValue);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function emitValue(value) {
|
|
97
|
+
emits("update:model-value", value);
|
|
98
|
+
emits("change", value);
|
|
99
|
+
}
|
|
100
|
+
return (_ctx, _cache) => {
|
|
101
|
+
return openBlock(), createElementBlock("label", {
|
|
102
|
+
for: unref(instanceId),
|
|
103
|
+
class: normalizeClass(["m-checkbox", { "--disabled": __props.disabled }]),
|
|
104
|
+
tabindex: "1",
|
|
105
|
+
onKeydown: keyboardHandler
|
|
106
|
+
}, [
|
|
107
|
+
createElementVNode("input", mergeProps({
|
|
108
|
+
id: unref(instanceId),
|
|
109
|
+
checked: __props.modelValue
|
|
110
|
+
}, _ctx.$attrs, {
|
|
111
|
+
disabled: __props.disabled,
|
|
112
|
+
name: __props.name,
|
|
113
|
+
type: "checkbox",
|
|
114
|
+
onChange: _cache[0] || (_cache[0] = ($event) => {
|
|
115
|
+
var _a;
|
|
116
|
+
return emitValue((_a = $event == null ? void 0 : $event.target) == null ? void 0 : _a.checked);
|
|
117
|
+
})
|
|
118
|
+
}), null, 16, _hoisted_2),
|
|
119
|
+
createElementVNode("span", null, [
|
|
120
|
+
createVNode(Transition, {
|
|
121
|
+
name: "maz-scale",
|
|
122
|
+
persisted: ""
|
|
123
|
+
}, {
|
|
124
|
+
default: withCtx(() => [
|
|
125
|
+
withDirectives(createVNode(unref(CheckIcon), {
|
|
126
|
+
class: normalizeClass(["check-icon", checkIconSize.value])
|
|
127
|
+
}, null, 8, ["class"]), [
|
|
128
|
+
[vShow, __props.modelValue]
|
|
129
|
+
])
|
|
130
|
+
]),
|
|
131
|
+
_: 1
|
|
132
|
+
/* STABLE */
|
|
133
|
+
})
|
|
134
|
+
]),
|
|
135
|
+
renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
136
|
+
], 42, _hoisted_1);
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
const MazCheckbox_vue_vue_type_style_index_0_scoped_5b54604c_lang = "";
|
|
141
|
+
const MazCheckbox = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-5b54604c"]]);
|
|
142
|
+
export {
|
|
143
|
+
MazCheckbox as default
|
|
144
|
+
};
|
package/components/chunks/{MazPhoneNumberInput-e4f90230.mjs → MazPhoneNumberInput-94d7c29b.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../assets/MazPhoneNumberInput.css";
|
|
2
|
-
import { computed, defineAsyncComponent, defineComponent, ref, getCurrentInstance, onMounted, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, renderSlot, createVNode, createCommentVNode, withDirectives, mergeProps, toHandlers, vModelDynamic, createTextVNode, toDisplayString, createBlock, withModifiers, withCtx, onBeforeMount, watch,
|
|
2
|
+
import { computed, defineAsyncComponent, defineComponent, ref, getCurrentInstance, onMounted, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, renderSlot, createVNode, createCommentVNode, withDirectives, mergeProps, toHandlers, vModelDynamic, createTextVNode, toDisplayString, createBlock, withModifiers, withCtx, useCssVars, onBeforeMount, watch, unref, Transition, normalizeStyle, Fragment, renderList, nextTick, reactive } from "vue";
|
|
3
3
|
import { isSupportedCountry, getCountryCallingCode, getExampleNumber, getCountries, parsePhoneNumberFromString, AsYouType } from "libphonenumber-js";
|
|
4
4
|
function truthyFilter(value) {
|
|
5
5
|
return !!value;
|
|
@@ -192,11 +192,11 @@ function debounce(func, delay) {
|
|
|
192
192
|
}, delay);
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
|
-
const MazBtn = defineAsyncComponent(() => import("./MazBtn-
|
|
195
|
+
const MazBtn = defineAsyncComponent(() => import("./MazBtn-e578aab0.mjs"));
|
|
196
196
|
const MazIcon = defineAsyncComponent(() => import("./MazIcon-bda198b4.mjs"));
|
|
197
197
|
const EyeOffIcon = defineAsyncComponent(() => import("./eye-slash-3c6844fc.mjs"));
|
|
198
198
|
const EyeIcon = defineAsyncComponent(() => import("./eye-290c6a03.mjs"));
|
|
199
|
-
const CheckIcon = defineAsyncComponent(() => import("./check-
|
|
199
|
+
const CheckIcon = defineAsyncComponent(() => import("./check-77afbaee.mjs"));
|
|
200
200
|
const _sfc_main$2 = defineComponent({
|
|
201
201
|
components: {
|
|
202
202
|
MazBtn,
|
|
@@ -553,7 +553,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
553
553
|
__name: "MazSelect",
|
|
554
554
|
props: {
|
|
555
555
|
modelValue: {
|
|
556
|
-
type: [Number, String, Boolean],
|
|
556
|
+
type: [Number, String, Boolean, Array],
|
|
557
557
|
default: void 0
|
|
558
558
|
},
|
|
559
559
|
id: { type: String, default: void 0 },
|
|
@@ -588,7 +588,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
588
588
|
}
|
|
589
589
|
},
|
|
590
590
|
search: { type: Boolean, default: false },
|
|
591
|
-
searchPlaceholder: { type: String, default: "Search in options" }
|
|
591
|
+
searchPlaceholder: { type: String, default: "Search in options" },
|
|
592
|
+
multiple: { type: Boolean, default: false }
|
|
592
593
|
},
|
|
593
594
|
emits: [
|
|
594
595
|
"close",
|
|
@@ -601,6 +602,12 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
601
602
|
"selected-option"
|
|
602
603
|
],
|
|
603
604
|
setup(__props, { emit: __emit }) {
|
|
605
|
+
useCssVars((_ctx) => ({
|
|
606
|
+
"4268d79e": keyboardSelectedBgColor.value,
|
|
607
|
+
"71723ca0": selectedTextColor.value,
|
|
608
|
+
"66e06018": selectedBgColor.value
|
|
609
|
+
}));
|
|
610
|
+
const MazCheckbox = defineAsyncComponent(() => import("./MazCheckbox-12a37b71.mjs"));
|
|
604
611
|
const SearchIcon = defineAsyncComponent(() => import("./magnifying-glass-6a0dd1a2.mjs"));
|
|
605
612
|
const ChevronDownIcon = defineAsyncComponent(() => import("./chevron-down-7a070b10.mjs"));
|
|
606
613
|
const NoSymbolIcon = defineAsyncComponent(() => import("./no-symbol-6173a20b.mjs"));
|
|
@@ -609,42 +616,64 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
609
616
|
const emits = __emit;
|
|
610
617
|
const listOpened = ref(false);
|
|
611
618
|
const tmpModelValueIndex = ref();
|
|
619
|
+
const isBlackOrTransparentColor = computed(
|
|
620
|
+
() => ["black", "transparent", "white"].includes(props.color)
|
|
621
|
+
);
|
|
622
|
+
const selectedTextColor = computed(
|
|
623
|
+
() => isBlackOrTransparentColor.value ? `var(--maz-color-black)` : `var(--maz-color-${props.color}-800)`
|
|
624
|
+
);
|
|
625
|
+
const selectedBgColor = computed(
|
|
626
|
+
() => isBlackOrTransparentColor.value ? "var(--maz-color-muted)" : `var(--maz-color-${props.color}-100)`
|
|
627
|
+
);
|
|
628
|
+
const keyboardSelectedBgColor = computed(
|
|
629
|
+
() => isBlackOrTransparentColor.value ? "var(--maz-color-muted)" : `var(--maz-color-${props.color}-200)`
|
|
630
|
+
);
|
|
612
631
|
const hasListOpened = computed(() => listOpened.value || props.open);
|
|
613
632
|
const instanceId = useInstanceUniqId({
|
|
614
633
|
componentName: "MazSelect",
|
|
615
634
|
instance,
|
|
616
635
|
providedId: props.id
|
|
617
636
|
});
|
|
637
|
+
const selectedOptions = computed(
|
|
638
|
+
() => {
|
|
639
|
+
var _a;
|
|
640
|
+
return ((_a = props.options) == null ? void 0 : _a.filter((option) => {
|
|
641
|
+
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]);
|
|
642
|
+
})) ?? [];
|
|
643
|
+
}
|
|
644
|
+
);
|
|
618
645
|
onBeforeMount(() => {
|
|
619
|
-
var _a
|
|
646
|
+
var _a;
|
|
620
647
|
if (!((_a = props.options) == null ? void 0 : _a.length)) {
|
|
621
648
|
console.warn("[maz-ui](MazSelect) you must provide options");
|
|
622
649
|
}
|
|
623
|
-
|
|
624
|
-
tmpModelValueIndex.value = (_b = props.options) == null ? void 0 : _b.findIndex(
|
|
625
|
-
(option) => {
|
|
626
|
-
var _a2;
|
|
627
|
-
return option[props.optionValueKey] === ((_a2 = selectedOption.value) == null ? void 0 : _a2[props.optionValueKey]);
|
|
628
|
-
}
|
|
629
|
-
);
|
|
630
|
-
}
|
|
650
|
+
updateTmpModelValueIndex();
|
|
631
651
|
});
|
|
632
652
|
const mazSelectElement = ref();
|
|
633
653
|
const mazInputComponent = ref();
|
|
634
654
|
const searchInputComponent = ref();
|
|
635
655
|
const optionsListElement = ref();
|
|
636
|
-
const selectedOption = computed(
|
|
637
|
-
() => {
|
|
638
|
-
var _a;
|
|
639
|
-
return (_a = props.options) == null ? void 0 : _a.find((option) => props.modelValue === option[props.optionValueKey]);
|
|
640
|
-
}
|
|
641
|
-
);
|
|
642
656
|
const isNullOrUndefined = (value) => {
|
|
643
657
|
return value === void 0 || value === null;
|
|
644
658
|
};
|
|
659
|
+
function isSelectedOption(option) {
|
|
660
|
+
var _a;
|
|
661
|
+
const hasOption = ((_a = selectedOptions.value) == null ? void 0 : _a.some(
|
|
662
|
+
(selectedOption) => selectedOption[props.optionValueKey] === option[props.optionValueKey]
|
|
663
|
+
)) ?? false;
|
|
664
|
+
return hasOption && !isNullOrUndefined(option[props.optionValueKey]);
|
|
665
|
+
}
|
|
645
666
|
const mazInputValue = computed(() => {
|
|
646
|
-
var _a, _b
|
|
647
|
-
|
|
667
|
+
var _a, _b;
|
|
668
|
+
if (props.multiple && props.modelValue && Array.isArray(props.modelValue)) {
|
|
669
|
+
return props.modelValue.map(
|
|
670
|
+
(value) => {
|
|
671
|
+
var _a2, _b2;
|
|
672
|
+
return (_b2 = (_a2 = optionsList.value) == null ? void 0 : _a2.find((option) => option[props.optionValueKey] === value)) == null ? void 0 : _b2[props.optionInputValueKey];
|
|
673
|
+
}
|
|
674
|
+
).join(", ");
|
|
675
|
+
}
|
|
676
|
+
return (_b = (_a = optionsList.value) == null ? void 0 : _a.find((option) => option[props.optionValueKey] === props.modelValue)) == null ? void 0 : _b[props.optionInputValueKey];
|
|
648
677
|
});
|
|
649
678
|
const listTransition = computed(
|
|
650
679
|
() => props.listPosition.includes("bottom") ? "maz-slide" : "maz-slideinvert"
|
|
@@ -662,10 +691,6 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
662
691
|
watch(
|
|
663
692
|
() => props.modelValue,
|
|
664
693
|
(value, oldValue) => {
|
|
665
|
-
if (value && value !== oldValue) {
|
|
666
|
-
scrollToSelected();
|
|
667
|
-
updateTmpModelValueIndex();
|
|
668
|
-
}
|
|
669
694
|
}
|
|
670
695
|
);
|
|
671
696
|
function getFilteredOptionWithQuery(query2) {
|
|
@@ -689,17 +714,20 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
689
714
|
emits("close", event);
|
|
690
715
|
};
|
|
691
716
|
const openList = async (event) => {
|
|
692
|
-
|
|
693
|
-
if (props.disabled)
|
|
717
|
+
if (props.disabled || hasListOpened.value)
|
|
694
718
|
return;
|
|
719
|
+
event == null ? void 0 : event.preventDefault();
|
|
695
720
|
listOpened.value = true;
|
|
696
|
-
await
|
|
721
|
+
await scrollToOptionIndex();
|
|
697
722
|
emits("focus", event);
|
|
698
723
|
emits("open", listOpened.value);
|
|
699
724
|
};
|
|
700
|
-
function
|
|
725
|
+
function focusMainInput() {
|
|
701
726
|
var _a, _b;
|
|
702
|
-
|
|
727
|
+
(_b = (_a = mazInputComponent.value) == null ? void 0 : _a.$el.querySelector("input")) == null ? void 0 : _b.focus();
|
|
728
|
+
}
|
|
729
|
+
function toggleList(event) {
|
|
730
|
+
listOpened.value ? closeList(event) : focusMainInput();
|
|
703
731
|
}
|
|
704
732
|
function focusSearchInputAndSetQuery(q) {
|
|
705
733
|
var _a;
|
|
@@ -718,7 +746,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
718
746
|
tmpModelValueIndex.value = (_a = optionsList.value) == null ? void 0 : _a.findIndex(
|
|
719
747
|
(option) => option[props.optionValueKey] === filteredOptions[0][props.optionValueKey]
|
|
720
748
|
);
|
|
721
|
-
|
|
749
|
+
if (typeof tmpModelValueIndex.value === "number" && tmpModelValueIndex.value >= 0) {
|
|
750
|
+
scrollToOptionIndex(tmpModelValueIndex.value);
|
|
751
|
+
}
|
|
722
752
|
}
|
|
723
753
|
debounceCallback(() => {
|
|
724
754
|
query.value = "";
|
|
@@ -737,13 +767,13 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
737
767
|
const keyboardHandler = (event) => {
|
|
738
768
|
const code = event.code;
|
|
739
769
|
const isArrow = ["ArrowUp", "ArrowDown"].includes(code);
|
|
740
|
-
const
|
|
741
|
-
const
|
|
770
|
+
const shouldSelect = ["Enter", "Space"].includes(code);
|
|
771
|
+
const shouldCloseList = "Escape" === code && hasListOpened.value;
|
|
742
772
|
if (isArrow) {
|
|
743
773
|
arrowHandler(event, tmpModelValueIndex.value);
|
|
744
|
-
} else if (
|
|
774
|
+
} else if (shouldSelect) {
|
|
745
775
|
enterHandler(event, tmpModelValueIndex.value);
|
|
746
|
-
} else if (
|
|
776
|
+
} else if (shouldCloseList) {
|
|
747
777
|
closeList();
|
|
748
778
|
}
|
|
749
779
|
};
|
|
@@ -768,7 +798,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
768
798
|
} else {
|
|
769
799
|
tmpModelValueIndex.value = code === "ArrowDown" ? 0 : optionsLength - 1;
|
|
770
800
|
}
|
|
771
|
-
|
|
801
|
+
scrollToOptionIndex(tmpModelValueIndex.value);
|
|
772
802
|
};
|
|
773
803
|
const enterHandler = (event, currentIndex) => {
|
|
774
804
|
var _a, _b, _c;
|
|
@@ -781,40 +811,61 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
781
811
|
updateValue(newValue);
|
|
782
812
|
}
|
|
783
813
|
};
|
|
784
|
-
async function
|
|
785
|
-
var _a, _b
|
|
814
|
+
async function scrollToOptionIndex(index) {
|
|
815
|
+
var _a, _b;
|
|
786
816
|
await nextTick();
|
|
787
|
-
|
|
788
|
-
(
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
if (typeof selectedIndex === "number") {
|
|
794
|
-
if (!tmpModelValueIndex.value)
|
|
795
|
-
tmpModelValueIndex.value = selectedIndex;
|
|
796
|
-
(_c = (_b = optionsListElement.value) == null ? void 0 : _b.querySelectorAll(".m-select-list-item")[selectedIndex]) == null ? void 0 : _c.scrollIntoView({
|
|
817
|
+
if (typeof index !== "number") {
|
|
818
|
+
updateTmpModelValueIndex();
|
|
819
|
+
}
|
|
820
|
+
const selectedIndex = index ?? tmpModelValueIndex.value;
|
|
821
|
+
if (typeof selectedIndex === "number" && selectedIndex >= 0) {
|
|
822
|
+
(_b = (_a = optionsListElement.value) == null ? void 0 : _a.querySelectorAll(".m-select-list-item")[selectedIndex]) == null ? void 0 : _b.scrollIntoView({
|
|
797
823
|
behavior: "auto",
|
|
798
824
|
block: "nearest",
|
|
799
825
|
inline: "start"
|
|
800
826
|
});
|
|
801
827
|
}
|
|
802
828
|
}
|
|
803
|
-
function updateTmpModelValueIndex() {
|
|
829
|
+
function updateTmpModelValueIndex(inputOption) {
|
|
804
830
|
var _a;
|
|
805
|
-
const index = (_a = optionsList.value) == null ? void 0 : _a.findIndex(
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
831
|
+
const index = (_a = optionsList.value) == null ? void 0 : _a.findIndex((option) => {
|
|
832
|
+
var _a2, _b;
|
|
833
|
+
if (props.multiple && Array.isArray(props.modelValue)) {
|
|
834
|
+
if (inputOption) {
|
|
835
|
+
return inputOption[props.optionValueKey] === option[props.optionValueKey];
|
|
836
|
+
}
|
|
837
|
+
const values = [...props.modelValue].reverse();
|
|
838
|
+
return values[0] === option[props.optionValueKey];
|
|
839
|
+
} else {
|
|
840
|
+
return ((_b = (_a2 = selectedOptions.value) == null ? void 0 : _a2[0]) == null ? void 0 : _b[props.optionValueKey]) === option[props.optionValueKey];
|
|
841
|
+
}
|
|
842
|
+
});
|
|
843
|
+
tmpModelValueIndex.value = index && index >= 0 ? index : 0;
|
|
809
844
|
}
|
|
810
|
-
const updateValue = (
|
|
811
|
-
|
|
845
|
+
const updateValue = (inputOption, mustCloseList = true) => {
|
|
846
|
+
var _a;
|
|
847
|
+
if (mustCloseList && !props.multiple) {
|
|
812
848
|
nextTick(() => closeList());
|
|
813
849
|
}
|
|
814
850
|
searchQuery.value = "";
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
851
|
+
const isAlreadySelected = (_a = selectedOptions.value) == null ? void 0 : _a.some(
|
|
852
|
+
(option) => option[props.optionValueKey] === inputOption[props.optionValueKey]
|
|
853
|
+
);
|
|
854
|
+
let newValue = selectedOptions.value;
|
|
855
|
+
if (isAlreadySelected && props.multiple) {
|
|
856
|
+
newValue = newValue == null ? void 0 : newValue.filter(
|
|
857
|
+
(option) => option[props.optionValueKey] !== inputOption[props.optionValueKey]
|
|
858
|
+
);
|
|
859
|
+
} else if (props.multiple) {
|
|
860
|
+
newValue.push(inputOption);
|
|
861
|
+
} else {
|
|
862
|
+
newValue = [inputOption];
|
|
863
|
+
}
|
|
864
|
+
const selectedValues = newValue.map((option) => option[props.optionValueKey]);
|
|
865
|
+
emits("update:model-value", props.multiple ? selectedValues : selectedValues[0]);
|
|
866
|
+
emits("selected-option", inputOption);
|
|
867
|
+
updateTmpModelValueIndex(inputOption);
|
|
868
|
+
focusMainInput();
|
|
818
869
|
};
|
|
819
870
|
return (_ctx, _cache) => {
|
|
820
871
|
return openBlock(), createElementBlock(
|
|
@@ -840,6 +891,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
840
891
|
size: __props.size,
|
|
841
892
|
disabled: __props.disabled,
|
|
842
893
|
onFocus: withModifiers(openList, ["prevent", "stop"]),
|
|
894
|
+
onClick: withModifiers(openList, ["prevent", "stop"]),
|
|
843
895
|
onChange: _cache[0] || (_cache[0] = ($event) => emits("change", $event)),
|
|
844
896
|
onKeydown: mainInputKeyboardHandler
|
|
845
897
|
}), {
|
|
@@ -855,7 +907,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
855
907
|
]),
|
|
856
908
|
_: 1
|
|
857
909
|
/* STABLE */
|
|
858
|
-
}, 16, ["id", "required", "border-active", "color", "model-value", "size", "disabled", "onFocus"]),
|
|
910
|
+
}, 16, ["id", "required", "border-active", "color", "model-value", "size", "disabled", "onFocus", "onClick"]),
|
|
859
911
|
createVNode(Transition, { name: listTransition.value }, {
|
|
860
912
|
default: withCtx(() => [
|
|
861
913
|
hasListOpened.value ? (openBlock(), createElementBlock(
|
|
@@ -901,7 +953,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
901
953
|
/* STABLE */
|
|
902
954
|
}, 8, ["modelValue", "color", "placeholder"])
|
|
903
955
|
])) : createCommentVNode("v-if", true),
|
|
904
|
-
createCommentVNode(" No results slot - Displayed when no results corresponding with seeach query
|
|
956
|
+
createCommentVNode("\n @slot No results slot - Displayed when no results corresponding with seeach query\n "),
|
|
905
957
|
!optionsList.value || optionsList.value.length <= 0 ? renderSlot(_ctx.$slots, "no-results", { key: 1 }, () => [
|
|
906
958
|
createElementVNode("span", _hoisted_3, [
|
|
907
959
|
createVNode(unref(NoSymbolIcon), { class: "maz-h-6 maz-w-6 maz-text-normal" })
|
|
@@ -911,7 +963,6 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
911
963
|
Fragment,
|
|
912
964
|
null,
|
|
913
965
|
renderList(optionsList.value, (option, i) => {
|
|
914
|
-
var _a, _b, _c;
|
|
915
966
|
return openBlock(), createElementBlock("button", {
|
|
916
967
|
key: i,
|
|
917
968
|
tabindex: "-1",
|
|
@@ -919,18 +970,24 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
919
970
|
class: normalizeClass(["m-select-list-item maz-custom", [
|
|
920
971
|
{
|
|
921
972
|
"--is-keyboard-selected": tmpModelValueIndex.value === i,
|
|
922
|
-
"--is-selected": (
|
|
973
|
+
"--is-selected": isSelectedOption(option),
|
|
923
974
|
"--is-none-value": isNullOrUndefined(option[__props.optionValueKey])
|
|
924
|
-
}
|
|
925
|
-
`--${__props.color}`
|
|
975
|
+
}
|
|
926
976
|
]]),
|
|
927
977
|
style: normalizeStyle({ minHeight: `${__props.itemHeight}px` }),
|
|
928
978
|
onClick: withModifiers(($event) => updateValue(option), ["prevent", "stop"])
|
|
929
979
|
}, [
|
|
980
|
+
__props.multiple ? (openBlock(), createBlock(unref(MazCheckbox), {
|
|
981
|
+
key: 0,
|
|
982
|
+
tabindex: "-1",
|
|
983
|
+
"model-value": isSelectedOption(option),
|
|
984
|
+
size: "sm",
|
|
985
|
+
color: __props.color
|
|
986
|
+
}, null, 8, ["model-value", "color"])) : createCommentVNode("v-if", true),
|
|
987
|
+
createCommentVNode("\n @slot Custom option\n @binding {Object} option\n @binding {Boolean} is-selected\n "),
|
|
930
988
|
renderSlot(_ctx.$slots, "default", {
|
|
931
989
|
option,
|
|
932
|
-
isSelected: (
|
|
933
|
-
selectedOption: (_c = selectedOption.value) == null ? void 0 : _c[__props.optionValueKey]
|
|
990
|
+
isSelected: isSelectedOption(option)
|
|
934
991
|
}, () => [
|
|
935
992
|
createElementVNode(
|
|
936
993
|
"span",
|
|
@@ -961,8 +1018,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
961
1018
|
};
|
|
962
1019
|
}
|
|
963
1020
|
});
|
|
964
|
-
const
|
|
965
|
-
const MazSelect = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
1021
|
+
const MazSelect_vue_vue_type_style_index_0_scoped_6ebd3ef8_lang = "";
|
|
1022
|
+
const MazSelect = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-6ebd3ef8"]]);
|
|
966
1023
|
const _hoisted_1 = ["id"];
|
|
967
1024
|
const _hoisted_2 = {
|
|
968
1025
|
key: 0,
|
|
@@ -1297,8 +1354,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1297
1354
|
var _a, _b;
|
|
1298
1355
|
(_b = (_a = CountrySelector.value) == null ? void 0 : _a.$el.querySelector("input")) == null ? void 0 : _b.focus();
|
|
1299
1356
|
}
|
|
1300
|
-
function focusPhoneNumberInput() {
|
|
1357
|
+
async function focusPhoneNumberInput() {
|
|
1301
1358
|
var _a;
|
|
1359
|
+
await nextTick();
|
|
1302
1360
|
(_a = getPhoneNumberInput()) == null ? void 0 : _a.focus();
|
|
1303
1361
|
}
|
|
1304
1362
|
return (_ctx, _cache) => {
|
|
@@ -1415,9 +1473,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1415
1473
|
};
|
|
1416
1474
|
}
|
|
1417
1475
|
});
|
|
1418
|
-
const
|
|
1419
|
-
const MazPhoneNumberInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
1476
|
+
const MazPhoneNumberInput_vue_vue_type_style_index_0_scoped_2cc88337_lang = "";
|
|
1477
|
+
const MazPhoneNumberInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-2cc88337"]]);
|
|
1420
1478
|
export {
|
|
1421
1479
|
MazPhoneNumberInput as M,
|
|
1422
|
-
_export_sfc as _
|
|
1480
|
+
_export_sfc as _,
|
|
1481
|
+
useInstanceUniqId as u
|
|
1423
1482
|
};
|