{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "openlmis-form-actions",
  "title": "Form Actions",
  "description": "Cancel and Save actions for a form, with dirty and pending states, usable inside the form or in a page footer.",
  "dependencies": [
    "@base-ui/react@^1"
  ],
  "registryDependencies": [
    "button",
    "input",
    "label",
    "spinner"
  ],
  "files": [
    {
      "path": "registry/components/openlmis/form-actions/form-actions.tsx",
      "content": "\"use client\"\n\nimport type { ReactNode } from \"react\"\n\nimport { Button } from \"@/components/ui/button\"\nimport { Spinner } from \"@/components/ui/spinner\"\n\n/** What a form hands its Cancel and Save buttons, wherever they are placed. */\nexport type FormActionState = {\n  /** The form's id, for a submit button placed outside it. */\n  formId: string\n  changed: boolean\n  pending: boolean\n  /** Puts the form back to the saved values. */\n  cancel: () => void\n}\n\n/** Cancel and Save for a form, e.g. in a `WorkspaceFooter`. */\nexport function FormActions({\n  actions: { formId, changed, pending, cancel },\n  saveLabel,\n  cancelDisabled = !changed,\n}: {\n  actions: FormActionState\n  saveLabel: ReactNode\n  /** A navigation Cancel may stay available while the form is unchanged. */\n  cancelDisabled?: boolean\n}) {\n  return (\n    <>\n      <Button\n        disabled={cancelDisabled || pending}\n        onClick={cancel}\n        size=\"lg\"\n        type=\"button\"\n        variant=\"outline\"\n      >\n        Cancel\n      </Button>\n      <Button\n        disabled={!changed || pending}\n        focusableWhenDisabled={pending}\n        form={formId}\n        size=\"lg\"\n        type=\"submit\"\n      >\n        {pending && <Spinner data-icon=\"inline-start\" />}\n        {saveLabel}\n      </Button>\n    </>\n  )\n}",
      "type": "registry:component",
      "target": "components/openlmis/form-actions.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": "170px"
  },
  "categories": [
    "forms"
  ],
  "type": "registry:component"
}
