Skip to content

Commit bc47468

Browse files
committed
Merge remote-tracking branch 'origin' into rylan/fix/select/search
2 parents 27d6653 + 5a6d3dd commit bc47468

File tree

196 files changed

+5197
-3466
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+5197
-3466
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"@types/testing-library__jest-dom": "5.14.2",
8383
"@typescript-eslint/eslint-plugin": "^5.13.0",
8484
"@typescript-eslint/parser": "^5.13.0",
85-
"@vitejs/plugin-react": "^4.3.1",
85+
"@vitejs/plugin-react": "^5.1.1",
8686
"@vitest/coverage-istanbul": "^2.1.1",
8787
"@vitest/coverage-v8": "^2.1.1",
8888
"@vitest/ui": "^3.1.1",

packages/common

Submodule common updated 265 files

packages/components/_util/helper.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,6 @@ export function firstUpperCase(str: string): string {
3535
return str.toLowerCase().replace(/( |^)[a-z]/g, (char: string) => char.toUpperCase());
3636
}
3737

38-
export type Gradients = { [percent: string]: string };
39-
export type FromTo = { from: string; to: string };
40-
export type LinearGradient = { direction?: string } & (Gradients | FromTo);
41-
export function getBackgroundColor(color: string | string[] | LinearGradient): string {
42-
if (typeof color === 'string') {
43-
return color;
44-
}
45-
if (Array.isArray(color)) {
46-
if (color[0] && color[0][0] === '#') {
47-
color.unshift('90deg');
48-
}
49-
return `linear-gradient( ${color.join(',')} )`;
50-
}
51-
const { from, to, direction = 'to right', ...rest } = color;
52-
let keys = Object.keys(rest);
53-
if (keys.length) {
54-
keys = keys.sort((a, b) => parseFloat(a.substr(0, a.length - 1)) - parseFloat(b.substr(0, b.length - 1)));
55-
const tempArr = keys.map((key: any) => `${rest[key]} ${key}`);
56-
return `linear-gradient(${direction}, ${tempArr.join(',')})`;
57-
}
58-
return `linear-gradient(${direction}, ${from}, ${to})`;
59-
}
60-
6138
// keyboard-event => onKeyboardEvent
6239
export function getPropsApiByEvent(eventName: string) {
6340
return camelCase(`on-${eventName}`);

packages/components/_util/linearGradient.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
1-
/**
2-
** 加法函数,用来得到精确的加法结果
3-
** 说明:javascript 的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的加法结果。
4-
** 调用:accAdd(num1,num2)
5-
** 返回值:num1 加上num2 的精确结果
6-
* */
7-
export function accAdd(num1: number, num2: number) {
8-
const isFloat = (n: number) => typeof n === 'number' && !Number.isInteger(n);
9-
10-
if (isFloat(num1) && isFloat(num2)) {
11-
const [integer1, precision1] = String(num1).split('.');
12-
const [integer2, precision2] = String(num2).split('.');
1+
export const numberToPercent = (number: number) => `${number * 100}%`;
132

14-
// 获取两个浮点数的最长精度
15-
const maxPrecisionLen = Math.max(precision1.length, precision2.length);
16-
// 对齐小数部分的精度长度
17-
const wholePrecision1 = Number(precision1.padEnd(maxPrecisionLen, '0'));
18-
const wholePrecision2 = Number(precision2.padEnd(maxPrecisionLen, '0'));
3+
/**
4+
* 精确加法函数,避免 JavaScript 浮点误差
5+
* - 浮点运算会导致类似 0.1 + 0.2 = 0.30000000000000004 的问题
6+
* - 该函数通过将数字放大为整数进行运算,再缩小回原精度,得到更精确的结果
7+
*/
8+
export function accAdd(num1: number, num2: number): number {
9+
// 获取每个数字的小数位长度
10+
const precision1 = (num1.toString().split('.')[1] || '').length;
11+
const precision2 = (num2.toString().split('.')[1] || '').length;
1912

20-
// 小数部分转化成整数相加之后除以精度最长的 10 的倍数
21-
const precisionVal = (wholePrecision1 + wholePrecision2) / 10 ** maxPrecisionLen;
22-
const integerVal = Number(integer1) + Number(integer2);
13+
// 取两者中较大的小数位长度,用于计算放大倍数
14+
const scale = 10 ** Math.max(precision1, precision2);
2315

24-
return integerVal + precisionVal;
25-
}
16+
// 将小数放大为整数
17+
const sum = Math.round(num1 * scale) + Math.round(num2 * scale);
2618

27-
return num1 + num2;
19+
// 缩放回原精度,得到最终结果
20+
return sum / scale;
2821
}

packages/components/affix/affix.en-US.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
name | type | default | description | required
77
-- | -- | -- | -- | --
8-
className | String | - | 类名 | N
9-
style | Object | - | 样式,Typescript`React.CSSProperties` | N
10-
children | TNode | - | Typescript`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
11-
container | String / Function | () => (() => window) | Typescript`ScrollContainer`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
12-
content | TNode | - | Typescript`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
8+
className | String | - | className of component | N
9+
style | Object | - | CSS(Cascading Style Sheets),Typescript: `React.CSSProperties` | N
10+
children | TNode | - | Typescript: `string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
11+
container | String / Function | () => (() => window) | Typescript: `ScrollContainer`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
12+
content | TNode | - | Typescript: `string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
1313
offsetBottom | Number | 0 | When the distance from the bottom of the container reaches the specified distance, the trigger is fixed | N
1414
offsetTop | Number | 0 | When the distance from the top of the container reaches the specified distance, the trigger is fixed | N
1515
zIndex | Number | - | \- | N
16-
onFixedChange | Function | | Typescript`(affixed: boolean, context: { top: number }) => void`<br/> | N
16+
onFixedChange | Function | | Typescript: `(affixed: boolean, context: { top: number }) => void`<br/> | N

packages/components/affix/affix.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## API
44
### Affix Props
55

6-
名称 | 类型 | 默认值 | 说明 | 必传
6+
名称 | 类型 | 默认值 | 描述 | 必传
77
-- | -- | -- | -- | --
88
className | String | - | 类名 | N
99
style | Object | - | 样式,TS 类型:`React.CSSProperties` | N

packages/components/alert/alert.en-US.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
name | type | default | description | required
88
-- | -- | -- | -- | --
99
className | String | - | className of component | N
10-
style | Object | - | CSS(Cascading Style Sheets),Typescript`React.CSSProperties` | N
11-
close | TNode | false | Deprecated, use closeBtn instead. Typescript`string \| boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
12-
closeBtn | TNode | false | Close button. Value "true" show the close button. Value "False" hide close button. Value type string display as is. Use TNode to custom the close trigger. Typescript`string \| boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
13-
icon | TElement | - | Typescript`TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
10+
style | Object | - | CSS(Cascading Style Sheets),Typescript: `React.CSSProperties` | N
11+
close | TNode | false | Deprecated, use closeBtn instead. Typescript: `string \| boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
12+
closeBtn | TNode | false | Close button. Value "true" show the close button. Value "False" hide close button. Value type string display as is. Use TNode to custom the close trigger. Typescript: `string \| boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
13+
icon | TElement | - | Typescript: `TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
1414
maxLine | Number | 0 | \- | N
15-
message | TNode | - | Typescript`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
16-
operation | TElement | - | Typescript`TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
15+
message | TNode | - | Typescript: `string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
16+
operation | TElement | - | Typescript: `TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
1717
theme | String | info | options: success/info/warning/error | N
18-
title | TNode | - | Typescript`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
19-
onClose | Function | | Typescript`(context: { e: MouseEvent }) => void`<br/> | N
20-
onClosed | Function | | Typescript`(context: { e: TransitionEvent }) => void`<br/> | N
18+
title | TNode | - | Typescript: `string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
19+
onClose | Function | | Typescript: `(context: { e: MouseEvent }) => void`<br/> | N
20+
onClosed | Function | | Typescript: `(context: { e: TransitionEvent }) => void`<br/> | N

packages/components/anchor/anchor.en-US.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,33 @@
55

66
name | type | default | description | required
77
-- | -- | -- | -- | --
8-
className | String | - | 类名 | N
9-
style | Object | - | 样式,Typescript`React.CSSProperties` | N
10-
affixProps | Object | - | Typescript`Omit<AffixProps, 'children'>`[Affix API Documents](./affix?tab=api)[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/anchor/type.ts) | N
8+
className | String | - | className of component | N
9+
style | Object | - | CSS(Cascading Style Sheets),Typescript: `React.CSSProperties` | N
10+
affixProps | Object | - | Typescript: `Omit<AffixProps, 'children'>`[Affix API Documents](./affix?tab=api)[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/anchor/type.ts) | N
1111
bounds | Number | 5 | \- | N
12-
container | String / Function | () => window | Typescript`ScrollContainer`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
13-
cursor | TElement | - | Typescript`TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
14-
getCurrentAnchor | Function | - | Custom Highlighted Anchor Points。Typescript`(activeLink: string) => string` | N
15-
size | String | medium | options: small/medium/large。Typescript`SizeEnum`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
12+
container | String / Function | () => window | Typescript: `ScrollContainer`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
13+
cursor | TElement | - | Typescript: `TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
14+
getCurrentAnchor | Function | - | Custom Highlighted Anchor Points。Typescript: `(activeLink: string) => string` | N
15+
size | String | medium | options: small/medium/large。Typescript: `SizeEnum`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
1616
targetOffset | Number | 0 | \- | N
17-
onChange | Function | | Typescript`(currentLink: string, prevLink: string) => void`<br/> | N
18-
onClick | Function | | Typescript`(link: { href: string; title: string; e: MouseEvent }) => void`<br/> | N
17+
onChange | Function | | Typescript: `(currentLink: string, prevLink: string) => void`<br/> | N
18+
onClick | Function | | Typescript: `(link: { href: string; title: string; e: MouseEvent }) => void`<br/> | N
1919

2020
### AnchorItem Props
2121

2222
name | type | default | description | required
2323
-- | -- | -- | -- | --
24-
className | String | - | 类名 | N
25-
style | Object | - | 样式,Typescript`React.CSSProperties` | N
24+
className | String | - | className of component | N
25+
style | Object | - | CSS(Cascading Style Sheets),Typescript: `React.CSSProperties` | N
2626
href | String | - | required | Y
2727
target | String | _self | options: _self/_blank/_parent/_top | N
28-
title | TNode | '' | Typescript`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
28+
title | TNode | '' | Typescript: `string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
2929

3030
### AnchorTarget Props
3131

3232
name | type | default | description | required
3333
-- | -- | -- | -- | --
34-
className | String | - | 类名 | N
35-
style | Object | - | 样式,Typescript`React.CSSProperties` | N
34+
className | String | - | className of component | N
35+
style | Object | - | CSS(Cascading Style Sheets),Typescript: `React.CSSProperties` | N
3636
id | String | - | required | Y
3737
tag | String | div | \- | N

packages/components/anchor/anchor.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## API
44
### Anchor Props
55

6-
名称 | 类型 | 默认值 | 说明 | 必传
6+
名称 | 类型 | 默认值 | 描述 | 必传
77
-- | -- | -- | -- | --
88
className | String | - | 类名 | N
99
style | Object | - | 样式,TS 类型:`React.CSSProperties` | N
@@ -19,7 +19,7 @@ onClick | Function | | TS 类型:`(link: { href: string; title: string; e: Mo
1919

2020
### AnchorItem Props
2121

22-
名称 | 类型 | 默认值 | 说明 | 必传
22+
名称 | 类型 | 默认值 | 描述 | 必传
2323
-- | -- | -- | -- | --
2424
className | String | - | 类名 | N
2525
style | Object | - | 样式,TS 类型:`React.CSSProperties` | N
@@ -29,7 +29,7 @@ title | TNode | '' | 锚点文本。TS 类型:`string \| TNode`。[通用类
2929

3030
### AnchorTarget Props
3131

32-
名称 | 类型 | 默认值 | 说明 | 必传
32+
名称 | 类型 | 默认值 | 描述 | 必传
3333
-- | -- | -- | -- | --
3434
className | String | - | 类名 | N
3535
style | Object | - | 样式,TS 类型:`React.CSSProperties` | N

0 commit comments

Comments
 (0)