UNPKG

@wordpress/components

Version:
33 lines (32 loc) • 1.25 kB
import { forwardRef, useRef } from "@wordpress/element"; import TreeGridItem from "./item.mjs"; import { useValidateTreeGridStructure } from "./use-validate-tree-grid-structure.mjs"; import { Fragment, jsx } from "react/jsx-runtime"; // packages/components/src/tree-grid/cell.tsx function UnforwardedTreeGridCell({ children, withoutGridItem = false, ...props }, ref) { const cellRef = useRef(null); useValidateTreeGridStructure("TreeGridCell", cellRef); return /* @__PURE__ */ jsx("td", { ref: cellRef, ...props, role: "gridcell", children: withoutGridItem ? /* @__PURE__ */ jsx(Fragment, { children: typeof children === "function" ? children({ ...props, ref }) : children }) : /* @__PURE__ */ jsx(TreeGridItem, { ref, children }) }); } /** * `TreeGridCell` is used to create a tree hierarchy. * It is not a visually styled component, but instead helps with adding * keyboard navigation and roving tab index behaviors to tree grid structures. * * @see {@link https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html} */ const TreeGridCell = forwardRef(UnforwardedTreeGridCell); TreeGridCell.displayName = "TreeGridCell"; export { TreeGridCell, TreeGridCell as default }; //# sourceMappingURL=cell.mjs.map