Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/_common
Submodule _common updated 79 files
+1 −1 .github/workflows/tdesign-component-repositories-ci.yml
+2 −1 docs/plugins/changelog-to-json/libs.ts
+1 −1 docs/plugins/changelog-to-json/types.ts
+19 −0 docs/web/api/attachments.md
+0 −12 docs/web/api/chat-action.md
+12 −0 docs/web/api/chat-actionbar.md
+0 −63 docs/web/api/chat-ai.md
+1 −1 docs/web/api/chat-content.md
+1 −1 docs/web/api/chat-input.md
+1 −1 docs/web/api/chat-item.md
+45 −0 docs/web/api/chat-list.md
+1 −1 docs/web/api/chat-loading.md
+33 −0 docs/web/api/chat-markdown.md
+33 −0 docs/web/api/chat-message.md
+1 −1 docs/web/api/chat-reasoning.md
+16 −4 docs/web/api/chat-sender.md
+22 −0 docs/web/api/chat-thinking.md
+0 −37 docs/web/api/chat.md
+31 −0 docs/web/api/chatbot.md
+13 −10 js/components.ts
+52 −5 js/date-picker/format.ts
+1 −0 js/global-config/locale/ar_KW.ts
+2 −0 js/global-config/locale/en_US.ts
+2 −0 js/global-config/locale/it_IT.ts
+2 −0 js/global-config/locale/ja_JP.ts
+3 −1 js/global-config/locale/ko_KR.ts
+2 −0 js/global-config/locale/ru_RU.ts
+2 −0 js/global-config/locale/zh_CN.ts
+1 −0 js/global-config/locale/zh_TW.ts
+8 −0 js/image-viewer/types.d.ts
+95 −0 js/image-viewer/utils.ts
+108 −0 js/message/animation.ts
+56 −0 js/message/consts.ts
+2 −0 js/message/index.ts
+2 −0 js/slider/utils.ts
+2 −0 js/tree-v1/tree-node-model.ts
+129 −55 js/tree-v1/tree-node.ts
+2 −0 js/tree-v1/types.ts
+62 −50 js/tree/tree-node.ts
+5 −2 js/upload/main.ts
+2 −0 js/upload/types.ts
+8 −1 js/upload/xhr.ts
+1 −1 naming.md
+31 −0 style/mobile/_variables.less
+2 −1 style/mobile/components/action-sheet/_index.less
+1 −1 style/mobile/components/back-top/_var.less
+1 −0 style/mobile/components/calendar/_index.less
+1 −1 style/mobile/components/cascader/_index.less
+6 −13 style/mobile/components/cascader/_var.less
+3 −3 style/mobile/components/dialog/_index.less
+2 −0 style/mobile/components/dialog/_var.less
+2 −2 style/mobile/components/divider/_index.less
+1 −0 style/mobile/components/divider/_var.less
+1 −0 style/mobile/components/drawer/_index.less
+4 −0 style/mobile/components/dropdown-menu/_index.less
+10 −6 style/mobile/components/grid-item/_index.less
+16 −38 style/mobile/components/grid-item/_var.less
+6 −2 style/mobile/components/input/_index.less
+2 −0 style/mobile/components/input/_var.less
+1 −1 style/mobile/components/loading/_index.less
+1 −1 style/mobile/components/navbar/_index.less
+1 −1 style/mobile/components/picker/_index.less
+2 −0 style/mobile/components/picker/_var.less
+12 −0 style/mobile/components/popover/_mixin.less
+1 −0 style/mobile/components/popover/_var.less
+13 −3 style/mobile/components/slider/_index.less
+5 −3 style/mobile/components/slider/_var.less
+12 −12 style/mobile/components/swiper-nav/_index.less
+3 −1 style/mobile/components/swiper-nav/_var.less
+2 −2 style/mobile/components/toast/_var.less
+1 −0 style/mobile/components/tree-select/_index.less
+4 −4 style/mobile/components/tree-select/_var.less
+1 −0 style/mobile/components/upload/_index.less
+5 −0 style/mobile/theme/_components.less
+44 −0 style/mobile/theme/_font.less
+127 −48 style/web/components/chat/_index.less
+1 −1 style/web/components/chat/_var.less
+2 −2 style/web/components/descriptions/_index.less
+2 −1 style/web/components/select/_index.less
22 changes: 12 additions & 10 deletions src/slider/slider-button.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import Vue, { VNode, PropType, VueConstructor } from 'vue';
import { Styles } from '../common';
import Slider from './slider';
import Tooltip from '../tooltip/index';
import ITooltip from '../tooltip/tooltip';
import Vue, { PropType, VNode, VueConstructor } from 'vue';

