{"version":3,"file":"chunk-clickable.mjs","names":[],"sources":["../../src/clickable.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport { type KeyboardEvent, type MouseEvent } from 'react';\n\n/**\n * Props that make a non-button element (a Card, a Card row, an Image frame) a button when it has an `onClick`:\n * focusable and activated by Enter and Space, but only when it is itself the target, so a nested control's keys stay\n * its own. Without `onClick` only the caller's `onKeyDown` passes through.\n */\nexport const clickableProps = <T extends HTMLElement>(\n  onClick: ((event: MouseEvent<T>) => void) | undefined,\n  onKeyDown: ((event: KeyboardEvent<T>) => void) | undefined,\n) =>\n  onClick\n    ? {\n        role: 'button',\n        tabIndex: 0,\n        onClick,\n        onKeyDown: (event: KeyboardEvent<T>) => {\n          onKeyDown?.(event);\n          if (!event.defaultPrevented && event.target === event.currentTarget && [' ', 'Enter'].includes(event.key)) {\n            event.preventDefault();\n            event.currentTarget.click();\n          }\n        },\n      }\n    : { onKeyDown };\n"],"mappings":";;;;;;AAWA,IAAa,kBACX,SACA,cAEA,UACI;CACE,MAAM;CACN,UAAU;CACV;CACA,YAAY,UAA4B;EACtC,YAAY,KAAK;EACjB,IAAI,CAAC,MAAM,oBAAoB,MAAM,WAAW,MAAM,iBAAiB,CAAC,KAAK,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,GAAG;GACzG,MAAM,eAAe;GACrB,MAAM,cAAc,MAAM;EAC5B;CACF;AACF,IACA,EAAE,UAAU"}