maz-ui 4.7.5 → 4.7.6
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/dist/chunks/MazAccordion.CKnz73h4.js +1 -0
- package/dist/chunks/MazAlert.B8hE7wet.js +1 -0
- package/dist/chunks/MazAnimatedCounter.GLLYbZAz.js +1 -0
- package/dist/chunks/MazAnimatedElement._8NY8WgC.js +1 -0
- package/dist/chunks/MazAnimatedText.BSZ8FNf-.js +1 -0
- package/dist/chunks/MazAvatar.vO5VNPi8.js +1 -0
- package/dist/chunks/MazBackdrop.Cjbwi8-V.js +1 -0
- package/dist/chunks/MazBadge.BBZJgHXm.js +1 -0
- package/dist/chunks/MazBottomSheet.WgZ6qobx.js +1 -0
- package/dist/chunks/MazBtn.Cc9C1v2l.js +1 -0
- package/dist/chunks/MazBtnGroup.3B1XcqWM.js +1 -0
- package/dist/chunks/MazCard.YYC0LaHY.js +1 -0
- package/dist/chunks/MazCardSpotlight.SpZF61hl.js +1 -0
- package/dist/chunks/MazCarousel.1NT4jcvR.js +1 -0
- package/dist/chunks/MazChart.CDZ2PBTC.js +1 -0
- package/dist/chunks/MazCheckbox.DurIbKdf.js +1 -0
- package/dist/chunks/MazChecklist.D9ezwGpQ.js +1 -0
- package/dist/chunks/MazCircularProgressBar.rATx_hD9.js +1 -0
- package/dist/chunks/MazContainer.zXcfMOs-.js +1 -0
- package/dist/chunks/MazDatePicker.KUP34cbV.js +1 -0
- package/dist/chunks/MazDialog.CtKF3Xzo.js +1 -0
- package/dist/chunks/MazDialogConfirm.CAAHeBPE.js +1 -0
- package/dist/chunks/MazDrawer.Dc_RGG8a.js +1 -0
- package/dist/chunks/MazDropdown.2DUcivzO.js +1 -0
- package/dist/chunks/MazDropzone.CiWiPcFM.js +1 -0
- package/dist/chunks/MazExpandAnimation.CMMwtuQA.js +1 -0
- package/dist/chunks/MazFullscreenLoader.BIVRcZJ8.js +1 -0
- package/dist/chunks/MazGallery.CEmGy0K9.js +1 -0
- package/dist/chunks/MazIcon.ZWAk25ZX.js +1 -0
- package/dist/chunks/MazInput.DJjWLaKg.js +1 -0
- package/dist/chunks/MazInputCode.DKnl3i-X.js +1 -0
- package/dist/chunks/MazInputNumber.B42Mn-9h.js +1 -0
- package/dist/chunks/MazInputPhoneNumber.CLivThtK.js +1 -0
- package/dist/chunks/MazInputPrice.BeL-M944.js +1 -0
- package/dist/chunks/MazInputTags.CIVT9F6Q.js +1 -0
- package/dist/chunks/MazLazyImg.-EMwandx.js +1 -0
- package/dist/chunks/MazLink.BOpxMATj.js +1 -0
- package/dist/chunks/MazLoadingBar.C86AX2Tk.js +1 -0
- package/dist/chunks/MazPagination.CNNKXBsg.js +1 -0
- package/dist/chunks/MazPickerCalendarDays.CSZZbk5Z.js +1 -0
- package/dist/chunks/MazPickerCalendarGrid.DrUHBH6-.js +1 -0
- package/dist/chunks/MazPickerContainer.BZ74M74V.js +1 -0
- package/dist/chunks/MazPopover.Co8BEopX.js +1 -0
- package/dist/chunks/MazPullToRefresh.DMtb6Oa3.js +1 -0
- package/dist/chunks/MazRadio.75ipjTw2.js +1 -0
- package/dist/chunks/MazRadioButtons.DenHCgB3.js +1 -0
- package/dist/chunks/MazReadMore.CDXacQIw.js +1 -0
- package/dist/chunks/MazReadingProgressBar.828Y0mxA.js +1 -0
- package/dist/chunks/MazSelect.yYFAbBb5.js +1 -0
- package/dist/chunks/MazSelectCountry.DvVgk2es.js +1 -0
- package/dist/chunks/MazSkeleton.BewTYJC2.js +1 -0
- package/dist/chunks/MazSlider.BS5QHWK6.js +1 -0
- package/dist/chunks/MazSpinner.D3NN2pow.js +1 -0
- package/dist/chunks/MazStepper.DTu8HG9T.js +1 -0
- package/dist/chunks/MazSwitch.Dvmj-rTW.js +1 -0
- package/dist/chunks/MazTable.DnOehvN6.js +1 -0
- package/dist/chunks/MazTableCell.xbm2NGWL.js +1 -0
- package/dist/chunks/MazTableRow.B5dJiXk1.js +1 -0
- package/dist/chunks/MazTableTitle.DNA_1mCy.js +1 -0
- package/dist/chunks/MazTabs.-0-YP3QQ.js +1 -0
- package/dist/chunks/MazTabsBar.D2JVKMS7.js +1 -0
- package/dist/chunks/MazTabsContent.C9omK25X.js +1 -0
- package/dist/chunks/MazTabsContentItem.mJEAS5R8.js +1 -0
- package/dist/chunks/MazTextarea.BliEP5G5.js +1 -0
- package/dist/chunks/MazUiProvider.BgN8V0lD.js +1 -0
- package/dist/chunks/_plugin-vue_export-helper.ChmETRGw.js +1 -0
- package/dist/chunks/dialog.DexeIC3K.js +1 -0
- package/dist/chunks/dom-events.BPrKJiCz.js +1 -0
- package/dist/chunks/resolveLinkComponent.DAc3sqGH.js +1 -0
- package/dist/chunks/toast.UQ8RRuT9.js +1 -0
- package/dist/chunks/types.DDbvTVqf.js +1 -0
- package/dist/chunks/useMazInputPhoneNumber.B_qQ0ldP.js +1 -0
- package/dist/chunks/utils.B8bfGQxN.js +1 -0
- package/dist/chunks/vFullscreenImg.CZeRh3mw.js +1 -0
- package/dist/chunks/vLazyImg.CXmd3Lp0.js +1 -0
- package/dist/chunks/vZoomImg.CaAHb98S.js +124 -0
- package/dist/components/MazAccordion.js +1 -86
- package/dist/components/MazAlert.js +1 -85
- package/dist/components/MazAnimatedCounter.js +1 -73
- package/dist/components/MazAnimatedElement.js +1 -44
- package/dist/components/MazAnimatedText.js +1 -103
- package/dist/components/MazAvatar.js +1 -125
- package/dist/components/MazBackdrop.js +1 -163
- package/dist/components/MazBadge.js +1 -29
- package/dist/components/MazBottomSheet.js +1 -55
- package/dist/components/MazBtn.js +1 -109
- package/dist/components/MazBtnGroup.js +1 -44
- package/dist/components/MazCard.js +1 -184
- package/dist/components/MazCardSpotlight.js +1 -81
- package/dist/components/MazCarousel.js +1 -104
- package/dist/components/MazChart.js +1 -4
- package/dist/components/MazCheckbox.js +1 -128
- package/dist/components/MazChecklist.js +1 -133
- package/dist/components/MazCircularProgressBar.js +1 -131
- package/dist/components/MazContainer.js +1 -71
- package/dist/components/MazDatePicker/MazPickerCalendar.js +1 -113
- package/dist/components/MazDatePicker/MazPickerCalendarMonth/MazPickerCalendarDays.js +1 -19
- package/dist/components/MazDatePicker/MazPickerCalendarMonth/MazPickerCalendarGrid.js +1 -181
- package/dist/components/MazDatePicker/MazPickerCalendarMonth/MazPickerCalendarMonth.js +1 -75
- package/dist/components/MazDatePicker/MazPickerCalendarSwitcher.js +1 -90
- package/dist/components/MazDatePicker/MazPickerContainer.js +1 -116
- package/dist/components/MazDatePicker/MazPickerHeader.js +1 -126
- package/dist/components/MazDatePicker/MazPickerMonthSwitcher.js +1 -82
- package/dist/components/MazDatePicker/MazPickerShortcuts.js +1 -55
- package/dist/components/MazDatePicker/MazPickerTime.js +1 -178
- package/dist/components/MazDatePicker/MazPickerYearSwitcher.js +1 -95
- package/dist/components/MazDatePicker.js +1 -466
- package/dist/components/MazDatePicker.vue.d.ts +2 -6
- package/dist/components/MazDialog.js +1 -115
- package/dist/components/MazDialog.vue.d.ts +2 -6
- package/dist/components/MazDialogConfirm.js +1 -6
- package/dist/components/MazDialogConfirm.vue.d.ts +2 -6
- package/dist/components/MazDrawer.js +1 -70
- package/dist/components/MazDropdown.js +1 -277
- package/dist/components/MazDropdown.vue.d.ts +2 -6
- package/dist/components/MazDropzone.js +1 -533
- package/dist/components/MazExpandAnimation.js +1 -46
- package/dist/components/MazFullscreenLoader.js +1 -38
- package/dist/components/MazGallery.js +1 -105
- package/dist/components/MazIcon.js +1 -114
- package/dist/components/MazInput.js +1 -256
- package/dist/components/MazInputCode.js +1 -152
- package/dist/components/MazInputNumber.js +1 -152
- package/dist/components/MazInputPhoneNumber/PhoneInput.js +1 -114
- package/dist/components/MazInputPhoneNumber.js +1 -253
- package/dist/components/MazInputPrice.js +1 -4
- package/dist/components/MazInputTags.js +1 -145
- package/dist/components/MazLazyImg.js +1 -62
- package/dist/components/MazLink.js +1 -80
- package/dist/components/MazLoadingBar.js +1 -24
- package/dist/components/MazPagination.js +1 -184
- package/dist/components/MazPopover.js +1 -326
- package/dist/components/MazPullToRefresh.js +1 -145
- package/dist/components/MazRadio.js +1 -103
- package/dist/components/MazRadioButtons.js +1 -135
- package/dist/components/MazReadMore.js +1 -110
- package/dist/components/MazReadingProgressBar.js +1 -68
- package/dist/components/MazSelect.js +1 -413
- package/dist/components/MazSelectCountry.js +1 -192
- package/dist/components/MazSkeleton.js +1 -50
- package/dist/components/MazSlider.js +1 -205
- package/dist/components/MazSpinner.js +1 -27
- package/dist/components/MazStepper.js +1 -170
- package/dist/components/MazSwitch.js +1 -4
- package/dist/components/MazTable.js +1 -8
- package/dist/components/MazTableCell.js +1 -18
- package/dist/components/MazTableRow.js +1 -26
- package/dist/components/MazTableTitle.js +1 -18
- package/dist/components/MazTabs.js +1 -4
- package/dist/components/MazTabsBar.js +1 -138
- package/dist/components/MazTabsContent.js +1 -4
- package/dist/components/MazTabsContentItem.js +1 -37
- package/dist/components/MazTextarea.js +1 -147
- package/dist/components/MazUiProvider.js +1 -4
- package/dist/components/index.js +1 -127
- package/dist/composables/index.js +1 -44
- package/dist/composables/useAos.js +1 -7
- package/dist/composables/useBreakpoints.js +1 -34
- package/dist/composables/useDialog.js +1 -7
- package/dist/composables/useDisplayNames.js +1 -111
- package/dist/composables/useDropzone.js +1 -66
- package/dist/composables/useFormField.js +1 -101
- package/dist/composables/useFormValidator.js +1 -163
- package/dist/composables/useFreezeValue.js +1 -8
- package/dist/composables/useIdleTimeout.js +1 -10
- package/dist/composables/useInjectStrict.js +1 -10
- package/dist/composables/useInstanceUniqId.js +1 -12
- package/dist/composables/useMountComponent.js +1 -16
- package/dist/composables/useMutationObserver.js +1 -37
- package/dist/composables/useReadingTime.js +1 -33
- package/dist/composables/useStringMatching.js +1 -42
- package/dist/composables/useSwipe.js +1 -26
- package/dist/composables/useTimer.js +1 -36
- package/dist/composables/useToast.js +1 -14
- package/dist/composables/useUserVisibility.js +1 -10
- package/dist/composables/useWait.js +1 -7
- package/dist/composables/useWindowSize.js +1 -21
- package/dist/directives/index.js +1 -19
- package/dist/directives/vClickOutside.js +1 -104
- package/dist/directives/vFullscreenImg.js +1 -10
- package/dist/directives/vLazyImg.js +1 -23
- package/dist/directives/vTooltip.js +1 -161
- package/dist/directives/vZoomImg.js +1 -286
- package/dist/index.js +1 -1
- package/dist/plugins/aos.js +1 -89
- package/dist/plugins/dialog.js +1 -61
- package/dist/plugins/index.js +1 -17
- package/dist/plugins/maz-ui.js +1 -11
- package/dist/plugins/toast.js +1 -261
- package/dist/plugins/wait.js +1 -43
- package/dist/resolvers/MazComponentsResolver.js +1 -18
- package/dist/resolvers/MazDirectivesResolver.js +1 -14
- package/dist/resolvers/MazModulesResolver.js +1 -76
- package/dist/resolvers/index.js +1 -8
- package/dist/tailwindcss/index.js +1 -20
- package/dist/tailwindcss/tailwind.config.js +1 -35
- package/dist/tailwindcss/utils/colors.js +1 -25
- package/dist/tailwindcss/variables/breakpoints.js +1 -29
- package/dist/tailwindcss/variables/colors.js +1 -33
- package/dist/tailwindcss/variables/design-tokens.js +1 -42
- package/dist/tailwindcss/variables/utilities.js +1 -20
- package/dist/tailwindcss/variables/z-indexes.js +1 -17
- package/package.json +12 -13
- package/dist/chunks/MazChart.vue_vue_type_script_setup_true_lang.DpG9UYdm.js +0 -50
- package/dist/chunks/MazDialogConfirm.vue_vue_type_script_setup_true_lang.BB2rYkwY.js +0 -215
- package/dist/chunks/MazInputPrice.vue_vue_type_script_setup_true_lang.DcNkyw1C.js +0 -77
- package/dist/chunks/MazSwitch.vue_vue_type_style_index_0_lang.lYfYsI0R.js +0 -84
- package/dist/chunks/MazTable.vue_vue_type_script_setup_true_lang.ycpSYFvJ.js +0 -517
- package/dist/chunks/MazTabs.vue_vue_type_script_setup_true_lang.CiIFxs7J.js +0 -28
- package/dist/chunks/MazTabsContent.vue_vue_type_script_setup_true_lang.MO7zA8LZ.js +0 -26
- package/dist/chunks/MazUiProvider.vue_vue_type_script_setup_true_lang.DtnM1DOn.js +0 -34
- package/dist/chunks/_plugin-vue_export-helper.B--vMWp3.js +0 -9
- package/dist/chunks/dom-events.DTx6Kblx.js +0 -368
- package/dist/chunks/fullscreen-img.directive.BJieSSIt.js +0 -321
- package/dist/chunks/lazy-img.directive.GRfYbidn.js +0 -174
- package/dist/chunks/resolveLinkComponent.CKR2McYy.js +0 -8
- package/dist/chunks/types.D0Bp_UhS.js +0 -6
- package/dist/chunks/useMazInputPhoneNumber.Os-2y9bz.js +0 -157
- package/dist/chunks/utils.D89Q5cCP.js +0 -207
- /package/dist/assets/{fullscreen-img.DFp1SMPU.css → vFullscreenImg.DFp1SMPU.css} +0 -0
|
@@ -1,105 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { MazNoImage } from "@maz-ui/icons/lazy";
|
|
3
|
-
import { d as directive } from "../chunks/lazy-img.directive.GRfYbidn.js";
|
|
4
|
-
import { d as directive$1 } from "../chunks/fullscreen-img.directive.BJieSSIt.js";
|
|
5
|
-
import { _ as _export_sfc } from "../chunks/_plugin-vue_export-helper.B--vMWp3.js";
|
|
6
|
-
import '../assets/MazGallery.Cizzw0bJ.css';const _hoisted_1 = { class: "m-gallery__wrapper maz-flex maz-flex-1" }, _hoisted_2 = ["alt"], _hoisted_3 = {
|
|
7
|
-
key: 0,
|
|
8
|
-
class: "m-gallery__remaining-layer"
|
|
9
|
-
}, _sfc_main = /* @__PURE__ */ defineComponent({
|
|
10
|
-
__name: "MazGallery",
|
|
11
|
-
props: {
|
|
12
|
-
images: { default: () => [] },
|
|
13
|
-
displayedCount: { default: 5 },
|
|
14
|
-
remaining: { type: Boolean, default: !0 },
|
|
15
|
-
height: { type: [Number, String, Boolean], default: "100%" },
|
|
16
|
-
width: { type: [Number, String, Boolean], default: "100%" },
|
|
17
|
-
radius: { type: Boolean, default: !0 },
|
|
18
|
-
zoom: { type: Boolean, default: !0 },
|
|
19
|
-
hasEmptyLayer: { type: Boolean, default: !0 },
|
|
20
|
-
lazy: { type: Boolean, default: !0 },
|
|
21
|
-
blur: { type: Boolean, default: !0 },
|
|
22
|
-
scale: { type: Boolean, default: !0 },
|
|
23
|
-
separatorColor: { default: "transparent" },
|
|
24
|
-
backgroundColor: { default: () => {
|
|
25
|
-
} }
|
|
26
|
-
},
|
|
27
|
-
setup(__props) {
|
|
28
|
-
onBeforeMount(() => {
|
|
29
|
-
__props.displayedCount > 5 && console.warn('[MazUI](m-gallery) The maximum of "displayed-count" is 5');
|
|
30
|
-
});
|
|
31
|
-
const sizeStyle = computed(() => ({
|
|
32
|
-
...__props.width === !1 ? {} : {
|
|
33
|
-
flex: `0 0 ${typeof __props.width}` == "number" ? `${__props.width}px` : __props.width,
|
|
34
|
-
width: typeof __props.width == "number" ? `${__props.width}px` : __props.width
|
|
35
|
-
},
|
|
36
|
-
...__props.height === !1 ? {} : {
|
|
37
|
-
height: typeof __props.height == "number" ? `${__props.height}px` : `${__props.height}`,
|
|
38
|
-
minHeight: typeof __props.height == "number" ? `${__props.height}px` : `${__props.height}`
|
|
39
|
-
}
|
|
40
|
-
})), imagesCount = computed(() => __props.displayedCount <= 5 ? __props.displayedCount : 5), numberImagesRemaining = computed(() => __props.images.length - (__props.images.length < imagesCount.value ? __props.images.length : imagesCount.value)), imagesNormalized = computed(() => __props.images.map(
|
|
41
|
-
(image) => typeof image == "object" ? { ...image, thumbnail: image.thumbnail ?? image.src } : { src: image, thumbnail: image, alt: void 0 }
|
|
42
|
-
)), imagesShown = computed(() => imagesNormalized.value.slice(0, imagesCount.value)), imagesHidden = computed(() => imagesNormalized.value.slice(imagesCount.value, __props.images.length));
|
|
43
|
-
function shouldHaveRemainingLayer(index) {
|
|
44
|
-
return __props.remaining ? (numberImagesRemaining.value && index + 1) === imagesShown.value.length : !1;
|
|
45
|
-
}
|
|
46
|
-
return (_ctx, _cache) => __props.images.length > 0 || __props.hasEmptyLayer ? (openBlock(), createElementBlock("div", {
|
|
47
|
-
key: 0,
|
|
48
|
-
class: normalizeClass(["m-gallery m-reset-css", { "--radius": __props.radius, "--has-background-color": !!__props.backgroundColor }]),
|
|
49
|
-
style: normalizeStyle([sizeStyle.value, {
|
|
50
|
-
"--gallery-separator-color": __props.separatorColor,
|
|
51
|
-
"--gallery-background-color": __props.backgroundColor
|
|
52
|
-
}])
|
|
53
|
-
}, [
|
|
54
|
-
createElementVNode("section", _hoisted_1, [
|
|
55
|
-
(openBlock(!0), createElementBlock(Fragment, null, renderList(imagesShown.value, (image, i) => (openBlock(), createElementBlock("figure", {
|
|
56
|
-
key: i,
|
|
57
|
-
class: normalizeClass(["m-gallery__item !maz-my-0 maz-flex maz-flex-center", [`m-gallery__item--${i + 1}`]])
|
|
58
|
-
}, [
|
|
59
|
-
withDirectives(createElementVNode("img", {
|
|
60
|
-
class: "m-gallery__item__image maz-flex-1",
|
|
61
|
-
src: "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
|
|
62
|
-
alt: image.alt,
|
|
63
|
-
loading: "lazy"
|
|
64
|
-
}, null, 8, _hoisted_2), [
|
|
65
|
-
[unref(directive), { src: image.thumbnail, disabled: !__props.lazy }, "bg-image"],
|
|
66
|
-
[unref(directive$1), {
|
|
67
|
-
src: image.src,
|
|
68
|
-
alt: image.alt,
|
|
69
|
-
disabled: !__props.zoom || shouldHaveRemainingLayer(i),
|
|
70
|
-
blurOnHover: __props.blur,
|
|
71
|
-
scaleOnHover: __props.scale
|
|
72
|
-
}]
|
|
73
|
-
]),
|
|
74
|
-
shouldHaveRemainingLayer(i) ? withDirectives((openBlock(), createElementBlock("div", _hoisted_3, [
|
|
75
|
-
createElementVNode("span", null, "+" + toDisplayString(numberImagesRemaining.value), 1)
|
|
76
|
-
])), [
|
|
77
|
-
[unref(directive$1), {
|
|
78
|
-
src: image.src,
|
|
79
|
-
alt: image.alt,
|
|
80
|
-
disabled: !__props.zoom,
|
|
81
|
-
blurOnHover: !1,
|
|
82
|
-
scaleOnHover: __props.scale
|
|
83
|
-
}]
|
|
84
|
-
]) : createCommentVNode("", !0)
|
|
85
|
-
], 2))), 128)),
|
|
86
|
-
__props.hasEmptyLayer && __props.images.length === 0 ? (openBlock(), createElementBlock("div", {
|
|
87
|
-
key: 0,
|
|
88
|
-
class: normalizeClass(["m-gallery__empty-layer", { "maz-rounded-xl": __props.radius }]),
|
|
89
|
-
style: normalizeStyle([sizeStyle.value])
|
|
90
|
-
}, [
|
|
91
|
-
createVNode(unref(MazNoImage), { class: "maz-size-8" })
|
|
92
|
-
], 6)) : createCommentVNode("", !0)
|
|
93
|
-
]),
|
|
94
|
-
(openBlock(!0), createElementBlock(Fragment, null, renderList(imagesHidden.value, (image, i) => withDirectives((openBlock(), createElementBlock("div", {
|
|
95
|
-
key: i,
|
|
96
|
-
class: "m-gallery__hidden"
|
|
97
|
-
})), [
|
|
98
|
-
[unref(directive$1), { src: image.src, disabled: !__props.zoom }]
|
|
99
|
-
])), 128))
|
|
100
|
-
], 6)) : createCommentVNode("", !0);
|
|
101
|
-
}
|
|
102
|
-
}), MazGallery = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-ea866cec"]]);
|
|
103
|
-
export {
|
|
104
|
-
MazGallery as default
|
|
105
|
-
};
|
|
1
|
+
import"../chunks/MazSpinner.D3NN2pow.js";import"../chunks/vFullscreenImg.CZeRh3mw.js";import{t as MazGallery_default}from"../chunks/MazGallery.CEmGy0K9.js";export{MazGallery_default as default};
|
|
@@ -1,114 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useInjectStrict } from "../composables/useInjectStrict.js";
|
|
3
|
-
import { _ as _export_sfc } from "../chunks/_plugin-vue_export-helper.B--vMWp3.js";
|
|
4
|
-
import '../assets/MazIcon.B6T_aVr6.css';const _hoisted_1 = ["innerHTML"], _sfc_main = /* @__PURE__ */ defineComponent({
|
|
5
|
-
__name: "MazIcon",
|
|
6
|
-
props: {
|
|
7
|
-
icon: { type: [Function, Object] },
|
|
8
|
-
src: {},
|
|
9
|
-
path: {},
|
|
10
|
-
name: {},
|
|
11
|
-
size: {},
|
|
12
|
-
title: {},
|
|
13
|
-
transformSource: { type: Function, default: (svg) => svg }
|
|
14
|
-
},
|
|
15
|
-
emits: ["loaded", "unloaded", "error"],
|
|
16
|
-
setup(__props, { emit: __emit }) {
|
|
17
|
-
const emits = __emit, predefinedSizes = ["xs", "sm", "md", "lg", "xl"], cache = {}, svgElSource = ref(), svgElem = ref();
|
|
18
|
-
function getMazIconPath() {
|
|
19
|
-
try {
|
|
20
|
-
return useInjectStrict("mazIconPath");
|
|
21
|
-
} catch {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
const iconPath = computed(() => __props.path ?? getMazIconPath()), fullSrc = computed(() => {
|
|
26
|
-
if (!__props.icon)
|
|
27
|
-
return __props.src ? __props.src : iconPath.value ? `${iconPath.value}/${__props.name}.svg` : `/${__props.name}.svg`;
|
|
28
|
-
});
|
|
29
|
-
onMounted(() => {
|
|
30
|
-
(__props.icon && __props.src || __props.icon && __props.name) && console.error('[maz-ui](MazIcon) you should provide "name" or "src" as prop'), !__props.icon && !__props.name && !__props.src && console.error('[maz-ui](MazIcon) you should provide "icon", "name" or "src" as prop');
|
|
31
|
-
});
|
|
32
|
-
function setTitle(svg, title) {
|
|
33
|
-
const titleTags = svg.querySelectorAll("title");
|
|
34
|
-
if (titleTags.length > 0)
|
|
35
|
-
titleTags[0].textContent = title;
|
|
36
|
-
else {
|
|
37
|
-
const titleEl = document.createElementNS("http://www.w3.org/2000/svg", "title");
|
|
38
|
-
titleEl.textContent = title, svg.append(titleEl);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function filterAttrs(attrs) {
|
|
42
|
-
return Object.keys(attrs).reduce((result, key) => (attrs[key] !== !1 && attrs[key] !== null && attrs[key] !== void 0 && (result[key] = attrs[key]), result), {});
|
|
43
|
-
}
|
|
44
|
-
function getSvgAttrs(svgEl) {
|
|
45
|
-
const svgAttrs = {}, attrs = svgEl.attributes;
|
|
46
|
-
if (!attrs)
|
|
47
|
-
return svgAttrs;
|
|
48
|
-
for (let i = attrs.length - 1; i >= 0; i--)
|
|
49
|
-
svgAttrs[attrs[i].name] = attrs[i].value;
|
|
50
|
-
return svgAttrs;
|
|
51
|
-
}
|
|
52
|
-
function getSvgContent(svgEl) {
|
|
53
|
-
svgEl.cloneNode(!0);
|
|
54
|
-
const svgElNode = __props.transformSource(svgEl);
|
|
55
|
-
return __props.title && setTitle(svgElNode, __props.title), svgEl.innerHTML;
|
|
56
|
-
}
|
|
57
|
-
async function getSource(src) {
|
|
58
|
-
cache[src] || (cache[src] = download(src));
|
|
59
|
-
try {
|
|
60
|
-
svgElSource.value = await cache[src], await nextTick(), emits("loaded", svgElem.value);
|
|
61
|
-
} catch (error) {
|
|
62
|
-
svgElSource.value && (svgElSource.value = void 0, emits("unloaded")), delete cache[src], emits("error", error);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
function download(url) {
|
|
66
|
-
return new Promise((resolve, reject) => {
|
|
67
|
-
const request = new XMLHttpRequest();
|
|
68
|
-
request.open("GET", url, !0), request.addEventListener("load", () => {
|
|
69
|
-
if (request.status >= 200 && request.status < 400)
|
|
70
|
-
try {
|
|
71
|
-
let svgEl = new DOMParser().parseFromString(request.responseText, "text/xml").querySelectorAll("svg")[0];
|
|
72
|
-
svgEl ? (svgEl = __props.transformSource(svgEl), resolve(svgEl)) : reject(new Error('Loaded file is not valid SVG"'));
|
|
73
|
-
} catch (error) {
|
|
74
|
-
reject(error);
|
|
75
|
-
}
|
|
76
|
-
else
|
|
77
|
-
reject(new Error("Error loading SVG"));
|
|
78
|
-
}), request.addEventListener("error", (error) => reject(error)), request.send();
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
const svgStyle = computed(() => {
|
|
82
|
-
if (!(__props.size && predefinedSizes.includes(__props.size)))
|
|
83
|
-
return {
|
|
84
|
-
fontSize: __props.size
|
|
85
|
-
};
|
|
86
|
-
}), svgClasses = computed(() => {
|
|
87
|
-
if (__props.size && predefinedSizes.includes(__props.size))
|
|
88
|
-
return `m-icon--${__props.size}`;
|
|
89
|
-
});
|
|
90
|
-
return watchEffect(() => {
|
|
91
|
-
fullSrc.value && getSource(fullSrc.value);
|
|
92
|
-
}), (_ctx, _cache) => svgElSource.value ? (openBlock(), createElementBlock("svg", mergeProps({
|
|
93
|
-
key: 0,
|
|
94
|
-
ref_key: "svgElem",
|
|
95
|
-
ref: svgElem,
|
|
96
|
-
class: ["m-icon m-reset-css", svgClasses.value],
|
|
97
|
-
width: "1em",
|
|
98
|
-
height: "1em"
|
|
99
|
-
}, {
|
|
100
|
-
...getSvgAttrs(svgElSource.value),
|
|
101
|
-
...filterAttrs(_ctx.$attrs)
|
|
102
|
-
}, {
|
|
103
|
-
style: svgStyle.value,
|
|
104
|
-
innerHTML: getSvgContent(svgElSource.value)
|
|
105
|
-
}), null, 16, _hoisted_1)) : (openBlock(), createBlock(resolveDynamicComponent(__props.icon), {
|
|
106
|
-
key: 1,
|
|
107
|
-
class: normalizeClass(["m-icon m-reset-css", svgClasses.value]),
|
|
108
|
-
style: normalizeStyle(svgStyle.value)
|
|
109
|
-
}, null, 8, ["class", "style"]));
|
|
110
|
-
}
|
|
111
|
-
}), MazIcon = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-71bafbcf"]]);
|
|
112
|
-
export {
|
|
113
|
-
MazIcon as default
|
|
114
|
-
};
|
|
1
|
+
import{t as MazIcon_default}from"../chunks/MazIcon.ZWAk25ZX.js";export{MazIcon_default as default};
|
|
@@ -1,256 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { MazEyeSlash, MazEye } from "@maz-ui/icons/lazy";
|
|
3
|
-
import { debounce } from "@maz-ui/utils/helpers/debounce";
|
|
4
|
-
import { useInstanceUniqId } from "../composables/useInstanceUniqId.js";
|
|
5
|
-
import { _ as _export_sfc } from "../chunks/_plugin-vue_export-helper.B--vMWp3.js";
|
|
6
|
-
import '../assets/MazInput.BG6XtSxl.css';const _hoisted_1 = ["for"], _hoisted_2 = {
|
|
7
|
-
key: 0,
|
|
8
|
-
class: "m-input-wrapper-left"
|
|
9
|
-
}, _hoisted_3 = ["id", "placeholder", "aria-label", "type", "inputmode", "name", "autocomplete", "disabled", "readonly", "required"], _hoisted_4 = {
|
|
10
|
-
key: 1,
|
|
11
|
-
class: "m-input-wrapper-right"
|
|
12
|
-
}, _sfc_main = /* @__PURE__ */ defineComponent({
|
|
13
|
-
inheritAttrs: !1,
|
|
14
|
-
__name: "MazInput",
|
|
15
|
-
props: {
|
|
16
|
-
style: { type: [Boolean, null, String, Object, Array], default: void 0 },
|
|
17
|
-
class: { type: [Boolean, null, String, Object, Array], default: void 0 },
|
|
18
|
-
modelValue: { default: void 0 },
|
|
19
|
-
placeholder: { default: void 0 },
|
|
20
|
-
label: { default: void 0 },
|
|
21
|
-
topLabel: {},
|
|
22
|
-
assistiveText: {},
|
|
23
|
-
color: { default: "primary" },
|
|
24
|
-
type: { default: "text" },
|
|
25
|
-
required: { type: Boolean, default: !1 },
|
|
26
|
-
disabled: { type: Boolean, default: !1 },
|
|
27
|
-
readonly: { type: Boolean },
|
|
28
|
-
id: { default: void 0 },
|
|
29
|
-
error: { type: Boolean, default: !1 },
|
|
30
|
-
success: { type: Boolean, default: !1 },
|
|
31
|
-
warning: { type: Boolean, default: !1 },
|
|
32
|
-
hint: { default: void 0 },
|
|
33
|
-
inputClasses: { default: void 0 },
|
|
34
|
-
border: { type: Boolean, default: !0 },
|
|
35
|
-
inputmode: { default: "text" },
|
|
36
|
-
size: { default: "md" },
|
|
37
|
-
debounce: { type: [Boolean, Number], default: !1 },
|
|
38
|
-
autoFocus: { type: Boolean, default: !1 },
|
|
39
|
-
borderActive: { type: Boolean, default: !1 },
|
|
40
|
-
leftIcon: { type: [String, Function, Object], default: void 0 },
|
|
41
|
-
rightIcon: { type: [String, Function, Object], default: void 0 },
|
|
42
|
-
roundedSize: { default: "lg" },
|
|
43
|
-
block: { type: Boolean },
|
|
44
|
-
name: {},
|
|
45
|
-
autocomplete: {},
|
|
46
|
-
loading: { type: Boolean, default: !1 }
|
|
47
|
-
},
|
|
48
|
-
emits: ["update:model-value", "focus", "blur", "click", "change", "input"],
|
|
49
|
-
setup(__props, { emit: __emit }) {
|
|
50
|
-
const props = __props, emits = __emit, MazIcon = defineAsyncComponent(() => import("./MazIcon.js")), MazBtn = defineAsyncComponent(() => import("./MazBtn.js")), MazSpinner = defineAsyncComponent(() => import("./MazSpinner.js")), hasPasswordVisible = ref(!1), isFocused = ref(!1), input = ref(), instanceId = useInstanceUniqId({
|
|
51
|
-
componentName: "MazInput",
|
|
52
|
-
providedId: props.id
|
|
53
|
-
});
|
|
54
|
-
onMounted(() => {
|
|
55
|
-
props.autoFocus && input.value?.focus();
|
|
56
|
-
});
|
|
57
|
-
const isPasswordType = computed(() => props.type === "password"), inputType = computed(() => hasPasswordVisible.value ? "text" : props.type), borderStyle = computed(() => {
|
|
58
|
-
if (props.border) {
|
|
59
|
-
if (props.error && !isFocused.value)
|
|
60
|
-
return "maz-border-destructive";
|
|
61
|
-
if (props.success && !isFocused.value)
|
|
62
|
-
return "maz-border-success";
|
|
63
|
-
if (props.warning && !isFocused.value)
|
|
64
|
-
return "maz-border-warning";
|
|
65
|
-
if (isFocused.value || props.borderActive) {
|
|
66
|
-
if (props.color === "destructive")
|
|
67
|
-
return "maz-border-destructive";
|
|
68
|
-
if (props.color === "info")
|
|
69
|
-
return "maz-border-info";
|
|
70
|
-
if (props.color === "primary")
|
|
71
|
-
return "maz-border-primary";
|
|
72
|
-
if (props.color === "secondary")
|
|
73
|
-
return "maz-border-secondary";
|
|
74
|
-
if (props.color === "success")
|
|
75
|
-
return "maz-border-success";
|
|
76
|
-
if (props.color === "warning")
|
|
77
|
-
return "maz-border-warning";
|
|
78
|
-
if (props.color === "accent")
|
|
79
|
-
return "maz-border-accent";
|
|
80
|
-
if (props.color === "contrast")
|
|
81
|
-
return "maz-border-contrast";
|
|
82
|
-
}
|
|
83
|
-
return "--default-border";
|
|
84
|
-
}
|
|
85
|
-
}), slots = useSlots(), debounceEmitValue = debounce(
|
|
86
|
-
(value) => {
|
|
87
|
-
emits("update:model-value", value);
|
|
88
|
-
},
|
|
89
|
-
typeof props.debounce == "number" ? props.debounce : 500
|
|
90
|
-
);
|
|
91
|
-
function emitValue(value) {
|
|
92
|
-
if (props.debounce)
|
|
93
|
-
return debounceEmitValue(value);
|
|
94
|
-
emits("update:model-value", value);
|
|
95
|
-
}
|
|
96
|
-
const model = computed({
|
|
97
|
-
get: () => props.modelValue,
|
|
98
|
-
set: (value) => emitValue(value)
|
|
99
|
-
}), hasValue = computed(() => model.value !== void 0 && model.value !== ""), shouldUp = computed(() => (!!props.label || !!props.hint) && (!!hasValue.value || !!props.placeholder || ["date", "month", "week"].includes(props.type))), hasLabel = computed(() => !!props.label || !!props.hint);
|
|
100
|
-
function hasRightPart() {
|
|
101
|
-
return !!slots["right-icon"] || isPasswordType.value || !!props.rightIcon || props.loading;
|
|
102
|
-
}
|
|
103
|
-
function hasLeftPart() {
|
|
104
|
-
return !!slots["left-icon"] || !!props.leftIcon;
|
|
105
|
-
}
|
|
106
|
-
function focus(event) {
|
|
107
|
-
emits("focus", event), isFocused.value = !0;
|
|
108
|
-
}
|
|
109
|
-
function blur(event) {
|
|
110
|
-
emits("blur", event), isFocused.value = !1;
|
|
111
|
-
}
|
|
112
|
-
function change(event) {
|
|
113
|
-
return emits("change", event);
|
|
114
|
-
}
|
|
115
|
-
function emitInputEvent(event) {
|
|
116
|
-
return emits("input", event);
|
|
117
|
-
}
|
|
118
|
-
const stateColor = computed(() => {
|
|
119
|
-
if (props.error)
|
|
120
|
-
return "!maz-text-destructive-600";
|
|
121
|
-
if (props.success)
|
|
122
|
-
return "!maz-text-success-600";
|
|
123
|
-
if (props.warning)
|
|
124
|
-
return "!maz-text-warning-600";
|
|
125
|
-
});
|
|
126
|
-
return (_ctx, _cache) => (openBlock(), createElementBlock("div", {
|
|
127
|
-
class: normalizeClass(["m-input m-reset-css", [
|
|
128
|
-
{
|
|
129
|
-
"--is-focused": isFocused.value || __props.borderActive,
|
|
130
|
-
"--should-up": shouldUp.value,
|
|
131
|
-
"--has-label": hasLabel.value,
|
|
132
|
-
"--is-readonly": __props.readonly,
|
|
133
|
-
"--has-z-2": __props.error || __props.warning || __props.success,
|
|
134
|
-
"--has-state": __props.error || __props.warning || __props.success,
|
|
135
|
-
"--block": __props.block
|
|
136
|
-
},
|
|
137
|
-
props.class,
|
|
138
|
-
`--${__props.color}`
|
|
139
|
-
]]),
|
|
140
|
-
style: normalizeStyle([__props.style, { "--maz-input-color": `hsl(var(--maz-${__props.color}-100))` }])
|
|
141
|
-
}, [
|
|
142
|
-
__props.topLabel ? (openBlock(), createElementBlock("label", {
|
|
143
|
-
key: 0,
|
|
144
|
-
for: unref(instanceId),
|
|
145
|
-
class: normalizeClass(["m-input-top-label", stateColor.value])
|
|
146
|
-
}, toDisplayString(__props.topLabel), 11, _hoisted_1)) : createCommentVNode("", !0),
|
|
147
|
-
createElementVNode("div", {
|
|
148
|
-
class: normalizeClass(["m-input-wrapper", [
|
|
149
|
-
__props.inputClasses,
|
|
150
|
-
borderStyle.value,
|
|
151
|
-
`--rounded-${__props.roundedSize}`,
|
|
152
|
-
{ "--block": __props.block, "--border": __props.border }
|
|
153
|
-
]])
|
|
154
|
-
}, [
|
|
155
|
-
hasLeftPart() ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
156
|
-
_ctx.$slots["left-icon"] || __props.leftIcon ? renderSlot(_ctx.$slots, "left-icon", { key: 0 }, () => [
|
|
157
|
-
typeof __props.leftIcon == "string" ? (openBlock(), createBlock(unref(MazIcon), {
|
|
158
|
-
key: 0,
|
|
159
|
-
name: __props.leftIcon,
|
|
160
|
-
class: normalizeClass(["maz-text-xl", stateColor.value || "maz-text-muted"])
|
|
161
|
-
}, null, 8, ["name", "class"])) : __props.leftIcon ? (openBlock(), createBlock(resolveDynamicComponent(__props.leftIcon), {
|
|
162
|
-
key: 1,
|
|
163
|
-
class: normalizeClass(["maz-text-xl", stateColor.value || "maz-text-muted"])
|
|
164
|
-
}, null, 8, ["class"])) : createCommentVNode("", !0)
|
|
165
|
-
], !0) : createCommentVNode("", !0)
|
|
166
|
-
])) : createCommentVNode("", !0),
|
|
167
|
-
createElementVNode("div", {
|
|
168
|
-
class: normalizeClass(["m-input-wrapper-input", [
|
|
169
|
-
`--${__props.size}`,
|
|
170
|
-
{
|
|
171
|
-
"--top-label": !!__props.topLabel,
|
|
172
|
-
"--has-left-icon": hasLeftPart(),
|
|
173
|
-
"--has-right-icon": hasRightPart()
|
|
174
|
-
}
|
|
175
|
-
]])
|
|
176
|
-
}, [
|
|
177
|
-
withDirectives(createElementVNode("input", mergeProps({ id: unref(instanceId) }, _ctx.$attrs, {
|
|
178
|
-
ref_key: "input",
|
|
179
|
-
ref: input,
|
|
180
|
-
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event),
|
|
181
|
-
placeholder: __props.placeholder,
|
|
182
|
-
"aria-label": __props.label || __props.placeholder,
|
|
183
|
-
type: inputType.value,
|
|
184
|
-
inputmode: __props.inputmode,
|
|
185
|
-
name: __props.name,
|
|
186
|
-
autocomplete: __props.autocomplete,
|
|
187
|
-
disabled: __props.disabled,
|
|
188
|
-
readonly: __props.readonly,
|
|
189
|
-
required: __props.required,
|
|
190
|
-
class: "m-input-input"
|
|
191
|
-
}, toHandlers({
|
|
192
|
-
blur,
|
|
193
|
-
focus,
|
|
194
|
-
change,
|
|
195
|
-
input: emitInputEvent
|
|
196
|
-
}, !0), {
|
|
197
|
-
onClick: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("click", $event))
|
|
198
|
-
}), null, 16, _hoisted_3), [
|
|
199
|
-
[vModelDynamic, model.value]
|
|
200
|
-
]),
|
|
201
|
-
__props.label || __props.hint ? (openBlock(), createElementBlock("span", {
|
|
202
|
-
key: 0,
|
|
203
|
-
class: normalizeClass(["m-input-label", stateColor.value])
|
|
204
|
-
}, toDisplayString(__props.hint || __props.label), 3)) : createCommentVNode("", !0)
|
|
205
|
-
], 2),
|
|
206
|
-
hasRightPart() ? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
207
|
-
_ctx.$slots["right-icon"] || __props.rightIcon ? renderSlot(_ctx.$slots, "right-icon", { key: 0 }, () => [
|
|
208
|
-
typeof __props.rightIcon == "string" ? (openBlock(), createBlock(unref(MazIcon), {
|
|
209
|
-
key: 0,
|
|
210
|
-
name: __props.rightIcon,
|
|
211
|
-
class: normalizeClass(["maz-text-xl", stateColor.value || "maz-text-muted"])
|
|
212
|
-
}, null, 8, ["name", "class"])) : __props.rightIcon ? (openBlock(), createBlock(resolveDynamicComponent(__props.rightIcon), {
|
|
213
|
-
key: 1,
|
|
214
|
-
class: normalizeClass(["maz-text-xl", stateColor.value || "maz-text-muted"])
|
|
215
|
-
}, null, 8, ["class"])) : createCommentVNode("", !0)
|
|
216
|
-
], !0) : createCommentVNode("", !0),
|
|
217
|
-
isPasswordType.value ? (openBlock(), createBlock(unref(MazBtn), {
|
|
218
|
-
key: 1,
|
|
219
|
-
color: "transparent",
|
|
220
|
-
tabindex: "-1",
|
|
221
|
-
size: "mini",
|
|
222
|
-
onClick: _cache[2] || (_cache[2] = withModifiers(($event) => hasPasswordVisible.value = !hasPasswordVisible.value, ["stop"]))
|
|
223
|
-
}, {
|
|
224
|
-
default: withCtx(() => [
|
|
225
|
-
hasPasswordVisible.value ? (openBlock(), createBlock(unref(MazEyeSlash), {
|
|
226
|
-
key: 0,
|
|
227
|
-
class: "maz-text-xl maz-text-muted"
|
|
228
|
-
})) : (openBlock(), createBlock(unref(MazEye), {
|
|
229
|
-
key: 1,
|
|
230
|
-
class: "maz-text-xl maz-text-muted"
|
|
231
|
-
}))
|
|
232
|
-
]),
|
|
233
|
-
_: 1
|
|
234
|
-
})) : createCommentVNode("", !0),
|
|
235
|
-
__props.loading ? renderSlot(_ctx.$slots, "loader", { key: 2 }, () => [
|
|
236
|
-
createVNode(unref(MazSpinner), { color: __props.color }, null, 8, ["color"])
|
|
237
|
-
], !0) : createCommentVNode("", !0)
|
|
238
|
-
])) : createCommentVNode("", !0)
|
|
239
|
-
], 2),
|
|
240
|
-
__props.assistiveText ? (openBlock(), createElementBlock("div", {
|
|
241
|
-
key: 1,
|
|
242
|
-
class: normalizeClass(["m-input-bottom-text", [
|
|
243
|
-
{
|
|
244
|
-
"maz-text-destructive-600": __props.error,
|
|
245
|
-
"maz-text-success-600": __props.success,
|
|
246
|
-
"maz-text-warning-600": __props.warning,
|
|
247
|
-
"maz-text-muted": !__props.error && !__props.success && !__props.warning
|
|
248
|
-
}
|
|
249
|
-
]])
|
|
250
|
-
}, toDisplayString(__props.assistiveText), 3)) : createCommentVNode("", !0)
|
|
251
|
-
], 6));
|
|
252
|
-
}
|
|
253
|
-
}), MazInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-e2d8a63d"]]);
|
|
254
|
-
export {
|
|
255
|
-
MazInput as default
|
|
256
|
-
};
|
|
1
|
+
import{t as MazInput_default}from"../chunks/MazInput.DJjWLaKg.js";export{MazInput_default as default};
|
|
@@ -1,152 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { _ as _export_sfc } from "../chunks/_plugin-vue_export-helper.B--vMWp3.js";
|
|
3
|
-
import '../assets/MazInputCode.Dn05KUeo.css';const _hoisted_1 = ["disabled"], _hoisted_2 = { class: "m-input-code__wrapper" }, _hoisted_3 = ["id", "name", "inputmode", "pattern", "required", "value", "onInput", "onKeydown", "onClick"], _sfc_main = /* @__PURE__ */ defineComponent({
|
|
4
|
-
inheritAttrs: !1,
|
|
5
|
-
__name: "MazInputCode",
|
|
6
|
-
props: {
|
|
7
|
-
style: { type: [Boolean, null, String, Object, Array], default: void 0 },
|
|
8
|
-
class: { type: [Boolean, null, String, Object, Array], default: void 0 },
|
|
9
|
-
modelValue: { default: void 0 },
|
|
10
|
-
codeLength: { default: 4 },
|
|
11
|
-
type: { default: "text" },
|
|
12
|
-
acceptAlpha: { type: Boolean, default: !1 },
|
|
13
|
-
required: { type: Boolean, default: !1 },
|
|
14
|
-
disabled: { type: Boolean, default: !1 },
|
|
15
|
-
error: { type: Boolean, default: !1 },
|
|
16
|
-
success: { type: Boolean, default: !1 },
|
|
17
|
-
warning: { type: Boolean, default: !1 },
|
|
18
|
-
size: { default: "md" },
|
|
19
|
-
color: { default: "primary" },
|
|
20
|
-
hint: {}
|
|
21
|
-
},
|
|
22
|
-
emits: ["update:model-value", "completed"],
|
|
23
|
-
setup(__props, { emit: __emit }) {
|
|
24
|
-
const props = __props, emits = __emit, inputList = ref([]), localMap = ref(/* @__PURE__ */ new Map());
|
|
25
|
-
watch(
|
|
26
|
-
() => props.modelValue,
|
|
27
|
-
(value, oldValue) => {
|
|
28
|
-
value !== oldValue && (localMap.value = getMapValues());
|
|
29
|
-
},
|
|
30
|
-
{ immediate: !0 }
|
|
31
|
-
);
|
|
32
|
-
const inputValues = computed({
|
|
33
|
-
get: () => localMap.value,
|
|
34
|
-
set: (value) => {
|
|
35
|
-
const emittedValue = getEmittedValue(value);
|
|
36
|
-
emits("update:model-value", emittedValue), emittedValue?.toString().length === props.codeLength && emits("completed");
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
function getMapValues(value = props.modelValue) {
|
|
40
|
-
const map = /* @__PURE__ */ new Map();
|
|
41
|
-
for (const item of Array.from({ length: props.codeLength }, (_, i) => i))
|
|
42
|
-
if (value === void 0)
|
|
43
|
-
map.set(item + 1, void 0);
|
|
44
|
-
else {
|
|
45
|
-
const values = [...value.toString()];
|
|
46
|
-
map.set(item + 1, values[item]);
|
|
47
|
-
}
|
|
48
|
-
return map;
|
|
49
|
-
}
|
|
50
|
-
function handleNewValue(event, item) {
|
|
51
|
-
const newValue = getValueSanitized(event.target?.value);
|
|
52
|
-
inputValues.value = localMap.value.set(item, newValue), newValue && focusAndSelectInputByIndex(item);
|
|
53
|
-
}
|
|
54
|
-
function getEmittedValue(map) {
|
|
55
|
-
const stringValue = [...map.values()].join("");
|
|
56
|
-
return props.type === "text" ? stringValue : stringValue && !Number.isNaN(Number(stringValue)) ? Number(stringValue) : void 0;
|
|
57
|
-
}
|
|
58
|
-
const isLetterOrNumberRegex = /^[\w.]$/, isNumberRegex = /\d+/g;
|
|
59
|
-
function getValueSanitized(value) {
|
|
60
|
-
return (props.acceptAlpha ? value.match(isLetterOrNumberRegex) : value.match(isNumberRegex))?.toString();
|
|
61
|
-
}
|
|
62
|
-
function handleKeydown(event, inputIndex) {
|
|
63
|
-
const currentInputValue = localMap.value.get(inputIndex);
|
|
64
|
-
if (event.key === "ArrowRight" && focusAndSelectInputByIndex(inputIndex), event.key === "ArrowLeft" && focusAndSelectInputByIndex(inputIndex - 2), event.key === "Backspace" && !currentInputValue) {
|
|
65
|
-
const previousInputIndexToFocus = inputIndex - 1 < 0 ? 0 : inputIndex - 1;
|
|
66
|
-
inputValues.value = localMap.value.set(previousInputIndexToFocus, void 0), focusAndSelectInputByIndex(previousInputIndexToFocus - 1);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
function setValueOnPaste(event) {
|
|
70
|
-
const pasteData = event.clipboardData?.getData("text");
|
|
71
|
-
if (!pasteData)
|
|
72
|
-
return;
|
|
73
|
-
const indexInputsFromPastePlace = Array.from({ length: props.codeLength }, (_, i) => ({
|
|
74
|
-
index: i + 1,
|
|
75
|
-
value: [...pasteData.toString()][i] ?? void 0
|
|
76
|
-
}));
|
|
77
|
-
for (const { index, value } of indexInputsFromPastePlace) {
|
|
78
|
-
const sanitizedValue = value ? getValueSanitized(value) : void 0;
|
|
79
|
-
sanitizedValue && localMap.value.set(index, sanitizedValue);
|
|
80
|
-
}
|
|
81
|
-
setTimeout(() => {
|
|
82
|
-
const lastInputWithoutValueIndex = getLastInputWithoutValueIndex(), lastIndex = lastInputWithoutValueIndex >= props.codeLength ? props.codeLength - 1 : lastInputWithoutValueIndex;
|
|
83
|
-
focusAndSelectInputByIndex(lastIndex, !1);
|
|
84
|
-
}, 0);
|
|
85
|
-
}
|
|
86
|
-
function getLastInputWithoutValueIndex() {
|
|
87
|
-
return [...localMap.value.values()].filter(Boolean).length;
|
|
88
|
-
}
|
|
89
|
-
function focusAndSelectInputByIndex(index, selectValue = !0) {
|
|
90
|
-
setTimeout(() => {
|
|
91
|
-
const input = inputList.value[index];
|
|
92
|
-
index + 1 > props.codeLength || !input || (input.focus(), selectValue && selectInputByIndex(index));
|
|
93
|
-
}, 0);
|
|
94
|
-
}
|
|
95
|
-
function selectInputByIndex(index) {
|
|
96
|
-
const input = inputList.value[index];
|
|
97
|
-
index + 1 > props.codeLength || !input || input.select();
|
|
98
|
-
}
|
|
99
|
-
const borderColorState = computed(() => {
|
|
100
|
-
if (props.error)
|
|
101
|
-
return "!maz-border-destructive";
|
|
102
|
-
if (props.success)
|
|
103
|
-
return "!maz-border-success";
|
|
104
|
-
if (props.warning)
|
|
105
|
-
return "!maz-border-warning";
|
|
106
|
-
});
|
|
107
|
-
return (_ctx, _cache) => (openBlock(), createElementBlock("fieldset", {
|
|
108
|
-
class: normalizeClass(["m-input-code m-reset-css", [__props.size ? `--${__props.size}` : void 0, props.class]]),
|
|
109
|
-
disabled: __props.disabled,
|
|
110
|
-
style: normalizeStyle([__props.style, { "--input-border-color": `hsl(var(--maz-${props.color}))` }])
|
|
111
|
-
}, [
|
|
112
|
-
createElementVNode("div", _hoisted_2, [
|
|
113
|
-
(openBlock(!0), createElementBlock(Fragment, null, renderList(__props.codeLength, (item) => (openBlock(), createElementBlock("div", {
|
|
114
|
-
key: item,
|
|
115
|
-
class: normalizeClass(["input-wrapper", borderColorState.value])
|
|
116
|
-
}, [
|
|
117
|
-
createElementVNode("input", mergeProps({
|
|
118
|
-
id: `m-input-code-${item}`,
|
|
119
|
-
ref_for: !0,
|
|
120
|
-
ref: (el) => {
|
|
121
|
-
inputList.value[item - 1] = el;
|
|
122
|
-
},
|
|
123
|
-
type: "text",
|
|
124
|
-
name: `m-input-code-${item}`,
|
|
125
|
-
minlength: "1",
|
|
126
|
-
maxlength: "1",
|
|
127
|
-
inputmode: __props.acceptAlpha ? "text" : "numeric",
|
|
128
|
-
pattern: __props.acceptAlpha ? "[a-zA-Z0-9]{1}" : "[0-9]{1}",
|
|
129
|
-
autocomplete: "do-not-autofill",
|
|
130
|
-
required: __props.required
|
|
131
|
-
}, { ref_for: !0 }, _ctx.$attrs, {
|
|
132
|
-
value: inputValues.value.get(item),
|
|
133
|
-
onInput: ($event) => handleNewValue($event, item),
|
|
134
|
-
onKeydown: ($event) => handleKeydown($event, item),
|
|
135
|
-
onClick: ($event) => selectInputByIndex(item - 1),
|
|
136
|
-
onPaste: setValueOnPaste
|
|
137
|
-
}), null, 16, _hoisted_3)
|
|
138
|
-
], 2))), 128))
|
|
139
|
-
]),
|
|
140
|
-
createElementVNode("span", {
|
|
141
|
-
class: normalizeClass(["m-input-code__hint", {
|
|
142
|
-
"--error": __props.error,
|
|
143
|
-
"--success": __props.success,
|
|
144
|
-
"--warning": __props.warning
|
|
145
|
-
}])
|
|
146
|
-
}, toDisplayString(__props.hint), 3)
|
|
147
|
-
], 14, _hoisted_1));
|
|
148
|
-
}
|
|
149
|
-
}), MazInputCode = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-8bc09e57"]]);
|
|
150
|
-
export {
|
|
151
|
-
MazInputCode as default
|
|
152
|
-
};
|
|
1
|
+
import{t as MazInputCode_default}from"../chunks/MazInputCode.DKnl3i-X.js";export{MazInputCode_default as default};
|