"use client"; /** * Controlled meaning/signals field set for a core-value chip. Rendered both * by `core-values` (custom-rule selection step) and `final-review` (chip * edit modal). Holds no state — the parent owns the draft and decides when * to persist (`updateState`) or discard. */ import { memo, useCallback } from "react"; import { useMessages } from "../../../../contexts/MessagesContext"; import ModalTextAreaField from "../ModalTextAreaField"; import type { CoreValueDetailEntry } from "../../types"; export interface CoreValueEditFieldsProps { value: CoreValueDetailEntry; onChange: (_next: CoreValueDetailEntry) => void; /** View mode until the user taps **Customize**. */ readOnly?: boolean; } function CoreValueEditFieldsComponent({ value, onChange, readOnly = false, }: CoreValueEditFieldsProps) { const m = useMessages(); const t = m.create.customRule.coreValues.detailModal; const patch = useCallback( ( key: K, next: CoreValueDetailEntry[K], ) => { onChange({ ...value, [key]: next }); }, [value, onChange], ); return (
patch("meaning", v)} rows={4} disabled={readOnly} /> patch("signals", v)} rows={4} disabled={readOnly} />
); } CoreValueEditFieldsComponent.displayName = "CoreValueEditFields"; export default memo(CoreValueEditFieldsComponent);