{"version":3,"file":"form.mjs","sources":["../../../../../../packages/components/form/src/form.ts"],"sourcesContent":["import { componentSizes } from '@sgui-plus/utils/size'\r\nimport { buildProps, definePropType } from '@sgui-plus/utils/props'\r\nimport { isArray, isBool, isString } from '@sgui-plus/utils/util'\r\n\r\nimport type { ExtractPropTypes } from 'vue'\r\nimport type { FormItemProp } from './form-item'\r\nimport type { FormRules } from './types'\r\n\r\nconst formMetaProps = buildProps({\r\n  /**\r\n   * @description Control the size of components in this form.\r\n   */\r\n  size: {\r\n    type: String,\r\n    values: componentSizes,\r\n  },\r\n  /**\r\n   * @description Whether to disable all components in this form. If set to `true`, it will override the `disabled` prop of the inner component.\r\n   */\r\n  disabled: Boolean,\r\n} as const)\r\n\r\nexport const formProps = buildProps({\r\n  ...formMetaProps,\r\n  /**\r\n   * @description Data of form component.\r\n   */\r\n  model: Object,\r\n  /**\r\n   * @description Validation rules of form.\r\n   */\r\n  rules: {\r\n    type: definePropType<FormRules>(Object),\r\n  },\r\n  /**\r\n   * @description Position of label. If set to `'left'` or `'right'`, `label-width` prop is also required.\r\n   */\r\n  labelPosition: {\r\n    type: String,\r\n    values: ['left', 'right', 'top'],\r\n    default: 'right',\r\n  },\r\n  /**\r\n   * @description Position of asterisk.\r\n   */\r\n  requireAsteriskPosition: {\r\n    type: String,\r\n    values: ['left', 'right'],\r\n    default: 'left',\r\n  },\r\n  /**\r\n   * @description Width of label, e.g. `'50px'`. All its direct child form items will inherit this value. `auto` is supported.\r\n   */\r\n  labelWidth: {\r\n    type: [String, Number],\r\n    default: '',\r\n  },\r\n  /**\r\n   * @description Suffix of the label.\r\n   */\r\n  labelSuffix: {\r\n    type: String,\r\n    default: '',\r\n  },\r\n  /**\r\n   * @description Whether the form is inline.\r\n   */\r\n  inline: Boolean,\r\n  /**\r\n   * @description Whether to display the error message inline with the form item.\r\n   */\r\n  inlineMessage: Boolean,\r\n  /**\r\n   * @description Whether to display an icon indicating the validation result.\r\n   */\r\n  statusIcon: Boolean,\r\n  /**\r\n   * @description Whether to show the error message.\r\n   */\r\n  showMessage: {\r\n    type: Boolean,\r\n    default: true,\r\n  },\r\n  /**\r\n   * @description Whether to trigger validation when the `rules` prop is changed.\r\n   */\r\n  validateOnRuleChange: {\r\n    type: Boolean,\r\n    default: true,\r\n  },\r\n  /**\r\n   * @description Whether to hide required fields should have a red asterisk (star) beside their labels.\r\n   */\r\n  hideRequiredAsterisk: Boolean,\r\n  /**\r\n   * @description When validation fails, scroll to the first error form entry.\r\n   */\r\n  scrollToError: Boolean,\r\n  /**\r\n   * @description When validation fails, it scrolls to the first error item based on the scrollIntoView option.\r\n   */\r\n  scrollIntoViewOptions: {\r\n    type: [Object, Boolean],\r\n  },\r\n} as const)\r\nexport type FormProps = ExtractPropTypes<typeof formProps>\r\nexport type FormMetaProps = ExtractPropTypes<typeof formMetaProps>\r\n\r\nexport const formEmits = {\r\n  validate: (prop: FormItemProp, isValid: boolean, message: string) =>\r\n    (isArray(prop) || isString(prop)) &&\r\n    isBool(isValid) &&\r\n    isString(message),\r\n}\r\nexport type FormEmits = typeof formEmits\r\n"],"names":[],"mappings":";;;;;AAGA,MAAM,aAAa,GAAG,UAAU,CAAC;AACjC,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,MAAM,EAAE,cAAc;AAC1B,GAAG;AACH,EAAE,QAAQ,EAAE,OAAO;AACnB,CAAC,CAAC,CAAC;AACS,MAAC,SAAS,GAAG,UAAU,CAAC;AACpC,EAAE,GAAG,aAAa;AAClB,EAAE,KAAK,EAAE,MAAM;AACf,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC;AAChC,GAAG;AACH,EAAE,aAAa,EAAE;AACjB,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC;AACpC,IAAI,OAAO,EAAE,OAAO;AACpB,GAAG;AACH,EAAE,uBAAuB,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