diff --git a/rsconcept/frontend/src/components/select/PickConstituenta.tsx b/rsconcept/frontend/src/components/select/PickConstituenta.tsx index 36760ab4..6c604647 100644 --- a/rsconcept/frontend/src/components/select/PickConstituenta.tsx +++ b/rsconcept/frontend/src/components/select/PickConstituenta.tsx @@ -17,6 +17,9 @@ import { describeConstituenta } from '@/utils/labels'; interface PickConstituentaProps extends CProps.Styling { id?: string; + value?: IConstituenta; + onChange: (newValue: IConstituenta) => void; + prefixID: string; data?: IConstituenta[]; rows?: number; @@ -25,9 +28,6 @@ interface PickConstituentaProps extends CProps.Styling { onBeginFilter?: (cst: IConstituenta) => boolean; describeFunc?: (cst: IConstituenta) => string; matchFunc?: (cst: IConstituenta, filter: string) => boolean; - - value?: IConstituenta; - onSelectValue: (newValue: IConstituenta) => void; } const columnHelper = createColumnHelper(); @@ -42,7 +42,7 @@ function PickConstituenta({ describeFunc = describeConstituenta, matchFunc = (cst, filter) => matchConstituenta(cst, filter, CstMatchMode.ALL), onBeginFilter, - onSelectValue, + onChange, className, ...restProps }: PickConstituentaProps) { @@ -110,7 +110,7 @@ function PickConstituenta({

Измените параметры фильтра

} - onRowClicked={onSelectValue} + onRowClicked={onChange} /> ); diff --git a/rsconcept/frontend/src/components/select/PickMultiConstituenta.tsx b/rsconcept/frontend/src/components/select/PickMultiConstituenta.tsx index f6dea9a8..a098b3a3 100644 --- a/rsconcept/frontend/src/components/select/PickMultiConstituenta.tsx +++ b/rsconcept/frontend/src/components/select/PickMultiConstituenta.tsx @@ -18,15 +18,15 @@ import ToolbarGraphSelection from './ToolbarGraphSelection'; interface PickMultiConstituentaProps extends CProps.Styling { id?: string; + value: ConstituentaID[]; + onChange: React.Dispatch>; + schema: IRSForm; data: IConstituenta[]; prefixID: string; rows?: number; noBorder?: boolean; - - selected: ConstituentaID[]; - setSelected: React.Dispatch>; } const columnHelper = createColumnHelper(); @@ -38,8 +38,8 @@ function PickMultiConstituenta({ prefixID, rows, noBorder, - selected, - setSelected, + value, + onChange, className, ...restProps }: PickMultiConstituentaProps) { @@ -74,10 +74,10 @@ function PickMultiConstituenta({ } const newRowSelection: RowSelectionState = {}; filtered.forEach((cst, index) => { - newRowSelection[String(index)] = selected.includes(cst.id); + newRowSelection[String(index)] = value.includes(cst.id); }); setRowSelection(newRowSelection); - }, [filtered, setRowSelection, selected]); + }, [filtered, setRowSelection, value]); useEffect(() => { if (data.length === 0) { @@ -91,7 +91,7 @@ function PickMultiConstituenta({ function handleRowSelection(updater: React.SetStateAction) { if (!data) { - setSelected([]); + onChange([]); } else { const newRowSelection = typeof updater === 'function' ? updater(rowSelection) : updater; const newSelection: ConstituentaID[] = []; @@ -100,7 +100,7 @@ function PickMultiConstituenta({ newSelection.push(cst.id); } }); - setSelected(prev => [...prev.filter(cst_id => !filtered.find(cst => cst.id === cst_id)), ...newSelection]); + onChange(prev => [...prev.filter(cst_id => !filtered.find(cst => cst.id === cst_id)), ...newSelection]); } } @@ -122,7 +122,7 @@ function PickMultiConstituenta({
- {data.length > 0 ? `Выбраны ${selected.length} из ${data.length}` : 'Конституенты'} + {data.length > 0 ? `Выбраны ${value.length} из ${data.length}` : 'Конституенты'}
isBasicConcept(schema.cstByID.get(cstID)?.cst_type)} isOwned={cstID => !schema.cstByID.get(cstID)?.is_inherited} - selected={selected} - setSelected={setSelected} - emptySelection={selected.length === 0} + value={value} + onChange={onChange} + emptySelection={value.length === 0} className='w-fit' />
diff --git a/rsconcept/frontend/src/components/select/PickMultiOperation.tsx b/rsconcept/frontend/src/components/select/PickMultiOperation.tsx index 98b891cc..07348f71 100644 --- a/rsconcept/frontend/src/components/select/PickMultiOperation.tsx +++ b/rsconcept/frontend/src/components/select/PickMultiOperation.tsx @@ -12,36 +12,36 @@ import NoData from '@/components/ui/NoData'; import { IOperation, OperationID } from '@/models/oss'; interface PickMultiOperationProps extends CProps.Styling { - rows?: number; + value: OperationID[]; + onChange: React.Dispatch>; items: IOperation[]; - selected: OperationID[]; - setSelected: React.Dispatch>; + rows?: number; } const columnHelper = createColumnHelper(); -function PickMultiOperation({ rows, items, selected, setSelected, className, ...restProps }: PickMultiOperationProps) { - const selectedItems = selected.map(itemID => items.find(item => item.id === itemID)!); - const nonSelectedItems = items.filter(item => !selected.includes(item.id)); +function PickMultiOperation({ rows, items, value, onChange, className, ...restProps }: PickMultiOperationProps) { + const selectedItems = value.map(itemID => items.find(item => item.id === itemID)!); + const nonSelectedItems = items.filter(item => !value.includes(item.id)); const [lastSelected, setLastSelected] = useState(undefined); function handleDelete(operation: OperationID) { - setSelected(prev => prev.filter(item => item !== operation)); + onChange(prev => prev.filter(item => item !== operation)); } function handleSelect(operation?: IOperation) { if (operation) { setLastSelected(operation); - setSelected(prev => [...prev, operation.id]); + onChange(prev => [...prev, operation.id]); setTimeout(() => setLastSelected(undefined), 1000); } } function handleMoveUp(operation: OperationID) { - const index = selected.indexOf(operation); + const index = value.indexOf(operation); if (index > 0) { - setSelected(prev => { + onChange(prev => { const newSelected = [...prev]; newSelected[index] = newSelected[index - 1]; newSelected[index - 1] = operation; @@ -51,9 +51,9 @@ function PickMultiOperation({ rows, items, selected, setSelected, className, ... } function handleMoveDown(operation: OperationID) { - const index = selected.indexOf(operation); - if (index < selected.length - 1) { - setSelected(prev => { + const index = value.indexOf(operation); + if (index < value.length - 1) { + onChange(prev => { const newSelected = [...prev]; newSelected[index] = newSelected[index + 1]; newSelected[index + 1] = operation; @@ -118,7 +118,7 @@ function PickMultiOperation({ rows, items, selected, setSelected, className, ... noBorder items={nonSelectedItems} // prettier: split-line value={lastSelected} - onSelectValue={handleSelect} + onChange={handleSelect} /> void; + initialFilter?: string; rows?: number; items: ILibraryItem[]; itemType: LibraryItemType; - value?: LibraryItemID; baseFilter?: (target: ILibraryItem) => boolean; - onSelectValue: (newValue: LibraryItemID) => void; } const columnHelper = createColumnHelper(); @@ -38,7 +39,7 @@ function PickSchema({ items, itemType, value, - onSelectValue, + onChange, baseFilter, className, ...restProps @@ -156,7 +157,7 @@ function PickSchema({

Измените параметры фильтра

} - onRowClicked={rowData => onSelectValue(rowData.id)} + onRowClicked={rowData => onChange(rowData.id)} />
); diff --git a/rsconcept/frontend/src/components/select/PickSubstitutions.tsx b/rsconcept/frontend/src/components/select/PickSubstitutions.tsx index 0edb0540..195478e0 100644 --- a/rsconcept/frontend/src/components/select/PickSubstitutions.tsx +++ b/rsconcept/frontend/src/components/select/PickSubstitutions.tsx @@ -20,8 +20,9 @@ import { errors } from '@/utils/labels'; import SelectLibraryItem from './SelectLibraryItem'; interface PickSubstitutionsProps extends CProps.Styling { - substitutions: ICstSubstitute[]; - setSubstitutions: React.Dispatch>; + value: ICstSubstitute[]; + onChange: React.Dispatch>; + suggestions?: ICstSubstitute[]; prefixID: string; @@ -35,8 +36,8 @@ interface PickSubstitutionsProps extends CProps.Styling { const columnHelper = createColumnHelper(); function PickSubstitutions({ - substitutions, - setSubstitutions, + value, + onChange, suggestions, prefixID, rows, @@ -66,7 +67,7 @@ function PickSubstitutions({ ) ?? []; const substitutionData: IMultiSubstitution[] = [ - ...substitutions.map(item => ({ + ...value.map(item => ({ original_source: getSchemaByCst(item.original)!, original: getConstituenta(item.original)!, substitution: getConstituenta(item.substitution)!, @@ -110,8 +111,8 @@ function PickSubstitutions({ original: deleteRight ? rightCst.id : leftCst.id, substitution: deleteRight ? leftCst.id : rightCst.id }; - const toDelete = substitutions.map(item => item.original); - const replacements = substitutions.map(item => item.substitution); + const toDelete = value.map(item => item.original); + const replacements = value.map(item => item.substitution); if ( toDelete.includes(newSubstitution.original) || toDelete.includes(newSubstitution.substitution) || @@ -126,7 +127,7 @@ function PickSubstitutions({ return; } } - setSubstitutions(prev => [...prev, newSubstitution]); + onChange(prev => [...prev, newSubstitution]); setLeftCst(undefined); setRightCst(undefined); } @@ -136,12 +137,12 @@ function PickSubstitutions({ } function handleAcceptSuggestion(item: IMultiSubstitution) { - setSubstitutions(prev => [...prev, { original: item.original.id, substitution: item.substitution.id }]); + onChange(prev => [...prev, { original: item.original.id, substitution: item.substitution.id }]); } function handleDeleteSubstitution(target: IMultiSubstitution) { handleDeclineSuggestion(target); - setSubstitutions(prev => { + onChange(prev => { const newItems: ICstSubstitute[] = []; prev.forEach(item => { if (item.original !== target.original.id || item.substitution !== target.substitution.id) { @@ -230,15 +231,15 @@ function PickSubstitutions({ placeholder='Выберите аргумент' items={allowSelfSubstitution ? schemas : schemas.filter(item => item.id !== rightArgument?.id)} value={leftArgument} - onSelectValue={setLeftArgument} + onChange={setLeftArgument} /> !substitutions.find(item => item.original === cst.id) && (!filter || filter(cst)) + cst => !value.find(item => item.original === cst.id) && (!filter || filter(cst)) )} value={leftCst} - onSelectValue={setLeftCst} + onChange={setLeftCst} />
@@ -268,15 +269,15 @@ function PickSubstitutions({ placeholder='Выберите аргумент' items={allowSelfSubstitution ? schemas : schemas.filter(item => item.id !== leftArgument?.id)} value={rightArgument} - onSelectValue={setRightArgument} + onChange={setRightArgument} /> !substitutions.find(item => item.original === cst.id) && (!filter || filter(cst)) + cst => !value.find(item => item.original === cst.id) && (!filter || filter(cst)) )} value={rightCst} - onSelectValue={setRightCst} + onChange={setRightCst} />
diff --git a/rsconcept/frontend/src/components/select/SelectAccessPolicy.tsx b/rsconcept/frontend/src/components/select/SelectAccessPolicy.tsx index ecb63b19..9f8e3a50 100644 --- a/rsconcept/frontend/src/components/select/SelectAccessPolicy.tsx +++ b/rsconcept/frontend/src/components/select/SelectAccessPolicy.tsx @@ -15,6 +15,7 @@ import { describeAccessPolicy, labelAccessPolicy } from '@/utils/labels'; interface SelectAccessPolicyProps extends CProps.Styling { value: AccessPolicy; onChange: (value: AccessPolicy) => void; + disabled?: boolean; stretchLeft?: boolean; } diff --git a/rsconcept/frontend/src/components/select/SelectConstituenta.tsx b/rsconcept/frontend/src/components/select/SelectConstituenta.tsx index 8cef8cfb..56a200fe 100644 --- a/rsconcept/frontend/src/components/select/SelectConstituenta.tsx +++ b/rsconcept/frontend/src/components/select/SelectConstituenta.tsx @@ -10,10 +10,10 @@ import { matchConstituenta } from '@/models/rsformAPI'; import { describeConstituenta, describeConstituentaTerm } from '@/utils/labels'; interface SelectConstituentaProps extends CProps.Styling { - items?: IConstituenta[]; value?: IConstituenta; - onSelectValue: (newValue?: IConstituenta) => void; + onChange: (newValue?: IConstituenta) => void; + items?: IConstituenta[]; placeholder?: string; noBorder?: boolean; } @@ -22,7 +22,7 @@ function SelectConstituenta({ className, items, value, - onSelectValue, + onChange, placeholder = 'Выберите конституенту', ...restProps }: SelectConstituentaProps) { @@ -42,7 +42,7 @@ function SelectConstituenta({ className={clsx('text-ellipsis', className)} options={options} value={value ? { value: value.id, label: `${value.alias}: ${describeConstituentaTerm(value)}` } : null} - onChange={data => onSelectValue(items?.find(cst => cst.id === data?.value))} + onChange={data => onChange(items?.find(cst => cst.id === data?.value))} // @ts-expect-error: TODO: use type definitions from react-select in filter object filterOption={filter} placeholder={placeholder} diff --git a/rsconcept/frontend/src/components/select/SelectGraphFilter.tsx b/rsconcept/frontend/src/components/select/SelectGraphFilter.tsx index fdcf3ef2..3d7e4d8f 100644 --- a/rsconcept/frontend/src/components/select/SelectGraphFilter.tsx +++ b/rsconcept/frontend/src/components/select/SelectGraphFilter.tsx @@ -15,8 +15,8 @@ import { describeCstSource, labelCstSource } from '@/utils/labels'; interface SelectGraphFilterProps extends CProps.Styling { value: DependencyMode; - dense?: boolean; onChange: (value: DependencyMode) => void; + dense?: boolean; } function SelectGraphFilter({ value, dense, onChange, ...restProps }: SelectGraphFilterProps) { diff --git a/rsconcept/frontend/src/components/select/SelectLibraryItem.tsx b/rsconcept/frontend/src/components/select/SelectLibraryItem.tsx index 9e692b1f..ad4940ce 100644 --- a/rsconcept/frontend/src/components/select/SelectLibraryItem.tsx +++ b/rsconcept/frontend/src/components/select/SelectLibraryItem.tsx @@ -10,7 +10,7 @@ import { matchLibraryItem } from '@/models/libraryAPI'; interface SelectLibraryItemProps extends CProps.Styling { items?: ILibraryItem[]; value?: ILibraryItem; - onSelectValue: (newValue?: ILibraryItem) => void; + onChange: (newValue?: ILibraryItem) => void; placeholder?: string; noBorder?: boolean; @@ -20,7 +20,7 @@ function SelectLibraryItem({ className, items, value, - onSelectValue, + onChange, placeholder = 'Выберите схему', ...restProps }: SelectLibraryItemProps) { @@ -40,7 +40,7 @@ function SelectLibraryItem({ className={clsx('text-ellipsis', className)} options={options} value={value ? { value: value.id, label: `${value.alias}: ${value.title}` } : null} - onChange={data => onSelectValue(items?.find(cst => cst.id === data?.value))} + onChange={data => onChange(items?.find(cst => cst.id === data?.value))} // @ts-expect-error: TODO: use type definitions from react-select in filter object filterOption={filter} placeholder={placeholder} diff --git a/rsconcept/frontend/src/components/select/SelectLocation.tsx b/rsconcept/frontend/src/components/select/SelectLocation.tsx index 4a610d7b..0bbcba3d 100644 --- a/rsconcept/frontend/src/components/select/SelectLocation.tsx +++ b/rsconcept/frontend/src/components/select/SelectLocation.tsx @@ -12,9 +12,10 @@ import { labelFolderNode } from '@/utils/labels'; interface SelectLocationProps extends CProps.Styling { value: string; + onClick: (event: CProps.EventMouse, target: FolderNode) => void; + prefix: string; dense?: boolean; - onClick: (event: CProps.EventMouse, target: FolderNode) => void; } function SelectLocation({ value, dense, prefix, onClick, className, style }: SelectLocationProps) { diff --git a/rsconcept/frontend/src/components/select/SelectLocationContext.tsx b/rsconcept/frontend/src/components/select/SelectLocationContext.tsx index 32d268b9..662042ec 100644 --- a/rsconcept/frontend/src/components/select/SelectLocationContext.tsx +++ b/rsconcept/frontend/src/components/select/SelectLocationContext.tsx @@ -14,10 +14,9 @@ import SelectLocation from './SelectLocation'; interface SelectLocationContextProps extends CProps.Styling { value: string; + onChange: (newValue: string) => void; title?: string; stretchTop?: boolean; - - onChange: (newValue: string) => void; } function SelectLocationContext({ diff --git a/rsconcept/frontend/src/components/select/SelectMatchMode.tsx b/rsconcept/frontend/src/components/select/SelectMatchMode.tsx index 8f7c24b4..11fe79a3 100644 --- a/rsconcept/frontend/src/components/select/SelectMatchMode.tsx +++ b/rsconcept/frontend/src/components/select/SelectMatchMode.tsx @@ -15,8 +15,8 @@ import { describeCstMatchMode, labelCstMatchMode } from '@/utils/labels'; interface SelectMatchModeProps extends CProps.Styling { value: CstMatchMode; - dense?: boolean; onChange: (value: CstMatchMode) => void; + dense?: boolean; } function SelectMatchMode({ value, dense, onChange, ...restProps }: SelectMatchModeProps) { diff --git a/rsconcept/frontend/src/components/select/SelectMultiGrammeme.tsx b/rsconcept/frontend/src/components/select/SelectMultiGrammeme.tsx index e35e600a..9dc60669 100644 --- a/rsconcept/frontend/src/components/select/SelectMultiGrammeme.tsx +++ b/rsconcept/frontend/src/components/select/SelectMultiGrammeme.tsx @@ -10,11 +10,11 @@ interface SelectMultiGrammemeProps extends Omit, 'value' | 'onChange'>, CProps.Styling { value: IGrammemeOption[]; - onChangeValue: (newValue: IGrammemeOption[]) => void; + onChange: (newValue: IGrammemeOption[]) => void; placeholder?: string; } -function SelectMultiGrammeme({ value, onChangeValue, ...restProps }: SelectMultiGrammemeProps) { +function SelectMultiGrammeme({ value, onChange, ...restProps }: SelectMultiGrammemeProps) { const [options, setOptions] = useState([]); useEffect(() => { @@ -28,7 +28,7 @@ function SelectMultiGrammeme({ value, onChangeValue, ...restProps }: SelectMulti onChangeValue([...newValue].sort(compareGrammemeOptions))} + onChange={newValue => onChange([...newValue].sort(compareGrammemeOptions))} {...restProps} /> ); diff --git a/rsconcept/frontend/src/components/select/SelectOperation.tsx b/rsconcept/frontend/src/components/select/SelectOperation.tsx index c42946f5..d85cace7 100644 --- a/rsconcept/frontend/src/components/select/SelectOperation.tsx +++ b/rsconcept/frontend/src/components/select/SelectOperation.tsx @@ -10,7 +10,7 @@ import { matchOperation } from '@/models/ossAPI'; interface SelectOperationProps extends CProps.Styling { items?: IOperation[]; value?: IOperation; - onSelectValue: (newValue?: IOperation) => void; + onChange: (newValue?: IOperation) => void; placeholder?: string; noBorder?: boolean; @@ -20,7 +20,7 @@ function SelectOperation({ className, items, value, - onSelectValue, + onChange, placeholder = 'Выберите операцию', ...restProps }: SelectOperationProps) { @@ -40,7 +40,7 @@ function SelectOperation({ className={clsx('text-ellipsis', className)} options={options} value={value ? { value: value.id, label: `${value.alias}: ${value.title}` } : null} - onChange={data => onSelectValue(items?.find(cst => cst.id === data?.value))} + onChange={data => onChange(items?.find(cst => cst.id === data?.value))} // @ts-expect-error: TODO: use type definitions from react-select in filter object filterOption={filter} placeholder={placeholder} diff --git a/rsconcept/frontend/src/components/select/SelectUser.tsx b/rsconcept/frontend/src/components/select/SelectUser.tsx index 423eab08..cdf5f3ca 100644 --- a/rsconcept/frontend/src/components/select/SelectUser.tsx +++ b/rsconcept/frontend/src/components/select/SelectUser.tsx @@ -11,7 +11,7 @@ import { matchUser } from '@/models/userAPI'; interface SelectUserProps extends CProps.Styling { value?: UserID; - onSelectValue: (newValue: UserID) => void; + onChange: (newValue: UserID) => void; filter?: (userID: UserID) => boolean; placeholder?: string; @@ -22,7 +22,7 @@ function SelectUser({ className, filter, value, - onSelectValue, + onChange, placeholder = 'Выберите пользователя', ...restProps }: SelectUserProps) { @@ -46,7 +46,7 @@ function SelectUser({ options={options} value={value ? { value: value, label: getUserLabel(value) } : null} onChange={data => { - if (data?.value !== undefined) onSelectValue(data.value); + if (data?.value !== undefined) onChange(data.value); }} // @ts-expect-error: TODO: use type definitions from react-select in filter object filterOption={filterLabel} diff --git a/rsconcept/frontend/src/components/select/SelectVersion.tsx b/rsconcept/frontend/src/components/select/SelectVersion.tsx index e5419ca5..5ca00ee6 100644 --- a/rsconcept/frontend/src/components/select/SelectVersion.tsx +++ b/rsconcept/frontend/src/components/select/SelectVersion.tsx @@ -11,13 +11,13 @@ interface SelectVersionProps extends CProps.Styling { id?: string; items?: IVersionInfo[]; value?: VersionID; - onSelectValue: (newValue?: VersionID) => void; + onChange: (newValue?: VersionID) => void; placeholder?: string; noBorder?: boolean; } -function SelectVersion({ id, className, items, value, onSelectValue, ...restProps }: SelectVersionProps) { +function SelectVersion({ id, className, items, value, onChange, ...restProps }: SelectVersionProps) { const options = [ { value: undefined, @@ -40,7 +40,7 @@ function SelectVersion({ id, className, items, value, onSelectValue, ...restProp className={clsx('min-w-[12rem] text-ellipsis', className)} options={options} value={{ value: value, label: valueLabel }} - onChange={data => onSelectValue(data?.value)} + onChange={data => onChange(data?.value)} {...restProps} /> ); diff --git a/rsconcept/frontend/src/components/select/SelectWordForm.tsx b/rsconcept/frontend/src/components/select/SelectWordForm.tsx index 3ede7b70..e7129968 100644 --- a/rsconcept/frontend/src/components/select/SelectWordForm.tsx +++ b/rsconcept/frontend/src/components/select/SelectWordForm.tsx @@ -10,16 +10,16 @@ import { prefixes } from '@/utils/constants'; import { DefaultWordForms, IGrammemeOption, SelectorGrammemes } from '@/utils/selectors'; interface SelectWordFormProps extends CProps.Styling { - selected: IGrammemeOption[]; - setSelected: React.Dispatch>; + value: IGrammemeOption[]; + onChange: React.Dispatch>; } -function SelectWordForm({ selected, setSelected, className, ...restProps }: SelectWordFormProps) { +function SelectWordForm({ value, onChange, className, ...restProps }: SelectWordFormProps) { const handleSelect = useCallback( (grams: Grammeme[]) => { - setSelected(SelectorGrammemes.filter(({ value }) => grams.includes(value as Grammeme))); + onChange(SelectorGrammemes.filter(({ value }) => grams.includes(value as Grammeme))); }, - [setSelected] + [onChange] ); return ( @@ -30,7 +30,7 @@ function SelectWordForm({ selected, setSelected, className, ...restProps }: Sele text={data.text} example={data.example} grams={data.grams} - isSelected={data.grams.every(gram => selected.find(item => (item.value as Grammeme) === gram))} + isSelected={data.grams.every(gram => value.find(item => (item.value as Grammeme) === gram))} onSelectGrams={handleSelect} /> ))} diff --git a/rsconcept/frontend/src/components/select/ToolbarGraphSelection.tsx b/rsconcept/frontend/src/components/select/ToolbarGraphSelection.tsx index ff8e58fd..ca1c7707 100644 --- a/rsconcept/frontend/src/components/select/ToolbarGraphSelection.tsx +++ b/rsconcept/frontend/src/components/select/ToolbarGraphSelection.tsx @@ -17,37 +17,37 @@ import MiniButton from '@/components/ui/MiniButton'; import { Graph } from '@/models/Graph'; interface ToolbarGraphSelectionProps extends CProps.Styling { + value: number[]; + onChange: (newSelection: number[]) => void; graph: Graph; - selected: number[]; isCore: (item: number) => boolean; isOwned?: (item: number) => boolean; - setSelected: (newSelection: number[]) => void; emptySelection?: boolean; } function ToolbarGraphSelection({ className, graph, - selected, + value: selected, isCore, isOwned, - setSelected, + onChange, emptySelection, ...restProps }: ToolbarGraphSelectionProps) { const handleSelectCore = useCallback(() => { const core = [...graph.nodes.keys()].filter(isCore); - setSelected([...core, ...graph.expandInputs(core)]); - }, [setSelected, graph, isCore]); + onChange([...core, ...graph.expandInputs(core)]); + }, [onChange, graph, isCore]); const handleSelectOwned = useCallback( - () => (isOwned ? setSelected([...graph.nodes.keys()].filter(isOwned)) : undefined), - [setSelected, graph, isOwned] + () => (isOwned ? onChange([...graph.nodes.keys()].filter(isOwned)) : undefined), + [onChange, graph, isOwned] ); const handleInvertSelection = useCallback( - () => setSelected([...graph.nodes.keys()].filter(item => !selected.includes(item))), - [setSelected, selected, graph] + () => onChange([...graph.nodes.keys()].filter(item => !selected.includes(item))), + [onChange, selected, graph] ); return ( @@ -55,37 +55,37 @@ function ToolbarGraphSelection({ } - onClick={() => setSelected([])} + onClick={() => onChange([])} disabled={emptySelection} /> } - onClick={() => setSelected([...selected, ...graph.expandAllInputs(selected)])} + onClick={() => onChange([...selected, ...graph.expandAllInputs(selected)])} disabled={emptySelection} /> } - onClick={() => setSelected([...selected, ...graph.expandAllOutputs(selected)])} + onClick={() => onChange([...selected, ...graph.expandAllOutputs(selected)])} disabled={emptySelection} /> } - onClick={() => setSelected(graph.maximizePart(selected))} + onClick={() => onChange(graph.maximizePart(selected))} disabled={emptySelection} /> } - onClick={() => setSelected([...selected, ...graph.expandInputs(selected)])} + onClick={() => onChange([...selected, ...graph.expandInputs(selected)])} disabled={emptySelection} /> } - onClick={() => setSelected([...selected, ...graph.expandOutputs(selected)])} + onClick={() => onChange([...selected, ...graph.expandOutputs(selected)])} disabled={emptySelection} /> { +export interface CheckboxProps extends Omit { /** Label to display next to the checkbox. */ label?: string; @@ -15,7 +15,7 @@ export interface CheckboxProps extends Omit value?: boolean; /** Callback to set the `value`. */ - setValue?: (newValue: boolean) => void; + onChange?: (newValue: boolean) => void; } /** @@ -29,18 +29,18 @@ function Checkbox({ hideTitle, className, value, - setValue, + onChange, ...restProps }: CheckboxProps) { - const cursor = disabled ? 'cursor-arrow' : setValue ? 'cursor-pointer' : ''; + const cursor = disabled ? 'cursor-arrow' : onChange ? 'cursor-pointer' : ''; function handleClick(event: CProps.EventMouse): void { event.preventDefault(); event.stopPropagation(); - if (disabled || !setValue) { + if (disabled || !onChange) { return; } - setValue(!value); + onChange(!value); } return ( diff --git a/rsconcept/frontend/src/components/ui/CheckboxTristate.tsx b/rsconcept/frontend/src/components/ui/CheckboxTristate.tsx index 35a98936..95272f5e 100644 --- a/rsconcept/frontend/src/components/ui/CheckboxTristate.tsx +++ b/rsconcept/frontend/src/components/ui/CheckboxTristate.tsx @@ -6,12 +6,12 @@ import { globals } from '@/utils/constants'; import { CheckboxProps } from './Checkbox'; -export interface CheckboxTristateProps extends Omit { +export interface CheckboxTristateProps extends Omit { /** Current value - `null`, `true` or `false`. */ value: boolean | null; /** Callback to set the `value`. */ - setValue?: (newValue: boolean | null) => void; + onChange?: (newValue: boolean | null) => void; } /** @@ -25,23 +25,23 @@ function CheckboxTristate({ hideTitle, className, value, - setValue, + onChange, ...restProps }: CheckboxTristateProps) { - const cursor = disabled ? 'cursor-arrow' : setValue ? 'cursor-pointer' : ''; + const cursor = disabled ? 'cursor-arrow' : onChange ? 'cursor-pointer' : ''; function handleClick(event: CProps.EventMouse): void { event.preventDefault(); event.stopPropagation(); - if (disabled || !setValue) { + if (disabled || !onChange) { return; } if (value === false) { - setValue(null); + onChange(null); } else if (value === null) { - setValue(true); + onChange(true); } else { - setValue(false); + onChange(false); } } diff --git a/rsconcept/frontend/src/components/ui/DataTable/SelectAll.tsx b/rsconcept/frontend/src/components/ui/DataTable/SelectAll.tsx index a33394f0..6489bdc6 100644 --- a/rsconcept/frontend/src/components/ui/DataTable/SelectAll.tsx +++ b/rsconcept/frontend/src/components/ui/DataTable/SelectAll.tsx @@ -22,7 +22,7 @@ function SelectAll({ table, resetLastSelected }: SelectAllProps) { value={ !table.getIsAllPageRowsSelected() && table.getIsSomePageRowsSelected() ? null : table.getIsAllPageRowsSelected() } - setValue={handleChange} + onChange={handleChange} /> ); } diff --git a/rsconcept/frontend/src/components/ui/DataTable/SelectRow.tsx b/rsconcept/frontend/src/components/ui/DataTable/SelectRow.tsx index 28d1f521..c45216bb 100644 --- a/rsconcept/frontend/src/components/ui/DataTable/SelectRow.tsx +++ b/rsconcept/frontend/src/components/ui/DataTable/SelectRow.tsx @@ -15,7 +15,7 @@ function SelectRow({ row, onChangeLastSelected }: SelectRowProps) row.toggleSelected(value); } - return ; + return ; } export default SelectRow; diff --git a/rsconcept/frontend/src/components/ui/DropdownCheckbox.tsx b/rsconcept/frontend/src/components/ui/DropdownCheckbox.tsx index 63b0dace..5235852e 100644 --- a/rsconcept/frontend/src/components/ui/DropdownCheckbox.tsx +++ b/rsconcept/frontend/src/components/ui/DropdownCheckbox.tsx @@ -3,7 +3,7 @@ import clsx from 'clsx'; import Checkbox, { CheckboxProps } from './Checkbox'; /** Animated {@link Checkbox} inside a {@link Dropdown} item. */ -function DropdownCheckbox({ setValue, disabled, ...restProps }: CheckboxProps) { +function DropdownCheckbox({ onChange: setValue, disabled, ...restProps }: CheckboxProps) { return (
- +
); } diff --git a/rsconcept/frontend/src/components/ui/SelectTree.tsx b/rsconcept/frontend/src/components/ui/SelectTree.tsx index 7e2ed1a0..59f3237b 100644 --- a/rsconcept/frontend/src/components/ui/SelectTree.tsx +++ b/rsconcept/frontend/src/components/ui/SelectTree.tsx @@ -19,7 +19,7 @@ interface SelectTreeProps extends CProps.Styling { prefix: string; /** Callback to be called when the value changes. */ - onChangeValue: (newItem: ItemType) => void; + onChange: (newItem: ItemType) => void; /** Callback providing the parent of the item. */ getParent: (item: ItemType) => ItemType; @@ -40,7 +40,7 @@ function SelectTree({ getParent, getLabel, getDescription, - onChangeValue, + onChange, prefix, ...restProps }: SelectTreeProps) { @@ -75,7 +75,7 @@ function SelectTree({ function handleSetValue(event: CProps.EventMouse, target: ItemType) { event.preventDefault(); event.stopPropagation(); - onChangeValue(target); + onChange(target); } return ( diff --git a/rsconcept/frontend/src/dialogs/DlgChangeInputSchema.tsx b/rsconcept/frontend/src/dialogs/DlgChangeInputSchema.tsx index 8c0bbaac..553d8b3a 100644 --- a/rsconcept/frontend/src/dialogs/DlgChangeInputSchema.tsx +++ b/rsconcept/frontend/src/dialogs/DlgChangeInputSchema.tsx @@ -61,7 +61,7 @@ function DlgChangeInputSchema() { items={sortedItems} itemType={LibraryItemType.RSFORM} value={selected} // prettier: split-line - onSelectValue={handleSelectLocation} + onChange={handleSelectLocation} rows={14} baseFilter={baseFilter} /> diff --git a/rsconcept/frontend/src/dialogs/DlgCloneLibraryItem.tsx b/rsconcept/frontend/src/dialogs/DlgCloneLibraryItem.tsx index 6568abd7..ae415000 100644 --- a/rsconcept/frontend/src/dialogs/DlgCloneLibraryItem.tsx +++ b/rsconcept/frontend/src/dialogs/DlgCloneLibraryItem.tsx @@ -6,7 +6,7 @@ import { useState } from 'react'; import { useConceptNavigation } from '@/app/Navigation/NavigationContext'; import { urls } from '@/app/urls'; import { useAuthSuspense } from '@/backend/auth/useAuth'; -import { IRSFormCloneDTO } from '@/backend/library/api'; +import { IRCloneLibraryItemDTO } from '@/backend/library/api'; import { useCloneItem } from '@/backend/library/useCloneItem'; import { VisibilityIcon } from '@/components/DomainIcons'; import SelectAccessPolicy from '@/components/select/SelectAccessPolicy'; @@ -59,7 +59,7 @@ function DlgCloneLibraryItem() { } function handleSubmit() { - const data: IRSFormCloneDTO = { + const data: IRCloneLibraryItemDTO = { id: base.id, item_type: base.item_type, title: title, @@ -137,7 +137,7 @@ function DlgCloneLibraryItem() { id='dlg_only_selected' label={`Только выбранные конституенты [${selected.length} из ${totalCount}]`} value={onlySelected} - setValue={value => setOnlySelected(value)} + onChange={value => setOnlySelected(value)} /> ); diff --git a/rsconcept/frontend/src/dialogs/DlgCreateOperation/TabInputOperation.tsx b/rsconcept/frontend/src/dialogs/DlgCreateOperation/TabInputOperation.tsx index 3cdb9d35..af724bdf 100644 --- a/rsconcept/frontend/src/dialogs/DlgCreateOperation/TabInputOperation.tsx +++ b/rsconcept/frontend/src/dialogs/DlgCreateOperation/TabInputOperation.tsx @@ -98,7 +98,7 @@ function TabInputOperation({ @@ -108,7 +108,7 @@ function TabInputOperation({ items={sortedItems} value={attachedID} itemType={LibraryItemType.RSFORM} - onSelectValue={onChangeAttachedID} + onChange={onChangeAttachedID} rows={8} baseFilter={baseFilter} /> diff --git a/rsconcept/frontend/src/dialogs/DlgCreateOperation/TabSynthesisOperation.tsx b/rsconcept/frontend/src/dialogs/DlgCreateOperation/TabSynthesisOperation.tsx index 810e98e7..6ff99db8 100644 --- a/rsconcept/frontend/src/dialogs/DlgCreateOperation/TabSynthesisOperation.tsx +++ b/rsconcept/frontend/src/dialogs/DlgCreateOperation/TabSynthesisOperation.tsx @@ -57,7 +57,7 @@ function TabSynthesisOperation({ ); diff --git a/rsconcept/frontend/src/dialogs/DlgCreateVersion.tsx b/rsconcept/frontend/src/dialogs/DlgCreateVersion.tsx index d4dc8abf..fc5c9787 100644 --- a/rsconcept/frontend/src/dialogs/DlgCreateVersion.tsx +++ b/rsconcept/frontend/src/dialogs/DlgCreateVersion.tsx @@ -64,7 +64,7 @@ function DlgCreateVersion() { id='dlg_only_selected' label={`Только выбранные конституенты [${selected.length} из ${totalCount}]`} value={onlySelected} - setValue={value => setOnlySelected(value)} + onChange={value => setOnlySelected(value)} /> ); diff --git a/rsconcept/frontend/src/dialogs/DlgCstTemplate/TabArguments.tsx b/rsconcept/frontend/src/dialogs/DlgCstTemplate/TabArguments.tsx index d499d69b..0a2256c5 100644 --- a/rsconcept/frontend/src/dialogs/DlgCstTemplate/TabArguments.tsx +++ b/rsconcept/frontend/src/dialogs/DlgCstTemplate/TabArguments.tsx @@ -190,7 +190,7 @@ function TabArguments({ state, schema, partialUpdate }: TabArgumentsProps) { id='dlg_argument_picker' value={selectedCst} data={schema.items} - onSelectValue={handleSelectConstituenta} + onChange={handleSelectConstituenta} prefixID={prefixes.cst_modal_list} rows={7} /> diff --git a/rsconcept/frontend/src/dialogs/DlgCstTemplate/TabTemplate.tsx b/rsconcept/frontend/src/dialogs/DlgCstTemplate/TabTemplate.tsx index 175e58a0..0fd986ec 100644 --- a/rsconcept/frontend/src/dialogs/DlgCstTemplate/TabTemplate.tsx +++ b/rsconcept/frontend/src/dialogs/DlgCstTemplate/TabTemplate.tsx @@ -102,7 +102,7 @@ function TabTemplate({ state, partialUpdate, templateSchema }: TabTemplateProps) id='dlg_template_picker' value={state.prototype} data={filteredData} - onSelectValue={cst => partialUpdate({ prototype: cst })} + onChange={cst => partialUpdate({ prototype: cst })} prefixID={prefixes.cst_template_ist} className='rounded-t-none' rows={8} diff --git a/rsconcept/frontend/src/dialogs/DlgDeleteCst/DlgDeleteCst.tsx b/rsconcept/frontend/src/dialogs/DlgDeleteCst/DlgDeleteCst.tsx index 7447120c..3c8b3b64 100644 --- a/rsconcept/frontend/src/dialogs/DlgDeleteCst/DlgDeleteCst.tsx +++ b/rsconcept/frontend/src/dialogs/DlgDeleteCst/DlgDeleteCst.tsx @@ -55,7 +55,7 @@ function DlgDeleteCst() { label='Удалить зависимые конституенты' className='mb-2' value={expandOut} - setValue={value => setExpandOut(value)} + onChange={value => setExpandOut(value)} /> {hasInherited ? (

Внимание! Выбранные конституенты имеют наследников в ОСС

diff --git a/rsconcept/frontend/src/dialogs/DlgDeleteOperation.tsx b/rsconcept/frontend/src/dialogs/DlgDeleteOperation.tsx index fa48a1c4..f432469e 100644 --- a/rsconcept/frontend/src/dialogs/DlgDeleteOperation.tsx +++ b/rsconcept/frontend/src/dialogs/DlgDeleteOperation.tsx @@ -39,7 +39,7 @@ function DlgDeleteOperation() { label='Сохранить наследованные конституенты' titleHtml='Наследованные конституенты
превратятся в дописанные' value={keepConstituents} - setValue={setKeepConstituents} + onChange={setKeepConstituents} disabled={target.result === null} /> diff --git a/rsconcept/frontend/src/dialogs/DlgEditEditors/DlgEditEditors.tsx b/rsconcept/frontend/src/dialogs/DlgEditEditors/DlgEditEditors.tsx index 7cef50fd..3fd7bc3c 100644 --- a/rsconcept/frontend/src/dialogs/DlgEditEditors/DlgEditEditors.tsx +++ b/rsconcept/frontend/src/dialogs/DlgEditEditors/DlgEditEditors.tsx @@ -63,7 +63,7 @@ function DlgEditEditors() { !selected.includes(id)} value={undefined} - onSelectValue={onAddEditor} + onChange={onAddEditor} className='w-[25rem]' /> diff --git a/rsconcept/frontend/src/dialogs/DlgEditOperation/TabArguments.tsx b/rsconcept/frontend/src/dialogs/DlgEditOperation/TabArguments.tsx index 596dd8fd..d474c312 100644 --- a/rsconcept/frontend/src/dialogs/DlgEditOperation/TabArguments.tsx +++ b/rsconcept/frontend/src/dialogs/DlgEditOperation/TabArguments.tsx @@ -19,7 +19,7 @@ function TabArguments({ oss, inputs, target, setInputs }: TabArgumentsProps) {
); diff --git a/rsconcept/frontend/src/dialogs/DlgEditOperation/TabSynthesis.tsx b/rsconcept/frontend/src/dialogs/DlgEditOperation/TabSynthesis.tsx index 10998c5a..c4b61825 100644 --- a/rsconcept/frontend/src/dialogs/DlgEditOperation/TabSynthesis.tsx +++ b/rsconcept/frontend/src/dialogs/DlgEditOperation/TabSynthesis.tsx @@ -29,8 +29,8 @@ function TabSynthesis({ schemas={schemas} prefixID={prefixes.dlg_cst_substitutes_list} rows={8} - substitutions={substitutions} - setSubstitutions={setSubstitutions} + value={substitutions} + onChange={setSubstitutions} suggestions={suggestions} />