components.d.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import { CSSProperties } from 'vue'
  2. import { InputProps } from 'element-plus'
  3. export enum ComponentNameEnum {
  4. RADIO = 'Radio',
  5. RADIO_BUTTON = 'RadioButton',
  6. CHECKBOX = 'Checkbox',
  7. CHECKBOX_BUTTON = 'CheckboxButton',
  8. INPUT = 'Input',
  9. AUTOCOMPLETE = 'Autocomplete',
  10. INPUT_NUMBER = 'InputNumber',
  11. SELECT = 'Select',
  12. CASCADER = 'Cascader',
  13. SWITCH = 'Switch',
  14. SLIDER = 'Slider',
  15. TIME_PICKER = 'TimePicker',
  16. DATE_PICKER = 'DatePicker',
  17. RATE = 'Rate',
  18. COLOR_PICKER = 'ColorPicker',
  19. TRANSFER = 'Transfer',
  20. DIVIDER = 'Divider',
  21. TIME_SELECT = 'TimeSelect',
  22. SELECT_V2 = 'SelectV2',
  23. INPUT_PASSWORD = 'InputPassword',
  24. EDITOR = 'Editor'
  25. }
  26. export interface InputComponentProps {
  27. value?: string | number
  28. maxlength?: number | string
  29. minlength?: number | string
  30. showWordLimit?: boolean
  31. placeholder?: string
  32. clearable?: boolean
  33. formatter?: (value: string | number) => string
  34. parser?: (value: string) => string
  35. showPassword?: boolean
  36. disabled?: boolean
  37. size?: InputProps['size']
  38. prefixIcon?: string | JSX.Element | (<T>(data: T | any) => string | JSX.Element)
  39. suffixIcon?: string | JSX.Element | (<T>(data: T | any) => string | JSX.Element)
  40. rows?: number
  41. autosize?: boolean | { Pows?: numer; maxRows?: number }
  42. autocomplete?: string
  43. name?: string
  44. readonly?: boolean
  45. max?: number | string
  46. min?: number | string
  47. step?: number | string
  48. resize?: InputProps['resize']
  49. autofocus?: boolean
  50. form?: string
  51. label?: string
  52. tabindex?: string | number
  53. validateEvent?: boolean
  54. inputStyle?: string | CSSProperties | CSSProperties[] | string[]
  55. on?: {
  56. blur?: (event: FocusEvent) => void
  57. focus?: (event: FocusEvent) => void
  58. change?: (value: string | number) => void
  59. clear?: () => void
  60. input?: (value: string | number) => void
  61. }
  62. slots?: {
  63. prefix?: JSX.Element | (<T>(data: T | any) => JSX.Element)
  64. suffix?: JSX.Element | (<T>(data: T | any) => JSX.Element)
  65. prepend?: JSX.Element | (<T>(data: T | any) => JSX.Element)
  66. append?: JSX.Element | (<T>(data: T | any) => JSX.Element)
  67. }
  68. }
  69. type CamelCaseComponentName = keyof typeof ComponentNameEnum extends infer K
  70. ? K extends string
  71. ? K extends `${infer A}_${infer B}`
  72. ? `${Capitalize<Lowercase<A>>}${Capitalize<Lowercase<B>>}`
  73. : Capitalize<Lowercase<K>>
  74. : never
  75. : never
  76. export type ComponentName = CamelCaseComponentName
  77. export interface ColProps {
  78. span?: number
  79. xs?: number
  80. sm?: number
  81. md?: number
  82. lg?: number
  83. xl?: number
  84. tag?: string
  85. }
  86. export interface ComponentOptions extends Recordable {
  87. label?: string
  88. value?: FormValueType
  89. disabled?: boolean
  90. key?: string | number
  91. children?: ComponentOptions[]
  92. options?: ComponentOptions[]
  93. }
  94. export interface ComponentOptionsAlias {
  95. labelField?: string
  96. valueField?: string
  97. }
  98. export interface ComponentProps extends Recordable {
  99. optionsAlias?: ComponentOptionsAlias
  100. options?: ComponentOptions[]
  101. optionsSlot?: boolean
  102. }