defaults.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import { placements } from '@popperjs/core'
  2. import { definePropType, isValidComponentSize } from '@element-plus/utils'
  3. import { useTooltipContentProps } from '@element-plus/components/tooltip'
  4. import { CircleClose } from '@element-plus/icons-vue'
  5. import type { Component, PropType } from 'vue'
  6. import type { ComponentSize } from '@element-plus/constants'
  7. import type { OptionType } from './select.types'
  8. import type { Options, Placement } from '@element-plus/components/popper'
  9. export const SelectProps = {
  10. allowCreate: Boolean,
  11. autocomplete: {
  12. type: String as PropType<'none' | 'both' | 'list' | 'inline'>,
  13. default: 'none',
  14. },
  15. automaticDropdown: Boolean,
  16. clearable: Boolean,
  17. clearIcon: {
  18. type: [String, Object] as PropType<string | Component>,
  19. default: CircleClose,
  20. },
  21. effect: {
  22. type: String as PropType<'light' | 'dark' | string>,
  23. default: 'light',
  24. },
  25. collapseTags: Boolean,
  26. collapseTagsTooltip: {
  27. type: Boolean,
  28. default: false,
  29. },
  30. defaultFirstOption: Boolean,
  31. disabled: Boolean,
  32. estimatedOptionHeight: {
  33. type: Number,
  34. default: undefined,
  35. },
  36. filterable: Boolean,
  37. filterMethod: Function,
  38. height: {
  39. type: Number,
  40. default: 170, // 5 items by default
  41. },
  42. itemHeight: {
  43. type: Number,
  44. default: 34,
  45. },
  46. id: String,
  47. loading: Boolean,
  48. loadingText: String,
  49. label: String,
  50. modelValue: [Array, String, Number, Boolean, Object] as PropType<
  51. any[] | string | number | boolean | Record<string, any> | any
  52. >,
  53. multiple: Boolean,
  54. multipleLimit: {
  55. type: Number,
  56. default: 0,
  57. },
  58. name: String,
  59. noDataText: String,
  60. noMatchText: String,
  61. remoteMethod: Function,
  62. reserveKeyword: {
  63. type: Boolean,
  64. default: true,
  65. },
  66. options: {
  67. type: Array as PropType<OptionType[]>,
  68. required: true,
  69. },
  70. placeholder: {
  71. type: String,
  72. },
  73. teleported: useTooltipContentProps.teleported,
  74. persistent: {
  75. type: Boolean,
  76. default: true,
  77. },
  78. popperClass: {
  79. type: String,
  80. default: '',
  81. },
  82. popperOptions: {
  83. type: Object as PropType<Partial<Options>>,
  84. default: () => ({} as Partial<Options>),
  85. },
  86. remote: Boolean,
  87. size: {
  88. type: String as PropType<ComponentSize>,
  89. validator: isValidComponentSize,
  90. },
  91. valueKey: {
  92. type: String,
  93. default: 'value',
  94. },
  95. scrollbarAlwaysOn: {
  96. type: Boolean,
  97. default: false,
  98. },
  99. validateEvent: {
  100. type: Boolean,
  101. default: true,
  102. },
  103. placement: {
  104. type: definePropType<Placement>(String),
  105. values: placements,
  106. default: 'bottom-start',
  107. },
  108. }
  109. export const OptionProps = {
  110. data: Array,
  111. disabled: Boolean,
  112. hovering: Boolean,
  113. item: Object,
  114. index: Number,
  115. style: Object,
  116. selected: Boolean,
  117. created: Boolean,
  118. }