@kubit-ui-web/react-components
Version:
Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience
43 lines • 2.42 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TableV2 = exports.Table = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = __importDefault(require("react"));
const stylesName_1 = require("../../constants/stylesName/stylesName");
const useStylesV2_1 = require("../../hooks/useStyles/useStylesV2");
const useTableHasScroll_1 = require("./hooks/useTableHasScroll");
const useTableShadow_1 = require("./hooks/useTableShadow");
const useTableStickyLeftColumns_1 = require("./hooks/useTableStickyLeftColumns");
const useTableStickyRightColumns_1 = require("./hooks/useTableStickyRightColumns");
const tableStandAlone_1 = require("./tableStandAlone");
const TableComponent = ({ variant, ctv, autoRightStickyCalc = true, autoLeftStickyCalc = true, disableShadowEffects, ...props }, ref) => {
const styles = (0, useStylesV2_1.useStylesV2)({
styleName: stylesName_1.STYLES_NAME.TABLE_V2,
variantName: variant,
customTokens: ctv,
isOptional: true,
});
const innerRef = react_1.default.useRef(null);
react_1.default.useImperativeHandle(ref, () => innerRef.current, []);
// Indicates if table has scroll in order to add accesibility aria props
const { hasScroll } = (0, useTableHasScroll_1.useTableHasScroll)({ ref: innerRef, disabled: props.hasScrollDisabled });
// Set column sticky right if table has horizontal scroll
(0, useTableStickyRightColumns_1.useTableStickyRightColumns)({ ref: innerRef, disabled: !autoRightStickyCalc });
// Set column sticky left if table has horizontal scroll
(0, useTableStickyLeftColumns_1.useTableStickyLeftColumns)({ ref: innerRef, disabled: !autoLeftStickyCalc });
// Set shadow when scrolling
(0, useTableShadow_1.useTableShadow)({
ref: innerRef,
headBoxShadow: styles?.headBoxShadow,
leftBoxShadow: styles?.leftBoxShadow,
rightBoxShadow: styles?.rightBoxShadow,
disabled: disableShadowEffects,
});
return (0, jsx_runtime_1.jsx)(tableStandAlone_1.TableStandAlone, { ref: innerRef, hasScroll: hasScroll, styles: styles, ...props });
};
exports.Table = react_1.default.forwardRef(TableComponent);
exports.TableV2 = exports.Table;
//# sourceMappingURL=table.js.map