slider.mjs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. import { CHANGE_EVENT, INPUT_EVENT, UPDATE_MODEL_EVENT } from "../../../constants/event.mjs";
  2. import { isArray, isNumber } from "../../../utils/types.mjs";
  3. import { buildProps, definePropType } from "../../../utils/vue/props/runtime.mjs";
  4. import { useSizeProp } from "../../../hooks/use-size/index.mjs";
  5. import { useAriaProps } from "../../../hooks/use-aria/index.mjs";
  6. import { placements } from "@popperjs/core";
  7. //#region ../../packages/components/slider/src/slider.ts
  8. const sliderProps = buildProps({
  9. /**
  10. * @description binding value
  11. */
  12. modelValue: {
  13. type: definePropType([Number, Array]),
  14. default: 0
  15. },
  16. id: {
  17. type: String,
  18. default: void 0
  19. },
  20. /**
  21. * @description minimum value
  22. */
  23. min: {
  24. type: Number,
  25. default: 0
  26. },
  27. /**
  28. * @description maximum value
  29. */
  30. max: {
  31. type: Number,
  32. default: 100
  33. },
  34. /**
  35. * @description step size, can be a number or `'mark'` to restrict values to marks. When set to `'mark'`, the `marks` attribute must be set
  36. */
  37. step: {
  38. type: definePropType([Number, String]),
  39. default: 1
  40. },
  41. /**
  42. * @description whether to display an input box, works when `range` is false and `step` is not `'mark'`
  43. */
  44. showInput: Boolean,
  45. /**
  46. * @description whether to display control buttons when `show-input` is true
  47. */
  48. showInputControls: {
  49. type: Boolean,
  50. default: true
  51. },
  52. /**
  53. * @description size of the slider wrapper, will not work in vertical mode
  54. */
  55. size: useSizeProp,
  56. /**
  57. * @description size of the input box, when set `size`, the default is the value of `size`
  58. */
  59. inputSize: useSizeProp,
  60. /**
  61. * @description whether to display breakpoints
  62. */
  63. showStops: Boolean,
  64. /**
  65. * @description whether to display tooltip value
  66. */
  67. showTooltip: {
  68. type: Boolean,
  69. default: true
  70. },
  71. /**
  72. * @description format to display tooltip value
  73. */
  74. formatTooltip: {
  75. type: definePropType(Function),
  76. default: void 0
  77. },
  78. /**
  79. * @description whether Slider is disabled
  80. */
  81. disabled: {
  82. type: Boolean,
  83. default: void 0
  84. },
  85. /**
  86. * @description whether to select a range
  87. */
  88. range: Boolean,
  89. /**
  90. * @description vertical mode
  91. */
  92. vertical: Boolean,
  93. /**
  94. * @description slider height, required in vertical mode
  95. */
  96. height: String,
  97. /**
  98. * @description when `range` is true, screen reader label for the start of the range
  99. */
  100. rangeStartLabel: {
  101. type: String,
  102. default: void 0
  103. },
  104. /**
  105. * @description when `range` is true, screen reader label for the end of the range
  106. */
  107. rangeEndLabel: {
  108. type: String,
  109. default: void 0
  110. },
  111. /**
  112. * @description format to display the `aria-valuenow` attribute for screen readers
  113. */
  114. formatValueText: {
  115. type: definePropType(Function),
  116. default: void 0
  117. },
  118. /**
  119. * @description custom class name for the tooltip
  120. */
  121. tooltipClass: {
  122. type: String,
  123. default: void 0
  124. },
  125. /**
  126. * @description position of Tooltip
  127. */
  128. placement: {
  129. type: String,
  130. values: placements,
  131. default: "top"
  132. },
  133. /**
  134. * @description marks, type of key must be `number` and must in closed interval `[min, max]`, each mark can custom style
  135. */
  136. marks: { type: definePropType(Object) },
  137. /**
  138. * @description whether to trigger form validation
  139. */
  140. validateEvent: {
  141. type: Boolean,
  142. default: true
  143. },
  144. /**
  145. * @description when slider tooltip inactive and `persistent` is `false` , popconfirm will be destroyed. `persistent` always be `false` when `show-tooltip ` is `false`
  146. */
  147. persistent: {
  148. type: Boolean,
  149. default: true
  150. },
  151. ...useAriaProps(["ariaLabel"])
  152. });
  153. const isValidValue = (value) => isNumber(value) || isArray(value) && value.every(isNumber);
  154. const sliderEmits = {
  155. [UPDATE_MODEL_EVENT]: isValidValue,
  156. [INPUT_EVENT]: isValidValue,
  157. [CHANGE_EVENT]: isValidValue
  158. };
  159. //#endregion
  160. export { sliderEmits, sliderProps };
  161. //# sourceMappingURL=slider.mjs.map