merge feature

This commit is contained in:
afc163 2024-10-14 18:05:41 +08:00
commit 2d2a7c9da3
8 changed files with 79 additions and 62 deletions

View File

@ -175,12 +175,13 @@ const RefLinks: React.FC<{ refs: string[] }> = ({ refs }) => {
const RenderChangelogList: React.FC<{ changelogList: ChangelogInfo[] }> = ({ changelogList }) => {
const elements: React.ReactNode[] = [];
const { styles } = useStyle();
for (let i = 0; i < changelogList.length; i += 1) {
const len = changelogList.length;
for (let i = 0; i < len; i += 1) {
const { refs, changelog } = changelogList[i];
// Check if the next line is an image link and append it to the current line
if (i + 1 < changelogList.length && changelogList[i + 1].changelog.trim().startsWith('<img')) {
if (i + 1 < len && changelogList[i + 1].changelog.trim().startsWith('<img')) {
const imgDom = new DOMParser().parseFromString(changelogList[i + 1].changelog, 'text/html');
const imgElement = imgDom.querySelector('img');
const imgElement = imgDom.querySelector<HTMLImageElement>('img');
elements.push(
<li key={i}>
<ParseChangelog changelog={changelog} />

View File

@ -55,13 +55,13 @@ demo:
### SegmentedItemType
| 属性 | 描述 | 类型 | 默认值 | 版本 |
| --- | --- | --- | --- | --- |
| label | 分段项的显示文本 | ReactNode | - | |
| value | 分段项的值 | string \| number | - | |
| icon | 分段项的显示图标 | ReactNode | - | |
| disabled | 分段项的禁用状态 | boolean | false | |
| className | 自定义类名 | string | - | |
| 属性 | 描述 | 类型 | 默认值 | 版本 |
| --------- | ---------------- | ---------------- | ------ | ---- |
| label | 分段项的显示文本 | ReactNode | - | |
| value | 分段项的值 | string \| number | - | |
| icon | 分段项的显示图标 | ReactNode | - | |
| disabled | 分段项的禁用状态 | boolean | false | |
| className | 自定义类名 | string | - | |
## 主题变量Design Token

View File

@ -43,48 +43,48 @@ describe('Table.rowSelection', () => {
const namesList: Node['textContent'][] = [];
container
?.querySelector('.ant-table-tbody')
?.querySelectorAll('tr')
?.querySelectorAll<HTMLTableRowElement>('tr')
?.forEach((tr) => {
namesList.push(tr?.querySelectorAll('td')?.[1]?.textContent);
namesList.push(tr?.querySelectorAll<HTMLTableCellElement>('td')?.[1]?.textContent);
});
return namesList;
}
function getSelections(container: ReturnType<typeof render>['container']) {
const getSelections = (container: HTMLElement) => {
const keys: React.Key[] = [];
container.querySelectorAll('.ant-table-tbody tr').forEach((row) => {
container.querySelectorAll<HTMLTableRowElement>('.ant-table-tbody tr').forEach((row) => {
const key = row.getAttribute('data-row-key');
if (row.querySelector('input')?.checked) {
if (isNaN(Number(key))) {
if (key && row.querySelector<HTMLInputElement>('input')?.checked) {
if (Number.isNaN(Number(key))) {
// rowKey
keys.push(key!);
keys.push(key);
} else {
keys.push(Number(key));
}
}
});
return keys;
}
};
function getIndeterminateSelection(container: ReturnType<typeof render>['container']) {
const getIndeterminateSelection = (container: HTMLElement) => {
const keys: React.Key[] = [];
container.querySelectorAll('.ant-table-tbody tr').forEach((row) => {
container.querySelectorAll<HTMLTableRowElement>('.ant-table-tbody tr').forEach((row) => {
const key = row.getAttribute('data-row-key');
if (row.querySelector('.ant-checkbox-indeterminate')) {
if (isNaN(Number(key))) {
if (key && row.querySelector<HTMLElement>('.ant-checkbox-indeterminate')) {
if (Number.isNaN(Number(key))) {
// rowKey
keys.push(key!);
keys.push(key);
} else {
keys.push(Number(key));
}
}
});
return keys;
}
};
it('select default row', () => {
const { container } = render(createTable({ rowSelection: { defaultSelectedRowKeys: [0] } }));
const checkboxes = container.querySelectorAll('input[type="checkbox"]');
const checkboxes = container.querySelectorAll<HTMLInputElement>('input[type="checkbox"]');
expect(getSelections(container)).toEqual([0]);
fireEvent.click(checkboxes[1]);

View File

@ -248,7 +248,7 @@ Properties for expandable.
| columnWidth | Set the width of the expand column | string \| number | - | |
| defaultExpandAllRows | Expand all rows initially | boolean | false | |
| defaultExpandedRowKeys | Initial expanded row keys | string\[] | - | |
| expandedRowClassName | Expanded row's className | function(record, index, indent): string | - | |
| expandedRowClassName | Expanded row's className | string \| (record, index, indent) => string | - | string: 5.22.0 |
| expandedRowKeys | Current expanded row keys | string\[] | - | |
| expandedRowRender | Expanded container render for each row | function(record, index, indent, expanded): ReactNode | - | |
| expandIcon | Customize row expand Icon. Ref [example](https://codesandbox.io/s/fervent-bird-nuzpr) | function(props): ReactNode | - | |

View File

@ -250,7 +250,7 @@ const columns = [
| columnWidth | 自定义展开列宽度 | string \| number | - | |
| defaultExpandAllRows | 初始时,是否展开所有行 | boolean | false | |
| defaultExpandedRowKeys | 默认展开的行 | string\[] | - | |
| expandedRowClassName | 展开行的 className | function(record, index, indent): string | - | |
| expandedRowClassName | 展开行的 className | string \| (record, index, indent) => string | - | string: 5.22.0 |
| expandedRowKeys | 展开的行,控制属性 | string\[] | - | |
| expandedRowRender | 额外的展开行 | function(record, index, indent, expanded): ReactNode | - | |
| expandIcon | 自定义展开图标,参考[示例](https://codesandbox.io/s/fervent-bird-nuzpr) | function(props): ReactNode | - | |

View File

@ -48,6 +48,7 @@ const App: React.FC = () => {
Tree: {
nodeHoverBg: '#fff2f0',
nodeSelectedBg: '#ffa39e',
indentSize: 80,
},
},
}}

View File

@ -13,6 +13,11 @@ export interface TreeSharedToken {
* @descEN Node title height
*/
titleHeight: number;
/**
* @desc
* @descEN Indent width of tree
*/
indentSize?: number;
/**
* @desc
* @descEN Background color of hovered node
@ -94,7 +99,15 @@ type TreeToken = FullToken<'Tree'> & {
};
export const genBaseStyle = (prefixCls: string, token: TreeToken): CSSObject => {
const { treeCls, treeNodeCls, treeNodePadding, titleHeight, nodeSelectedBg, nodeHoverBg } = token;
const {
treeCls,
treeNodeCls,
treeNodePadding,
titleHeight,
indentSize,
nodeSelectedBg,
nodeHoverBg,
} = token;
const treeCheckBoxMarginHorizontal = token.paddingXS;
return {
@ -223,7 +236,7 @@ export const genBaseStyle = (prefixCls: string, token: TreeToken): CSSObject =>
userSelect: 'none',
'&-unit': {
display: 'inline-block',
width: titleHeight,
width: indentSize,
},
},
@ -538,12 +551,14 @@ export const genTreeStyle = (
};
export const initComponentToken = (token: AliasToken): TreeSharedToken => {
const { controlHeightSM } = token;
const { controlHeightSM, controlItemBgHover, controlItemBgActive } = token;
const titleHeight = controlHeightSM;
return {
titleHeight: controlHeightSM,
nodeHoverBg: token.controlItemBgHover,
nodeSelectedBg: token.controlItemBgActive,
titleHeight,
indentSize: titleHeight,
nodeHoverBg: controlItemBgHover,
nodeSelectedBg: controlItemBgActive,
};
};

View File

@ -144,7 +144,7 @@
"rc-slider": "~11.1.7",
"rc-steps": "~6.0.1",
"rc-switch": "~4.1.0",
"rc-table": "~7.47.5",
"rc-table": "~7.48.0",
"rc-tabs": "~15.3.0",
"rc-textarea": "~1.8.2",
"rc-tooltip": "~6.2.1",
@ -159,19 +159,19 @@
"@ant-design/compatible": "^5.1.3",
"@ant-design/happy-work-theme": "^1.0.0",
"@ant-design/tools": "^18.0.2",
"@antfu/eslint-config": "^3.0.0",
"@antfu/eslint-config": "^3.7.3",
"@antv/g6": "^4.8.24",
"@biomejs/biome": "^1.9.1",
"@codecov/webpack-plugin": "^1.0.1",
"@codesandbox/sandpack-react": "^2.19.8",
"@biomejs/biome": "^1.9.3",
"@codecov/webpack-plugin": "^1.2.0",
"@codesandbox/sandpack-react": "^2.19.9",
"@dnd-kit/core": "^6.1.0",
"@dnd-kit/modifiers": "^7.0.0",
"@dnd-kit/sortable": "^8.0.0",
"@dnd-kit/utilities": "^3.2.2",
"@emotion/css": "^11.13.0",
"@emotion/css": "^11.13.4",
"@emotion/react": "^11.13.3",
"@emotion/server": "^11.11.0",
"@eslint-react/eslint-plugin": "^1.13.0",
"@eslint-react/eslint-plugin": "^1.14.3",
"@ianvs/prettier-plugin-sort-imports": "^4.3.1",
"@inquirer/prompts": "^7.0.0",
"@madccc/duplicate-package-checker-webpack-plugin": "^1.0.0",
@ -179,7 +179,7 @@
"@npmcli/run-script": "^9.0.0",
"@octokit/rest": "^21.0.2",
"@qixian.cs/github-contributors-list": "^2.0.2",
"@size-limit/file": "^11.1.5",
"@size-limit/file": "^11.1.6",
"@stackblitz/sdk": "^1.11.0",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.5.0",
@ -196,18 +196,18 @@
"@types/jest-axe": "^3.5.9",
"@types/jest-environment-puppeteer": "^5.0.6",
"@types/jest-image-snapshot": "^6.4.0",
"@types/jquery": "^3.5.30",
"@types/jquery": "^3.5.31",
"@types/jsdom": "^21.1.7",
"@types/lodash": "^4.17.7",
"@types/lodash": "^4.17.9",
"@types/minimist": "^1.2.5",
"@types/node": "^22.5.5",
"@types/node": "^22.7.4",
"@types/nprogress": "^0.2.3",
"@types/pixelmatch": "^5.2.6",
"@types/pngjs": "^6.0.5",
"@types/prismjs": "^1.26.4",
"@types/progress": "^2.0.7",
"@types/qs": "^6.9.16",
"@types/react": "^18.3.5",
"@types/react": "^18.3.10",
"@types/react-copy-to-clipboard": "^5.0.7",
"@types/react-dom": "^18.3.0",
"@types/react-highlight-words": "^0.20.0",
@ -220,7 +220,7 @@
"adm-zip": "^0.5.16",
"ali-oss": "^6.21.0",
"antd-img-crop": "^4.23.0",
"antd-style": "^3.6.3",
"antd-style": "^3.7.0",
"antd-token-previewer": "^2.0.8",
"axios": "^1.7.7",
"chalk": "^4.1.2",
@ -231,14 +231,14 @@
"cross-fetch": "^4.0.0",
"dekko": "^0.2.1",
"dotenv": "^16.4.5",
"dumi": "~2.4.10",
"dumi": "~2.4.12",
"dumi-plugin-color-chunk": "^1.1.2",
"eslint": "^9.0.0",
"eslint-plugin-compat": "^6.0.0",
"eslint-plugin-jest": "^28.8.2",
"eslint": "^9.11.1",
"eslint-plugin-compat": "^6.0.1",
"eslint-plugin-jest": "^28.8.3",
"eslint-plugin-jsx-a11y": "^6.10.0",
"eslint-plugin-react-hooks": "^5.1.0-beta-26f2496093-20240514",
"eslint-plugin-react-refresh": "^0.4.11",
"eslint-plugin-react-refresh": "^0.4.12",
"fast-glob": "^3.3.2",
"fetch-jsonp": "^1.3.0",
"fs-extra": "^11.2.0",
@ -259,7 +259,7 @@
"jest-image-snapshot": "^6.4.0",
"jest-puppeteer": "^10.1.1",
"jquery": "^3.7.1",
"jsdom": "^25.0.0",
"jsdom": "^25.0.1",
"jsonml-to-react-element": "^1.1.11",
"jsonml.js": "^0.1.0",
"lint-staged": "^15.2.10",
@ -279,11 +279,11 @@
"prettier": "^3.3.3",
"pretty-format": "^29.7.0",
"prismjs": "^1.29.0",
"puppeteer": "^23.3.0",
"puppeteer": "^23.4.1",
"qs": "^6.13.0",
"rc-footer": "^0.6.8",
"rc-tween-one": "^3.0.6",
"rc-virtual-list": "^3.14.5",
"rc-virtual-list": "^3.14.8",
"react": "^18.3.1",
"react-copy-to-clipboard": "^5.1.0",
"react-countup": "^6.5.3",
@ -297,31 +297,31 @@
"react-router-dom": "^6.26.2",
"react-sticky-box": "^2.0.5",
"regenerator-runtime": "^0.14.1",
"rehype-stringify": "^10.0.0",
"rehype-stringify": "^10.0.1",
"remark": "^15.0.1",
"remark-cli": "^12.0.1",
"remark-gfm": "^4.0.0",
"remark-lint": "^10.0.0",
"remark-lint-no-undefined-references": "^5.0.0",
"remark-preset-lint-recommended": "^7.0.0",
"remark-rehype": "^11.1.0",
"remark-rehype": "^11.1.1",
"rimraf": "^6.0.1",
"runes2": "^1.1.4",
"semver": "^7.6.3",
"sharp": "^0.33.5",
"simple-git": "^3.26.0",
"size-limit": "^11.1.5",
"simple-git": "^3.27.0",
"size-limit": "^11.1.6",
"spinnies": "^0.5.1",
"sylvanas": "^0.6.1",
"tar": "^7.4.0",
"tar": "^7.4.3",
"tar-fs": "^3.0.6",
"terser": "^5.32.0",
"terser": "^5.34.1",
"tsx": "4.11.2",
"typedoc": "^0.26.7",
"typescript": "~5.6.2",
"vanilla-jsoneditor": "^1.0.0",
"vanilla-jsoneditor": "^1.0.6",
"vanilla-tilt": "^1.8.1",
"webpack": "^5.94.0",
"webpack": "^5.95.0",
"webpack-bundle-analyzer": "^4.10.2",
"xhr-mock": "^2.5.1"
},