UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

81 lines 2.7 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 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) { var _content$, _content$2; 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$ = content[0]) === null || _content$ === void 0 ? void 0 : _content$.type) !== TableContainer.Head) { _unshiftInstanceProperty(content).call(content, _TableContainer$Head || (_TableContainer$Head = _jsx(TableContainer.Head, {}, "head"))); } if (((_content$2 = content[2]) === null || _content$2 === void 0 ? void 0 : _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', 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