{"version":3,"file":"form.mjs","sources":["../../../../../../../packages/components/form/src/form.ts"],"sourcesContent":["import { useSizeProp } from '@m-eleplus-crud/hooks'\r\nimport { buildProps, definePropType } from '@m-eleplus-crud/utils'\r\n\r\nimport type { ColumnType, ICommonColumn } from '../../common'\r\nimport type { FormItemRule } from 'element-plus'\r\n\r\nimport type { ExtractPropTypes } from 'vue'\r\n\r\n// 事件处理\r\ntype EventHandlers = {\r\n  [K in `event${string}`]?: (...args: any[]) => any\r\n}\r\n\r\n/**\r\n * @description 公开的form column配置\r\n */\r\nexport interface IFormCommonColumn extends EventHandlers {\r\n  /**\r\n   * 表单校验规则\r\n   */\r\n  rules?: FormItemRule[]\r\n  /**\r\n   * @description 单个标签宽度\r\n   */\r\n  labelWidth?: string\r\n  /**\r\n   * @description 表单排序\r\n   */\r\n  order?: number\r\n  /**\r\n   * @description 栅栏宽度\r\n   */\r\n  span?: number\r\n  /**\r\n   * @description 最大长度\r\n   */\r\n  maxlength?: number\r\n  /**\r\n   * @description 是否显示字数统计，仅对type为textarea有效\r\n   */\r\n  showWordLimit?: boolean\r\n  /**\r\n   * @description 是否显示密码切换按钮，仅对type为password有效\r\n   */\r\n  showPassword?: boolean\r\n  /**\r\n   * @description 默认值\r\n   */\r\n  value?: any\r\n  /**\r\n   * @description 占位文本\r\n   */\r\n  placeholder?: string\r\n  /**\r\n   * @description 表单禁用\r\n   */\r\n  disabled?: boolean\r\n  /**\r\n   * @description 可清除\r\n   */\r\n  clearable?: boolean\r\n}\r\n\r\nexport interface IFormColumn extends ICommonColumn, IFormCommonColumn {\r\n  /**\r\n   * @description 组件类型\r\n   */\r\n  type?: ColumnType\r\n}\r\n\r\n/**\r\n * @description 公开的form配置\r\n */\r\nexport interface IFormCommonOption {\r\n  /**\r\n   * @description 标签宽度\r\n   */\r\n  labelWidth?: string\r\n}\r\n\r\nexport interface IFormOption extends IFormCommonOption {\r\n  /**\r\n   * @description 表单列\r\n   */\r\n  column: IFormColumn[]\r\n}\r\n\r\nexport const formProps = buildProps({\r\n  /**\r\n   * @description 组件大小\r\n   */\r\n  size: useSizeProp,\r\n  /**\r\n   * @description 表单绑定的数据\r\n   */\r\n  model: {\r\n    type: Object,\r\n    required: true,\r\n  },\r\n  /**\r\n   * @description 表单加载状态\r\n   */\r\n  loading: {\r\n    type: Boolean,\r\n    default: false,\r\n  },\r\n  /**\r\n   * @description 表单权限配置\r\n   */\r\n  permission: {\r\n    type: Object,\r\n    default: {},\r\n  },\r\n  /**\r\n   * @description 是否只读\r\n   */\r\n  readonly: {\r\n    type: Boolean,\r\n    default: false,\r\n  },\r\n  /**\r\n   * @description 表单配置\r\n   */\r\n  option: {\r\n    type: definePropType<IFormOption>(Object),\r\n    required: false,\r\n  },\r\n} as const)\r\nexport type FormProps = ExtractPropTypes<typeof formProps>\r\n\r\nexport const formEmits = {}\r\nexport type FormEmits = typeof formEmits\r\n"],"names":[],"mappings":";;;AAuFO,MAAM,YAAY,UAAW,CAAA;AAAA,EAIlC,IAAM,EAAA,WAAA;AAAA,EAIN,KAAO,EAAA;AAAA,IACL,IAAM,EAAA,MAAA;AAAA,IACN,QAAU,EAAA,IAAA;AAAA,GACZ;AAAA,EAIA,OAAS,EAAA;AAAA,IACP,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,KAAA;AAAA,GACX;AAAA,EAIA,UAAY,EAAA;AAAA,IACV,IAAM,EAAA,MAAA;AAAA,IACN,SAAS,EAAC;AAAA,GACZ;AAAA,EAIA,QAAU,EAAA;AAAA,IACR,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,KAAA;AAAA,GACX;AAAA,EAIA,MAAQ,EAAA;AAAA,IACN,IAAA,EAAM,eAA4B,MAAM,CAAA;AAAA,IACxC,QAAU,EAAA,KAAA;AAAA,GACZ;AACF,CAAU,EAAA;AAGH,MAAM,YAAY;;;;"}