maz-ui 4.0.0-beta.3 → 4.0.0-beta.33
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/README.md +1 -1
- package/dist/assets/MazAccordion.DUQCf8vy.css +1 -0
- package/dist/assets/{MazAnimatedCounter.CTG-PC5W.css → MazAnimatedCounter.DkZNPRLp.css} +1 -1
- package/dist/assets/MazAnimatedText.DDqCxrFX.css +1 -0
- package/dist/assets/MazBackdrop.BnhcmjbP.css +1 -0
- package/dist/assets/{MazBadge.DN8tdE8_.css → MazBadge.ChI2DaTU.css} +1 -1
- package/dist/assets/MazBtn.BYOKMl_2.css +1 -0
- package/dist/assets/MazCard.D0ksni8A.css +1 -0
- package/dist/assets/{MazCardSpotlight.Dy-wuLQq.css → MazCardSpotlight.IbPp_y0j.css} +1 -1
- package/dist/assets/MazCarousel.D4zTkRsG.css +1 -0
- package/dist/assets/MazCheckbox.aH1IKnrR.css +1 -0
- package/dist/assets/MazChecklist.BzF5KtZ3.css +1 -0
- package/dist/assets/MazDatePicker.BUVI9tfN.css +1 -0
- package/dist/assets/MazDropzone.C2SunLAI.css +1 -0
- package/dist/assets/MazInput.BPhjbYZG.css +1 -0
- package/dist/assets/MazInputCode.FA2z4HQd.css +1 -0
- package/dist/assets/MazInputPhoneNumber.DQKElfIM.css +1 -0
- package/dist/assets/MazInputTags.KNTpDHof.css +1 -0
- package/dist/assets/MazLazyImg.NlPRN3Nk.css +1 -0
- package/dist/assets/MazLink.CFscNMFr.css +1 -0
- package/dist/assets/MazPickerCalendar.e-eF8E7m.css +1 -0
- package/dist/assets/MazPickerCalendarMonth.BRoEh_ad.css +1 -0
- package/dist/assets/{MazPickerCalendarSwitcher.uni8vJJv.css → MazPickerCalendarSwitcher.CI9Vw1sJ.css} +1 -1
- package/dist/assets/{MazPickerContainer.k3DGjyHC.css → MazPickerContainer.DmHuaFqE.css} +1 -1
- package/dist/assets/{MazPickerHeader.ZYCJY5bX.css → MazPickerHeader.C4W93yMD.css} +1 -1
- package/dist/assets/MazPickerMonthSwitcher.D9lfVzYo.css +1 -0
- package/dist/assets/{MazPickerYearSwitcher.Dl30Dwor.css → MazPickerYearSwitcher.CFiH13QC.css} +1 -1
- package/dist/assets/MazPopover.BkR4UUzj.css +1 -0
- package/dist/assets/MazPullToRefresh.BQ64UvzA.css +1 -0
- package/dist/assets/MazRadio.aTHM-mpx.css +1 -0
- package/dist/assets/MazRadioButtons.DN_rAzT9.css +1 -0
- package/dist/assets/MazReadingProgressBar.CwBVXE3g.css +1 -0
- package/dist/assets/MazSelect.DuRAHZGW.css +1 -0
- package/dist/assets/{MazSelectCountry.D2Qudf0K.css → MazSelectCountry.EW8fKXFX.css} +1 -1
- package/dist/assets/{MazSlider.D5SgmZLH.css → MazSlider.y4qpnD0N.css} +1 -1
- package/dist/assets/MazSpinner.CsiFJ1DS.css +1 -0
- package/dist/assets/MazStepper.BD2gDGAX.css +1 -0
- package/dist/assets/MazSwitch.Bxmh2iFj.css +1 -0
- package/dist/assets/{MazTable.B1tkeUfE.css → MazTable.DMlQdImb.css} +1 -1
- package/dist/assets/MazTableRow.DgBXpK9J.css +1 -0
- package/dist/assets/{MazTabsBar.B9N_jdqU.css → MazTabsBar.gcS2Fc-B.css} +1 -1
- package/dist/assets/{MazTabsContentItem.CHfy19ZF.css → MazTabsContentItem.C84SDmj0.css} +1 -1
- package/dist/assets/MazTextarea.li9dWBax.css +1 -0
- package/dist/assets/{PhoneInput.CyWO76iq.css → PhoneInput.DCWA_-gC.css} +1 -1
- package/dist/assets/{fullscreen-img.pvt6196l.css → fullscreen-img.Bkuz1GOX.css} +1 -1
- package/dist/assets/{toast.kunueRvo.css → toast.DH9mbkvs.css} +1 -1
- package/dist/chunks/{MazDatePicker.CT5yJhSN.js → MazDatePicker.bKFpslPf.js} +54 -44
- package/dist/chunks/{MazDialogPromise.vue_vue_type_script_setup_true_lang.BQvDEofz.js → MazDialogConfirm.vue_vue_type_script_setup_true_lang.Grn2kB3x.js} +78 -18
- package/dist/chunks/{MazDropdown.vue_vue_type_style_index_0_lang.abk1IbMX.js → MazDropdown.vue_vue_type_style_index_0_lang.X8ygqBUZ.js} +22 -27
- package/dist/chunks/{MazInputPhoneNumber.Uwhn1Q9j.js → MazInputPhoneNumber.BVHi0OiN.js} +28 -18
- package/dist/chunks/{MazInputPrice.vue_vue_type_script_setup_true_lang.GMKzSu7R.js → MazInputPrice.vue_vue_type_script_setup_true_lang.BA6TDX-T.js} +31 -1
- package/dist/chunks/{MazPickerCalendar.RS6ZMdDK.js → MazPickerCalendar.lLfvUtrb.js} +8 -8
- package/dist/chunks/{MazPickerCalendarMonth.hQBSVkc9.js → MazPickerCalendarMonth.Djzgo1tF.js} +9 -9
- package/dist/chunks/{MazPickerCalendarSwitcher.Cp2ux3E4.js → MazPickerCalendarSwitcher.Bf24kKw6.js} +3 -3
- package/dist/chunks/{MazPickerContainer.DnfB3Dqg.js → MazPickerContainer.7hYHiOaa.js} +4 -6
- package/dist/chunks/{MazPickerHeader.Dlz2yJ1D.js → MazPickerHeader.B00RAQPS.js} +3 -3
- package/dist/chunks/{MazPickerMonthSwitcher.BpfCGGxQ.js → MazPickerMonthSwitcher.B2ZgNJWy.js} +5 -6
- package/dist/chunks/{MazPickerTime.EuWWNfid.js → MazPickerTime.Bd4khA2e.js} +1 -1
- package/dist/chunks/{MazPickerYearSwitcher.D4aO09D3.js → MazPickerYearSwitcher.BIy9xGIw.js} +8 -27
- package/dist/chunks/{MazSwitch.vue_vue_type_style_index_0_lang.DnCjlD6D.js → MazSwitch.vue_vue_type_style_index_0_lang.CU43Y1ky.js} +2 -2
- package/dist/chunks/{MazTable.vue_vue_type_script_setup_true_lang.bm7ng8fK.js → MazTable.vue_vue_type_script_setup_true_lang.BcTw9Tyh.js} +3 -3
- package/dist/chunks/{PhoneInput.CPjyZ8Sq.js → PhoneInput.D9vRIgS6.js} +21 -27
- package/dist/chunks/{utils.BBuYjMbK.js → dom-events.Bbe7wDQl.js} +221 -115
- package/dist/chunks/{en.BzBlrE0C.js → en.Q_4-KljL.js} +12 -0
- package/dist/chunks/{fullscreen-img.directive.CyOHexcO.js → fullscreen-img.directive.Be383en8.js} +2 -2
- package/dist/chunks/{lazy-img.directive.D5zCo3Zi.js → lazy-img.directive.BLFnGqQa.js} +1 -1
- package/dist/chunks/pascalCase.GdDKKQ-O.js +19 -0
- package/dist/chunks/types.D0Bp_UhS.js +6 -0
- package/dist/chunks/useStringMatching.BBezu-6J.js +134 -0
- package/dist/chunks/{useTranslations.BXuww4ux.js → useTranslations.D5aoYwD7.js} +1 -1
- package/dist/chunks/vClickOutside.DIOiluy0.js +107 -0
- package/dist/components/MazAccordion.js +2 -2
- package/dist/components/MazAnimatedCounter.js +3 -3
- package/dist/components/MazAnimatedText.js +2 -2
- package/dist/components/MazBackdrop.js +3 -3
- package/dist/components/MazBadge.js +5 -4
- package/dist/components/MazBtn.js +9 -7
- package/dist/components/MazCard.js +2 -2
- package/dist/components/MazCardSpotlight.js +4 -4
- package/dist/components/MazCarousel.js +12 -9
- package/dist/components/MazCheckbox.js +10 -12
- package/dist/components/MazChecklist.js +4 -5
- package/dist/components/MazDatePicker.js +1 -1
- package/dist/components/MazDialogConfirm.js +6 -0
- package/dist/components/MazDropdown.js +1 -1
- package/dist/components/MazDropzone.js +5 -5
- package/dist/components/MazGallery.js +2 -2
- package/dist/components/MazInput.js +21 -16
- package/dist/components/MazInputCode.js +2 -2
- package/dist/components/MazInputPhoneNumber.js +1 -1
- package/dist/components/MazInputPrice.js +1 -1
- package/dist/components/MazInputTags.js +2 -2
- package/dist/components/MazLazyImg.js +9 -9
- package/dist/components/MazLink.js +9 -5
- package/dist/components/MazPagination.js +1 -1
- package/dist/components/MazPopover.js +127 -164
- package/dist/components/MazPullToRefresh.js +8 -3
- package/dist/components/MazRadio.js +8 -16
- package/dist/components/MazRadioButtons.js +8 -7
- package/dist/components/MazReadingProgressBar.js +10 -3
- package/dist/components/MazSelect.js +31 -18
- package/dist/components/MazSelectCountry.js +18 -11
- package/dist/components/MazSlider.js +2 -2
- package/dist/components/MazSpinner.js +3 -4
- package/dist/components/MazStepper.js +2 -2
- package/dist/components/MazSwitch.js +1 -1
- package/dist/components/MazTable.js +3 -3
- package/dist/components/MazTableCell.js +1 -1
- package/dist/components/MazTableRow.js +3 -3
- package/dist/components/MazTableTitle.js +1 -1
- package/dist/components/MazTabsBar.js +6 -6
- package/dist/components/MazTabsContentItem.js +6 -7
- package/dist/components/MazTextarea.js +24 -3
- package/dist/components/index.js +8 -8
- package/dist/composables/index.js +4 -2
- package/dist/composables/useAos.js +1 -1
- package/dist/composables/useDialog.js +1 -1
- package/dist/composables/useDisplayNames.js +17 -13
- package/dist/composables/useDropzone.js +7 -7
- package/dist/composables/useFormField.js +15 -19
- package/dist/composables/useFormValidator.js +58 -29
- package/dist/composables/useIdleTimeout.js +108 -1
- package/dist/composables/useInjectStrict.js +2 -2
- package/dist/composables/useInstanceUniqId.js +3 -2
- package/dist/composables/useStringMatching.js +3 -40
- package/dist/composables/useSwipe.js +77 -1
- package/dist/composables/useToast.js +1 -1
- package/dist/composables/useUserVisibility.js +47 -1
- package/dist/composables/useWait.js +1 -1
- package/dist/composables/useWindowSize.js +1 -1
- package/dist/css/main.css +1 -1
- package/dist/directives/index.js +7 -7
- package/dist/directives/vClickOutside.js +4 -102
- package/dist/directives/vFullscreenImg.js +1 -1
- package/dist/directives/vLazyImg.js +2 -2
- package/dist/directives/vTooltip.js +93 -64
- package/dist/index.js +1 -114
- package/dist/plugins/dialog.js +3 -3
- package/dist/plugins/maz-ui.js +235 -195
- package/dist/plugins/toast.js +13 -14
- package/dist/resolvers/MazComponentsResolver.js +1 -1
- package/dist/resolvers/MazDirectivesResolver.js +1 -1
- package/dist/resolvers/MazModulesResolver.js +6 -2
- package/dist/tailwindcss/tailwind.config.js +5 -2
- package/dist/tailwindcss/variables/design-tokens.js +3 -0
- package/dist/types/components/MazAccordion.vue.d.ts +15 -2
- package/dist/types/components/MazBtn.vue.d.ts +1 -0
- package/dist/types/components/MazCard.vue.d.ts +1 -1
- package/dist/types/components/MazCarousel.vue.d.ts +4 -1
- package/dist/types/components/MazCheckbox.vue.d.ts +0 -6
- package/dist/types/components/MazChecklist.vue.d.ts +1 -1
- package/dist/types/components/MazDatePicker/utils.d.ts +5 -4
- package/dist/types/components/MazDatePicker.vue.d.ts +49 -53
- package/dist/types/components/MazDialogConfirm/useMazDialogConfirm.d.ts +47 -0
- package/dist/types/components/{MazDialogPromise.vue.d.ts → MazDialogConfirm.vue.d.ts} +43 -10
- package/dist/types/components/MazDropdown.vue.d.ts +12 -12
- package/dist/types/components/MazInput.vue.d.ts +7 -0
- package/dist/types/components/MazInputNumber.vue.d.ts +4 -4
- package/dist/types/components/MazInputPhoneNumber/PhoneInput.vue.d.ts +1 -1
- package/dist/types/components/MazInputPhoneNumber/useLibphonenumber.d.ts +3 -3
- package/dist/types/components/MazInputPhoneNumber/useMazInputPhoneNumber.d.ts +8 -2
- package/dist/types/components/MazInputPhoneNumber.vue.d.ts +45 -23
- package/dist/types/components/MazInputPrice.vue.d.ts +3 -3
- package/dist/types/components/MazInputTags.vue.d.ts +1 -1
- package/dist/types/components/MazLazyImg.vue.d.ts +8 -8
- package/dist/types/components/MazLink.vue.d.ts +11 -0
- package/dist/types/components/MazPopover.vue.d.ts +28 -20
- package/dist/types/components/MazRadioButtons.vue.d.ts +9 -9
- package/dist/types/components/MazReadingProgressBar.vue.d.ts +1 -1
- package/dist/types/components/MazSelect.vue.d.ts +11 -4
- package/dist/types/components/MazSelectCountry.vue.d.ts +15 -6
- package/dist/types/components/MazStepper.vue.d.ts +13 -2
- package/dist/types/components/MazTable.vue.d.ts +63 -2
- package/dist/types/components/index.d.ts +4 -4
- package/dist/types/components/types.d.ts +1 -0
- package/dist/types/composables/index.d.ts +2 -1
- package/dist/types/composables/useDisplayNames.d.ts +3 -8
- package/dist/types/composables/useDropzone.d.ts +3 -3
- package/dist/types/composables/useFormField.d.ts +16 -56
- package/dist/types/composables/useFormValidator/config.d.ts +2 -2
- package/dist/types/composables/useFormValidator/dom-events.d.ts +19 -0
- package/dist/types/composables/useFormValidator/state-management.d.ts +72 -0
- package/dist/types/composables/useFormValidator/types.d.ts +20 -32
- package/dist/types/composables/useFormValidator/validation.d.ts +37 -0
- package/dist/types/composables/useFormValidator.d.ts +16 -10
- package/dist/types/composables/useIdleTimeout.d.ts +1 -1
- package/dist/types/composables/useInjectStrict.d.ts +1 -1
- package/dist/types/composables/useSwipe.d.ts +1 -1
- package/dist/types/composables/useUserVisibility.d.ts +1 -1
- package/dist/types/directives/vClickOutside.d.ts +11 -18
- package/dist/types/directives/vFullscreenImg/MazFullscreenImg.vue.d.ts +2 -2
- package/dist/types/directives/vFullscreenImg/fullscreen-img.directive.d.ts +3 -5
- package/dist/types/directives/vFullscreenImg.d.ts +9 -4
- package/dist/types/directives/vLazyImg/lazy-img.directive.d.ts +3 -5
- package/dist/types/directives/vLazyImg.d.ts +11 -6
- package/dist/types/directives/vTooltip.d.ts +14 -14
- package/dist/types/directives/vZoomImg/zoom-img.directive.d.ts +2 -0
- package/dist/types/directives/vZoomImg.d.ts +9 -5
- package/dist/types/index.d.ts +1 -1
- package/dist/types/plugins/aos.d.ts +30 -4
- package/dist/types/plugins/dialog/DialogHandler.d.ts +2 -2
- package/dist/types/plugins/dialog.d.ts +2 -4
- package/dist/types/plugins/maz-ui.d.ts +2 -63
- package/dist/types/plugins/toast.d.ts +2 -4
- package/dist/types/plugins/wait.d.ts +2 -3
- package/dist/types/tailwindcss/tailwind.config.d.ts +5 -0
- package/dist/types/tailwindcss/variables/design-tokens.d.ts +3 -0
- package/package.json +38 -37
- package/dist/assets/MazAccordion.esK3rR4p.css +0 -1
- package/dist/assets/MazAnimatedText.BrOwWuqf.css +0 -1
- package/dist/assets/MazBackdrop.DNpnLh63.css +0 -1
- package/dist/assets/MazBtn.BnRxVlqS.css +0 -1
- package/dist/assets/MazCard.C6nDaeIC.css +0 -1
- package/dist/assets/MazCarousel.BaqN4hLP.css +0 -1
- package/dist/assets/MazCheckbox.C_qIngLy.css +0 -1
- package/dist/assets/MazChecklist.CWK_Gl-t.css +0 -1
- package/dist/assets/MazDatePicker.V5JwKPrQ.css +0 -1
- package/dist/assets/MazDropzone.DafxQwbq.css +0 -1
- package/dist/assets/MazInput.DW2KOJHY.css +0 -1
- package/dist/assets/MazInputCode.CG6EJBEk.css +0 -1
- package/dist/assets/MazInputPhoneNumber.vpA2mrZn.css +0 -1
- package/dist/assets/MazInputTags.B_s9J3sw.css +0 -1
- package/dist/assets/MazLazyImg.BNaVtpfX.css +0 -1
- package/dist/assets/MazLink.CCfbrUs0.css +0 -1
- package/dist/assets/MazPickerCalendar.CHpWIzhL.css +0 -1
- package/dist/assets/MazPickerCalendarMonth.zkrPVHDv.css +0 -1
- package/dist/assets/MazPickerMonthSwitcher.168v7Hs1.css +0 -1
- package/dist/assets/MazPopover.Bth9NWia.css +0 -1
- package/dist/assets/MazPullToRefresh.DABqbGtK.css +0 -1
- package/dist/assets/MazRadio.DKMFWwy_.css +0 -1
- package/dist/assets/MazRadioButtons.BA4rjgK9.css +0 -1
- package/dist/assets/MazReadingProgressBar.n1Is8_Y3.css +0 -1
- package/dist/assets/MazSelect.DZZpDg8z.css +0 -1
- package/dist/assets/MazSpinner.CP85N7RJ.css +0 -1
- package/dist/assets/MazStepper.DYMde9uq.css +0 -1
- package/dist/assets/MazSwitch.Z1ZMm7tx.css +0 -1
- package/dist/assets/MazTableRow.B78Bd4Kv.css +0 -1
- package/dist/assets/MazTextarea.Dz11mUeK.css +0 -1
- package/dist/chunks/TextareaAutogrow.C22LQx0k.js +0 -25
- package/dist/chunks/debounceCallback.B69vn57Q.js +0 -7
- package/dist/chunks/formatCurrency.C8NzW9Ii.js +0 -34
- package/dist/chunks/formatDate.DZ_OzdnV.js +0 -21
- package/dist/chunks/getCountryFlagUrl.dQjriBXx.js +0 -9
- package/dist/chunks/idleTimeout.-ICpdeGV.js +0 -111
- package/dist/chunks/isServer.BokzeB-Q.js +0 -6
- package/dist/chunks/isStandaloneMode.BpUpOTbA.js +0 -10
- package/dist/chunks/normalizeString.CFe2M8S_.js +0 -69
- package/dist/chunks/pascalCase.D_nuQ66I.js +0 -11
- package/dist/chunks/swipeHandler.8emelhOL.js +0 -80
- package/dist/chunks/throttle.DN8ARw0a.js +0 -11
- package/dist/chunks/throttleId.7PhWZjcS.js +0 -62
- package/dist/chunks/userVisibility.BbQSJASv.js +0 -50
- package/dist/chunks/x-mark.CTalOvvY.js +0 -23
- package/dist/components/MazDialogPromise.js +0 -6
- package/dist/types/components/MazDialogPromise/useMazDialogPromise.d.ts +0 -54
- package/dist/types/components/MazInputPhoneNumber/types.d.ts +0 -22
- package/dist/types/composables/useFormValidator/utils.d.ts +0 -116
- package/dist/chunks/{pristine.ylgbwjxO.js → pristine.CxBZzgUG.js} +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as isClient } from "../chunks/isClient.WI4oSt66.js";
|
|
2
2
|
import { ref, shallowRef, watch, toValue, onBeforeUnmount, unref } from "vue";
|
|
3
|
-
function
|
|
3
|
+
function useDropzone(target, options = {}) {
|
|
4
4
|
const isOverDropZone = ref(!1), isOverError = ref(!1), files = shallowRef(null);
|
|
5
5
|
let counter = 0, isValid = !0;
|
|
6
6
|
if (isClient()) {
|
|
@@ -16,7 +16,7 @@ function useDropZone(target, options = {}) {
|
|
|
16
16
|
const types = Array.from(items ?? []).map((item) => item.type), dataTypesValid = checkDataTypes(types), multipleFilesValid = multiple || items.length <= 1;
|
|
17
17
|
return dataTypesValid && multipleFilesValid;
|
|
18
18
|
}, isSafari = function() {
|
|
19
|
-
return /^(?:(?!chrome|android).)*safari/i.test(navigator.userAgent) && !("chrome" in
|
|
19
|
+
return /^(?:(?!chrome|android).)*safari/i.test(navigator.userAgent) && !("chrome" in globalThis);
|
|
20
20
|
}, handleDragEvent = function(event, eventType) {
|
|
21
21
|
const dataTransferItemList = event.dataTransfer?.items;
|
|
22
22
|
isValid = (dataTransferItemList && checkValidity(dataTransferItemList)) ?? !1, preventDefaultForUnhandled && event.preventDefault();
|
|
@@ -37,11 +37,11 @@ function useDropZone(target, options = {}) {
|
|
|
37
37
|
}
|
|
38
38
|
}, removeEventListeners = function() {
|
|
39
39
|
const targetElement = toValue(target);
|
|
40
|
-
targetElement && (targetElement.removeEventListener("dragenter",
|
|
40
|
+
targetElement && (targetElement.removeEventListener("dragenter", dragEnterHandler), targetElement.removeEventListener("dragover", dragOverHandler), targetElement.removeEventListener("dragleave", dragLeaveHandler), targetElement.removeEventListener("drop", dropHandler));
|
|
41
41
|
};
|
|
42
|
-
const _options = typeof options == "function" ? { onDrop: options } : options, multiple = _options.multiple ?? !0, preventDefaultForUnhandled = _options.preventDefaultForUnhandled ?? !1;
|
|
43
|
-
watch(() => toValue(target), (element) => {
|
|
44
|
-
|
|
42
|
+
const _options = typeof options == "function" ? { onDrop: options } : options, multiple = _options.multiple ?? !0, preventDefaultForUnhandled = _options.preventDefaultForUnhandled ?? !1, dragEnterHandler = (event) => handleDragEvent(event, "enter"), dragOverHandler = (event) => handleDragEvent(event, "over"), dragLeaveHandler = (event) => handleDragEvent(event, "leave"), dropHandler = (event) => handleDragEvent(event, "drop");
|
|
43
|
+
watch(() => toValue(target), (element, oldElement) => {
|
|
44
|
+
oldElement && (oldElement.removeEventListener("dragenter", dragEnterHandler), oldElement.removeEventListener("dragover", dragOverHandler), oldElement.removeEventListener("dragleave", dragLeaveHandler), oldElement.removeEventListener("drop", dropHandler)), element && (element.addEventListener("dragenter", dragEnterHandler), element.addEventListener("dragover", dragOverHandler), element.addEventListener("dragleave", dragLeaveHandler), element.addEventListener("drop", dropHandler));
|
|
45
45
|
}, { immediate: !0 }), onBeforeUnmount(() => {
|
|
46
46
|
removeEventListeners();
|
|
47
47
|
});
|
|
@@ -53,5 +53,5 @@ function useDropZone(target, options = {}) {
|
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
export {
|
|
56
|
-
|
|
56
|
+
useDropzone
|
|
57
57
|
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as isEqual } from "../chunks/throttleId.7PhWZjcS.js";
|
|
1
|
+
import { e as getContext, f as fieldHasValidation, i as updateFieldState, j as isEqual, k as setFieldValidationState, l as getValidationEvents, h as hasModeIncludes, r as removeEventFromInteractiveElements, m as findInteractiveElements, n as addEventToInteractiveElements, o as handleFieldBlur } from "../chunks/dom-events.Bbe7wDQl.js";
|
|
3
2
|
import { computed, onMounted, onUnmounted } from "vue";
|
|
4
|
-
import { e as getContext, f as fieldHasValidation, i as updateFieldState, j as setFieldValidationState, k as getValidationEvents, d as hasModeIncludes, r as removeEventFromInteractiveElements, l as handleFieldBlur, m as findInteractiveElements, n as addEventToInteractiveElements } from "../chunks/utils.BBuYjMbK.js";
|
|
5
3
|
import { useFreezeValue } from "./useFreezeValue.js";
|
|
6
4
|
function useFormField(name, options) {
|
|
7
5
|
const opts = {
|
|
@@ -14,17 +12,17 @@ function useFormField(name, options) {
|
|
|
14
12
|
internalSchema,
|
|
15
13
|
errorMessages,
|
|
16
14
|
isSubmitted
|
|
17
|
-
} = getContext(opts.formIdentifier, "useFormField"), fieldMode = fieldHasValidation(name, internalSchema.value) ? options?.mode ?? formOptions.mode : void 0;
|
|
18
|
-
|
|
15
|
+
} = getContext(opts.formIdentifier, "useFormField"), finalOpts = opts, fieldMode = fieldHasValidation(name, internalSchema.value) ? options?.mode ?? formOptions.mode : void 0;
|
|
16
|
+
finalOpts.mode = fieldMode;
|
|
19
17
|
const fieldState = computed(() => fieldsStates.value[name]);
|
|
20
18
|
if (fieldsStates.value[name] = updateFieldState({
|
|
21
19
|
name,
|
|
22
20
|
fieldState: fieldState.value,
|
|
23
21
|
payload: payload.value,
|
|
24
22
|
schema: internalSchema.value,
|
|
25
|
-
options: { ...formOptions, ...
|
|
26
|
-
}),
|
|
27
|
-
const initialValue =
|
|
23
|
+
options: { ...formOptions, ...finalOpts }
|
|
24
|
+
}), finalOpts.defaultValue !== void 0 && !isEqual(payload.value[name], finalOpts.defaultValue)) {
|
|
25
|
+
const initialValue = finalOpts.defaultValue;
|
|
28
26
|
payload.value[name] = initialValue, fieldsStates.value[name].initialValue = useFreezeValue(initialValue);
|
|
29
27
|
}
|
|
30
28
|
fieldMode && setFieldValidationState({
|
|
@@ -46,27 +44,26 @@ function useFormField(name, options) {
|
|
|
46
44
|
}
|
|
47
45
|
const validationEvents = computed(
|
|
48
46
|
() => getValidationEvents({
|
|
49
|
-
hasRef: !!
|
|
47
|
+
hasRef: !!finalOpts.ref?.value,
|
|
50
48
|
onBlur,
|
|
51
49
|
fieldState: fieldState.value
|
|
52
50
|
})
|
|
53
51
|
);
|
|
54
|
-
if (
|
|
52
|
+
if (finalOpts.ref && fieldMode && hasModeIncludes(["eager", "blur", "progressive"], fieldMode)) {
|
|
55
53
|
let interactiveElements = [];
|
|
56
54
|
const handleInteractiveElements = (element) => {
|
|
57
|
-
interactiveElements
|
|
55
|
+
interactiveElements.length > 0 && removeEventFromInteractiveElements({
|
|
56
|
+
interactiveElements,
|
|
57
|
+
onBlur
|
|
58
|
+
}), interactiveElements = findInteractiveElements(element), addEventToInteractiveElements({
|
|
58
59
|
interactiveElements,
|
|
59
60
|
onBlur,
|
|
60
61
|
mode: fieldMode
|
|
61
62
|
});
|
|
62
63
|
};
|
|
63
64
|
onMounted(() => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
interactiveElement && handleInteractiveElements(interactiveElement);
|
|
67
|
-
}, {
|
|
68
|
-
errorMessage: `[maz-ui](useFormField) No element found for ref ${opts.ref} for field ${name}`
|
|
69
|
-
});
|
|
65
|
+
const element = finalOpts.ref?.value, elementToBind = element instanceof HTMLElement ? element : element?.$el;
|
|
66
|
+
elementToBind instanceof HTMLElement ? handleInteractiveElements(elementToBind) : console.warn(`[maz-ui](useFormField) No element found for ref in field '${String(name)}'. Make sure the ref is properly bound to an HTMLElement or Vue component (form identifier: ${String(formOptions.identifier)})`);
|
|
70
67
|
}), onUnmounted(() => {
|
|
71
68
|
removeEventFromInteractiveElements({
|
|
72
69
|
interactiveElements,
|
|
@@ -88,8 +85,7 @@ function useFormField(name, options) {
|
|
|
88
85
|
get: () => payload.value[name],
|
|
89
86
|
set: (value) => payload.value[name] = value
|
|
90
87
|
}),
|
|
91
|
-
validationEvents
|
|
92
|
-
onBlur
|
|
88
|
+
validationEvents
|
|
93
89
|
};
|
|
94
90
|
}
|
|
95
91
|
export {
|
|
@@ -1,5 +1,20 @@
|
|
|
1
|
-
import { ref, computed, watch, provide, nextTick } from "vue";
|
|
2
|
-
import { g as getInstance, a as getFieldsStates, b as getFieldsErrors, c as getErrorMessages, u as updateFieldsStates, v as validateForm, C as CONFIG, s as scrollToError, h as
|
|
1
|
+
import { ref, toValue, computed, watch, provide, nextTick } from "vue";
|
|
2
|
+
import { g as getInstance, a as getFieldsStates, b as getFieldsErrors, c as getErrorMessages, u as updateFieldsStates, v as validateForm, C as CONFIG, s as scrollToError, h as hasModeIncludes, d as handleFieldInput } from "../chunks/dom-events.Bbe7wDQl.js";
|
|
3
|
+
function createValidationProcessor(fieldsToValidate, fieldsStates, payload, internalSchema, isSubmitted) {
|
|
4
|
+
return () => {
|
|
5
|
+
fieldsToValidate.forEach((name) => {
|
|
6
|
+
const fieldState = fieldsStates.value[name];
|
|
7
|
+
handleFieldInput({
|
|
8
|
+
name,
|
|
9
|
+
fieldState,
|
|
10
|
+
payload: payload.value,
|
|
11
|
+
schema: internalSchema.value,
|
|
12
|
+
isSubmitted: isSubmitted.value,
|
|
13
|
+
forceValidation: !0
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
}
|
|
3
18
|
function useFormValidator({ schema, defaultValues, model, options }) {
|
|
4
19
|
const instance = getInstance("useFormValidator"), opts = {
|
|
5
20
|
mode: CONFIG.mode,
|
|
@@ -8,13 +23,23 @@ function useFormValidator({ schema, defaultValues, model, options }) {
|
|
|
8
23
|
throttledFields: null,
|
|
9
24
|
identifier: "main-form-validator",
|
|
10
25
|
...options
|
|
11
|
-
}, internalDefaultValues = ref(defaultValues), payload = ref({ ...internalDefaultValues.value, ...model?.value }), internalSchema = ref(schema), fieldsStates = ref(
|
|
26
|
+
}, internalDefaultValues = ref(toValue(defaultValues)), payload = ref({ ...internalDefaultValues.value, ...model?.value }), internalSchema = ref(toValue(schema)), fieldsStates = ref(
|
|
12
27
|
getFieldsStates({
|
|
13
28
|
schema: internalSchema.value,
|
|
14
29
|
payload: payload.value,
|
|
15
30
|
options: opts
|
|
16
31
|
})
|
|
17
|
-
), isSubmitting = ref(!1), isSubmitted = ref(!1), isValid = computed(() =>
|
|
32
|
+
), isSubmitting = ref(!1), isSubmitted = ref(!1), isValid = computed(() => {
|
|
33
|
+
for (const key in fieldsStates.value)
|
|
34
|
+
if (!fieldsStates.value[key].valid)
|
|
35
|
+
return !1;
|
|
36
|
+
return !0;
|
|
37
|
+
}), isDirty = computed(() => {
|
|
38
|
+
for (const key in fieldsStates.value)
|
|
39
|
+
if (fieldsStates.value[key].dirty)
|
|
40
|
+
return !0;
|
|
41
|
+
return !1;
|
|
42
|
+
}), errors = computed(() => getFieldsErrors(fieldsStates.value)), errorMessages = computed(() => getErrorMessages(errors.value, fieldsStates.value));
|
|
18
43
|
model && watch(
|
|
19
44
|
payload,
|
|
20
45
|
(newModel) => {
|
|
@@ -39,39 +64,43 @@ function useFormValidator({ schema, defaultValues, model, options }) {
|
|
|
39
64
|
},
|
|
40
65
|
{ deep: !0 }
|
|
41
66
|
), internalValidateForm();
|
|
42
|
-
function internalValidateForm(
|
|
67
|
+
function internalValidateForm(setErrors = opts.mode === "aggressive") {
|
|
43
68
|
return validateForm({
|
|
44
69
|
fieldsStates: fieldsStates.value,
|
|
45
70
|
payload: payload.value,
|
|
46
71
|
schema: internalSchema.value,
|
|
47
|
-
|
|
72
|
+
setErrors
|
|
48
73
|
});
|
|
49
74
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
75
|
+
let payloadWatchStop = null;
|
|
76
|
+
function setupOptimizedWatch() {
|
|
77
|
+
payloadWatchStop && payloadWatchStop();
|
|
78
|
+
const payloadSnapshot = computed(() => {
|
|
79
|
+
const snapshot = {};
|
|
80
|
+
for (const key of Object.keys(internalSchema.value))
|
|
81
|
+
snapshot[key] = payload.value[key];
|
|
82
|
+
return snapshot;
|
|
83
|
+
});
|
|
84
|
+
payloadWatchStop = watch(
|
|
85
|
+
payloadSnapshot,
|
|
86
|
+
(newSnapshot, oldSnapshot) => {
|
|
87
|
+
const fieldsToValidate = Object.keys(internalSchema.value).filter((name) => {
|
|
88
|
+
const fieldState = fieldsStates.value[name];
|
|
89
|
+
return fieldState && newSnapshot[name] !== oldSnapshot?.[name] && hasModeIncludes(["aggressive", "lazy", "progressive"], fieldState.mode);
|
|
64
90
|
});
|
|
91
|
+
if (fieldsToValidate.length > 0) {
|
|
92
|
+
const processValidations = createValidationProcessor(
|
|
93
|
+
fieldsToValidate,
|
|
94
|
+
fieldsStates,
|
|
95
|
+
payload,
|
|
96
|
+
internalSchema,
|
|
97
|
+
isSubmitted
|
|
98
|
+
);
|
|
99
|
+
typeof requestIdleCallback < "u" ? requestIdleCallback(processValidations, { timeout: 100 }) : nextTick(processValidations);
|
|
100
|
+
}
|
|
65
101
|
},
|
|
66
|
-
{ deep:
|
|
102
|
+
{ deep: !0 }
|
|
67
103
|
);
|
|
68
|
-
watchedPayloadStopFunctions.push(watchStopFunc);
|
|
69
|
-
}
|
|
70
|
-
function addFieldsValidationWatch() {
|
|
71
|
-
for (const watchStopFunc of watchedPayloadStopFunctions)
|
|
72
|
-
watchStopFunc();
|
|
73
|
-
for (const name of Object.keys(internalSchema.value))
|
|
74
|
-
addFieldValidationWatch(name);
|
|
75
104
|
}
|
|
76
105
|
function handleSubmit(successCallback, enableScrollOrSelector) {
|
|
77
106
|
return async (event) => {
|
|
@@ -96,7 +125,7 @@ function useFormValidator({ schema, defaultValues, model, options }) {
|
|
|
96
125
|
errorMessages,
|
|
97
126
|
isSubmitted
|
|
98
127
|
};
|
|
99
|
-
return instance.formContexts ??= /* @__PURE__ */ new Map(), instance.formContexts.set(opts.identifier, context), provide(opts.identifier, context),
|
|
128
|
+
return instance.formContexts ??= /* @__PURE__ */ new Map(), instance.formContexts.set(opts.identifier, context), provide(opts.identifier, context), setupOptimizedWatch(), {
|
|
100
129
|
identifier: opts.identifier,
|
|
101
130
|
isDirty,
|
|
102
131
|
isSubmitting,
|
|
@@ -1,4 +1,111 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as isClient } from "../chunks/isClient.WI4oSt66.js";
|
|
2
|
+
class IdleTimeout {
|
|
3
|
+
constructor(callback, options) {
|
|
4
|
+
this.callback = callback, this.options = {
|
|
5
|
+
...this.defaultOptions,
|
|
6
|
+
...options
|
|
7
|
+
}, isClient() && this.start();
|
|
8
|
+
}
|
|
9
|
+
defaultOptions = {
|
|
10
|
+
element: void 0,
|
|
11
|
+
timeout: 60 * 1e3 * 5,
|
|
12
|
+
// 5 minutes
|
|
13
|
+
once: !1,
|
|
14
|
+
immediate: !0
|
|
15
|
+
};
|
|
16
|
+
options;
|
|
17
|
+
timeoutHandler;
|
|
18
|
+
isIdle = !1;
|
|
19
|
+
isDestroy = !1;
|
|
20
|
+
startTime = 0;
|
|
21
|
+
remainingTime = 0;
|
|
22
|
+
lastClientX = -1;
|
|
23
|
+
lastClientY = -1;
|
|
24
|
+
eventNames = [
|
|
25
|
+
"DOMMouseScroll",
|
|
26
|
+
"mousedown",
|
|
27
|
+
"mousemove",
|
|
28
|
+
"mousewheel",
|
|
29
|
+
"MSPointerDown",
|
|
30
|
+
"MSPointerMove",
|
|
31
|
+
"keydown",
|
|
32
|
+
"touchmove",
|
|
33
|
+
"touchstart",
|
|
34
|
+
"wheel",
|
|
35
|
+
"click"
|
|
36
|
+
];
|
|
37
|
+
get element() {
|
|
38
|
+
return this.options.element ?? document.body;
|
|
39
|
+
}
|
|
40
|
+
start() {
|
|
41
|
+
if (!isClient()) {
|
|
42
|
+
console.warn("[IdleTimeout](start) you should run this method on client side");
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
for (const eventName of this.eventNames)
|
|
46
|
+
this.element.addEventListener(eventName, this.handleEvent);
|
|
47
|
+
this.resetTimeout(), this.options.immediate && this.callback({ isIdle: !1, instance: this });
|
|
48
|
+
}
|
|
49
|
+
pause() {
|
|
50
|
+
const remainingTime = this.startTime + this.options.timeout - Date.now();
|
|
51
|
+
remainingTime <= 0 || (this.remainingTime = remainingTime, this.timeoutHandler && (clearTimeout(this.timeoutHandler), this.timeoutHandler = void 0));
|
|
52
|
+
}
|
|
53
|
+
resume() {
|
|
54
|
+
this.remainingTime <= 0 || (this.resetTimeout(), this.callback({ isIdle: this.isIdle, instance: this }), this.remainingTime = 0);
|
|
55
|
+
}
|
|
56
|
+
reset() {
|
|
57
|
+
this.isDestroy = !1, this.isIdle = !1, this.remainingTime = 0, this.resetTimeout(), this.callback({ isIdle: this.isIdle, instance: this });
|
|
58
|
+
}
|
|
59
|
+
destroy() {
|
|
60
|
+
if (!isClient()) {
|
|
61
|
+
console.warn("[IdleTimeout](destroy) you should run this method on client side");
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this.isDestroy = !0;
|
|
65
|
+
for (const eventName of this.eventNames)
|
|
66
|
+
this.element.removeEventListener(eventName, this.handleEvent);
|
|
67
|
+
this.timeoutHandler && clearTimeout(this.timeoutHandler);
|
|
68
|
+
}
|
|
69
|
+
resetTimeout() {
|
|
70
|
+
this.isIdle = !1, this.timeoutHandler && (clearTimeout(this.timeoutHandler), this.timeoutHandler = void 0), this.timeoutHandler = setTimeout(
|
|
71
|
+
this.handleTimeout.bind(this),
|
|
72
|
+
this.remainingTime || this.options.timeout
|
|
73
|
+
), this.startTime = Date.now();
|
|
74
|
+
}
|
|
75
|
+
handleEvent = (event) => {
|
|
76
|
+
try {
|
|
77
|
+
if (this.remainingTime > 0)
|
|
78
|
+
return;
|
|
79
|
+
if (event.type === "mousemove") {
|
|
80
|
+
const { clientX, clientY } = event;
|
|
81
|
+
if (clientX === void 0 && clientY === void 0 || clientX === this.lastClientX && clientY === this.lastClientY)
|
|
82
|
+
return;
|
|
83
|
+
this.lastClientX = clientX, this.lastClientY = clientY;
|
|
84
|
+
}
|
|
85
|
+
this.resetTimeout(), this.callback({ isIdle: this.isIdle, eventType: event.type, instance: this });
|
|
86
|
+
} catch (error) {
|
|
87
|
+
throw new Error(`[IdleTimeout](handleEvent) ${error}`);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
handleTimeout() {
|
|
91
|
+
this.isIdle = !0, this.callback({ isIdle: this.isIdle, instance: this }), this.options.once && this.destroy();
|
|
92
|
+
}
|
|
93
|
+
get destroyed() {
|
|
94
|
+
return this.isDestroy;
|
|
95
|
+
}
|
|
96
|
+
get timeout() {
|
|
97
|
+
return this.options.timeout;
|
|
98
|
+
}
|
|
99
|
+
set timeout(value) {
|
|
100
|
+
this.options.timeout = value;
|
|
101
|
+
}
|
|
102
|
+
get idle() {
|
|
103
|
+
return this.isIdle;
|
|
104
|
+
}
|
|
105
|
+
set idle(value) {
|
|
106
|
+
value ? this.handleTimeout() : this.reset(), this.callback({ isIdle: this.isIdle, instance: this });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
2
109
|
function useIdleTimeout({
|
|
3
110
|
callback,
|
|
4
111
|
options
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { inject } from "vue";
|
|
2
|
-
function useInjectStrict(key, fallback) {
|
|
2
|
+
function useInjectStrict(key, fallback, errorMessage) {
|
|
3
3
|
const resolved = inject(key, fallback);
|
|
4
4
|
if (!resolved)
|
|
5
|
-
throw new TypeError(`[maz-ui](injectStrict) Could not resolve ${key.toString()}`);
|
|
5
|
+
throw new TypeError(errorMessage || `[maz-ui](injectStrict) Could not resolve ${key.toString()}`);
|
|
6
6
|
return resolved;
|
|
7
7
|
}
|
|
8
8
|
export {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useId, computed } from "vue";
|
|
2
2
|
function useInstanceUniqId({
|
|
3
3
|
componentName,
|
|
4
4
|
providedId
|
|
5
5
|
}) {
|
|
6
|
-
|
|
6
|
+
const generatedId = useId();
|
|
7
|
+
return computed(() => providedId || `${componentName}-${generatedId.replace(/:/g, "")}`);
|
|
7
8
|
}
|
|
8
9
|
export {
|
|
9
10
|
useInstanceUniqId
|
|
@@ -1,42 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
function levenshteinDistance(string1, string2) {
|
|
4
|
-
const length1 = string1.length, length2 = string2.length, matrix = [];
|
|
5
|
-
for (let index = 0; index <= length1; index++)
|
|
6
|
-
matrix[index] = [index];
|
|
7
|
-
for (let index = 0; index <= length2; index++)
|
|
8
|
-
matrix[0][index] = index;
|
|
9
|
-
for (let index = 1; index <= length1; index++)
|
|
10
|
-
for (let index_ = 1; index_ <= length2; index_++) {
|
|
11
|
-
const cost = string1[index - 1] === string2[index_ - 1] ? 0 : 1;
|
|
12
|
-
matrix[index][index_] = Math.min(
|
|
13
|
-
matrix[index - 1][index_] + 1,
|
|
14
|
-
matrix[index][index_ - 1] + 1,
|
|
15
|
-
matrix[index - 1][index_ - 1] + cost
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
return matrix[length1][length2];
|
|
19
|
-
}
|
|
20
|
-
function getMatchingScore(string1, string2) {
|
|
21
|
-
const distance = levenshteinDistance(string1, string2), maxLength = Math.max(string1.length, string2.length);
|
|
22
|
-
return 1 - distance / maxLength;
|
|
23
|
-
}
|
|
24
|
-
function getMatchingResults(string1, string2, threshold = 0.75) {
|
|
25
|
-
return getMatchingScore(string1, string2) >= threshold;
|
|
26
|
-
}
|
|
27
|
-
function useStringMatching(string1, string2, threshold = 0.75) {
|
|
28
|
-
const _string1 = computed(
|
|
29
|
-
() => normalizeString(toValue(string1))
|
|
30
|
-
), _string2 = computed(
|
|
31
|
-
() => normalizeString(toValue(string2))
|
|
32
|
-
), _threshold = computed(() => toValue(threshold)), score = computed(() => getMatchingScore(_string1.value, _string2.value));
|
|
33
|
-
return {
|
|
34
|
-
isMatching: computed(
|
|
35
|
-
() => getMatchingResults(_string1.value, _string2.value, _threshold.value)
|
|
36
|
-
),
|
|
37
|
-
score
|
|
38
|
-
};
|
|
39
|
-
}
|
|
1
|
+
import { u } from "../chunks/useStringMatching.BBezu-6J.js";
|
|
2
|
+
import "vue";
|
|
40
3
|
export {
|
|
41
|
-
useStringMatching
|
|
4
|
+
u as useStringMatching
|
|
42
5
|
};
|
|
@@ -1,5 +1,81 @@
|
|
|
1
|
-
import { S as Swipe } from "../chunks/swipeHandler.8emelhOL.js";
|
|
2
1
|
import { ref, computed, toValue } from "vue";
|
|
2
|
+
const defaultOptions = {
|
|
3
|
+
preventDefaultOnTouchMove: !1,
|
|
4
|
+
preventDefaultOnMouseWheel: !1,
|
|
5
|
+
threshold: 50,
|
|
6
|
+
immediate: !1,
|
|
7
|
+
triggerOnEnd: !1
|
|
8
|
+
};
|
|
9
|
+
class Swipe {
|
|
10
|
+
constructor(inputOption) {
|
|
11
|
+
this.inputOption = inputOption, this.options = { ...defaultOptions, ...inputOption }, this.onToucheStartCallback = this.toucheStartHandler.bind(this), this.onToucheMoveCallback = this.handleTouchMove.bind(this), this.onToucheEndCallback = this.handleTouchEnd.bind(this), this.onMouseWheelCallback = this.handleMouseWheel.bind(this), this.start = this.startListening.bind(this), this.stop = this.stopListening.bind(this), this.options.element && this.setElement(this.options.element), this.options.immediate && this.start();
|
|
12
|
+
}
|
|
13
|
+
element;
|
|
14
|
+
xStart;
|
|
15
|
+
yStart;
|
|
16
|
+
xEnd;
|
|
17
|
+
yEnd;
|
|
18
|
+
xDiff;
|
|
19
|
+
yDiff;
|
|
20
|
+
onToucheStartCallback;
|
|
21
|
+
onToucheMoveCallback;
|
|
22
|
+
onToucheEndCallback;
|
|
23
|
+
onMouseWheelCallback;
|
|
24
|
+
start;
|
|
25
|
+
stop;
|
|
26
|
+
options;
|
|
27
|
+
startListening() {
|
|
28
|
+
this.setElement(this.options.element), this.element?.addEventListener("touchstart", this.onToucheStartCallback, { passive: !0 }), this.element?.addEventListener("touchmove", this.onToucheMoveCallback, { passive: !0 }), this.options.triggerOnEnd && this.element?.addEventListener("touchend", this.onToucheEndCallback, { passive: !0 }), this.options.preventDefaultOnMouseWheel && this.element?.addEventListener("mousewheel", this.onMouseWheelCallback, { passive: !1 });
|
|
29
|
+
}
|
|
30
|
+
stopListening() {
|
|
31
|
+
this.element?.removeEventListener("touchstart", this.onToucheStartCallback), this.element?.removeEventListener("touchmove", this.onToucheMoveCallback), this.element?.removeEventListener("touchend", this.onToucheEndCallback), this.options.preventDefaultOnMouseWheel && this.element?.removeEventListener("mousewheel", this.onMouseWheelCallback);
|
|
32
|
+
}
|
|
33
|
+
setElement(element) {
|
|
34
|
+
if (!element) {
|
|
35
|
+
console.error(
|
|
36
|
+
"[maz-ui][SwipeHandler](setElement) Element should be provided. Its can be a string selector or an HTMLElement"
|
|
37
|
+
);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (typeof element == "string") {
|
|
41
|
+
const foundElement = document.querySelector(element);
|
|
42
|
+
if (!(foundElement instanceof HTMLElement)) {
|
|
43
|
+
console.error("[maz-ui][SwipeHandler](setElement) String selector for element is not found");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
this.element = foundElement;
|
|
47
|
+
} else
|
|
48
|
+
this.element = element;
|
|
49
|
+
}
|
|
50
|
+
handleMouseWheel(event) {
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
}
|
|
53
|
+
toucheStartHandler(event) {
|
|
54
|
+
this.xStart = event.touches[0].clientX, this.yStart = event.touches[0].clientY, this.emitValuesChanged();
|
|
55
|
+
}
|
|
56
|
+
emitValuesChanged() {
|
|
57
|
+
this.options.onValuesChanged?.({
|
|
58
|
+
xStart: this.xStart,
|
|
59
|
+
yStart: this.yStart,
|
|
60
|
+
xEnd: this.xEnd,
|
|
61
|
+
yEnd: this.yEnd,
|
|
62
|
+
xDiff: this.xDiff,
|
|
63
|
+
yDiff: this.yDiff
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
handleTouchMove(event) {
|
|
67
|
+
this.options.preventDefaultOnTouchMove && event.cancelable && event.preventDefault(), this.xEnd = event.touches[0].clientX, this.yEnd = event.touches[0].clientY, !(!this.xStart || !this.yStart) && (this.xDiff = this.xStart - this.xEnd, this.yDiff = this.yStart - this.yEnd, this.emitValuesChanged(), this.options.triggerOnEnd || this.runCallbacks(event));
|
|
68
|
+
}
|
|
69
|
+
handleTouchEnd(event) {
|
|
70
|
+
this.runCallbacks(event), this.emitValuesChanged();
|
|
71
|
+
}
|
|
72
|
+
runCallbacks(event) {
|
|
73
|
+
typeof this.xDiff != "number" || typeof this.yDiff != "number" || Math.abs(this.xDiff) < this.options.threshold && Math.abs(this.yDiff) < this.options.threshold || (Math.abs(this.xDiff) > Math.abs(this.yDiff) ? this.xDiff > 0 ? this.options.onLeft?.(event) : this.options.onRight?.(event) : this.yDiff > 0 ? this.options.onUp?.(event) : this.options.onDown?.(event), this.resetValues());
|
|
74
|
+
}
|
|
75
|
+
resetValues() {
|
|
76
|
+
this.xStart = void 0, this.yStart = void 0, this.xEnd = void 0, this.yEnd = void 0, this.xDiff = void 0, this.yDiff = void 0, this.emitValuesChanged();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
3
79
|
function useSwipe(options) {
|
|
4
80
|
const xDiff = ref(), yDiff = ref(), xStart = ref(), xEnd = ref(), yStart = ref(), yEnd = ref(), element = computed(() => toValue(options.element)), swiper = new Swipe({
|
|
5
81
|
...options,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useInjectStrict } from "./useInjectStrict.js";
|
|
2
2
|
function useToast() {
|
|
3
|
-
const toast = useInjectStrict("mazToast");
|
|
3
|
+
const toast = useInjectStrict("mazToast", void 0, "[maz-ui](useToast) ToastPlugin is not installed");
|
|
4
4
|
return {
|
|
5
5
|
message: toast.message.bind(toast),
|
|
6
6
|
success: toast.success.bind(toast),
|
|
@@ -1,4 +1,50 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as isClient } from "../chunks/isClient.WI4oSt66.js";
|
|
2
|
+
class UserVisibility {
|
|
3
|
+
constructor(callback, options) {
|
|
4
|
+
this.callback = callback, this.options = {
|
|
5
|
+
...this.defaultOptions,
|
|
6
|
+
...options
|
|
7
|
+
}, this.eventHandlerFunction = this.eventHandler.bind(this), isClient() && this.start();
|
|
8
|
+
}
|
|
9
|
+
eventHandlerFunction;
|
|
10
|
+
event = "visibilitychange";
|
|
11
|
+
timeoutHandler;
|
|
12
|
+
options;
|
|
13
|
+
defaultOptions = {
|
|
14
|
+
timeout: 5e3,
|
|
15
|
+
once: !1,
|
|
16
|
+
immediate: !0
|
|
17
|
+
};
|
|
18
|
+
isVisible = !1;
|
|
19
|
+
start() {
|
|
20
|
+
if (!isClient()) {
|
|
21
|
+
console.warn("[UserVisibility](start) you should run this method on client side");
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
this.options.immediate && this.emitCallback(), this.addEventListener();
|
|
25
|
+
}
|
|
26
|
+
emitCallback() {
|
|
27
|
+
this.isVisible = document.visibilityState === "visible", this.callback({ isVisible: this.isVisible }), this.options.once && this.destroy();
|
|
28
|
+
}
|
|
29
|
+
eventHandler() {
|
|
30
|
+
document.visibilityState === "visible" && !this.isVisible ? (this.clearTimeout(), this.emitCallback()) : document.visibilityState === "hidden" && this.initTimeout();
|
|
31
|
+
}
|
|
32
|
+
clearTimeout() {
|
|
33
|
+
this.timeoutHandler && (clearTimeout(this.timeoutHandler), this.timeoutHandler = void 0);
|
|
34
|
+
}
|
|
35
|
+
initTimeout() {
|
|
36
|
+
this.clearTimeout(), this.timeoutHandler = setTimeout(this.emitCallback.bind(this), this.options.timeout);
|
|
37
|
+
}
|
|
38
|
+
addEventListener() {
|
|
39
|
+
document.addEventListener(this.event, this.eventHandlerFunction);
|
|
40
|
+
}
|
|
41
|
+
removeEventListener() {
|
|
42
|
+
document.removeEventListener(this.event, this.eventHandlerFunction);
|
|
43
|
+
}
|
|
44
|
+
destroy() {
|
|
45
|
+
this.removeEventListener(), this.timeoutHandler && clearTimeout(this.timeoutHandler);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
2
48
|
function useUserVisibility({
|
|
3
49
|
callback,
|
|
4
50
|
options
|
|
@@ -2,7 +2,7 @@ import { i as isClient } from "../chunks/isClient.WI4oSt66.js";
|
|
|
2
2
|
import { ref, onMounted, onUnmounted } from "vue";
|
|
3
3
|
function useWindowSize(options = {}) {
|
|
4
4
|
const {
|
|
5
|
-
internalWindow = isClient() ?
|
|
5
|
+
internalWindow = isClient() ? globalThis : void 0,
|
|
6
6
|
initialWidth = Number.POSITIVE_INFINITY,
|
|
7
7
|
initialHeight = Number.POSITIVE_INFINITY,
|
|
8
8
|
includeScrollbar = !0
|