form.mjs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import { componentSizes } from "../../../constants/size.mjs";
  2. import { isArray, isBoolean, isString } from "../../../utils/types.mjs";
  3. import { buildProps, definePropType } from "../../../utils/vue/props/runtime.mjs";
  4. //#region ../../packages/components/form/src/form.ts
  5. /**
  6. * @deprecated Removed after 3.0.0, Use `FormMetaProps` instead.
  7. */
  8. const formMetaProps = buildProps({
  9. /**
  10. * @description Control the size of components in this form.
  11. */
  12. size: {
  13. type: String,
  14. values: componentSizes
  15. },
  16. /**
  17. * @description Whether to disable all components in this form. If set to `true`, it will override the `disabled` prop of the inner component.
  18. */
  19. disabled: Boolean
  20. });
  21. /**
  22. * @deprecated Removed after 3.0.0, Use `FormProps` instead.
  23. */
  24. const formProps = buildProps({
  25. ...formMetaProps,
  26. /**
  27. * @description Data of form component.
  28. */
  29. model: Object,
  30. /**
  31. * @description Validation rules of form.
  32. */
  33. rules: { type: definePropType(Object) },
  34. /**
  35. * @description Position of label. If set to `'left'` or `'right'`, `label-width` prop is also required.
  36. */
  37. labelPosition: {
  38. type: String,
  39. values: [
  40. "left",
  41. "right",
  42. "top"
  43. ],
  44. default: "right"
  45. },
  46. /**
  47. * @description Position of asterisk.
  48. */
  49. requireAsteriskPosition: {
  50. type: String,
  51. values: ["left", "right"],
  52. default: "left"
  53. },
  54. /**
  55. * @description Width of label, e.g. `'50px'`. All its direct child form items will inherit this value. `auto` is supported.
  56. */
  57. labelWidth: {
  58. type: [String, Number],
  59. default: ""
  60. },
  61. /**
  62. * @description Suffix of the label.
  63. */
  64. labelSuffix: {
  65. type: String,
  66. default: ""
  67. },
  68. /**
  69. * @description Whether the form is inline.
  70. */
  71. inline: Boolean,
  72. /**
  73. * @description Whether to display the error message inline with the form item.
  74. */
  75. inlineMessage: Boolean,
  76. /**
  77. * @description Whether to display an icon indicating the validation result.
  78. */
  79. statusIcon: Boolean,
  80. /**
  81. * @description Whether to show the error message.
  82. */
  83. showMessage: {
  84. type: Boolean,
  85. default: true
  86. },
  87. /**
  88. * @description Whether to trigger validation when the `rules` prop is changed.
  89. */
  90. validateOnRuleChange: {
  91. type: Boolean,
  92. default: true
  93. },
  94. /**
  95. * @description Whether to hide required fields should have a red asterisk (star) beside their labels.
  96. */
  97. hideRequiredAsterisk: Boolean,
  98. /**
  99. * @description When validation fails, scroll to the first error form entry.
  100. */
  101. scrollToError: Boolean,
  102. /**
  103. * @description When validation fails, it scrolls to the first error item based on the scrollIntoView option.
  104. */
  105. scrollIntoViewOptions: {
  106. type: definePropType([Object, Boolean]),
  107. default: true
  108. }
  109. });
  110. const formEmits = { validate: (prop, isValid, message) => (isArray(prop) || isString(prop)) && isBoolean(isValid) && isString(message) };
  111. //#endregion
  112. export { formEmits, formMetaProps, formProps };
  113. //# sourceMappingURL=form.mjs.map