Skip to content

Commit a18de31

Browse files
committed
refactor: 移除已废弃的 columnsStateMap 属性,统一使用 columnsState
1 parent aeda008 commit a18de31

File tree

6 files changed

+11
-256
lines changed

6 files changed

+11
-256
lines changed

demos/table/columnsStateMap.tsx

Lines changed: 0 additions & 113 deletions
This file was deleted.

docs/components/table/index.$tab-api.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ RTL means right-to-left.
5151

5252
可以默认隐藏某些栏,但是在操作栏中可以选择
5353

54-
<code src="../../../demos/table/columnsStateMap.tsx" background="var(--main-bg-color)" ></code>
55-
5654
<code src="../../../demos/table/pollinga.tsx" background="var(--main-bg-color)" title="表格轮询"></code>
5755

5856
<code src="../../../demos/table/dateFormatter.tsx" background="var(--main-bg-color)" title="dateFormatter-日期格式化"></code>

docs/components/table/index.en-US.$tab-api.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ RTL means right-to-left.
5353

5454
You can hide some columns by default, but in the action column you can select
5555

56-
<code src="../../../demos/table/columnsStateMap.tsx" background="var(--main-bg-color)" ></code>
57-
5856
### Tables polling network data
5957

6058
<code src="../../../demos/table/pollinga.tsx" background="var(--main-bg-color)" ></code>

src/table/Store/Provide.tsx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { TableColumnType } from 'antd';
22
import merge from 'lodash-es/merge';
33
import useMergedState from 'rc-util/lib/hooks/useMergedState';
4-
import { noteOnce } from 'rc-util/lib/warning';
54
import {
65
createContext,
76
useCallback,
@@ -29,7 +28,6 @@ export type ColumnsState = {
2928
export type ProTableColumn<T> = ColumnsState & TableColumnType<T>;
3029

3130
export type UseContainerProps<T = any> = {
32-
columnsStateMap?: Record<string, ColumnsState>;
3331
onColumnsStateChange?: (map: Record<string, ColumnsState>) => void;
3432
size?: DensitySize;
3533
defaultSize?: DensitySize;
@@ -105,14 +103,13 @@ function useContainer(props: UseContainerProps = {} as Record<string, any>) {
105103
}
106104
}
107105
return (
108-
props.columnsStateMap ||
109106
props.columnsState?.value ||
110107
props.columnsState?.defaultValue ||
111108
defaultColumnKeyMap
112109
);
113110
},
114111
{
115-
value: props.columnsState?.value || props.columnsStateMap,
112+
value: props.columnsState?.value,
116113
onChange: props.columnsState?.onChange || props.onColumnsStateChange,
117114
},
118115
);
@@ -152,15 +149,6 @@ function useContainer(props: UseContainerProps = {} as Record<string, any>) {
152149
defaultColumnKeyMap,
153150
]);
154151

