UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

78 lines 2.31 kB
var _TableContainer$Head, _TableContainer$Foot; import React from 'react'; import clsx from 'clsx'; import TableScrollView from "./TableScrollView.js"; import { applySpacing } 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 = applySpacing(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) { content.unshift(_TableContainer$Head || (_TableContainer$Head = _jsx(TableContainer.Head, {}, "head"))); } if (content[2]?.type !== TableContainer.Foot) { content.push(_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', className, !children && 'dnb-table__container__head--empty'), ...rest, children: children }); } export function TableContainerFoot(props) { const { children, className, ...rest } = props; return _jsx("div", { className: clsx('dnb-table__container__foot', className, !children && 'dnb-table__container__foot--empty'), ...rest, children: children }); } TableContainer.Body = TableContainerBody; TableContainer.Head = TableContainerHead; TableContainer.Foot = TableContainerFoot; withComponentMarkers(TableContainer, { _supportsSpacingProps: true }); //# sourceMappingURL=TableContainer.js.map