diff --git a/src/_common b/src/_common
index 0a709515d..a2a5496ea 160000
--- a/src/_common
+++ b/src/_common
@@ -1 +1 @@
-Subproject commit 0a709515dd1bdebc42e18f4224c6b99395b01a55
+Subproject commit a2a5496ea3a2769b9d33b64b063b85fa6bab5b18
diff --git a/src/loading/__test__/__snapshots__/demo.test.jsx.snap b/src/loading/__test__/__snapshots__/demo.test.jsx.snap
index cca86f152..4b71c6da7 100644
--- a/src/loading/__test__/__snapshots__/demo.test.jsx.snap
+++ b/src/loading/__test__/__snapshots__/demo.test.jsx.snap
@@ -1,34 +1,5 @@
// Vitest Snapshot v1
-exports[`Loading > Loading barVue demo works fine 1`] = `
-
-
-
-
-
-
-
-
-`;
-
exports[`Loading > Loading baseVue demo works fine 1`] = `
Loading baseVue demo works fine 1`] = `
-
-
Loading baseVue demo works fine 1`] = `
-
-
@@ -174,13 +152,11 @@ exports[`Loading > Loading delayVue demo works fine 1`] = `
-
-
@@ -194,10 +170,9 @@ exports[`Loading > Loading horzVue demo works fine 1`] = `
-
-
Loading horzVue demo works fine 1`] = `
加载中...
-
@@ -314,12 +286,12 @@ exports[`Loading > Loading mobileVue demo works fine 1`] = `
- 01 类型
+ 01 组件类型
- 纯icon
+ 纯图标
Loading mobileVue demo works fine 1`] = `
-
-
Loading mobileVue demo works fine 1`] = `
-
-
@@ -442,7 +421,7 @@ exports[`Loading > Loading mobileVue demo works fine 1`] = `
- icon加文字横向
+ 图标加文字横向
Loading mobileVue demo works fine 1`] = `
-
-
Loading mobileVue demo works fine 1`] = `
加载中...
-
@@ -557,7 +532,7 @@ exports[`Loading > Loading mobileVue demo works fine 1`] = `
- icon加文字竖向
+ 图标加文字竖向
Loading mobileVue demo works fine 1`] = `
data-v-448d2bed=""
>
-
-
-
-
-
-
-
-
- 纯文字
-
-
-
-
-
- 加载中...
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
- 加载失败
+ 加载中...
-
-
-
-
-
-
-
-
- 加载失败
-
- 刷新
-
-
-
-
@@ -693,35 +647,26 @@ exports[`Loading > Loading mobileVue demo works fine 1`] = `
- 进度条加载
+ 纯文字
-
-
-
-
+
+
@@ -732,13 +677,9 @@ exports[`Loading > Loading mobileVue demo works fine 1`] = `
- 02 状态
+ 02 组件尺寸
-
- 如果加载状态在延迟内结束,则不显示
-
+
Loading mobileVue demo works fine 1`] = `
>
-
+
-
+
+
+
+
- 请求结束,隐藏loading
-
+ 加载中...
+
+
+
+
+ 中尺寸
-
-
+
+
+
+ 加载中...
+
+
+
+ 小尺寸
+
+
+
+
+
+ 加载中...
+
+
@@ -797,7 +822,7 @@ exports[`Loading > Loading mobileVue demo works fine 1`] = `
- 加载速度可配置,加载一周的时间单位(毫秒)
+ 加载速度调整
Loading mobileVue demo works fine 1`] = `
-
-
- 速度调整
-
-
- 0
-
+
@@ -870,13 +883,13 @@ exports[`Loading > Loading mobileVue demo works fine 1`] = `
@@ -888,228 +901,47 @@ exports[`Loading > Loading mobileVue demo works fine 1`] = `
-
- 800
-
+
-
-
- 04 规格
-
-
- 支持自定义加载规格
-
-
-
-
-
-
-
-
-
-
- 加载中(小)...
-
-
-
-
-
-
-
-
-
-
- 加载中(中)...
-
-
-
-
-
-
-
-
-
-
- 加载中(大)...
-
-
-
-
-
-
-
-
`;
exports[`Loading > Loading pureTextVue demo works fine 1`] = `
-
-
-
-
- 加载中...
-
-
-
-
-
+
-
-
-
-
-
- 加载失败
-
-
-
-
-
-
-
-
-
-
- 加载失败
-
- 刷新
-
-
-
-
-
+ 加载中...
+
+
`;
exports[`Loading > Loading sizeVue demo works fine 1`] = `
+
-
+ 大尺寸
+
+
-
+ 中尺寸
+
+
-
+ 小尺寸
+
+
+
`;
@@ -1223,14 +1063,13 @@ exports[`Loading > Loading speedVue demo works fine 1`] = `
-
-
- 速度调整
-
-
- 0
-
+
@@ -1285,13 +1113,13 @@ exports[`Loading > Loading speedVue demo works fine 1`] = `
@@ -1303,11 +1131,7 @@ exports[`Loading > Loading speedVue demo works fine 1`] = `
-
- 800
-
+
@@ -1315,13 +1139,16 @@ exports[`Loading > Loading speedVue demo works fine 1`] = `
`;
exports[`Loading > Loading vertVue demo works fine 1`] = `
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 加载中...
+
+
`;
diff --git a/src/loading/__test__/__snapshots__/index.test.jsx.snap b/src/loading/__test__/__snapshots__/index.test.jsx.snap
index dd00f5191..201914b5c 100644
--- a/src/loading/__test__/__snapshots__/index.test.jsx.snap
+++ b/src/loading/__test__/__snapshots__/index.test.jsx.snap
@@ -3,10 +3,9 @@
exports[`Loading.vue > props > :pause 1`] = `
-
`;
exports[`Loading.vue > props > :reverse 1`] = `
-
`;
diff --git a/src/loading/__test__/demo.test.jsx b/src/loading/__test__/demo.test.jsx
index 61173f186..1eff088ac 100644
--- a/src/loading/__test__/demo.test.jsx
+++ b/src/loading/__test__/demo.test.jsx
@@ -3,7 +3,6 @@
*/
import { mount } from '@vue/test-utils';
-import barVue from '@/loading/demos/bar.vue';
import baseVue from '@/loading/demos/base.vue';
import delayVue from '@/loading/demos/delay.vue';
import horzVue from '@/loading/demos/horz.vue';
@@ -14,7 +13,6 @@ import speedVue from '@/loading/demos/speed.vue';
import vertVue from '@/loading/demos/vert.vue';
const mapper = {
- barVue,
baseVue,
delayVue,
horzVue,
diff --git a/src/loading/__test__/index.test.jsx b/src/loading/__test__/index.test.jsx
index 77425a734..b87029f29 100644
--- a/src/loading/__test__/index.test.jsx
+++ b/src/loading/__test__/index.test.jsx
@@ -14,13 +14,6 @@ describe('Loading.vue', () => {
vi.restoreAllMocks();
});
- it(':progress', () => {
- const wrapper = mount(() =>
);
-
- const shadow = wrapper.find('.t-loading__shadow');
- expect(shadow.exists()).toBeTruthy();
- });
-
it(':delay', async () => {
const wrapper = mount(() =>
);
expect(wrapper.find('.t-icon-loading').exists()).not.toBeTruthy();
@@ -29,19 +22,13 @@ describe('Loading.vue', () => {
expect(wrapper.find('.t-icon-loading').exists()).toBeTruthy();
});
- it(':error', () => {
- const wrapper = mount(() =>
);
- const errorBlock = wrapper.find('.t-loading__text');
- expect(errorBlock.element.innerHTML).toBe('加载失败');
- });
-
it(':inheritColor', () => {
const wrapper = mount(Loading, {
props: {
inheritColor: true,
},
});
- expect(wrapper.vm.rootStyle).toBe('color: inherit');
+ expect(wrapper.vm.rootStyle).toContain('color: inherit');
});
it(':pause', () => {
diff --git a/src/loading/demos/bar.vue b/src/loading/demos/bar.vue
deleted file mode 100644
index 53fb3e0d8..000000000
--- a/src/loading/demos/bar.vue
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
- {{
- progress > 0 && progress < 1 ? '页面加载中...' : '页面进度条加载'
- }}
-
-
-
diff --git a/src/loading/demos/base.vue b/src/loading/demos/base.vue
index 43ddab4af..b6b0a4de5 100644
--- a/src/loading/demos/base.vue
+++ b/src/loading/demos/base.vue
@@ -6,6 +6,6 @@
diff --git a/src/loading/demos/mobile.vue b/src/loading/demos/mobile.vue
index a2a1409fd..04e45cca3 100644
--- a/src/loading/demos/mobile.vue
+++ b/src/loading/demos/mobile.vue
@@ -2,17 +2,17 @@
Loading 加载中
用于表示页面或操作的加载状态,给予用户反馈的同时减缓等待的焦虑感,由一个或一组反馈动效组成。
-
+
-
+
-
+
@@ -22,37 +22,24 @@
-
-
-
-
-
-
+
-
+
-
+
-
-
-
-
-
diff --git a/src/loading/demos/pure-text.vue b/src/loading/demos/pure-text.vue
index bd1a77b9c..751c42b34 100644
--- a/src/loading/demos/pure-text.vue
+++ b/src/loading/demos/pure-text.vue
@@ -1,30 +1,3 @@
-
-
-
-
-
- 加载失败
- 刷新
-
-
-
+
-
-
-
-
diff --git a/src/loading/demos/size.vue b/src/loading/demos/size.vue
index 09ed9659d..e1652f49d 100644
--- a/src/loading/demos/size.vue
+++ b/src/loading/demos/size.vue
@@ -1,15 +1,16 @@
-
-
-
-
-
+ 大尺寸
+
+ 中尺寸
+
+ 小尺寸
+
diff --git a/src/loading/demos/speed.vue b/src/loading/demos/speed.vue
index 6fa6e7d2f..a2ad17d39 100644
--- a/src/loading/demos/speed.vue
+++ b/src/loading/demos/speed.vue
@@ -1,15 +1,14 @@
-
+
- 速度调整
-
+
diff --git a/src/loading/loading.en-US.md b/src/loading/loading.en-US.md
new file mode 100644
index 000000000..c3cd950e0
--- /dev/null
+++ b/src/loading/loading.en-US.md
@@ -0,0 +1,21 @@
+:: BASE_DOC ::
+
+## API
+### Loading Props
+
+name | type | default | description | required
+-- | -- | -- | -- | --
+content | String / Slot / Function | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
+default | String / Slot / Function | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
+delay | Number | 0 | \- | N
+duration | Number | 800 | \- | N
+indicator | Boolean | true | \- | N
+inheritColor | Boolean | false | \- | N
+layout | String | horizontal | options:horizontal/vertical | N
+loading | Boolean | true | \- | N
+pause | Boolean | false | \- | N
+progress | Number | - | \- | N
+reverse | Boolean | - | \- | N
+size | String | '20px' | \- | N
+text | String / Slot / Function | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
+theme | String | circular | options:circular/spinner/dots | N
diff --git a/src/loading/loading.md b/src/loading/loading.md
index 0bb46083b..6fc6b2502 100644
--- a/src/loading/loading.md
+++ b/src/loading/loading.md
@@ -1,22 +1,21 @@
:: BASE_DOC ::
## API
-
### Loading Props
-| 名称 | 类型 | 默认值 | 说明 | 必传 |
-| ------------ | ------------------------ | ---------- | --------------------------------------------------------------------------------------------------------------------------------------- | ---- |
-| default | String / Slot / Function | - | 子元素,同 content。TS 类型:`string | TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N |
-| delay | Number | 0 | 延迟显示加载效果的时间,用于防止请求速度过快引起的加载闪烁,单位:毫秒 | N |
-| content | String / Slot / Function | - | 子元素。TS 类型:`string | TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N |
-| duration | Number | 800 | 加载动画执行完成一次的时间,单位:毫秒 | N |
-| indicator | Boolean | true | 是否显示加载指示符 | N |
-| inheritColor | Boolean | false | 是否继承父元素颜色 | N |
-| layout | String | horizontal | 对齐方式。可选项:horizontal/vertical | N |
-| loading | Boolean | true | 是否处于加载状态 | N |
-| pause | Boolean | false | 是否暂停动画 | N |
-| progress | Number | - | 加载进度 | N |
-| reverse | Boolean | - | 加载动画是否反向 | N |
-| size | String | '40rpx' | 尺寸,示例:40rpx/20px | N |
-| text | String / Slot | - | 加载提示文案 | N |
-| theme | String | circular | 加载组件类型。可选项:circular/spinner/bar/error/dots | N |
+名称 | 类型 | 默认值 | 说明 | 必传
+-- | -- | -- | -- | --
+content | String / Slot / Function | - | 子元素。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
+default | String / Slot / Function | - | 子元素,同 content。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
+delay | Number | 0 | 延迟显示加载效果的时间,用于防止请求速度过快引起的加载闪烁,单位:毫秒 | N
+duration | Number | 800 | 加载动画执行完成一次的时间,单位:毫秒 | N
+indicator | Boolean | true | 是否显示加载指示符 | N
+inheritColor | Boolean | false | 是否继承父元素颜色 | N
+layout | String | horizontal | 对齐方式。可选项:horizontal/vertical | N
+loading | Boolean | true | 是否处于加载状态 | N
+pause | Boolean | false | 是否暂停动画 | N
+progress | Number | - | 加载进度 | N
+reverse | Boolean | - | 加载动画是否反向 | N
+size | String | '20px' | 尺寸,示例:20px | N
+text | String / Slot / Function | - | 加载提示文案。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
+theme | String | circular | 加载组件类型。可选项:circular/spinner/dots | N
diff --git a/src/loading/loading.vue b/src/loading/loading.vue
index 73904f57f..6342fda2f 100644
--- a/src/loading/loading.vue
+++ b/src/loading/loading.vue
@@ -1,19 +1,27 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
@@ -22,7 +30,6 @@ import { defineComponent, getCurrentInstance, computed, ref, watch, toRefs } fro
import GradientIcon from './icon/gradient.vue';
import SpinnerIcon from './icon/spinner.vue';
import { renderTNode, TNode, renderContent } from '../shared';
-import CLASSNAMES from '../shared/constants';
import config from '../config';
import LoadingProps from './props';
@@ -30,12 +37,6 @@ import LoadingProps from './props';
const { prefix } = config;
const name = `${prefix}-loading`;
-const toBarPerc = (n?: number) => {
- if (!n || n <= 0) return -100;
- if (n > 1) return 0;
- return (-1 + n) * 100;
-};
-
export default defineComponent({
name,
components: {
@@ -71,39 +72,32 @@ export default defineComponent({
},
);
- const rootClass = computed(() => [
- name,
- { [`${name}--vertical`]: props.layout === 'vertical' },
- { [`${name}--bar`]: props.theme === 'bar' },
- props.size ? CLASSNAMES.SIZE[props.size] : '',
- ]);
+ const rootClass = computed(() => [name, { [`${name}--vertical`]: props.layout === 'vertical' }]);
const textClass = computed(() => [
`${name}__text`,
- { [`${name}__text--error`]: props.theme === 'error' },
{
- [`${name}__text--only`]: !props.indicator || props.theme === 'error',
+ [`${name}__text--only`]: !props.indicator,
},
]);
const textContent = computed(() => {
- if (props.theme === 'error') {
- return '加载失败';
- }
return renderTNode(internalInstance, 'text');
});
const defaultContent = computed(() => renderContent(internalInstance, 'default', 'content'));
const rootStyle = computed(() => {
+ const style = [];
if (props.inheritColor) {
- return 'color: inherit';
+ style.push('color: inherit');
+ }
+ if (props.size) {
+ style.push(`font-size: ${props.size}`);
}
- return '';
+ return style.join(';');
});
- const barStyle = computed(() => ({
- transform: `translate3d(${toBarPerc(props.progress)}%, 0px, 0px)`,
- }));
+
const animationStyle = computed(() => {
const ans: Record = {};
if (props.pause) {
@@ -126,7 +120,6 @@ export default defineComponent({
textContent,
defaultContent,
rootStyle,
- barStyle,
animationStyle,
realLoading,
};
diff --git a/src/loading/props.ts b/src/loading/props.ts
index e0be73992..b4b608ed5 100644
--- a/src/loading/props.ts
+++ b/src/loading/props.ts
@@ -8,14 +8,14 @@ import { TdLoadingProps } from './type';
import { PropType } from 'vue';
export default {
- /** 子元素,同 content */
- default: {
- type: [String, Function] as PropType,
- },
/** 子元素 */
content: {
type: [String, Function] as PropType,
},
+ /** 子元素,同 content */
+ default: {
+ type: [String, Function] as PropType,
+ },
/** 延迟显示加载效果的时间,用于防止请求速度过快引起的加载闪烁,单位:毫秒 */
delay: {
type: Number,
@@ -55,14 +55,14 @@ export default {
},
/** 加载动画是否反向 */
reverse: Boolean,
- /** 尺寸,示例:40rpx/20px */
+ /** 尺寸,示例:20px */
size: {
type: String,
- default: '40rpx',
+ default: '20px',
},
/** 加载提示文案 */
text: {
- type: String,
+ type: [String, Function] as PropType,
},
/** 加载组件类型 */
theme: {
@@ -70,7 +70,7 @@ export default {
default: 'circular' as TdLoadingProps['theme'],
validator(val: TdLoadingProps['theme']): boolean {
if (!val) return true;
- return ['circular', 'spinner', 'bar', 'error', 'dots'].includes(val);
+ return ['circular', 'spinner', 'dots'].includes(val);
},
},
};
diff --git a/src/loading/type.ts b/src/loading/type.ts
index e2d028f8f..b39d15193 100644
--- a/src/loading/type.ts
+++ b/src/loading/type.ts
@@ -7,14 +7,14 @@
import { TNode } from '../common';
export interface TdLoadingProps {
- /**
- * 子元素,同 content
- */
- default?: string | TNode;
/**
* 子元素
*/
content?: string | TNode;
+ /**
+ * 子元素,同 content
+ */
+ default?: string | TNode;
/**
* 延迟显示加载效果的时间,用于防止请求速度过快引起的加载闪烁,单位:毫秒
* @default 0
@@ -59,17 +59,17 @@ export interface TdLoadingProps {
*/
reverse?: boolean;
/**
- * 尺寸,示例:40rpx/20px
- * @default '40rpx'
+ * 尺寸,示例:20px
+ * @default '20px'
*/
size?: string;
/**
* 加载提示文案
*/
- text?: string;
+ text?: string | TNode;
/**
* 加载组件类型
* @default circular
*/
- theme?: 'circular' | 'spinner' | 'bar' | 'error' | 'dots';
+ theme?: 'circular' | 'spinner' | 'dots';
}
diff --git a/src/switch/__test__/__snapshots__/demo.test.jsx.snap b/src/switch/__test__/__snapshots__/demo.test.jsx.snap
index 237457a39..b36b73e6c 100644
--- a/src/switch/__test__/__snapshots__/demo.test.jsx.snap
+++ b/src/switch/__test__/__snapshots__/demo.test.jsx.snap
@@ -460,10 +460,9 @@ exports[`Switch > Switch mobileVue demo works fine 1`] = `
>
-
@@ -528,10 +526,9 @@ exports[`Switch > Switch mobileVue demo works fine 1`] = `
>
-
@@ -955,10 +951,9 @@ exports[`Switch > Switch statusVue demo works fine 1`] = `
>
-
@@ -1023,10 +1017,9 @@ exports[`Switch > Switch statusVue demo works fine 1`] = `
>
-