diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml
index 3353a3956..22f16b3c6 100644
--- a/.github/workflows/push.yml
+++ b/.github/workflows/push.yml
@@ -1,7 +1,6 @@
name: MAIN_PUSH
-on:
- push
+on: push
jobs:
call-test-build:
diff --git a/src/action-sheet/__test__/__snapshots__/demo.test.jsx.snap b/src/action-sheet/__test__/__snapshots__/demo.test.jsx.snap
index a3614174d..05c2914de 100644
--- a/src/action-sheet/__test__/__snapshots__/demo.test.jsx.snap
+++ b/src/action-sheet/__test__/__snapshots__/demo.test.jsx.snap
@@ -1,5 +1,343 @@
// Vitest Snapshot v1
+exports[`ActionSheet > ActionSheet alignVue demo works fine 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
exports[`ActionSheet > ActionSheet gridMultipleVue demo works fine 1`] = `
ActionSheet gridMultipleVue demo works fine 1`] = `
>
+
+
+
+
-
+
-
-
+ class="t-loading__dots"
+ style="animation-duration: 800ms; width: 20px; height: 20px;"
+ >
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
- 文字
+
-
-
-
+
-
-
+ class="t-loading__dots"
+ style="animation-duration: 800ms; width: 20px; height: 20px;"
+ >
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
- 文字
+
+
+
-
+
+
-
+
+
+
+
+
+
+
+`;
+
+exports[`ActionSheet > ActionSheet gridVue demo works fine 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[`ActionSheet > ActionSheet gridVue demo works fine 1`] = `
-
-
-
-
-
+ class="t-grid-item t-grid-item--vertical"
+ style="text-align: center; flex-basis: 25%;"
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
ActionSheet gridVue demo works fine 1`] = `
-
+
+ 动作面板描述文字
+
+
-
-
+
-
-
+ class="t-loading__dots"
+ style="animation-duration: 800ms; width: 20px; height: 20px;"
+ >
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
- 文字
+
-
-
-
+
-
-
+ class="t-loading__dots"
+ style="animation-duration: 800ms; width: 20px; height: 20px;"
+ >
+
+
+
+
+
+
+
-
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ class="t-loading__dot"
+ style="animation-duration: 0.8s; animation-delay: 0s;"
+ />
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
-
-
-
-
-
+
+
+
-
-
-`;
-
-exports[`ActionSheet > ActionSheet listVue demo works fine 1`] = `
-
-
-
-
-
@@ -1741,1905 +3374,7715 @@ exports[`ActionSheet > ActionSheet listVue demo works fine 1`] = `
-
-
-
-
-
-`;
-
-exports[`ActionSheet > ActionSheet mobileVue demo works fine 1`] = `
-
-
- ActionSheet 动作面板
-
-
- 底部弹起的模态面板,包含与当前情境相关的多个选项。
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ 带徽标宫格型
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
+ class="t-loading__dot"
+ style="animation-duration: 0.8s; animation-delay: 0s;"
+ />
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
+
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+`;
+
+exports[`ActionSheet > ActionSheet listVue demo works fine 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`ActionSheet > ActionSheet mobileVue demo works fine 1`] = `
+
+
+ ActionSheet 动作面板
+
+
+ 从底部弹出的模态框,提供和当前场景相关的操作动作,也支持提供信息输入和描述。
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- 文字
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+ class="t-loading__dots"
+ style="animation-duration: 800ms; width: 20px; height: 20px;"
+ >
+
+
+
+
+
+
+
-
+
+
+
+
-
- 文字
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -3650,3 +11093,230 @@ exports[`ActionSheet > ActionSheet mobileVue demo works fine 1`] = `
`;
+
+exports[`ActionSheet > ActionSheet statusVue demo works fine 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
diff --git a/src/action-sheet/__test__/demo.test.jsx b/src/action-sheet/__test__/demo.test.jsx
index 3c3cb9758..0ae569344 100644
--- a/src/action-sheet/__test__/demo.test.jsx
+++ b/src/action-sheet/__test__/demo.test.jsx
@@ -3,16 +3,20 @@
*/
import { mount } from '@vue/test-utils';
+import alignVue from '@/action-sheet/demos/align.vue';
import gridMultipleVue from '@/action-sheet/demos/grid-multiple.vue';
import gridVue from '@/action-sheet/demos/grid.vue';
import listVue from '@/action-sheet/demos/list.vue';
import mobileVue from '@/action-sheet/demos/mobile.vue';
+import statusVue from '@/action-sheet/demos/status.vue';
const mapper = {
+ alignVue,
gridMultipleVue,
gridVue,
listVue,
mobileVue,
+ statusVue,
};
describe('ActionSheet', () => {
diff --git a/src/action-sheet/__test__/index.test.jsx b/src/action-sheet/__test__/index.test.jsx
index 663b6a109..c3d9b1229 100644
--- a/src/action-sheet/__test__/index.test.jsx
+++ b/src/action-sheet/__test__/index.test.jsx
@@ -1,11 +1,7 @@
import { describe, it, expect, vi } from 'vitest';
-import { config, mount } from '@vue/test-utils';
+import { mount } from '@vue/test-utils';
import ActionSheet from '../action-sheet.vue';
-import MenuGrid from '../menu-grid.vue';
-
-config.global.stubs = {
- teleport: true
-}
+import MenuGrid from '../action-sheet-grid.vue';
describe('ActionSheet', () => {
describe('props', () => {
@@ -16,11 +12,11 @@ describe('ActionSheet', () => {
visible: true,
},
});
- expect(wrapper.find('.t-action-sheet__action').exists()).toEqual(true);
+ expect(wrapper.find('.t-action-sheet__content').exists()).toEqual(true);
await wrapper.setProps({
showCancel: false,
});
- expect(wrapper.find('.t-action-sheet__action').exists()).toEqual(false);
+ expect(wrapper.find('.t-action-sheet__footer').exists()).toEqual(false);
});
it('cancelText', async () => {
@@ -30,34 +26,34 @@ describe('ActionSheet', () => {
visible: true,
},
});
- expect(wrapper.find('.t-action-sheet__action').text()).toEqual('取消');
+ expect(wrapper.find('.t-action-sheet__footer').text()).toEqual('取消');
await wrapper.setProps({
cancelText: 'Cancel',
});
- expect(wrapper.find('.t-action-sheet__action').text()).toEqual('Cancel');
+ expect(wrapper.find('.t-action-sheet__footer').text()).toEqual('Cancel');
});
- it('type', async () => {
+ it('theme', async () => {
const wrapper = mount(ActionSheet, {
props: {
- type: 'list',
+ theme: 'list',
items: [],
visible: true,
},
});
- expect(wrapper.find('.t-action-sheet__panel-list').exists()).toEqual(true);
- expect(wrapper.find('.t-action-sheet__panel-grid').exists()).toEqual(false);
+ expect(wrapper.find('.t-action-sheet__list').exists()).toEqual(true);
+ expect(wrapper.find('.t-action-sheet__grid').exists()).toEqual(false);
await wrapper.setProps({
- type: 'grid',
+ theme: 'grid',
});
- expect(wrapper.find('.t-action-sheet__panel-list').exists()).toEqual(false);
- expect(wrapper.find('.t-action-sheet__panel-grid').exists()).toEqual(true);
+ expect(wrapper.find('.t-action-sheet__list').exists()).toEqual(false);
+ expect(wrapper.find('.t-action-sheet__grid').exists()).toEqual(true);
});
it('count', async () => {
const wrapper = mount(ActionSheet, {
props: {
- type: 'grid',
+ theme: 'grid',
items: ['1', '2', '3'],
visible: true,
count: 2,
@@ -88,11 +84,17 @@ describe('ActionSheet', () => {
describe('events', () => {
it('onSelected', () => {
const onSelected = vi.fn();
- const wrapper = mount(() => );
- wrapper.find('button').trigger('click');
+ const wrapper = mount(ActionSheet, {
+ props: {
+ visible: true,
+ items: ['确定', '删除'],
+ onSelected,
+ },
+ });
+ wrapper.findAll('.t-action-sheet__list-item')[0].trigger('click');
expect(onSelected).toHaveBeenCalledTimes(1);
expect(onSelected).toHaveBeenLastCalledWith('确定', 0);
- wrapper.findAll('button')[1].trigger('click');
+ wrapper.findAll('.t-action-sheet__list-item')[1].trigger('click');
expect(onSelected).toHaveBeenCalledTimes(2);
expect(onSelected).toHaveBeenLastCalledWith('删除', 1);
});
@@ -100,7 +102,7 @@ describe('ActionSheet', () => {
it('onCancel', () => {
const onCancel = vi.fn();
const wrapper = mount(() => );
- wrapper.find('.t-action-sheet__action').trigger('click');
+ wrapper.find('.t-action-sheet__cancel').trigger('click');
expect(onCancel).toHaveBeenCalledTimes(1);
});
@@ -114,27 +116,6 @@ describe('ActionSheet', () => {
});
describe('MenuGrid', () => {
- function triggerTouchEvent(event, ele, clientX) {
- ele.trigger(event, {
- touches: [
- {
- clientX,
- },
- ],
- changedTouches: [
- {
- clientX,
- },
- ],
- });
- }
- async function simulateSwipe(ele, dir) {
- await triggerTouchEvent('touchstart', ele, 0);
- await triggerTouchEvent('touchmove', ele, 0);
- const distance = 51;
- await triggerTouchEvent('touchend', ele, dir === 'prev' ? distance : -distance);
- }
-
it('count', async () => {
const wrapper = mount(MenuGrid, {
props: {
@@ -152,36 +133,10 @@ describe('MenuGrid', () => {
count: 1,
},
});
- expect(wrapper.findAll('.t-action-sheet__menu')).toHaveLength(3);
+ expect(wrapper.findAll('.t-grid')).toHaveLength(3);
await wrapper.setProps({
count: 2,
});
- expect(wrapper.findAll('.t-action-sheet__menu')).toHaveLength(2);
- });
-
- it('touch move', async () => {
- const wrapper = mount(MenuGrid, {
- props: {
- items: [
- {
- label: '1',
- },
- {
- label: '2',
- },
- {
- label: '3',
- },
- ],
- count: 1,
- },
- });
-
- Object.defineProperty(wrapper.element, 'offsetWidth', { configurable: true, value: 500 });
- const slider = wrapper.find('.t-action-sheet__menu-slider');
- await simulateSwipe(slider, 'next');
- expect(getComputedStyle(slider.element).transform).toEqual('translate3d(-500px, 0, 0)');
- await simulateSwipe(slider, 'prev');
- expect(getComputedStyle(slider.element).transform).toEqual('translate3d(0px, 0, 0)');
+ expect(wrapper.findAll('.t-grid')).toHaveLength(2);
});
});
diff --git a/src/action-sheet/action-sheet-grid.vue b/src/action-sheet/action-sheet-grid.vue
new file mode 100644
index 000000000..9b92af5c8
--- /dev/null
+++ b/src/action-sheet/action-sheet-grid.vue
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/action-sheet/action-sheet-list.vue b/src/action-sheet/action-sheet-list.vue
new file mode 100644
index 000000000..efbe543d2
--- /dev/null
+++ b/src/action-sheet/action-sheet-list.vue
@@ -0,0 +1,72 @@
+
+
+
+
+ {{ item.label }}
+
+
+ {{ item.label }}
+
+ {{ item.label }}
+
+
+
+
+
diff --git a/src/action-sheet/action-sheet.en-US.md b/src/action-sheet/action-sheet.en-US.md
new file mode 100644
index 000000000..e7ecb3f27
--- /dev/null
+++ b/src/action-sheet/action-sheet.en-US.md
@@ -0,0 +1,28 @@
+:: BASE_DOC ::
+
+## API
+
+### ActionSheet Props
+
+name | type | default | description | required
+-- | -- | -- | -- | --
+align | String | center | options:center/left | N
+cancelText | String | - | \- | N
+count | Number | 8 | \- | N
+description | String | - | \- | N
+items | Array | - | required。Typescript:`Array` `interface ActionSheetItem {label: string; color?: string; disabled?: boolean }`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/action-sheet/type.ts) | Y
+showCancel | Boolean | true | \- | N
+theme | String | list | options:list/grid | N
+visible | Boolean | false | required。`v-model` and `v-model:visible` is supported | Y
+defaultVisible | Boolean | false | required。uncontrolled property | Y
+onCancel | Function | | Typescript:`(context: { e: MouseEvent }) => void`
| N
+onClose | Function | | Typescript:`(trigger: TriggerSource) => void`
[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/action-sheet/type.ts)。
`type TriggerSource = 'overlay' \| 'command' \| 'select' `
| N
+onSelected | Function | | Typescript:`(selected: ActionSheetItem \| string, index: number) => void`
| N
+
+### ActionSheet Events
+
+name | params | description
+-- | -- | --
+cancel | `(context: { e: MouseEvent })` | \-
+close | `(trigger: TriggerSource)` | [see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/action-sheet/type.ts)。
`type TriggerSource = 'overlay' \| 'command' \| 'select' `
+selected | `(selected: ActionSheetItem \| string, index: number)` | \-
diff --git a/src/action-sheet/action-sheet.md b/src/action-sheet/action-sheet.md
index 4b4902097..998e46308 100644
--- a/src/action-sheet/action-sheet.md
+++ b/src/action-sheet/action-sheet.md
@@ -1,27 +1,27 @@
:: BASE_DOC ::
## API
-
### ActionSheet Props
名称 | 类型 | 默认值 | 说明 | 必传
-- | -- | -- | -- | --
-type | string | list | 展示类型,可选项:list/grid | N
-cancelText | String | 取消 | 设置取消按钮的文本 | N
+align | String | center | 水平对齐方式。可选项:center/left | N
+cancelText | String | - | 设置取消按钮的文本 | N
count | Number | 8 | 设置每页展示菜单的数量,仅当 type=grid 时有效 | N
-items | Array | - | 必需。菜单项。TS 类型:`Array` `interface ActionSheetItem {label: string; color?: string; disabled?: boolean }`。[详细类型定义](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/action-sheet/type.ts) | Y
+description | String | - | 动作面板描述文字 | N
+items | Array | - | 必需。菜单项。TS 类型:`Array` `interface ActionSheetItem {label: string; color?: string; disabled?: boolean }`。[详细类型定义](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/action-sheet/type.ts) | Y
showCancel | Boolean | true | 是否显示取消按钮 | N
theme | String | list | 展示类型,列表和表格形式展示。可选项:list/grid | N
visible | Boolean | false | 必需。显示与隐藏。支持语法糖 `v-model` 或 `v-model:visible` | Y
defaultVisible | Boolean | false | 必需。显示与隐藏。非受控属性 | Y
onCancel | Function | | TS 类型:`(context: { e: MouseEvent }) => void`
点击取消按钮时触发 | N
-onClose | Function | | TS 类型:`(context: { e: MouseEvent }) => void`
关闭时触发 | N
-onSelected | Function | | TS 类型:`(selected: ActionSheetItem | String, index: number) => void`
选择菜单项时触发 | N
+onClose | Function | | TS 类型:`(trigger: TriggerSource) => void`
关闭时触发。[详细类型定义](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/action-sheet/type.ts)。
`type TriggerSource = 'overlay' \| 'command' \| 'select' `
| N
+onSelected | Function | | TS 类型:`(selected: ActionSheetItem \| string, index: number) => void`
选择菜单项时触发 | N
### ActionSheet Events
名称 | 参数 | 描述
-- | -- | --
cancel | `(context: { e: MouseEvent })` | 点击取消按钮时触发
-close | `(context: { e: MouseEvent })` | 关闭时触发
-selected | `(selected: ActionSheetItem | String, index: number)` | 选择菜单项时触发
+close | `(trigger: TriggerSource)` | 关闭时触发。[详细类型定义](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/action-sheet/type.ts)。
`type TriggerSource = 'overlay' \| 'command' \| 'select' `
+selected | `(selected: ActionSheetItem \| string, index: number)` | 选择菜单项时触发
diff --git a/src/action-sheet/action-sheet.vue b/src/action-sheet/action-sheet.vue
index 85d9e4cb5..a721d505f 100644
--- a/src/action-sheet/action-sheet.vue
+++ b/src/action-sheet/action-sheet.vue
@@ -1,35 +1,30 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
{{ description }}
+
+
-
-
+
+
+
+ {{ cancelText }}
+
+
+
+
diff --git a/src/action-sheet/demos/grid-multiple.vue b/src/action-sheet/demos/grid-multiple.vue
index a0df4e6e8..f34fcaa68 100644
--- a/src/action-sheet/demos/grid-multiple.vue
+++ b/src/action-sheet/demos/grid-multiple.vue
@@ -1,10 +1,10 @@
- 宫格型-多页
+ 宫格型-多页
diff --git a/src/action-sheet/index.ts b/src/action-sheet/index.ts
index 0f8acfc49..e50dd9bb4 100644
--- a/src/action-sheet/index.ts
+++ b/src/action-sheet/index.ts
@@ -1,7 +1,70 @@
-import ActionSheet from './action-sheet.vue';
-import { withInstall, WithInstallType } from '../shared';
+import { createApp, DefineComponent, ref, h, VNode, App, nextTick } from 'vue';
+import ActionSheetVue from './action-sheet.vue';
+import { WithInstallType } from '../shared';
import './style';
+import { TdActionSheetProps } from './type';
-const _ActionSheet: WithInstallType = withInstall(ActionSheet);
+export * from './type';
+export type ActionSheetProps = TdActionSheetProps;
+
+let instance: any = null;
+let app: App;
+
+function create(props: Partial): DefineComponent {
+ const root = document.createElement('div');
+ document.body.appendChild(root);
+
+ const visible = ref(false);
+ const propsObject = {
+ visible,
+ ...props,
+ };
+
+ if (instance) {
+ instance.clear();
+ }
+
+ instance = ActionSheetVue;
+
+ instance.clear = (trigger: any) => {
+ app.unmount();
+ root.remove();
+ if (propsObject.onClose && trigger && trigger.trigger !== 'overlay') {
+ propsObject.onClose(trigger);
+ }
+ instance = null;
+ };
+ app = createApp(instance, { ...propsObject });
+ app.mount(root);
+ nextTick(() => {
+ visible.value = true;
+ });
+ return instance;
+}
+
+function ActionSheet(props: Partial) {
+ create(props);
+}
+
+ActionSheet.close = (trigger: any) => {
+ if (instance) {
+ instance.clear(trigger);
+ }
+};
+
+ActionSheet.show = (props: Partial) => {
+ create(props);
+};
+
+ActionSheet.install = (app: App, name = '') => {
+ app.component(name || ActionSheetVue.name, ActionSheetVue);
+};
+
+type ActionSheetApi = {
+ /** 关闭ActionSheet */
+ close: () => void;
+};
+
+const _ActionSheet: WithInstallType & ActionSheetApi = ActionSheet as any;
export default _ActionSheet;
diff --git a/src/action-sheet/menu-grid.vue b/src/action-sheet/menu-grid.vue
deleted file mode 100644
index f4067e686..000000000
--- a/src/action-sheet/menu-grid.vue
+++ /dev/null
@@ -1,149 +0,0 @@
-
-
-
-
-
diff --git a/src/action-sheet/menu-list.vue b/src/action-sheet/menu-list.vue
deleted file mode 100644
index 4ae200b61..000000000
--- a/src/action-sheet/menu-list.vue
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
-
diff --git a/src/action-sheet/props.ts b/src/action-sheet/props.ts
index 45215d1e4..f6771355f 100644
--- a/src/action-sheet/props.ts
+++ b/src/action-sheet/props.ts
@@ -8,6 +8,15 @@ import { TdActionSheetProps } from './type';
import { PropType } from 'vue';
export default {
+ /** 水平对齐方式 */
+ align: {
+ type: String as PropType,
+ default: 'center' as TdActionSheetProps['align'],
+ validator(val: TdActionSheetProps['align']): boolean {
+ if (!val) return true;
+ return ['center', 'left'].includes(val);
+ },
+ },
/** 设置取消按钮的文本 */
cancelText: {
type: String,
@@ -18,9 +27,15 @@ export default {
type: Number,
default: 8,
},
+ /** 动作面板描述文字 */
+ description: {
+ type: String,
+ default: '',
+ },
/** 菜单项 */
items: {
type: Array as PropType,
+ default: [],
required: true,
},
/** 是否显示取消按钮 */
diff --git a/src/action-sheet/style/index.js b/src/action-sheet/style/index.js
index 0141179b0..04ef0b4c3 100644
--- a/src/action-sheet/style/index.js
+++ b/src/action-sheet/style/index.js
@@ -1 +1 @@
-import '../../_common/style/mobile/components/action-sheet/_index.less';
+import '../../_common/style/mobile/components/action-sheet/v2/_index.less';
diff --git a/src/action-sheet/type.ts b/src/action-sheet/type.ts
index b8a3cf4f0..9e096294b 100644
--- a/src/action-sheet/type.ts
+++ b/src/action-sheet/type.ts
@@ -3,11 +3,17 @@
/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */
-
+import { TNode } from '../common';
+import { TdBadgeProps } from '../badge/type';
export interface TdActionSheetProps {
+ /**
+ * 水平对齐方式
+ * @default center
+ */
+ align?: 'center' | 'left';
/**
* 设置取消按钮的文本
- * @default 取消
+ * @default ''
*/
cancelText?: string;
/**
@@ -15,10 +21,15 @@ export interface TdActionSheetProps {
* @default 8
*/
count?: number;
+ /**
+ * 动作面板描述文字
+ * @default ''
+ */
+ description?: string;
/**
* 菜单项
*/
- items: Array;
+ items?: Array;
/**
* 是否显示取消按钮
* @default true
@@ -51,15 +62,19 @@ export interface TdActionSheetProps {
/**
* 关闭时触发
*/
- onClose?: (context: { e: MouseEvent }) => void;
+ onClose?: (trigger: TriggerSource) => void;
/**
* 选择菜单项时触发
*/
- onSelected?: (selected: ActionSheetItem | String, index: number) => void;
+ onSelected?: (selected: ActionSheetItem | string, index: number) => void;
}
export interface ActionSheetItem {
label: string;
color?: string;
disabled?: boolean;
+ icon?: TNode;
+ badge?: TdBadgeProps;
}
+
+export type TriggerSource = 'overlay' | 'command' | 'select';
diff --git a/src/calendar/__test__/index.test.jsx b/src/calendar/__test__/index.test.jsx
index b72a071d2..0070d1f22 100644
--- a/src/calendar/__test__/index.test.jsx
+++ b/src/calendar/__test__/index.test.jsx
@@ -5,8 +5,8 @@ import Button from '../../button/index';
import Calendar from '../calendar.vue';
config.global.stubs = {
- teleport: true
-}
+ teleport: true,
+};
const prefix = 't';
const name = `${prefix}-calendar`;
@@ -18,7 +18,7 @@ const day = 15;
const minDate = new Date(year, month, 1);
const maxDate = new Date(year, month, 31);
const value = new Date(year, month, day);
-const confirmBtn = 'confirmBtn'
+const confirmBtn = 'confirmBtn';
const dayFormat = (date, character) => {
const D = new Date(date);
diff --git a/src/cascader/__test__/index.test.jsx b/src/cascader/__test__/index.test.jsx
index bc0729157..7d8abd0d1 100644
--- a/src/cascader/__test__/index.test.jsx
+++ b/src/cascader/__test__/index.test.jsx
@@ -6,8 +6,8 @@ import { AppIcon as TIconApp, CloseIcon } from 'tdesign-icons-vue-next';
import Radio from '../../radio/index';
config.global.stubs = {
- teleport: true
-}
+ teleport: true,
+};
const prefix = 't';
const name = `${prefix}-cascader`;
@@ -130,14 +130,14 @@ describe('cascader', () => {
// 无默认 value 值,初始化时 steps.length = 1
expect($cascaderSteps).toHaveLength(1);
const $radios = wrapper.findAllComponents(Radio);
- expect( $radios).toHaveLength(options.length);
+ expect($radios).toHaveLength(options.length);
// 模拟点击 第1项
const clickIndex = 0;
- await $radios[clickIndex].find(`.t-radio`).trigger('click')
+ await $radios[clickIndex].find(`.t-radio`).trigger('click');
expect(onPick).toHaveBeenCalledTimes(1);
expect($radios[clickIndex].findAll(`.t-radio__icon--checked`)).toHaveLength(1);
- expect (selectedValue[0]).toBe(options[0].value);
+ expect(selectedValue[0]).toBe(options[0].value);
});
});
});
diff --git a/src/dialog/__test__/index.test.jsx b/src/dialog/__test__/index.test.jsx
index bc963116f..eac59834d 100644
--- a/src/dialog/__test__/index.test.jsx
+++ b/src/dialog/__test__/index.test.jsx
@@ -5,8 +5,8 @@ import Dialog from '../dialog.vue';
import Button from '../../button/button.vue';
config.global.stubs = {
- teleport: true
-}
+ teleport: true,
+};
describe('dialog', () => {
describe('props', () => {
@@ -151,7 +151,7 @@ describe('dialog', () => {
const cancelBtn = 'cancel';
const confirmBtn = 'confirm';
const title = 'this is a title';
- const onClose = vi.fn(({trigger}) => {
+ const onClose = vi.fn(({ trigger }) => {
triggerOrigin = trigger;
});
const onCancel = vi.fn();
diff --git a/src/drawer/__test__/index.test.jsx b/src/drawer/__test__/index.test.jsx
index ca090eeae..f8703aedd 100644
--- a/src/drawer/__test__/index.test.jsx
+++ b/src/drawer/__test__/index.test.jsx
@@ -5,8 +5,8 @@ import { ref, h } from 'vue';
import { AppIcon } from 'tdesign-icons-vue-next';
config.global.stubs = {
- teleport: true
-}
+ teleport: true,
+};
describe('drawer', () => {
// test props
diff --git a/src/footer/__test__/index.test.jsx b/src/footer/__test__/index.test.jsx
index 52dca13bc..07ad51c1f 100644
--- a/src/footer/__test__/index.test.jsx
+++ b/src/footer/__test__/index.test.jsx
@@ -2,42 +2,40 @@ import { mount } from '@vue/test-utils';
import { describe, it, expect, vi } from 'vitest';
import Footer from '../footer.vue';
-
describe('footer', () => {
- describe('props', () => {
- it(': text', () => {
- const text = 'Copyright © 2019-2023 TDesign.All Rights Reserved.';
- const wrapper = mount(Footer, {
- props: { text },
- });
- const textContainer = wrapper.find('.t-footer__text');
- expect(textContainer.text()).toBe(text);
- });
-
- it(': links', () => {
- const links = [
- {
- name: '底部链接',
- url: '/pages/index',
- openType: 'navigate',
- }
- ];
- const wrapper = mount(Footer, {
- props: { links },
- });
- const textContainer = wrapper.find('.t-footer__link-item');
- expect(textContainer.text()).toBe('底部链接');
- });
+ describe('props', () => {
+ it(': text', () => {
+ const text = 'Copyright © 2019-2023 TDesign.All Rights Reserved.';
+ const wrapper = mount(Footer, {
+ props: { text },
+ });
+ const textContainer = wrapper.find('.t-footer__text');
+ expect(textContainer.text()).toBe(text);
});
- it(': logo', () => {
- const logo = {
- url: 'https://tdesign.gtimg.com/miniprogram/images/logo1.png',
- };
- const wrapper = mount(Footer, {
- props: { logo },
- });
- expect(wrapper.find('.t-footer__logo').exists()).toEqual(true);
- });
+ it(': links', () => {
+ const links = [
+ {
+ name: '底部链接',
+ url: '/pages/index',
+ openType: 'navigate',
+ },
+ ];
+ const wrapper = mount(Footer, {
+ props: { links },
+ });
+ const textContainer = wrapper.find('.t-footer__link-item');
+ expect(textContainer.text()).toBe('底部链接');
+ });
+ });
-});
\ No newline at end of file
+ it(': logo', () => {
+ const logo = {
+ url: 'https://tdesign.gtimg.com/miniprogram/images/logo1.png',
+ };
+ const wrapper = mount(Footer, {
+ props: { logo },
+ });
+ expect(wrapper.find('.t-footer__logo').exists()).toEqual(true);
+ });
+});
diff --git a/src/picker/__test__/index.test.jsx b/src/picker/__test__/index.test.jsx
index 95e9744fa..ce378b9ea 100644
--- a/src/picker/__test__/index.test.jsx
+++ b/src/picker/__test__/index.test.jsx
@@ -157,7 +157,11 @@ describe('picker', () => {
await simulateMoveOption(wrapper.find('.t-picker-item').element, 2);
await wrapper.find('.t-picker__confirm').trigger('click');
expect(onConfirm).toBeCalledTimes(1);
- expect(onConfirm).toBeCalledWith([seasonOptions[2].value], { e: expect.any(MouseEvent), index: [2], label: ['秋'] });
+ expect(onConfirm).toBeCalledWith([seasonOptions[2].value], {
+ e: expect.any(MouseEvent),
+ index: [2],
+ label: ['秋'],
+ });
});
it(': pick', async () => {
diff --git a/src/popup/__test__/index.test.jsx b/src/popup/__test__/index.test.jsx
index b6b441830..8281a01a6 100644
--- a/src/popup/__test__/index.test.jsx
+++ b/src/popup/__test__/index.test.jsx
@@ -4,8 +4,8 @@ import Popup from '../popup.vue';
import { ref } from 'vue';
config.global.stubs = {
- teleport: true
-}
+ teleport: true,
+};
describe('popup', () => {
// test props api
@@ -33,7 +33,7 @@ describe('popup', () => {
const wrapper = mount(Popup, {
props: {
placement: 'top',
- visible: true
+ visible: true,
},
});
expect(wrapper.find('.t-popup').classes()).toContain(`t-popup--${wrapper.vm.placement}`);
@@ -47,7 +47,7 @@ describe('popup', () => {
const wrapper = mount(Popup, {
props: {
zIndex: 15000,
- visible: true
+ visible: true,
},
});
expect(wrapper.find('.t-popup').attributes('style')).toContain('z-index: 15000');
@@ -94,7 +94,7 @@ describe('popup', () => {
onClosed={closed}
/>
);
- }
+ },
});
const $popup = wrapper.find('.t-popup');
diff --git a/src/switch/__test__/index.test.jsx b/src/switch/__test__/index.test.jsx
index aaf43f189..4b4f9f55a 100644
--- a/src/switch/__test__/index.test.jsx
+++ b/src/switch/__test__/index.test.jsx
@@ -30,7 +30,7 @@ describe('switch', () => {
const $label = wrapper.find('.t-switch__label');
expect($label.text()).toBe('close');
- await wrapper.trigger('click')
+ await wrapper.trigger('click');
expect($label.text()).toBe('open');
});
diff --git a/tsconfig.json b/tsconfig.json
index 68ec330cd..8e571afae 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -35,6 +35,7 @@
"src/**/*.js",
"babel.config.js",
"src/style/index.js",
- "scripts/rollup.config.js"],
+ "scripts/rollup.config.js"
+ ],
"exclude": ["node_modules", "src/_common", "dist", "es", "esm", "lib", "site"]
}