'use client'; import { AnimatePresence } from 'framer-motion'; import { useLayoutEffect, useMemo, useState } from 'react'; import BadgeHelp from '@/components/man/BadgeHelp'; import RSInput from '@/components/RSInput'; import SelectSingle from '@/components/ui/SelectSingle'; import TextArea from '@/components/ui/TextArea'; import TextInput from '@/components/ui/TextInput'; import AnimateFade from '@/components/wrap/AnimateFade'; import { HelpTopic } from '@/models/miscellaneous'; import { CstType, ICstCreateData, IRSForm } from '@/models/rsform'; import { generateAlias, isBaseSet, isBasicConcept, isFunctional, validateNewAlias } from '@/models/rsformAPI'; import { labelCstType } from '@/utils/labels'; import { SelectorCstType } from '@/utils/selectors'; interface FormCreateCstProps { schema: IRSForm; state: ICstCreateData; partialUpdate: React.Dispatch>; setValidated: React.Dispatch>; } function FormCreateCst({ schema, state, partialUpdate, setValidated }: FormCreateCstProps) { const [forceComment, setForceComment] = useState(false); const isBasic = useMemo(() => isBasicConcept(state.cst_type), [state]); const isElementary = useMemo(() => isBaseSet(state.cst_type), [state]); const showConvention = useMemo(() => !!state.convention || forceComment || isBasic, [state, forceComment, isBasic]); useLayoutEffect(() => { partialUpdate({ alias: generateAlias(state.cst_type, schema) }); setForceComment(false); }, [state.cst_type, partialUpdate, schema]); useLayoutEffect(() => { setValidated(validateNewAlias(state.alias, state.cst_type, schema)); }, [state.alias, state.cst_type, schema, setValidated]); return (
partialUpdate({ cst_type: data?.value ?? CstType.BASE })} /> partialUpdate({ alias: event.target.value })} />