{"version":3,"file":"use-graph.cjs","sources":["../../../src/hooks/use-graph.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react';\nimport type { dia } from '@joint/core';\nimport { useGraphStore } from './use-graph-store';\nimport { useGraphTransaction, type Transaction } from './use-graph-transaction';\nimport {\n  useSetCell,\n  useSetCellData,\n  useRemoveCell,\n  useRemoveCells,\n  useResetCells,\n  useUpdateCells,\n  type SetCell,\n  type SetCellData,\n} from './use-cell-setters';\nimport type { ArrayUpdate } from '../store/state-container';\nimport type { ElementJSONInit, LinkJSONInit, CellInput, CellRef } from '../types/cell.types';\n\n/**\n * The shape of the graph's JSON export, as produced by `graph.toJSON()`.\n * @group Types\n */\nexport type GraphJSON = dia.Graph.JSON;\n\n/** Drops an untyped (`unknown`) `data` side so it doesn't collapse a union. */\ntype TypedData<Data> = unknown extends Data ? never : Data;\n\n/**\n * `data` type for the GraphApi's `setCellData`, derived from {@link useGraph}'s\n * `Element` / `Link` generics by reusing each record's `['data']`:\n * - both sides untyped → open `Record<string, unknown>` (keeps the no-generic\n *   {@link useGraph}() spreadable)\n * - one side typed → that side's data\n * - both sides typed → their union (narrow inside the updater)\n *\n * A cell id is opaque at the type level, so this cannot narrow element-vs-link\n * per call, it exposes the data shapes {@link useGraph} was told about.\n */\ntype HandleCellData<Element extends ElementJSONInit, Link extends LinkJSONInit> = [\n  TypedData<Element['data']> | TypedData<Link['data']>,\n] extends [never]\n  ? Record<string, unknown>\n  : TypedData<Element['data']> | TypedData<Link['data']>;\n\n/**\n * Imperative API returned by {@link useGraph}.\n * @template Element - element record shape (e.g. `ElementRecord<MyData>` for\n *                    write input, `Computed<ElementRecord<MyData>>` for reads)\n * @template Link - link record shape (e.g. `LinkRecord<MyData>` /\n *                  `Computed<LinkRecord<MyData>>`)\n * @expand\n * @group Types\n */\nexport interface GraphApi<\n  Element extends ElementJSONInit = ElementJSONInit,\n  Link extends LinkJSONInit = LinkJSONInit,\n> {\n  /** The JointJS graph instance. */\n  readonly graph: dia.Graph;\n  /**\n   * Add or update a cell. Two forms:\n   * - `setCell(record)`, `record.id` names the target. Existing cell:\n   *   attributes merge over it. Missing cell: the cell is added.\n   * - `setCell(id, (prev) => next)`, updater form. The updater is invoked\n   *   once with the real previous record. A nullish `id`, or an `id` with no\n   *   matching cell, warns in dev and no-ops (use the direct form to add).\n   */\n  readonly setCell: SetCell<Element, Link>;\n  /**\n   * Set a single cell's `data` field. Two forms, both keyed by cell id:\n   * - `setCellData(id, data)`, replaces the cell's `data` with `data`.\n   * - `setCellData(id, (prev) => next)`, updater form; `prev` is the current\n   *   `data`, the return value replaces it (merge inside the updater for a\n   *   partial update). A nullish `id`, or an `id` with no matching cell, warns\n   *   in dev and no-ops.\n   *\n   * The `data` type is derived from the `useGraph<Element, Link>` generics:\n   * typed records flow through, otherwise it falls back to\n   * `Record<string, unknown>`. A cell id can't be narrowed to element-vs-link\n   * at the type level, so when both are typed the updater sees their union.\n   * Narrow inside it, or fix the `data` shape via `useGraph<ElementRecord<MyData>>()`.\n   */\n  readonly setCellData: SetCellData<HandleCellData<Element, Link>>;\n  /**\n   * Remove a cell by id or dia.Cell reference. A nullish reference warns in dev\n   * and no-ops; a reference that resolves to no cell is a silent no-op. The\n   * optional `metadata` is forwarded as the `graph.removeCells` event opt.\n   */\n  readonly removeCell: (cellRef?: CellRef | null, metadata?: Record<string, unknown>) => void;\n  /**\n   * Remove multiple cells by id or dia.Cell reference. A nullish array warns in\n   * dev and no-ops; references that resolve to no cell are silently skipped. The\n   * optional `metadata` is forwarded as the `graph.removeCells` event opt.\n   */\n  readonly removeCells: (\n    cellRefs?: readonly CellRef[] | null,\n    metadata?: Record<string, unknown>\n  ) => void;\n  /**\n   * Atomically replace the cell set. Accepts dia.Cell instances alongside\n   * records. The optional `metadata` is forwarded as the `graph.resetCells` opt.\n   */\n  readonly resetCells: (\n    input: ArrayUpdate<Element | Link, CellInput<Element, Link>>,\n    metadata?: Record<string, unknown>\n  ) => void;\n  /**\n   * Apply an updater to the current cells array. Updater may return dia.Cell\n   * instances. The optional `metadata` is forwarded as the sync event opt.\n   */\n  readonly updateCells: (\n    updater: (previous: ReadonlyArray<Element | Link>) => ReadonlyArray<CellInput<Element, Link>>,\n    metadata?: Record<string, unknown>\n  ) => void;\n  /**\n   * Predicate / type guard: true when the input resolves to an element cell.\n   * Consults the graph's type registry so any `dia.Element` subclass (including\n   * custom shapes) is recognised, not just the default {@link ElementModel}.\n   */\n  readonly isElement: (input: Element | Link) => input is Element;\n  /**\n   * Predicate / type guard: true when the input resolves to a link cell.\n   * Consults the graph's type registry so any `dia.Link` subclass (including\n   * custom shapes) is recognised, not just the default {@link LinkModel}.\n   */\n  readonly isLink: (input: Element | Link) => input is Link;\n  /**\n   * Serialize the graph to a plain JSON object.\n   *\n   * By default the output is **minimal**: attributes that match each cell's\n   * `defaults` are dropped and empty `{}` placeholders are pruned everywhere\n   * except inside `attrs` at the third nesting level (e.g.\n   * `attrs.text.textWrap: {}` is a meaningful reset marker in JointJS shapes\n   * and must survive). Pass `{ includeDefaults: true }` to keep every\n   * attribute on every cell, no pruning is applied in that mode.\n   */\n  readonly exportToJSON: (options?: ExportToJSONOptions) => GraphJSON;\n  /**\n   * Replace the graph contents from a previously exported JSON object\n   * (e.g. produced by `exportToJSON`). Triggers JointJS's `reset` event so\n   * all React subscriptions resync automatically.\n   */\n  readonly importFromJSON: (json: GraphJSON) => void;\n  /**\n   * Run a callback as one atomic transaction: every edit inside collapses into\n   * a single undo entry and (for sync callbacks) a single re-render. Pass\n   * `{ rollbackOnError: true }` to restore the graph on error (off by default —\n   * partial edits stay; enabling it snapshots the full cells array up-front,\n   * so leave off for large graphs when the callback is trusted). See\n   * {@link Transaction}.\n   */\n  readonly transaction: Transaction;\n}\n\n/**\n * Options for {@link GraphApi}'s `exportToJSON`.\n * @expand\n * @group Types\n */\nexport interface ExportToJSONOptions {\n  /**\n   * When `true`, every attribute is kept (defaults included) and no\n   * empty-attribute pruning is applied. The default minimal output strips\n   * attributes that match each cell's `defaults` and prunes empty `{}`\n   * (except inside `attrs` at depth 3, e.g. `attrs.text.textWrap: {}`, which\n   * JointJS treats as a meaningful reset marker).\n   * @default false\n   */\n  readonly includeDefaults?: boolean;\n}\n\n/**\n * Access the graph together with its imperative cell-mutation API for adding,\n * updating, removing, and serializing cells. Call this inside a\n * {@link GraphProvider}.\n * @template Element - element record shape (use `ElementRecord<MyData>` for input,\n *                    `Computed<ElementRecord<MyData>>` for read shapes)\n * @template Link - link record shape (use `LinkRecord<MyData>` /\n *                  `Computed<LinkRecord<MyData>>`)\n * @returns The {@link GraphApi}: the `dia.Graph` instance plus `setCell`,\n *          `setCellData`, `removeCell`, `resetCells`, `exportToJSON`, and the\n *          other cell actions.\n * @group Hooks\n * @example\n * ```tsx\n * import { GraphProvider, Paper, useGraph } from '@joint/react';\n *\n * function Toolbar() {\n *   const { setCell, exportToJSON } = useGraph();\n *   return (\n *     <button\n *       onClick={() =>\n *         setCell({\n *           id: 'node-1',\n *           type: 'standard.Rectangle',\n *           position: { x: 40, y: 40 },\n *           size: { width: 120, height: 60 },\n *         })\n *       }\n *     >\n *       Add node\n *     </button>\n *   );\n * }\n *\n * function App() {\n *   return (\n *     <GraphProvider>\n *       <Paper />\n *       <Toolbar />\n *     </GraphProvider>\n *   );\n * }\n * ```\n */\nexport function useGraph<\n  Element extends ElementJSONInit = ElementJSONInit,\n  Link extends LinkJSONInit = LinkJSONInit,\n>(): GraphApi<Element, Link> {\n  const store = useGraphStore<Element, Link>();\n  const { graph } = store;\n\n  const setCell = useSetCell<Element, Link>();\n  const setCellData = useSetCellData<HandleCellData<Element, Link>>();\n  const removeCell = useRemoveCell();\n  const removeCells = useRemoveCells();\n  const resetCells = useResetCells<Element, Link>();\n  const updateCells = useUpdateCells<Element, Link>();\n  const transaction = useGraphTransaction();\n\n  const exportToJSON = useCallback<GraphApi<Element, Link>['exportToJSON']>(\n    (options) => {\n      if (options?.includeDefaults) {\n        // Raw graph state — defaults kept, no pruning.\n        // `cell.toJSON()` with no opts still strips `attrs` defaults\n        // (built-in fallback `differentiateKeys = ['attrs']`), so we pass\n        // `ignoreDefaults: false` explicitly to keep them.\n        return graph.toJSON({ cellAttributes: { ignoreDefaults: false } });\n      }\n      return graph.toJSON({\n        cellAttributes: {\n          ignoreDefaults: true,\n          // Drop every empty `{}` EXCEPT inside `attrs` at depth 3\n          // (e.g. `attrs.text.textWrap: {}` is a meaningful reset marker).\n          ignoreEmptyAttributes: (_key, path) => !(path[0] === 'attrs' && path.length === 3),\n        },\n      });\n    },\n    [graph]\n  );\n\n  const importFromJSON = useCallback<GraphApi<Element, Link>['importFromJSON']>(\n    (json) => {\n      graph.fromJSON(json);\n    },\n    [graph]\n  );\n\n  return useMemo(\n    () => ({\n      graph,\n      setCell,\n      setCellData,\n      removeCell,\n      removeCells,\n      resetCells,\n      updateCells,\n      isElement: store.isElement,\n      isLink: store.isLink,\n      exportToJSON,\n      importFromJSON,\n      transaction,\n    }),\n    [\n      graph,\n      store,\n      setCell,\n      setCellData,\n      removeCell,\n      removeCells,\n      resetCells,\n      updateCells,\n      exportToJSON,\n      importFromJSON,\n      transaction,\n    ]\n  );\n}\n"],"names":["useGraphStore","useSetCell","useSetCellData","useRemoveCell","useRemoveCells","useResetCells","useUpdateCells","useGraphTransaction","useCallback","useMemo"],"mappings":";;;;;;;;;;;;;;AAsNO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,QAAA,CAAA,CAAA,CAGa,CAAA;AAC3B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,IAAQA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA,CAAA,CAA6B,CAAA;AAC3C,CAAA,CAAA,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