tsv2-library 1.0.61-beta.71 → 1.0.61-beta.73
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.
|
@@ -120,6 +120,14 @@ declare class Form extends ClassComponent<FormProps, FormSlots, FormEmits> {
|
|
|
120
120
|
* Clears the form fields.
|
|
121
121
|
*/
|
|
122
122
|
clearField: () => void;
|
|
123
|
+
/**
|
|
124
|
+
* Sets the errors for the form fields.
|
|
125
|
+
*/
|
|
126
|
+
setErrors: (errors: Partial<Record<string, string | undefined>>) => void;
|
|
127
|
+
/**
|
|
128
|
+
* Sets the error for a specific field.
|
|
129
|
+
*/
|
|
130
|
+
setFieldError: (field: string, error: string | undefined) => void;
|
|
123
131
|
}
|
|
124
132
|
|
|
125
133
|
declare module '@vue/runtime-core' {
|
package/dist/tsv2-library.es.js
CHANGED
|
@@ -68443,7 +68443,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
68443
68443
|
setDialogClass();
|
|
68444
68444
|
}
|
|
68445
68445
|
});
|
|
68446
|
-
const { handleSubmit, values, resetForm, errors } = useForm$1();
|
|
68446
|
+
const { handleSubmit, values, resetForm, errors, setErrors, setFieldError } = useForm$1();
|
|
68447
68447
|
const isSubmitting = shallowRef(false);
|
|
68448
68448
|
provide("isSubmitting", isSubmitting);
|
|
68449
68449
|
const formState = shallowRef("submit");
|
|
@@ -68539,7 +68539,9 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
68539
68539
|
formElement,
|
|
68540
68540
|
clearField,
|
|
68541
68541
|
errors,
|
|
68542
|
-
values
|
|
68542
|
+
values,
|
|
68543
|
+
setErrors,
|
|
68544
|
+
setFieldError
|
|
68543
68545
|
});
|
|
68544
68546
|
return (_ctx, _cache) => {
|
|
68545
68547
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -78074,25 +78076,28 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
78074
78076
|
});
|
|
78075
78077
|
const setValidatorMessage = async (value) => {
|
|
78076
78078
|
await nextTick();
|
|
78079
|
+
let result = true;
|
|
78077
78080
|
if (props.validatorMessage && typeof props.validatorMessage === "string" && props.invalid) {
|
|
78078
|
-
|
|
78081
|
+
result = props.validatorMessage;
|
|
78079
78082
|
} else if (!value && props.mandatory) {
|
|
78080
|
-
|
|
78083
|
+
result = `${props.label} must not be empty`;
|
|
78081
78084
|
} else if ((value == null ? void 0 : value.length) > props.maxLength && (props.type === "text" || props.type === "email")) {
|
|
78082
|
-
|
|
78085
|
+
result = "Max. " + props.maxLength + " characters";
|
|
78083
78086
|
} else if (value && props.type === "email") {
|
|
78084
78087
|
const emailRegexp = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
|
|
78085
|
-
|
|
78088
|
+
result = emailRegexp.test(value) ? true : "Email format is incorrect";
|
|
78086
78089
|
} else if (value && props.type === "url") {
|
|
78087
78090
|
const urlRegExp = new RegExp(
|
|
78088
78091
|
"^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+:@!$&'()*+,;=]*)*(\\?[;&a-z\\d%_.~+=:@!$&'()*+,;=-]*)?(\\#[-a-z\\d_:@!$&'()*+,;=]*)?$",
|
|
78089
78092
|
// Fragment (Allowing special characters)
|
|
78090
78093
|
"i"
|
|
78091
78094
|
);
|
|
78092
|
-
|
|
78095
|
+
result = urlRegExp.test(value) ? true : "URL format is incorrect";
|
|
78093
78096
|
} else if (!props.allowSpecialCharacters) {
|
|
78094
|
-
|
|
78097
|
+
result = /[^A-Za-z0-9 ]/.test(value) ? "Cannot include any special characters" : true;
|
|
78095
78098
|
}
|
|
78099
|
+
if (result !== true)
|
|
78100
|
+
return result;
|
|
78096
78101
|
if (props.checkAvailability)
|
|
78097
78102
|
return handleAvailabilityValidation();
|
|
78098
78103
|
return true;
|