UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

79 lines 2.5 kB
var _TableContainer$Head, _TableContainer$Foot; import _unshiftInstanceProperty from "core-js-pure/stable/instance/unshift.js"; import _pushInstanceProperty from "core-js-pure/stable/instance/push.js"; import { clsx } from 'clsx'; import TableScrollView from "./TableScrollView.js"; import { useSpacing } from "../space/SpacingUtils.js"; import { validateDOMAttributes } from "../../shared/component-helper.js"; import withComponentMarkers from "../../shared/helpers/withComponentMarkers.js"; import { jsx as _jsx } from "react/jsx-runtime"; export default function TableContainer(props) { const { children, className, ...rest } = props; validateDOMAttributes(props, rest); const sectionProps = useSpacing(props, { className: clsx('dnb-table__container', className), ...rest }); const ScrollView = TableScrollView; const isArray = Array.isArray(children); const content = isArray ? children : [children]; if (content[0]?.type !== TableContainer.Head) { _unshiftInstanceProperty(content).call(content, _TableContainer$Head || (_TableContainer$Head = _jsx(TableContainer.Head, {}, "head"))); } if (content[2]?.type !== TableContainer.Foot) { _pushInstanceProperty(content).call(content, _TableContainer$Foot || (_TableContainer$Foot = _jsx(TableContainer.Foot, {}, "foot"))); } return _jsx("section", { ...sectionProps, children: _jsx(ScrollView, { children: content }) }); } export function TableContainerBody(props) { const { children, className, ...rest } = props; return _jsx("div", { className: clsx('dnb-table__container__body', className), ...rest, children: children }); } export function TableContainerHead(props) { const { children, className, ...rest } = props; return _jsx("div", { className: clsx('dnb-table__container__head', !children && 'dnb-table__container__head--empty', className), ...rest, children: children }); } export function TableContainerFoot(props) { const { children, className, ...rest } = props; return _jsx("div", { className: clsx('dnb-table__container__foot', !children && 'dnb-table__container__foot--empty', className), ...rest, children: children }); } TableContainer.Body = TableContainerBody; TableContainer.Head = TableContainerHead; TableContainer.Foot = TableContainerFoot; withComponentMarkers(TableContainer, { _supportsSpacingProps: true }); //# sourceMappingURL=TableContainer.js.map