checkbox-group.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { UPDATE_MODEL_EVENT } from '@element-plus/constants'
  2. import { useSizeProp } from '@element-plus/hooks'
  3. import { buildProps, definePropType, isArray } from '@element-plus/utils'
  4. import type { ExtractPropTypes } from 'vue'
  5. import type checkboxGroup from './checkbox-group.vue'
  6. import type { CheckboxValueType } from './checkbox'
  7. export type CheckboxGroupValueType = Exclude<CheckboxValueType, boolean>[]
  8. export const checkboxGroupProps = buildProps({
  9. /**
  10. * @description binding value
  11. */
  12. modelValue: {
  13. type: definePropType<CheckboxGroupValueType>(Array),
  14. default: () => [],
  15. },
  16. /**
  17. * @description whether the nesting checkboxes are disabled
  18. */
  19. disabled: Boolean,
  20. /**
  21. * @description minimum number of checkbox checked
  22. */
  23. min: Number,
  24. /**
  25. * @description maximum number of checkbox checked
  26. */
  27. max: Number,
  28. /**
  29. * @description size of checkbox
  30. */
  31. size: useSizeProp,
  32. /**
  33. * @description label for screen reader
  34. */
  35. label: String,
  36. /**
  37. * @description border and background color when button is active
  38. */
  39. fill: String,
  40. /**
  41. * @description font color when button is active
  42. */
  43. textColor: String,
  44. /**
  45. * @description element tag of the checkbox group
  46. */
  47. tag: {
  48. type: String,
  49. default: 'div',
  50. },
  51. /**
  52. * @description whether to trigger form validation
  53. */
  54. validateEvent: {
  55. type: Boolean,
  56. default: true,
  57. },
  58. } as const)
  59. export const checkboxGroupEmits = {
  60. [UPDATE_MODEL_EVENT]: (val: CheckboxGroupValueType) => isArray(val),
  61. change: (val: CheckboxValueType[]) => isArray(val),
  62. }
  63. export type CheckboxGroupProps = ExtractPropTypes<typeof checkboxGroupProps>
  64. export type CheckboxGroupEmits = typeof checkboxGroupEmits
  65. export type CheckboxGroupInstance = InstanceType<typeof checkboxGroup>