{"version":3,"file":"switch.mjs","names":[],"sources":["../../../../../../packages/components/switch/src/switch.ts"],"sourcesContent":["import {\n  buildProps,\n  definePropType,\n  iconPropType,\n  isBoolean,\n  isNumber,\n  isString,\n  isValidComponentSize,\n} from '@element-plus/utils'\nimport {\n  CHANGE_EVENT,\n  INPUT_EVENT,\n  UPDATE_MODEL_EVENT,\n} from '@element-plus/constants'\nimport { useAriaProps } from '@element-plus/hooks'\n\nimport type { ComponentSize } from '@element-plus/constants'\nimport type { ExtractPublicPropTypes, PropType } from 'vue'\nimport type { IconPropType } from '@element-plus/utils'\nimport type Switch from './switch.vue'\n\nexport interface SwitchProps {\n  /**\n   * @description binding value, it should be equivalent to either `active-value` or `inactive-value`, by default it's `boolean` type\n   */\n  modelValue?: boolean | string | number\n  /**\n   * @description whether Switch is disabled\n   */\n  disabled?: boolean\n  /**\n   * @description whether Switch is in loading state\n   */\n  loading?: boolean\n  /**\n   * @description size of Switch\n   */\n  size?: ComponentSize\n  /**\n   * @description width of Switch\n   */\n  width?: string | number\n  /**\n   * @description whether icon or text is displayed inside dot, only the first character will be rendered for text\n   */\n  inlinePrompt?: boolean\n  /**\n   * @description component of the icon displayed in action when in `off` state\n   */\n  inactiveActionIcon?: IconPropType\n  /**\n   * @description component of the icon displayed in action when in `on` state\n   */\n  activeActionIcon?: IconPropType\n  /**\n   * @description component of the icon displayed when in `on` state, overrides `active-text`\n   */\n  activeIcon?: IconPropType\n  /**\n   * @description component of the icon displayed when in `off` state, overrides `inactive-text`\n   */\n  inactiveIcon?: IconPropType\n  /**\n   * @description text displayed when in `on` state\n   */\n  activeText?: string\n  /**\n   * @description text displayed when in `off` state\n   */\n  inactiveText?: string\n  /**\n   * @description switch value when in `on` state\n   */\n  activeValue?: boolean | string | number\n  /**\n   * @description switch value when in `off` state\n   */\n  inactiveValue?: boolean | string | number\n  /**\n   * @description input name of Switch\n   */\n  name?: string\n  /**\n   * @description whether to trigger form validation\n   */\n  validateEvent?: boolean\n  /**\n   * @description before-change hook before the switch state changes. If `false` is returned or a `Promise` is returned and then is rejected, will stop switching\n   */\n  beforeChange?: () => Promise<boolean> | boolean\n  /**\n   * @description id for input\n   */\n  id?: string\n  /**\n   * @description tabindex for input\n   */\n  tabindex?: string | number\n  /**\n   * @description native `aria-label` attribute\n   */\n  ariaLabel?: string\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `SwitchProps` instead.\n */\nexport const switchProps = buildProps({\n  /**\n   * @description binding value, it should be equivalent to either `active-value` or `inactive-value`, by default it's `boolean` type\n   */\n  modelValue: {\n    type: [Boolean, String, Number],\n    default: false,\n  },\n  /**\n   * @description whether Switch is disabled\n   */\n  disabled: {\n    type: Boolean,\n    default: undefined,\n  },\n  /**\n   * @description whether Switch is in loading state\n   */\n  loading: Boolean,\n  /**\n   * @description size of Switch\n   */\n  size: {\n    type: String as PropType<ComponentSize>,\n    validator: isValidComponentSize,\n  },\n  /**\n   * @description width of Switch\n   */\n  width: {\n    type: [String, Number],\n    default: '',\n  },\n  /**\n   * @description whether icon or text is displayed inside dot, only the first character will be rendered for text\n   */\n  inlinePrompt: Boolean,\n  /**\n   * @description component of the icon displayed in action when in `off` state\n   */\n  inactiveActionIcon: {\n    type: iconPropType,\n  },\n  /**\n   * @description component of the icon displayed in action when in `on` state\n   */\n  activeActionIcon: {\n    type: iconPropType,\n  },\n  /**\n   * @description component of the icon displayed when in `on` state, overrides `active-text`\n   */\n  activeIcon: {\n    type: iconPropType,\n  },\n  /**\n   * @description component of the icon displayed when in `off` state, overrides `inactive-text`\n   */\n  inactiveIcon: {\n    type: iconPropType,\n  },\n  /**\n   * @description text displayed when in `on` state\n   */\n  activeText: {\n    type: String,\n    default: '',\n  },\n  /**\n   * @description text displayed when in `off` state\n   */\n  inactiveText: {\n    type: String,\n    default: '',\n  },\n  /**\n   * @description switch value when in `on` state\n   */\n  activeValue: {\n    type: [Boolean, String, Number],\n    default: true,\n  },\n  /**\n   * @description switch value when in `off` state\n   */\n  inactiveValue: {\n    type: [Boolean, String, Number],\n    default: false,\n  },\n  /**\n   * @description input name of Switch\n   */\n  name: {\n    type: String,\n    default: '',\n  },\n  /**\n   * @description whether to trigger form validation\n   */\n  validateEvent: {\n    type: Boolean,\n    default: true,\n  },\n  /**\n   * @description before-change hook before the switch state changes. If `false` is returned or a `Promise` is returned and then is rejected, will stop switching\n   */\n  beforeChange: {\n    type: definePropType<() => Promise<boolean> | boolean>(Function),\n  },\n  /**\n   * @description id for input\n   */\n  id: String,\n  /**\n   * @description tabindex for input\n   */\n  tabindex: {\n    type: [String, Number],\n  },\n  ...useAriaProps(['ariaLabel']),\n} as const)\n\n/**\n * @deprecated Removed after 3.0.0, Use `SwitchProps` instead.\n */\nexport type SwitchPropsPublic = ExtractPublicPropTypes<typeof switchProps>\n\nexport const switchEmits = {\n  [UPDATE_MODEL_EVENT]: (val: boolean | string | number) =>\n    isBoolean(val) || isString(val) || isNumber(val),\n  [CHANGE_EVENT]: (val: boolean | string | number) =>\n    isBoolean(val) || isString(val) || isNumber(val),\n  [INPUT_EVENT]: (val: boolean | string | number) =>\n    isBoolean(val) || isString(val) || isNumber(val),\n}\nexport type SwitchEmits = typeof switchEmits\n\nexport type SwitchInstance = InstanceType<typeof Switch> & unknown\n"],"mappings":";;;;;;;;;;;AA2GA,MAAa,cAAc,WAAW;CAIpC,YAAY;EACV,MAAM;GAAC;GAAS;GAAQ;GAAO;EAC/B,SAAS;EACV;CAID,UAAU;EACR,MAAM;EACN,SAAS;EACV;CAID,SAAS;CAIT,MAAM;EACJ,MAAM;EACN,WAAW;EACZ;CAID,OAAO;EACL,MAAM,CAAC,QAAQ,OAAO;EACtB,SAAS;EACV;CAID,cAAc;CAId,oBAAoB,EAClB,MAAM,cACP;CAID,kBAAkB,EAChB,MAAM,cACP;CAID,YAAY,EACV,MAAM,cACP;CAID,cAAc,EACZ,MAAM,cACP;CAID,YAAY;EACV,MAAM;EACN,SAAS;EACV;CAID,cAAc;EACZ,MAAM;EACN,SAAS;EACV;CAID,aAAa;EACX,MAAM;GAAC;GAAS;GAAQ;GAAO;EAC/B,SAAS;EACV;CAID,eAAe;EACb,MAAM;GAAC;GAAS;GAAQ;GAAO;EAC/B,SAAS;EACV;CAID,MAAM;EACJ,MAAM;EACN,SAAS;EACV;CAID,eAAe;EACb,MAAM;EACN,SAAS;EACV;CAID,cAAc,EACZ,MAAM,eAAiD,SAAS,EACjE;CAID,IAAI;CAIJ,UAAU,EACR,MAAM,CAAC,QAAQ,OAAO,EACvB;CACD,GAAG,aAAa,CAAC,YAAY,CAAC;CAC/B,CAAU;AAOX,MAAa,cAAc;EACxB,sBAAsB,QACrB,UAAU,IAAI,IAAI,SAAS,IAAI,IAAI,SAAS,IAAI;EACjD,gBAAgB,QACf,UAAU,IAAI,IAAI,SAAS,IAAI,IAAI,SAAS,IAAI;EACjD,eAAe,QACd,UAAU,IAAI,IAAI,SAAS,IAAI,IAAI,SAAS,IAAI;CACnD"}