UNPKG

element-plus

Version:

A Component Library for Vue 3

137 lines (134 loc) 3.16 kB
import { isNil } from 'lodash-unified'; import { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs'; import { useAriaProps } from '../../../hooks/use-aria/index.mjs'; import { isNumber } from '../../../utils/types.mjs'; import { useSizeProp } from '../../../hooks/use-size/index.mjs'; import { UPDATE_MODEL_EVENT, INPUT_EVENT, CHANGE_EVENT } from '../../../constants/event.mjs'; const inputNumberProps = buildProps({ /** * @description same as `id` in native input */ id: { type: String, default: void 0 }, /** * @description incremental step */ step: { type: Number, default: 1 }, /** * @description whether input value can only be multiple of step */ stepStrictly: Boolean, /** * @description the maximum allowed value */ max: { type: Number, default: Number.MAX_SAFE_INTEGER }, /** * @description the minimum allowed value */ min: { type: Number, default: Number.MIN_SAFE_INTEGER }, /** * @description binding value */ modelValue: { type: [Number, null] }, /** * @description same as `readonly` in native input */ readonly: Boolean, /** * @description whether the component is disabled */ disabled: { type: Boolean, default: void 0 }, /** * @description size of the component */ size: useSizeProp, /** * @description whether to enable the control buttons */ controls: { type: Boolean, default: true }, /** * @description position of the control buttons */ controlsPosition: { type: String, default: "", values: ["", "right"] }, /** * @description value should be set when input box is cleared */ valueOnClear: { type: definePropType([String, Number, null]), validator: (val) => val === null || isNumber(val) || ["min", "max"].includes(val), default: null }, /** * @description same as `name` in native input */ name: String, /** * @description same as `placeholder` in native input */ placeholder: String, /** * @description precision of input value */ precision: { type: Number, validator: (val) => val >= 0 && val === Number.parseInt(`${val}`, 10) }, /** * @description whether to trigger form validation */ validateEvent: { type: Boolean, default: true }, ...useAriaProps(["ariaLabel"]), /** * @description native input mode for virtual keyboards */ inputmode: { type: definePropType(String), default: void 0 }, /** * @description alignment for the inner input text */ align: { type: definePropType(String), default: "center" }, /** * @description whether to disable scientific notation input (e.g. 'e', 'E') */ disabledScientific: Boolean }); const inputNumberEmits = { [CHANGE_EVENT]: (cur, prev) => prev !== cur, blur: (e) => e instanceof FocusEvent, focus: (e) => e instanceof FocusEvent, [INPUT_EVENT]: (val) => isNumber(val) || isNil(val), [UPDATE_MODEL_EVENT]: (val) => isNumber(val) || isNil(val) }; export { inputNumberEmits, inputNumberProps }; //# sourceMappingURL=input-number.mjs.map