Skip to content

Commit

Permalink
refactor(swipe): move to script setup (jd-opensource#2975)
Browse files Browse the repository at this point in the history
  • Loading branch information
eiinu authored Mar 18, 2024
1 parent 8e1b59b commit ac60b0d
Show file tree
Hide file tree
Showing 20 changed files with 556 additions and 513 deletions.
2 changes: 2 additions & 0 deletions src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -472,13 +472,15 @@
"name": "Swipe",
"cName": "滑动手势",
"desc": "列表项左滑删除场景使用",
"setup": true,
"author": "richard1015"
},
{
"name": "SwipeGroup",
"cName": "滑动手势",
"show": false,
"desc": "Swipe 的集合,用于控制互斥",
"setup": true,
"author": "eiinu"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { createComponent } from '@/packages/utils/create';
const { create } = createComponent('address-list-general');
import ItemContents from './ItemContents.taro.vue';
import NutButton from '../../button/index.taro';
import NutSwipe from '../../swipe/index.taro.vue';
import NutSwipe from '../../swipe/index.taro';
export default create({
props: {
Expand Down
2 changes: 1 addition & 1 deletion src/packages/__VUE/addresslist/components/GeneralShell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { createComponent } from '@/packages/utils/create';
const { create } = createComponent('address-list-general');
import ItemContents from './ItemContents.vue';
import NutButton from '../../button';
import NutSwipe from '../../swipe/index.vue';
import NutSwipe from '../../swipe';
export default create({
props: {
Expand Down
5 changes: 1 addition & 4 deletions src/packages/__VUE/swipe/__tests__/swipe.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { DOMWrapper, mount } from '@vue/test-utils';
import Swipe from '../index.vue';
import SwipeGroup from '../../swipegroup/index.vue';
import { Button, Cell, Swipe, SwipeGroup } from '@nutui/nutui';
import { nextTick } from 'vue';
import Button from '../../button';
import Cell from '../../cell/index.vue';
import { triggerDrag, mockGetBoundingClientRect } from '@/packages/utils/unit';

test('Swipe: base swipe', () => {
Expand Down
10 changes: 9 additions & 1 deletion src/packages/__VUE/swipe/doc.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ The prop `name` of Swipe is required.

| Event | Description | Arguments |
| --- | --- | --- |
| click | click event | `name, position: 'left' \| 'content' \| 'right'` |
| open | Emitted when Swipe is opened, swipe left/swipe right | `name, position: 'left' \| 'right' ` |
| close | Emitted when Swipe is closed, swipe left/swipe right | `name, position: 'left' \| 'right' ` |

Expand All @@ -74,7 +75,6 @@ Use [ref](https://vuejs.org/guide/essentials/template-refs.html) to get Swipe in

| Name | Description | Arguments |
| --- | --- | --- |
| click | click event | `name, position: 'left' \| 'content' \| 'right'` |
| open | open swipe, swipe left/swipe right | `name, position: 'left' \| 'right' ` |
| close | close swipe, swipe left/swipe right | `name, position: 'left' \| 'right' ` |

Expand All @@ -85,3 +85,11 @@ Use [ref](https://vuejs.org/guide/essentials/template-refs.html) to get Swipe in
| Attribute | Description | Type | Default |
| --- | --- | --- | --- |
| lock`v4.1.1` | When a child Swipe opens, others will close. | boolean | `false` |

### Types version

The component exports the following type definitions:

```ts
import type { SwipePosition, SwipeProps, SwipeInstance, SwipeGroupProps, SwipeGroupInstance } from '@nutui/nutui';
```
10 changes: 9 additions & 1 deletion src/packages/__VUE/swipe/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ app.use(Swipe);

| 事件名 | 说明 | 回调参数 |
| --- | --- | --- |
| click | 点击事件 | `name, position: 'left' \| 'content' \| 'right'` |
| open | 滑动时触发,left 指向左滑,right 指向右滑 | `name, position: 'left' \| 'right'` |
| close | 关闭时触发,同上 | `name, position: 'left' \| 'right'` |

Expand All @@ -74,7 +75,6 @@ app.use(Swipe);

| 方法名 | 说明 | 参数 |
| --- | --- | --- |
| click | 点击事件 | `name, position: 'left' \| 'content' \| 'right'` |
| open | 滑动单元格侧边栏,left 指向左滑,right 指向右滑 | `name, position: 'left' \| 'right'` |
| close | 收起单元格侧边栏,同上 | `name, position: 'left' \| 'right'` |

Expand All @@ -85,3 +85,11 @@ app.use(Swipe);
| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| lock`v4.1.1` | 控制内部 Swipe 互斥,即滑动打开某一个 Swipe 时,触发其余 Swipe 的 close 方法 | boolean | `false` |

### 类型定义 version

组件导出以下类型定义:

```ts
import type { SwipePosition, SwipeProps, SwipeInstance, SwipeGroupProps, SwipeGroupInstance } from '@nutui/nutui';
```
10 changes: 9 additions & 1 deletion src/packages/__VUE/swipe/doc.taro.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ app.use(Swipe);

| 事件名 | 说明 | 回调参数 |
| --- | --- | --- |
| click | 点击事件 | `name, position: 'left' \| 'content' \| 'right'` |
| open | 滑动时触发,left 指向左滑,right 指向右滑 | `name, position: 'left' \| 'right'` |
| close | 关闭时触发,同上 | `name, position: 'left' \| 'right'` |

Expand All @@ -74,7 +75,6 @@ app.use(Swipe);

| 方法名 | 说明 | 参数 |
| --- | --- | --- |
| click | 点击事件 | `name, position: 'left' \| 'content' \| 'right'` |
| open | 滑动单元格侧边栏,left 指向左滑,right 指向右滑 | `name, position: 'left' \| 'right'` |
| close | 收起单元格侧边栏,同上 | `name, position: 'left' \| 'right'` |

Expand All @@ -85,3 +85,11 @@ app.use(Swipe);
| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| lock`v4.1.1` | 控制内部 Swipe 互斥,即滑动打开某一个 Swipe 时,触发其余 Swipe 的 close 方法 | boolean | `false` |

### 类型定义 version

组件导出以下类型定义:

```ts
import type { SwipePosition, SwipeProps, SwipeInstance, SwipeGroupProps, SwipeGroupInstance } from '@nutui/nutui-taro';
```
13 changes: 13 additions & 0 deletions src/packages/__VUE/swipe/index.taro.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Swipe from './swipe.taro.vue';
import type { ComponentPublicInstance } from 'vue';
import { withInstall } from '@/packages/utils';

withInstall(Swipe);

export type { SwipeProps } from './swipe.taro.vue';

export type { SwipePosition } from './types';

export type SwipeInstance = ComponentPublicInstance & InstanceType<typeof Swipe>;

export { Swipe, Swipe as default };
231 changes: 0 additions & 231 deletions src/packages/__VUE/swipe/index.taro.vue

This file was deleted.

13 changes: 13 additions & 0 deletions src/packages/__VUE/swipe/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Swipe from './swipe.vue';
import type { ComponentPublicInstance } from 'vue';
import { withInstall } from '@/packages/utils';

withInstall(Swipe);

export type { SwipeProps } from './swipe.vue';

export type { SwipePosition } from './types';

export type SwipeInstance = ComponentPublicInstance & InstanceType<typeof Swipe>;

export { Swipe, Swipe as default };
Loading

0 comments on commit ac60b0d

Please sign in to comment.