@payfit/unity-components
Version:
39 lines (38 loc) • 1.39 kB
JavaScript
import { useTableContext as e } from "../Table.context.js";
import { forwardRef as t, memo as n, useMemo as r } from "react";
import { uyTv as i } from "@payfit/unity-themes";
import { jsx as a } from "react/jsx-runtime";
//#region src/components/table/parts/TableCell.tsx
var o = i({
base: ["uy:px-200 uy:py-150 uy:text-content-neutral uy:typography-body", "uy:focus-visible:outline-2 uy:focus-visible:outline-solid uy:focus-visible:outline-offset-[-2px] uy:focus-visible:outline-utility-focus-ring"],
variants: { align: {
left: "uy:text-left",
center: "uy:text-center",
right: "uy:text-right"
} }
}), s = n(t(({ children: t, colIndex: n = 0, rowIndex: i = 0, align: s, onKeyDown: c, onFocus: l, className: u, isRowHeader: d = !1, isFocusable: f = !0, ...p }, m) => {
let { keyboardNavigation: h } = e(), { isCellFocused: g, handleCellKeyDown: _, handleCellFocus: v } = h, y = r(() => o({
align: s,
className: u
}), [s, u]), b = f && g(i, n);
return /* @__PURE__ */ a(d ? "th" : "td", {
ref: m,
role: d ? "rowheader" : "gridcell",
"aria-colindex": n + 1,
tabIndex: b ? 0 : -1,
"data-focusable": f,
className: y,
onKeyDown: (e) => {
e.key !== "Tab" && (_(e), c?.(e));
},
onFocus: (e) => {
v(e), l?.(e);
},
"data-dd-privacy": "mask",
...p,
children: t
});
}));
s.displayName = "TableCell";
//#endregion
export { s as TableCell, o as tableCell };