mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 21:10:38 +03:00
Add toggle for side list
This commit is contained in:
parent
6919529466
commit
930c185908
|
@ -3,6 +3,7 @@
|
||||||
import { Dispatch, SetStateAction, useMemo, useState } from 'react';
|
import { Dispatch, SetStateAction, useMemo, useState } from 'react';
|
||||||
|
|
||||||
import { useRSForm } from '@/context/RSFormContext';
|
import { useRSForm } from '@/context/RSFormContext';
|
||||||
|
import useLocalStorage from '@/hooks/useLocalStorage';
|
||||||
import useWindowSize from '@/hooks/useWindowSize';
|
import useWindowSize from '@/hooks/useWindowSize';
|
||||||
import { CstType, IConstituenta, ICstCreateData, ICstRenameData } from '@/models/rsform';
|
import { CstType, IConstituenta, ICstCreateData, ICstRenameData } from '@/models/rsform';
|
||||||
import { globalIDs } from '@/utils/constants';
|
import { globalIDs } from '@/utils/constants';
|
||||||
|
@ -39,6 +40,7 @@ function EditorConstituenta({
|
||||||
const windowSize = useWindowSize();
|
const windowSize = useWindowSize();
|
||||||
const { schema } = useRSForm();
|
const { schema } = useRSForm();
|
||||||
|
|
||||||
|
const [showList, setShowList] = useLocalStorage('rseditor-show-list', true);
|
||||||
const [toggleReset, setToggleReset] = useState(false);
|
const [toggleReset, setToggleReset] = useState(false);
|
||||||
|
|
||||||
const disabled = useMemo(() => (!activeCst || !isMutable), [activeCst, isMutable]);
|
const disabled = useMemo(() => (!activeCst || !isMutable), [activeCst, isMutable]);
|
||||||
|
@ -136,16 +138,18 @@ function EditorConstituenta({
|
||||||
onKeyDown={handleInput}
|
onKeyDown={handleInput}
|
||||||
>
|
>
|
||||||
<FormConstituenta disabled={disabled}
|
<FormConstituenta disabled={disabled}
|
||||||
|
showList={showList}
|
||||||
id={globalIDs.constituenta_editor}
|
id={globalIDs.constituenta_editor}
|
||||||
constituenta={activeCst}
|
constituenta={activeCst}
|
||||||
isModified={isModified}
|
isModified={isModified}
|
||||||
toggleReset={toggleReset}
|
toggleReset={toggleReset}
|
||||||
|
onToggleList={() => setShowList(prev => !prev)}
|
||||||
|
|
||||||
setIsModified={setIsModified}
|
setIsModified={setIsModified}
|
||||||
onEditTerm={onEditTerm}
|
onEditTerm={onEditTerm}
|
||||||
onRenameCst={onRenameCst}
|
onRenameCst={onRenameCst}
|
||||||
/>
|
/>
|
||||||
{(windowSize.width && windowSize.width >= SIDELIST_HIDE_THRESHOLD) ?
|
{(showList && windowSize.width && windowSize.width >= SIDELIST_HIDE_THRESHOLD) ?
|
||||||
<ViewConstituents
|
<ViewConstituents
|
||||||
schema={schema}
|
schema={schema}
|
||||||
expression={activeCst?.definition_formal ?? ''}
|
expression={activeCst?.definition_formal ?? ''}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import EditorRSExpression from '../EditorRSExpression';
|
||||||
|
|
||||||
interface FormConstituentaProps {
|
interface FormConstituentaProps {
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
|
showList: boolean
|
||||||
|
|
||||||
id?: string
|
id?: string
|
||||||
constituenta?: IConstituenta
|
constituenta?: IConstituenta
|
||||||
|
@ -28,15 +29,16 @@ interface FormConstituentaProps {
|
||||||
toggleReset: boolean
|
toggleReset: boolean
|
||||||
setIsModified: Dispatch<SetStateAction<boolean>>
|
setIsModified: Dispatch<SetStateAction<boolean>>
|
||||||
|
|
||||||
|
onToggleList: () => void
|
||||||
onRenameCst: (initial: ICstRenameData) => void
|
onRenameCst: (initial: ICstRenameData) => void
|
||||||
onEditTerm: () => void
|
onEditTerm: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
function FormConstituenta({
|
function FormConstituenta({
|
||||||
disabled,
|
disabled, showList,
|
||||||
id, isModified, setIsModified,
|
id, isModified, setIsModified,
|
||||||
constituenta, toggleReset,
|
constituenta, toggleReset,
|
||||||
onRenameCst, onEditTerm
|
onRenameCst, onEditTerm, onToggleList
|
||||||
}: FormConstituentaProps) {
|
}: FormConstituentaProps) {
|
||||||
const { schema, cstUpdate, processing } = useRSForm();
|
const { schema, cstUpdate, processing } = useRSForm();
|
||||||
|
|
||||||
|
@ -158,11 +160,13 @@ function FormConstituenta({
|
||||||
/>
|
/>
|
||||||
<EditorRSExpression
|
<EditorRSExpression
|
||||||
label='Формальное определение'
|
label='Формальное определение'
|
||||||
activeCst={constituenta}
|
|
||||||
placeholder='Родоструктурное выражение, задающее формальное определение'
|
placeholder='Родоструктурное выражение, задающее формальное определение'
|
||||||
value={expression}
|
value={expression}
|
||||||
|
activeCst={constituenta}
|
||||||
|
showList={showList}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
toggleReset={toggleReset}
|
toggleReset={toggleReset}
|
||||||
|
onToggleList={onToggleList}
|
||||||
onChange={newValue => setExpression(newValue)}
|
onChange={newValue => setExpression(newValue)}
|
||||||
setTypification={setTypification}
|
setTypification={setTypification}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import { ReactCodeMirrorRef } from '@uiw/react-codemirror';
|
import { ReactCodeMirrorRef } from '@uiw/react-codemirror';
|
||||||
import { useCallback, useLayoutEffect, useRef, useState } from 'react';
|
import { useCallback, useLayoutEffect, useRef, useState } from 'react';
|
||||||
|
import { BiListUl } from 'react-icons/bi';
|
||||||
import { FaRegKeyboard } from 'react-icons/fa6';
|
import { FaRegKeyboard } from 'react-icons/fa6';
|
||||||
import { RiNodeTree } from 'react-icons/ri'
|
import { RiNodeTree } from 'react-icons/ri'
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
|
@ -27,18 +28,23 @@ import StatusBar from './StatusBar';
|
||||||
interface EditorRSExpressionProps {
|
interface EditorRSExpressionProps {
|
||||||
id?: string
|
id?: string
|
||||||
activeCst?: IConstituenta
|
activeCst?: IConstituenta
|
||||||
|
value: string
|
||||||
label: string
|
label: string
|
||||||
|
placeholder?: string
|
||||||
|
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
toggleReset?: boolean
|
toggleReset?: boolean
|
||||||
placeholder?: string
|
showList: boolean
|
||||||
|
|
||||||
setTypification: (typificaiton: string) => void
|
setTypification: (typificaiton: string) => void
|
||||||
value: string
|
|
||||||
onChange: (newValue: string) => void
|
onChange: (newValue: string) => void
|
||||||
|
onToggleList: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
function EditorRSExpression({
|
function EditorRSExpression({
|
||||||
activeCst, disabled, value, toggleReset,
|
activeCst, disabled, value, toggleReset, showList,
|
||||||
setTypification, onChange, ...restProps
|
setTypification, onChange, onToggleList,
|
||||||
|
...restProps
|
||||||
}: EditorRSExpressionProps) {
|
}: EditorRSExpressionProps) {
|
||||||
const { schema } = useRSForm();
|
const { schema } = useRSForm();
|
||||||
|
|
||||||
|
@ -138,10 +144,15 @@ function EditorRSExpression({
|
||||||
<div>
|
<div>
|
||||||
<Overlay position='top-0 right-0 flex'>
|
<Overlay position='top-0 right-0 flex'>
|
||||||
<MiniButton noHover
|
<MiniButton noHover
|
||||||
title='Включение специальной клавиатуры'
|
title='Отображение специальной клавиатуры'
|
||||||
onClick={() => setShowControls(prev => !prev)}
|
onClick={() => setShowControls(prev => !prev)}
|
||||||
icon={<FaRegKeyboard size='1.25rem' className={showControls ? 'clr-text-primary': ''} />}
|
icon={<FaRegKeyboard size='1.25rem' className={showControls ? 'clr-text-primary': ''} />}
|
||||||
/>
|
/>
|
||||||
|
<MiniButton noHover
|
||||||
|
title='Отображение списка конституент'
|
||||||
|
onClick={onToggleList}
|
||||||
|
icon={<BiListUl size='1.25rem' className={showList ? 'clr-text-primary': ''} />}
|
||||||
|
/>
|
||||||
<MiniButton noHover
|
<MiniButton noHover
|
||||||
title='Дерево разбора выражения'
|
title='Дерево разбора выражения'
|
||||||
onClick={handleShowAST}
|
onClick={handleShowAST}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user