From 59f0259f297aa3ebb485109ed30f619b03bee2a6 Mon Sep 17 00:00:00 2001 From: Siniji <1349021570@qq.com> Date: Tue, 19 Sep 2023 15:01:43 +0800 Subject: [PATCH 1/9] fix: change css in style.ts fiels --- .../components/PageContainer/demos/token.tsx | 2 +- .../src/components/PageContainer/index.tsx | 17 +++++++++-------- .../src/components/PageContainer/style/index.ts | 5 +++++ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/layout/src/components/PageContainer/demos/token.tsx b/packages/layout/src/components/PageContainer/demos/token.tsx index 6c0799ee327e..2d61f9792abd 100644 --- a/packages/layout/src/components/PageContainer/demos/token.tsx +++ b/packages/layout/src/components/PageContainer/demos/token.tsx @@ -65,7 +65,7 @@ export default () => ( ], }} > - + ); diff --git a/packages/layout/src/components/PageContainer/index.tsx b/packages/layout/src/components/PageContainer/index.tsx index 2690b232c356..ad94725cfa31 100644 --- a/packages/layout/src/components/PageContainer/index.tsx +++ b/packages/layout/src/components/PageContainer/index.tsx @@ -355,6 +355,10 @@ const PageContainerBase: React.FC = (props) => { const basePageContainer = `${prefixCls}-page-container`; const { wrapSSR, hashId } = useStyle(basePageContainer, propsToken); + console.log( + 'useStyle(basePageContainer, propsToken)', + useStyle(basePageContainer, propsToken), + ); const stylish = useStylish( `${basePageContainer}.${basePageContainer}-stylish`, @@ -398,15 +402,12 @@ const PageContainerBase: React.FC = (props) => { <>
{children}
diff --git a/packages/layout/src/components/PageContainer/style/index.ts b/packages/layout/src/components/PageContainer/style/index.ts index b92353b6f610..1ec33196ba58 100644 --- a/packages/layout/src/components/PageContainer/style/index.ts +++ b/packages/layout/src/components/PageContainer/style/index.ts @@ -12,11 +12,16 @@ const genPageContainerStyle: GenerateStyle = (token) => { [token.componentCls]: { position: 'relative', '&-children-container': { + paddingBlockStart: 0, paddingBlockEnd: token.layout?.pageContainer?.paddingBlockPageContainerContent, paddingInline: token.layout?.pageContainer?.paddingInlinePageContainerContent, }, + '&-children-container-no-header': { + paddingBlockStart: + token.layout?.pageContainer?.paddingBlockPageContainerContent, + }, '&-affix': { [`${token.antCls}-affix`]: { [`${token.componentCls}-warp`]: { From 1599a94f0fd1301d445229c6b8d79be138f8dc96 Mon Sep 17 00:00:00 2001 From: Siniji <1349021570@qq.com> Date: Tue, 19 Sep 2023 15:02:42 +0800 Subject: [PATCH 2/9] fix: delete useless code --- packages/layout/src/components/PageContainer/index.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/layout/src/components/PageContainer/index.tsx b/packages/layout/src/components/PageContainer/index.tsx index ad94725cfa31..8a73a7ee37d5 100644 --- a/packages/layout/src/components/PageContainer/index.tsx +++ b/packages/layout/src/components/PageContainer/index.tsx @@ -355,10 +355,6 @@ const PageContainerBase: React.FC = (props) => { const basePageContainer = `${prefixCls}-page-container`; const { wrapSSR, hashId } = useStyle(basePageContainer, propsToken); - console.log( - 'useStyle(basePageContainer, propsToken)', - useStyle(basePageContainer, propsToken), - ); const stylish = useStylish( `${basePageContainer}.${basePageContainer}-stylish`, From 8830ffc31e6b2d946200657772d7928c8a7200c4 Mon Sep 17 00:00:00 2001 From: Siniji <1349021570@qq.com> Date: Tue, 19 Sep 2023 16:28:26 +0800 Subject: [PATCH 3/9] fix: ts error fixed --- packages/field/src/index.tsx | 2 -- packages/form/src/layouts/DrawerForm/index.tsx | 2 +- packages/layout/src/components/PageContainer/index.tsx | 10 ++++++---- packages/utils/src/useEditableArray/index.tsx | 1 - 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/field/src/index.tsx b/packages/field/src/index.tsx index 1e9dc9a6f3bb..3d183a5356f3 100644 --- a/packages/field/src/index.tsx +++ b/packages/field/src/index.tsx @@ -64,8 +64,6 @@ dayjs.extend(isoWeek); dayjs.extend(weekOfYear); dayjs.extend(weekday); -const REQUEST_VALUE_TYPE = ['select', 'radio', 'radioButton', 'checkbook']; - export type ProFieldMoneyProps = FieldMoneyProps; export type ProFieldEmptyText = string | false; diff --git a/packages/form/src/layouts/DrawerForm/index.tsx b/packages/form/src/layouts/DrawerForm/index.tsx index da612d083f95..89b25de6828a 100644 --- a/packages/form/src/layouts/DrawerForm/index.tsx +++ b/packages/form/src/layouts/DrawerForm/index.tsx @@ -280,7 +280,7 @@ function DrawerForm, U = Record>({ const offsetRight: number | string = ((document.body.offsetWidth || 1000) - (e.clientX - document.body.offsetLeft)) as number | string; - const minWidth = resizeInfo?.minWidth ?? width; + const minWidth = resizeInfo?.minWidth ?? (width || 800); const maxWidth = resizeInfo?.maxWidth ?? window.innerWidth * 0.8; if (offsetRight < minWidth) { diff --git a/packages/layout/src/components/PageContainer/index.tsx b/packages/layout/src/components/PageContainer/index.tsx index 8a73a7ee37d5..74ef31c7f376 100644 --- a/packages/layout/src/components/PageContainer/index.tsx +++ b/packages/layout/src/components/PageContainer/index.tsx @@ -398,10 +398,12 @@ const PageContainerBase: React.FC = (props) => { <>
diff --git a/packages/utils/src/useEditableArray/index.tsx b/packages/utils/src/useEditableArray/index.tsx index 11b4250dabfd..611be3a51518 100644 --- a/packages/utils/src/useEditableArray/index.tsx +++ b/packages/utils/src/useEditableArray/index.tsx @@ -333,7 +333,6 @@ export function SaveEditableAction( .filter(Boolean) as string[]; setLoading(true); await form.validateFields(namePath, { - // @ts-expect-error recursive: true, }); From 94dbaaeab48286df07e54a660a4f22a2ee3f8a96 Mon Sep 17 00:00:00 2001 From: Siniji <1349021570@qq.com> Date: Tue, 19 Sep 2023 16:59:35 +0800 Subject: [PATCH 4/9] fix: ts fixd --- packages/form/src/components/Checkbox/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/form/src/components/Checkbox/index.tsx b/packages/form/src/components/Checkbox/index.tsx index 77f155e3d28f..00b3b5657250 100644 --- a/packages/form/src/components/Checkbox/index.tsx +++ b/packages/form/src/components/Checkbox/index.tsx @@ -70,7 +70,7 @@ const ProFormCheckboxComponents: React.FC = React.forwardRef( ({ fieldProps, children }, ref) => { return ( - + {children} ); From a18a448530d478b24a0a59bdb3b454e655a4adf4 Mon Sep 17 00:00:00 2001 From: Siniji <1349021570@qq.com> Date: Thu, 21 Sep 2023 11:55:35 +0800 Subject: [PATCH 5/9] fix: lint ci fixed --- .../form/src/components/Checkbox/index.tsx | 11 ++++------ .../src/components/SiderMenu/BaseMenu.tsx | 8 +++++--- .../layout/src/components/WaterMark/index.tsx | 18 ++++++++--------- packages/list/src/demos/expand.tsx | 6 ++---- packages/list/src/demos/selectedRow.tsx | 6 +++--- packages/list/src/demos/size.tsx | 10 ++++------ packages/list/src/demos/special.tsx | 10 ++++------ .../list/src/demos/testConfigProvider.tsx | 6 +++--- packages/table/src/Store/Provide.tsx | 4 ++-- packages/table/src/Table.tsx | 5 +++-- packages/table/src/components/Alert/index.tsx | 6 +++--- .../src/components/ColumnSetting/index.tsx | 4 ++-- .../src/components/EditableTable/index.tsx | 7 +++++-- .../table/src/components/ToolBar/index.tsx | 4 ++-- .../table/src/utils/cellRenderToFromItem.tsx | 2 +- .../table/src/utils/genProColumnToColumn.tsx | 4 ++-- packages/table/src/utils/index.ts | 3 ++- .../src/transformKeySubmitValue/index.ts | 2 +- packages/utils/src/useEditableArray/index.tsx | 4 ++-- tests/list/index.test.tsx | 20 +++++++++---------- 20 files changed, 69 insertions(+), 71 deletions(-) diff --git a/packages/form/src/components/Checkbox/index.tsx b/packages/form/src/components/Checkbox/index.tsx index 00b3b5657250..a50f82db212c 100644 --- a/packages/form/src/components/Checkbox/index.tsx +++ b/packages/form/src/components/Checkbox/index.tsx @@ -1,5 +1,5 @@ import { runFunction } from '@ant-design/pro-utils'; -import type { CheckboxProps } from 'antd'; +import type { CheckboxProps, CheckboxRef } from 'antd'; import { Checkbox } from 'antd'; import type { CheckboxGroupProps } from 'antd/lib/checkbox'; import React from 'react'; @@ -56,10 +56,7 @@ const CheckboxGroup: React.FC = React.forwardRef( ), ); -export type ProFormCheckboxProps = ProFormFieldItemProps< - CheckboxProps, - HTMLInputElement ->; +export type ProFormCheckboxProps = ProFormFieldItemProps; /** * 多选框的 @@ -67,10 +64,10 @@ export type ProFormCheckboxProps = ProFormFieldItemProps< * @param */ const ProFormCheckboxComponents: React.FC = - React.forwardRef( + React.forwardRef( ({ fieldProps, children }, ref) => { return ( - + {children} ); diff --git a/packages/layout/src/components/SiderMenu/BaseMenu.tsx b/packages/layout/src/components/SiderMenu/BaseMenu.tsx index 44e5e647021c..2d03ceef71dd 100644 --- a/packages/layout/src/components/SiderMenu/BaseMenu.tsx +++ b/packages/layout/src/components/SiderMenu/BaseMenu.tsx @@ -546,7 +546,9 @@ const BaseMenu: React.FC = (props) => { menu?.defaultOpenAll, ); - const [openKeys, setOpenKeys] = useMountMergeState>( + const [openKeys, setOpenKeys] = useMountMergeState< + (string | number)[] | false + >( () => { if (menu?.defaultOpenAll) { return getOpenKeysFromMenuData(menuData) || []; @@ -605,7 +607,7 @@ const BaseMenu: React.FC = (props) => { propsOpenKeys !== false && matchMenuKeys.join('-') !== (openKeys || []).join('-') ) { - let newKeys: React.Key[] = matchMenuKeys; + let newKeys: (string | number)[] | false = matchMenuKeys; // 如果不自动关闭,我需要把 openKeys 放进去 if (menu?.autoClose === false) { newKeys = Array.from( @@ -697,7 +699,7 @@ const BaseMenu: React.FC = (props) => { [`${baseClassName}-collapsed`]: props.collapsed, })} items={menuUtils.getNavMenuItems(finallyData, 0)} - onOpenChange={(_openKeys: React.Key[]) => { + onOpenChange={(_openKeys) => { if (!props.collapsed) { setOpenKeys(_openKeys); } diff --git a/packages/layout/src/components/WaterMark/index.tsx b/packages/layout/src/components/WaterMark/index.tsx index 51bfcf239375..f6b1cecd5638 100644 --- a/packages/layout/src/components/WaterMark/index.tsx +++ b/packages/layout/src/components/WaterMark/index.tsx @@ -85,7 +85,7 @@ export const WaterMark: React.FC = (props) => { rotate = -22, // 默认旋转 -22 度 image, offsetLeft, - offsetTop, + offsetTop: outOffsetTop, fontStyle = 'normal', fontWeight = 'normal', fontColor = token.colorFill, @@ -108,7 +108,7 @@ export const WaterMark: React.FC = (props) => { const canvasWidth = `${(gapX + width) * ratio}px`; const canvasHeight = `${(gapY + height) * ratio}px`; const canvasOffsetLeft = offsetLeft || gapX / 2; - const canvasOffsetTop = offsetTop || gapY / 2; + const canvasOffsetTop = outOffsetTop || gapY / 2; canvas.setAttribute('width', canvasWidth); canvas.setAttribute('height', canvasHeight); @@ -119,6 +119,12 @@ export const WaterMark: React.FC = (props) => { return; } + // 旋转字符 rotate + ctx.translate(canvasOffsetLeft * ratio, canvasOffsetTop * ratio); + ctx.rotate((Math.PI / 180) * Number(rotate)); + const markWidth = width * ratio; + const markHeight = height * ratio; + const writeContent = ( contentText: string | string[], offsetTop: number = 0, @@ -136,12 +142,6 @@ export const WaterMark: React.FC = (props) => { setBase64Url(canvas.toDataURL()); }; - // 旋转字符 rotate - ctx.translate(canvasOffsetLeft * ratio, canvasOffsetTop * ratio); - ctx.rotate((Math.PI / 180) * Number(rotate)); - const markWidth = width * ratio; - const markHeight = height * ratio; - if (image) { const img = new Image(); img.crossOrigin = 'anonymous'; @@ -165,7 +165,7 @@ export const WaterMark: React.FC = (props) => { gapX, gapY, offsetLeft, - offsetTop, + outOffsetTop, rotate, fontStyle, fontWeight, diff --git a/packages/list/src/demos/expand.tsx b/packages/list/src/demos/expand.tsx index c76c10b1653f..f2f94614ba1c 100644 --- a/packages/list/src/demos/expand.tsx +++ b/packages/list/src/demos/expand.tsx @@ -1,6 +1,6 @@ import { ProList } from '@ant-design/pro-components'; import { Button, Progress, Space, Tag } from 'antd'; -import type { ReactText } from 'react'; +import type { Key } from 'react'; import { useState } from 'react'; const dataSource = [ @@ -27,9 +27,7 @@ const dataSource = [ ]; export default () => { - const [expandedRowKeys, setExpandedRowKeys] = useState( - [], - ); + const [expandedRowKeys, setExpandedRowKeys] = useState([]); return ( diff --git a/packages/list/src/demos/selectedRow.tsx b/packages/list/src/demos/selectedRow.tsx index 80f63de48c5d..dbc2faead585 100644 --- a/packages/list/src/demos/selectedRow.tsx +++ b/packages/list/src/demos/selectedRow.tsx @@ -1,6 +1,6 @@ import { ProList } from '@ant-design/pro-components'; import { Button, Progress } from 'antd'; -import type { ReactText } from 'react'; +import type { Key } from 'react'; import { useState } from 'react'; const dataSource = [ @@ -27,10 +27,10 @@ const dataSource = [ ]; export default () => { - const [selectedRowKeys, setSelectedRowKeys] = useState([]); + const [selectedRowKeys, setSelectedRowKeys] = useState([]); const rowSelection = { selectedRowKeys, - onChange: (keys: ReactText[]) => setSelectedRowKeys(keys), + onChange: (keys: Key[]) => setSelectedRowKeys(keys), }; return ( diff --git a/packages/list/src/demos/size.tsx b/packages/list/src/demos/size.tsx index 8d6f877040a6..0c568ab5a786 100644 --- a/packages/list/src/demos/size.tsx +++ b/packages/list/src/demos/size.tsx @@ -1,6 +1,6 @@ import { ProList } from '@ant-design/pro-components'; import { Button, Progress, Select } from 'antd'; -import type { ReactText } from 'react'; +import type { Key } from 'react'; import { useState } from 'react'; const dataSource = [ @@ -27,17 +27,15 @@ const dataSource = [ ]; export default () => { - const [selectedRowKeys, setSelectedRowKeys] = useState([]); - const [expandedRowKeys, setExpandedRowKeys] = useState( - [], - ); + const [selectedRowKeys, setSelectedRowKeys] = useState([]); + const [expandedRowKeys, setExpandedRowKeys] = useState([]); const [size, setSize] = useState<'small' | 'default' | 'large' | undefined>( 'default', ); const [split, setSplit] = useState<0 | 1>(1); const rowSelection = { selectedRowKeys, - onChange: (keys: ReactText[]) => setSelectedRowKeys(keys), + onChange: (keys: Key[]) => setSelectedRowKeys(keys), }; return ( diff --git a/packages/list/src/demos/special.tsx b/packages/list/src/demos/special.tsx index d4d977c95062..6730dd11e8b7 100644 --- a/packages/list/src/demos/special.tsx +++ b/packages/list/src/demos/special.tsx @@ -1,7 +1,7 @@ import { EllipsisOutlined } from '@ant-design/icons'; import { ProList } from '@ant-design/pro-components'; import { Button, Progress, Tag } from 'antd'; -import type { ReactText } from 'react'; +import type { Key } from 'react'; import { useState } from 'react'; const types = ['top', 'inline', 'new']; @@ -51,13 +51,11 @@ const data = [ })); export default () => { - const [expandedRowKeys, setExpandedRowKeys] = useState( - [], - ); - const [selectedRowKeys, setSelectedRowKeys] = useState([]); + const [expandedRowKeys, setExpandedRowKeys] = useState([]); + const [selectedRowKeys, setSelectedRowKeys] = useState([]); const rowSelection = { selectedRowKeys, - onChange: (keys: ReactText[]) => setSelectedRowKeys(keys), + onChange: (keys: Key[]) => setSelectedRowKeys(keys), }; const [dataSource, setDataSource] = useState([...data] as any[]); diff --git a/packages/list/src/demos/testConfigProvider.tsx b/packages/list/src/demos/testConfigProvider.tsx index 27b2642c6721..734834c93523 100644 --- a/packages/list/src/demos/testConfigProvider.tsx +++ b/packages/list/src/demos/testConfigProvider.tsx @@ -1,6 +1,6 @@ import { ProList } from '@ant-design/pro-components'; import { ConfigProvider, Progress } from 'antd'; -import type { ReactText } from 'react'; +import type { Key } from 'react'; import { useState } from 'react'; const dataSource = [ @@ -12,10 +12,10 @@ const dataSource = [ ]; export default () => { - const [selectedRowKeys, setSelectedRowKeys] = useState([]); + const [selectedRowKeys, setSelectedRowKeys] = useState([]); const rowSelection = { selectedRowKeys, - onChange: (keys: ReactText[]) => setSelectedRowKeys(keys), + onChange: (keys: Key[]) => setSelectedRowKeys(keys), }; return ( diff --git a/packages/table/src/Store/Provide.tsx b/packages/table/src/Store/Provide.tsx index 46e82c8260de..f76ac047f6c6 100644 --- a/packages/table/src/Store/Provide.tsx +++ b/packages/table/src/Store/Provide.tsx @@ -11,7 +11,7 @@ import { } from 'react'; import type { DensitySize } from '../components/ToolBar/DensityIcon'; import type { ProTableProps } from '../index'; -import type { ActionType } from '../typing'; +import type { ActionType, ProColumns } from '../typing'; import { genColumnKey } from '../utils'; export type ColumnsState = { @@ -33,7 +33,7 @@ export type UseContainerProps = { size?: DensitySize; defaultSize?: DensitySize; onSizeChange?: (size: DensitySize) => void; - columns?: ProTableColumn[]; + columns?: ProTableColumn[] | ProColumns[]; columnsState?: ProTableProps['columnsState']; }; diff --git a/packages/table/src/Table.tsx b/packages/table/src/Table.tsx index 683796b4a647..8e4dc25410bf 100644 --- a/packages/table/src/Table.tsx +++ b/packages/table/src/Table.tsx @@ -28,6 +28,7 @@ import type { import classNames from 'classnames'; import type Summary from 'rc-table/lib/Footer/Summary'; import React, { + Key, useCallback, useContext, useEffect, @@ -478,7 +479,7 @@ const ProTable = < /** 单选多选的相关逻辑 */ const [selectedRowKeys, setSelectedRowKeys] = useMountMergeState< - (string | number)[] | undefined + (string | number)[] | Key[] | undefined >( propsRowSelection ? propsRowSelection?.defaultSelectedRowKeys || [] @@ -692,7 +693,7 @@ const ProTable = < setSelectedRowKeys([]); }, [propsRowSelection, setSelectedRowKeys]); - counter.propsRef.current = props; + counter.propsRef.current = props as ProTableProps; /** 可编辑行的相关配置 */ const editableUtils = useEditableArray({ diff --git a/packages/table/src/components/Alert/index.tsx b/packages/table/src/components/Alert/index.tsx index 67383989873d..875a950efda7 100644 --- a/packages/table/src/components/Alert/index.tsx +++ b/packages/table/src/components/Alert/index.tsx @@ -1,20 +1,20 @@ import type { IntlType } from '@ant-design/pro-provider'; import { useIntl } from '@ant-design/pro-provider'; import { ConfigProvider, Space } from 'antd'; -import React, { useContext } from 'react'; +import React, { Key, useContext } from 'react'; import { useStyle } from './style'; export type AlertRenderType = | ((props: { intl: IntlType; - selectedRowKeys: (number | string)[]; + selectedRowKeys: (number | string | Key)[]; selectedRows: T[]; onCleanSelected: () => void; }) => React.ReactNode) | false; export type TableAlertProps = { - selectedRowKeys: (number | string)[]; + selectedRowKeys: (number | string | Key)[]; selectedRows: T[]; alwaysShowAlert?: boolean; alertInfoRender?: AlertRenderType; diff --git a/packages/table/src/components/ColumnSetting/index.tsx b/packages/table/src/components/ColumnSetting/index.tsx index 6fbf33b1f868..af3674584740 100644 --- a/packages/table/src/components/ColumnSetting/index.tsx +++ b/packages/table/src/components/ColumnSetting/index.tsx @@ -224,7 +224,7 @@ const CheckboxList: React.FC<{ if (treeDataConfig.map?.get(key)?.children) { treeDataConfig.map .get(key) - ?.children?.forEach((item) => loopSetShow(item.key)); + ?.children?.forEach((item) => loopSetShow(item.key as string)); } newColumnMap[key] = newSetting; }; @@ -266,7 +266,7 @@ const CheckboxList: React.FC<{ {...node} showListItemOption={showListItemOption} title={runFunction(node.title, node)} - columnKey={node.key} + columnKey={node.key as string} /> ); }} diff --git a/packages/table/src/components/EditableTable/index.tsx b/packages/table/src/components/EditableTable/index.tsx index e67328e3afba..edff05f0c310 100644 --- a/packages/table/src/components/EditableTable/index.tsx +++ b/packages/table/src/components/EditableTable/index.tsx @@ -19,6 +19,7 @@ import useMergedState from 'rc-util/lib/hooks/useMergedState'; import get from 'rc-util/lib/utils/get'; import set from 'rc-util/lib/utils/set'; import React, { + Key, useContext, useEffect, useImperativeHandle, @@ -200,7 +201,9 @@ function EditableTable< * @param finlayRowKey * @returns string | number */ - const coverRowKey = (finlayRowKey: number | string): string | number => { + const coverRowKey = ( + finlayRowKey: number | string, + ): string | number | Key => { /** * 如果是 prop.name 的模式,就需要把行号转化成具体的rowKey。 */ @@ -304,7 +307,7 @@ function EditableTable< if (!props.controlled) return; value.forEach((current, index) => { formRef.current?.setFieldsValue({ - [getRowKey(current, index)]: current, + [`${getRowKey(current, index)}`]: current, }); }, {}); // eslint-disable-next-line react-hooks/exhaustive-deps diff --git a/packages/table/src/components/ToolBar/index.tsx b/packages/table/src/components/ToolBar/index.tsx index cf7ce82fbfe0..304e346db519 100644 --- a/packages/table/src/components/ToolBar/index.tsx +++ b/packages/table/src/components/ToolBar/index.tsx @@ -283,7 +283,7 @@ export type ToolbarRenderProps = { tableColumn: any[]; tooltip?: string | LabelTooltipType; selectedRows: T[]; - selectedRowKeys: React.Key[]; + selectedRowKeys: React.Key[] | (string | number)[]; headerTitle: React.ReactNode; toolbar: ProTableProps['toolbar']; options: ProTableProps['options']; @@ -400,7 +400,7 @@ class ToolbarRender extends React.Component> { action={actionRef} onSearch={this.onSearch} selectedRows={selectedRows} - selectedRowKeys={selectedRowKeys} + selectedRowKeys={selectedRowKeys as (string | number)[]} toolBarRender={toolBarRender} toolbar={{ filter: searchNode, diff --git a/packages/table/src/utils/cellRenderToFromItem.tsx b/packages/table/src/utils/cellRenderToFromItem.tsx index dd9f34dee17c..8fa32d7ab992 100644 --- a/packages/table/src/utils/cellRenderToFromItem.tsx +++ b/packages/table/src/utils/cellRenderToFromItem.tsx @@ -236,7 +236,7 @@ const CellRenderFromItem = (props: CellRenderFromItemProps) => { noStyle shouldUpdate={(pre, next) => { if (pre === next) return false; - const shouldName = [rowName].flat(1); + const shouldName = [rowName].flat(1) as (string | number | symbol)[]; try { return ( JSON.stringify(get(pre, shouldName)) !== diff --git a/packages/table/src/utils/genProColumnToColumn.tsx b/packages/table/src/utils/genProColumnToColumn.tsx index 3cf0593b472c..b455641c1565 100644 --- a/packages/table/src/utils/genProColumnToColumn.tsx +++ b/packages/table/src/utils/genProColumnToColumn.tsx @@ -114,7 +114,7 @@ export function genProColumnToColumn( return omitBoolean(onFilter); }; - let keyName: React.Key = rowKey as string; + let keyName: string | number | symbol = rowKey as string; const tempColumns = { index: columnsIndex, @@ -142,7 +142,7 @@ export function genProColumnToColumn( : undefined, render: (text: any, rowData: T, index: number) => { if (typeof rowKey === 'function') { - keyName = rowKey(rowData, index); + keyName = rowKey(rowData, index) as string; } let uniqueKey: any; diff --git a/packages/table/src/utils/index.ts b/packages/table/src/utils/index.ts index 0776fbd5858e..1ae2483c0940 100644 --- a/packages/table/src/utils/index.ts +++ b/packages/table/src/utils/index.ts @@ -3,6 +3,7 @@ import type { UseEditableUtilType } from '@ant-design/pro-utils'; import type { TablePaginationConfig } from 'antd'; import type { SortOrder } from 'antd/lib/table/interface'; import type React from 'react'; +import { Key } from 'react'; import type { ActionType, Bordered, @@ -160,7 +161,7 @@ export const isMergeCell = ( * @param index 序列号,理论上唯一 */ export const genColumnKey = ( - key?: string | number, + key?: string | number | Key, index?: number | string, ): string => { if (key) { diff --git a/packages/utils/src/transformKeySubmitValue/index.ts b/packages/utils/src/transformKeySubmitValue/index.ts index d5187882e9c2..3255c8c29529 100644 --- a/packages/utils/src/transformKeySubmitValue/index.ts +++ b/packages/utils/src/transformKeySubmitValue/index.ts @@ -133,7 +133,7 @@ export const transformKeySubmitValue = ( : [entityKey].flat(1); const itemValue = tempValues[entityKey]; - const transformFunction = get(dataFormatMap, key); + const transformFunction = get(dataFormatMap, key as (number | string)[]); const transform = () => { let tempKey, diff --git a/packages/utils/src/useEditableArray/index.tsx b/packages/utils/src/useEditableArray/index.tsx index 611be3a51518..982154e84d03 100644 --- a/packages/utils/src/useEditableArray/index.tsx +++ b/packages/utils/src/useEditableArray/index.tsx @@ -345,7 +345,7 @@ export function SaveEditableAction( const [, ...recordKeyPath] = recordKey; // 将目标值获取出来并设置到 fields 当中 const curValue = get(fields, recordKeyPath as string[]); - set(fields, recordKeyPath, curValue); + set(fields, recordKeyPath as (number | string)[], curValue); } const data = isMapEditor ? set({}, namePath, fields, true) : fields; @@ -488,7 +488,7 @@ const CancelEditableAction: React.FC & { row: any }> = ( await cancelEditable(recordKey); /** 重置为默认值,不然编辑的行会丢掉 */ form.setFieldsValue({ - [recordKey as React.Key]: isMapEditor ? get(row, namePath) : row, + [`${recordKey as React.Key}`]: isMapEditor ? get(row, namePath) : row, }); return res; }} diff --git a/tests/list/index.test.tsx b/tests/list/index.test.tsx index 5dd04370e75e..9cf2971209d0 100644 --- a/tests/list/index.test.tsx +++ b/tests/list/index.test.tsx @@ -7,7 +7,7 @@ import { waitFor, } from '@testing-library/react'; import { Tag } from 'antd'; -import type { ReactText } from 'react'; +import type { Key } from 'react'; import { useState } from 'react'; import PaginationDemo from '../../packages/list/src/demos/pagination'; import { waitForWaitTime } from '../util'; @@ -184,9 +184,9 @@ describe('List', () => { it('🚏 expandable', async () => { const onExpand = vi.fn(); const Wrapper = () => { - const [expandedRowKeys, onExpandedRowsChange] = useState< - readonly ReactText[] - >([]); + const [expandedRowKeys, onExpandedRowsChange] = useState( + [], + ); return ( { it('🚏 expandable support expandRowByClick', async () => { const onExpand = vi.fn(); const Wrapper = () => { - const [expandedRowKeys, onExpandedRowsChange] = useState< - readonly ReactText[] - >([]); + const [expandedRowKeys, onExpandedRowsChange] = useState( + [], + ); return ( { it('🚏 expandable with expandedRowRender', async () => { const Wrapper = () => { - const [expandedRowKeys, onExpandedRowsChange] = useState< - readonly ReactText[] - >([]); + const [expandedRowKeys, onExpandedRowsChange] = useState( + [], + ); return ( Date: Thu, 21 Sep 2023 12:40:40 +0800 Subject: [PATCH 6/9] feat: update snapshot --- tests/form/__snapshots__/demo.test.ts.snap | 3 +- tests/layout/__snapshots__/demo.test.ts.snap | 201 ++++-------------- .../__snapshots__/pageContainer.test.tsx.snap | 3 +- 3 files changed, 40 insertions(+), 167 deletions(-) diff --git a/tests/form/__snapshots__/demo.test.ts.snap b/tests/form/__snapshots__/demo.test.ts.snap index d4fbacec85b6..3b31300116f8 100644 --- a/tests/form/__snapshots__/demo.test.ts.snap +++ b/tests/form/__snapshots__/demo.test.ts.snap @@ -47998,8 +47998,7 @@ exports[`form demos > 📸 renders ./packages/form/src/demos/layout-footer.tsx c class="ant-pro-grid-content-children" >
📸 renders ./packages/layout/src/components/PageContai >
📸 renders ./packages/layout/src/components/PageContai >
📸 renders ./packages/layout/src/components/PageContai >
📸 renders ./packages/layout/src/components/PageContai >
-
@@ -4279,8 +4193,7 @@ exports[`layout demos > 📸 renders ./packages/layout/src/demos/AlwaysDefaultOp class="ant-pro-grid-content-children" >
Hello World @@ -4581,8 +4494,7 @@ exports[`layout demos > 📸 renders ./packages/layout/src/demos/BreadcrumbsRepe class="ant-pro-grid-content-children" >
Hello World @@ -4825,8 +4737,7 @@ exports[`layout demos > 📸 renders ./packages/layout/src/demos/DefaultOpenAllM class="ant-pro-grid-content-children" >
Hello World @@ -5069,8 +4980,7 @@ exports[`layout demos > 📸 renders ./packages/layout/src/demos/IconFont.tsx co class="ant-pro-grid-content-children" >
Hello World @@ -5313,8 +5223,7 @@ exports[`layout demos > 📸 renders ./packages/layout/src/demos/MenuGroup.tsx c class="ant-pro-grid-content-children" >
Hello World @@ -5579,8 +5488,7 @@ exports[`layout demos > 📸 renders ./packages/layout/src/demos/MultipleMenuOne class="ant-pro-grid-content-children" >
Hello World @@ -5791,8 +5699,7 @@ exports[`layout demos > 📸 renders ./packages/layout/src/demos/Nested.tsx corr class="ant-pro-grid-content-children" >
Hello World @@ -6126,8 +6033,7 @@ exports[`layout demos > 📸 renders ./packages/layout/src/demos/TopmenuNested.t class="ant-pro-grid-content-children" >
Hello World @@ -6407,8 +6313,7 @@ exports[`layout demos > 📸 renders ./packages/layout/src/demos/antd@4MenuIconF class="ant-pro-grid-content-children" >
📸 renders ./packages/layout/src/demos/api.tsx correct class="ant-pro-grid-content-children" >
Hello World
@@ -8003,8 +7907,7 @@ exports[`layout demos > 📸 renders ./packages/layout/src/demos/background-cont class="ant-pro-grid-content-children" >
📸 renders ./packages/layout/src/demos/base.tsx correc class="ant-pro-grid-content-children" >
📸 renders ./packages/layout/src/demos/classicMode.tsx class="ant-pro-grid-content-children" >
📸 renders ./packages/layout/src/demos/collapsedShowTi class="ant-pro-grid-content-children" >
📸 renders ./packages/layout/src/demos/config-provider class="qixian-pro-grid-content-children" >
📸 renders ./packages/layout/src/demos/customSider.tsx class="ant-pro-grid-content-children" >
📸 renders ./packages/layout/src/demos/customize-colla class="ant-pro-grid-content-children" >
📸 renders ./packages/layout/src/demos/customizeMenu.t class="ant-pro-grid-content-children" >
Hello World
@@ -11430,8 +11326,7 @@ exports[`layout demos > 📸 renders ./packages/layout/src/demos/dark.tsx correc class="ant-pro-grid-content-children" >
📸 renders ./packages/layout/src/demos/debug-demo.tsx class="ant-pro-grid-content-children" >
📸 renders ./packages/layout/src/demos/designMenuCss.t class="ant-pro-grid-content-children" >
📸 renders ./packages/layout/src/demos/designSiderMenu class="ant-pro-grid-content-children" >
📸 renders ./packages/layout/src/demos/dynamic-setting style="position: relative;" >
📸 renders ./packages/layout/src/demos/dynamicMenu.tsx class="ant-pro-grid-content-children" >
当从服务器获取的菜单为空时隐藏Sider: @@ -14947,8 +14837,7 @@ exports[`layout demos > 📸 renders ./packages/layout/src/demos/footer.tsx corr class="ant-pro-grid-content-children" >
Hello World
@@ -15377,8 +15266,7 @@ exports[`layout demos > 📸 renders ./packages/layout/src/demos/footer-global-t class="ant-pro-grid-content-children" >
📸 renders ./packages/layout/src/demos/ghost.tsx corre class="ant-pro-grid-content-children" >
📸 renders ./packages/layout/src/demos/hideMenu.tsx co class="ant-pro-grid-content-children" >
Hello World
@@ -17410,7 +17296,6 @@ exports[`layout demos > 📸 renders ./packages/layout/src/demos/immersive-navig >
📸 renders ./packages/layout/src/demos/menu-group.tsx style="position: relative;" >
📸 renders ./packages/layout/src/demos/mixMode.tsx cor class="ant-pro-grid-content-children" >
📸 renders ./packages/layout/src/demos/pageSimplify.ts class="ant-pro-grid-content-children" >
📸 renders ./packages/layout/src/demos/searchMenu.tsx class="ant-pro-grid-content-children" >
Hello World @@ -19727,8 +19608,7 @@ exports[`layout demos > 📸 renders ./packages/layout/src/demos/siderMode.tsx c class="ant-pro-grid-content-children" >
📸 renders ./packages/layout/src/demos/siteMenu.tsx co class="ant-pro-grid-content-children" >
📸 renders ./packages/layout/src/demos/splitMenus.tsx class="ant-pro-grid-content-children" >
xxxx
@@ -21087,8 +20965,7 @@ exports[`layout demos > 📸 renders ./packages/layout/src/demos/theme.tsx corre class="ant-pro-grid-content-children" >
📸 renders ./packages/layout/src/demos/top-breadcrumb. class="ant-pro-grid-content-children" >
Hello World @@ -21767,8 +21643,7 @@ exports[`layout demos > 📸 renders ./packages/layout/src/demos/topMode.tsx cor class="ant-pro-grid-content-children" >
🐲 FooterToolbar should know width 1`] = ` class="ant-pro-grid-content-children" >