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,34 +0,0 @@
|
|
|
1
|
-
import { defineComponent, provide, ref, watch, onUnmounted, renderSlot } from "vue";
|
|
2
|
-
import { setupTheme } from "@maz-ui/themes/utils/setup-theme";
|
|
3
|
-
import { createMazUiTranslations } from "@maz-ui/translations/utils/instance";
|
|
4
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
5
|
-
__name: "MazUiProvider",
|
|
6
|
-
props: {
|
|
7
|
-
theme: {},
|
|
8
|
-
translations: {}
|
|
9
|
-
},
|
|
10
|
-
setup(__props) {
|
|
11
|
-
const i18n = createMazUiTranslations(__props.translations);
|
|
12
|
-
provide("mazTranslations", i18n);
|
|
13
|
-
const providedThemeState = ref();
|
|
14
|
-
provide("mazThemeState", providedThemeState);
|
|
15
|
-
let themeCleanup, stopThemeSync;
|
|
16
|
-
function initTheme(options) {
|
|
17
|
-
themeCleanup?.(), stopThemeSync?.();
|
|
18
|
-
const { themeState, cleanup } = setupTheme(options);
|
|
19
|
-
providedThemeState.value = themeState.value, stopThemeSync = watch(themeState, (newState) => {
|
|
20
|
-
providedThemeState.value = { ...newState };
|
|
21
|
-
}, { deep: !0 }), themeCleanup = cleanup;
|
|
22
|
-
}
|
|
23
|
-
return initTheme(__props.theme), watch(() => __props.theme, (newThemeOptions) => {
|
|
24
|
-
initTheme(newThemeOptions);
|
|
25
|
-
}, { deep: !0 }), watch(() => __props.translations, (newTranslationsOptions) => {
|
|
26
|
-
newTranslationsOptions?.locale && i18n.setLocale(newTranslationsOptions.locale);
|
|
27
|
-
}, { deep: !0 }), onUnmounted(() => {
|
|
28
|
-
themeCleanup?.(), stopThemeSync?.();
|
|
29
|
-
}), (_ctx, _cache) => renderSlot(_ctx.$slots, "default");
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
export {
|
|
33
|
-
_sfc_main as _
|
|
34
|
-
};
|
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
import { isEqual } from "@maz-ui/utils/helpers/isEqual";
|
|
2
|
-
import { nextTick, getCurrentInstance, inject } from "vue";
|
|
3
|
-
import { useFreezeValue } from "../composables/useFreezeValue.js";
|
|
4
|
-
import { debounceId } from "@maz-ui/utils/helpers/debounceId";
|
|
5
|
-
import { throttleId } from "@maz-ui/utils/helpers/throttleId";
|
|
6
|
-
const CONFIG = {
|
|
7
|
-
mode: "lazy",
|
|
8
|
-
scrollToErrorSelector: ".has-field-error",
|
|
9
|
-
debounceTime: 300,
|
|
10
|
-
throttleTime: 1e3
|
|
11
|
-
};
|
|
12
|
-
function isEmptyValue(value) {
|
|
13
|
-
return value == null || value === "";
|
|
14
|
-
}
|
|
15
|
-
const storeValidbot = {};
|
|
16
|
-
async function getValibotValidationMethod(methodName) {
|
|
17
|
-
if (storeValidbot[methodName])
|
|
18
|
-
return storeValidbot[methodName];
|
|
19
|
-
const valibot = await import("valibot");
|
|
20
|
-
return storeValidbot[methodName] = valibot[methodName], valibot[methodName];
|
|
21
|
-
}
|
|
22
|
-
async function getValidationSchema(formSchema) {
|
|
23
|
-
return (await getValibotValidationMethod("objectAsync"))(formSchema);
|
|
24
|
-
}
|
|
25
|
-
async function getFieldValidationResult(name, schema, value) {
|
|
26
|
-
const fieldSchema = await getValidationSchema(schema), result = await (await getValibotValidationMethod("safeParseAsync"))(fieldSchema.entries[name], value ?? "");
|
|
27
|
-
return {
|
|
28
|
-
result,
|
|
29
|
-
isValid: result.success
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
async function setFieldValidationState({
|
|
33
|
-
name,
|
|
34
|
-
fieldState,
|
|
35
|
-
schema,
|
|
36
|
-
payload,
|
|
37
|
-
setError = !0,
|
|
38
|
-
setErrorIfInvalidAndNotEmpty = !1
|
|
39
|
-
}) {
|
|
40
|
-
if (await nextTick(), fieldState.validating)
|
|
41
|
-
return Promise.resolve();
|
|
42
|
-
fieldState.validating = !0;
|
|
43
|
-
try {
|
|
44
|
-
if (!schema[name]) {
|
|
45
|
-
fieldState.valid = !0, fieldState.validating = !1, fieldState.validated = !0, fieldState.errors = [], fieldState.error = !1;
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const { result, isValid } = await getFieldValidationResult(name, schema, payload[name]);
|
|
49
|
-
fieldState.valid = isValid;
|
|
50
|
-
const shouldSetError = setError || setErrorIfInvalidAndNotEmpty && !isValid && !isEmptyValue(payload[name]), shouldPreserveError = fieldState.blurred && !isValid && fieldState.mode && ["eager", "blur", "progressive"].includes(fieldState.mode);
|
|
51
|
-
(shouldSetError || shouldPreserveError) && (fieldState.error = !isValid), fieldState.errors = result.issues ?? [], fieldState.validated = !0;
|
|
52
|
-
} finally {
|
|
53
|
-
fieldState.validating = !1;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function validateForm({
|
|
57
|
-
fieldsStates,
|
|
58
|
-
payload,
|
|
59
|
-
setErrors = !0,
|
|
60
|
-
schema
|
|
61
|
-
}) {
|
|
62
|
-
return Promise.all(
|
|
63
|
-
Object.keys(fieldsStates).map(
|
|
64
|
-
(name) => setFieldValidationState({
|
|
65
|
-
name,
|
|
66
|
-
setError: setErrors,
|
|
67
|
-
fieldState: fieldsStates[name],
|
|
68
|
-
payload,
|
|
69
|
-
schema,
|
|
70
|
-
setErrorIfInvalidAndNotEmpty: fieldsStates[name].mode === "lazy"
|
|
71
|
-
})
|
|
72
|
-
)
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
function getErrorMessages(errors, fieldsStates) {
|
|
76
|
-
const errorMessages = {};
|
|
77
|
-
for (const [name, value] of Object.entries(errors)) {
|
|
78
|
-
const issues = value;
|
|
79
|
-
errorMessages[name] = fieldsStates[name].error && issues[0] ? issues[0].message : void 0;
|
|
80
|
-
}
|
|
81
|
-
return errorMessages;
|
|
82
|
-
}
|
|
83
|
-
function getFieldsErrors(fieldsStates) {
|
|
84
|
-
const fieldsErrors = {};
|
|
85
|
-
for (const [name, fieldState] of Object.entries(fieldsStates))
|
|
86
|
-
fieldsErrors[name] = fieldState.errors;
|
|
87
|
-
return fieldsErrors;
|
|
88
|
-
}
|
|
89
|
-
function getValidateFunction({
|
|
90
|
-
name,
|
|
91
|
-
hasValidation,
|
|
92
|
-
debouncedFields,
|
|
93
|
-
throttledFields
|
|
94
|
-
}) {
|
|
95
|
-
if (!hasValidation)
|
|
96
|
-
return;
|
|
97
|
-
const fieldName = String(name);
|
|
98
|
-
if (debouncedFields?.[fieldName] && throttledFields?.[fieldName])
|
|
99
|
-
throw new Error(`The field "${String(fieldName)}" cannot be both debounced and throttled`);
|
|
100
|
-
return debouncedFields?.[fieldName] ? debounceId(
|
|
101
|
-
String(fieldName),
|
|
102
|
-
setFieldValidationState,
|
|
103
|
-
typeof debouncedFields[fieldName] == "number" ? debouncedFields[fieldName] : CONFIG.debounceTime
|
|
104
|
-
) : throttledFields?.[fieldName] ? throttleId(
|
|
105
|
-
String(fieldName),
|
|
106
|
-
setFieldValidationState,
|
|
107
|
-
typeof throttledFields[fieldName] == "number" ? throttledFields[fieldName] : CONFIG.throttleTime
|
|
108
|
-
) : setFieldValidationState;
|
|
109
|
-
}
|
|
110
|
-
function getFieldState({
|
|
111
|
-
name,
|
|
112
|
-
schema,
|
|
113
|
-
initialValue,
|
|
114
|
-
fieldState,
|
|
115
|
-
options
|
|
116
|
-
}) {
|
|
117
|
-
const hasValidation = schema ? fieldHasValidation(name, schema) : !1, validateFunction = getValidateFunction({
|
|
118
|
-
name,
|
|
119
|
-
hasValidation,
|
|
120
|
-
debouncedFields: options?.debouncedFields,
|
|
121
|
-
throttledFields: options?.throttledFields
|
|
122
|
-
});
|
|
123
|
-
return {
|
|
124
|
-
blurred: !1,
|
|
125
|
-
dirty: !1,
|
|
126
|
-
errors: [],
|
|
127
|
-
error: !1,
|
|
128
|
-
valid: !hasValidation,
|
|
129
|
-
validating: !1,
|
|
130
|
-
validated: !1,
|
|
131
|
-
initialValue: useFreezeValue(initialValue),
|
|
132
|
-
validateFunction,
|
|
133
|
-
mode: hasValidation ? options?.mode ?? fieldState?.mode ?? CONFIG.mode : void 0
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
function fieldHasValidation(field, schema) {
|
|
137
|
-
return Object.keys(schema).includes(field);
|
|
138
|
-
}
|
|
139
|
-
function getFieldsStates({
|
|
140
|
-
schema,
|
|
141
|
-
payload,
|
|
142
|
-
options
|
|
143
|
-
}) {
|
|
144
|
-
const fieldsStates = {};
|
|
145
|
-
for (const fieldName in schema) {
|
|
146
|
-
const name = fieldName;
|
|
147
|
-
fieldsStates[name] = getFieldState({
|
|
148
|
-
name,
|
|
149
|
-
schema,
|
|
150
|
-
options,
|
|
151
|
-
fieldState: fieldsStates[name],
|
|
152
|
-
initialValue: payload?.[name]
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
return fieldsStates;
|
|
156
|
-
}
|
|
157
|
-
function updateFieldsStates({
|
|
158
|
-
fieldsStates,
|
|
159
|
-
payload,
|
|
160
|
-
schema,
|
|
161
|
-
options,
|
|
162
|
-
updateMode = !1
|
|
163
|
-
}) {
|
|
164
|
-
for (const fieldName in schema) {
|
|
165
|
-
const name = fieldName;
|
|
166
|
-
fieldsStates[name] = updateFieldState({
|
|
167
|
-
name,
|
|
168
|
-
fieldState: fieldsStates[name],
|
|
169
|
-
payload,
|
|
170
|
-
schema,
|
|
171
|
-
options,
|
|
172
|
-
updateMode
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
function updateFieldState({
|
|
177
|
-
name,
|
|
178
|
-
fieldState,
|
|
179
|
-
payload,
|
|
180
|
-
schema,
|
|
181
|
-
options,
|
|
182
|
-
updateMode = !0
|
|
183
|
-
}) {
|
|
184
|
-
const { initialValue, mode, ...rest } = getFieldState({
|
|
185
|
-
name,
|
|
186
|
-
schema,
|
|
187
|
-
initialValue: options.defaultValue ?? payload[name],
|
|
188
|
-
fieldState,
|
|
189
|
-
options
|
|
190
|
-
}), newMode = updateMode ? mode ?? fieldState.mode ?? CONFIG.mode : fieldState.mode;
|
|
191
|
-
return {
|
|
192
|
-
...fieldState,
|
|
193
|
-
initialValue,
|
|
194
|
-
mode: newMode,
|
|
195
|
-
...fieldState?.mode && newMode !== fieldState.mode ? rest : {}
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
function canExecuteValidation({
|
|
199
|
-
eventName,
|
|
200
|
-
fieldState,
|
|
201
|
-
isSubmitted
|
|
202
|
-
}) {
|
|
203
|
-
const { dirty, blurred, mode, valid } = fieldState;
|
|
204
|
-
return eventName === "blur" && (hasModeIncludes(["lazy", "aggressive"], mode) || valid) || eventName === "input" && mode === "blur" || !mode ? !1 : isSubmitted || mode === "eager" && blurred || mode === "blur" && blurred || mode === "aggressive" && dirty || mode === "lazy" && dirty || mode === "progressive";
|
|
205
|
-
}
|
|
206
|
-
function handleFieldBlur({
|
|
207
|
-
name,
|
|
208
|
-
force = !1,
|
|
209
|
-
payload,
|
|
210
|
-
fieldState,
|
|
211
|
-
schema,
|
|
212
|
-
isSubmitted
|
|
213
|
-
}) {
|
|
214
|
-
const fieldValue = payload[name], isDirty = !isEqual(fieldValue, fieldState.initialValue);
|
|
215
|
-
if (fieldState.dirty = isDirty, fieldState.blurred = fieldState.blurred || (fieldState.mode === "eager" ? isDirty : !0), !!(force || canExecuteValidation({ eventName: "blur", fieldState, isSubmitted })))
|
|
216
|
-
return fieldState.validateFunction?.({
|
|
217
|
-
name,
|
|
218
|
-
fieldState,
|
|
219
|
-
schema,
|
|
220
|
-
payload,
|
|
221
|
-
setError: fieldState.mode === "progressive" ? fieldState.validated || fieldState.blurred : !0
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
function handleFieldInput({
|
|
225
|
-
name,
|
|
226
|
-
payload,
|
|
227
|
-
fieldState,
|
|
228
|
-
schema,
|
|
229
|
-
isSubmitted,
|
|
230
|
-
forceValidation = !1
|
|
231
|
-
}) {
|
|
232
|
-
const fieldValue = payload[name];
|
|
233
|
-
fieldState.validated = !1;
|
|
234
|
-
const isDirty = !isEqual(fieldValue, fieldState.initialValue);
|
|
235
|
-
if (fieldState.dirty = isDirty, !!(forceValidation || canExecuteValidation({ eventName: "input", fieldState, isSubmitted })))
|
|
236
|
-
return fieldState.validateFunction?.({
|
|
237
|
-
name,
|
|
238
|
-
fieldState,
|
|
239
|
-
schema,
|
|
240
|
-
payload,
|
|
241
|
-
setError: fieldState.mode === "progressive" ? fieldState.validated || fieldState.blurred : !0
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
function hasModeIncludes(modes, value) {
|
|
245
|
-
return value ? modes.includes(value) : !1;
|
|
246
|
-
}
|
|
247
|
-
function getInstance(composableName) {
|
|
248
|
-
const instance = getCurrentInstance();
|
|
249
|
-
if (!instance)
|
|
250
|
-
throw new Error(`${composableName} must be called within setup()`);
|
|
251
|
-
return instance;
|
|
252
|
-
}
|
|
253
|
-
function getContext(identifier, composableName) {
|
|
254
|
-
const context = getInstance(composableName).formContexts?.get(identifier) ?? inject(identifier);
|
|
255
|
-
if (!context)
|
|
256
|
-
throw new Error("useFormField must be used within a form (useFormValidator)");
|
|
257
|
-
return context;
|
|
258
|
-
}
|
|
259
|
-
function scrollToError(selector = CONFIG.scrollToErrorSelector) {
|
|
260
|
-
const element = document.querySelector(selector);
|
|
261
|
-
element && element.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
262
|
-
}
|
|
263
|
-
function findInteractiveElements(el) {
|
|
264
|
-
if (isInteractiveElement(el))
|
|
265
|
-
return [el];
|
|
266
|
-
const selector = [
|
|
267
|
-
// Standard form elements
|
|
268
|
-
"input",
|
|
269
|
-
"select",
|
|
270
|
-
"textarea",
|
|
271
|
-
"button",
|
|
272
|
-
// Focusable elements
|
|
273
|
-
"a[href]",
|
|
274
|
-
'[tabindex]:not([tabindex="-1"])',
|
|
275
|
-
// Elements with interactive ARIA roles
|
|
276
|
-
'[role="button"]',
|
|
277
|
-
'[role="textbox"]',
|
|
278
|
-
'[role="combobox"]',
|
|
279
|
-
'[role="listbox"]',
|
|
280
|
-
'[role="slider"]',
|
|
281
|
-
'[role="spinbutton"]',
|
|
282
|
-
'[role="switch"]',
|
|
283
|
-
'[role="checkbox"]',
|
|
284
|
-
'[role="radio"]',
|
|
285
|
-
'[role="menuitem"]',
|
|
286
|
-
'[role="option"]',
|
|
287
|
-
// Contenteditable elements
|
|
288
|
-
'[contenteditable="true"]',
|
|
289
|
-
// Custom interactive elements (common patterns)
|
|
290
|
-
"[data-interactive]",
|
|
291
|
-
".interactive",
|
|
292
|
-
"[data-clickable]"
|
|
293
|
-
].join(", ");
|
|
294
|
-
return [...el.querySelectorAll(selector)].filter(isInteractiveElement);
|
|
295
|
-
}
|
|
296
|
-
function isInteractiveElement(el) {
|
|
297
|
-
if (el.getAttribute("tabindex") === "-1")
|
|
298
|
-
return !1;
|
|
299
|
-
if (el instanceof HTMLInputElement || el instanceof HTMLSelectElement || el instanceof HTMLTextAreaElement || el instanceof HTMLButtonElement || el instanceof HTMLAnchorElement && el.href || el.hasAttribute("tabindex") && el.getAttribute("tabindex") !== "-1")
|
|
300
|
-
return !0;
|
|
301
|
-
const interactiveRoles = [
|
|
302
|
-
"button",
|
|
303
|
-
"textbox",
|
|
304
|
-
"combobox",
|
|
305
|
-
"listbox",
|
|
306
|
-
"slider",
|
|
307
|
-
"spinbutton",
|
|
308
|
-
"switch",
|
|
309
|
-
"checkbox",
|
|
310
|
-
"radio",
|
|
311
|
-
"menuitem",
|
|
312
|
-
"option"
|
|
313
|
-
], role = el.getAttribute("role");
|
|
314
|
-
return role && interactiveRoles.includes(role) || el.getAttribute("contenteditable") === "true" ? !0 : el.hasAttribute("data-interactive") || el.hasAttribute("data-clickable") || el.classList.contains("interactive");
|
|
315
|
-
}
|
|
316
|
-
const activeListeners = /* @__PURE__ */ new WeakMap();
|
|
317
|
-
function addEventToInteractiveElements({
|
|
318
|
-
interactiveElements,
|
|
319
|
-
onBlur,
|
|
320
|
-
mode
|
|
321
|
-
}) {
|
|
322
|
-
interactiveElements.forEach((element) => {
|
|
323
|
-
if (hasModeIncludes(["eager", "blur", "progressive"], mode)) {
|
|
324
|
-
const existingListeners = activeListeners.get(element);
|
|
325
|
-
existingListeners?.has("blur") && element.removeEventListener("blur", existingListeners.get("blur")), element.addEventListener("blur", onBlur), activeListeners.has(element) || activeListeners.set(element, /* @__PURE__ */ new Map()), activeListeners.get(element).set("blur", onBlur);
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
function removeEventFromInteractiveElements({
|
|
330
|
-
interactiveElements,
|
|
331
|
-
onBlur
|
|
332
|
-
}) {
|
|
333
|
-
interactiveElements.forEach((element) => {
|
|
334
|
-
const existingListeners = activeListeners.get(element);
|
|
335
|
-
existingListeners?.has("blur") && (element.removeEventListener("blur", onBlur), existingListeners.delete("blur"), existingListeners.size === 0 && activeListeners.delete(element));
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
function getValidationEvents({
|
|
339
|
-
hasRef,
|
|
340
|
-
fieldState,
|
|
341
|
-
onBlur
|
|
342
|
-
}) {
|
|
343
|
-
if (!(hasRef || hasModeIncludes(["aggressive", "lazy"], fieldState.mode)))
|
|
344
|
-
return {
|
|
345
|
-
onBlur
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
export {
|
|
349
|
-
CONFIG as C,
|
|
350
|
-
getFieldsStates as a,
|
|
351
|
-
getFieldsErrors as b,
|
|
352
|
-
getErrorMessages as c,
|
|
353
|
-
handleFieldInput as d,
|
|
354
|
-
getContext as e,
|
|
355
|
-
fieldHasValidation as f,
|
|
356
|
-
getInstance as g,
|
|
357
|
-
hasModeIncludes as h,
|
|
358
|
-
updateFieldState as i,
|
|
359
|
-
setFieldValidationState as j,
|
|
360
|
-
getValidationEvents as k,
|
|
361
|
-
findInteractiveElements as l,
|
|
362
|
-
addEventToInteractiveElements as m,
|
|
363
|
-
handleFieldBlur as n,
|
|
364
|
-
removeEventFromInteractiveElements as r,
|
|
365
|
-
scrollToError as s,
|
|
366
|
-
updateFieldsStates as u,
|
|
367
|
-
validateForm as v
|
|
368
|
-
};
|