From 5c73e15044f0b556fd72a307e5e9a6abf9c4cd9e Mon Sep 17 00:00:00 2001 From: TheoryOfNekomata Date: Mon, 24 Jul 2023 12:30:42 +0800 Subject: [PATCH] Update multiple file uploads Implement view for multiple file uploads. --- categories/blob/react/.eslintrc | 5 ++ .../src/components/FileSelectBox/index.tsx | 79 +++++++++++-------- .../src/pages/categories/blob/index.tsx | 14 ++++ 3 files changed, 64 insertions(+), 34 deletions(-) diff --git a/categories/blob/react/.eslintrc b/categories/blob/react/.eslintrc index 7d22244..edad3d1 100644 --- a/categories/blob/react/.eslintrc +++ b/categories/blob/react/.eslintrc @@ -1,5 +1,10 @@ { "root": true, + "rules": { + "quote-props": "off", + "react/jsx-props-no-spreading": "off", + "import/no-extraneous-dependencies": "off" + }, "extends": [ "lxsmnsyc/typescript/react" ], diff --git a/categories/blob/react/src/components/FileSelectBox/index.tsx b/categories/blob/react/src/components/FileSelectBox/index.tsx index 6fb57b1..2d4ad3f 100644 --- a/categories/blob/react/src/components/FileSelectBox/index.tsx +++ b/categories/blob/react/src/components/FileSelectBox/index.tsx @@ -227,7 +227,7 @@ export const FileSelectBox = React.forwardRef = React.useCallback(() => { setAboutToSelect(true); setTimeout(() => { @@ -236,6 +236,13 @@ export const FileSelectBox = React.forwardRef = React.useCallback(() => { + const fileInput = defaultRef.current as FileSelectBoxDerivedElement; + fileInput.showPicker(); + }, [defaultRef]); + const handleDeleteMouseDown: React.MouseEventHandler< HTMLButtonElement > = React.useCallback(() => { @@ -256,7 +263,7 @@ export const FileSelectBox = React.forwardRef { window.removeEventListener('mouseup', handleLabelMouseUp, { capture: true }); }; - }, []); + }, [defaultRef, aboutToSelect]); return (
- {clientSide && ( + {label && ( + )} + {clientSide && ( + )} - {label && ( -
-
- {label} -
-
- )} {filesCount < 1 && clientSide && hint @@ -355,13 +364,13 @@ export const FileSelectBox = React.forwardRef {multiple && ( -
-
- {Array.from(fileList ?? []).map((file, i) => ( +
+
+ {Array.from(fileList ?? []).map((file) => (
)} {!multiple - && Array.from(fileList ?? []).map((file, i) => ( + && Array.from(fileList ?? []).map((file) => (
- +