@hitachivantara/uikit-react-core
Version:
Core React components for the NEXT Design System.
70 lines (69 loc) • 2.66 kB
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const React = require("react");
const uikitReactUtils = require("@hitachivantara/uikit-react-utils");
const helpers = require("../../utils/helpers.cjs");
const TableContext = require("../TableContext.cjs");
const TableSectionContext = require("../TableSectionContext.cjs");
const TableCell_styles = require("./TableCell.styles.cjs");
const defaultComponent = "td";
const HvTableCell = React.forwardRef(
function HvTableCell2(props, ref) {
const {
children,
component,
className,
style,
classes: classesProp,
align = "inherit",
variant = "default",
type: typeProp,
stickyColumn = false,
stickyColumnMostLeft = false,
stickyColumnLeastRight = false,
groupColumnMostLeft = false,
groupColumnMostRight = false,
sorted = false,
resizable = false,
resizing = false,
...others
} = uikitReactUtils.useDefaultProps("HvTableCell", props);
const { classes, cx } = TableCell_styles.useClasses(classesProp);
const tableContext = React.useContext(TableContext.default);
const tableSectionContext = React.useContext(TableSectionContext.TableSectionContext);
const type = typeProp || tableSectionContext?.type || "body";
const Component = component || tableContext?.components?.Td || defaultComponent;
return /* @__PURE__ */ jsxRuntime.jsx(
Component,
{
ref,
role: Component === defaultComponent ? null : "cell",
style,
className: cx(
classes.root,
classes[type],
align !== "inherit" && classes[`align${helpers.capitalize(align)}`],
variant !== "default" && classes[`variant${helpers.capitalize(variant)}`],
{
[classes.variantList]: tableContext.variant === "listrow",
[classes.variantListHead]: tableContext.variant === "listrow" && type !== "body",
[classes.sorted]: sorted,
[classes.stickyColumn]: stickyColumn,
[classes.stickyColumnMostLeft]: stickyColumnMostLeft,
[classes.stickyColumnLeastRight]: stickyColumnLeastRight,
[classes.groupColumnMostLeft]: groupColumnMostLeft,
[classes.groupColumnMostRight]: groupColumnMostRight,
[classes.resizable]: resizable,
[classes.resizing]: resizing
},
className
),
...others,
children
}
);
}
);
exports.tableCellClasses = TableCell_styles.staticClasses;
exports.HvTableCell = HvTableCell;