UNPKG

@ackplus/react-tanstack-data-table

Version:

A powerful React data table component built with MUI and TanStack Table

22 lines (21 loc) 1.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getSlotComponent = getSlotComponent; exports.renderSlot = renderSlot; exports.createSlottableComponent = createSlottableComponent; const jsx_runtime_1 = require("react/jsx-runtime"); function getSlotComponent(slots, slotName, fallback) { return (slots === null || slots === void 0 ? void 0 : slots[slotName]) || fallback; } function renderSlot(slotComponent, defaultProps, slotProps) { const mergedProps = Object.assign(Object.assign({}, defaultProps), slotProps); const Component = slotComponent; return (0, jsx_runtime_1.jsx)(Component, Object.assign({}, mergedProps)); } function createSlottableComponent(slotName, defaultComponent) { return function SlottableComponent(props) { var _a; const SlotComponent = getSlotComponent(props.slots, slotName, defaultComponent); return renderSlot(SlotComponent, props.componentProps, (_a = props.slotProps) === null || _a === void 0 ? void 0 : _a[slotName]); }; }