From 6f922df227756fc45d0fcc5f60a4ea8b0c942517 Mon Sep 17 00:00:00 2001 From: Ivan <8611739+IRBorisov@users.noreply.github.com> Date: Fri, 13 Dec 2024 21:30:49 +0300 Subject: [PATCH] R: Remove unused useMemo and useCallback --- .../src/components/RSInput/RSInput.tsx | 162 +++++----- .../src/components/RefsInput/RefsInput.tsx | 145 ++++----- .../src/components/info/TooltipOperation.tsx | 75 ++--- .../components/select/PickConstituenta.tsx | 48 ++- .../select/PickMultiConstituenta.tsx | 36 +-- .../components/select/PickMultiOperation.tsx | 178 +++++------ .../src/components/select/PickSchema.tsx | 100 +++--- .../components/select/PickSubstitutions.tsx | 293 ++++++++---------- .../components/select/SelectConstituenta.tsx | 25 +- .../components/select/SelectLibraryItem.tsx | 25 +- .../src/components/select/SelectLocation.tsx | 51 ++- .../src/components/select/SelectOperation.tsx | 25 +- .../src/components/select/SelectUser.tsx | 25 +- .../src/components/select/SelectVersion.tsx | 28 +- .../frontend/src/components/ui/Checkbox.tsx | 11 +- .../src/components/ui/CheckboxTristate.tsx | 11 +- .../src/components/ui/PDFViewer/PDFViewer.tsx | 8 +- .../src/components/ui/SelectMulti.tsx | 98 +++--- .../src/components/ui/SelectSingle.tsx | 92 +++--- .../frontend/src/components/ui/SelectTree.tsx | 64 ++-- .../frontend/src/components/ui/ValueIcon.tsx | 4 +- .../src/dialogs/DlgChangeInputSchema.tsx | 18 +- .../src/dialogs/DlgChangeLocation.tsx | 10 +- .../src/dialogs/DlgCloneLibraryItem.tsx | 10 +- .../DlgConstituentaTemplate.tsx | 47 +-- .../DlgConstituentaTemplate/TabArguments.tsx | 165 +++++----- .../DlgConstituentaTemplate/TabTemplate.tsx | 45 +-- .../dialogs/DlgCreateCst/FormCreateCst.tsx | 15 +- .../DlgCreateOperation/DlgCreateOperation.tsx | 102 +++--- .../DlgCreateOperation/TabInputOperation.tsx | 9 +- .../frontend/src/dialogs/DlgCreateVersion.tsx | 6 +- .../src/dialogs/DlgDeleteCst/DlgDeleteCst.tsx | 11 +- .../dialogs/DlgEditEditors/DlgEditEditors.tsx | 19 +- .../src/dialogs/DlgEditEditors/TableUsers.tsx | 59 ++-- .../DlgEditOperation/DlgEditOperation.tsx | 129 +++----- .../dialogs/DlgEditOperation/TabArguments.tsx | 9 +- .../DlgEditReference/DlgEditReference.tsx | 44 +-- .../TabSyntacticReference.tsx | 6 +- .../DlgEditVersions/DlgEditVersions.tsx | 39 +-- .../dialogs/DlgEditVersions/TableVersions.tsx | 113 ++++--- .../DlgEditWordForms/TableWordForms.tsx | 85 +++-- .../DlgInlineSynthesis/DlgInlineSynthesis.tsx | 67 ++-- .../dialogs/DlgInlineSynthesis/TabSchema.tsx | 6 +- .../DlgInlineSynthesis/TabSubstitutions.tsx | 13 +- .../src/dialogs/DlgRelocateConstituents.tsx | 32 +- .../src/dialogs/DlgShowAST/DlgShowAST.tsx | 12 +- .../src/dialogs/DlgShowAST/graph/ASTNode.tsx | 3 +- .../DlgShowTypeGraph/DlgShowTypeGraph.tsx | 5 +- .../DlgShowTypeGraph/graph/MGraphNode.tsx | 10 +- .../frontend/src/dialogs/DlgSubstituteCst.tsx | 5 +- .../pages/CreateItemPage/FormCreateItem.tsx | 6 +- .../frontend/src/pages/DatabaseSchemaPage.tsx | 4 +- .../src/pages/LibraryPage/LibraryPage.tsx | 93 ++---- .../pages/LibraryPage/TableLibraryItems.tsx | 183 ++++++----- .../src/pages/LibraryPage/ToolbarSearch.tsx | 38 +-- .../pages/LibraryPage/ViewSideLocation.tsx | 34 +- .../pages/ManualsPage/items/HelpRSLang.tsx | 6 +- .../EditorOssGraph/NodeContextMenu.tsx | 6 +- .../pages/OssPage/EditorOssGraph/OssFlow.tsx | 261 ++++++---------- .../EditorOssGraph/ToolbarOssGraph.tsx | 10 +- .../frontend/src/pages/OssPage/OssTabs.tsx | 64 ++-- .../frontend/src/pages/PasswordChangePage.tsx | 15 +- .../EditorConstituenta/EditorConstituenta.tsx | 10 +- .../EditorConstituenta/FormConstituenta.tsx | 29 +- .../EditorRSExpression/EditorRSExpression.tsx | 27 +- .../EditorRSExpression/StatusBar.tsx | 5 +- .../EditorRSFormCard/ToolbarItemAccess.tsx | 7 +- .../EditorRSFormCard/ToolbarRSFormCard.tsx | 8 +- .../RSFormPage/EditorRSList/EditorRSList.tsx | 8 +- .../RSFormPage/EditorRSList/TableRSList.tsx | 139 ++++----- .../EditorTermGraph/SchemasGuide.tsx | 6 +- .../RSFormPage/EditorTermGraph/TGFlow.tsx | 167 ++++------ .../RSFormPage/EditorTermGraph/ViewHidden.tsx | 20 +- .../EditorTermGraph/graph/TGNode.tsx | 6 +- .../EditorTermGraph/useGraphFilter.ts | 6 +- .../frontend/src/pages/RSFormPage/RSTabs.tsx | 191 +++++------- .../ViewConstituents/ConstituentsSearch.tsx | 16 +- .../TableSideConstituents.tsx | 125 ++++---- .../ViewConstituents/ViewConstituents.tsx | 31 +- .../src/pages/RegisterPage/FormSignup.tsx | 7 +- .../pages/UserProfilePage/EditorPassword.tsx | 15 +- .../pages/UserProfilePage/EditorProfile.tsx | 11 +- 82 files changed, 1736 insertions(+), 2416 deletions(-) diff --git a/rsconcept/frontend/src/components/RSInput/RSInput.tsx b/rsconcept/frontend/src/components/RSInput/RSInput.tsx index c49a72fe..c67fef37 100644 --- a/rsconcept/frontend/src/components/RSInput/RSInput.tsx +++ b/rsconcept/frontend/src/components/RSInput/RSInput.tsx @@ -6,7 +6,7 @@ import { createTheme } from '@uiw/codemirror-themes'; import CodeMirror, { BasicSetupOptions, ReactCodeMirrorProps, ReactCodeMirrorRef } from '@uiw/react-codemirror'; import clsx from 'clsx'; import { EditorView } from 'codemirror'; -import { forwardRef, useCallback, useMemo, useRef } from 'react'; +import { forwardRef, useRef } from 'react'; import Label from '@/components/ui/Label'; import { useConceptOptions } from '@/context/ConceptOptionsContext'; @@ -66,102 +66,92 @@ const RSInput = forwardRef( const { darkMode, colors } = useConceptOptions(); const internalRef = useRef(null); - const thisRef = useMemo(() => (!ref || typeof ref === 'function' ? internalRef : ref), [internalRef, ref]); + const thisRef = !ref || typeof ref === 'function' ? internalRef : ref; - const cursor = useMemo(() => (!disabled ? 'cursor-text' : 'cursor-default'), [disabled]); - const customTheme: Extension = useMemo( - () => - createTheme({ - theme: darkMode ? 'dark' : 'light', - settings: { - fontFamily: 'inherit', - background: !disabled ? colors.bgInput : colors.bgDefault, - foreground: colors.fgDefault, - selection: colors.bgHover, - caret: colors.fgDefault - }, - styles: [ - { tag: tags.name, color: colors.fgPurple, cursor: schema ? 'default' : cursor }, // GlobalID - { tag: tags.variableName, color: colors.fgGreen }, // LocalID - { tag: tags.propertyName, color: colors.fgTeal }, // Radical - { tag: tags.keyword, color: colors.fgBlue }, // keywords - { tag: tags.literal, color: colors.fgBlue }, // literals - { tag: tags.controlKeyword, fontWeight: '400' }, // R | I | D - { tag: tags.unit, fontSize: '0.75rem' }, // indices - { tag: tags.brace, color: colors.fgPurple, fontWeight: '600' } // braces (curly brackets) - ] - }), - [disabled, colors, darkMode, schema, cursor] - ); + const cursor = !disabled ? 'cursor-text' : 'cursor-default'; + const customTheme: Extension = createTheme({ + theme: darkMode ? 'dark' : 'light', + settings: { + fontFamily: 'inherit', + background: !disabled ? colors.bgInput : colors.bgDefault, + foreground: colors.fgDefault, + selection: colors.bgHover, + caret: colors.fgDefault + }, + styles: [ + { tag: tags.name, color: colors.fgPurple, cursor: schema ? 'default' : cursor }, // GlobalID + { tag: tags.variableName, color: colors.fgGreen }, // LocalID + { tag: tags.propertyName, color: colors.fgTeal }, // Radical + { tag: tags.keyword, color: colors.fgBlue }, // keywords + { tag: tags.literal, color: colors.fgBlue }, // literals + { tag: tags.controlKeyword, fontWeight: '400' }, // R | I | D + { tag: tags.unit, fontSize: '0.75rem' }, // indices + { tag: tags.brace, color: colors.fgPurple, fontWeight: '600' } // braces (curly brackets) + ] + }); - const editorExtensions = useMemo( - () => [ - EditorView.lineWrapping, - RSLanguage, - ccBracketMatching(darkMode), - ...(!schema || !onOpenEdit ? [] : [rsNavigation(schema, onOpenEdit)]), - ...(noTooltip || !schema ? [] : [rsHoverTooltip(schema, onOpenEdit !== undefined)]) - ], - [darkMode, schema, noTooltip, onOpenEdit] - ); + const editorExtensions = [ + EditorView.lineWrapping, + RSLanguage, + ccBracketMatching(darkMode), + ...(!schema || !onOpenEdit ? [] : [rsNavigation(schema, onOpenEdit)]), + ...(noTooltip || !schema ? [] : [rsHoverTooltip(schema, onOpenEdit !== undefined)]) + ]; - const handleInput = useCallback( - (event: React.KeyboardEvent) => { - if (!thisRef.current) { + function handleInput(event: React.KeyboardEvent) { + if (!thisRef.current) { + return; + } + const text = new RSTextWrapper(thisRef.current as Required); + if ((event.ctrlKey || event.metaKey) && event.code === 'Space') { + const selection = text.getSelection(); + if (!selection.empty || !schema) { return; } - const text = new RSTextWrapper(thisRef.current as Required); - if ((event.ctrlKey || event.metaKey) && event.code === 'Space') { - const selection = text.getSelection(); - if (!selection.empty || !schema) { + const wordRange = text.getWord(selection.from); + if (wordRange) { + const word = text.getText(wordRange.from, wordRange.to); + if (word.length > 2 && (word.startsWith('Pr') || word.startsWith('pr'))) { + text.setSelection(wordRange.from, wordRange.from + 2); + if (word.startsWith('Pr')) { + text.replaceWith('pr'); + } else { + text.replaceWith('Pr'); + } + event.preventDefault(); + event.stopPropagation(); return; } - const wordRange = text.getWord(selection.from); - if (wordRange) { - const word = text.getText(wordRange.from, wordRange.to); - if (word.length > 2 && (word.startsWith('Pr') || word.startsWith('pr'))) { - text.setSelection(wordRange.from, wordRange.from + 2); - if (word.startsWith('Pr')) { - text.replaceWith('pr'); - } else { - text.replaceWith('Pr'); - } - event.preventDefault(); - event.stopPropagation(); - return; - } - } + } - const hint = text.getText(selection.from - 1, selection.from); - const type = guessCstType(hint); - if (hint === getCstTypePrefix(type)) { - text.setSelection(selection.from - 1, selection.from); - } - const takenAliases = [...extractGlobals(thisRef.current.view?.state.doc.toString() ?? '')]; - const newAlias = generateAlias(type, schema, takenAliases); - text.replaceWith(newAlias); - event.preventDefault(); - event.stopPropagation(); - } else if (event.altKey) { - if (text.processAltKey(event.code, event.shiftKey)) { - event.preventDefault(); - event.stopPropagation(); - } - } else if (!(event.ctrlKey || event.metaKey)) { - const newSymbol = getSymbolSubstitute(event.code, event.shiftKey); - if (newSymbol) { - text.replaceWith(newSymbol); - event.preventDefault(); - event.stopPropagation(); - } - } else if (event.code === 'KeyQ' && onAnalyze) { - onAnalyze(); + const hint = text.getText(selection.from - 1, selection.from); + const type = guessCstType(hint); + if (hint === getCstTypePrefix(type)) { + text.setSelection(selection.from - 1, selection.from); + } + const takenAliases = [...extractGlobals(thisRef.current.view?.state.doc.toString() ?? '')]; + const newAlias = generateAlias(type, schema, takenAliases); + text.replaceWith(newAlias); + event.preventDefault(); + event.stopPropagation(); + } else if (event.altKey) { + if (text.processAltKey(event.code, event.shiftKey)) { event.preventDefault(); event.stopPropagation(); } - }, - [thisRef, onAnalyze, schema] - ); + } else if (!(event.ctrlKey || event.metaKey)) { + const newSymbol = getSymbolSubstitute(event.code, event.shiftKey); + if (newSymbol) { + text.replaceWith(newSymbol); + event.preventDefault(); + event.stopPropagation(); + } + } else if (event.code === 'KeyQ' && onAnalyze) { + onAnalyze(); + event.preventDefault(); + event.stopPropagation(); + } + } return (
diff --git a/rsconcept/frontend/src/components/RefsInput/RefsInput.tsx b/rsconcept/frontend/src/components/RefsInput/RefsInput.tsx index 505bf04d..78a10c74 100644 --- a/rsconcept/frontend/src/components/RefsInput/RefsInput.tsx +++ b/rsconcept/frontend/src/components/RefsInput/RefsInput.tsx @@ -6,7 +6,7 @@ import { createTheme } from '@uiw/codemirror-themes'; import CodeMirror, { BasicSetupOptions, ReactCodeMirrorProps, ReactCodeMirrorRef } from '@uiw/react-codemirror'; import clsx from 'clsx'; import { EditorView } from 'codemirror'; -import { forwardRef, useCallback, useMemo, useRef, useState } from 'react'; +import { forwardRef, useRef, useState } from 'react'; import Label from '@/components/ui/Label'; import { useConceptOptions } from '@/context/ConceptOptionsContext'; @@ -103,39 +103,32 @@ const RefsInput = forwardRef( const [mainRefs, setMainRefs] = useState([]); const internalRef = useRef(null); - const thisRef = useMemo(() => (!ref || typeof ref === 'function' ? internalRef : ref), [internalRef, ref]); + const thisRef = !ref || typeof ref === 'function' ? internalRef : ref; - const cursor = useMemo(() => (!disabled ? 'cursor-text' : 'cursor-default'), [disabled]); - const customTheme: Extension = useMemo( - () => - createTheme({ - theme: darkMode ? 'dark' : 'light', - settings: { - fontFamily: 'inherit', - background: !disabled ? colors.bgInput : colors.bgDefault, - foreground: colors.fgDefault, - selection: colors.bgHover, - caret: colors.fgDefault - }, - styles: [ - { tag: tags.name, color: colors.fgPurple, cursor: 'default' }, // EntityReference - { tag: tags.literal, color: colors.fgTeal, cursor: 'default' }, // SyntacticReference - { tag: tags.comment, color: colors.fgRed } // Error - ] - }), - [disabled, colors, darkMode] - ); + const cursor = !disabled ? 'cursor-text' : 'cursor-default'; + const customTheme: Extension = createTheme({ + theme: darkMode ? 'dark' : 'light', + settings: { + fontFamily: 'inherit', + background: !disabled ? colors.bgInput : colors.bgDefault, + foreground: colors.fgDefault, + selection: colors.bgHover, + caret: colors.fgDefault + }, + styles: [ + { tag: tags.name, color: colors.fgPurple, cursor: 'default' }, // EntityReference + { tag: tags.literal, color: colors.fgTeal, cursor: 'default' }, // SyntacticReference + { tag: tags.comment, color: colors.fgRed } // Error + ] + }); - const editorExtensions = useMemo( - () => [ - EditorView.lineWrapping, - EditorView.contentAttributes.of({ spellcheck: 'true' }), - NaturalLanguage, - ...(!schema || !onOpenEdit ? [] : [refsNavigation(schema, onOpenEdit)]), - ...(schema ? [refsHoverTooltip(schema, colors, onOpenEdit !== undefined)] : []) - ], - [schema, colors, onOpenEdit] - ); + const editorExtensions = [ + EditorView.lineWrapping, + EditorView.contentAttributes.of({ spellcheck: 'true' }), + NaturalLanguage, + ...(!schema || !onOpenEdit ? [] : [refsNavigation(schema, onOpenEdit)]), + ...(schema ? [refsHoverTooltip(schema, colors, onOpenEdit !== undefined)] : []) + ]; function handleChange(newValue: string) { if (onChange) onChange(newValue); @@ -151,58 +144,52 @@ const RefsInput = forwardRef( if (onBlur) onBlur(event); } - const handleInput = useCallback( - (event: React.KeyboardEvent) => { - if (!thisRef.current?.view) { - event.preventDefault(); - event.stopPropagation(); - return; - } - if ((event.ctrlKey || event.metaKey) && event.code === 'Space') { - event.preventDefault(); - event.stopPropagation(); + function handleInput(event: React.KeyboardEvent) { + if (!thisRef.current?.view) { + event.preventDefault(); + event.stopPropagation(); + return; + } + if ((event.ctrlKey || event.metaKey) && event.code === 'Space') { + event.preventDefault(); + event.stopPropagation(); - const wrap = new CodeMirrorWrapper(thisRef.current as Required); - wrap.fixSelection(ReferenceTokens); - const nodes = wrap.getEnvelopingNodes(ReferenceTokens); - if (nodes.length !== 1) { - setCurrentType(ReferenceType.ENTITY); - setRefText(''); - setHintText(wrap.getSelectionText()); - } else { - setCurrentType(nodes[0].type.id === RefEntity ? ReferenceType.ENTITY : ReferenceType.SYNTACTIC); - setRefText(wrap.getSelectionText()); - } - - const selection = wrap.getSelection(); - const mainNodes = wrap - .getAllNodes([RefEntity]) - .filter(node => node.from >= selection.to || node.to <= selection.from); - setMainRefs(mainNodes.map(node => wrap.getText(node.from, node.to))); - setBasePosition(mainNodes.filter(node => node.to <= selection.from).length); - - setShowEditor(true); - } - }, - [thisRef] - ); - - const handleInputReference = useCallback( - (referenceText: string) => { - if (!thisRef.current?.view) { - return; - } - thisRef.current.view.focus(); const wrap = new CodeMirrorWrapper(thisRef.current as Required); - wrap.replaceWith(referenceText); - }, - [thisRef] - ); + wrap.fixSelection(ReferenceTokens); + const nodes = wrap.getEnvelopingNodes(ReferenceTokens); + if (nodes.length !== 1) { + setCurrentType(ReferenceType.ENTITY); + setRefText(''); + setHintText(wrap.getSelectionText()); + } else { + setCurrentType(nodes[0].type.id === RefEntity ? ReferenceType.ENTITY : ReferenceType.SYNTACTIC); + setRefText(wrap.getSelectionText()); + } - const hideEditReference = useCallback(() => { + const selection = wrap.getSelection(); + const mainNodes = wrap + .getAllNodes([RefEntity]) + .filter(node => node.from >= selection.to || node.to <= selection.from); + setMainRefs(mainNodes.map(node => wrap.getText(node.from, node.to))); + setBasePosition(mainNodes.filter(node => node.to <= selection.from).length); + + setShowEditor(true); + } + } + + function handleInputReference(referenceText: string) { + if (!thisRef.current?.view) { + return; + } + thisRef.current.view.focus(); + const wrap = new CodeMirrorWrapper(thisRef.current as Required); + wrap.replaceWith(referenceText); + } + + function hideEditReference() { setShowEditor(false); setTimeout(() => thisRef.current?.view?.focus(), PARAMETER.refreshTimeout); - }, [thisRef]); + } return (
diff --git a/rsconcept/frontend/src/components/info/TooltipOperation.tsx b/rsconcept/frontend/src/components/info/TooltipOperation.tsx index 198acf1f..57298733 100644 --- a/rsconcept/frontend/src/components/info/TooltipOperation.tsx +++ b/rsconcept/frontend/src/components/info/TooltipOperation.tsx @@ -1,7 +1,6 @@ 'use client'; import { createColumnHelper } from '@tanstack/react-table'; -import { useMemo } from 'react'; import Tooltip from '@/components/ui/Tooltip'; import { OssNodeInternal } from '@/models/miscellaneous'; @@ -19,47 +18,30 @@ interface TooltipOperationProps { const columnHelper = createColumnHelper(); function TooltipOperation({ node, anchor }: TooltipOperationProps) { - const columns = useMemo( - () => [ - columnHelper.accessor('substitution_term', { - id: 'substitution_term', - size: 200 - }), - columnHelper.accessor('substitution_alias', { - id: 'substitution_alias', - size: 50 - }), - columnHelper.display({ - id: 'status', - header: '', - size: 40, - cell: () => - }), - columnHelper.accessor('original_alias', { - id: 'original_alias', - size: 50 - }), - columnHelper.accessor('original_term', { - id: 'original_term', - size: 200 - }) - ], - [] - ); - - const table = useMemo( - () => ( - - ), - [columns, node] - ); + const columns = [ + columnHelper.accessor('substitution_term', { + id: 'substitution_term', + size: 200 + }), + columnHelper.accessor('substitution_alias', { + id: 'substitution_alias', + size: 50 + }), + columnHelper.display({ + id: 'status', + header: '', + size: 40, + cell: () => + }), + columnHelper.accessor('original_alias', { + id: 'original_alias', + size: 50 + }), + columnHelper.accessor('original_term', { + id: 'original_term', + size: 200 + }) + ]; return ( @@ -90,7 +72,14 @@ function TooltipOperation({ node, anchor }: TooltipOperationProps) {

) : null} {node.data.operation.substitutions.length > 0 ? ( - table + ) : node.data.operation.operation_type !== OperationType.INPUT ? (

Отождествления: Отсутствуют diff --git a/rsconcept/frontend/src/components/select/PickConstituenta.tsx b/rsconcept/frontend/src/components/select/PickConstituenta.tsx index e529aba8..c1007387 100644 --- a/rsconcept/frontend/src/components/select/PickConstituenta.tsx +++ b/rsconcept/frontend/src/components/select/PickConstituenta.tsx @@ -1,7 +1,7 @@ 'use client'; import clsx from 'clsx'; -import { useEffect, useMemo, useState } from 'react'; +import { useEffect, useState } from 'react'; import DataTable, { createColumnHelper, IConditionalStyle } from '@/components/ui/DataTable'; import SearchBar from '@/components/ui/SearchBar'; @@ -64,33 +64,27 @@ function PickConstituenta({ } }, [data, filterText, matchFunc, onBeginFilter]); - const columns = useMemo( - () => [ - columnHelper.accessor('alias', { - id: 'alias', - size: 65, - minSize: 65, - maxSize: 65, - cell: props => - }), - columnHelper.accessor(cst => describeFunc(cst), { - id: 'description', - size: 1000, - minSize: 1000 - }) - ], - [colors, prefixID, describeFunc] - ); + const columns = [ + columnHelper.accessor('alias', { + id: 'alias', + size: 65, + minSize: 65, + maxSize: 65, + cell: props => + }), + columnHelper.accessor(cst => describeFunc(cst), { + id: 'description', + size: 1000, + minSize: 1000 + }) + ]; - const conditionalRowStyles = useMemo( - (): IConditionalStyle[] => [ - { - when: (cst: IConstituenta) => cst.id === value?.id, - style: { backgroundColor: colors.bgSelected } - } - ], - [value, colors] - ); + const conditionalRowStyles: IConditionalStyle[] = [ + { + when: (cst: IConstituenta) => cst.id === value?.id, + style: { backgroundColor: colors.bgSelected } + } + ]; return (

diff --git a/rsconcept/frontend/src/components/select/PickMultiConstituenta.tsx b/rsconcept/frontend/src/components/select/PickMultiConstituenta.tsx index 8b7d00ee..337d1bc3 100644 --- a/rsconcept/frontend/src/components/select/PickMultiConstituenta.tsx +++ b/rsconcept/frontend/src/components/select/PickMultiConstituenta.tsx @@ -1,7 +1,7 @@ 'use client'; import clsx from 'clsx'; -import { useEffect, useMemo, useState } from 'react'; +import { useEffect, useState } from 'react'; import DataTable, { createColumnHelper, RowSelectionState } from '@/components/ui/DataTable'; import { useConceptOptions } from '@/context/ConceptOptionsContext'; @@ -49,7 +49,8 @@ function PickMultiConstituenta({ const [filtered, setFiltered] = useState(data); const [filterText, setFilterText] = useState(''); - const foldedGraph = useMemo(() => { + // TODO: extract graph fold logic to separate function + const foldedGraph = (() => { if (data.length === schema.items.length) { return schema.graph; } @@ -66,7 +67,7 @@ function PickMultiConstituenta({ newGraph.foldNode(item.id); }); return newGraph; - }, [data, schema.graph, schema.items]); + })(); useEffect(() => { if (filtered.length === 0) { @@ -105,22 +106,19 @@ function PickMultiConstituenta({ } } - const columns = useMemo( - () => [ - columnHelper.accessor('alias', { - id: 'alias', - header: () => Имя, - size: 65, - cell: props => - }), - columnHelper.accessor(cst => describeConstituenta(cst), { - id: 'description', - size: 1000, - header: 'Описание' - }) - ], - [colors, prefixID] - ); + const columns = [ + columnHelper.accessor('alias', { + id: 'alias', + header: () => Имя, + size: 65, + cell: props => + }), + columnHelper.accessor(cst => describeConstituenta(cst), { + id: 'description', + size: 1000, + header: 'Описание' + }) + ]; return (
diff --git a/rsconcept/frontend/src/components/select/PickMultiOperation.tsx b/rsconcept/frontend/src/components/select/PickMultiOperation.tsx index 447a8d9c..6701774f 100644 --- a/rsconcept/frontend/src/components/select/PickMultiOperation.tsx +++ b/rsconcept/frontend/src/components/select/PickMultiOperation.tsx @@ -1,7 +1,7 @@ 'use client'; import clsx from 'clsx'; -import { useCallback, useMemo, useState } from 'react'; +import { useState } from 'react'; import { IconMoveDown, IconMoveUp, IconRemove } from '@/components/Icons'; import SelectOperation from '@/components/select/SelectOperation'; @@ -23,108 +23,92 @@ interface PickMultiOperationProps extends CProps.Styling { const columnHelper = createColumnHelper(); function PickMultiOperation({ rows, items, selected, setSelected, className, ...restProps }: PickMultiOperationProps) { - const selectedItems = useMemo( - () => selected.map(itemID => items.find(item => item.id === itemID)!), - [items, selected] - ); - const nonSelectedItems = useMemo(() => items.filter(item => !selected.includes(item.id)), [items, selected]); + const selectedItems = selected.map(itemID => items.find(item => item.id === itemID)!); + const nonSelectedItems = items.filter(item => !selected.includes(item.id)); const [lastSelected, setLastSelected] = useState(undefined); - const handleDelete = useCallback( - (operation: OperationID) => setSelected(prev => prev.filter(item => item !== operation)), - [setSelected] - ); + function handleDelete(operation: OperationID) { + setSelected(prev => prev.filter(item => item !== operation)); + } - const handleSelect = useCallback( - (operation?: IOperation) => { - if (operation) { - setLastSelected(operation); - setSelected(prev => [...prev, operation.id]); - setTimeout(() => setLastSelected(undefined), 1000); - } - }, - [setSelected] - ); + function handleSelect(operation?: IOperation) { + if (operation) { + setLastSelected(operation); + setSelected(prev => [...prev, operation.id]); + setTimeout(() => setLastSelected(undefined), 1000); + } + } - const handleMoveUp = useCallback( - (operation: OperationID) => { - const index = selected.indexOf(operation); - if (index > 0) { - setSelected(prev => { - const newSelected = [...prev]; - newSelected[index] = newSelected[index - 1]; - newSelected[index - 1] = operation; - return newSelected; - }); - } - }, - [setSelected, selected] - ); + function handleMoveUp(operation: OperationID) { + const index = selected.indexOf(operation); + if (index > 0) { + setSelected(prev => { + const newSelected = [...prev]; + newSelected[index] = newSelected[index - 1]; + newSelected[index - 1] = operation; + return newSelected; + }); + } + } - const handleMoveDown = useCallback( - (operation: OperationID) => { - const index = selected.indexOf(operation); - if (index < selected.length - 1) { - setSelected(prev => { - const newSelected = [...prev]; - newSelected[index] = newSelected[index + 1]; - newSelected[index + 1] = operation; - return newSelected; - }); - } - }, - [setSelected, selected] - ); + function handleMoveDown(operation: OperationID) { + const index = selected.indexOf(operation); + if (index < selected.length - 1) { + setSelected(prev => { + const newSelected = [...prev]; + newSelected[index] = newSelected[index + 1]; + newSelected[index + 1] = operation; + return newSelected; + }); + } + } - const columns = useMemo( - () => [ - columnHelper.accessor('alias', { - id: 'alias', - header: 'Шифр', - size: 300, - minSize: 150, - maxSize: 300 - }), - columnHelper.accessor('title', { - id: 'title', - header: 'Название', - size: 1200, - minSize: 300, - maxSize: 1200, - cell: props =>
{props.getValue()}
- }), - columnHelper.display({ - id: 'actions', - size: 0, - cell: props => ( -
- } - onClick={() => handleDelete(props.row.original.id)} - /> - } - onClick={() => handleMoveUp(props.row.original.id)} - /> - } - onClick={() => handleMoveDown(props.row.original.id)} - /> -
- ) - }) - ], - [handleDelete, handleMoveUp, handleMoveDown] - ); + const columns = [ + columnHelper.accessor('alias', { + id: 'alias', + header: 'Шифр', + size: 300, + minSize: 150, + maxSize: 300 + }), + columnHelper.accessor('title', { + id: 'title', + header: 'Название', + size: 1200, + minSize: 300, + maxSize: 1200, + cell: props =>
{props.getValue()}
+ }), + columnHelper.display({ + id: 'actions', + size: 0, + cell: props => ( +
+ } + onClick={() => handleDelete(props.row.original.id)} + /> + } + onClick={() => handleMoveUp(props.row.original.id)} + /> + } + onClick={() => handleMoveDown(props.row.original.id)} + /> +
+ ) + }) + ]; return (
([]); - const baseFiltered = useMemo( - () => items.filter(item => item.item_type === itemType && (!baseFilter || baseFilter(item))), - [items, itemType, baseFilter] - ); + const baseFiltered = items.filter(item => item.item_type === itemType && (!baseFilter || baseFilter(item))); const locationMenu = useDropdown(); @@ -68,59 +65,50 @@ function PickSchema({ setFiltered(newFiltered); }, [filterText, filterLocation, baseFiltered]); - const columns = useMemo( - () => [ - columnHelper.accessor('alias', { - id: 'alias', - header: 'Шифр', - size: 150, - minSize: 80, - maxSize: 150 - }), - columnHelper.accessor('title', { - id: 'title', - header: 'Название', - size: 1200, - minSize: 200, - maxSize: 1200, - cell: props =>
{props.getValue()}
- }), - columnHelper.accessor('time_update', { - id: 'time_update', - header: 'Дата', - cell: props => ( -
- {new Date(props.getValue()).toLocaleString(intl.locale, { - year: '2-digit', - month: '2-digit', - day: '2-digit' - })} -
- ) - }) - ], - [intl] - ); + const columns = [ + columnHelper.accessor('alias', { + id: 'alias', + header: 'Шифр', + size: 150, + minSize: 80, + maxSize: 150 + }), + columnHelper.accessor('title', { + id: 'title', + header: 'Название', + size: 1200, + minSize: 200, + maxSize: 1200, + cell: props =>
{props.getValue()}
+ }), + columnHelper.accessor('time_update', { + id: 'time_update', + header: 'Дата', + cell: props => ( +
+ {new Date(props.getValue()).toLocaleString(intl.locale, { + year: '2-digit', + month: '2-digit', + day: '2-digit' + })} +
+ ) + }) + ]; - const conditionalRowStyles = useMemo( - (): IConditionalStyle[] => [ - { - when: (item: ILibraryItem) => item.id === value, - style: { backgroundColor: colors.bgSelected } - } - ], - [value, colors] - ); + const conditionalRowStyles: IConditionalStyle[] = [ + { + when: (item: ILibraryItem) => item.id === value, + style: { backgroundColor: colors.bgSelected } + } + ]; - const handleLocationClick = useCallback( - (event: CProps.EventMouse, newValue: string) => { - event.preventDefault(); - event.stopPropagation(); - locationMenu.hide(); - setFilterLocation(newValue); - }, - [locationMenu] - ); + function handleLocationClick(event: CProps.EventMouse, newValue: string) { + event.preventDefault(); + event.stopPropagation(); + locationMenu.hide(); + setFilterLocation(newValue); + } return (
diff --git a/rsconcept/frontend/src/components/select/PickSubstitutions.tsx b/rsconcept/frontend/src/components/select/PickSubstitutions.tsx index 6db21427..b55125ec 100644 --- a/rsconcept/frontend/src/components/select/PickSubstitutions.tsx +++ b/rsconcept/frontend/src/components/select/PickSubstitutions.tsx @@ -1,7 +1,7 @@ 'use client'; import clsx from 'clsx'; -import { useCallback, useMemo, useState } from 'react'; +import { useState } from 'react'; import { toast } from 'react-toastify'; import BadgeConstituenta from '@/components/info/BadgeConstituenta'; @@ -62,59 +62,47 @@ function PickSubstitutions({ const toggleDelete = () => setDeleteRight(prev => !prev); const [ignores, setIgnores] = useState([]); - const filteredSuggestions = useMemo( - () => - suggestions?.filter( - item => !ignores.find(ignore => ignore.original === item.original && ignore.substitution === item.substitution) - ) ?? [], - [ignores, suggestions] - ); + const filteredSuggestions = + suggestions?.filter( + item => !ignores.find(ignore => ignore.original === item.original && ignore.substitution === item.substitution) + ) ?? []; - const getSchemaByCst = useCallback( - (id: ConstituentaID): IRSForm | undefined => { - for (const schema of schemas) { - const cst = schema.cstByID.get(id); - if (cst) { - return schema; - } + const substitutionData: IMultiSubstitution[] = [ + ...substitutions.map(item => ({ + original_source: getSchemaByCst(item.original)!, + original: getConstituenta(item.original)!, + substitution: getConstituenta(item.substitution)!, + substitution_source: getSchemaByCst(item.substitution)!, + is_suggestion: false + })), + ...filteredSuggestions.map(item => ({ + original_source: getSchemaByCst(item.original)!, + original: getConstituenta(item.original)!, + substitution: getConstituenta(item.substitution)!, + substitution_source: getSchemaByCst(item.substitution)!, + is_suggestion: true + })) + ]; + + function getSchemaByCst(id: ConstituentaID): IRSForm | undefined { + for (const schema of schemas) { + const cst = schema.cstByID.get(id); + if (cst) { + return schema; } - return undefined; - }, - [schemas] - ); + } + return undefined; + } - const getConstituenta = useCallback( - (id: ConstituentaID): IConstituenta | undefined => { - for (const schema of schemas) { - const cst = schema.cstByID.get(id); - if (cst) { - return cst; - } + function getConstituenta(id: ConstituentaID): IConstituenta | undefined { + for (const schema of schemas) { + const cst = schema.cstByID.get(id); + if (cst) { + return cst; } - return undefined; - }, - [schemas] - ); - - const substitutionData: IMultiSubstitution[] = useMemo( - () => [ - ...substitutions.map(item => ({ - original_source: getSchemaByCst(item.original)!, - original: getConstituenta(item.original)!, - substitution: getConstituenta(item.substitution)!, - substitution_source: getSchemaByCst(item.substitution)!, - is_suggestion: false - })), - ...filteredSuggestions.map(item => ({ - original_source: getSchemaByCst(item.original)!, - original: getConstituenta(item.original)!, - substitution: getConstituenta(item.substitution)!, - substitution_source: getSchemaByCst(item.substitution)!, - is_suggestion: true - })) - ], - [getConstituenta, getSchemaByCst, substitutions, filteredSuggestions] - ); + } + return undefined; + } function addSubstitution() { if (!leftCst || !rightCst) { @@ -145,120 +133,105 @@ function PickSubstitutions({ setRightCst(undefined); } - const handleDeclineSuggestion = useCallback( - (item: IMultiSubstitution) => { - setIgnores(prev => [...prev, { original: item.original.id, substitution: item.substitution.id }]); - }, - [setIgnores] - ); + function handleDeclineSuggestion(item: IMultiSubstitution) { + setIgnores(prev => [...prev, { original: item.original.id, substitution: item.substitution.id }]); + } - const handleAcceptSuggestion = useCallback( - (item: IMultiSubstitution) => { - setSubstitutions(prev => [...prev, { original: item.original.id, substitution: item.substitution.id }]); - }, - [setSubstitutions] - ); + function handleAcceptSuggestion(item: IMultiSubstitution) { + setSubstitutions(prev => [...prev, { original: item.original.id, substitution: item.substitution.id }]); + } - const handleDeleteSubstitution = useCallback( - (target: IMultiSubstitution) => { - handleDeclineSuggestion(target); - setSubstitutions(prev => { - const newItems: ICstSubstitute[] = []; - prev.forEach(item => { - if (item.original !== target.original.id || item.substitution !== target.substitution.id) { - newItems.push(item); - } - }); - return newItems; - }); - }, - [setSubstitutions, handleDeclineSuggestion] - ); - - const columns = useMemo( - () => [ - columnHelper.accessor(item => item.substitution_source.alias, { - id: 'left_schema', - size: 100, - cell: props =>
{props.getValue()}
- }), - columnHelper.accessor(item => item.substitution.alias, { - id: 'left_alias', - size: 65, - cell: props => ( - - ) - }), - columnHelper.display({ - id: 'status', - size: 0, - cell: () => - }), - columnHelper.accessor(item => item.original.alias, { - id: 'right_alias', - size: 65, - cell: props => ( - - ) - }), - columnHelper.accessor(item => item.original_source.alias, { - id: 'right_schema', - size: 100, - cell: props =>
{props.getValue()}
- }), - columnHelper.display({ - id: 'actions', - size: 0, - cell: props => - props.row.original.is_suggestion ? ( -
- } - onClick={() => handleAcceptSuggestion(props.row.original)} - /> - } - onClick={() => handleDeclineSuggestion(props.row.original)} - /> -
- ) : ( -
- } - onClick={() => handleDeleteSubstitution(props.row.original)} - /> -
- ) - }) - ], - [handleDeleteSubstitution, handleDeclineSuggestion, handleAcceptSuggestion, colors, prefixID] - ); - - const conditionalRowStyles = useMemo( - (): IConditionalStyle[] => [ - { - when: (item: IMultiSubstitution) => item.is_suggestion, - style: { - backgroundColor: colors.bgOrange50 + function handleDeleteSubstitution(target: IMultiSubstitution) { + handleDeclineSuggestion(target); + setSubstitutions(prev => { + const newItems: ICstSubstitute[] = []; + prev.forEach(item => { + if (item.original !== target.original.id || item.substitution !== target.substitution.id) { + newItems.push(item); } + }); + return newItems; + }); + } + + const columns = [ + columnHelper.accessor(item => item.substitution_source.alias, { + id: 'left_schema', + size: 100, + cell: props =>
{props.getValue()}
+ }), + columnHelper.accessor(item => item.substitution.alias, { + id: 'left_alias', + size: 65, + cell: props => ( + + ) + }), + columnHelper.display({ + id: 'status', + size: 0, + cell: () => + }), + columnHelper.accessor(item => item.original.alias, { + id: 'right_alias', + size: 65, + cell: props => ( + + ) + }), + columnHelper.accessor(item => item.original_source.alias, { + id: 'right_schema', + size: 100, + cell: props =>
{props.getValue()}
+ }), + columnHelper.display({ + id: 'actions', + size: 0, + cell: props => + props.row.original.is_suggestion ? ( +
+ } + onClick={() => handleAcceptSuggestion(props.row.original)} + /> + } + onClick={() => handleDeclineSuggestion(props.row.original)} + /> +
+ ) : ( +
+ } + onClick={() => handleDeleteSubstitution(props.row.original)} + /> +
+ ) + }) + ]; + + const conditionalRowStyles: IConditionalStyle[] = [ + { + when: (item: IMultiSubstitution) => item.is_suggestion, + style: { + backgroundColor: colors.bgOrange50 } - ], - [colors] - ); + } + ]; return (
diff --git a/rsconcept/frontend/src/components/select/SelectConstituenta.tsx b/rsconcept/frontend/src/components/select/SelectConstituenta.tsx index 9d7f99f0..91340d4b 100644 --- a/rsconcept/frontend/src/components/select/SelectConstituenta.tsx +++ b/rsconcept/frontend/src/components/select/SelectConstituenta.tsx @@ -1,7 +1,6 @@ 'use client'; import clsx from 'clsx'; -import { useCallback, useMemo } from 'react'; import { CstMatchMode } from '@/models/miscellaneous'; import { ConstituentaID, IConstituenta } from '@/models/rsform'; @@ -28,22 +27,16 @@ function SelectConstituenta({ placeholder = 'Выберите конституенту', ...restProps }: SelectConstituentaProps) { - const options = useMemo(() => { - return ( - items?.map(cst => ({ - value: cst.id, - label: `${cst.alias}${cst.is_inherited ? '*' : ''}: ${describeConstituenta(cst)}` - })) ?? [] - ); - }, [items]); + const options = + items?.map(cst => ({ + value: cst.id, + label: `${cst.alias}${cst.is_inherited ? '*' : ''}: ${describeConstituenta(cst)}` + })) ?? []; - const filter = useCallback( - (option: { value: ConstituentaID | undefined; label: string }, inputValue: string) => { - const cst = items?.find(item => item.id === option.value); - return !cst ? false : matchConstituenta(cst, inputValue, CstMatchMode.ALL); - }, - [items] - ); + function filter(option: { value: ConstituentaID | undefined; label: string }, inputValue: string) { + const cst = items?.find(item => item.id === option.value); + return !cst ? false : matchConstituenta(cst, inputValue, CstMatchMode.ALL); + } return ( { - return ( - items?.map(cst => ({ - value: cst.id, - label: `${cst.alias}: ${cst.title}` - })) ?? [] - ); - }, [items]); + const options = + items?.map(cst => ({ + value: cst.id, + label: `${cst.alias}: ${cst.title}` + })) ?? []; - const filter = useCallback( - (option: { value: LibraryItemID | undefined; label: string }, inputValue: string) => { - const item = items?.find(item => item.id === option.value); - return !item ? false : matchLibraryItem(item, inputValue); - }, - [items] - ); + function filter(option: { value: LibraryItemID | undefined; label: string }, inputValue: string) { + const item = items?.find(item => item.id === option.value); + return !item ? false : matchLibraryItem(item, inputValue); + } return ( folderTree.at(value), [folderTree, value]); - - const items = useMemo(() => folderTree.getTree(), [folderTree]); + const activeNode = folderTree.at(value); + const items = folderTree.getTree(); const [folded, setFolded] = useState(items); useEffect(() => { setFolded(items.filter(item => item !== activeNode && !activeNode?.hasPredecessor(item))); }, [items, activeNode]); - const onFoldItem = useCallback( - (target: FolderNode, showChildren: boolean) => { - setFolded(prev => - items.filter(item => { - if (item === target) { - return !showChildren; - } - if (!showChildren && item.hasPredecessor(target)) { - return true; - } else { - return prev.includes(item); - } - }) - ); - }, - [items] - ); + function onFoldItem(target: FolderNode, showChildren: boolean) { + setFolded(prev => + items.filter(item => { + if (item === target) { + return !showChildren; + } + if (!showChildren && item.hasPredecessor(target)) { + return true; + } else { + return prev.includes(item); + } + }) + ); + } - const handleClickFold = useCallback( - (event: CProps.EventMouse, target: FolderNode, showChildren: boolean) => { - event.preventDefault(); - event.stopPropagation(); - onFoldItem(target, showChildren); - }, - [onFoldItem] - ); + function handleClickFold(event: CProps.EventMouse, target: FolderNode, showChildren: boolean) { + event.preventDefault(); + event.stopPropagation(); + onFoldItem(target, showChildren); + } return (
diff --git a/rsconcept/frontend/src/components/select/SelectOperation.tsx b/rsconcept/frontend/src/components/select/SelectOperation.tsx index 359e650c..9f77f42b 100644 --- a/rsconcept/frontend/src/components/select/SelectOperation.tsx +++ b/rsconcept/frontend/src/components/select/SelectOperation.tsx @@ -1,7 +1,6 @@ 'use client'; import clsx from 'clsx'; -import { useCallback, useMemo } from 'react'; import { IOperation, OperationID } from '@/models/oss'; import { matchOperation } from '@/models/ossAPI'; @@ -26,22 +25,16 @@ function SelectOperation({ placeholder = 'Выберите операцию', ...restProps }: SelectOperationProps) { - const options = useMemo(() => { - return ( - items?.map(cst => ({ - value: cst.id, - label: `${cst.alias}: ${cst.title}` - })) ?? [] - ); - }, [items]); + const options = + items?.map(cst => ({ + value: cst.id, + label: `${cst.alias}: ${cst.title}` + })) ?? []; - const filter = useCallback( - (option: { value: OperationID | undefined; label: string }, inputValue: string) => { - const operation = items?.find(item => item.id === option.value); - return !operation ? false : matchOperation(operation, inputValue); - }, - [items] - ); + function filter(option: { value: OperationID | undefined; label: string }, inputValue: string) { + const operation = items?.find(item => item.id === option.value); + return !operation ? false : matchOperation(operation, inputValue); + } return ( { - return ( - items?.map(user => ({ - value: user.id, - label: getUserLabel(user.id) - })) ?? [] - ); - }, [items, getUserLabel]); + const options = + items?.map(user => ({ + value: user.id, + label: getUserLabel(user.id) + })) ?? []; - const filter = useCallback( - (option: { value: UserID | undefined; label: string }, inputValue: string) => { - const user = items?.find(item => item.id === option.value); - return !user ? false : matchUser(user, inputValue); - }, - [items] - ); + function filter(option: { value: UserID | undefined; label: string }, inputValue: string) { + const user = items?.find(item => item.id === option.value); + return !user ? false : matchUser(user, inputValue); + } return ( { - return [ - { - value: undefined, - label: labelVersion(undefined) - }, - ...(items?.map(version => ({ - value: version.id, - label: version.version - })) ?? []) - ]; - }, [items]); - const valueLabel = useMemo(() => { + const options = [ + { + value: undefined, + label: labelVersion(undefined) + }, + ...(items?.map(version => ({ + value: version.id, + label: version.version + })) ?? []) + ]; + + const valueLabel = (() => { const version = items?.find(ver => ver.id === value); return version ? version.version : labelVersion(undefined); - }, [items, value]); + })(); return ( { - if (disabled) { - return 'cursor-arrow'; - } else if (setValue) { - return 'cursor-pointer'; - } else { - return ''; - } - }, [disabled, setValue]); + const cursor = disabled ? 'cursor-arrow' : setValue ? 'cursor-pointer' : ''; function handleClick(event: CProps.EventMouse): void { event.preventDefault(); diff --git a/rsconcept/frontend/src/components/ui/CheckboxTristate.tsx b/rsconcept/frontend/src/components/ui/CheckboxTristate.tsx index 9bd08706..18c142f5 100644 --- a/rsconcept/frontend/src/components/ui/CheckboxTristate.tsx +++ b/rsconcept/frontend/src/components/ui/CheckboxTristate.tsx @@ -1,5 +1,4 @@ import clsx from 'clsx'; -import { useMemo } from 'react'; import { globals } from '@/utils/constants'; @@ -29,15 +28,7 @@ function CheckboxTristate({ setValue, ...restProps }: CheckboxTristateProps) { - const cursor = useMemo(() => { - if (disabled) { - return 'cursor-arrow'; - } else if (setValue) { - return 'cursor-pointer'; - } else { - return ''; - } - }, [disabled, setValue]); + const cursor = disabled ? 'cursor-arrow' : setValue ? 'cursor-pointer' : ''; function handleClick(event: CProps.EventMouse): void { event.preventDefault(); diff --git a/rsconcept/frontend/src/components/ui/PDFViewer/PDFViewer.tsx b/rsconcept/frontend/src/components/ui/PDFViewer/PDFViewer.tsx index 6e7ecead..52c3cde1 100644 --- a/rsconcept/frontend/src/components/ui/PDFViewer/PDFViewer.tsx +++ b/rsconcept/frontend/src/components/ui/PDFViewer/PDFViewer.tsx @@ -1,7 +1,5 @@ 'use client'; -import { useMemo } from 'react'; - import { useConceptOptions } from '@/context/ConceptOptionsContext'; import useWindowSize from '@/hooks/useWindowSize'; @@ -29,10 +27,8 @@ function PDFViewer({ file, offsetXpx, minWidth = MINIMUM_WIDTH }: PDFViewerProps const windowSize = useWindowSize(); const { calculateHeight } = useConceptOptions(); - const pageWidth = useMemo(() => { - return Math.max(minWidth, Math.min((windowSize?.width ?? 0) - (offsetXpx ?? 0) - 10, MAXIMUM_WIDTH)); - }, [windowSize, offsetXpx, minWidth]); - const pageHeight = useMemo(() => calculateHeight('1rem'), [calculateHeight]); + const pageWidth = Math.max(minWidth, Math.min((windowSize?.width ?? 0) - (offsetXpx ?? 0) - 10, MAXIMUM_WIDTH)); + const pageHeight = calculateHeight('1rem'); return ; } diff --git a/rsconcept/frontend/src/components/ui/SelectMulti.tsx b/rsconcept/frontend/src/components/ui/SelectMulti.tsx index 80b321b6..edd9f638 100644 --- a/rsconcept/frontend/src/components/ui/SelectMulti.tsx +++ b/rsconcept/frontend/src/components/ui/SelectMulti.tsx @@ -1,6 +1,5 @@ 'use client'; -import { useMemo } from 'react'; import Select, { ClearIndicatorProps, components, @@ -54,58 +53,55 @@ function SelectMulti = GroupBase