From fe9adbf0a59f513a58075bbb7c18dbeb28ca15e4 Mon Sep 17 00:00:00 2001 From: chanx <1243304602@qq.com> Date: Fri, 29 Aug 2025 10:57:29 +0800 Subject: [PATCH] Fix: Optimized Input and MultiSelect component functionality and dataSet-chunk page styling #9779 (#9815) ### What problem does this PR solve? Fix: Optimized Input and MultiSelect component functionality and dataSet-chunk page styling - Updated @js-preview/excel to version 1.7.14 #9779 - Optimized the EditTag component - Updated the Input component to optimize numeric input processing - Adjusted the MultiSelect component to use lodash's isEmpty method - Optimized the CheckboxSets component to display action buttons based on the selected state ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- web/package-lock.json | 9 +- web/package.json | 2 +- web/src/components/edit-tag/index.tsx | 217 +++++++++--------- .../raptor-form-fields.tsx | 6 +- web/src/components/ui/input.tsx | 24 +- web/src/components/ui/multi-select.tsx | 9 +- .../chunk-result-bar/checkbox-sets.tsx | 67 +++--- .../components/knowledge-chunk/index.tsx | 3 +- 8 files changed, 188 insertions(+), 149 deletions(-) diff --git a/web/package-lock.json b/web/package-lock.json index 6a643d64b..b4b3ea2d2 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -12,7 +12,7 @@ "@antv/g2": "^5.2.10", "@antv/g6": "^5.0.10", "@hookform/resolvers": "^3.9.1", - "@js-preview/excel": "^1.7.8", + "@js-preview/excel": "^1.7.14", "@lexical/react": "^0.23.1", "@monaco-editor/react": "^4.6.0", "@radix-ui/react-accordion": "^1.2.3", @@ -4114,9 +4114,10 @@ } }, "node_modules/@js-preview/excel": { - "version": "1.7.8", - "resolved": "https://registry.npmmirror.com/@js-preview/excel/-/excel-1.7.8.tgz", - "integrity": "sha512-pLJTDIhbzqaiH3kUPnbeWLsBFeCAHjnBwloMvoREdW4YUYTcsHDQ5h41QTyRJWSYRJBCcsy6Kt7KeDHOHDbVEw==" + "version": "1.7.14", + "resolved": "https://registry.npmmirror.com/@js-preview/excel/-/excel-1.7.14.tgz", + "integrity": "sha512-7QHtuRalWQzWIKARc/IRN8+kj1S5eWV4+cAQipzZngE3mVxMPL1RHXKJt/ONmpcKZ410egYkaBuOOs9+LctBkA==", + "license": "MIT" }, "node_modules/@lexical/clipboard": { "version": "0.23.1", diff --git a/web/package.json b/web/package.json index 2ef31b171..ce028bfb5 100644 --- a/web/package.json +++ b/web/package.json @@ -23,7 +23,7 @@ "@antv/g2": "^5.2.10", "@antv/g6": "^5.0.10", "@hookform/resolvers": "^3.9.1", - "@js-preview/excel": "^1.7.8", + "@js-preview/excel": "^1.7.14", "@lexical/react": "^0.23.1", "@monaco-editor/react": "^4.6.0", "@radix-ui/react-accordion": "^1.2.3", diff --git a/web/src/components/edit-tag/index.tsx b/web/src/components/edit-tag/index.tsx index 94013ceac..e867185d8 100644 --- a/web/src/components/edit-tag/index.tsx +++ b/web/src/components/edit-tag/index.tsx @@ -15,123 +15,122 @@ interface EditTagsProps { onChange?: (tags: string[]) => void; } -const EditTag = ({ value = [], onChange }: EditTagsProps) => { - const [inputVisible, setInputVisible] = useState(false); - const [inputValue, setInputValue] = useState(''); - const inputRef = useRef(null); +const EditTag = React.forwardRef( + ({ value = [], onChange }: EditTagsProps, ref) => { + const [inputVisible, setInputVisible] = useState(false); + const [inputValue, setInputValue] = useState(''); + const inputRef = useRef(null); - useEffect(() => { - if (inputVisible) { - inputRef.current?.focus(); - } - }, [inputVisible]); + useEffect(() => { + if (inputVisible) { + inputRef.current?.focus(); + } + }, [inputVisible]); - const handleClose = (removedTag: string) => { - const newTags = value?.filter((tag) => tag !== removedTag); - onChange?.(newTags ?? []); - }; + const handleClose = (removedTag: string) => { + const newTags = value?.filter((tag) => tag !== removedTag); + onChange?.(newTags ?? []); + }; - const showInput = () => { - setInputVisible(true); - }; + const showInput = () => { + setInputVisible(true); + }; - const handleInputChange = (e: React.ChangeEvent) => { - setInputValue(e.target.value); - }; + const handleInputChange = (e: React.ChangeEvent) => { + setInputValue(e.target.value); + }; - const handleInputConfirm = () => { - if (inputValue && value) { - const newTags = inputValue - .split(';') - .map((tag) => tag.trim()) - .filter((tag) => tag && !value.includes(tag)); - onChange?.([...value, ...newTags]); - } - setInputVisible(false); - setInputValue(''); - }; + const handleInputConfirm = () => { + if (inputValue && value) { + const newTags = inputValue + .split(';') + .map((tag) => tag.trim()) + .filter((tag) => tag && !value.includes(tag)); + onChange?.([...value, ...newTags]); + } + setInputVisible(false); + setInputValue(''); + }; - const forMap = (tag: string) => { - return ( - - {tag} - -
-
-
- {tag} + const forMap = (tag: string) => { + return ( + + {tag} + +
+
+
+ {tag} +
+ { + e.preventDefault(); + handleClose(tag); + }} + />
- { - e.preventDefault(); - handleClose(tag); - }} - />
-
- - + + + ); + }; + + const tagChild = value?.map(forMap); + + const tagPlusStyle: React.CSSProperties = { + borderStyle: 'dashed', + }; + + return ( +
+ {inputVisible ? ( + { + if (e?.key === 'Enter') { + handleInputConfirm(); + } + }} + /> + ) : ( + + )} + {Array.isArray(tagChild) && tagChild.length > 0 && ( + { + if (e.type === 'appear' || e.type === 'enter') { + (e.target as any).style = 'display: inline-block'; + } + }} + leave={{ opacity: 0, width: 0, scale: 0, duration: 200 }} + appear={false} + > + {tagChild} + + )} +
); - }; - - const tagChild = value?.map(forMap); - - const tagPlusStyle: React.CSSProperties = { - borderStyle: 'dashed', - }; - - return ( -
- {inputVisible ? ( - { - if (e?.key === 'Enter') { - handleInputConfirm(); - } - }} - /> - ) : ( - - )} - {Array.isArray(tagChild) && tagChild.length > 0 && ( - { - if (e.type === 'appear' || e.type === 'enter') { - (e.target as any).style = 'display: inline-block'; - } - }} - leave={{ opacity: 0, width: 0, scale: 0, duration: 200 }} - appear={false} - > - {tagChild} - - )} -
- ); -}; + }, +); export default EditTag; diff --git a/web/src/components/parse-configuration/raptor-form-fields.tsx b/web/src/components/parse-configuration/raptor-form-fields.tsx index 143ecbcc5..fdab905d4 100644 --- a/web/src/components/parse-configuration/raptor-form-fields.tsx +++ b/web/src/components/parse-configuration/raptor-form-fields.tsx @@ -183,13 +183,13 @@ const RaptorFormFields = () => { render={({ field }) => (
- + {t('randomSeed')}
-
- +
+