From aa648d2cd80847054b86907890f6977c4425f45f Mon Sep 17 00:00:00 2001 From: losgif Date: Sat, 30 Jul 2022 17:13:20 +0800 Subject: [PATCH 01/22] feat(table): add column title attribute in expandable props. (#36794) * chore: rc-table's version up to 7.26.0 * docs(table): add column title attribute in expandable * docs(table): add column title attribute in expandable --- components/table/index.en-US.md | 1 + components/table/index.zh-CN.md | 1 + package.json | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/components/table/index.en-US.md b/components/table/index.en-US.md index b1964d0899..c2de4149ee 100644 --- a/components/table/index.en-US.md +++ b/components/table/index.en-US.md @@ -177,6 +177,7 @@ Properties for expandable. | Property | Description | Type | Default | Version | | --- | --- | --- | --- | --- | | childrenColumnName | The column contains children to display | string | children | | +| columnTitle | Set the title of the expand column | ReactNode | - | 4.23.0 | | columnWidth | Set the width of the expand column | string \| number | - | | | defaultExpandAllRows | Expand all rows initially | boolean | false | | | defaultExpandedRowKeys | Initial expanded row keys | string\[] | - | | diff --git a/components/table/index.zh-CN.md b/components/table/index.zh-CN.md index b5d8017063..902b874e5d 100644 --- a/components/table/index.zh-CN.md +++ b/components/table/index.zh-CN.md @@ -178,6 +178,7 @@ const columns = [ | 参数 | 说明 | 类型 | 默认值 | 版本 | | --- | --- | --- | --- | --- | | childrenColumnName | 指定树形结构的列名 | string | children | | +| columnTitle | 自定义展开列表头 | ReactNode | - | 4.23.0 | | columnWidth | 自定义展开列宽度 | string \| number | - | | | defaultExpandAllRows | 初始时,是否展开所有行 | boolean | false | | | defaultExpandedRowKeys | 默认展开的行 | string\[] | - | | diff --git a/package.json b/package.json index e7737114a5..921aa7f36f 100644 --- a/package.json +++ b/package.json @@ -148,7 +148,7 @@ "rc-slider": "~10.0.0", "rc-steps": "~4.1.0", "rc-switch": "~3.2.0", - "rc-table": "~7.25.3", + "rc-table": "~7.26.0", "rc-tabs": "~11.16.0", "rc-textarea": "~0.3.0", "rc-tooltip": "~5.2.0", From 549a2f956f1e5c414457ef315ea321ce9e5d5275 Mon Sep 17 00:00:00 2001 From: JarvisArt <38420763+JarvisArt@users.noreply.github.com> Date: Mon, 1 Aug 2022 17:39:57 +0800 Subject: [PATCH 02/22] feat: add value parameter to textarea showCount.formatter (#36793) --- components/input/TextArea.tsx | 4 ++-- components/input/__tests__/index.test.tsx | 6 ++++-- components/input/__tests__/textarea.test.js | 6 ++++-- components/input/index.en-US.md | 4 ++-- components/input/index.zh-CN.md | 4 ++-- package.json | 2 +- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/components/input/TextArea.tsx b/components/input/TextArea.tsx index 82dde308a2..2be7514256 100644 --- a/components/input/TextArea.tsx +++ b/components/input/TextArea.tsx @@ -17,7 +17,7 @@ import type { InputFocusOptions } from './Input'; import { fixControlledValue, resolveOnChange, triggerFocus } from './Input'; interface ShowCountProps { - formatter: (args: { count: number; maxLength?: number }) => string; + formatter: (args: { value: string; count: number; maxLength?: number }) => string; } function fixEmojiLength(value: string, maxLength: number) { @@ -233,7 +233,7 @@ const TextArea = React.forwardRef( let dataCount = ''; if (typeof showCount === 'object') { - dataCount = showCount.formatter({ count: valueLength, maxLength }); + dataCount = showCount.formatter({ value: val, count: valueLength, maxLength }); } else { dataCount = `${valueLength}${hasMaxLength ? ` / ${maxLength}` : ''}`; } diff --git a/components/input/__tests__/index.test.tsx b/components/input/__tests__/index.test.tsx index c43759b7b7..833c682d16 100644 --- a/components/input/__tests__/index.test.tsx +++ b/components/input/__tests__/index.test.tsx @@ -272,12 +272,14 @@ describe('should support showCount', () => { const { container } = render( `${count}, ${maxLength}` }} + showCount={{ + formatter: ({ value, count, maxLength }) => `${value}, ${count}, ${maxLength}`, + }} value="12345" />, ); expect(container.querySelector('input')?.getAttribute('value')).toBe('12345'); - expect(container.querySelector('.ant-input-show-count-suffix')?.innerHTML).toBe('5, 5'); + expect(container.querySelector('.ant-input-show-count-suffix')?.innerHTML).toBe('12345, 5, 5'); }); }); diff --git a/components/input/__tests__/textarea.test.js b/components/input/__tests__/textarea.test.js index 27a882c428..3e3744034c 100644 --- a/components/input/__tests__/textarea.test.js +++ b/components/input/__tests__/textarea.test.js @@ -304,13 +304,15 @@ describe('TextArea', () => { const { container } = render(