UNPKG

@wordpress/components

Version:
1 lines • 1.91 kB
{"version":3,"file":"cell.mjs","names":[],"sources":["../../src/tree-grid/cell.tsx"],"sourcesContent":["import { forwardRef, useRef } from '@wordpress/element';\nimport TreeGridItem from './item';\nimport type { WordPressComponentProps } from '../context';\nimport type { TreeGridCellProps } from './types';\nimport { useValidateTreeGridStructure } from './use-validate-tree-grid-structure';\n\nfunction UnforwardedTreeGridCell(\n\t{\n\t\tchildren,\n\t\twithoutGridItem = false,\n\t\t...props\n\t}: WordPressComponentProps< TreeGridCellProps, 'td', false >,\n\tref: React.ForwardedRef< any >\n) {\n\tconst cellRef = useRef< HTMLTableCellElement >( null );\n\tuseValidateTreeGridStructure( 'TreeGridCell', cellRef );\n\n\treturn (\n\t\t<td ref={ cellRef } { ...props } role=\"gridcell\">\n\t\t\t{ withoutGridItem ? (\n\t\t\t\t<>\n\t\t\t\t\t{ typeof children === 'function'\n\t\t\t\t\t\t? children( { ...props, ref } )\n\t\t\t\t\t\t: children }\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t<TreeGridItem ref={ ref }>{ children }</TreeGridItem>\n\t\t\t) }\n\t\t</td>\n\t);\n}\n\n/**\n * `TreeGridCell` is used to create a tree hierarchy.\n * It is not a visually styled component, but instead helps with adding\n * keyboard navigation and roving tab index behaviors to tree grid structures.\n *\n * @see {@link https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html}\n */\nexport const TreeGridCell = forwardRef( UnforwardedTreeGridCell );\nTreeGridCell.displayName = 'TreeGridCell';\n\nexport default TreeGridCell;\n"],"mappings":";;;;;AAMA,SAAS,wBACR,EACC,UACA,kBAAkB,OAClB,GAAG,SAEJ,KACC;CACD,MAAM,UAAU,OAAgC,IAAK;CACrD,6BAA8B,gBAAgB,OAAQ;CAEtD,OACC,oBAAC,MAAD;EAAI,KAAM;EAAU,GAAK;EAAQ,MAAK;EACnC,UAAA,kBACD,oBAAA,UAAA,EAAA,UACG,OAAO,aAAa,aACnB,SAAU;GAAE,GAAG;GAAO;EAAI,CAAE,IAC5B,SACF,CAAA,IAEF,oBAAC,cAAD;GAAoB;GAAQ;EAAwB,CAAA;CAElD,CAAA;AAEN;;;;;;;;AASA,MAAa,eAAe,WAAY,uBAAwB;AAChE,aAAa,cAAc"}