UNPKG

element-plus

Version:

A Component Library for Vue 3

1 lines 5.81 kB
{"version":3,"file":"form-item.mjs","sources":["../../../../../../packages/components/form/src/form-item.ts"],"sourcesContent":["import { componentSizes } from '@element-plus/constants'\nimport { buildProps, definePropType } from '@element-plus/utils'\n\nimport type { ExtractPublicPropTypes } from 'vue'\nimport type { ComponentSize } from '@element-plus/constants'\nimport type { Arrayable } from '@element-plus/utils'\nimport type { FormItemRule } from './types'\n\nexport const formItemValidateStates = [\n '',\n 'error',\n 'validating',\n 'success',\n] as const\nexport type FormItemValidateState = (typeof formItemValidateStates)[number]\n\nexport type FormItemProp = Arrayable<string>\n\nexport interface FormItemProps {\n /**\n * @description Label text.\n */\n label?: string\n /**\n * @description Width of label, e.g. `'50px'`. `'auto'` is supported.\n */\n labelWidth?: string | number\n /**\n * @description Position of label. If set to `'left'` or `'right'`, `label-width` prop is also required. The default is extend from `form label-position`.\n */\n labelPosition?: 'left' | 'right' | 'top' | ''\n /**\n * @description A key of `model`. It could be an array of property paths (e.g `['a', 'b', '0']`). In the use of `validate` and `resetFields` method, the attribute is required.\n */\n prop?: FormItemProp\n /**\n * @description Whether the field is required or not, will be determined by validation rules if omitted.\n */\n required?: boolean\n /**\n * @description Validation rules of form, see the [following table](#formitemrule), more advanced usage at [async-validator](https://github.com/yiminghe/async-validator).\n */\n rules?: Arrayable<FormItemRule>\n /**\n * @description Field error message, set its value and the field will validate error and show this message immediately.\n */\n error?: string\n /**\n * @description Validation state of formItem.\n */\n validateStatus?: FormItemValidateState\n /**\n * @description Same as for in native label.\n */\n for?: string\n /**\n * @description Inline style validate message.\n */\n inlineMessage?: boolean\n /**\n * @description Whether to show the error message.\n */\n showMessage?: boolean\n /**\n * @description Control the size of components in this form-item.\n */\n size?: ComponentSize\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `FormItemProps` instead.\n */\nexport const formItemProps = buildProps({\n /**\n * @description Label text.\n */\n label: String,\n /**\n * @description Width of label, e.g. `'50px'`. `'auto'` is supported.\n */\n labelWidth: {\n type: [String, Number],\n },\n /**\n * @description Position of label. If set to `'left'` or `'right'`, `label-width` prop is also required. The default is extend from `form label-position`.\n */\n labelPosition: {\n type: String,\n values: ['left', 'right', 'top', ''],\n default: '',\n },\n /**\n * @description A key of `model`. It could be an array of property paths (e.g `['a', 'b', '0']`). In the use of `validate` and `resetFields` method, the attribute is required.\n */\n prop: {\n type: definePropType<FormItemProp>([String, Array]),\n },\n /**\n * @description Whether the field is required or not, will be determined by validation rules if omitted.\n */\n required: {\n type: Boolean,\n default: undefined,\n },\n /**\n * @description Validation rules of form, see the [following table](#formitemrule), more advanced usage at [async-validator](https://github.com/yiminghe/async-validator).\n */\n rules: {\n type: definePropType<Arrayable<FormItemRule>>([Object, Array]),\n },\n /**\n * @description Field error message, set its value and the field will validate error and show this message immediately.\n */\n error: String,\n /**\n * @description Validation state of formItem.\n */\n validateStatus: {\n type: String,\n values: formItemValidateStates,\n },\n /**\n * @description Same as for in native label.\n */\n for: String,\n /**\n * @description Inline style validate message.\n */\n inlineMessage: {\n type: Boolean,\n default: undefined,\n },\n /**\n * @description Whether to show the error message.\n */\n showMessage: {\n type: Boolean,\n default: true,\n },\n /**\n * @description Control the size of components in this form-item.\n */\n size: {\n type: String,\n values: componentSizes,\n },\n} as const)\n\n/**\n * @deprecated Removed after 3.0.0, Use `FormItemProps` instead.\n */\nexport type FormItemPropsPublic = ExtractPublicPropTypes<typeof formItemProps>\n"],"names":[],"mappings":";;;AAQO,MAAM,sBAAA,GAAyB;AAAA,EACpC,EAAA;AAAA,EACA,OAAA;AAAA,EACA,YAAA;AAAA,EACA;AACF;AA2DO,MAAM,gBAAgB,UAAA,CAAW;AAAA;AAAA;AAAA;AAAA,EAItC,KAAA,EAAO,MAAA;AAAA;AAAA;AAAA;AAAA,EAIP,UAAA,EAAY;AAAA,IACV,IAAA,EAAM,CAAC,MAAA,EAAQ,MAAM;AAAA,GACvB;AAAA;AAAA;AAAA;AAAA,EAIA,aAAA,EAAe;AAA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