UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

73 lines 2.94 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; var _TableContainer$Head, _TableContainer$Foot; const _excluded = ["children", "className"], _excluded2 = ["children", "className"], _excluded3 = ["children", "className"], _excluded4 = ["children", "className"]; import React from 'react'; import classnames from 'classnames'; import TableScrollView from './TableScrollView'; import { createSpacingClasses } from '../space/SpacingUtils'; import { validateDOMAttributes } from '../../shared/component-helper'; export default function TableContainer(props) { var _content$, _content$2; const { children, className } = props, rest = _objectWithoutProperties(props, _excluded); const spacingClasses = createSpacingClasses(props); validateDOMAttributes(props, 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) { content.unshift(_TableContainer$Head || (_TableContainer$Head = React.createElement(TableContainer.Head, { key: "head" }))); } if (((_content$2 = content[2]) === null || _content$2 === void 0 ? void 0 : _content$2.type) !== TableContainer.Foot) { content.push(_TableContainer$Foot || (_TableContainer$Foot = React.createElement(TableContainer.Foot, { key: "foot" }))); } return React.createElement("section", _extends({ className: classnames('dnb-table__container', className, spacingClasses) }, rest), React.createElement(ScrollView, null, content)); } export function TableContainerBody(props) { const { children, className } = props, rest = _objectWithoutProperties(props, _excluded2); return React.createElement("div", _extends({ className: classnames('dnb-table__container__body', className) }, rest), children); } export function TableContainerHead(props) { const { children, className } = props, rest = _objectWithoutProperties(props, _excluded3); return React.createElement("div", _extends({ className: classnames('dnb-table__container__head', className, !children && 'dnb-table__container__head--empty') }, rest), children); } export function TableContainerFoot(props) { const { children, className } = props, rest = _objectWithoutProperties(props, _excluded4); return React.createElement("div", _extends({ className: classnames('dnb-table__container__foot', className, !children && 'dnb-table__container__foot--empty') }, rest), children); } TableContainer.Body = TableContainerBody; TableContainer.Head = TableContainerHead; TableContainer.Foot = TableContainerFoot; TableContainer._supportsSpacingProps = true; //# sourceMappingURL=TableContainer.js.map