{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "openlmis-reason-editor-page",
  "title": "Reason Editor Page",
  "description": "Mock stock reason editor with assignment pairs, partial-save feedback and discard confirmation.",
  "dependencies": [
    "@tanstack/react-form@^1",
    "lucide-react@^1",
    "zod@^4",
    "@base-ui/react@^1"
  ],
  "registryDependencies": [
    "alert",
    "button",
    "empty",
    "field",
    "skeleton",
    "spinner",
    "switch",
    "table",
    "https://registry.soldevelo.com/r/openlmis-callout.json",
    "https://registry.soldevelo.com/r/openlmis-data-table.json",
    "https://registry.soldevelo.com/r/openlmis-discard-changes-dialog.json",
    "https://registry.soldevelo.com/r/openlmis-form-dialog.json",
    "https://registry.soldevelo.com/r/openlmis-form-fields.json",
    "https://registry.soldevelo.com/r/openlmis-page-breadcrumbs.json",
    "https://registry.soldevelo.com/r/openlmis-workspace.json"
  ],
  "files": [
    {
      "path": "registry/templates/openlmis/reason-editor-page/components/mock-reason.ts",
      "content": "import type {\n  AssignmentOption,\n  ReasonAssignment,\n} from \"@/components/openlmis/reason-editor-page/reason-assignment\"\nimport type { ReasonValues } from \"@/components/openlmis/reason-editor-page/reason-form\"\n\nexport type MockReason = {\n  values: ReasonValues\n  assignments: ReasonAssignment[]\n}\n\nexport const MOCK_PROGRAMS: AssignmentOption[] = [\n  { id: \"family-planning\", name: \"Family Planning\" },\n  { id: \"essential-meds\", name: \"Essential Meds\" },\n  { id: \"new-program\", name: \"New Program\" },\n  { id: \"epi\", name: \"EPI\" },\n]\n\n/** Every facility type, so a saved row for an inactive one still has a name. */\nexport const MOCK_FACILITY_TYPES: AssignmentOption[] = [\n  { id: \"health-center\", name: \"Health Center\" },\n  { id: \"district-hospital\", name: \"District Hospital\" },\n  { id: \"district-store\", name: \"District Store\" },\n  { id: \"warehouse\", name: \"Warehouse\" },\n  { id: \"dispensary\", name: \"Dispensary\" },\n]\n\n/** Only active types are offered for a new row. */\nexport const MOCK_ACTIVE_FACILITY_TYPES = MOCK_FACILITY_TYPES.filter(\n  (type) => type.id !== \"dispensary\"\n)\n\n/** Tags other reasons use, suggested as the user types. */\nexport const MOCK_TAGS = [\n  \"adjustment\",\n  \"consumed\",\n  \"damaged\",\n  \"expired\",\n  \"receipts\",\n]\n\n/** Names other reasons already have. */\nexport const MOCK_TAKEN_NAMES = [\"Transfer Out\", \"Damage\", \"Expired\", \"Stolen\"]\n\nexport const MOCK_REASON: MockReason = {\n  values: {\n    name: \"Transfer In\",\n    category: \"TRANSFER\",\n    type: \"CREDIT\",\n    isFreeTextAllowed: false,\n    tags: [\"receipts\"],\n  },\n  assignments: [\n    {\n      programId: \"family-planning\",\n      facilityTypeId: \"health-center\",\n      show: true,\n    },\n    { programId: \"family-planning\", facilityTypeId: \"dispensary\", show: false },\n    {\n      programId: \"essential-meds\",\n      facilityTypeId: \"district-hospital\",\n      show: true,\n    },\n  ],\n}",
      "type": "registry:lib",
      "target": "components/openlmis/reason-editor-page/mock-reason.ts"
    },
    {
      "path": "registry/templates/openlmis/reason-editor-page/components/reason-assignment-dialog/reason-assignment-dialog.tsx",
      "content": "\"use client\"\n\nimport { revalidateLogic } from \"@tanstack/react-form\"\nimport { useMemo, useState } from \"react\"\n\nimport { Field, FieldGroup, FieldLabel } from \"@/components/ui/field\"\nimport {\n  FormDialog,\n  FormDialogBody,\n  FormDialogCancel,\n  FormDialogDescription,\n  FormDialogFooter,\n  FormDialogForm,\n  FormDialogHeader,\n  FormDialogSubmit,\n  FormDialogTitle,\n} from \"@/components/openlmis/form-dialog/form-dialog\"\nimport { useDialogTarget } from \"@/components/openlmis/form-dialog/use-dialog-target\"\nimport { useAppForm } from \"@/components/openlmis/form-fields/form\"\nimport { FieldSkeleton } from \"@/components/openlmis/form-fields/form-fields\"\n\nimport {\n  addAssignmentSchema,\n  type AssignmentOption,\n  EMPTY_ASSIGNMENT,\n  type ReasonAssignment,\n} from \"@/components/openlmis/reason-editor-page/reason-assignment\"\n\ntype ReasonAssignmentDialogProps = {\n  open: boolean\n  /** The reason's assignments, so a pair already listed is refused. */\n  rows: readonly ReasonAssignment[]\n  /** The programs and active facility types to pick from; skeletons show until set. */\n  programs: readonly AssignmentOption[] | undefined\n  facilityTypes: readonly AssignmentOption[] | undefined\n  /** Called with the new assignment; add it, then close. */\n  onAdd: (assignment: ReasonAssignment) => void\n  onClose: () => void\n}\n\n/** Offer a reason for one more program and facility type. */\nexport function ReasonAssignmentDialog({\n  open,\n  onClose,\n  ...props\n}: ReasonAssignmentDialogProps) {\n  const { shown, dialogProps } = useDialogTarget(open || undefined, onClose)\n\n  return (\n    <FormDialog {...dialogProps()}>\n      {shown && <AddAssignmentContent {...props} />}\n    </FormDialog>\n  )\n}\n\nfunction AddAssignmentHeader() {\n  return (\n    <FormDialogHeader>\n      <FormDialogTitle>Add Program And Facility Type</FormDialogTitle>\n      <FormDialogDescription>\n        Offer this reason for one more program and facility type.\n      </FormDialogDescription>\n    </FormDialogHeader>\n  )\n}\n\ntype ContentProps = Omit<ReasonAssignmentDialogProps, \"open\" | \"onClose\">\n\nfunction AddAssignmentContent({\n  programs,\n  facilityTypes,\n  ...props\n}: ContentProps) {\n  if (!programs || !facilityTypes) {\n    return (\n      <>\n        <AddAssignmentHeader />\n        <FormDialogBody>\n          <div aria-busy>\n            <FieldGroup>\n              <FieldSkeleton label=\"Program\" required />\n              <FieldSkeleton label=\"Facility Type\" required />\n              <Field orientation=\"horizontal\">\n                <div className=\"flex min-h-8 flex-1 items-center\">\n                  <FieldLabel>Show</FieldLabel>\n                </div>\n                {/* A plain element, since Skeleton owns its corner radius and the switch is round. */}\n                <div className=\"h-4.5 w-8 shrink-0 animate-pulse rounded-full bg-muted\" />\n              </Field>\n            </FieldGroup>\n          </div>\n        </FormDialogBody>\n        <FormDialogFooter>\n          <FormDialogCancel />\n          <FormDialogSubmit disabled>Add</FormDialogSubmit>\n        </FormDialogFooter>\n      </>\n    )\n  }\n  return (\n    <AddAssignmentForm\n      facilityTypes={facilityTypes}\n      programs={programs}\n      {...props}\n    />\n  )\n}\n\nconst byLabel = (a: { label: string }, b: { label: string }) =>\n  a.label.localeCompare(b.label)\n\nconst toItems = (options: readonly AssignmentOption[]) =>\n  options\n    .map((item) => ({ value: item.id, label: item.name }))\n    // oxlint-disable-next-line unicorn/no-array-sort -- sorts the new array without requiring ES2023\n    .sort(byLabel)\n\nfunction AddAssignmentForm({\n  rows,\n  programs,\n  facilityTypes,\n  onAdd,\n}: Omit<ContentProps, \"programs\" | \"facilityTypes\"> & {\n  programs: readonly AssignmentOption[]\n  facilityTypes: readonly AssignmentOption[]\n}) {\n  // The rows as the dialog opened, so the pair just added is not refused while it closes.\n  const [rowsAtOpen] = useState(rows)\n  const programItems = useMemo(() => toItems(programs), [programs])\n  const typeItems = useMemo(() => toItems(facilityTypes), [facilityTypes])\n  const schema = useMemo(() => addAssignmentSchema(rowsAtOpen), [rowsAtOpen])\n\n  const form = useAppForm({\n    defaultValues: EMPTY_ASSIGNMENT,\n    // Quiet until the first submit, then each field re-checks as it is corrected.\n    validationLogic: revalidateLogic({\n      mode: \"submit\",\n      modeAfterSubmission: \"change\",\n    }),\n    validators: { onDynamic: schema },\n    onSubmit: ({ value }) => onAdd(value),\n  })\n\n  return (\n    <FormDialogForm onSubmit={() => void form.handleSubmit()}>\n      <AddAssignmentHeader />\n      <FormDialogBody>\n        <FieldGroup>\n          <form.AppField name=\"programId\">\n            {(field) => (\n              <field.SelectField\n                items={programItems}\n                label=\"Program\"\n                required\n              />\n            )}\n          </form.AppField>\n          <form.AppField name=\"facilityTypeId\">\n            {(field) => (\n              <field.SelectField\n                items={typeItems}\n                label=\"Facility Type\"\n                required\n              />\n            )}\n          </form.AppField>\n          <form.AppField name=\"show\">\n            {(field) => (\n              <field.SwitchField\n                description=\"Show the reason in the requisition and stock adjustment forms.\"\n                label=\"Show\"\n              />\n            )}\n          </form.AppField>\n        </FieldGroup>\n      </FormDialogBody>\n      <FormDialogFooter>\n        <FormDialogCancel />\n        <FormDialogSubmit>Add</FormDialogSubmit>\n      </FormDialogFooter>\n    </FormDialogForm>\n  )\n}",
      "type": "registry:component",
      "target": "components/openlmis/reason-editor-page/reason-assignment-dialog.tsx"
    },
    {
      "path": "registry/templates/openlmis/reason-editor-page/components/reason-assignment-dialog/reason-assignment.ts",
      "content": "import { z } from \"zod\"\n\n/** A program or facility type: picked by id and shown by name. */\nexport type AssignmentOption = {\n  id: string\n  name: string\n}\n\n/** Where a reason is offered; `show` false keeps it assigned but out of the stock and requisition forms. */\nexport type ReasonAssignment = {\n  programId: string\n  facilityTypeId: string\n  show: boolean\n}\n\nexport type AssignmentRef = Pick<\n  ReasonAssignment,\n  \"programId\" | \"facilityTypeId\"\n>\n\nexport const assignmentKey = (ref: AssignmentRef) =>\n  `${ref.programId}|${ref.facilityTypeId}`\n\n/** The same program and facility type can be listed once, whatever its Show. */\nexport function addAssignmentSchema(rows: readonly AssignmentRef[]) {\n  const listed = new Set(rows.map(assignmentKey))\n  return z\n    .object({\n      programId: z.string().min(1, \"Choose a program.\"),\n      facilityTypeId: z.string().min(1, \"Choose a facility type.\"),\n      show: z.boolean(),\n    })\n    .refine((pair) => !listed.has(assignmentKey(pair)), {\n      message: \"This program and facility type are already listed.\",\n      path: [\"facilityTypeId\"],\n    })\n}\n\nexport const EMPTY_ASSIGNMENT: ReasonAssignment = {\n  programId: \"\",\n  facilityTypeId: \"\",\n  show: true,\n}\n\n/** Names an assignment's program and facility type; an unknown id shows as Unknown. */\nexport function assignmentNames(\n  programs: readonly AssignmentOption[],\n  facilityTypes: readonly AssignmentOption[]\n) {\n  const programNames = new Map(programs.map((item) => [item.id, item.name]))\n  const typeNames = new Map(facilityTypes.map((item) => [item.id, item.name]))\n  const program = (id: string) => programNames.get(id) ?? \"Unknown\"\n  const facilityType = (id: string) => typeNames.get(id) ?? \"Unknown\"\n  return {\n    program,\n    facilityType,\n    pair: (ref: AssignmentRef) =>\n      `${program(ref.programId)}, ${facilityType(ref.facilityTypeId)}`,\n  }\n}",
      "type": "registry:lib",
      "target": "components/openlmis/reason-editor-page/reason-assignment.ts"
    },
    {
      "path": "registry/templates/openlmis/reason-editor-page/components/reason-assignments/reason-assignments.tsx",
      "content": "\"use client\"\n\nimport { MapPinnedIcon, PlusIcon, Trash2Icon } from \"lucide-react\"\nimport { useMemo, useRef, useState } from \"react\"\n\nimport { Button } from \"@/components/ui/button\"\nimport {\n  Empty,\n  EmptyDescription,\n  EmptyHeader,\n  EmptyMedia,\n  EmptyTitle,\n} from \"@/components/ui/empty\"\nimport { Skeleton } from \"@/components/ui/skeleton\"\nimport { Switch } from \"@/components/ui/switch\"\nimport {\n  Table,\n  TableBody,\n  TableCell,\n  TableHead,\n  TableHeader,\n  TableRow,\n} from \"@/components/ui/table\"\nimport { DataTableCard } from \"@/components/blocks/openlmis/data-table/data-table\"\nimport {\n  type AssignmentOption,\n  assignmentKey,\n  assignmentNames,\n  type ReasonAssignment,\n} from \"@/components/openlmis/reason-editor-page/reason-assignment\"\nimport { ReasonAssignmentDialog } from \"@/components/openlmis/reason-editor-page/reason-assignment-dialog\"\n\ntype ReasonAssignmentsProps = {\n  /** Where the reason is offered; a skeleton shows until it is set. */\n  rows: readonly ReasonAssignment[] | undefined\n  /** Name the rows; a missing id shows as Unknown. */\n  programs: readonly AssignmentOption[] | undefined\n  /** Every facility type, naming the rows, including ones no longer active. */\n  facilityTypes: readonly AssignmentOption[] | undefined\n  /** The facility types Add offers; defaults to `facilityTypes`. */\n  activeFacilityTypes?: readonly AssignmentOption[] | undefined\n  /** Called with the rows after any change; keep them until the page saves. */\n  onRowsChange: (rows: ReasonAssignment[]) => void\n  readOnly?: boolean\n}\n\nconst NO_OPTIONS: readonly AssignmentOption[] = []\n\n/** The programs and facility types a reason is offered for, with Show and Remove. */\nexport function ReasonAssignments({\n  rows,\n  programs,\n  facilityTypes,\n  activeFacilityTypes = facilityTypes,\n  onRowsChange,\n  readOnly = false,\n}: ReasonAssignmentsProps) {\n  const table = useRef<HTMLDivElement>(null)\n  const addButton = useRef<HTMLButtonElement>(null)\n  const [adding, setAdding] = useState(false)\n  const names = useMemo(\n    () => assignmentNames(programs ?? NO_OPTIONS, facilityTypes ?? NO_OPTIONS),\n    [programs, facilityTypes]\n  )\n\n  if (!rows || !programs || !facilityTypes) {\n    return <ReasonAssignmentsSkeleton readOnly={readOnly} rows={rows?.length} />\n  }\n\n  const remove = (index: number) => {\n    onRowsChange(rows.filter((_, at) => at !== index))\n    // The pressed button is gone, so the next row's takes the focus, or Add.\n    requestAnimationFrame(() => {\n      const buttons =\n        table.current?.querySelectorAll<HTMLElement>(\"[data-remove-pair]\")\n      const next = buttons?.[Math.min(index, buttons.length - 1)]\n      ;(next ?? addButton.current)?.focus()\n    })\n  }\n\n  return (\n    <div className=\"flex flex-col gap-4\">\n      {!readOnly && (\n        <div className=\"flex justify-end\">\n          <Button\n            onClick={() => setAdding(true)}\n            ref={addButton}\n            variant=\"outline\"\n          >\n            <PlusIcon data-icon=\"inline-start\" />\n            Add Program And Facility Type\n          </Button>\n        </div>\n      )}\n      <ReasonAssignmentDialog\n        facilityTypes={activeFacilityTypes}\n        onAdd={(row) => {\n          onRowsChange([...rows, row])\n          setAdding(false)\n        }}\n        onClose={() => setAdding(false)}\n        open={adding}\n        programs={programs}\n        rows={rows}\n      />\n      <div ref={table}>\n        <DataTableCard>\n          {rows.length === 0 ? (\n            <AssignmentsEmpty />\n          ) : (\n            <Table>\n              <AssignmentsHeader />\n              <TableBody>\n                {rows.map((row, index) => {\n                  const pair = names.pair(row)\n                  return (\n                    <TableRow key={assignmentKey(row)}>\n                      <TableCell>\n                        <span\n                          className=\"font-medium whitespace-normal\"\n                          dir=\"auto\"\n                        >\n                          {names.program(row.programId)}\n                        </span>\n                      </TableCell>\n                      <TableCell>\n                        <span className=\"whitespace-normal\" dir=\"auto\">\n                          {names.facilityType(row.facilityTypeId)}\n                        </span>\n                      </TableCell>\n                      <TableCell>\n                        <Switch\n                          aria-label={`Show For ${pair}`}\n                          checked={row.show}\n                          disabled={readOnly}\n                          onCheckedChange={(show) =>\n                            onRowsChange(\n                              rows.map((item, at) =>\n                                at === index ? { ...item, show } : item\n                              )\n                            )\n                          }\n                        />\n                      </TableCell>\n                      <TableCell>\n                        {!readOnly && (\n                          <div className=\"flex justify-end\">\n                            <Button\n                              aria-label={`Remove ${pair}`}\n                              data-remove-pair\n                              onClick={() => remove(index)}\n                              size=\"icon-sm\"\n                              variant=\"destructive\"\n                            >\n                              <Trash2Icon />\n                            </Button>\n                          </div>\n                        )}\n                      </TableCell>\n                    </TableRow>\n                  )\n                })}\n              </TableBody>\n            </Table>\n          )}\n        </DataTableCard>\n      </div>\n    </div>\n  )\n}\n\nfunction AssignmentsEmpty() {\n  return (\n    <Empty>\n      <EmptyHeader>\n        <EmptyMedia variant=\"icon\">\n          <MapPinnedIcon />\n        </EmptyMedia>\n        <EmptyTitle>Not Offered Anywhere Yet</EmptyTitle>\n        <EmptyDescription>\n          Add a program and facility type to offer this reason there.\n        </EmptyDescription>\n      </EmptyHeader>\n    </Empty>\n  )\n}\n\nfunction AssignmentsHeader() {\n  return (\n    <TableHeader>\n      <TableRow>\n        <TableHead>Program</TableHead>\n        <TableHead>Facility Type</TableHead>\n        <TableHead>Show</TableHead>\n        <TableHead>\n          <span className=\"sr-only\">Actions</span>\n        </TableHead>\n      </TableRow>\n    </TableHeader>\n  )\n}\n\n/** As many placeholder rows as the reason has, or the empty state for none. */\nfunction ReasonAssignmentsSkeleton({\n  rows = 3,\n  readOnly,\n}: {\n  rows?: number | undefined\n  readOnly: boolean\n}) {\n  return (\n    <div aria-busy className=\"flex flex-col gap-4\">\n      {!readOnly && (\n        <div className=\"flex justify-end\">\n          <Button disabled variant=\"outline\">\n            <PlusIcon data-icon=\"inline-start\" />\n            Add Program And Facility Type\n          </Button>\n        </div>\n      )}\n      <DataTableCard>\n        {rows === 0 ? (\n          <AssignmentsEmpty />\n        ) : (\n          <Table>\n            <AssignmentsHeader />\n            <TableBody>\n              {Array.from({ length: rows }, (_, index) => (\n                // Placeholder rows have nothing else to key on.\n                <TableRow key={index}>\n                  <TableCell>\n                    <Skeleton className=\"h-4 w-28\" />\n                  </TableCell>\n                  <TableCell>\n                    <Skeleton className=\"h-4 w-24\" />\n                  </TableCell>\n                  <TableCell>\n                    <div className=\"h-4.5 w-8 animate-pulse rounded-full bg-muted\" />\n                  </TableCell>\n                  <TableCell>\n                    <div className=\"flex justify-end\">\n                      <Skeleton className=\"size-7\" />\n                    </div>\n                  </TableCell>\n                </TableRow>\n              ))}\n            </TableBody>\n          </Table>\n        )}\n      </DataTableCard>\n    </div>\n  )\n}",
      "type": "registry:component",
      "target": "components/openlmis/reason-editor-page/reason-assignments.tsx"
    },
    {
      "path": "registry/templates/openlmis/reason-editor-page/components/reason-editor-page.tsx",
      "content": "\"use client\"\n\nimport { AlertCircleIcon, MessageSquareTextIcon } from \"lucide-react\"\nimport { useEffect, useMemo, useRef, useState } from \"react\"\n\nimport { Alert, AlertDescription, AlertTitle } from \"@/components/ui/alert\"\nimport { Button } from \"@/components/ui/button\"\nimport { FieldDescription, FieldLegend, FieldSet } from \"@/components/ui/field\"\nimport { Spinner } from \"@/components/ui/spinner\"\nimport {\n  assignmentKey,\n  assignmentNames,\n  type ReasonAssignment,\n} from \"@/components/openlmis/reason-editor-page/reason-assignment\"\nimport { ReasonAssignments } from \"@/components/openlmis/reason-editor-page/reason-assignments\"\nimport {\n  EMPTY_REASON,\n  type ReasonValues,\n} from \"@/components/openlmis/reason-editor-page/reason-form\"\nimport { ReasonGeneralForm } from \"@/components/openlmis/reason-editor-page/reason-general-form\"\nimport {\n  Workspace,\n  WorkspaceContent,\n  WorkspaceDescription,\n  WorkspaceFooter,\n  WorkspaceHeader,\n  WorkspaceHeading,\n  WorkspaceIcon,\n  WorkspaceLayout,\n  WorkspaceTitle,\n} from \"@/components/blocks/openlmis/workspace\"\nimport { Callout } from \"@/components/openlmis/callout\"\nimport { DiscardChangesDialog } from \"@/components/openlmis/discard-changes-dialog\"\nimport { PageBreadcrumbs } from \"@/components/openlmis/page-breadcrumbs\"\n\nimport {\n  MOCK_ACTIVE_FACILITY_TYPES,\n  MOCK_FACILITY_TYPES,\n  MOCK_PROGRAMS,\n  MOCK_REASON,\n  MOCK_TAGS,\n  MOCK_TAKEN_NAMES,\n  type MockReason,\n} from \"@/components/openlmis/reason-editor-page/mock-reason\"\n\nconst FORM_ID = \"reason-form\"\n\ntype ReasonEditorPageProps = {\n  /** Start on a new, empty reason. */\n  adding?: boolean\n  /** Show the skeleton, as while the reason loads. */\n  loading?: boolean\n  /** Show Save as in progress. */\n  pending?: boolean\n  /** Mock outcome: every save fails. */\n  saveFails?: boolean\n  /** Mock outcome: the server refuses any changed name. */\n  refuseNames?: boolean\n  /** Mock outcome: the reason saves, but its new or changed places do not. */\n  placesFail?: boolean\n}\n\nconst NEW_REASON: MockReason = { values: EMPTY_REASON, assignments: [] }\n\nconst LOOKUPS = { tags: MOCK_TAGS }\n\nconst NAMES = assignmentNames(MOCK_PROGRAMS, MOCK_FACILITY_TYPES)\n\n/** Rows that are new, or whose Show changed, since the last save. */\nfunction unsavedAssignments(\n  rows: readonly ReasonAssignment[],\n  saved: readonly ReasonAssignment[]\n) {\n  const stored = new Map(saved.map((row) => [assignmentKey(row), row]))\n  return rows.filter((row) => stored.get(assignmentKey(row))?.show !== row.show)\n}\n\nconst sameAssignments = (\n  rows: readonly ReasonAssignment[],\n  saved: readonly ReasonAssignment[]\n) =>\n  rows.length === saved.length && unsavedAssignments(rows, saved).length === 0\n\ntype Notice = { title: string; description: string }\n\n/** Focuses the first invalid field, waiting for it to render if needed. */\nfunction focusFirstError(container: HTMLElement) {\n  const focus = () => {\n    const field = container.querySelector<HTMLElement>('[aria-invalid=\"true\"]')\n    field?.focus()\n    return Boolean(field)\n  }\n  if (focus()) return () => {}\n  const observer = new MutationObserver(() => {\n    if (focus()) observer.disconnect()\n  })\n  observer.observe(container, {\n    attributes: true,\n    attributeFilter: [\"aria-invalid\"],\n    childList: true,\n    subtree: true,\n  })\n  return () => observer.disconnect()\n}\n\n/** Add or edit a stock reason: why stock moves, and where the reason is offered. */\nexport function ReasonEditorPage({\n  adding: startAdding = false,\n  loading = false,\n  pending = false,\n  saveFails = false,\n  refuseNames = false,\n  placesFail = false,\n}: ReasonEditorPageProps) {\n  const [adding, setAdding] = useState(startAdding)\n  const [saved, setSaved] = useState(startAdding ? NEW_REASON : MOCK_REASON)\n  // Bumped to start the form again from `saved`, after a save or a discard.\n  const [revision, setRevision] = useState(0)\n  const [assignments, setAssignments] = useState(saved.assignments)\n  const [formChanges, setFormChanges] = useState(0)\n  const [refusedNames, setRefusedNames] = useState<string[]>([])\n  const [saveError, setSaveError] = useState(false)\n  const [notSaved, setNotSaved] = useState<ReasonAssignment[]>([])\n  const [notice, setNotice] = useState<Notice>()\n  const [discarding, setDiscarding] = useState(false)\n  // Bumped to focus the first error after a refused or invalid submit.\n  const [focusRequest, setFocusRequest] = useState(0)\n  const container = useRef<HTMLDivElement>(null)\n  const changes =\n    formChanges + (sameAssignments(assignments, saved.assignments) ? 0 : 1)\n  const takenNames = useMemo(\n    () => [\n      ...MOCK_TAKEN_NAMES.filter((name) => name !== saved.values.name),\n      ...refusedNames,\n    ],\n    [saved.values.name, refusedNames]\n  )\n\n  useEffect(() => {\n    if (focusRequest === 0 || !container.current) return\n    return focusFirstError(container.current)\n  }, [focusRequest])\n\n  const requestFocus = () => setFocusRequest((current) => current + 1)\n\n  const start = (reason: MockReason) => {\n    setSaved(reason)\n    setAssignments(reason.assignments)\n    setRevision((current) => current + 1)\n    setFormChanges(0)\n    setRefusedNames([])\n    setSaveError(false)\n    setNotSaved([])\n    setNotice(undefined)\n  }\n\n  const save = (values: ReasonValues) => {\n    setSaveError(false)\n    setNotSaved([])\n    setNotice(undefined)\n    if (saveFails) {\n      setSaveError(true)\n      return\n    }\n    if (refuseNames && values.name !== saved.values.name) {\n      // The server refused the name, so the form now marks it as taken.\n      setRefusedNames((names) => [...names, values.name])\n      requestFocus()\n      return\n    }\n    const unsaved = unsavedAssignments(assignments, saved.assignments)\n    if (placesFail && unsaved.length > 0) {\n      // The reason saved, but its new places did not; Save again retries them.\n      const failed = new Set(unsaved.map(assignmentKey))\n      setSaved({\n        values,\n        assignments: [\n          ...saved.assignments.filter((row) =>\n            assignments.some(\n              (draft) => assignmentKey(draft) === assignmentKey(row)\n            )\n          ),\n          ...assignments.filter(\n            (row) =>\n              !failed.has(assignmentKey(row)) &&\n              !saved.assignments.some(\n                (stored) => assignmentKey(stored) === assignmentKey(row)\n              )\n          ),\n        ],\n      })\n      // The form starts again from the saved values; the failed places stay as drafts.\n      setRevision((current) => current + 1)\n      setFormChanges(0)\n      setNotSaved(unsaved)\n      setAdding(false)\n      return\n    }\n    const wasAdding = adding\n    start({ values, assignments })\n    setAdding(false)\n    setNotice(\n      wasAdding\n        ? {\n            title: \"Reason Created\",\n            description: `${values.name} is ready to use.`,\n          }\n        : {\n            title: \"Reason Saved\",\n            description: `Changes to ${values.name} are saved.`,\n          }\n    )\n  }\n\n  const cancel = () => {\n    if (changes > 0) setDiscarding(true)\n    else start(saved)\n  }\n\n  return (\n    <WorkspaceLayout ref={container}>\n      <Workspace width=\"narrow\">\n        <PageBreadcrumbs\n          items={[\n            { label: \"Home\", href: \"#\" },\n            { label: \"Administration\" },\n            { label: \"Reasons\", href: \"#\" },\n            { label: adding ? \"Add Reason\" : \"Edit Reason\" },\n          ]}\n        />\n        <WorkspaceHeader>\n          <WorkspaceHeading>\n            <WorkspaceIcon>\n              <MessageSquareTextIcon />\n            </WorkspaceIcon>\n            <WorkspaceTitle>\n              {adding\n                ? \"Add Reason\"\n                : loading\n                  ? \"Edit Reason\"\n                  : `Edit ${saved.values.name}`}\n            </WorkspaceTitle>\n            <WorkspaceDescription>\n              {adding\n                ? \"Say why stock moves, and where the reason is offered.\"\n                : \"Change the reason's name, tags and where it is offered.\"}\n            </WorkspaceDescription>\n          </WorkspaceHeading>\n        </WorkspaceHeader>\n        <WorkspaceContent>\n          <div className=\"flex flex-col gap-8\" inert={pending}>\n            {(notice || saveError || notSaved.length > 0) && (\n              <div className=\"flex flex-col gap-4\">\n                {notice && (\n                  <Callout title={notice.title} tone=\"success\">\n                    {notice.description}\n                  </Callout>\n                )}\n                {saveError && (\n                  <Alert variant=\"destructive\">\n                    <AlertCircleIcon />\n                    <AlertTitle>Could Not Save Reason</AlertTitle>\n                    <AlertDescription>\n                      Something went wrong. Check your connection and try again.\n                    </AlertDescription>\n                  </Alert>\n                )}\n                {notSaved.length > 0 && (\n                  <Alert variant=\"destructive\">\n                    <AlertCircleIcon />\n                    <AlertTitle>Some Places Not Saved</AlertTitle>\n                    <AlertDescription>\n                      The reason is saved, but these places are not:{\" \"}\n                      {notSaved.map(NAMES.pair).join(\"; \")}. Save again to try\n                      them once more.\n                    </AlertDescription>\n                  </Alert>\n                )}\n              </div>\n            )}\n            <ReasonGeneralForm\n              formId={FORM_ID}\n              key={revision}\n              lookups={LOOKUPS}\n              onChangesChange={setFormChanges}\n              onInvalid={requestFocus}\n              onSubmit={save}\n              reason={loading ? undefined : saved.values}\n              saved={!adding}\n              takenNames={takenNames}\n            />\n            <FieldSet>\n              <FieldLegend>Where Is This Reason Used?</FieldLegend>\n              <FieldDescription>\n                Add each program and facility type where this reason can be\n                used, and whether to show it in the requisition and stock\n                adjustment forms.\n              </FieldDescription>\n              <ReasonAssignments\n                activeFacilityTypes={MOCK_ACTIVE_FACILITY_TYPES}\n                facilityTypes={loading ? undefined : MOCK_FACILITY_TYPES}\n                onRowsChange={setAssignments}\n                programs={loading ? undefined : MOCK_PROGRAMS}\n                rows={assignments}\n              />\n            </FieldSet>\n          </div>\n        </WorkspaceContent>\n      </Workspace>\n      <WorkspaceFooter width=\"narrow\">\n        <Button\n          disabled={pending || loading}\n          onClick={cancel}\n          size=\"lg\"\n          variant=\"outline\"\n        >\n          Cancel\n        </Button>\n        <Button\n          disabled={pending || loading}\n          focusableWhenDisabled={pending}\n          form={FORM_ID}\n          size=\"lg\"\n          type=\"submit\"\n        >\n          {pending && <Spinner data-icon=\"inline-start\" />}\n          {adding ? \"Create\" : \"Save\"}\n        </Button>\n      </WorkspaceFooter>\n      <DiscardChangesDialog\n        changes={changes}\n        onDiscard={() => {\n          setDiscarding(false)\n          start(saved)\n        }}\n        onKeepEditing={() => setDiscarding(false)}\n        open={discarding}\n        subject={adding ? \"the new reason\" : saved.values.name}\n      />\n    </WorkspaceLayout>\n  )\n}",
      "type": "registry:component",
      "target": "components/openlmis/reason-editor-page/reason-editor-page.tsx"
    },
    {
      "path": "registry/templates/openlmis/reason-editor-page/components/reason-form-dialog/reason-form-dialog.tsx",
      "content": "\"use client\"\n\nimport { revalidateLogic } from \"@tanstack/react-form\"\nimport { type ReactNode, useMemo } from \"react\"\n\nimport { FieldGroup } from \"@/components/ui/field\"\nimport {\n  EMPTY_REASON,\n  reasonFormSchema,\n  type ReasonValues,\n  toReasonValues,\n} from \"@/components/openlmis/reason-editor-page/reason-form\"\nimport {\n  type ReasonLookups,\n  ReasonFormFields,\n} from \"@/components/openlmis/reason-editor-page/reason-form-fields\"\nimport {\n  FormDialog,\n  FormDialogBody,\n  FormDialogCancel,\n  FormDialogDescription,\n  FormDialogError,\n  FormDialogFooter,\n  FormDialogForm,\n  FormDialogHeader,\n  FormDialogSubmit,\n  FormDialogTitle,\n} from \"@/components/openlmis/form-dialog/form-dialog\"\nimport { useDialogTarget } from \"@/components/openlmis/form-dialog/use-dialog-target\"\nimport { useAppForm } from \"@/components/openlmis/form-fields/form\"\n\ntype ReasonFormDialogProps = {\n  open: boolean\n  lookups?: ReasonLookups\n  /** Other reasons' names, and any the server refused, turned down for the new one. */\n  takenNames?: readonly string[]\n  /** Called with trimmed values; create the reason, then close. */\n  onSubmit: (values: ReasonValues) => void\n  /** Keeps the dialog open and spins Create while the save runs. */\n  pending?: boolean\n  /** Shown above the fields, e.g. why the create failed; what was typed stays. */\n  error?: ReactNode\n  onClose: () => void\n}\n\n/** Add Reason from a list: say why stock moves; where it is offered comes later in the editor. */\nexport function ReasonFormDialog({\n  open,\n  pending = false,\n  onClose,\n  ...props\n}: ReasonFormDialogProps) {\n  const { shown, dialogProps } = useDialogTarget(open || undefined, onClose)\n\n  return (\n    <FormDialog {...dialogProps(pending)}>\n      {shown && <AddReasonForm pending={pending} {...props} />}\n    </FormDialog>\n  )\n}\n\nfunction AddReasonForm({\n  lookups,\n  takenNames,\n  onSubmit,\n  pending,\n  error,\n}: Omit<ReasonFormDialogProps, \"open\" | \"onClose\"> & { pending: boolean }) {\n  const schema = useMemo(() => reasonFormSchema(takenNames), [takenNames])\n  const form = useAppForm({\n    defaultValues: EMPTY_REASON,\n    // Quiet until the first submit, then each field re-checks as it is corrected.\n    validationLogic: revalidateLogic({\n      mode: \"submit\",\n      modeAfterSubmission: \"change\",\n    }),\n    validators: { onDynamic: schema },\n    onSubmit: ({ value }) => onSubmit(toReasonValues(value)),\n  })\n\n  return (\n    <FormDialogForm onSubmit={() => void form.handleSubmit()}>\n      <FormDialogHeader>\n        <FormDialogTitle>Add Reason</FormDialogTitle>\n        <FormDialogDescription>\n          Say why stock moves; choose where it is offered once it is created.\n        </FormDialogDescription>\n      </FormDialogHeader>\n      <FormDialogBody>\n        <FieldGroup>\n          {error && (\n            <FormDialogError\n              description={error}\n              title=\"Could Not Save Reason\"\n            />\n          )}\n          <ReasonFormFields form={form} lookups={lookups} />\n        </FieldGroup>\n      </FormDialogBody>\n      <FormDialogFooter>\n        <FormDialogCancel disabled={pending} />\n        <FormDialogSubmit pending={pending}>Create</FormDialogSubmit>\n      </FormDialogFooter>\n    </FormDialogForm>\n  )\n}",
      "type": "registry:component",
      "target": "components/openlmis/reason-editor-page/reason-form-dialog.tsx"
    },
    {
      "path": "registry/templates/openlmis/reason-editor-page/components/reason-general-form/reason-form-fields.tsx",
      "content": "\"use client\"\n\nimport { useMemo } from \"react\"\n\nimport { withForm } from \"@/components/openlmis/form-fields/form\"\n\nimport {\n  categoryLabel,\n  EMPTY_REASON,\n  REASON_CATEGORIES,\n  REASON_TYPES,\n  TAG_REFUSALS,\n  toCodeItems,\n  typeLabel,\n} from \"@/components/openlmis/reason-editor-page/reason-form\"\n\nexport type ReasonLookups = {\n  /** Category codes; defaults to the four OpenLMIS ships. */\n  categories?: readonly string[]\n  /** Type codes; defaults to Credit, Debit and Balance Adjustment. */\n  types?: readonly string[]\n  /** Tags other reasons use, suggested as the user types. */\n  tags?: readonly string[]\n}\n\ntype ReasonFormFieldsProps = {\n  lookups?: ReasonLookups\n  /** A saved reason keeps its category and type, so both are read only. */\n  saved?: { category: string; type: string }\n  readOnly?: boolean\n}\n\nconst DEFAULT_CATEGORIES = Object.keys(REASON_CATEGORIES)\nconst DEFAULT_TYPES = Object.keys(REASON_TYPES)\nconst NO_TAGS: readonly string[] = []\nconst NO_LOOKUPS: ReasonLookups = {}\n\n/** The reason's name, tags, category, type and free text, shared by Add Reason and the editor. */\nexport const ReasonFormFields = withForm({\n  defaultValues: EMPTY_REASON,\n  props: {} as ReasonFormFieldsProps,\n  render: function Render({\n    form,\n    lookups = NO_LOOKUPS,\n    saved,\n    readOnly = false,\n  }) {\n    const {\n      categories = DEFAULT_CATEGORIES,\n      types = DEFAULT_TYPES,\n      tags = NO_TAGS,\n    } = lookups\n    const categoryItems = useMemo(\n      () => toCodeItems(categories, categoryLabel, saved?.category),\n      [categories, saved?.category]\n    )\n    const typeItems = useMemo(\n      () => toCodeItems(types, typeLabel, saved?.type),\n      [types, saved?.type]\n    )\n\n    return (\n      <div className=\"grid grid-cols-1 gap-x-6 gap-y-5 @3xl/main:grid-cols-2\">\n        <form.AppField name=\"name\">\n          {(field) => (\n            <field.TextField\n              autoComplete=\"off\"\n              dir=\"auto\"\n              disabled={readOnly}\n              label=\"Name\"\n              required\n            />\n          )}\n        </form.AppField>\n        <form.AppField name=\"tags\">\n          {(field) => (\n            <field.TagsField\n              description=\"Tags group reasons for other screens; their meaning is up to your team. Press Enter or a comma to add one.\"\n              disabled={readOnly}\n              label=\"Tags\"\n              maxLength={255}\n              minLength={3}\n              placeholder=\"Add A Tag\"\n              refusedMessage={(reason) => TAG_REFUSALS[reason]}\n              removeLabel={(tag) => `Remove ${tag}`}\n              suggestions={tags}\n            />\n          )}\n        </form.AppField>\n        <form.AppField name=\"category\">\n          {(field) => (\n            <field.SelectField\n              description={\n                saved\n                  ? \"A saved reason keeps its category and type.\"\n                  : undefined\n              }\n              disabled={readOnly || Boolean(saved)}\n              items={categoryItems}\n              label=\"Category\"\n              required\n            />\n          )}\n        </form.AppField>\n        <form.AppField name=\"type\">\n          {(field) => (\n            <field.SelectField\n              disabled={readOnly || Boolean(saved)}\n              items={typeItems}\n              label=\"Type\"\n              required\n            />\n          )}\n        </form.AppField>\n        <form.AppField name=\"isFreeTextAllowed\">\n          {(field) => (\n            <field.SwitchField\n              description=\"Let users type a note when they pick this reason.\"\n              disabled={readOnly}\n              label=\"Allow Free Text\"\n            />\n          )}\n        </form.AppField>\n      </div>\n    )\n  },\n})",
      "type": "registry:component",
      "target": "components/openlmis/reason-editor-page/reason-form-fields.tsx"
    },
    {
      "path": "registry/templates/openlmis/reason-editor-page/components/reason-general-form/reason-form.ts",
      "content": "import { z } from \"zod\"\n\nimport type { TagRefusal } from \"@/components/openlmis/form-fields/tags\"\n\n/** Why stock moved, as OpenLMIS groups reasons; a code the server adds later shows as it is. */\nexport const REASON_CATEGORIES: Record<string, string> = {\n  TRANSFER: \"Transfer\",\n  ADJUSTMENT: \"Adjustment\",\n  PHYSICAL_INVENTORY: \"Physical Inventory\",\n  AGGREGATION: \"Aggregation\",\n}\n\n/** Whether the reason adds stock, takes it away, or corrects it. */\nexport const REASON_TYPES: Record<string, string> = {\n  CREDIT: \"Credit\",\n  DEBIT: \"Debit\",\n  BALANCE_ADJUSTMENT: \"Balance Adjustment\",\n}\n\nexport const categoryLabel = (code: string) => REASON_CATEGORIES[code] ?? code\nexport const typeLabel = (code: string) => REASON_TYPES[code] ?? code\n\n/** What the reason forms show and save; map your API's reason onto it. */\nexport type ReasonValues = {\n  name: string\n  category: string\n  type: string\n  isFreeTextAllowed: boolean\n  tags: string[]\n}\n\nexport const EMPTY_REASON: ReasonValues = {\n  name: \"\",\n  category: \"\",\n  type: \"\",\n  isFreeTextAllowed: false,\n  tags: [],\n}\n\nconst sameName = (a: string, b: string) =>\n  a.trim().localeCompare(b.trim(), undefined, { sensitivity: \"accent\" }) === 0\n\n/** `takenNames` holds other reasons' names, and any the server refused. */\nexport function reasonFormSchema(takenNames: readonly string[] = []) {\n  return z.object({\n    name: z\n      .string()\n      .trim()\n      .min(1, \"Enter a name.\")\n      .refine(\n        (name) => !takenNames.some((other) => sameName(other, name)),\n        \"Another reason already has this name.\"\n      ),\n    category: z.string().min(1, \"Choose a category.\"),\n    type: z.string().min(1, \"Choose a type.\"),\n    isFreeTextAllowed: z.boolean(),\n    tags: z.array(z.string()),\n  })\n}\n\nexport const toReasonValues = (values: ReasonValues): ReasonValues => ({\n  ...values,\n  name: values.name.trim(),\n})\n\n/** How many fields differ from the saved reason. */\nexport function reasonChanges(values: ReasonValues, saved: ReasonValues) {\n  return [\n    values.name.trim() !== saved.name.trim(),\n    values.category !== saved.category,\n    values.type !== saved.type,\n    values.isFreeTextAllowed !== saved.isFreeTextAllowed,\n    values.tags.join(\"\\n\") !== saved.tags.join(\"\\n\"),\n  ].filter(Boolean).length\n}\n\nexport const TAG_REFUSALS: Record<TagRefusal, string> = {\n  \"too-short\": \"A tag needs at least 3 characters.\",\n  \"too-long\": \"A tag can have at most 255 characters.\",\n  duplicate: \"This tag is already added.\",\n}\n\n/** The codes as a select lists them, with a saved code the list lacks kept on the end. */\nexport function toCodeItems(\n  codes: readonly string[],\n  label: (code: string) => string,\n  current?: string\n) {\n  const all = current && !codes.includes(current) ? [...codes, current] : codes\n  return all.map((code) => ({ value: code, label: label(code) }))\n}",
      "type": "registry:lib",
      "target": "components/openlmis/reason-editor-page/reason-form.ts"
    },
    {
      "path": "registry/templates/openlmis/reason-editor-page/components/reason-general-form/reason-general-form.tsx",
      "content": "\"use client\"\n\nimport { revalidateLogic, useStore } from \"@tanstack/react-form\"\nimport { useEffect, useId, useMemo, useRef } from \"react\"\n\nimport { Field, FieldGroup, FieldLabel } from \"@/components/ui/field\"\nimport { useAppForm } from \"@/components/openlmis/form-fields/form\"\nimport { FieldSkeleton } from \"@/components/openlmis/form-fields/form-fields\"\n\nimport {\n  reasonChanges,\n  reasonFormSchema,\n  type ReasonValues,\n  toReasonValues,\n} from \"@/components/openlmis/reason-editor-page/reason-form\"\nimport { type ReasonLookups, ReasonFormFields } from \"@/components/openlmis/reason-editor-page/reason-form-fields\"\n\ntype ReasonGeneralFormProps = {\n  /** The reason's values, or `EMPTY_REASON` to add one; a skeleton shows until it is set. */\n  reason: ReasonValues | undefined\n  /** Whether the reason is stored, which fixes its category and type. */\n  saved?: boolean\n  lookups?: ReasonLookups\n  /** Other reasons' names, and any the server refused, turned down as this one's. */\n  takenNames?: readonly string[]\n  readOnly?: boolean\n  /** The form's id, for a Save placed elsewhere, e.g. in a page's `WorkspaceFooter`. */\n  formId?: string\n  /** Called with trimmed values once every field is valid. */\n  onSubmit: (values: ReasonValues) => void\n  /** Called when a submit finds errors. */\n  onInvalid?: () => void\n  /** Tells the page how many fields are unsaved, e.g. to ask before leaving. */\n  onChangesChange?: (changes: number) => void\n}\n\n/** A stock reason's details: name, tags, category, type and free text. */\nexport function ReasonGeneralForm({\n  reason,\n  ...props\n}: ReasonGeneralFormProps) {\n  if (!reason) return <ReasonGeneralFormSkeleton />\n  return <GeneralForm reason={reason} {...props} />\n}\n\nfunction GeneralForm({\n  reason,\n  saved = false,\n  lookups,\n  takenNames,\n  readOnly = false,\n  formId: givenFormId,\n  onSubmit,\n  onInvalid,\n  onChangesChange,\n}: ReasonGeneralFormProps & { reason: ReasonValues }) {\n  const generatedFormId = useId()\n  const formId = givenFormId ?? generatedFormId\n  // Keyed on the names, so an inline array does not re-run validation each render.\n  const takenKey = takenNames?.join(\"\\n\") ?? \"\"\n  const schema = useMemo(\n    () => reasonFormSchema(takenKey ? takenKey.split(\"\\n\") : []),\n    [takenKey]\n  )\n\n  const form = useAppForm({\n    defaultValues: reason,\n    // Quiet until the first submit, then each field re-checks as it is corrected.\n    validationLogic: revalidateLogic({\n      mode: \"submit\",\n      modeAfterSubmission: \"change\",\n    }),\n    validators: { onDynamic: schema },\n    onSubmit: ({ value }) => onSubmit(toReasonValues(value)),\n    onSubmitInvalid: () => onInvalid?.(),\n  })\n  const changes = useStore(form.store, (state) =>\n    reasonChanges(state.values, reason)\n  )\n\n  // Starts again only when the values differ, so an equal new object keeps the draft.\n  const reasonKey = JSON.stringify(reason)\n  const resetKey = useRef(reasonKey)\n  useEffect(() => {\n    if (resetKey.current === reasonKey) return\n    resetKey.current = reasonKey\n    form.reset(reason)\n  }, [form, reason, reasonKey])\n  // A name the server refused shows its error at once, rather than on the next submit.\n  useEffect(() => {\n    if (form.state.submissionAttempts === 0) return\n    form.update({ ...form.options, validators: { onDynamic: schema } })\n    void form.validate(\"change\")\n  }, [form, schema])\n  useEffect(() => {\n    onChangesChange?.(changes)\n  }, [changes, onChangesChange])\n\n  return (\n    <form\n      id={formId}\n      noValidate\n      onSubmit={(event) => {\n        event.preventDefault()\n        void form.handleSubmit()\n      }}\n    >\n      <FieldGroup>\n        <ReasonFormFields\n          form={form}\n          lookups={lookups}\n          readOnly={readOnly}\n          saved={saved ? reason : undefined}\n        />\n      </FieldGroup>\n    </form>\n  )\n}\n\n/** The form as it will look, so nothing moves when the reason arrives. */\nexport function ReasonGeneralFormSkeleton() {\n  return (\n    <div aria-busy>\n      <FieldGroup>\n        <div className=\"grid grid-cols-1 gap-x-6 gap-y-5 @3xl/main:grid-cols-2\">\n          <FieldSkeleton label=\"Name\" required />\n          <FieldSkeleton label=\"Tags\" />\n          <FieldSkeleton label=\"Category\" required />\n          <FieldSkeleton label=\"Type\" required />\n          <Field orientation=\"horizontal\">\n            <div className=\"flex min-h-8 flex-1 items-center\">\n              <FieldLabel>Allow Free Text</FieldLabel>\n            </div>\n            {/* A plain element, since Skeleton owns its corner radius and the switch is round. */}\n            <div className=\"h-4.5 w-8 shrink-0 animate-pulse rounded-full bg-muted\" />\n          </Field>\n        </div>\n      </FieldGroup>\n    </div>\n  )\n}",
      "type": "registry:component",
      "target": "components/openlmis/reason-editor-page/reason-general-form.tsx"
    },
    {
      "path": "registry/templates/openlmis/reason-editor-page/page.tsx",
      "content": "import { ReasonEditorPage } from \"@/components/openlmis/reason-editor-page/reason-editor-page\"\n\n// A Next.js App Router route; in any other React app, render ReasonEditorPage from your own route.\nexport default function Page() {\n  return <ReasonEditorPage />\n}",
      "type": "registry:page",
      "target": "app/reason-editor-page/page.tsx"
    }
  ],
  "cssVars": {
    "light": {
      "destructive": "oklch(0.577 0.245 27.325)",
      "destructive-foreground": "oklch(0.985 0 0)",
      "success": "oklch(0.596 0.145 163.225)",
      "success-foreground": "oklch(0.985 0 0)",
      "warning": "oklch(0.666 0.179 58.318)",
      "warning-foreground": "oklch(0.985 0 0)",
      "info": "oklch(0.55 0.13 237)",
      "info-foreground": "oklch(0.985 0 0)"
    },
    "dark": {
      "destructive": "oklch(0.704 0.191 22.216)",
      "destructive-foreground": "oklch(0.21 0.04 25)",
      "success": "oklch(0.696 0.17 162.48)",
      "success-foreground": "oklch(0.21 0.04 163)",
      "warning": "oklch(0.769 0.188 70.08)",
      "warning-foreground": "oklch(0.22 0.04 60)",
      "info": "oklch(0.7 0.14 237)",
      "info-foreground": "oklch(0.2 0.04 240)"
    }
  },
  "meta": {
    "project": "openlmis",
    "height": "813px"
  },
  "categories": [
    "stock"
  ],
  "type": "registry:page"
}