155-
noteOnce(
156-
!props.columnsStateMap,
157-
'columnsStateMap已经废弃,请使用 columnsState.value 替换',
158-
);
159-
noteOnce(
160-
!props.columnsStateMap,
161-
'columnsStateMap has been discarded, please use columnsState.value replacement',
162-
);
163-
164152
/** 清空一下当前的 key */
165153
const clearPersistenceStorage = useCallback(() => {
166154
const { persistenceType, persistenceKey } = props.columnsState || {};

src/table/typing.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ export type ColumnStateType = {
184184
persistenceType?: 'localStorage' | 'sessionStorage';
185185
/** 持久化的key,用于存储到 storage 中 */
186186
persistenceKey?: string;
187-
/** ColumnsState 的值,columnsStateMap将会废弃 */
187+
/** ColumnsState 的值 */
188188
defaultValue?: Record<string, ColumnsState>;
189-
/** ColumnsState 的值,columnsStateMap将会废弃 */
189+
/** ColumnsState 的值 */
190190
value?: Record<string, ColumnsState>;
191191
onChange?: (map: Record<string, ColumnsState>) => void;
192192
};

tests/table/columnSetting.test.tsx

Lines changed: 8 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -82,126 +82,6 @@ describe('Table ColumnSetting', () => {
8282
expect(titleList.length).toBe(2);
8383
});
8484

85-
it('🎏 columnSetting columnsStateMap props', async () => {
86-
const html = render(
87-
<ProTable
88-
size="small"
89-
columnsStateMap={{
90-
index: { fixed: 'left' },
91-
Age: { show: false },
92-
option: { fixed: 'right' },
93-
}}
94-
columns={columns}
95-
request={async () => {
96-
return {
97-
data: [
98-
{
99-
key: 1,
100-
name: `TradeCode ${1}`,
101-
createdAt: 1602572994055,
102-
},
103-
],
104-
success: true,
105-
};
106-
}}
107-
rowKey="key"
108-
/>,
109-
);
110-
await waitForWaitTime(100);
111-
112-
act(() => {
113-
html.baseElement
114-
.querySelector<HTMLDivElement>(
115-
'.ant-pro-table-list-toolbar-setting-item .anticon-setting',
116-
)
117-
?.click();
118-
});
119-
await waitForWaitTime(100);
120-
let overlay = html.baseElement.querySelectorAll<HTMLDivElement>(
121-
'.ant-pro-table-column-setting-overlay .ant-pro-table-column-setting-list-title',
122-
);
123-
expect(overlay.length).toBe(3);
124-
125-
act(() => {
126-
html.rerender(
127-
<ProTable
128-
size="small"
129-
columnsStateMap={{
130-
index: { fixed: 'left' },
131-
}}
132-
columns={columns}
133-
request={async () => {
134-
return {
135-
data: [
136-
{
137-
key: 1,
138-
name: `TradeCode ${1}`,
139-
createdAt: 1602572994055,
140-
},
141-
],
142-
success: true,
143-
};
144-
}}
145-
rowKey="key"
146-
/>,
147-
);
148-
});
149-
await waitForWaitTime(100);
150-
overlay = html.baseElement.querySelectorAll<HTMLDivElement>(
151-
'.ant-pro-table-column-setting-overlay .ant-pro-table-column-setting-list-title',
152-
);
153-
expect(overlay.length).toBe(2);
154-
});
155-
156-
it('🎏 columnSetting columnsStateMap onChange', async () => {
157-
const callBack = vi.fn();
158-
const html = render(
159-
<ProTable
160-
size="small"
161-
columnsStateMap={{
162-
index: { fixed: 'left' },
163-
Age: { show: false },
164-
option: { fixed: 'right' },
165-
}}
166-
onColumnsStateChange={callBack}
167-
columns={columns}
168-
request={async () => {
169-
return {
170-
data: [
171-
{
172-
key: 1,
173-
name: `TradeCode ${1}`,
174-
createdAt: 1602572994055,
175-
},
176-
],
177-
success: true,
178-
};
179-
}}
180-
rowKey="key"
181-
/>,
182-
);
183-
184-
await waitForWaitTime(200);
185-
act(() => {
186-
html.baseElement
187-
.querySelector<HTMLDivElement>(
188-
'.ant-pro-table-list-toolbar-setting-item .anticon-setting',
189-
)
190-
?.click();
191-
});
192-
await waitForWaitTime(100);
193-
194-
const reset = html.baseElement.querySelector<HTMLDivElement>(
195-
'.ant-pro-table-column-setting-title a',
196-
);
197-
act(() => {
198-
reset?.click();
199-
});
200-
await waitForWaitTime(100);
201-
202-
expect(callBack).toHaveBeenCalled();
203-
});
204-
20585
it('🎏 columnSetting columnsState.value props', async () => {
20686
const html = render(
20787
<ProTable
@@ -692,8 +572,10 @@ describe('Table ColumnSetting', () => {
692572
const html = render(
693573
<ProTable
694574
size="small"
695-
onColumnsStateChange={() => {
696-
callBack();
575+
columnsState={{
576+
onChange: () => {
577+
callBack();
578+
},
697579
}}
698580
columns={[
699581
{
@@ -1003,8 +885,10 @@ describe('Table ColumnSetting', () => {
1003885
const html = render(
1004886
<ProTable
1005887
size="small"
1006-
onColumnsStateChange={() => {
1007-
callBack();
888+
columnsState={{
889+
onChange: () => {
890+
callBack();
891+
},
1008892
}}
1009893
columns={[
1010894
{

0 commit comments

Comments
 (0)