switch.mjs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import { CHANGE_EVENT, INPUT_EVENT, UPDATE_MODEL_EVENT } from "../../../constants/event.mjs";
  2. import { isBoolean, isNumber, isString } from "../../../utils/types.mjs";
  3. import { buildProps, definePropType } from "../../../utils/vue/props/runtime.mjs";
  4. import { iconPropType } from "../../../utils/vue/icon.mjs";
  5. import { isValidComponentSize } from "../../../utils/vue/validator.mjs";
  6. import { useAriaProps } from "../../../hooks/use-aria/index.mjs";
  7. //#region ../../packages/components/switch/src/switch.ts
  8. /**
  9. * @deprecated Removed after 3.0.0, Use `SwitchProps` instead.
  10. */
  11. const switchProps = buildProps({
  12. modelValue: {
  13. type: [
  14. Boolean,
  15. String,
  16. Number
  17. ],
  18. default: false
  19. },
  20. disabled: {
  21. type: Boolean,
  22. default: void 0
  23. },
  24. loading: Boolean,
  25. size: {
  26. type: String,
  27. validator: isValidComponentSize
  28. },
  29. width: {
  30. type: [String, Number],
  31. default: ""
  32. },
  33. inlinePrompt: Boolean,
  34. inactiveActionIcon: { type: iconPropType },
  35. activeActionIcon: { type: iconPropType },
  36. activeIcon: { type: iconPropType },
  37. inactiveIcon: { type: iconPropType },
  38. activeText: {
  39. type: String,
  40. default: ""
  41. },
  42. inactiveText: {
  43. type: String,
  44. default: ""
  45. },
  46. activeValue: {
  47. type: [
  48. Boolean,
  49. String,
  50. Number
  51. ],
  52. default: true
  53. },
  54. inactiveValue: {
  55. type: [
  56. Boolean,
  57. String,
  58. Number
  59. ],
  60. default: false
  61. },
  62. name: {
  63. type: String,
  64. default: ""
  65. },
  66. validateEvent: {
  67. type: Boolean,
  68. default: true
  69. },
  70. beforeChange: { type: definePropType(Function) },
  71. id: String,
  72. tabindex: { type: [String, Number] },
  73. ...useAriaProps(["ariaLabel"])
  74. });
  75. const switchEmits = {
  76. [UPDATE_MODEL_EVENT]: (val) => isBoolean(val) || isString(val) || isNumber(val),
  77. [CHANGE_EVENT]: (val) => isBoolean(val) || isString(val) || isNumber(val),
  78. [INPUT_EVENT]: (val) => isBoolean(val) || isString(val) || isNumber(val)
  79. };
  80. //#endregion
  81. export { switchEmits, switchProps };
  82. //# sourceMappingURL=switch.mjs.map