署名記録SignedRecordExperimental
Append-only signed legal record: a draft body that, once signed, locks read-only (recording signer + timestamp) and can only be amended by a timestamped, authored addendum — never edited. Renders the draft/signed badge, the locked affordance, the signer audit line, an addendum composer and chain, and an optional CoSign gate. For clinical notes, discharge summaries, operative records and any signed/audited document.
プレビュー
Props
表は横にスクロールできます
| プロパティ | 型 | 初期値 | 説明 |
|---|---|---|---|
| value | SignedRecordValue | - | Controlled state: { status: 'draft' | 'signed', signedBy?, signedAt?, addenda: SignedRecordAddendum[] }. |
| onChange | (value: SignedRecordValue) => void | - | Notified when the record is signed or an addendum is appended. |
| children | ({ readOnly }) => ReactNode | - | Render prop for the document body. readOnly is true once signed — render the locked view vs the editable fields. |
| signerId | string | - | The signing user's id — recorded as signedBy and each addendum's author. |
| canSign | boolean | true | Whether the record can be signed now (required sections filled). |
| requireAddendumReason | boolean | true | Require a reason on each addendum. |
| formatTime | (iso: string) => ReactNode | - | Format an ISO timestamp for display. Default a deterministic YYYY/MM/DD HH:mm. |
| labels | SignedRecordLabels | - | Localized strings (draft / signed / sign / locked / addendum composer …). |
Usage
import { SignedRecord, Textarea, type SignedRecordValue } from "@gunjo/ui"
const [record, setRecord] = useState<SignedRecordValue>({ status: "draft", addenda: [] })
<SignedRecord value={record} onChange={setRecord} signerId="dr-yamada" canSign={isComplete}>
{({ readOnly }) =>
readOnly
? <p>{body}</p> // signed: locked, read-only
: <Textarea value={body} onChange={onBodyChange} /> // draft: editable
}
</SignedRecord>
// draft → 署名・確定 locks it → only addenda (author + timestamp + reason) can be appended