署名記録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

表は横にスクロールできます
プロパティ初期値説明
valueSignedRecordValue-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.
signerIdstring-The signing user's id — recorded as signedBy and each addendum's author.
canSignbooleantrueWhether the record can be signed now (required sections filled).
requireAddendumReasonbooleantrueRequire a reason on each addendum.
formatTime(iso: string) => ReactNode-Format an ISO timestamp for display. Default a deterministic YYYY/MM/DD HH:mm.
labelsSignedRecordLabels-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