element-plus
Version:
A Component Library for Vue 3
109 lines (106 loc) • 2.82 kB
JavaScript
import { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs';
import { componentSizes } from '../../../constants/size.mjs';
import { isArray, isString } from '@vue/shared';
import { isBoolean } from '../../../utils/types.mjs';
const formMetaProps = buildProps({
/**
* @description Control the size of components in this form.
*/
size: {
type: String,
values: componentSizes
},
/**
* @description Whether to disable all components in this form. If set to `true`, it will override the `disabled` prop of the inner component.
*/
disabled: Boolean
});
const formProps = buildProps({
...formMetaProps,
/**
* @description Data of form component.
*/
model: Object,
/**
* @description Validation rules of form.
*/
rules: {
type: definePropType(Object)
},
/**
* @description Position of label. If set to `'left'` or `'right'`, `label-width` prop is also required.
*/
labelPosition: {
type: String,
values: ["left", "right", "top"],
default: "right"
},
/**
* @description Position of asterisk.
*/
requireAsteriskPosition: {
type: String,
values: ["left", "right"],
default: "left"
},
/**
* @description Width of label, e.g. `'50px'`. All its direct child form items will inherit this value. `auto` is supported.
*/
labelWidth: {
type: [String, Number],
default: ""
},
/**
* @description Suffix of the label.
*/
labelSuffix: {
type: String,
default: ""
},
/**
* @description Whether the form is inline.
*/
inline: Boolean,
/**
* @description Whether to display the error message inline with the form item.
*/
inlineMessage: Boolean,
/**
* @description Whether to display an icon indicating the validation result.
*/
statusIcon: Boolean,
/**
* @description Whether to show the error message.
*/
showMessage: {
type: Boolean,
default: true
},
/**
* @description Whether to trigger validation when the `rules` prop is changed.
*/
validateOnRuleChange: {
type: Boolean,
default: true
},
/**
* @description Whether to hide required fields should have a red asterisk (star) beside their labels.
*/
hideRequiredAsterisk: Boolean,
/**
* @description When validation fails, scroll to the first error form entry.
*/
scrollToError: Boolean,
/**
* @description When validation fails, it scrolls to the first error item based on the scrollIntoView option.
*/
scrollIntoViewOptions: {
type: definePropType([Object, Boolean]),
default: true
}
});
const formEmits = {
validate: (prop, isValid, message) => (isArray(prop) || isString(prop)) && isBoolean(isValid) && isString(message)
};
export { formEmits, formMetaProps, formProps };
//# sourceMappingURL=form.mjs.map