From c36bc88f6b3072f3593b9f4ad0361541a48d8014 Mon Sep 17 00:00:00 2001 From: Eiinu Date: Sun, 7 Apr 2024 10:14:47 +0800 Subject: [PATCH] =?UTF-8?q?feat(input-number):=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=80=8F=E4=BC=A0=E5=B1=9E=E6=80=A7=E8=87=B3=20input=20?= =?UTF-8?q?=E5=85=83=E7=B4=A0=20(#3008)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...index.spec.ts.snap => index.spec.tsx.snap} | 0 .../{index.spec.ts => index.spec.tsx} | 19 ++++++++++++++----- src/packages/__VUE/inputnumber/doc.en-US.md | 4 ++++ src/packages/__VUE/inputnumber/doc.md | 4 ++++ src/packages/__VUE/inputnumber/doc.taro.md | 4 ++++ .../__VUE/inputnumber/input-number.taro.vue | 4 +++- .../__VUE/inputnumber/input-number.vue | 4 +++- 7 files changed, 32 insertions(+), 7 deletions(-) rename src/packages/__VUE/inputnumber/__tests__/__snapshots__/{index.spec.ts.snap => index.spec.tsx.snap} (100%) rename src/packages/__VUE/inputnumber/__tests__/{index.spec.ts => index.spec.tsx} (91%) diff --git a/src/packages/__VUE/inputnumber/__tests__/__snapshots__/index.spec.ts.snap b/src/packages/__VUE/inputnumber/__tests__/__snapshots__/index.spec.tsx.snap similarity index 100% rename from src/packages/__VUE/inputnumber/__tests__/__snapshots__/index.spec.ts.snap rename to src/packages/__VUE/inputnumber/__tests__/__snapshots__/index.spec.tsx.snap diff --git a/src/packages/__VUE/inputnumber/__tests__/index.spec.ts b/src/packages/__VUE/inputnumber/__tests__/index.spec.tsx similarity index 91% rename from src/packages/__VUE/inputnumber/__tests__/index.spec.ts rename to src/packages/__VUE/inputnumber/__tests__/index.spec.tsx index abb3528105..d793283425 100644 --- a/src/packages/__VUE/inputnumber/__tests__/index.spec.ts +++ b/src/packages/__VUE/inputnumber/__tests__/index.spec.tsx @@ -4,12 +4,9 @@ import { h, nextTick } from 'vue' import { Left, Right } from '@nutui/icons-vue' test('InputNumber: should render modelValue', () => { - const wrapper = mount(InputNumber, { - props: { - modelValue: 12 - } + const wrapper = mount(() => { + return }) - const input = wrapper.find('input').element as HTMLInputElement expect(input.value).toBe('12') }) @@ -189,3 +186,15 @@ test('InputNumber: should change modelValue after props.min was changed', async expect(wrapper.emitted()['update:modelValue']).toHaveLength(1) expect(wrapper.emitted()['update:modelValue'][0]).toStrictEqual(['7', {}]) }) + +test('InputNumber: v-bind="$attrs"', async () => { + const testClass = 'test-attr-class' + const customAttr = 'custom-attr' + const wrapper = mount(() => { + return + }) + + const input = wrapper.find('input').element as HTMLInputElement + expect(input.getAttribute('class')).includes(testClass) + expect(input.getAttribute(customAttr)).includes(customAttr) +}) diff --git a/src/packages/__VUE/inputnumber/doc.en-US.md b/src/packages/__VUE/inputnumber/doc.en-US.md index 9b4c565c62..f7e9e9cded 100644 --- a/src/packages/__VUE/inputnumber/doc.en-US.md +++ b/src/packages/__VUE/inputnumber/doc.en-US.md @@ -74,6 +74,10 @@ Set step size `step` 0.1 `decimal places` keep 1 decimal place | disabled | Disable all features | boolean | `false` | | readonly | Read only status disables input box operation behavior | boolean | `false` | +### Attrs version + +The attributes on `InputNumber` will be inherited by `input` element. + ### Slots | Name | Description | diff --git a/src/packages/__VUE/inputnumber/doc.md b/src/packages/__VUE/inputnumber/doc.md index 0bb5f3162d..4b22df2193 100644 --- a/src/packages/__VUE/inputnumber/doc.md +++ b/src/packages/__VUE/inputnumber/doc.md @@ -74,6 +74,10 @@ app.use(InputNumber) | disabled | 禁用所有功能 | boolean | `false` | | readonly | 只读状态禁用输入框操作行为 | boolean | `false` | +### Attrs version + +支持透传属性至组件内部的 input 元素。 + ### Slots | 名称 | 说明 | diff --git a/src/packages/__VUE/inputnumber/doc.taro.md b/src/packages/__VUE/inputnumber/doc.taro.md index ea4dbf1e68..cbf6dc66b0 100644 --- a/src/packages/__VUE/inputnumber/doc.taro.md +++ b/src/packages/__VUE/inputnumber/doc.taro.md @@ -74,6 +74,10 @@ app.use(InputNumber) | disabled | 禁用所有功能 | boolean | `false` | | readonly | 只读状态禁用输入框操作行为 | boolean | `false` | +### Attrs version + +支持透传属性至组件内部的 input 元素。 + ### Slots | 名称 | 说明 | diff --git a/src/packages/__VUE/inputnumber/input-number.taro.vue b/src/packages/__VUE/inputnumber/input-number.taro.vue index 3a9741bb03..b684f84b45 100644 --- a/src/packages/__VUE/inputnumber/input-number.taro.vue +++ b/src/packages/__VUE/inputnumber/input-number.taro.vue @@ -16,6 +16,7 @@ v-else class="nut-input-number__text--input" type="number" + v-bind="$attrs" :min="min" :max="max" :style="{ width: pxCheck(inputWidth), height: pxCheck(buttonSize) }" @@ -44,7 +45,8 @@ import { Minus, Plus } from '@nutui/icons-vue-taro' import { useFormDisabled } from '../form/common' defineOptions({ - name: 'NutInputNumber' + name: 'NutInputNumber', + inheritAttrs: false }) export type InputNumberProps = Partial<{ diff --git a/src/packages/__VUE/inputnumber/input-number.vue b/src/packages/__VUE/inputnumber/input-number.vue index b55bd658af..c89fcedb0a 100644 --- a/src/packages/__VUE/inputnumber/input-number.vue +++ b/src/packages/__VUE/inputnumber/input-number.vue @@ -11,6 +11,7 @@