{"version":3,"file":"hooks.mjs","names":[],"sources":["../../../../src/data-grid/style-rules/hooks.ts"],"sourcesContent":["/*!\n *\n *  Copyright (c) \"Neo4j\"\n *  Neo4j Sweden AB [http://neo4j.com]\n *\n *  This file is part of Neo4j.\n *\n *  Neo4j is free software: you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation, either version 3 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with this program.  If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { type Cell, type RowData } from '@tanstack/react-table';\nimport { useMemo } from 'react';\n\nimport { useDataGridContext } from '../data-grid-context';\nimport { computeDataGridRowStyles } from './evaluate';\n\n/**\n * Returns computed inline style for a specific cell based on style rules in context.\n * Use this in custom BodyCell overrides to apply rule-based styling.\n */\nexport function useDataGridCellStyle<T extends RowData>(\n  cell: Cell<T, unknown>,\n): React.CSSProperties | undefined {\n  const { styleRules, styleRuleValueConverters } = useDataGridContext<T>();\n\n  return useMemo(() => {\n    if (!styleRules || styleRules.length === 0) {\n      return undefined;\n    }\n    const original = cell.row.original;\n    const rowData =\n      typeof original === 'object' && original !== null\n        ? (original as Record<string, unknown>)\n        : {};\n    const { cellStyles } = computeDataGridRowStyles(\n      styleRules,\n      rowData,\n      styleRuleValueConverters,\n    );\n    return cellStyles[cell.column.id];\n  }, [styleRules, styleRuleValueConverters, cell]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,SAAgB,qBACd,MACiC;CACjC,MAAM,EAAE,YAAY,6BAA6B,mBAAsB;CAEvE,OAAO,cAAc;EACnB,IAAI,CAAC,cAAc,WAAW,WAAW,GACvC;EAEF,MAAM,WAAW,KAAK,IAAI;EAK1B,MAAM,EAAE,eAAe,yBACrB,YAJA,OAAO,aAAa,YAAY,aAAa,OACxC,WACD,CAAC,GAIL,wBACF;EACA,OAAO,WAAW,KAAK,OAAO;CAChC,GAAG;EAAC;EAAY;EAA0B;CAAI,CAAC;AACjD"}