UNPKG

element-plus

Version:

A Component Library for Vue 3

138 lines (135 loc) 3.4 kB
import { isValidComponentSize } from '../../../utils/vue/validator.mjs'; import { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs'; import { useAriaProps } from '../../../hooks/use-aria/index.mjs'; import { iconPropType } from '../../../utils/vue/icon.mjs'; import { isBoolean, isNumber } from '../../../utils/types.mjs'; import { isString } from '@vue/shared'; import { INPUT_EVENT, CHANGE_EVENT, UPDATE_MODEL_EVENT } from '../../../constants/event.mjs'; const switchProps = buildProps({ /** * @description binding value, it should be equivalent to either `active-value` or `inactive-value`, by default it's `boolean` type */ modelValue: { type: [Boolean, String, Number], default: false }, /** * @description whether Switch is disabled */ disabled: { type: Boolean, default: void 0 }, /** * @description whether Switch is in loading state */ loading: Boolean, /** * @description size of Switch */ size: { type: String, validator: isValidComponentSize }, /** * @description width of Switch */ width: { type: [String, Number], default: "" }, /** * @description whether icon or text is displayed inside dot, only the first character will be rendered for text */ inlinePrompt: Boolean, /** * @description component of the icon displayed in action when in `off` state */ inactiveActionIcon: { type: iconPropType }, /** * @description component of the icon displayed in action when in `on` state */ activeActionIcon: { type: iconPropType }, /** * @description component of the icon displayed when in `on` state, overrides `active-text` */ activeIcon: { type: iconPropType }, /** * @description component of the icon displayed when in `off` state, overrides `inactive-text` */ inactiveIcon: { type: iconPropType }, /** * @description text displayed when in `on` state */ activeText: { type: String, default: "" }, /** * @description text displayed when in `off` state */ inactiveText: { type: String, default: "" }, /** * @description switch value when in `on` state */ activeValue: { type: [Boolean, String, Number], default: true }, /** * @description switch value when in `off` state */ inactiveValue: { type: [Boolean, String, Number], default: false }, /** * @description input name of Switch */ name: { type: String, default: "" }, /** * @description whether to trigger form validation */ validateEvent: { type: Boolean, default: true }, /** * @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 */ beforeChange: { type: definePropType(Function) }, /** * @description id for input */ id: String, /** * @description tabindex for input */ tabindex: { type: [String, Number] }, ...useAriaProps(["ariaLabel"]) }); const switchEmits = { [UPDATE_MODEL_EVENT]: (val) => isBoolean(val) || isString(val) || isNumber(val), [CHANGE_EVENT]: (val) => isBoolean(val) || isString(val) || isNumber(val), [INPUT_EVENT]: (val) => isBoolean(val) || isString(val) || isNumber(val) }; export { switchEmits, switchProps }; //# sourceMappingURL=switch.mjs.map