Skip to content

Commit b840ce7

Browse files
committed
fix(numeric): update controls-position prop type and add validator
1 parent 9f48fc1 commit b840ce7

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

examples/sites/demos/apis/numeric.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default {
3131
},
3232
{
3333
name: 'blank',
34-
type: 'string',
34+
type: 'boolean',
3535
defaultValue: 'true',
3636
desc: {
3737
'zh-CN': '过滤器背景设置为透明,默认值为true',
@@ -67,7 +67,7 @@ export default {
6767
},
6868
{
6969
name: 'controls-position',
70-
type: 'string',
70+
type: '"right"',
7171
defaultValue: '',
7272
desc: {
7373
'zh-CN': '加减按钮位置,可选值为 right,表示加减按钮均位于最右侧',

packages/vue/src/numeric/__tests__/numeric.test.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { mountPcMode } from '@opentiny-internal/vue-test-utils'
22
import { describe, expect, test, vi } from 'vitest'
33
import Numeric from '@opentiny/vue-numeric'
4-
import { IconChevronUp } from '@opentiny/vue-icon'
54
import { nextTick, ref } from 'vue'
65

76
const mouseup = new Event('mouseup')
@@ -166,11 +165,10 @@ describe('PC Mode', () => {
166165
expect(wrapper.find('.tiny-numeric__increase').exists()).toBe(false)
167166
})
168167

169-
test('controls-position 控制按钮位置', async () => {
168+
test('controls-position = right', async () => {
170169
const num = ref(0)
171-
const wrapper = mount(() => <Numeric controls-position="rigint" v-model={num.value}></Numeric>)
172-
expect(wrapper.find('.tiny-numeric__decrease').findComponent(IconChevronUp).exists()).toBe(false)
173-
expect(wrapper.find('.tiny-numeric__increase').findComponent(IconChevronUp).exists()).toBe(false)
170+
const wrapper = mount(() => <Numeric controls-position="right" v-model={num.value} />)
171+
expect(wrapper.find('.is-controls-right').exists()).toBe(true)
174172
})
175173

176174
test('name 原生属性', async () => {

packages/vue/src/numeric/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ export const numericProps = {
5656
},
5757
controlsPosition: {
5858
type: String,
59-
default: ''
59+
default: '',
60+
validator: (value: string) => ['', 'right'].includes(value)
6061
},
6162
disabled: Boolean,
6263
format: [Object, String],

0 commit comments

Comments
 (0)