UNPKG

element-plus

Version:

A Component Library for Vue 3

1 lines 3.92 kB
{"version":3,"file":"form-item2.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 { ExtractPropTypes, ExtractPublicPropTypes } from 'vue'\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 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)\nexport type FormItemProps = ExtractPropTypes<typeof formItemProps>\nexport type FormItemPropsPublic = ExtractPublicPropTypes<typeof formItemProps>\n"],"names":[],"mappings":";;;AAOO,MAAM,sBAAyB,GAAA;AAAA,EACpC,EAAA;AAAA,EACA,OAAA;AAAA,EACA,YAAA;AAAA,EACA,SAAA;AACF,EAAA;AAKO,MAAM,gBAAgB,UAAW,CAAA;AAAA,EAItC,KAAO,EAAA,MAAA;AAAA,EAIP,UAAY,EAAA;AAAA,IACV,IAAA,EAAM,CAAC,MAAA,EAAQ,MAAM,CAAA;AAAA,GACvB;AAAA,EAIA,aAAe,EAAA;AAAA,IACb,IAAM,EAAA,MAAA;AAAA,IACN,MAAQ,EAAA,CAAC,MAAQ,EAAA,OAAA,EAAS,OAAO,EAAE,CAAA;AAAA,IACnC,OAAS,EAAA,EAAA;AAAA,GACX;AAAA,EAIA,IAAM,EAAA;AAAA,IACJ,IAAM,EAAA,cAAA,CAA6B,CAAC,MAAA,EAAQ,KAAK,CAAC,CAAA;AAAA,GACpD;AAAA,EAIA,QAAU,EAAA;AAAA,IACR,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,KAAA,CAAA;AAAA,GACX;AAAA,EAIA,KAAO,EAAA;AAAA,IACL,IAAM,EAAA,cAAA,CAAwC,CAAC,MAAA,EAAQ,KAAK,CAAC,CAAA;AAAA,GAC/D;AAAA,EAIA,KAAO,EAAA,MAAA;AAAA,EAIP,cAAgB,EAAA;AAAA,IACd,IAAM,EAAA,MAAA;AAAA,IACN,MAAQ,EAAA,sBAAA;AAAA,GACV;AAAA,EAIA,GAAK,EAAA,MAAA;AAAA,EAIL,aAAe,EAAA;AAAA,IACb,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,KAAA,CAAA;AAAA,GACX;AAAA,EAIA,WAAa,EAAA;AAAA,IACX,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,IAAA;AAAA,GACX;AAAA,EAIA,IAAM,EAAA;AAAA,IACJ,IAAM,EAAA,MAAA;AAAA,IACN,MAAQ,EAAA,cAAA;AAAA,GACV;AACF,CAAU;;;;"}