From 8c403172ae5b34a58200b0391bd78d1e4d47979a Mon Sep 17 00:00:00 2001 From: topiam Date: Fri, 12 Sep 2025 19:03:08 +0800 Subject: [PATCH 1/3] fix(form): ProFormUploadButton warning: TS2786 ProFormUploadButton cannot be used as a JSX component. --- src/form/components/UploadButton/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/form/components/UploadButton/index.tsx b/src/form/components/UploadButton/index.tsx index b5a8fd12f5d8..e3b1f23d62fb 100644 --- a/src/form/components/UploadButton/index.tsx +++ b/src/form/components/UploadButton/index.tsx @@ -168,7 +168,7 @@ const BaseProFormUploadButton: React.ForwardRefRenderFunction< }; const ProFormUploadButton = warpField?.( - React.forwardRef(BaseProFormUploadButton), + BaseProFormUploadButton, { getValueFromEvent: (value: { fileList: UploadProps['fileList'] }) => value.fileList, From 11209c5ed391472def838f218e5abcdd00e93771 Mon Sep 17 00:00:00 2001 From: topiam Date: Sat, 13 Sep 2025 00:59:35 +0800 Subject: [PATCH 2/3] fix(form): ProFormUploadButton warning: TS2786 ProFormUploadButton cannot be used as a JSX component. --- src/form/components/UploadButton/index.tsx | 168 +++++++++++---------- 1 file changed, 85 insertions(+), 83 deletions(-) diff --git a/src/form/components/UploadButton/index.tsx b/src/form/components/UploadButton/index.tsx index e3b1f23d62fb..9f0cc9296ee7 100644 --- a/src/form/components/UploadButton/index.tsx +++ b/src/form/components/UploadButton/index.tsx @@ -80,92 +80,94 @@ const getBase64 = (file: FileType): Promise => * * @param */ -const BaseProFormUploadButton: React.ForwardRefRenderFunction< - any, - ProFormUploadButtonProps -> = ( - { - fieldProps, - action, - accept, - listType, - title = '单击上传', - max, - icon = , - buttonProps, - disabled, - proFieldProps, - imageProps, - ...restProps - }, - ref, -) => { - const [previewOpen, setPreviewOpen] = useState(false); - const [previewImage, setPreviewImage] = useState(''); - const value = useMemo(() => { - return restProps.fileList ?? restProps.value; - }, [restProps.fileList, restProps.value]); - const handlePreview = async (file: UploadFile) => { - if (!file.url && !file.preview) { - file.preview = await getBase64(file.originFileObj as FileType); - } +const BaseProFormUploadButton: React.FC = + React.forwardRef( + ( + { + fieldProps, + action, + accept, + listType, + title = '单击上传', + max, + icon = , + buttonProps, + disabled, + proFieldProps, + imageProps, + ...restProps + }, + ref, + ) => { + const [previewOpen, setPreviewOpen] = useState(false); + const [previewImage, setPreviewImage] = useState(''); + const value = useMemo(() => { + return restProps.fileList ?? restProps.value; + }, [restProps.fileList, restProps.value]); + const handlePreview = async (file: UploadFile) => { + if (!file.url && !file.preview) { + file.preview = await getBase64(file.originFileObj as FileType); + } - setPreviewImage(file.url || (file.preview as string)); - setPreviewOpen(true); - }; - const modeContext = useContext(EditOrReadOnlyContext); - const mode = proFieldProps?.mode || modeContext.mode || 'edit'; + setPreviewImage(file.url || (file.preview as string)); + setPreviewOpen(true); + }; + const modeContext = useContext(EditOrReadOnlyContext); + const mode = proFieldProps?.mode || modeContext.mode || 'edit'; - // 如果配置了 max ,并且 超过了文件列表的大小,就不展示按钮 - const showUploadButton = - (max === undefined || !value || value?.length < max) && mode !== 'read'; - const isPictureCard = (listType ?? fieldProps?.listType) === 'picture-card'; - return ( - <> - { - fieldProps?.onChange?.(info); - }} - > - {showUploadButton && - (isPictureCard ? ( - - {icon} {title} - - ) : ( - - ))} - - {previewImage && ( - setPreviewOpen(open), - afterOpenChange: (open: boolean) => !open && setPreviewImage(''), - ...((imageProps?.preview as any) || {}), - }} - src={previewImage} - /> - )} - + // 如果配置了 max ,并且 超过了文件列表的大小,就不展示按钮 + const showUploadButton = + (max === undefined || !value || value?.length < max) && mode !== 'read'; + const isPictureCard = + (listType ?? fieldProps?.listType) === 'picture-card'; + return ( + <> + { + fieldProps?.onChange?.(info); + }} + > + {showUploadButton && + (isPictureCard ? ( + + {icon} {title} + + ) : ( + + ))} + + {previewImage && ( + setPreviewOpen(open), + afterOpenChange: (open: boolean) => + !open && setPreviewImage(''), + ...((imageProps?.preview as any) || {}), + }} + src={previewImage} + /> + )} + + ); + }, ); -}; const ProFormUploadButton = warpField?.( BaseProFormUploadButton, From 80c6f08db4d100de5647bc26d6f37426ff7c34c5 Mon Sep 17 00:00:00 2001 From: topiam Date: Mon, 15 Sep 2025 14:27:09 +0800 Subject: [PATCH 3/3] chore(deps): update pnpm-lock.yaml --- pnpm-lock.yaml | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 944ba9fd1d98..78848f16f937 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -177,10 +177,10 @@ importers: specifier: ^14.18.63 version: 14.18.63 '@types/react': - specifier: ^18.3.24 + specifier: ^18.0.38 version: 18.3.24 '@types/react-dom': - specifier: ^18.3.7 + specifier: ^18.0.11 version: 18.3.7(@types/react@18.3.24) '@types/react-helmet': specifier: ^6.1.11 @@ -2190,42 +2190,49 @@ packages: engines: {node: '>= 10'} cpu: [arm64] os: [linux] + libc: [glibc] '@napi-rs/nice-linux-arm64-musl@1.1.1': resolution: {integrity: sha512-+2Rzdb3nTIYZ0YJF43qf2twhqOCkiSrHx2Pg6DJaCPYhhaxbLcdlV8hCRMHghQ+EtZQWGNcS2xF4KxBhSGeutg==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] + libc: [musl] '@napi-rs/nice-linux-ppc64-gnu@1.1.1': resolution: {integrity: sha512-4FS8oc0GeHpwvv4tKciKkw3Y4jKsL7FRhaOeiPei0X9T4Jd619wHNe4xCLmN2EMgZoeGg+Q7GY7BsvwKpL22Tg==} engines: {node: '>= 10'} cpu: [ppc64] os: [linux] + libc: [glibc] '@napi-rs/nice-linux-riscv64-gnu@1.1.1': resolution: {integrity: sha512-HU0nw9uD4FO/oGCCk409tCi5IzIZpH2agE6nN4fqpwVlCn5BOq0MS1dXGjXaG17JaAvrlpV5ZeyZwSon10XOXw==} engines: {node: '>= 10'} cpu: [riscv64] os: [linux] + libc: [glibc] '@napi-rs/nice-linux-s390x-gnu@1.1.1': resolution: {integrity: sha512-2YqKJWWl24EwrX0DzCQgPLKQBxYDdBxOHot1KWEq7aY2uYeX+Uvtv4I8xFVVygJDgf6/92h9N3Y43WPx8+PAgQ==} engines: {node: '>= 10'} cpu: [s390x] os: [linux] + libc: [glibc] '@napi-rs/nice-linux-x64-gnu@1.1.1': resolution: {integrity: sha512-/gaNz3R92t+dcrfCw/96pDopcmec7oCcAQ3l/M+Zxr82KT4DljD37CpgrnXV+pJC263JkW572pdbP3hP+KjcIg==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [glibc] '@napi-rs/nice-linux-x64-musl@1.1.1': resolution: {integrity: sha512-xScCGnyj/oppsNPMnevsBe3pvNaoK7FGvMjT35riz9YdhB2WtTG47ZlbxtOLpjeO9SqqQ2J2igCmz6IJOD5JYw==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [musl] '@napi-rs/nice-openharmony-arm64@1.1.1': resolution: {integrity: sha512-6uJPRVwVCLDeoOaNyeiW0gp2kFIM4r7PL2MczdZQHkFi9gVlgm+Vn+V6nTWRcu856mJ2WjYJiumEajfSm7arPQ==} @@ -2460,36 +2467,42 @@ packages: engines: {node: '>= 10.0.0'} cpu: [arm] os: [linux] + libc: [glibc] '@parcel/watcher-linux-arm-musl@2.5.1': resolution: {integrity: sha512-6E+m/Mm1t1yhB8X412stiKFG3XykmgdIOqhjWj+VL8oHkKABfu/gjFj8DvLrYVHSBNC+/u5PeNrujiSQ1zwd1Q==} engines: {node: '>= 10.0.0'} cpu: [arm] os: [linux] + libc: [musl] '@parcel/watcher-linux-arm64-glibc@2.5.1': resolution: {integrity: sha512-LrGp+f02yU3BN9A+DGuY3v3bmnFUggAITBGriZHUREfNEzZh/GO06FF5u2kx8x+GBEUYfyTGamol4j3m9ANe8w==} engines: {node: '>= 10.0.0'} cpu: [arm64] os: [linux] + libc: [glibc] '@parcel/watcher-linux-arm64-musl@2.5.1': resolution: {integrity: sha512-cFOjABi92pMYRXS7AcQv9/M1YuKRw8SZniCDw0ssQb/noPkRzA+HBDkwmyOJYp5wXcsTrhxO0zq1U11cK9jsFg==} engines: {node: '>= 10.0.0'} cpu: [arm64] os: [linux] + libc: [musl] '@parcel/watcher-linux-x64-glibc@2.5.1': resolution: {integrity: sha512-GcESn8NZySmfwlTsIur+49yDqSny2IhPeZfXunQi48DMugKeZ7uy1FX83pO0X22sHntJ4Ub+9k34XQCX+oHt2A==} engines: {node: '>= 10.0.0'} cpu: [x64] os: [linux] + libc: [glibc] '@parcel/watcher-linux-x64-musl@2.5.1': resolution: {integrity: sha512-n0E2EQbatQ3bXhcH2D1XIAANAcTZkQICBPVaxMeaCVBtOpBZpWJuf7LwyWPSBDITb7In8mqQgJ7gH8CILCURXg==} engines: {node: '>= 10.0.0'} cpu: [x64] os: [linux] + libc: [musl] '@parcel/watcher-win32-arm64@2.5.1': resolution: {integrity: sha512-RFzklRvmc3PkjKjry3hLF9wD7ppR4AKcWNzH7kXR7GUe0Igb3Nz8fyPwtZCSquGrhU5HhUNDr/mKBqj7tqA2Vw==} @@ -2630,56 +2643,67 @@ packages: resolution: {integrity: sha512-u72Mzc6jyJwKjJbZZcIYmd9bumJu7KNmHYdue43vT1rXPm2rITwmPWF0mmPzLm9/vJWxIRbao/jrQmxTO0Sm9w==} cpu: [arm] os: [linux] + libc: [glibc] '@rollup/rollup-linux-arm-musleabihf@4.50.0': resolution: {integrity: sha512-S4UefYdV0tnynDJV1mdkNawp0E5Qm2MtSs330IyHgaccOFrwqsvgigUD29uT+B/70PDY1eQ3t40+xf6wIvXJyg==} cpu: [arm] os: [linux] + libc: [musl] '@rollup/rollup-linux-arm64-gnu@4.50.0': resolution: {integrity: sha512-1EhkSvUQXJsIhk4msxP5nNAUWoB4MFDHhtc4gAYvnqoHlaL9V3F37pNHabndawsfy/Tp7BPiy/aSa6XBYbaD1g==} cpu: [arm64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-arm64-musl@4.50.0': resolution: {integrity: sha512-EtBDIZuDtVg75xIPIK1l5vCXNNCIRM0OBPUG+tbApDuJAy9mKago6QxX+tfMzbCI6tXEhMuZuN1+CU8iDW+0UQ==} cpu: [arm64] os: [linux] + libc: [musl] '@rollup/rollup-linux-loongarch64-gnu@4.50.0': resolution: {integrity: sha512-BGYSwJdMP0hT5CCmljuSNx7+k+0upweM2M4YGfFBjnFSZMHOLYR0gEEj/dxyYJ6Zc6AiSeaBY8dWOa11GF/ppQ==} cpu: [loong64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-ppc64-gnu@4.50.0': resolution: {integrity: sha512-I1gSMzkVe1KzAxKAroCJL30hA4DqSi+wGc5gviD0y3IL/VkvcnAqwBf4RHXHyvH66YVHxpKO8ojrgc4SrWAnLg==} cpu: [ppc64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-riscv64-gnu@4.50.0': resolution: {integrity: sha512-bSbWlY3jZo7molh4tc5dKfeSxkqnf48UsLqYbUhnkdnfgZjgufLS/NTA8PcP/dnvct5CCdNkABJ56CbclMRYCA==} cpu: [riscv64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-riscv64-musl@4.50.0': resolution: {integrity: sha512-LSXSGumSURzEQLT2e4sFqFOv3LWZsEF8FK7AAv9zHZNDdMnUPYH3t8ZlaeYYZyTXnsob3htwTKeWtBIkPV27iQ==} cpu: [riscv64] os: [linux] + libc: [musl] '@rollup/rollup-linux-s390x-gnu@4.50.0': resolution: {integrity: sha512-CxRKyakfDrsLXiCyucVfVWVoaPA4oFSpPpDwlMcDFQvrv3XY6KEzMtMZrA+e/goC8xxp2WSOxHQubP8fPmmjOQ==} cpu: [s390x] os: [linux] + libc: [glibc] '@rollup/rollup-linux-x64-gnu@4.50.0': resolution: {integrity: sha512-8PrJJA7/VU8ToHVEPu14FzuSAqVKyo5gg/J8xUerMbyNkWkO9j2ExBho/68RnJsMGNJq4zH114iAttgm7BZVkA==} cpu: [x64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-x64-musl@4.50.0': resolution: {integrity: sha512-SkE6YQp+CzpyOrbw7Oc4MgXFvTw2UIBElvAvLCo230pyxOLmYwRPwZ/L5lBe/VW/qT1ZgND9wJfOsdy0XptRvw==} cpu: [x64] os: [linux] + libc: [musl] '@rollup/rollup-openharmony-arm64@4.50.0': resolution: {integrity: sha512-PZkNLPfvXeIOgJWA804zjSFH7fARBBCpCXxgkGDRjjAhRLOR8o0IGS01ykh5GYfod4c2yiiREuDM8iZ+pVsT+Q==} @@ -2883,24 +2907,28 @@ packages: engines: {node: '>=10'} cpu: [arm64] os: [linux] + libc: [glibc] '@swc/core-linux-arm64-musl@1.9.2': resolution: {integrity: sha512-8xzrOmsyCC1zrx2Wzx/h8dVsdewO1oMCwBTLc1gSJ/YllZYTb04pNm6NsVbzUX2tKddJVRgSJXV10j/NECLwpA==} engines: {node: '>=10'} cpu: [arm64] os: [linux] + libc: [musl] '@swc/core-linux-x64-gnu@1.9.2': resolution: {integrity: sha512-kZrNz/PjRQKcchWF6W292jk3K44EoVu1ad5w+zbS4jekIAxsM8WwQ1kd+yjUlN9jFcF8XBat5NKIs9WphJCVXg==} engines: {node: '>=10'} cpu: [x64] os: [linux] + libc: [glibc] '@swc/core-linux-x64-musl@1.9.2': resolution: {integrity: sha512-TTIpR4rjMkhX1lnFR+PSXpaL83TrQzp9znRdp2TzYrODlUd/R20zOwSo9vFLCyH6ZoD47bccY7QeGZDYT3nlRg==} engines: {node: '>=10'} cpu: [x64] os: [linux] + libc: [musl] '@swc/core-win32-arm64-msvc@1.9.2': resolution: {integrity: sha512-+Eg2d4icItKC0PMjZxH7cSYFLWk0aIp94LNmOw6tPq0e69ax6oh10upeq0D1fjWsKLmOJAWEvnXlayZcijEXDw==} @@ -3446,24 +3474,28 @@ packages: engines: {node: '>= 10'} cpu: [arm64] os: [linux] + libc: [glibc] '@umijs/es-module-parser-linux-arm64-musl@0.0.7': resolution: {integrity: sha512-cqQffARWkmQ3n1RYNKZR3aD6X8YaP6u1maASjDgPQOpZMAlv/OSDrM/7iGujWTs0PD0haockNG9/DcP6lgPHMw==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] + libc: [musl] '@umijs/es-module-parser-linux-x64-gnu@0.0.7': resolution: {integrity: sha512-PHrKHtT665Za0Ydjch4ACrNpRU+WIIden12YyF1CtMdhuLDSoU6UfdhF3NoDbgEUcXVDX/ftOqmj0SbH3R1uew==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [glibc] '@umijs/es-module-parser-linux-x64-musl@0.0.7': resolution: {integrity: sha512-cyZvUK5lcECLWzLp/eU1lFlCETcz+LEb+wrdARQSST1dgoIGZsT4cqM1WzYmdZNk3o883tiZizLt58SieEiHBQ==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [musl] '@umijs/es-module-parser-win32-arm64-msvc@0.0.7': resolution: {integrity: sha512-V7WxnUI88RboSl0RWLNQeKBT7EDW35fW6Tn92zqtoHHxrhAIL9DtDyvC8REP4qTxeZ6Oej/Ax5I6IjsLx3yTOg==} @@ -3504,24 +3536,28 @@ packages: engines: {node: '>= 10'} cpu: [arm64] os: [linux] + libc: [glibc] '@umijs/mako-linux-arm64-musl@0.11.10': resolution: {integrity: sha512-kqI1Jw6IHtDwrcsqPZrYxsV3pHzZyOR+6fCFnF5MSURnXbUbJb6Rk66VsKKpMqbyfsEO6nt0WT9FrRBlFvRU2A==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] + libc: [musl] '@umijs/mako-linux-x64-gnu@0.11.10': resolution: {integrity: sha512-jlhXVvWJuumMmiE3z3ViugOMx9ZasNM1anng0PsusCgDwfy0IOfGzfwfwagqtzfsC5MwyRcfnRQyDdbfbroaSA==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [glibc] '@umijs/mako-linux-x64-musl@0.11.10': resolution: {integrity: sha512-SLV/PRdL12dFEKlQGenW3OboZXmdYi25y+JblgVJLBhpdxZrHFqpCsTZn4L3hVEhyl0/ksR1iY0wtfK3urR29g==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [musl] '@umijs/mako-win32-ia32-msvc@0.11.10': resolution: {integrity: sha512-quCWpVl7yQjG+ccGhkF81GxO3orXdPW1OZWXWxJgOI0uPk7Hczh2EYMEVqqQGbi/83eJ1e3iE1jRTl/+2eHryQ==} @@ -3642,24 +3678,28 @@ packages: engines: {node: '>= 10'} cpu: [arm64] os: [linux] + libc: [glibc] '@utoo/pack-linux-arm64-musl@0.0.1-alpha.39': resolution: {integrity: sha512-3Ud5MBOYbOlzdOaCEQOUJA+sDvVjvRKVi4U1vEiiVA4vUvkh6bdZ35M/a4nqPgihgYWo1Ov86lzwA70C8rnO2w==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] + libc: [musl] '@utoo/pack-linux-x64-gnu@0.0.1-alpha.39': resolution: {integrity: sha512-DcAkBPmJgfnsVVzkmCYWS66bgsy8oElUDX2b9Pkqi78bQARs7QFTpiu76toxJynAWkFiOOJ+41xYo3ZtepWGog==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [glibc] '@utoo/pack-linux-x64-musl@0.0.1-alpha.39': resolution: {integrity: sha512-qdomM9Ri8qIIttRUF6VL6JxATgqz+CsYM4bXJt57r8lrb6MaeolKMxz/Gyrh/S1ufcPiMBn3qlw6RTnIZKU69g==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [musl] '@utoo/pack-win32-x64-msvc@0.0.1-alpha.39': resolution: {integrity: sha512-RIThSCgu+c87DnPcievPRn+cpNsh/O7sPpdZqtuWj5v7L3N8wBf6hE/vaetzlRWTsdb03eTpzLUMyJCDumD6Ig==} @@ -7285,24 +7325,28 @@ packages: engines: {node: '>= 12.0.0'} cpu: [arm64] os: [linux] + libc: [glibc] lightningcss-linux-arm64-musl@1.22.1: resolution: {integrity: sha512-MCV6RuRpzXbunvzwY644iz8cw4oQxvW7oer9xPkdadYqlEyiJJ6wl7FyJOH7Q6ZYH4yjGAUCvxDBxPbnDu9ZVg==} engines: {node: '>= 12.0.0'} cpu: [arm64] os: [linux] + libc: [musl] lightningcss-linux-x64-gnu@1.22.1: resolution: {integrity: sha512-RjNgpdM20VUXgV7us/VmlO3Vn2ZRiDnc3/bUxCVvySZWPiVPprpqW/QDWuzkGa+NCUf6saAM5CLsZLSxncXJwg==} engines: {node: '>= 12.0.0'} cpu: [x64] os: [linux] + libc: [glibc] lightningcss-linux-x64-musl@1.22.1: resolution: {integrity: sha512-ZgO4C7Rd6Hv/5MnyY2KxOYmIlzk4rplVolDt3NbkNR8DndnyX0Q5IR4acJWNTBICQ21j3zySzKbcJaiJpk/4YA==} engines: {node: '>= 12.0.0'} cpu: [x64] os: [linux] + libc: [musl] lightningcss-win32-x64-msvc@1.22.1: resolution: {integrity: sha512-4pozV4eyD0MDET41ZLHAeBo+H04Nm2UEYIk5w/ts40231dRFV7E0cjwbnZvSoc1DXFgecAhiC0L16ruv/ZDCpg==}