{"version":3,"file":"use-cell-id.cjs","sources":["../../../src/hooks/use-cell-id.ts"],"sourcesContent":["import { useContext } from 'react';\nimport { CellIdContext } from '../context';\nimport type { CellId } from '../types/cell.types';\n\n/**\n * Read the current cell id from the nearest `CellIdContext`. Populated by\n * `<Paper />` around every `renderElement` / `renderLink` invocation.\n *\n * Use this inside a render callback (or any component mounted from one) when\n * you only need the id, it's cheaper than {@link useCell}() since\n * it never subscribes to store updates. Throws when used outside a Paper\n * render context.\n * @returns the current cell id\n * @group Hooks\n * @example\n * ```tsx\n * import { useCellId } from '@joint/react';\n *\n * function MyElement() {\n *   const id = useCellId();\n *   return <text>{id}</text>;\n * }\n * ```\n */\nexport function useCellId(): CellId {\n  const id = useContext(CellIdContext);\n  if (id === undefined) {\n    throw new Error('useCellId() must be used inside renderElement or renderLink');\n  }\n  return id;\n}\n"],"names":["useContext","CellIdContext"],"mappings":";;;;;;;;;;;;AAwBO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,SAAA,CAAA,CAAA,CAAoB,CAAA;AAClC,CAAA,CAAA,MAAM,CAAA,CAAA,CAAA,CAAA,CAAKA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAWC,mBAAa,CAAA,CAAA;AACnC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAI,CAAA,MAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,CAAA;AACpB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAI,CAAA,CAAA,CAAA,CAAA,EAAM,6DAA6D,CAAA,CAAA;AAAA,CAAA,CAC/E,CAAA;AACA,CAAA,CAAA,OAAO,CAAA,CAAA,CAAA;AACT,CAAA;;"}