From 2c31ebe2e1e5d6c1de46b53776161bc3b59c2e69 Mon Sep 17 00:00:00 2001 From: mrayi <1078464063@qq.com> Date: Wed, 17 Apr 2024 10:06:58 +0800 Subject: [PATCH] refactor(steps): move to script setup (#3022) --- src/config.json | 2 + src/packages/__VUE/step/index.taro.ts | 11 +++ src/packages/__VUE/step/index.taro.vue | 89 ------------------- src/packages/__VUE/step/index.ts | 11 +++ src/packages/__VUE/step/index.vue | 89 ------------------- src/packages/__VUE/step/step.taro.vue | 70 +++++++++++++++ src/packages/__VUE/step/step.vue | 70 +++++++++++++++ .../__VUE/steps/__tests__/index.spec.tsx | 3 + src/packages/__VUE/steps/doc.en-US.md | 14 +++ src/packages/__VUE/steps/doc.md | 14 +++ src/packages/__VUE/steps/doc.taro.md | 14 +++ src/packages/__VUE/steps/index.taro.ts | 13 +++ src/packages/__VUE/steps/index.taro.vue | 63 ------------- src/packages/__VUE/steps/index.ts | 13 +++ src/packages/__VUE/steps/index.vue | 63 ------------- src/packages/__VUE/steps/steps.taro.vue | 45 ++++++++++ src/packages/__VUE/steps/steps.vue | 45 ++++++++++ src/packages/utils/useRelation/useParent.ts | 2 +- 18 files changed, 326 insertions(+), 305 deletions(-) create mode 100644 src/packages/__VUE/step/index.taro.ts delete mode 100644 src/packages/__VUE/step/index.taro.vue create mode 100644 src/packages/__VUE/step/index.ts delete mode 100644 src/packages/__VUE/step/index.vue create mode 100644 src/packages/__VUE/step/step.taro.vue create mode 100644 src/packages/__VUE/step/step.vue create mode 100644 src/packages/__VUE/steps/index.taro.ts delete mode 100644 src/packages/__VUE/steps/index.taro.vue create mode 100644 src/packages/__VUE/steps/index.ts delete mode 100644 src/packages/__VUE/steps/index.vue create mode 100644 src/packages/__VUE/steps/steps.taro.vue create mode 100644 src/packages/__VUE/steps/steps.vue diff --git a/src/config.json b/src/config.json index 2fe8e48770..3170008920 100644 --- a/src/config.json +++ b/src/config.json @@ -651,6 +651,7 @@ "version": "3.0.0", "name": "Steps", "cName": "步骤条", + "setup": true, "desc": "步骤条", "author": "ailululu" }, @@ -658,6 +659,7 @@ "version": "3.0.0", "name": "Step", "cName": "步骤条子组件", + "setup": true, "show": false, "desc": "步骤条子组件", "author": "ailululu" diff --git a/src/packages/__VUE/step/index.taro.ts b/src/packages/__VUE/step/index.taro.ts new file mode 100644 index 0000000000..676c1027bb --- /dev/null +++ b/src/packages/__VUE/step/index.taro.ts @@ -0,0 +1,11 @@ +import Step from './step.taro.vue' +import type { ComponentPublicInstance } from 'vue' +import { withInstall } from '@/packages/utils' + +withInstall(Step) + +export type { StepProps } from './step.taro.vue' + +export type StepInstance = ComponentPublicInstance & InstanceType + +export { Step, Step as default } diff --git a/src/packages/__VUE/step/index.taro.vue b/src/packages/__VUE/step/index.taro.vue deleted file mode 100644 index 3e2cba97f1..0000000000 --- a/src/packages/__VUE/step/index.taro.vue +++ /dev/null @@ -1,89 +0,0 @@ - - - diff --git a/src/packages/__VUE/step/index.ts b/src/packages/__VUE/step/index.ts new file mode 100644 index 0000000000..e9f99f1fe9 --- /dev/null +++ b/src/packages/__VUE/step/index.ts @@ -0,0 +1,11 @@ +import Step from './step.vue' +import type { ComponentPublicInstance } from 'vue' +import { withInstall } from '@/packages/utils' + +withInstall(Step) + +export type { StepProps } from './step.vue' + +export type StepInstance = ComponentPublicInstance & InstanceType + +export { Step, Step as default } diff --git a/src/packages/__VUE/step/index.vue b/src/packages/__VUE/step/index.vue deleted file mode 100644 index 3e2cba97f1..0000000000 --- a/src/packages/__VUE/step/index.vue +++ /dev/null @@ -1,89 +0,0 @@ - - - diff --git a/src/packages/__VUE/step/step.taro.vue b/src/packages/__VUE/step/step.taro.vue new file mode 100644 index 0000000000..129a09d13f --- /dev/null +++ b/src/packages/__VUE/step/step.taro.vue @@ -0,0 +1,70 @@ + + + diff --git a/src/packages/__VUE/step/step.vue b/src/packages/__VUE/step/step.vue new file mode 100644 index 0000000000..129a09d13f --- /dev/null +++ b/src/packages/__VUE/step/step.vue @@ -0,0 +1,70 @@ + + + diff --git a/src/packages/__VUE/steps/__tests__/index.spec.tsx b/src/packages/__VUE/steps/__tests__/index.spec.tsx index c6a9fde2e9..90a1ea764d 100644 --- a/src/packages/__VUE/steps/__tests__/index.spec.tsx +++ b/src/packages/__VUE/steps/__tests__/index.spec.tsx @@ -154,6 +154,9 @@ test('should emited click when step trigger', async () => { await nextTick() await wrapper.vm.$emit('click-step') expect(wrapper.emitted('click-step')).toBeTruthy() + const stepItem = wrapper.findAll('.nut-step')[0] + await stepItem.trigger('click') + expect(wrapper.emitted('click-step')).toBeTruthy() }) test('render step slot', async () => { diff --git a/src/packages/__VUE/steps/doc.en-US.md b/src/packages/__VUE/steps/doc.en-US.md index 4f7886d3a6..b0eb9811db 100644 --- a/src/packages/__VUE/steps/doc.en-US.md +++ b/src/packages/__VUE/steps/doc.en-US.md @@ -70,6 +70,20 @@ app.use(Step) | content | Step content | | icon | Step icon | +### Types version + +The component exports the following type definitions: + +```js +import type { + StepsProps, + StepsInstance, + StepsDirection, + StepProps, + StepInstance +} from '@nutui/nutui'; +``` + ## Theming ### CSS Variables diff --git a/src/packages/__VUE/steps/doc.md b/src/packages/__VUE/steps/doc.md index cbb1d41ff7..6a5e7418cf 100644 --- a/src/packages/__VUE/steps/doc.md +++ b/src/packages/__VUE/steps/doc.md @@ -70,6 +70,20 @@ app.use(Step) | content | 步骤内容 | | icon | 步骤图标 | +### 类型定义 version + +组件导出以下类型定义: + +```js +import type { + StepsProps, + StepsInstance, + StepsDirection, + StepProps, + StepInstance +} from '@nutui/nutui'; +``` + ## 主题定制 ### 样式变量 diff --git a/src/packages/__VUE/steps/doc.taro.md b/src/packages/__VUE/steps/doc.taro.md index b443943f5e..a456738d48 100644 --- a/src/packages/__VUE/steps/doc.taro.md +++ b/src/packages/__VUE/steps/doc.taro.md @@ -70,6 +70,20 @@ app.use(Step) | content | 步骤内容 | | icon | 步骤图标 | +### 类型定义 version + +组件导出以下类型定义: + +```js +import type { + StepsProps, + StepsInstance, + StepsDirection, + StepProps, + StepInstance +} from '@nutui/nutui-taro'; +``` + ## 主题定制 ### 样式变量 diff --git a/src/packages/__VUE/steps/index.taro.ts b/src/packages/__VUE/steps/index.taro.ts new file mode 100644 index 0000000000..79fec53a2b --- /dev/null +++ b/src/packages/__VUE/steps/index.taro.ts @@ -0,0 +1,13 @@ +import Steps from './steps.taro.vue' +import type { ComponentPublicInstance } from 'vue' +import { withInstall } from '@/packages/utils' + +withInstall(Steps) + +export type { StepsProps } from './steps.taro.vue' + +export type { StepsDirection } from './types' + +export type StepsInstance = ComponentPublicInstance & InstanceType + +export { Steps, Steps as default } diff --git a/src/packages/__VUE/steps/index.taro.vue b/src/packages/__VUE/steps/index.taro.vue deleted file mode 100644 index 3d7877f8d6..0000000000 --- a/src/packages/__VUE/steps/index.taro.vue +++ /dev/null @@ -1,63 +0,0 @@ - diff --git a/src/packages/__VUE/steps/index.ts b/src/packages/__VUE/steps/index.ts new file mode 100644 index 0000000000..3a12fc45e8 --- /dev/null +++ b/src/packages/__VUE/steps/index.ts @@ -0,0 +1,13 @@ +import Steps from './steps.vue' +import type { ComponentPublicInstance } from 'vue' +import { withInstall } from '@/packages/utils' + +withInstall(Steps) + +export type { StepsProps } from './steps.vue' + +export type { StepsDirection } from './types' + +export type StepsInstance = ComponentPublicInstance & InstanceType + +export { Steps, Steps as default } diff --git a/src/packages/__VUE/steps/index.vue b/src/packages/__VUE/steps/index.vue deleted file mode 100644 index 3d7877f8d6..0000000000 --- a/src/packages/__VUE/steps/index.vue +++ /dev/null @@ -1,63 +0,0 @@ - diff --git a/src/packages/__VUE/steps/steps.taro.vue b/src/packages/__VUE/steps/steps.taro.vue new file mode 100644 index 0000000000..c37ff68e48 --- /dev/null +++ b/src/packages/__VUE/steps/steps.taro.vue @@ -0,0 +1,45 @@ + + diff --git a/src/packages/__VUE/steps/steps.vue b/src/packages/__VUE/steps/steps.vue new file mode 100644 index 0000000000..c37ff68e48 --- /dev/null +++ b/src/packages/__VUE/steps/steps.vue @@ -0,0 +1,45 @@ + + diff --git a/src/packages/utils/useRelation/useParent.ts b/src/packages/utils/useRelation/useParent.ts index 06867dec75..37848574ae 100644 --- a/src/packages/utils/useRelation/useParent.ts +++ b/src/packages/utils/useRelation/useParent.ts @@ -11,7 +11,7 @@ export const useParent = (key: symbol) => { onUnmounted(() => { unlink(instance) }) - const index = computed(() => internalChildren.indexOf(instance)) + const index = computed(() => internalChildren.indexOf(instance)) return { parent, index } }