{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "core-edit-in-place",
  "type": "registry:lib",
  "title": "core/edit-in-place",
  "description": "Framework-free behaviour shared by the ui-* components (edit-in-place); no DOM, no lit. Copied from @purpurabog/ui 2.3.0; the package is the maintained source, this copy is yours to change. Icons from the Carbon Design System (Apache-2.0, © IBM Corp.; see THIRD-PARTY-NOTICES.md in the package).",
  "dependencies": [],
  "registryDependencies": [],
  "files": [
    {
      "path": "src/core/edit-in-place.ts",
      "type": "registry:lib",
      "target": "components/ui/core/edit-in-place.ts",
      "content": "/** Heights of an edit-in-place (Carbon for IBM Products `EditInPlace` sizes): sm 40, md 48, lg 64. Its buttons are squares of it. */\nexport type EditInPlaceSize = 'sm' | 'md' | 'lg';\n\nexport const EDIT_IN_PLACE_PX: Record<EditInPlaceSize, number> = { sm: 40, md: 48, lg: 64 };\n\n/** What the edited value allows (Carbon): saving needs a change (spaces at the ends don't count) and a valid value; cancelling needs a change. */\nexport function editState(value: string, initial: string, invalid: boolean) {\n    const changed = value.trim() !== initial.trim();\n    return { changed, canSave: changed && !invalid, canCancel: changed };\n}\n\n/**\n * A key in the field while editing (Carbon): Enter saves when it can and keeps editing, else leaves editing (the\n * focus stays in the field — Carbon blurs it, losing the focus); Escape puts the value back and keeps editing.\n */\nexport function editKeyAction(key: string, canSave: boolean): 'save' | 'leave' | 'cancel' | null {\n    if (key === 'Enter') return canSave ? 'save' : 'leave';\n    if (key === 'Escape') return 'cancel';\n    return null;\n}\n\n/** Focus left the whole control (not to one of its buttons): Carbon saves a valid change, else puts the value back. */\nexport const leaveAction = (canSave: boolean): 'save' | 'cancel' => (canSave ? 'save' : 'cancel');\n"
    }
  ]
}
