rate.mjs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. import { CHANGE_EVENT, UPDATE_MODEL_EVENT } from "../../../constants/event.mjs";
  2. import { isNumber } from "../../../utils/types.mjs";
  3. import { buildProps, definePropType } from "../../../utils/vue/props/runtime.mjs";
  4. import { iconPropType } from "../../../utils/vue/icon.mjs";
  5. import { mutable } from "../../../utils/typescript.mjs";
  6. import { useSizeProp } from "../../../hooks/use-size/index.mjs";
  7. import { useAriaProps } from "../../../hooks/use-aria/index.mjs";
  8. import { Star, StarFilled } from "@element-plus/icons-vue";
  9. //#region ../../packages/components/rate/src/rate.ts
  10. /**
  11. * @deprecated Removed after 3.0.0, Use `RateProps` instead.
  12. */
  13. const rateProps = buildProps({
  14. /**
  15. * @description binding value
  16. */
  17. modelValue: {
  18. type: Number,
  19. default: 0
  20. },
  21. /**
  22. * @description native `id` attribute
  23. */
  24. id: {
  25. type: String,
  26. default: void 0
  27. },
  28. /**
  29. * @description threshold value between low and medium level. The value itself will be included in low level
  30. */
  31. lowThreshold: {
  32. type: Number,
  33. default: 2
  34. },
  35. /**
  36. * @description threshold value between medium and high level. The value itself will be included in high level
  37. */
  38. highThreshold: {
  39. type: Number,
  40. default: 4
  41. },
  42. /**
  43. * @description max rating score
  44. */
  45. max: {
  46. type: Number,
  47. default: 5
  48. },
  49. /**
  50. * @description colors for icons. If array, it should have 3 elements, each of which corresponds with a score level, else if object, the key should be threshold value between two levels, and the value should be corresponding color
  51. */
  52. colors: {
  53. type: definePropType([Array, Object]),
  54. default: () => mutable([
  55. "",
  56. "",
  57. ""
  58. ])
  59. },
  60. /**
  61. * @description color of unselected icons
  62. */
  63. voidColor: {
  64. type: String,
  65. default: ""
  66. },
  67. /**
  68. * @description color of unselected read-only icons
  69. */
  70. disabledVoidColor: {
  71. type: String,
  72. default: ""
  73. },
  74. /**
  75. * @description icon components. If array, it should have 3 elements, each of which corresponds with a score level, else if object, the key should be threshold value between two levels, and the value should be corresponding icon component
  76. */
  77. icons: {
  78. type: definePropType([Array, Object]),
  79. default: () => [
  80. StarFilled,
  81. StarFilled,
  82. StarFilled
  83. ]
  84. },
  85. /**
  86. * @description component of unselected icons
  87. */
  88. voidIcon: {
  89. type: iconPropType,
  90. default: () => Star
  91. },
  92. /**
  93. * @description component of unselected read-only icons
  94. */
  95. disabledVoidIcon: {
  96. type: iconPropType,
  97. default: () => StarFilled
  98. },
  99. /**
  100. * @description whether Rate is read-only
  101. */
  102. disabled: {
  103. type: Boolean,
  104. default: void 0
  105. },
  106. /**
  107. * @description whether picking half start is allowed
  108. */
  109. allowHalf: Boolean,
  110. /**
  111. * @description whether to display texts
  112. */
  113. showText: Boolean,
  114. /**
  115. * @description whether to display current score. show-score and show-text cannot be true at the same time
  116. */
  117. showScore: Boolean,
  118. /**
  119. * @description color of texts
  120. */
  121. textColor: {
  122. type: String,
  123. default: ""
  124. },
  125. /**
  126. * @description text array
  127. */
  128. texts: {
  129. type: definePropType(Array),
  130. default: () => mutable([
  131. "Extremely bad",
  132. "Disappointed",
  133. "Fair",
  134. "Satisfied",
  135. "Surprise"
  136. ])
  137. },
  138. /**
  139. * @description score template
  140. */
  141. scoreTemplate: {
  142. type: String,
  143. default: "{value}"
  144. },
  145. /**
  146. * @description size of Rate
  147. */
  148. size: useSizeProp,
  149. /**
  150. * @description whether value can be reset to `0`
  151. */
  152. clearable: Boolean,
  153. ...useAriaProps(["ariaLabel"])
  154. });
  155. const rateEmits = {
  156. [CHANGE_EVENT]: (value) => isNumber(value),
  157. [UPDATE_MODEL_EVENT]: (value) => isNumber(value)
  158. };
  159. //#endregion
  160. export { rateEmits, rateProps };
  161. //# sourceMappingURL=rate.mjs.map