element-plus
Version:
A Component Library for Vue 3
1 lines • 4.88 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 { ExtractPropTypes, ExtractPublicPropTypes } from 'vue'\nimport type { FormItemProp } from './form-item'\nimport type { FormRules } from './types'\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 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)\nexport type FormProps = ExtractPropTypes<typeof formProps>\nexport type FormPropsPublic = ExtractPublicPropTypes<typeof formProps>\n\nexport type FormMetaProps = ExtractPropTypes<typeof formMetaProps>\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":";;;;;AAaO,MAAM,gBAAgB,UAAW,CAAA;AAAA,EAItC,IAAM,EAAA;AAAA,IACJ,IAAM,EAAA,MAAA;AAAA,IACN,MAAQ,EAAA,cAAA;AAAA,GACV;AAAA,EAIA,QAAU,EAAA,OAAA;AACZ,CAAU,EAAA;AAEH,MAAM,YAAY,UAAW,CAAA;AAAA,EAClC,GAAG,aAAA;AAAA,EAIH,KAAO,EAAA,MAAA;AAAA,EAIP,KAAO,EAAA;AAAA,IACL,IAAA,EAAM,eAA0B,MAAM,CAAA;AAAA,GACxC;AAAA,EAIA,aAAe,EAAA;AAAA,IACb,IAAM,EAAA,MAAA;AAAA,IACN,MAAQ,EAAA,CAAC,MAAQ,EAAA,OAAA,EAAS,KAAK,CAAA;AAAA,IAC/B,OAAS,EAAA,OAAA;AAAA,GACX;AAAA,EAIA,uBAAyB,EAAA;AAAA,IACvB,IAAM,EAAA,MAAA;AAAA,IACN,MAAA,EAAQ,CAAC,MAAA,EAAQ,OAAO,CAAA;AAAA,IACxB,OAAS,EAAA,MAAA;AAAA,GACX;AAAA,EAIA,UAAY,EAAA;AAAA,IACV,IAAA,EAAM,CAAC,MAAA,EAAQ,MAAM,CAAA;AAAA,IACrB,OAA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