From 78efdb874351acba42808cfc59a98f13af9c429e Mon Sep 17 00:00:00 2001 From: Ivan <8611739+IRBorisov@users.noreply.github.com> Date: Wed, 18 Jun 2025 00:16:27 +0300 Subject: [PATCH] F: Improve placeholder for RSExpressions --- .../frontend/src/features/rsform/labels.ts | 18 ++++++++++++++++++ .../editor-constituenta/form-constituenta.tsx | 12 +++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/rsconcept/frontend/src/features/rsform/labels.ts b/rsconcept/frontend/src/features/rsform/labels.ts index 1efee02f..ed26e614 100644 --- a/rsconcept/frontend/src/features/rsform/labels.ts +++ b/rsconcept/frontend/src/features/rsform/labels.ts @@ -137,6 +137,24 @@ export function getCstTypeShortcut(type: CstType) { } } +/** Generates placeholder for RS definition based on {@link CstType}. */ +export function getRSDefinitionPlaceholder(type: CstType): string { + switch (type) { + case CstType.STRUCTURED: + return 'Пример: ℬ(X1×D2)'; + case CstType.TERM: + return 'Пример: D{ξ∈S1 | Pr1(ξ)∩Pr2(ξ)=∅}'; + case CstType.THEOREM: + case CstType.AXIOM: + return 'Пример: D11=∅'; + case CstType.FUNCTION: + return 'Пример: [α∈X1, β∈ℬ(X1×X2)] Pr2(Fi1[{α}](β))'; + case CstType.PREDICATE: + return 'Пример: [α∈X1, β∈ℬ(X1)] α∈β & card(β)>1'; + } + return 'Формальное выражение'; +} + /** * Generates description for {@link TokenID}. */ diff --git a/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-constituenta/form-constituenta.tsx b/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-constituenta/form-constituenta.tsx index 0a61e7df..5dad5ea6 100644 --- a/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-constituenta/form-constituenta.tsx +++ b/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-constituenta/form-constituenta.tsx @@ -26,7 +26,7 @@ import { import { useMutatingRSForm } from '../../../backend/use-mutating-rsform'; import { useUpdateConstituenta } from '../../../backend/use-update-constituenta'; import { RefsInput } from '../../../components/refs-input'; -import { labelCstTypification, labelTypification } from '../../../labels'; +import { getRSDefinitionPlaceholder, labelCstTypification, labelTypification } from '../../../labels'; import { type IConstituenta, type IRSForm } from '../../../models/rsform'; import { isBaseSet, isBasicConcept, isFunctional } from '../../../models/rsform-api'; import { EditorRSExpression } from '../editor-rsexpression'; @@ -198,7 +198,7 @@ export function FormConstituenta({ disabled, id, toggleReset, schema, activeCst, id='cst_term' label='Термин' maxHeight='8rem' - placeholder='Обозначение для текстовых определений' + placeholder={disabled ? '' : 'Обозначение для текстовых определений'} schema={schema} onOpenEdit={onOpenEdit} value={field.value ?? ''} @@ -238,9 +238,7 @@ export function FormConstituenta({ disabled, id, toggleReset, schema, activeCst, ? 'Определение функции' : 'Формальное определение' } - placeholder={ - activeCst.cst_type !== CstType.STRUCTURED ? 'Родоструктурное выражение' : 'Типизация родовой структуры' - } + placeholder={disabled ? '' : getRSDefinitionPlaceholder(activeCst.cst_type)} value={field.value ?? ''} activeCst={activeCst} toggleReset={toggleReset} @@ -261,7 +259,7 @@ export function FormConstituenta({ disabled, id, toggleReset, schema, activeCst, ) : null}