{"version":3,"sources":["../src/components/inputs/mode/useInlineEdit.ts"],"names":["useState","useCallback"],"mappings":";;;;;AAwBO,SAAS,aAAA,CAAc,MAAiB,QAAA,EAAgC;AAC7E,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAIA,eAAS,KAAK,CAAA;AAC5C,EAAA,MAAM,WAAA,GAAc,IAAA,KAAS,MAAA,IAAU,CAAC,QAAA;AACxC,EAAA,MAAM,WAAA,GAAc,IAAA,KAAS,MAAA,IAAW,WAAA,IAAe,OAAA;AACvD,EAAA,MAAM,SAAA,GAAYC,kBAAY,MAAM;AAClC,IAAA,IAAI,WAAA,aAAwB,IAAI,CAAA;AAAA,EAClC,CAAA,EAAG,CAAC,WAAW,CAAC,CAAA;AAChB,EAAA,MAAM,WAAWA,iBAAA,CAAY,MAAM,WAAW,KAAK,CAAA,EAAG,EAAE,CAAA;AACxD,EAAA,OAAO,EAAE,WAAA,EAAa,WAAA,EAAa,SAAA,EAAW,QAAA,EAAS;AACzD","file":"chunk-KJ22KE56.cjs","sourcesContent":["import { useCallback, useState } from \"react\";\nimport type { FieldMode } from \"../inputs.types\";\n\nexport interface InlineEdit {\n  /** Render the editable control (`true`) vs. the read-only value display (`false`). */\n  showControl: boolean;\n  /** Whether view mode is interactive (click-to-edit) — i.e. `view` and not disabled. */\n  interactive: boolean;\n  /** Enter edit mode (no-op unless interactive). */\n  enterEdit: () => void;\n  /** Leave edit mode, back to the value display. */\n  exitEdit: () => void;\n}\n\n/**\n * Inline click-to-edit for `mode=\"view\"`. The bound value shows as clean static\n * text; clicking it swaps in the focused control; blur returns to the display\n * (the control's `onChange` / `onBlur` fire as usual, so a host can persist on\n * commit). `mode=\"edit\"` is always the control; a **disabled** view stays static\n * text (no click-to-edit).\n *\n * This is the value of \"view mode\": tidy read-only surfaces where each field\n * becomes editable only when the user reaches for it.\n */\nexport function useInlineEdit(mode: FieldMode, disabled?: boolean): InlineEdit {\n  const [editing, setEditing] = useState(false);\n  const interactive = mode === \"view\" && !disabled;\n  const showControl = mode !== \"view\" || (interactive && editing);\n  const enterEdit = useCallback(() => {\n    if (interactive) setEditing(true);\n  }, [interactive]);\n  const exitEdit = useCallback(() => setEditing(false), []);\n  return { showControl, interactive, enterEdit, exitEdit };\n}\n"]}