vxe-pc-ui 4.5.32 → 4.5.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/form/style.css +12 -12
- package/es/form/style.min.css +1 -1
- package/es/icon/style.css +1 -1
- package/es/input/src/input.js +2 -2
- package/es/number-input/src/number-input.js +248 -165
- package/es/number-input/style.css +74 -770
- package/es/number-input/style.min.css +1 -1
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/tooltip/style.css +1 -1
- package/es/tooltip/style.min.css +1 -1
- package/es/ui/index.js +11 -4
- package/es/ui/src/dom.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/es/vxe-form/style.css +12 -12
- package/es/vxe-form/style.min.css +1 -1
- package/es/vxe-number-input/style.css +74 -770
- package/es/vxe-number-input/style.min.css +1 -1
- package/es/vxe-tooltip/style.css +1 -1
- package/es/vxe-tooltip/style.min.css +1 -1
- package/lib/form/style/style.css +12 -12
- package/lib/form/style/style.min.css +1 -1
- package/lib/icon/style/style.css +1 -1
- package/lib/icon/style/style.min.css +1 -1
- package/lib/index.umd.js +255 -160
- package/lib/index.umd.min.js +1 -1
- package/lib/input/src/input.js +2 -2
- package/lib/input/src/input.min.js +1 -1
- package/lib/number-input/src/number-input.js +240 -152
- package/lib/number-input/src/number-input.min.js +1 -1
- package/lib/number-input/style/style.css +74 -770
- package/lib/number-input/style/style.min.css +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/tooltip/style/style.css +1 -1
- package/lib/tooltip/style/style.min.css +1 -1
- package/lib/ui/index.js +11 -4
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/dom.js +1 -1
- package/lib/ui/src/dom.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/lib/vxe-form/style/style.css +12 -12
- package/lib/vxe-form/style/style.min.css +1 -1
- package/lib/vxe-number-input/style/style.css +74 -770
- package/lib/vxe-number-input/style/style.min.css +1 -1
- package/lib/vxe-tooltip/style/style.css +1 -1
- package/lib/vxe-tooltip/style/style.min.css +1 -1
- package/package.json +1 -1
- package/packages/input/src/input.ts +2 -2
- package/packages/number-input/src/number-input.ts +264 -177
- package/packages/ui/index.ts +10 -3
- package/packages/ui/src/dom.ts +1 -1
- package/styles/components/form.scss +12 -12
- package/styles/components/number-input.scss +73 -598
- package/styles/components/tooltip.scss +1 -1
- package/styles/theme/base.scss +4 -4
- package/styles/theme/dark.scss +3 -0
- package/styles/theme/light.scss +3 -0
- package/types/components/number-input.d.ts +80 -6
- package/types/ui/global-icon.d.ts +4 -2
- /package/es/icon/{iconfont.1745800497803.ttf → iconfont.1745889662360.ttf} +0 -0
- /package/es/icon/{iconfont.1745800497803.woff → iconfont.1745889662360.woff} +0 -0
- /package/es/icon/{iconfont.1745800497803.woff2 → iconfont.1745889662360.woff2} +0 -0
- /package/es/{iconfont.1745800497803.ttf → iconfont.1745889662360.ttf} +0 -0
- /package/es/{iconfont.1745800497803.woff → iconfont.1745889662360.woff} +0 -0
- /package/es/{iconfont.1745800497803.woff2 → iconfont.1745889662360.woff2} +0 -0
- /package/lib/icon/style/{iconfont.1745800497803.ttf → iconfont.1745889662360.ttf} +0 -0
- /package/lib/icon/style/{iconfont.1745800497803.woff → iconfont.1745889662360.woff} +0 -0
- /package/lib/icon/style/{iconfont.1745800497803.woff2 → iconfont.1745889662360.woff2} +0 -0
- /package/lib/{iconfont.1745800497803.ttf → iconfont.1745889662360.ttf} +0 -0
- /package/lib/{iconfont.1745800497803.woff → iconfont.1745889662360.woff} +0 -0
- /package/lib/{iconfont.1745800497803.woff2 → iconfont.1745889662360.woff2} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { defineComponent, h, ref, Ref, computed, reactive, inject, nextTick, watch, onMounted,
|
|
1
|
+
import { defineComponent, h, ref, Ref, computed, reactive, inject, nextTick, watch, onMounted, onBeforeUnmount, PropType } from 'vue'
|
|
2
2
|
import XEUtils from 'xe-utils'
|
|
3
|
-
import { getConfig, getIcon, getI18n, globalEvents, GLOBAL_EVENT_KEYS, createEvent, useSize } from '../../ui'
|
|
4
|
-
import { getFuncText, eqEmptyValue } from '../../ui/src/utils'
|
|
3
|
+
import { getConfig, getIcon, getI18n, globalEvents, GLOBAL_EVENT_KEYS, createEvent, useSize, renderEmptyElement } from '../../ui'
|
|
4
|
+
import { getFuncText, eqEmptyValue, isEnableConf } from '../../ui/src/utils'
|
|
5
5
|
import { hasClass, getEventTargetNode, hasControlKey } from '../../ui/src/dom'
|
|
6
6
|
import { getSlotVNs } from '../../ui/src/vn'
|
|
7
7
|
import { handleNumber, toFloatValueFixed } from './util'
|
|
8
8
|
|
|
9
|
-
import type { VxeNumberInputConstructor, NumberInputInternalData, VxeNumberInputEmits, NumberInputReactData, NumberInputMethods, VxeNumberInputPropTypes, InputPrivateRef, VxeFormConstructor, VxeFormPrivateMethods, VxeFormDefines, ValueOf } from '../../../types'
|
|
9
|
+
import type { VxeNumberInputConstructor, NumberInputInternalData, VxeNumberInputEmits, VxeNumberInputPrivateComputed, NumberInputReactData, NumberInputMethods, VxeNumberInputPropTypes, InputPrivateRef, VxeFormConstructor, VxeFormPrivateMethods, VxeFormDefines, ValueOf } from '../../../types'
|
|
10
10
|
|
|
11
11
|
export default defineComponent({
|
|
12
12
|
name: 'VxeNumberInput',
|
|
@@ -72,12 +72,7 @@ export default defineComponent({
|
|
|
72
72
|
type: String as PropType<VxeNumberInputPropTypes.CurrencySymbol>,
|
|
73
73
|
default: () => getConfig().numberInput.currencySymbol
|
|
74
74
|
},
|
|
75
|
-
|
|
76
|
-
// number、integer、float
|
|
77
|
-
controls: {
|
|
78
|
-
type: Boolean as PropType<VxeNumberInputPropTypes.Controls>,
|
|
79
|
-
default: () => getConfig().numberInput.controls
|
|
80
|
-
},
|
|
75
|
+
controlConfig: Object as PropType<VxeNumberInputPropTypes.ControlConfig>,
|
|
81
76
|
|
|
82
77
|
// float
|
|
83
78
|
digits: {
|
|
@@ -93,9 +88,16 @@ export default defineComponent({
|
|
|
93
88
|
default: true
|
|
94
89
|
},
|
|
95
90
|
|
|
91
|
+
plusIcon: String as PropType<VxeNumberInputPropTypes.PlusIcon>,
|
|
92
|
+
minusIcon: String as PropType<VxeNumberInputPropTypes.MinusIcon>,
|
|
96
93
|
prefixIcon: String as PropType<VxeNumberInputPropTypes.PrefixIcon>,
|
|
97
94
|
suffixIcon: String as PropType<VxeNumberInputPropTypes.SuffixIcon>,
|
|
98
95
|
|
|
96
|
+
// 已废弃
|
|
97
|
+
controls: {
|
|
98
|
+
type: Boolean as PropType<VxeNumberInputPropTypes.Controls>,
|
|
99
|
+
default: null
|
|
100
|
+
},
|
|
99
101
|
// 已废弃
|
|
100
102
|
maxlength: [String, Number] as PropType<VxeNumberInputPropTypes.Maxlength>,
|
|
101
103
|
// 已废弃
|
|
@@ -112,10 +114,14 @@ export default defineComponent({
|
|
|
112
114
|
'focus',
|
|
113
115
|
'blur',
|
|
114
116
|
'clear',
|
|
115
|
-
'
|
|
116
|
-
'
|
|
117
|
+
'plus-number',
|
|
118
|
+
'minus-number',
|
|
117
119
|
'prefix-click',
|
|
118
|
-
'suffix-click'
|
|
120
|
+
'suffix-click',
|
|
121
|
+
|
|
122
|
+
// 已废弃
|
|
123
|
+
'prev-number',
|
|
124
|
+
'next-number'
|
|
119
125
|
] as VxeNumberInputEmits,
|
|
120
126
|
|
|
121
127
|
setup (props, context) {
|
|
@@ -135,6 +141,8 @@ export default defineComponent({
|
|
|
135
141
|
|
|
136
142
|
const internalData: NumberInputInternalData = {
|
|
137
143
|
// dnTimeout: undefined,
|
|
144
|
+
// ainTimeout: undefined,
|
|
145
|
+
// isMouseDown: undefined,
|
|
138
146
|
// isUM: undefined
|
|
139
147
|
}
|
|
140
148
|
|
|
@@ -142,22 +150,6 @@ export default defineComponent({
|
|
|
142
150
|
const refInputTarget = ref() as Ref<HTMLInputElement>
|
|
143
151
|
const refInputPanel = ref() as Ref<HTMLDivElement>
|
|
144
152
|
|
|
145
|
-
const refMaps: InputPrivateRef = {
|
|
146
|
-
refElem,
|
|
147
|
-
refInput: refInputTarget
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const $xeNumberInput = {
|
|
151
|
-
xID,
|
|
152
|
-
props,
|
|
153
|
-
context,
|
|
154
|
-
reactData,
|
|
155
|
-
internalData,
|
|
156
|
-
getRefMaps: () => refMaps
|
|
157
|
-
} as unknown as VxeNumberInputConstructor
|
|
158
|
-
|
|
159
|
-
let numberInputMethods = {} as NumberInputMethods
|
|
160
|
-
|
|
161
153
|
const computeFormReadonly = computed(() => {
|
|
162
154
|
const { readonly } = props
|
|
163
155
|
if (readonly === null) {
|
|
@@ -194,6 +186,10 @@ export default defineComponent({
|
|
|
194
186
|
return XEUtils.toInteger(defDigits) || 1
|
|
195
187
|
})
|
|
196
188
|
|
|
189
|
+
const computeControlOpts = computed(() => {
|
|
190
|
+
return Object.assign({}, getConfig().numberInput.controlConfig, props.controlConfig)
|
|
191
|
+
})
|
|
192
|
+
|
|
197
193
|
const computeDecimalsType = computed(() => {
|
|
198
194
|
const { type } = props
|
|
199
195
|
return type === 'float' || type === 'amount'
|
|
@@ -295,6 +291,27 @@ export default defineComponent({
|
|
|
295
291
|
return false
|
|
296
292
|
})
|
|
297
293
|
|
|
294
|
+
const refMaps: InputPrivateRef = {
|
|
295
|
+
refElem,
|
|
296
|
+
refInput: refInputTarget
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const computeMaps: VxeNumberInputPrivateComputed = {
|
|
300
|
+
computeControlOpts
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const $xeNumberInput = {
|
|
304
|
+
xID,
|
|
305
|
+
props,
|
|
306
|
+
context,
|
|
307
|
+
reactData,
|
|
308
|
+
internalData,
|
|
309
|
+
getRefMaps: () => refMaps,
|
|
310
|
+
getComputeMaps: () => computeMaps
|
|
311
|
+
} as unknown as VxeNumberInputConstructor
|
|
312
|
+
|
|
313
|
+
let numberInputMethods = {} as NumberInputMethods
|
|
314
|
+
|
|
298
315
|
const handleNumberString = (val: any) => {
|
|
299
316
|
if (XEUtils.eqNull(val)) {
|
|
300
317
|
return ''
|
|
@@ -532,34 +549,29 @@ export default defineComponent({
|
|
|
532
549
|
emitInputEvent(getNumberValue(restNum), evnt as (Event & { type: 'input' }))
|
|
533
550
|
}
|
|
534
551
|
|
|
535
|
-
const
|
|
552
|
+
const numberPlusEvent = (evnt: Event) => {
|
|
536
553
|
const isDisabled = computeIsDisabled.value
|
|
537
554
|
const formReadonly = computeFormReadonly.value
|
|
538
|
-
const
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
numberChange(false, evnt)
|
|
555
|
+
const isDisabledAddNumber = computeIsDisabledAddNumber.value
|
|
556
|
+
if (!isDisabled && !formReadonly && !isDisabledAddNumber) {
|
|
557
|
+
numberChange(true, evnt)
|
|
542
558
|
}
|
|
543
559
|
reactData.isActivated = true
|
|
560
|
+
numberInputMethods.dispatchEvent('plus-number', { value: reactData.inputValue }, evnt)
|
|
561
|
+
// 已废弃
|
|
544
562
|
numberInputMethods.dispatchEvent('next-number', { value: reactData.inputValue }, evnt)
|
|
545
563
|
}
|
|
546
564
|
|
|
547
|
-
const
|
|
548
|
-
internalData.dnTimeout = setTimeout(() => {
|
|
549
|
-
numberNextEvent(evnt)
|
|
550
|
-
numberDownNextEvent(evnt)
|
|
551
|
-
}, 60)
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
const numberPrevEvent = (evnt: Event) => {
|
|
565
|
+
const numberMinusEvent = (evnt: Event) => {
|
|
555
566
|
const isDisabled = computeIsDisabled.value
|
|
556
567
|
const formReadonly = computeFormReadonly.value
|
|
557
|
-
const
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
numberChange(true, evnt)
|
|
568
|
+
const isDisabledSubtractNumber = computeIsDisabledSubtractNumber.value
|
|
569
|
+
if (!isDisabled && !formReadonly && !isDisabledSubtractNumber) {
|
|
570
|
+
numberChange(false, evnt)
|
|
561
571
|
}
|
|
562
572
|
reactData.isActivated = true
|
|
573
|
+
numberInputMethods.dispatchEvent('minus-number', { value: reactData.inputValue }, evnt)
|
|
574
|
+
// 已废弃
|
|
563
575
|
numberInputMethods.dispatchEvent('prev-number', { value: reactData.inputValue }, evnt)
|
|
564
576
|
}
|
|
565
577
|
|
|
@@ -569,15 +581,17 @@ export default defineComponent({
|
|
|
569
581
|
if (isUpArrow || isDwArrow) {
|
|
570
582
|
evnt.preventDefault()
|
|
571
583
|
if (isUpArrow) {
|
|
572
|
-
|
|
584
|
+
numberMinusEvent(evnt)
|
|
573
585
|
} else {
|
|
574
|
-
|
|
586
|
+
numberPlusEvent(evnt)
|
|
575
587
|
}
|
|
576
588
|
}
|
|
577
589
|
}
|
|
578
590
|
|
|
579
591
|
const keydownEvent = (evnt: KeyboardEvent & { type: 'keydown' }) => {
|
|
580
592
|
const { type, exponential, controls } = props
|
|
593
|
+
const controlOpts = computeControlOpts.value
|
|
594
|
+
const { showButton } = controlOpts
|
|
581
595
|
const inputReadonly = computeInputReadonly.value
|
|
582
596
|
const isControlKey = hasControlKey(evnt)
|
|
583
597
|
const isShiftKey = evnt.shiftKey
|
|
@@ -594,7 +608,7 @@ export default defineComponent({
|
|
|
594
608
|
if (isEsc) {
|
|
595
609
|
afterCheckValue()
|
|
596
610
|
} else if (isUpArrow || isDwArrow) {
|
|
597
|
-
if (controls && !inputReadonly) {
|
|
611
|
+
if (isEnableConf(controlOpts) && (controls === false ? controls : showButton) && !inputReadonly) {
|
|
598
612
|
numberKeydownEvent(evnt)
|
|
599
613
|
}
|
|
600
614
|
}
|
|
@@ -606,8 +620,7 @@ export default defineComponent({
|
|
|
606
620
|
}
|
|
607
621
|
|
|
608
622
|
// 数值
|
|
609
|
-
|
|
610
|
-
const numberStopDown = () => {
|
|
623
|
+
const stopDown = () => {
|
|
611
624
|
const { dnTimeout } = internalData
|
|
612
625
|
if (dnTimeout) {
|
|
613
626
|
clearTimeout(dnTimeout)
|
|
@@ -615,27 +628,64 @@ export default defineComponent({
|
|
|
615
628
|
}
|
|
616
629
|
}
|
|
617
630
|
|
|
618
|
-
const
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
631
|
+
const stopAutoIncrement = () => {
|
|
632
|
+
const { ainTimeout } = internalData
|
|
633
|
+
if (ainTimeout) {
|
|
634
|
+
clearTimeout(ainTimeout)
|
|
635
|
+
internalData.ainTimeout = undefined
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
const numberDownMinusEvent = (evnt: Event) => {
|
|
640
|
+
numberStopAll()
|
|
641
|
+
internalData.ainTimeout = setTimeout(() => {
|
|
642
|
+
numberMinusEvent(evnt)
|
|
643
|
+
numberDownMinusEvent(evnt)
|
|
622
644
|
}, 60)
|
|
623
645
|
}
|
|
624
646
|
|
|
647
|
+
const numberDownPlusEvent = (evnt: Event) => {
|
|
648
|
+
numberStopAll()
|
|
649
|
+
internalData.ainTimeout = setTimeout(() => {
|
|
650
|
+
numberPlusEvent(evnt)
|
|
651
|
+
numberDownPlusEvent(evnt)
|
|
652
|
+
}, 60)
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
const numberStopAll = () => {
|
|
656
|
+
stopDown()
|
|
657
|
+
stopAutoIncrement()
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
const numberClickEvent = (evnt: MouseEvent) => {
|
|
661
|
+
if (internalData.isMouseDown) {
|
|
662
|
+
internalData.isMouseDown = false
|
|
663
|
+
} else {
|
|
664
|
+
numberStopAll()
|
|
665
|
+
const isAddNumber = hasClass(evnt.currentTarget, 'is--plus')
|
|
666
|
+
if (isAddNumber) {
|
|
667
|
+
numberPlusEvent(evnt)
|
|
668
|
+
} else {
|
|
669
|
+
numberMinusEvent(evnt)
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
|
|
625
674
|
const numberMousedownEvent = (evnt: MouseEvent) => {
|
|
626
|
-
|
|
675
|
+
numberStopAll()
|
|
676
|
+
internalData.isMouseDown = true
|
|
627
677
|
if (evnt.button === 0) {
|
|
628
|
-
const
|
|
629
|
-
if (
|
|
630
|
-
|
|
678
|
+
const isAddNumber = hasClass(evnt.currentTarget, 'is--plus')
|
|
679
|
+
if (isAddNumber) {
|
|
680
|
+
numberPlusEvent(evnt)
|
|
631
681
|
} else {
|
|
632
|
-
|
|
682
|
+
numberMinusEvent(evnt)
|
|
633
683
|
}
|
|
634
684
|
internalData.dnTimeout = setTimeout(() => {
|
|
635
|
-
if (
|
|
636
|
-
|
|
685
|
+
if (isAddNumber) {
|
|
686
|
+
numberDownPlusEvent(evnt)
|
|
637
687
|
} else {
|
|
638
|
-
|
|
688
|
+
numberDownMinusEvent(evnt)
|
|
639
689
|
}
|
|
640
690
|
}, 500)
|
|
641
691
|
}
|
|
@@ -645,16 +695,19 @@ export default defineComponent({
|
|
|
645
695
|
type: 'wheel';
|
|
646
696
|
wheelDelta: number;
|
|
647
697
|
}) => {
|
|
698
|
+
const { controls } = props
|
|
699
|
+
const controlOpts = computeControlOpts.value
|
|
700
|
+
const { isWheel } = controlOpts
|
|
648
701
|
const inputReadonly = computeInputReadonly.value
|
|
649
|
-
if (
|
|
702
|
+
if (isEnableConf(controlOpts) && (controls === false ? controls : isWheel) && !inputReadonly) {
|
|
650
703
|
if (reactData.isActivated) {
|
|
651
704
|
evnt.stopPropagation()
|
|
652
705
|
evnt.preventDefault()
|
|
653
706
|
const delta = evnt.deltaY
|
|
654
707
|
if (delta > 0) {
|
|
655
|
-
|
|
708
|
+
numberPlusEvent(evnt)
|
|
656
709
|
} else if (delta < 0) {
|
|
657
|
-
|
|
710
|
+
numberMinusEvent(evnt)
|
|
658
711
|
}
|
|
659
712
|
}
|
|
660
713
|
}
|
|
@@ -716,43 +769,38 @@ export default defineComponent({
|
|
|
716
769
|
}
|
|
717
770
|
}
|
|
718
771
|
|
|
719
|
-
const
|
|
720
|
-
|
|
721
|
-
const isDisabledSubtractNumber = computeIsDisabledSubtractNumber.value
|
|
722
|
-
return h('div', {
|
|
723
|
-
class: 'vxe-input--control-icon'
|
|
724
|
-
}, [
|
|
725
|
-
h('div', {
|
|
726
|
-
class: 'vxe-input--number-icon'
|
|
727
|
-
}, [
|
|
728
|
-
h('div', {
|
|
729
|
-
class: ['vxe-input--number-btn is--prev', {
|
|
730
|
-
'is--disabled': isDisabledAddNumber
|
|
731
|
-
}],
|
|
732
|
-
onMousedown: numberMousedownEvent,
|
|
733
|
-
onMouseup: numberStopDown,
|
|
734
|
-
onMouseleave: numberStopDown
|
|
735
|
-
}, [
|
|
736
|
-
h('i', {
|
|
737
|
-
class: getIcon().NUMBER_INPUT_PREV_NUM
|
|
738
|
-
})
|
|
739
|
-
]),
|
|
740
|
-
h('div', {
|
|
741
|
-
class: ['vxe-input--number-btn is--next', {
|
|
742
|
-
'is--disabled': isDisabledSubtractNumber
|
|
743
|
-
}],
|
|
744
|
-
onMousedown: numberMousedownEvent,
|
|
745
|
-
onMouseup: numberStopDown,
|
|
746
|
-
onMouseleave: numberStopDown
|
|
747
|
-
}, [
|
|
748
|
-
h('i', {
|
|
749
|
-
class: getIcon().NUMBER_INPUT_NEXT_NUM
|
|
750
|
-
})
|
|
751
|
-
])
|
|
752
|
-
])
|
|
753
|
-
])
|
|
772
|
+
const dispatchEvent = (type: ValueOf<VxeNumberInputEmits>, params: Record<string, any>, evnt: Event | null) => {
|
|
773
|
+
emit(type, createEvent(evnt, { $numberInput: $xeNumberInput }, params))
|
|
754
774
|
}
|
|
755
775
|
|
|
776
|
+
numberInputMethods = {
|
|
777
|
+
dispatchEvent,
|
|
778
|
+
|
|
779
|
+
focus () {
|
|
780
|
+
const inputReadonly = computeInputReadonly.value
|
|
781
|
+
if (!inputReadonly) {
|
|
782
|
+
const inputElem = refInputTarget.value
|
|
783
|
+
reactData.isActivated = true
|
|
784
|
+
inputElem.focus()
|
|
785
|
+
}
|
|
786
|
+
return nextTick()
|
|
787
|
+
},
|
|
788
|
+
blur () {
|
|
789
|
+
const inputElem = refInputTarget.value
|
|
790
|
+
inputElem.blur()
|
|
791
|
+
reactData.isActivated = false
|
|
792
|
+
return nextTick()
|
|
793
|
+
},
|
|
794
|
+
select () {
|
|
795
|
+
const inputElem = refInputTarget.value
|
|
796
|
+
inputElem.select()
|
|
797
|
+
reactData.isActivated = false
|
|
798
|
+
return nextTick()
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
Object.assign($xeNumberInput, numberInputMethods)
|
|
803
|
+
|
|
756
804
|
const renderPrefixIcon = () => {
|
|
757
805
|
const { prefixIcon } = props
|
|
758
806
|
const prefixSlot = slots.prefix
|
|
@@ -771,7 +819,7 @@ export default defineComponent({
|
|
|
771
819
|
})
|
|
772
820
|
])
|
|
773
821
|
])
|
|
774
|
-
:
|
|
822
|
+
: renderEmptyElement($xeNumberInput)
|
|
775
823
|
}
|
|
776
824
|
|
|
777
825
|
const renderSuffixIcon = () => {
|
|
@@ -794,8 +842,7 @@ export default defineComponent({
|
|
|
794
842
|
class: getIcon().INPUT_CLEAR
|
|
795
843
|
})
|
|
796
844
|
])
|
|
797
|
-
:
|
|
798
|
-
renderExtraSuffixIcon(),
|
|
845
|
+
: renderEmptyElement($xeNumberInput),
|
|
799
846
|
suffixSlot || suffixIcon
|
|
800
847
|
? h('div', {
|
|
801
848
|
class: 'vxe-number-input--suffix-icon',
|
|
@@ -807,91 +854,29 @@ export default defineComponent({
|
|
|
807
854
|
class: suffixIcon
|
|
808
855
|
})
|
|
809
856
|
])
|
|
810
|
-
:
|
|
857
|
+
: renderEmptyElement($xeNumberInput)
|
|
811
858
|
])
|
|
812
859
|
}
|
|
813
860
|
|
|
814
|
-
const
|
|
815
|
-
const {
|
|
816
|
-
const
|
|
817
|
-
if (controls && !inputReadonly) {
|
|
818
|
-
return renderNumberIcon()
|
|
819
|
-
}
|
|
820
|
-
return createCommentVNode()
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
const dispatchEvent = (type: ValueOf<VxeNumberInputEmits>, params: Record<string, any>, evnt: Event | null) => {
|
|
824
|
-
emit(type, createEvent(evnt, { $numberInput: $xeNumberInput }, params))
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
numberInputMethods = {
|
|
828
|
-
dispatchEvent,
|
|
829
|
-
|
|
830
|
-
focus () {
|
|
831
|
-
const inputReadonly = computeInputReadonly.value
|
|
832
|
-
if (!inputReadonly) {
|
|
833
|
-
const inputElem = refInputTarget.value
|
|
834
|
-
reactData.isActivated = true
|
|
835
|
-
inputElem.focus()
|
|
836
|
-
}
|
|
837
|
-
return nextTick()
|
|
838
|
-
},
|
|
839
|
-
blur () {
|
|
840
|
-
const inputElem = refInputTarget.value
|
|
841
|
-
inputElem.blur()
|
|
842
|
-
reactData.isActivated = false
|
|
843
|
-
return nextTick()
|
|
844
|
-
},
|
|
845
|
-
select () {
|
|
846
|
-
const inputElem = refInputTarget.value
|
|
847
|
-
inputElem.select()
|
|
848
|
-
reactData.isActivated = false
|
|
849
|
-
return nextTick()
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
Object.assign($xeNumberInput, numberInputMethods)
|
|
854
|
-
|
|
855
|
-
const renderVN = () => {
|
|
856
|
-
const { className, controls, type, align, name, autocomplete, autoComplete } = props
|
|
857
|
-
const { inputValue, isFocus, isActivated } = reactData
|
|
858
|
-
const vSize = computeSize.value
|
|
861
|
+
const renderInput = () => {
|
|
862
|
+
const { type, name, autocomplete, autoComplete } = props
|
|
863
|
+
const { inputValue, isFocus } = reactData
|
|
859
864
|
const isDisabled = computeIsDisabled.value
|
|
860
|
-
const formReadonly = computeFormReadonly.value
|
|
861
865
|
const numLabel = computeNumLabel.value
|
|
862
|
-
if (formReadonly) {
|
|
863
|
-
return h('div', {
|
|
864
|
-
ref: refElem,
|
|
865
|
-
class: ['vxe-number-input--readonly', `type--${type}`, className]
|
|
866
|
-
}, numLabel)
|
|
867
|
-
}
|
|
868
866
|
const inputReadonly = computeInputReadonly.value
|
|
869
867
|
const inpMaxLength = computeInpMaxLength.value
|
|
870
868
|
const inpPlaceholder = computeInpPlaceholder.value
|
|
871
|
-
const isClearable = computeIsClearable.value
|
|
872
|
-
const prefix = renderPrefixIcon()
|
|
873
|
-
const suffix = renderSuffixIcon()
|
|
874
869
|
return h('div', {
|
|
875
|
-
|
|
876
|
-
class:
|
|
877
|
-
[`size--${vSize}`]: vSize,
|
|
878
|
-
[`is--${align}`]: align,
|
|
879
|
-
'is--controls': controls && !inputReadonly,
|
|
880
|
-
'is--prefix': !!prefix,
|
|
881
|
-
'is--suffix': !!suffix,
|
|
882
|
-
'is--disabled': isDisabled,
|
|
883
|
-
'is--active': isActivated,
|
|
884
|
-
'show--clear': isClearable && !isDisabled && !(inputValue === '' || XEUtils.eqNull(inputValue))
|
|
885
|
-
}],
|
|
886
|
-
spellcheck: false
|
|
870
|
+
key: 'ni',
|
|
871
|
+
class: 'vxe-number-input--input-wrapper'
|
|
887
872
|
}, [
|
|
888
|
-
|
|
873
|
+
renderPrefixIcon(),
|
|
889
874
|
h('div', {
|
|
890
|
-
class: 'vxe-number-input--
|
|
875
|
+
class: 'vxe-number-input--input-inner'
|
|
891
876
|
}, [
|
|
892
877
|
h('input', {
|
|
893
878
|
ref: refInputTarget,
|
|
894
|
-
class: 'vxe-number-input--
|
|
879
|
+
class: 'vxe-number-input--input',
|
|
895
880
|
value: !isFocus && type === 'amount' ? numLabel : inputValue,
|
|
896
881
|
name,
|
|
897
882
|
type: 'text',
|
|
@@ -910,10 +895,112 @@ export default defineComponent({
|
|
|
910
895
|
onBlur: blurEvent
|
|
911
896
|
})
|
|
912
897
|
]),
|
|
913
|
-
|
|
898
|
+
renderSuffixIcon()
|
|
899
|
+
])
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
const renderMinusBtn = () => {
|
|
903
|
+
const { minusIcon } = props
|
|
904
|
+
const isDisabledSubtractNumber = computeIsDisabledSubtractNumber.value
|
|
905
|
+
return h('button', {
|
|
906
|
+
key: 'prev',
|
|
907
|
+
class: ['vxe-number-input--minus-btn is--minus', {
|
|
908
|
+
'is--disabled': isDisabledSubtractNumber
|
|
909
|
+
}],
|
|
910
|
+
onClick: numberClickEvent,
|
|
911
|
+
onMousedown: numberMousedownEvent,
|
|
912
|
+
onMouseup: numberStopAll,
|
|
913
|
+
onMouseleave: numberStopAll
|
|
914
|
+
}, [
|
|
915
|
+
h('i', {
|
|
916
|
+
class: minusIcon || getIcon().NUMBER_INPUT_MINUS_NUM
|
|
917
|
+
})
|
|
918
|
+
])
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
const renderPlusBtn = () => {
|
|
922
|
+
const { plusIcon } = props
|
|
923
|
+
const isDisabledAddNumber = computeIsDisabledAddNumber.value
|
|
924
|
+
return h('button', {
|
|
925
|
+
key: 'next',
|
|
926
|
+
class: ['vxe-number-input--plus-btn is--plus', {
|
|
927
|
+
'is--disabled': isDisabledAddNumber
|
|
928
|
+
}],
|
|
929
|
+
onClick: numberClickEvent,
|
|
930
|
+
onMousedown: numberMousedownEvent,
|
|
931
|
+
onMouseup: numberStopAll,
|
|
932
|
+
onMouseleave: numberStopAll
|
|
933
|
+
}, [
|
|
934
|
+
h('i', {
|
|
935
|
+
class: plusIcon || getIcon().NUMBER_INPUT_PLUS_NUM
|
|
936
|
+
})
|
|
937
|
+
])
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
const renderSideControl = () => {
|
|
941
|
+
return h('div', {
|
|
942
|
+
key: 'cplr',
|
|
943
|
+
class: 'vxe-number-input--side-control'
|
|
944
|
+
}, [
|
|
945
|
+
renderPlusBtn(),
|
|
946
|
+
renderMinusBtn()
|
|
914
947
|
])
|
|
915
948
|
}
|
|
916
949
|
|
|
950
|
+
const renderVN = () => {
|
|
951
|
+
const { className, controls, type, align, prefixIcon, suffixIcon } = props
|
|
952
|
+
const { inputValue, isActivated } = reactData
|
|
953
|
+
const vSize = computeSize.value
|
|
954
|
+
const controlOpts = computeControlOpts.value
|
|
955
|
+
const { layout, showButton } = controlOpts
|
|
956
|
+
const isDisabled = computeIsDisabled.value
|
|
957
|
+
const formReadonly = computeFormReadonly.value
|
|
958
|
+
const numLabel = computeNumLabel.value
|
|
959
|
+
const prefixSlot = slots.prefix
|
|
960
|
+
const suffixSlot = slots.suffix
|
|
961
|
+
if (formReadonly) {
|
|
962
|
+
return h('div', {
|
|
963
|
+
ref: refElem,
|
|
964
|
+
class: ['vxe-number-input--readonly', `type--${type}`, className]
|
|
965
|
+
}, numLabel)
|
|
966
|
+
}
|
|
967
|
+
const inputReadonly = computeInputReadonly.value
|
|
968
|
+
const isClearable = computeIsClearable.value
|
|
969
|
+
const isControls = isEnableConf(controlOpts) && (controls === false ? controls : showButton)
|
|
970
|
+
return h('div', {
|
|
971
|
+
ref: refElem,
|
|
972
|
+
class: ['vxe-number-input', `type--${type}`, `control-${layout === 'right' || layout === 'left' ? layout : 'default'}`, className, {
|
|
973
|
+
[`size--${vSize}`]: vSize,
|
|
974
|
+
[`is--${align}`]: align,
|
|
975
|
+
'is--controls': isControls && !inputReadonly,
|
|
976
|
+
'is--prefix': !!prefixSlot || prefixIcon,
|
|
977
|
+
'is--suffix': !!suffixSlot || suffixIcon,
|
|
978
|
+
'is--disabled': isDisabled,
|
|
979
|
+
'is--active': isActivated,
|
|
980
|
+
'show--clear': isClearable && !isDisabled && !(inputValue === '' || XEUtils.eqNull(inputValue))
|
|
981
|
+
}],
|
|
982
|
+
spellcheck: false
|
|
983
|
+
}, isControls
|
|
984
|
+
? (layout === 'right'
|
|
985
|
+
? [
|
|
986
|
+
renderInput(),
|
|
987
|
+
renderSideControl()
|
|
988
|
+
]
|
|
989
|
+
: (layout === 'left'
|
|
990
|
+
? [
|
|
991
|
+
renderSideControl(),
|
|
992
|
+
renderInput()
|
|
993
|
+
]
|
|
994
|
+
: [
|
|
995
|
+
renderMinusBtn(),
|
|
996
|
+
renderInput(),
|
|
997
|
+
renderPlusBtn()
|
|
998
|
+
]))
|
|
999
|
+
: [
|
|
1000
|
+
renderInput()
|
|
1001
|
+
])
|
|
1002
|
+
}
|
|
1003
|
+
|
|
917
1004
|
$xeNumberInput.renderVN = renderVN
|
|
918
1005
|
|
|
919
1006
|
watch(() => props.modelValue, (val) => {
|
|
@@ -939,7 +1026,7 @@ export default defineComponent({
|
|
|
939
1026
|
|
|
940
1027
|
onBeforeUnmount(() => {
|
|
941
1028
|
reactData.isFocus = false
|
|
942
|
-
|
|
1029
|
+
numberStopAll()
|
|
943
1030
|
afterCheckValue()
|
|
944
1031
|
globalEvents.off($xeNumberInput, 'mousedown')
|
|
945
1032
|
globalEvents.off($xeNumberInput, 'keydown')
|
package/packages/ui/index.ts
CHANGED
|
@@ -231,7 +231,12 @@ setConfig({
|
|
|
231
231
|
// transfer: false
|
|
232
232
|
digits: 2,
|
|
233
233
|
autoFill: true,
|
|
234
|
-
|
|
234
|
+
controlConfig: {
|
|
235
|
+
enabled: true,
|
|
236
|
+
// layout: 'default',
|
|
237
|
+
showButton: true,
|
|
238
|
+
isWheel: true
|
|
239
|
+
}
|
|
235
240
|
},
|
|
236
241
|
optgroup: {},
|
|
237
242
|
option: {},
|
|
@@ -414,10 +419,12 @@ setIcon({
|
|
|
414
419
|
// input
|
|
415
420
|
INPUT_CLEAR: iconPrefix + 'error-circle-fill',
|
|
416
421
|
INPUT_SEARCH: iconPrefix + 'search',
|
|
422
|
+
INPUT_PLUS_NUM: iconPrefix + 'caret-up',
|
|
423
|
+
INPUT_MINUS_NUM: iconPrefix + 'caret-down',
|
|
417
424
|
|
|
418
425
|
// number-picker
|
|
419
|
-
|
|
420
|
-
|
|
426
|
+
NUMBER_INPUT_MINUS_NUM: iconPrefix + 'minus',
|
|
427
|
+
NUMBER_INPUT_PLUS_NUM: iconPrefix + 'add',
|
|
421
428
|
|
|
422
429
|
// date-picker
|
|
423
430
|
DATE_PICKER_DATE: iconPrefix + 'calendar',
|
package/packages/ui/src/dom.ts
CHANGED
|
@@ -51,7 +51,7 @@ export function isScale (val: any) {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export function hasClass (elem: any, cls: any) {
|
|
54
|
-
return elem && elem.className && elem.className.match && elem.className.match(getClsRE(cls))
|
|
54
|
+
return !!(elem && elem.className && elem.className.match && elem.className.match(getClsRE(cls)))
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
export function removeClass (elem: any, cls: any) {
|