UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

39 lines 1.67 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; var _EditButton; const _excluded = ["children", "className", "title", "onEdit"]; import React, { useMemo } from 'react'; import classnames from 'classnames'; import { convertJsxToString } from '../../../../../shared/component-helper'; import { Flex } from '../../../../../components'; import { Lead } from '../../../../../elements'; import Toolbar from '../Toolbar/Toolbar'; import SectionContainer from '../containers/SectionContainer'; import EditButton from './EditButton'; function ViewContainer(props) { const _ref = props || {}, { children, className, title, onEdit } = _ref, restProps = _objectWithoutProperties(_ref, _excluded); const ariaLabel = useMemo(() => convertJsxToString(title), [title]); const hasToolbar = React.Children.toArray(children).some(child => { return (child === null || child === void 0 ? void 0 : child['type']) === Toolbar; }); return React.createElement(SectionContainer, _extends({ mode: "view", ariaLabel: ariaLabel, className: classnames('dnb-forms-section-view-block', className) }, restProps), React.createElement(Flex.Stack, null, title && React.createElement(Lead, { size: "basis" }, title), children, hasToolbar ? null : React.createElement(Toolbar, { onEdit: onEdit }, _EditButton || (_EditButton = React.createElement(EditButton, null))))); } ViewContainer.EditButton = EditButton; ViewContainer._supportsSpacingProps = true; export default ViewContainer; //# sourceMappingURL=ViewContainer.js.map