element-plus
Version:
A Component Library for Vue 3
1 lines • 7.34 kB
Source Map (JSON)
{"version":3,"file":"form.mjs","sources":["../../../../../../packages/components/form/src/form.ts"],"sourcesContent":["import { componentSizes } from '@element-plus/constants'\nimport {\n buildProps,\n definePropType,\n isArray,\n isBoolean,\n isString,\n} from '@element-plus/utils'\n\nimport type { ExtractPublicPropTypes } from 'vue'\nimport type { ComponentSize } from '@element-plus/constants'\nimport type { FormItemProp } from './form-item'\nimport type { FormRules } from './types'\n\nexport interface FormMetaProps {\n /**\n * @description Control the size of components in this form.\n */\n size?: ComponentSize\n /**\n * @description Whether to disable all components in this form. If set to `true`, it will override the `disabled` prop of the inner component.\n */\n disabled?: boolean\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `FormMetaProps` instead.\n */\nexport const formMetaProps = buildProps({\n /**\n * @description Control the size of components in this form.\n */\n size: {\n type: String,\n values: componentSizes,\n },\n /**\n * @description Whether to disable all components in this form. If set to `true`, it will override the `disabled` prop of the inner component.\n */\n disabled: Boolean,\n} as const)\n\nexport interface FormProps extends FormMetaProps {\n /**\n * @description Data of form component.\n */\n model?: Record<string, any>\n /**\n * @description Validation rules of form.\n */\n rules?: FormRules\n /**\n * @description Position of label. If set to `'left'` or `'right'`, `label-width` prop is also required.\n */\n labelPosition?: 'left' | 'right' | 'top'\n /**\n * @description Position of asterisk.\n */\n requireAsteriskPosition?: 'left' | 'right'\n /**\n * @description Width of label, e.g. `'50px'`. All its direct child form items will inherit this value. `auto` is supported.\n */\n labelWidth?: string | number\n /**\n * @description Suffix of the label.\n */\n labelSuffix?: string\n /**\n * @description Whether the form is inline.\n */\n inline?: boolean\n /**\n * @description Whether to display the error message inline with the form item.\n */\n inlineMessage?: boolean\n /**\n * @description Whether to display an icon indicating the validation result.\n */\n statusIcon?: boolean\n /**\n * @description Whether to show the error message.\n */\n showMessage?: boolean\n /**\n * @description Whether to trigger validation when the `rules` prop is changed.\n */\n validateOnRuleChange?: boolean\n /**\n * @description Whether to hide required fields should have a red asterisk (star) beside their labels.\n */\n hideRequiredAsterisk?: boolean\n /**\n * @description When validation fails, scroll to the first error form entry.\n */\n scrollToError?: boolean\n /**\n * @description When validation fails, it scrolls to the first error item based on the scrollIntoView option.\n */\n scrollIntoViewOptions?: ScrollIntoViewOptions | boolean\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `FormProps` instead.\n */\nexport const formProps = buildProps({\n ...formMetaProps,\n /**\n * @description Data of form component.\n */\n model: Object,\n /**\n * @description Validation rules of form.\n */\n rules: {\n type: definePropType<FormRules>(Object),\n },\n /**\n * @description Position of label. If set to `'left'` or `'right'`, `label-width` prop is also required.\n */\n labelPosition: {\n type: String,\n values: ['left', 'right', 'top'],\n default: 'right',\n },\n /**\n * @description Position of asterisk.\n */\n requireAsteriskPosition: {\n type: String,\n values: ['left', 'right'],\n default: 'left',\n },\n /**\n * @description Width of label, e.g. `'50px'`. All its direct child form items will inherit this value. `auto` is supported.\n */\n labelWidth: {\n type: [String, Number],\n default: '',\n },\n /**\n * @description Suffix of the label.\n */\n labelSuffix: {\n type: String,\n default: '',\n },\n /**\n * @description Whether the form is inline.\n */\n inline: Boolean,\n /**\n * @description Whether to display the error message inline with the form item.\n */\n inlineMessage: Boolean,\n /**\n * @description Whether to display an icon indicating the validation result.\n */\n statusIcon: Boolean,\n /**\n * @description Whether to show the error message.\n */\n showMessage: {\n type: Boolean,\n default: true,\n },\n /**\n * @description Whether to trigger validation when the `rules` prop is changed.\n */\n validateOnRuleChange: {\n type: Boolean,\n default: true,\n },\n /**\n * @description Whether to hide required fields should have a red asterisk (star) beside their labels.\n */\n hideRequiredAsterisk: Boolean,\n /**\n * @description When validation fails, scroll to the first error form entry.\n */\n scrollToError: Boolean,\n /**\n * @description When validation fails, it scrolls to the first error item based on the scrollIntoView option.\n */\n scrollIntoViewOptions: {\n type: definePropType<ScrollIntoViewOptions | boolean>([Object, Boolean]),\n default: true,\n },\n} as const)\n\n/**\n * @deprecated Removed after 3.0.0, Use `FormProps` instead.\n */\nexport type FormPropsPublic = ExtractPublicPropTypes<typeof formProps>\n\n/**\n * @deprecated Removed after 3.0.0, Use `FormMetaProps` instead.\n */\nexport type FormMetaPropsPublic = ExtractPublicPropTypes<typeof formMetaProps>\n\nexport const formEmits = {\n validate: (prop: FormItemProp, isValid: boolean, message: string) =>\n (isArray(prop) || isString(prop)) &&\n isBoolean(isValid) &&\n isString(message),\n}\nexport type FormEmits = typeof formEmits\n"],"names":[],"mappings":";;;;;AA4BO,MAAM,gBAAgB,UAAA,CAAW;AAAA;AAAA;AAAA;AAAA,EAItC,IAAA,EAAM;AAAA,IACJ,IAAA,EAAM,MAAA;AAAA,IACN,MAAA,EAAQ;AAAA,GACV;AAAA;AAAA;AAAA;AAAA,EAIA,QAAA,EAAU;AACZ,CAAU;AAgEH,MAAM,YAAY,UAAA,CAAW;AAAA,EAClC,GAAG,aAAA;AAAA;AAAA;AAAA;AAAA,EAIH,KAAA,EAAO,MAAA;AAAA;AAAA;AAAA;AAAA,EAIP,KAAA,EAAO;AAAA,IACL,IAAA,EAAM,eAA0B,MAAM;AAAA,GACxC;AAAA;AAAA;AAAA;AAAA,EAIA,aAAA,EAAe;AAAA,IACb,IAAA,EAAM,MAAA;AAAA,IACN,MAAA,EAAQ,CAAC,MAAA,EAAQ,OAAA,EAAS,KAAK,CAAA;AAAA,IAC/B,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,uBAAA,EAAyB;AAAA,IACvB,IAAA,EAAM,MAAA;AAAA,IACN,MAAA,EAAQ,CAAC,MAAA,EAAQ,OAAO,CAAA;AAAA,IACxB,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,UAAA,EAAY;AAAA,IACV,IAAA,EAAM,CAAC,MAAA,EAAQ,MAAM,CAAA;AAAA,IACrB,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,WAAA,EAAa;AAAA,IACX,IAAA,EAAM,MAAA;AAAA,I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