UNPKG

element-plus

Version:

A Component Library for Vue 3

140 lines (139 loc) 3.35 kB
import { CHANGE_EVENT, INPUT_EVENT, UPDATE_MODEL_EVENT } from "../../../constants/event.mjs"; import { isBoolean, isNumber, isString } from "../../../utils/types.mjs"; import { buildProps, definePropType } from "../../../utils/vue/props/runtime.mjs"; import { iconPropType } from "../../../utils/vue/icon.mjs"; import { isValidComponentSize } from "../../../utils/vue/validator.mjs"; import { useAriaProps } from "../../../hooks/use-aria/index.mjs"; //#region ../../packages/components/switch/src/switch.ts /** * @deprecated Removed after 3.0.0, Use `SwitchProps` instead. */ 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) }; //#endregion export { switchEmits, switchProps }; //# sourceMappingURL=switch.mjs.map