Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/Tencent/tdesign-react in…
Browse files Browse the repository at this point in the history
…to develop
  • Loading branch information
huangchen1031 committed Nov 19, 2024
2 parents cdb480d + ca02d7d commit aec8d37
Show file tree
Hide file tree
Showing 102 changed files with 2,490 additions and 1,528 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ robotMsg.json
cypress-coverage
instrumented
cy-report
.history
.history
src/**/_example-js/
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,50 @@ toc: false
spline: explain
---

## 🌈 1.10.0 `2024-11-15`
### 🚀 Features
- `Select`: `collapsedItems` 方法的参数 `collapsedSelectedItems` 扩充为 `options`,使用`collapsedItems`请注意此变更 @RSS1102 ([#3185](https://github.com/Tencent/tdesign-react/pull/3185))
- `Icon`: 图标库发布 `0.4.0`版本,新增 907 个新图标;命名优化`blockchain` 重命名改为`transform-1`,`gesture-pray-1`重命名为`gesture-open`,`gesture-ranslation-1`重命名为`wave-bye`, `gesture-up-1`重命名为`gesture-typing`,`gesture-up-2`重命名为`gesture-right-slip`,`logo-wechat`重命名为`logo-wechat-stroke-filled`,移除`tree-list``logo-adobe-photoshop-1` 等错误图标 @uyarn ([#3194](https://github.com/Tencent/tdesign-react/pull/3194))
- `Cascader`: 单选模式下当`trigger``hover`时,选中选项后自动关闭面板 @uyarn ([#3188](https://github.com/Tencent/tdesign-react/pull/3188))
- `Checkbox`: 新增 `title` API, 用于在选项展示禁用原因等场景 @uyarn ([#3207](https://github.com/Tencent/tdesign-react/pull/3207))
- `Menu`: 新增`tooltipProps` API,作用于一级菜单收起聚焦出现的节点 @uyarn ([#3201](https://github.com/Tencent/tdesign-react/pull/3201))
- `Switch`: 新增 `before-change` API @centuryPark ([#3167](https://github.com/Tencent/tdesign-react/pull/3167))
- `Form`: 新增 `getValidateMessage` 实例方法 @moecasts ([#3180](https://github.com/Tencent/tdesign-react/pull/3180))

### 🐞 Bug Fixes
- `TagInput`: 修复在`readonly`模式下仍可以通过Backspace按键删除已选项的缺陷 @RSS1102 ([#3172](https://github.com/Tencent/tdesign-react/pull/3172))
- `Form`: 修复`1.9.3`版本 `FormItem``Form`外设置了`name`属性有异常的问题 @l123wx ([#3183](https://github.com/Tencent/tdesign-react/pull/3183))
- `Select`: 修复 valueType 为 object 时,点击全选按钮后 onChange 回调参数类型错误的问题 @l123wx ([#3193](https://github.com/Tencent/tdesign-react/pull/3193))
- `Table`: 修复动态设置`expandTreeNode`没有正常展示子节点的问题 @uyarn ([#3202](https://github.com/Tencent/tdesign-react/pull/3202))
- `Tree`: 修复动态切换`expandAll`的功能异常问题 @uyarn ([#3204](https://github.com/Tencent/tdesign-react/pull/3204))
- `Drawer`: 修复无法自定义`confirmBtn``closeBtn`内容的问题 @RSS1102 ([#3191](https://github.com/Tencent/tdesign-react/pull/3191))
### 📝 Documentation
- `Icon`: 优化图标检索功能,支持中英文搜索图标 @uyarn ([#3194](https://github.com/Tencent/tdesign-react/pull/3194))
- `Popup`: 新增`popperOption`使用示例 @HaixingOoO ([#3200](https://github.com/Tencent/tdesign-react/pull/3200))


## 🌈 1.9.3 `2024-10-31`
### 🐞 Bug Fixes
- `Select`: 修复`valueDisplay`下的`onClose`回调问题 @uyarn ([#3154](https://github.com/Tencent/tdesign-react/pull/3154))
- `Typography`: 修复 `Typography``Ellipsis` 功能在中文下的问题 @HaixingOoO ([#3158](https://github.com/Tencent/tdesign-react/pull/3158))
- `Form`: 修复 `FormList``FormItem` 数据中的 `getFieldsValue` 问题 @HaixingOoO ([#3149](https://github.com/Tencent/tdesign-react/pull/3149))
- `Form`: 修复动态渲染表单无法使用 `setFieldsValue` 预设数据的问题 @l123wx ([#3145](https://github.com/Tencent/tdesign-react/pull/3145))
- `lib`: 修复`1.9.2`升级依赖改动导致`lib`错误携带`style`导致在`next`下不可用的异常 @honkinglin ([#3165](https://github.com/Tencent/tdesign-react/pull/3165))



## 🌈 1.9.2 `2024-10-17`
### 🚀 Features
- `TimePicker`: 新增 `autoSwap` API,支持`1.9.0` 版本之后仍可以保持选定的左右侧时间大小顺序 @uyarn ([#3146](https://github.com/Tencent/tdesign-react/pull/3146))
### 🐞 Bug Fixes
- `Tabs`: 修复`TabPanel``label`改变时,激活的选项卡底部横线没更新 @HaixingOoO ([#3134](https://github.com/Tencent/tdesign-react/pull/3134))
- `Drawer`: 修复打开 `drawer` 时页面抖动的问题 @RSS1102 ([#3141](https://github.com/Tencent/tdesign-react/pull/3141))
- `Dialog`: 修复打开 `dialog` 时页面抖动的问题 @RSS1102 ([#3141](https://github.com/Tencent/tdesign-react/pull/3141))
- `Select`: 修复使用 `OptionGroup `时无法自动定位到选中项问题 @moecasts ([#3139](https://github.com/Tencent/tdesign-react/pull/3139))
### 🚧 Others
- `Loading`: 优化 live demo 展示效果 @uyarn ([#3144](https://github.com/Tencent/tdesign-react/pull/3144))
- `DatePicker`: 移除文档中错误的`value` 类型描述 @uyarn ([#3144](https://github.com/Tencent/tdesign-react/pull/3144))

## 🌈 1.9.1 `2024-09-26`
### 🚀 Features
- `ImageViewer`: 优化图片预览旋转的重置效果 @sylsaint ([#3108](https://github.com/Tencent/tdesign-react/pull/3108))
Expand Down
40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tdesign-react",
"purename": "tdesign",
"version": "1.9.1",
"version": "1.10.0",
"description": "TDesign Component for React",
"title": "tdesign-react",
"main": "lib/index.js",
Expand Down Expand Up @@ -46,7 +46,7 @@
"lint:tsc": "tsc -p ./tsconfig.dev.json ",
"generate:usage": "node script/generate-usage/index.js",
"generate:coverage-badge": "npm run test:coverage && node script/generate-coverage.js",
"generate:jsx-demo":"npx babel src/**/_example --extensions '.tsx' --config-file ./babel.config.demo.js --relative --out-dir ../_example-js --out-file-extension=.jsx",
"generate:jsx-demo": "npx babel src/**/_example --extensions '.tsx' --config-file ./babel.config.demo.js --relative --out-dir ../_example-js --out-file-extension=.jsx",
"format:jsx-demo": "npx eslint src/**/_example-js/*.jsx --fix && npx prettier --write src/**/_example-js/*.jsx",
"test": "vitest run && npm run test:snap",
"test:ui": "vitest --ui",
Expand All @@ -61,7 +61,7 @@
"build:tsc-esm": "tsc --emitDeclarationOnly -d -p ./tsconfig.build.json --outDir esm/",
"build:tsc-cjs": "tsc --emitDeclarationOnly -d -p ./tsconfig.build.json --outDir cjs/",
"build:tsc-lib": "tsc --emitDeclarationOnly -d -p ./tsconfig.build.json --outDir lib/",
"build:jsx-demo":"npm run generate:jsx-demo && npm run format:jsx-demo",
"build:jsx-demo": "npm run generate:jsx-demo && npm run format:jsx-demo",
"changelog": "node script/generate-changelog.js",
"init:component": "node script/init-component",
"robot": "publish-cli robot-msg",
Expand Down Expand Up @@ -121,27 +121,26 @@
"@testing-library/user-event": "^14.4.3",
"@types/estree": "0.0.50",
"@types/hoist-non-react-statics": "^3.3.1",
"@types/lodash": "4.14.182",
"@types/node": "^17.0.21",
"@types/lodash": "4.17.9",
"@types/node": "^22.7.0",
"@types/raf": "^3.4.0",
"@types/react": "~18.2.0",
"@types/react-dom": "^18.2.1",
"@types/react-is": "^18.2.0",
"@types/react-transition-group": "^4.4.2",
"@types/rimraf": "^3.0.2",
"@types/rimraf": "^4.0.5",
"@types/testing-library__jest-dom": "5.14.2",
"@typescript-eslint/eslint-plugin": "^5.13.0",
"@typescript-eslint/parser": "^5.13.0",
"@vitejs/plugin-react": "^1.3.2",
"@vitest/coverage-c8": "^0.28.5",
"@vitest/coverage-istanbul": "^0.24.1",
"@vitest/ui": "^0.24.1",
"@vitejs/plugin-react": "^4.3.1",
"@vitest/coverage-istanbul": "^2.1.1",
"@vitest/coverage-v8": "^2.1.1",
"@vitest/ui": "^2.1.1",
"autoprefixer": "^10.4.0",
"babel-polyfill": "^6.26.0",
"camelcase": "^6.2.1",
"chalk": "^4.1.0",
"cross-env": "^5.2.1",
"cssnano": "^4.0.1",
"cz-conventional-changelog": "^3.3.0",
"dom-parser": "^0.1.6",
"esbuild": "^0.14.9",
Expand All @@ -153,7 +152,7 @@
"eslint-plugin-react-hooks": "^4.0.0",
"glob": "^8.0.3",
"gray-matter": "^4.0.3",
"happy-dom": "^7.5.7",
"happy-dom": "^15.11.0",
"husky": "^7.0.4",
"jest-canvas-mock": "^2.4.0",
"jsdom": "^20.0.1",
Expand All @@ -173,7 +172,7 @@
"react-element-to-jsx-string": "^15.0.0",
"react-router-dom": "^6.2.2",
"resize-observer-polyfill": "^1.5.1",
"rimraf": "^3.0.2",
"rimraf": "^6.0.1",
"rollup": "^2.74.1",
"rollup-plugin-analyzer": "^4.0.0",
"rollup-plugin-esbuild": "^4.9.1",
Expand All @@ -184,20 +183,21 @@
"rollup-plugin-styles": "^4.0.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.31.2",
"semver": "^7.6.3",
"standard-changelog": "^2.0.27",
"start-server-and-test": "^1.14.0",
"tdesign-icons-view": "^0.2.0",
"tdesign-icons-view": "^0.3.0",
"tdesign-publish-cli": "^0.0.12",
"tdesign-site-components": "^0.15.3",
"tdesign-theme-generator": "^1.0.0",
"ts-morph": "^13.0.02",
"ts-node": "^10.4.0",
"typescript": "~4.5.4",
"vite": "^2.9.15",
"vite-plugin-istanbul": "^5.0.0",
"vite-plugin-pwa": "^0.12.8",
"vite-plugin-tdoc": "^2.0.1",
"vitest": "^0.24.1",
"typescript": "5.6.2",
"vite": "^5.4.7",
"vite-plugin-istanbul": "^6.0.2",
"vite-plugin-pwa": "^0.20.5",
"vite-plugin-tdoc": "^2.0.4",
"vitest": "^2.1.1",
"workbox-precaching": "^7.0.0"
},
"dependencies": {
Expand Down
10 changes: 10 additions & 0 deletions script/generate-usage/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,16 @@ module.exports = {
const panelList = [{ label: 'loading', value: 'loading' }];
`,
usageStr: `
const { fullscreen } = changedProps;
useEffect(() => {
if (fullscreen) {
setTimeout(() => {
onConfigChange({ detail: { name: 'fullscreen', value: false } });
}, 2000);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [fullscreen]);
useEffect(() => {
setRenderComp(<Loading {...changedProps} />);
}, [changedProps]);
Expand Down
3 changes: 3 additions & 0 deletions site/docs/getting-started.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ npm i tdesign-react
<link rel="stylesheet" href="https://unpkg.com/tdesign-react/dist/tdesign.min.css" />
<script src="https://unpkg.com/tdesign-react/dist/tdesign.min.js"></script>
```

> Please note that unpkg usage is not recommended as it will download the entire component library. Production projects will be directly affected by version updates, and may also be affected by the stability of the CDN.
The package of tdesign-react provides kinds of bundles, read [the documentation](https://github.com/Tencent/tdesign/blob/main/docs/develop-install.md) for the detail of differences between bundles.
Expand Down Expand Up @@ -92,6 +93,8 @@ module.exports = {
When using Next.js, you need to adjust how you use these components.

```js
'use client'

import { Button } from 'tdesign-react/lib/';
import 'tdesign-react/dist/tdesign.css';
```
Expand Down
3 changes: 3 additions & 0 deletions site/docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ npm i tdesign-react
<link rel="stylesheet" href="https://unpkg.com/tdesign-react/dist/tdesign.min.css" />
<script src="https://unpkg.com/tdesign-react/dist/tdesign.min.js"></script>
```

> 请注意,我们不推荐使用这种方式,这样无法实现按需加载等优化手段,生产项目会直接受版本更新影响,同时也可能受到 CDN 的稳定性的影响。
npm package 中提供了多种构建产物,可以阅读 [这里](https://github.com/Tencent/tdesign/blob/main/docs/develop-install.md) 了解不同目录下产物的差别。
Expand Down Expand Up @@ -96,6 +97,8 @@ module.exports = {
所以在 `next.js` 中需要调整下使用方式:

```js
'use client'

import { Button } from 'tdesign-react/lib/'; // 按需引入无样式组件代码
import 'tdesign-react/dist/tdesign.css'; // 全局引入所有组件样式代码
```
Expand Down
11 changes: 7 additions & 4 deletions site/pwaConfig.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
export default {
strategies: 'injectManifest',
includeAssets: ['favicon.svg', 'favicon.ico', 'apple-touch-icon.png'],
includeAssets: ['favicon.svg', 'favicon.ico', 'apple-touch-icon.png'],
injectManifest: {
maximumFileSizeToCacheInBytes: 7000000,
},
manifest: {
name: 'TDesign for React',
short_name: 'TDesign',
Expand All @@ -16,7 +19,7 @@ export default {
src: 'pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
}
]
}
},
],
},
};
7 changes: 4 additions & 3 deletions site/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useEffect, useRef, useState, lazy, Suspense } from 'react';
import { BrowserRouter, Routes, Navigate, Route, useLocation, useNavigate, Outlet } from 'react-router-dom';
import semver from 'semver';
import Loading from 'tdesign-react/loading';
import ConfigProvider from 'tdesign-react/config-provider';
import zhConfig from 'tdesign-react/es/locale/zh_CN';
Expand All @@ -19,7 +20,7 @@ const docsMap = {
en: enDocs,
};

const registryUrl = 'https://mirrors.tencent.com/npm/tdesign-react';
const registryUrl = 'https://service-edbzjd6y-1257786608.hk.apigw.tencentcs.com/release/npm/versions/tdesign-react';
const currentVersion = packageJson.version.replace(/\./g, '_');

const docRoutes = [...getRoute(siteConfig.docs, []), ...getRoute(siteConfig.enDocs, [])];
Expand Down Expand Up @@ -65,7 +66,8 @@ function Components() {

options.unshift({ label: v, value: v.replace(/\./g, '_') });
});
tdSelectRef.current.options = options;

tdSelectRef.current.options = options.sort((a, b) => (semver.gt(a.label, b.label) ? -1 : 1));
});
}

Expand Down Expand Up @@ -95,7 +97,6 @@ function Components() {
};

initHistoryVersions();

}, []);

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/Demo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import Button from 'tdesign-react/button';
import { Link, useLocation } from 'react-router-dom';

export const demoFiles = import.meta.globEager('../../../src/**/_example/*.tsx');
export const demoFiles = import.meta.glob('../../../src/**/_example/*.tsx', { eager: true });

const demoObject = {};
Object.keys(demoFiles).forEach((key) => {
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/Playground.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ReactDOM from 'react-dom';
import Button from 'tdesign-react/button';
import 'tdesign-react/style/index.js';

const demoFiles = import.meta.globEager('../../../src/**/_example/*.jsx');
const demoFiles = import.meta.glob('../../../src/**/_example/*.jsx', { eager: true });
const demoObject = {};
const componentList = new Set();
Object.keys(demoFiles).forEach((key) => {
Expand Down
13 changes: 12 additions & 1 deletion site/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ const publicPathMap = {
production: 'https://static.tdesign.tencent.com/react/',
};

const disableTreeShakingPlugin = (paths) => ({
name: 'disable-treeshake',
transform(code, id) {
for (const path of paths) {
if (id.includes(path)) {
return { code, map: null, moduleSideEffects: 'no-treeshake' };
}
}
},
});

export default ({ mode }) =>
defineConfig({
base: publicPathMap[mode],
Expand Down Expand Up @@ -50,5 +61,5 @@ export default ({ mode }) =>
test: {
environment: 'jsdom',
},
plugins: [react(), tdocPlugin(), VitePWA(pwaConfig)],
plugins: [react(), tdocPlugin(), VitePWA(pwaConfig), disableTreeShakingPlugin(['style/'])],
});
17 changes: 17 additions & 0 deletions src/_util/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,20 @@ export function getPropsApiByEvent(eventName: string) {
export function pxCompat(param: string | number) {
return typeof param === 'number' ? `${param}px` : param;
}

/**
* 获取元素相对于容器(祖先)的偏移量
* @param element 目标元素
* @param container 容器元素
* @returns 相对于容器的偏移量
*/
export function getOffsetTopToContainer(element: HTMLElement, container: HTMLElement) {
let { offsetTop } = element;

let current = element.offsetParent as HTMLElement;
while (current && current !== container) {
offsetTop += current.offsetTop;
current = current.offsetParent as HTMLElement;
}
return offsetTop;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Vitest Snapshot v1
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Avatar Component > props.children works fine 1`] = `
<div>
Expand Down
5 changes: 2 additions & 3 deletions src/avatar/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import { MouseEvent } from 'react';
import { ImageProps } from '../image';
import { PopupProps } from '../popup';
import { TNode, TElement, ImageEvent } from '../common';

import { TNode, TElement, ImageEvent, ShapeEnum } from '../common';

export interface TdAvatarProps {
/**
Expand Down Expand Up @@ -94,6 +95,4 @@ export interface TdAvatarGroupProps {
size?: string;
}

export type ShapeEnum = 'circle' | 'round';

export type CascadingValue = 'left-up' | 'right-up';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Vitest Snapshot v1
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`BackTop Component > props.children works fine 1`] = `
<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Vitest Snapshot v1
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Button Component > props.block works fine 1`] = `
<div>
Expand Down
3 changes: 2 additions & 1 deletion src/cascader/core/effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export function expendClickEffect(
// 非受控状态下更新状态
setValue(valueType === 'single' ? value : node.getPath().map((item) => item.value), 'check', node.getModel());

if (!checkStrictly) {
// 当 trigger 为 hover 时 ,点击节点一定是关闭 panel 的操作
if (!checkStrictly || propsTrigger === 'hover') {
setVisible(false, {});
}
}
Expand Down
1 change: 1 addition & 0 deletions src/checkbox/checkbox.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ indeterminate | Boolean | false | \- | N
label | TNode | - | Typescript:`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
name | String | - | \- | N
readonly | Boolean | false | \- | N
title | String | - | html attribute | N
value | String / Number / Boolean | - | value of checkbox。Typescript:`string \| number \| boolean` | N
onChange | Function | | Typescript:`(checked: boolean, context: { e: ChangeEvent }) => void`<br/> | N
onClick | Function | | Typescript:`(context: { e: MouseEvent }) => void`<br/>trigger on click | N
Expand Down
Loading

0 comments on commit aec8d37

Please sign in to comment.