@vuesax-alpha/nightly
Version:
A Component Library for Vue 3
1 lines • 4.63 kB
Source Map (JSON)
{"version":3,"file":"input-number.mjs","sources":["../../../../../../packages/components/input-number/src/input-number.ts"],"sourcesContent":["import { isNil } from 'lodash-unified'\nimport { buildProps, isNumber } from '@vuesax-alpha/utils'\nimport {\n CHANGE_EVENT,\n INPUT_EVENT,\n UPDATE_MODEL_EVENT,\n} from '@vuesax-alpha/constants'\nimport { useColorProp } from '@vuesax-alpha/hooks'\nimport type { ExtractPropTypes } from 'vue'\nimport type InputNumber from './input-number.vue'\n\nexport const inputNumberProps = buildProps({\n color: useColorProp,\n background: useColorProp,\n /**\n * @description same as `id` in native input\n */\n id: {\n type: String,\n default: undefined,\n },\n /**\n * @description incremental step\n */\n step: {\n type: Number,\n default: 1,\n },\n /**\n * @description whether input value can only be multiple of step\n */\n stepStrictly: { type: Boolean },\n /**\n * @description the maximum allowed value\n */\n max: {\n type: Number,\n default: Number.POSITIVE_INFINITY,\n },\n /**\n * @description the minimum allowed value\n */\n min: {\n type: Number,\n default: Number.NEGATIVE_INFINITY,\n },\n /**\n * @description binding value\n */\n modelValue: { type: Number },\n /**\n * @description same as `readonly` in native input\n */\n readonly: { type: Boolean },\n /**\n * @description whether the component is disabled\n */\n disabled: { type: Boolean },\n /**\n * @description whether to enable the control buttons\n */\n controls: {\n type: Boolean,\n default: true,\n },\n\n /**\n * @description value should be set when input box is cleared\n */\n valueOnClear: {\n type: [String, Number, null],\n validator: (val: 'min' | 'max' | number | null) =>\n val === null || isNumber(val) || ['min', 'max'].includes(val),\n default: null,\n },\n /**\n * @description same as `name` in native input\n */\n name: { type: String },\n /**\n * @description same as `label` in native input\n */\n label: { type: String },\n /**\n * @description same as `placeholder` in native input\n */\n placeholder: { type: String },\n /**\n * @description precision of input value\n */\n precision: {\n type: Number,\n validator: (val: number) =>\n val >= 0 && val === Number.parseInt(`${val}`, 10),\n },\n} as const)\nexport type InputNumberProps = ExtractPropTypes<typeof inputNumberProps>\n\nexport const inputNumberEmits = {\n [CHANGE_EVENT]: (cur: number | undefined, prev: number | undefined) =>\n prev !== cur,\n blur: (e: FocusEvent) => e instanceof FocusEvent,\n focus: (e: FocusEvent) => e instanceof FocusEvent,\n [INPUT_EVENT]: (val: number | null | undefined) =>\n isNumber(val) || isNil(val),\n [UPDATE_MODEL_EVENT]: (val: number | undefined) =>\n isNumber(val) || isNil(val),\n}\nexport type InputNumberEmits = typeof inputNumberEmits\n\nexport type InputNumberInstance = InstanceType<typeof InputNumber>\n"],"names":[],"mappings":";;;;;;;;;AAWO,MAAM,mBAAmB,UAAW,CAAA;AAAA,EACzC,KAAO,EAAA,YAAA;AAAA,EACP,UAAY,EAAA,YAAA;AAAA,EAIZ,EAAI,EAAA;AAAA,IACF,IAAM,EAAA,MAAA;AAAA,IACN,OAAS,EAAA,KAAA,CAAA;AAAA,GACX;AAAA,EAIA,IAAM,EAAA;AAAA,IACJ,IAAM,EAAA,MAAA;AAAA,IACN,OAAS,EAAA,CAAA;AAAA,GACX;AAAA,EAIA,YAAA,EAAc,EAAE,IAAA,EAAM,OAAQ,EAAA;AAAA,EAI9B,GAAK,EAAA;AAAA,IACH,IAAM,EAAA,MAAA;AAAA,IACN,SAAS,MAAO,CAAA,iBAAA;AAAA,GAClB;AAAA,EAIA,GAAK,EAAA;AAAA,IACH,IAAM,EAAA,MAAA;AAAA,IACN,SAAS,MAAO,CAAA,iBAAA;AAAA,GAClB;AAAA,EAIA,UAAA,EAAY,EAAE,IAAA,EAAM,MAAO,EAAA;AAAA,EAI3B,QAAA,EAAU,EAAE,IAAA,EAAM,OAAQ,EAAA;AAAA,EAI1B,QAAA,EAAU,EAAE,IAAA,EAAM,OAAQ,EAAA;AAAA,EAI1B,QAAU,EAAA;AAAA,IACR,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,IAAA;AAAA,GACX;AAAA,EAKA,YAAc,EAAA;AAAA,IACZ,IAAM,EAAA,CAAC,MAAQ,EAAA,MAAA,EAAQ,IAA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