maz-ui 4.3.4-beta.3 → 4.3.4-beta.5
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/assets/{MazAnimatedCounter.LK7oyUrl.css → MazAnimatedCounter.DL7KsXq5.css} +1 -1
- package/dist/components/MazAnimatedCounter.js +10 -14
- package/dist/components/MazAnimatedCounter.vue.d.ts +1 -7
- package/dist/composables/useFormValidator/types.d.ts +5 -0
- package/dist/composables/useFormValidator.d.ts +4 -1
- package/dist/composables/useFormValidator.js +14 -2
- package/dist/types/components/MazAnimatedCounter.vue.d.ts +1 -7
- package/dist/types/composables/useFormValidator/types.d.ts +5 -0
- package/dist/types/composables/useFormValidator.d.ts +4 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
.m-animated-counter[data-v-
|
|
1
|
+
.m-animated-counter[data-v-e21d5b70]{white-space:nowrap;--maz-tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--maz-tw-ordinal)var(--maz-tw-slashed-zero)var(--maz-tw-numeric-figure)var(--maz-tw-numeric-spacing)var(--maz-tw-numeric-fraction)}
|
|
@@ -1,28 +1,24 @@
|
|
|
1
1
|
import { defineComponent, ref, onMounted, onBeforeUnmount, watch, createElementBlock, openBlock, createElementVNode, renderSlot, createTextVNode, toDisplayString } from "vue";
|
|
2
2
|
import { i as isClient } from "../chunks/isClient.WI4oSt66.js";
|
|
3
3
|
import { _ as _export_sfc } from "../chunks/_plugin-vue_export-helper.B--vMWp3.js";
|
|
4
|
-
import '../assets/MazAnimatedCounter.
|
|
4
|
+
import '../assets/MazAnimatedCounter.DL7KsXq5.css';const _hoisted_1 = { class: "maz-sr-only" }, _sfc_main = /* @__PURE__ */ defineComponent({
|
|
5
5
|
__name: "MazAnimatedCounter",
|
|
6
6
|
props: {
|
|
7
7
|
count: {},
|
|
8
8
|
duration: { default: 1e3 },
|
|
9
|
-
prefix: {
|
|
10
|
-
suffix: {
|
|
9
|
+
prefix: {},
|
|
10
|
+
suffix: {},
|
|
11
11
|
delay: { default: 100 },
|
|
12
12
|
once: { type: Boolean, default: !0 }
|
|
13
13
|
},
|
|
14
14
|
setup(__props) {
|
|
15
|
-
const
|
|
15
|
+
const currentCount = ref(0), elementRef = ref(null);
|
|
16
16
|
function getRequestAnimationFrame() {
|
|
17
17
|
return !isClient() || !globalThis.requestAnimationFrame ? (callback) => (setTimeout(callback, 1e3 / 60), 0) : globalThis.requestAnimationFrame.bind(globalThis);
|
|
18
18
|
}
|
|
19
19
|
function animate(start, end, duration, delay) {
|
|
20
20
|
const requestAnim = getRequestAnimationFrame();
|
|
21
|
-
|
|
22
|
-
currentCount.value = end;
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
currentCount.value = start, setTimeout(() => {
|
|
21
|
+
currentCount.value = start, isClient() && setTimeout(() => {
|
|
26
22
|
const startTime = performance.now(), updateCount = (currentTime = performance.now()) => {
|
|
27
23
|
const elapsed = currentTime - startTime, progress = Math.min(elapsed / duration, 1), easeOutQuad = (t) => t * (2 - t);
|
|
28
24
|
currentCount.value = Math.round(
|
|
@@ -33,15 +29,15 @@ import '../assets/MazAnimatedCounter.LK7oyUrl.css';const _hoisted_1 = { class: "
|
|
|
33
29
|
}, delay);
|
|
34
30
|
}
|
|
35
31
|
function startAnimation(start, end) {
|
|
36
|
-
animate(start, end,
|
|
32
|
+
animate(start, end, __props.duration, __props.delay);
|
|
37
33
|
}
|
|
38
34
|
let observer = null;
|
|
39
35
|
return onMounted(() => {
|
|
40
|
-
|
|
41
|
-
entry.isIntersecting && (startAnimation(0,
|
|
36
|
+
__props.once || (observer = new IntersectionObserver(([entry]) => {
|
|
37
|
+
entry.isIntersecting && (startAnimation(0, __props.count), __props.once && observer?.unobserve(entry.target));
|
|
42
38
|
}), elementRef.value && observer.observe(elementRef.value));
|
|
43
39
|
}), onBeforeUnmount(() => observer?.disconnect()), watch(
|
|
44
|
-
() =>
|
|
40
|
+
() => __props.count,
|
|
45
41
|
(newCount, oldCount) => {
|
|
46
42
|
if (newCount === oldCount)
|
|
47
43
|
return;
|
|
@@ -71,7 +67,7 @@ import '../assets/MazAnimatedCounter.LK7oyUrl.css';const _hoisted_1 = { class: "
|
|
|
71
67
|
], !0)
|
|
72
68
|
], 512));
|
|
73
69
|
}
|
|
74
|
-
}), MazAnimatedCounter = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
70
|
+
}), MazAnimatedCounter = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-e21d5b70"]]);
|
|
75
71
|
export {
|
|
76
72
|
MazAnimatedCounter as default
|
|
77
73
|
};
|
|
@@ -41,13 +41,7 @@ declare function __VLS_template(): {
|
|
|
41
41
|
rootEl: HTMLSpanElement;
|
|
42
42
|
};
|
|
43
43
|
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
44
|
-
declare const __VLS_component: import('vue').DefineComponent<MazAnimatedCounterProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<MazAnimatedCounterProps> & Readonly<{}>, {
|
|
45
|
-
duration: number;
|
|
46
|
-
delay: number;
|
|
47
|
-
once: boolean;
|
|
48
|
-
prefix: string;
|
|
49
|
-
suffix: string;
|
|
50
|
-
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
44
|
+
declare const __VLS_component: import('vue').DefineComponent<MazAnimatedCounterProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<MazAnimatedCounterProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
51
45
|
elementRef: HTMLSpanElement;
|
|
52
46
|
}, HTMLSpanElement>;
|
|
53
47
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
@@ -47,6 +47,11 @@ export interface FormValidatorOptions<Model extends BaseFormPayload = BaseFormPa
|
|
|
47
47
|
* @default `main-form-validator`
|
|
48
48
|
*/
|
|
49
49
|
identifier?: string | symbol;
|
|
50
|
+
/**
|
|
51
|
+
* Reset the form on submit success - you must use handleSubmit to handle the form submission
|
|
52
|
+
* @default true
|
|
53
|
+
*/
|
|
54
|
+
resetOnSuccess?: boolean;
|
|
50
55
|
}
|
|
51
56
|
export type StrictOptions<Model extends BaseFormPayload, ModelKey extends ExtractModelKey<FormSchema<Model>>> = Required<FormValidatorOptions<Model, ModelKey>>;
|
|
52
57
|
export interface FormContext<Model extends BaseFormPayload, ModelKey extends ExtractModelKey<FormSchema<Model>>> {
|
|
@@ -18,6 +18,9 @@ export declare function useFormValidator<TSchema extends MaybeRefOrGetter<FormSc
|
|
|
18
18
|
fieldsStates: Ref<FieldsStates<InferSchemaFormValidator<TSchema>, ExtractModelKey<FormSchema<InferSchemaFormValidator<TSchema>>>>, FieldsStates<InferSchemaFormValidator<TSchema>, ExtractModelKey<FormSchema<InferSchemaFormValidator<TSchema>>>>>;
|
|
19
19
|
validateForm: (setErrors?: boolean) => Promise<void[]>;
|
|
20
20
|
scrollToError: typeof scrollToError;
|
|
21
|
-
|
|
21
|
+
resetForm: () => void;
|
|
22
|
+
handleSubmit: <Func extends (model: InferOutputSchemaFormValidator<TSchema>) => Promise<Awaited<ReturnType<Func>>> | ReturnType<Func>>(successCallback: Func, enableScrollOrSelector?: FormValidatorOptions["scrollToError"], options?: {
|
|
23
|
+
resetOnSuccess?: boolean;
|
|
24
|
+
}) => (event?: Event) => Promise<ReturnType<Func> | undefined>;
|
|
22
25
|
errorMessages: import('vue').ComputedRef<Record<ExtractModelKey<FormSchema<InferSchemaFormValidator<TSchema>>>, string | undefined>>;
|
|
23
26
|
};
|
|
@@ -22,6 +22,7 @@ function useFormValidator({ schema, defaultValues, model, options }) {
|
|
|
22
22
|
debouncedFields: null,
|
|
23
23
|
throttledFields: null,
|
|
24
24
|
identifier: "main-form-validator",
|
|
25
|
+
resetOnSuccess: !0,
|
|
25
26
|
...options
|
|
26
27
|
}, internalDefaultValues = ref(toValue(defaultValues)), payload = ref({ ...internalDefaultValues.value, ...model?.value }), internalSchema = ref(toValue(schema)), fieldsStates = ref(
|
|
27
28
|
getFieldsStates({
|
|
@@ -102,7 +103,17 @@ function useFormValidator({ schema, defaultValues, model, options }) {
|
|
|
102
103
|
{ deep: !0 }
|
|
103
104
|
);
|
|
104
105
|
}
|
|
105
|
-
function
|
|
106
|
+
function resetForm() {
|
|
107
|
+
payloadWatchStop && payloadWatchStop(), isSubmitting.value = !1, isSubmitted.value = !1, payload.value = { ...internalDefaultValues.value }, fieldsStates.value = getFieldsStates({
|
|
108
|
+
schema: internalSchema.value,
|
|
109
|
+
payload: payload.value,
|
|
110
|
+
options: opts
|
|
111
|
+
}), internalValidateForm(!1), setupOptimizedWatch();
|
|
112
|
+
}
|
|
113
|
+
function handleSubmit(successCallback, enableScrollOrSelector, options2) {
|
|
114
|
+
const finalOptions = {
|
|
115
|
+
resetOnSuccess: options2?.resetOnSuccess ?? opts.resetOnSuccess
|
|
116
|
+
};
|
|
106
117
|
return async (event) => {
|
|
107
118
|
if (event?.preventDefault(), !isSubmitting.value) {
|
|
108
119
|
isSubmitted.value = !0, isSubmitting.value = !0;
|
|
@@ -110,7 +121,7 @@ function useFormValidator({ schema, defaultValues, model, options }) {
|
|
|
110
121
|
await internalValidateForm(!0);
|
|
111
122
|
const scrollToErrorParam = typeof enableScrollOrSelector == "string" ? enableScrollOrSelector : opts.scrollToError;
|
|
112
123
|
let response;
|
|
113
|
-
return isValid.value ? response = await successCallback(payload.value) : typeof scrollToErrorParam != "boolean" && scrollToError(scrollToErrorParam), isSubmitting.value = !1, response;
|
|
124
|
+
return isValid.value ? (response = await successCallback(payload.value), (finalOptions.resetOnSuccess || options2?.resetOnSuccess) && resetForm()) : typeof scrollToErrorParam != "boolean" && scrollToError(scrollToErrorParam), isSubmitting.value = !1, response;
|
|
114
125
|
} finally {
|
|
115
126
|
isSubmitting.value = !1;
|
|
116
127
|
}
|
|
@@ -136,6 +147,7 @@ function useFormValidator({ schema, defaultValues, model, options }) {
|
|
|
136
147
|
fieldsStates,
|
|
137
148
|
validateForm: internalValidateForm,
|
|
138
149
|
scrollToError,
|
|
150
|
+
resetForm,
|
|
139
151
|
handleSubmit,
|
|
140
152
|
errorMessages
|
|
141
153
|
};
|
|
@@ -41,13 +41,7 @@ declare function __VLS_template(): {
|
|
|
41
41
|
rootEl: HTMLSpanElement;
|
|
42
42
|
};
|
|
43
43
|
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
44
|
-
declare const __VLS_component: import('vue').DefineComponent<MazAnimatedCounterProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<MazAnimatedCounterProps> & Readonly<{}>, {
|
|
45
|
-
duration: number;
|
|
46
|
-
delay: number;
|
|
47
|
-
once: boolean;
|
|
48
|
-
prefix: string;
|
|
49
|
-
suffix: string;
|
|
50
|
-
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
44
|
+
declare const __VLS_component: import('vue').DefineComponent<MazAnimatedCounterProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<MazAnimatedCounterProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
51
45
|
elementRef: HTMLSpanElement;
|
|
52
46
|
}, HTMLSpanElement>;
|
|
53
47
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
@@ -47,6 +47,11 @@ export interface FormValidatorOptions<Model extends BaseFormPayload = BaseFormPa
|
|
|
47
47
|
* @default `main-form-validator`
|
|
48
48
|
*/
|
|
49
49
|
identifier?: string | symbol;
|
|
50
|
+
/**
|
|
51
|
+
* Reset the form on submit success - you must use handleSubmit to handle the form submission
|
|
52
|
+
* @default true
|
|
53
|
+
*/
|
|
54
|
+
resetOnSuccess?: boolean;
|
|
50
55
|
}
|
|
51
56
|
export type StrictOptions<Model extends BaseFormPayload, ModelKey extends ExtractModelKey<FormSchema<Model>>> = Required<FormValidatorOptions<Model, ModelKey>>;
|
|
52
57
|
export interface FormContext<Model extends BaseFormPayload, ModelKey extends ExtractModelKey<FormSchema<Model>>> {
|
|
@@ -18,6 +18,9 @@ export declare function useFormValidator<TSchema extends MaybeRefOrGetter<FormSc
|
|
|
18
18
|
fieldsStates: Ref<FieldsStates<InferSchemaFormValidator<TSchema>, ExtractModelKey<FormSchema<InferSchemaFormValidator<TSchema>>>>, FieldsStates<InferSchemaFormValidator<TSchema>, ExtractModelKey<FormSchema<InferSchemaFormValidator<TSchema>>>>>;
|
|
19
19
|
validateForm: (setErrors?: boolean) => Promise<void[]>;
|
|
20
20
|
scrollToError: typeof scrollToError;
|
|
21
|
-
|
|
21
|
+
resetForm: () => void;
|
|
22
|
+
handleSubmit: <Func extends (model: InferOutputSchemaFormValidator<TSchema>) => Promise<Awaited<ReturnType<Func>>> | ReturnType<Func>>(successCallback: Func, enableScrollOrSelector?: FormValidatorOptions["scrollToError"], options?: {
|
|
23
|
+
resetOnSuccess?: boolean;
|
|
24
|
+
}) => (event?: Event) => Promise<ReturnType<Func> | undefined>;
|
|
22
25
|
errorMessages: import('vue').ComputedRef<Record<ExtractModelKey<FormSchema<InferSchemaFormValidator<TSchema>>>, string | undefined>>;
|
|
23
26
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "maz-ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.3.4-beta.
|
|
4
|
+
"version": "4.3.4-beta.5",
|
|
5
5
|
"description": "A standalone components library for Vue.Js 3 & Nuxt.Js 3",
|
|
6
6
|
"author": "Louis Mazel <me@loicmazuel.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -178,11 +178,11 @@
|
|
|
178
178
|
"libphonenumber-js": "^1.12.33",
|
|
179
179
|
"valibot": "^1.2.0",
|
|
180
180
|
"vue-chartjs": "^5.3.3",
|
|
181
|
+
"@maz-ui/cli": "4.3.4-beta.0",
|
|
181
182
|
"@maz-ui/themes": "4.3.0",
|
|
183
|
+
"@maz-ui/translations": "4.3.0",
|
|
182
184
|
"@maz-ui/icons": "4.3.0",
|
|
183
|
-
"@maz-ui/
|
|
184
|
-
"@maz-ui/utils": "4.3.0",
|
|
185
|
-
"@maz-ui/translations": "4.3.0"
|
|
185
|
+
"@maz-ui/utils": "4.3.0"
|
|
186
186
|
},
|
|
187
187
|
"devDependencies": {
|
|
188
188
|
"@vitejs/plugin-vue": "^6.0.3",
|