import { formatLabel, formatPrecision } from '../_common/js/slider/utils';
import { getIEVersion } from '../_common/js/utils/helper';
import { TdSliderProps } from './type';
import { TdTooltipProps } from '../tooltip/type';
import { renderTNodeJSX } from '../utils/render-tnode';
import { getClassPrefixMixins } from '../config-provider/config-receiver';
import { formatLabel } from '../_common/js/slider/utils';
import Tooltip from '../tooltip/index';
import ITooltip from '../tooltip/tooltip';
import mixins from '../utils/mixins';
import { renderTNodeJSX } from '../utils/render-tnode';
import Slider from './slider';

import type { Styles } from '../common';
import type { TdTooltipProps } from '../tooltip/type';
import type { TdSliderProps } from './type';

const classPrefixMixins = getClassPrefixMixins('slider__button');

Expand Down Expand Up @@ -301,7 +303,7 @@ export default mixins(classPrefixMixins, Vue as VueConstructor<SliderInstanceTyp
const steps = Math.round(newPos / perStepLen);
let value = steps * perStepLen * this.rangeDiff * 0.01;
value += this.min;
value = Number(parseFloat(`${value}`).toFixed(this.precision));
value = formatPrecision(value, this.precision);
this.$emit('input', value);
this.$nextTick(() => {
this.showTooltipComponent();
Expand Down
36 changes: 20 additions & 16 deletions src/slider/slider.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import Vue, { VNode } from 'vue';

import { formatPrecision } from '../_common/js/slider/utils';
import { getClassPrefixMixins } from '../config-provider/config-receiver';
import InputNumber from '../input-number/index';
import { emitEvent } from '../utils/event';
import { TNode, ClassName } from '../common';
import mixins from '../utils/mixins';
import props from './props';
import InputNumber from '../input-number/index';
import TSliderMark from './slider-mark';
import { SliderValue, TdSliderProps } from './type';
import TSliderButton from './slider-button';
import { getClassPrefixMixins } from '../config-provider/config-receiver';
import mixins from '../utils/mixins';
import TSliderMark from './slider-mark';

import type { ClassName, TNode } from '../common';
import type { SliderValue, TdSliderProps } from './type';

const classPrefixMixins = getClassPrefixMixins('slider');

Expand Down Expand Up @@ -186,9 +189,10 @@ export default mixins(classPrefixMixins).extend({
value(newVal: SliderValue) {
if (this.dragging === true) return;
if (Array.isArray(newVal) && this.range) {
[this.firstValue, this.secondValue] = newVal;
this.firstValue = formatPrecision(newVal[0], this.precision);
this.secondValue = formatPrecision(newVal[1], this.precision);
} else {
this.prevValue = newVal as number;
this.prevValue = formatPrecision(newVal as number, this.precision);
}
},
dragging(newVal: boolean) {
Expand All @@ -211,18 +215,18 @@ export default mixins(classPrefixMixins).extend({
const { min, max, value } = this;
if (this.range) {
if (Array.isArray(value)) {
this.firstValue = Math.max(min || 0, value[0] ?? 0);
this.secondValue = Math.min(max || 100, value[1] ?? 0);
this.firstValue = formatPrecision(Math.max(min || 0, value[0] ?? 0), this.precision);
this.secondValue = formatPrecision(Math.min(max || 100, value[1] ?? 0), this.precision);
} else {
this.firstValue = min || 0;
this.secondValue = max || 100;
this.firstValue = formatPrecision(min || 0, this.precision);
this.secondValue = formatPrecision(max || 100, this.precision);
}
valuetext = `${this.firstValue}-${this.secondValue}`;
} else {
if (typeof this.value !== 'number') {
this.prevValue = min;
this.prevValue = formatPrecision(min, this.precision);
} else {
this.prevValue = Math.min(max, Math.max(min, value as number));
this.prevValue = formatPrecision(Math.min(max, Math.max(min, value as number)), this.precision);
}
valuetext = String(this.prevValue);
}
Expand Down Expand Up @@ -250,12 +254,12 @@ export default mixins(classPrefixMixins).extend({
if (firstValue < min) firstValue = min;
if (secondValue < min) secondValue = this.secondValue;
if (secondValue > max) secondValue = max;
return [firstValue, secondValue];
return [formatPrecision(firstValue, this.precision), formatPrecision(secondValue, this.precision)];
}
let prevValue = value as number;
if (prevValue < min) prevValue = min;
if (prevValue > max) prevValue = max;
return prevValue;
return formatPrecision(prevValue, this.precision);
},
// 相应button的位置
setPosition(percent: number): void {
Expand Down
22 changes: 0 additions & 22 deletions src/swiper/__tests__/__snapshots__/index.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -197,28 +197,6 @@ exports[`Swiper > :props > :navigation 1`] = `
</div>
`;

exports[`Swiper > :props > :theme 1`] = `
<div
class="t-swiper"
>
<div
class="t-swiper__wrap t-swiper--inside"
>
<div
class="t-swiper__content"
>
<div
class="t-swiper__container"
style="transform: translate3d(-0%, 0px, 0px);"
/>
</div>
<ul
class="t-swiper__navigation t-swiper__navigation-bars"
/>
</div>
</div>
`;

exports[`Swiper > :props > :type 1`] = `
<div
class="t-swiper"
Expand Down
13 changes: 0 additions & 13 deletions src/swiper/__tests__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,6 @@ describe('Swiper', () => {
});
expect(wrapper.element).toMatchSnapshot();
});
it(':theme', () => {
const wrapper = mount({
render() {
return (
<Swiper theme={'dark'}>
<SwiperItem>1</SwiperItem>
<SwiperItem>2</SwiperItem>
</Swiper>
);
},
});
expect(wrapper.element).toMatchSnapshot();
});
it(':type', () => {
const wrapper = mount({
render() {
Expand Down
49 changes: 29 additions & 20 deletions src/swiper/_example/card.vue
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
<template>
<div class="tdesign-demo-block--swiper">
<t-swiper type="card" :height="280">
<t-swiper-item>
<div class="demo-item">1</div>
</t-swiper-item>
<t-swiper-item>
<div class="demo-item">2</div>
</t-swiper-item>
<t-swiper-item>
<div class="demo-item">3</div>
</t-swiper-item>
<t-swiper-item>
<div class="demo-item">4</div>
</t-swiper-item>
<t-swiper-item>
<div class="demo-item">5</div>
</t-swiper-item>
<t-swiper-item>
<div class="demo-item">6</div>
</t-swiper-item>
</t-swiper>
<t-space direction="vertical" :size="50" style="width: 100%">
<t-space direction="vertical" style="width: 100%">
<t-tag theme="primary" variant="outline">卡片缩放比例</t-tag>

<t-slider v-model="cardScale" :min="0" :max="1" :step="0.01" :marks="marks" />
</t-space>

<t-swiper type="card" :height="280" :autoplay="false" :card-scale="cardScale">
<t-swiper-item v-for="i in 6" :key="i">
<div class="demo-item">{{ i }}</div>
</t-swiper-item>
</t-swiper>
</t-space>
</div>
</template>

<script>
export default {
data() {
const DEFAULT_SCALE = 210 / 332;

return {
cardScale: DEFAULT_SCALE,
DEFAULT_SCALE,
marks: {
[DEFAULT_SCALE]: 'Default',
},
};
},
};
</script>
15 changes: 0 additions & 15 deletions src/swiper/_usage/props.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,6 @@
"defaultValue": true,
"options": []
},
{
"name": "theme",
"type": "enum",
"defaultValue": "light",
"options": [
{
"label": "light",
"value": "light"
},
{
"label": "dark",
"value": "dark"
}
]
},
{
"name": "trigger",
"type": "enum",
Expand Down
14 changes: 5 additions & 9 deletions src/swiper/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export default {
type: Boolean,
default: true,
},
/** 卡片模式下非当前展示轮播图的缩放比例 */
cardScale: {
type: Number,
default: 210 / 332,
},
/** 当前轮播在哪一项(下标) */
current: {
type: Number,
Expand Down Expand Up @@ -69,15 +74,6 @@ export default {
type: Boolean,
default: true,
},
/** 深色模式和浅色模式 */
theme: {
type: String as PropType<TdSwiperProps['theme']>,
default: 'light' as TdSwiperProps['theme'],
validator(val: TdSwiperProps['theme']): boolean {
if (!val) return true;
return ['light', 'dark'].includes(val);
},
},
/** 触发切换的方式:悬浮、点击等 */
trigger: {
type: String as PropType<TdSwiperProps['trigger']>,
Expand Down
29 changes: 19 additions & 10 deletions src/swiper/swiper-item.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
import { VNode } from 'vue';
import props from './props';
import { getClassPrefixMixins } from '../config-provider/config-receiver';
import mixins from '../utils/mixins';
import props from './props';

const classPrefixMixins = getClassPrefixMixins('swiper');

const CARD_SCALE = 210 / 332; // 缩放比例
const ITEM_WIDTH = 0.415; // 依据设计稿使用t-swiper__card控制每个swiper的宽度为41.5%

const swiperItemProps = {
index: {
type: Number,
},
currentIndex: {
type: Number,
},
cardScale: {
type: Number,
default: CARD_SCALE,
},
isSwitching: {
type: Boolean,
default: false,
},
getWrapAttribute: {
type: Function,
swiperWidth: {
type: Number,
default: 0,
},
swiperItemLength: {
type: Number,
default: 0,
},
};
const CARD_SCALE = 210 / 332; // 缩放比例
const itemWidth = 0.415; // 依据设计稿使用t-swiper__card控制每个swiper的宽度为41.5%

export default mixins(classPrefixMixins).extend({
name: 'TSwiperItem',
Expand Down Expand Up @@ -58,16 +64,19 @@ export default mixins(classPrefixMixins).extend({
},
translateX(): number {
if (this.type !== 'card') return 0;
const wrapWidth = this.getWrapAttribute('offsetWidth');
const { swiperWidth } = this;
const translateIndex = !this.active && this.swiperItemLength > 2 ? this.disposeIndex : this.index;
const inStage = Math.abs(translateIndex - this.currentIndex) <= 1;
if (inStage) {
return (wrapWidth * ((translateIndex - this.currentIndex) * (1 - itemWidth * CARD_SCALE) - itemWidth + 1)) / 2;
return (
(swiperWidth * ((translateIndex - this.currentIndex) * (1 - ITEM_WIDTH * this.cardScale) - ITEM_WIDTH + 1))
/ 2
);
}
if (translateIndex < this.currentIndex) {
return (-itemWidth * (1 + CARD_SCALE) * wrapWidth) / 2;
return (-ITEM_WIDTH * (1 + this.cardScale) * swiperWidth) / 2;
}
return ((2 + itemWidth * (CARD_SCALE - 1)) * wrapWidth) / 2;
return ((2 + ITEM_WIDTH * (this.cardScale - 1)) * swiperWidth) / 2;
},
zIndex(): number {
if (this.type !== 'card') return 0;
Expand All @@ -94,7 +103,7 @@ export default mixins(classPrefixMixins).extend({
const translateIndex = !this.active && this.swiperItemLength > 2 ? this.disposeIndex : this.index;
const isActivity = translateIndex === this.currentIndex;
return {
transform: `translateX(${this.translateX}px) scale(${isActivity ? 1 : CARD_SCALE})`,
transform: `translateX(${this.translateX}px) scale(${isActivity ? 1 : this.cardScale})`,
transition: `transform ${this.duration / 1000}s ease`,
zIndex: this.zIndex,
};
Expand Down
23 changes: 12 additions & 11 deletions src/swiper/swiper.en-US.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
:: BASE_DOC ::

## API

### Swiper Props

name | type | default | description | required
-- | -- | -- | -- | --
animation | String | slide | optionsslide/fade | N
animation | String | slide | options: slide/fade | N
autoplay | Boolean | true | \- | N
cardScale | Number | 210/332 | \- | N
current | Number | 0 | `v-model` is supported | N
defaultCurrent | Number | 0 | uncontrolled property | N
direction | String | horizontal | optionshorizontal/vertical | N
direction | String | horizontal | options: horizontal/vertical | N
duration | Number | 300 | \- | N
height | Number | - | \- | N
interval | Number | 5000 | \- | N
loop | Boolean | true | \- | N
navigation | Object / Slot / Function | - | Typescript`SwiperNavigation \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N
navigation | Object / Slot / Function | - | Typescript: `SwiperNavigation \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N
stopOnHover | Boolean | true | \- | N
theme | String | light | options:light/dark | N
trigger | String | hover | options:hover/click | N
type | String | default | options:default/card | N
onChange | Function | | Typescript:`(current: number, context: { source: SwiperChangeSource }) => void`<br/>[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/swiper/type.ts)。<br/>`type SwiperChangeSource = 'autoplay' \| 'click' \| 'hover'`<br/> | N
trigger | String | hover | options: hover/click | N
type | String | default | options: default/card | N
onChange | Function | | Typescript: `(current: number, context: { source: SwiperChangeSource }) => void`<br/>[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/swiper/type.ts)。<br/>`type SwiperChangeSource = 'autoplay' \| 'click' \| 'hover'`<br/> | N

### Swiper Events

Expand All @@ -31,7 +32,7 @@ change | `(current: number, context: { source: SwiperChangeSource })` | [see mor

name | type | default | description | required
-- | -- | -- | -- | --
placement | String | inside | optionsinside/outside | N
showSlideBtn | String | always | optionsalways/hover/never | N
size | String | medium | optionssmall/medium/large | N
type | String | - | Typescript`SwiperNavigationType` `type SwiperNavigationType = 'dots' \| 'dots-bar' \| 'bars' \| 'fraction'`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/swiper/type.ts) | N
placement | String | inside | options: inside/outside | N
showSlideBtn | String | always | options: always/hover/never | N
size | String | medium | options: small/medium/large | N
type | String | - | Typescript: `SwiperNavigationType` `type SwiperNavigationType = 'dots' \| 'dots-bar' \| 'bars' \| 'fraction'`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/swiper/type.ts) | N
Loading
Loading