UNPKG

@carbon/ibm-security

Version:

Carbon for Cloud & Cognitive IBM Security UI components

94 lines (91 loc) 4.36 kB
import _extends from "@babel/runtime/helpers/extends"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; var _excluded = ["border", "bordered", "children", "className", "size"], _excluded2 = ["children", "className"], _excluded3 = ["children", "className"], _excluded4 = ["children", "className"]; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /** * @file Type layout. * @copyright IBM Security 2019 - 2021 */ import classnames from 'classnames'; import { bool, node, oneOf, string } from 'prop-types'; import React from 'react'; import { getComponentNamespace } from '../../globals/namespace'; import deprecatedProp from '../../globals/prop-types'; import { StructuredListBody, StructuredListCell, StructuredListRow, StructuredListWrapper } from '../StructuredList'; export var namespace = getComponentNamespace('type-layout__container'); // TODO: `2.x` - Remove deprecated prop `bordered`. /** * Type layouts provide an orderly layout of terms and definitions. */ var TypeLayout = function TypeLayout(_ref) { var border = _ref.border, bordered = _ref.bordered, children = _ref.children, className = _ref.className, size = _ref.size, other = _objectWithoutProperties(_ref, _excluded); return /*#__PURE__*/React.createElement(StructuredListWrapper, _extends({ className: classnames(namespace, _defineProperty(_defineProperty({}, "".concat(namespace, "--bordered"), border || bordered), "".concat(namespace, "--").concat(size), size), className) }, other), children); }; var TypeLayoutBody = function TypeLayoutBody(_ref2) { var children = _ref2.children, className = _ref2.className, other = _objectWithoutProperties(_ref2, _excluded2); return /*#__PURE__*/React.createElement(StructuredListBody, _extends({ className: classnames("".concat(namespace, "__body"), className) }, other), children); }; var TypeLayoutCell = function TypeLayoutCell(_ref3) { var children = _ref3.children, className = _ref3.className, other = _objectWithoutProperties(_ref3, _excluded3); return /*#__PURE__*/React.createElement(StructuredListCell, _extends({ className: classnames("".concat(namespace, "__cell"), className), tabIndex: "-1" }, other), children); }; var TypeLayoutRow = function TypeLayoutRow(_ref4) { var children = _ref4.children, className = _ref4.className, other = _objectWithoutProperties(_ref4, _excluded4); return /*#__PURE__*/React.createElement(StructuredListRow, _extends({ className: classnames("".concat(namespace, "__row"), className), role: "row" }, other), children); }; var propTypes = { /** Provide the contents of the node */ children: node, /** Provide an optional class to be applied to the containing node */ className: string }; TypeLayout.propTypes = _objectSpread(_objectSpread({}, propTypes), {}, { /** Specify if the type layout has a border */ border: bool, /** Deprecated in favor of `border` */ bordered: deprecatedProp('border', bool), /** Specify the size of the type layout, from a list of available sizes */ size: oneOf(['xs', 'sm', 'md', 'lg']) }); var defaultProps = { children: null, className: null }; TypeLayout.defaultProps = _objectSpread(_objectSpread({}, defaultProps), {}, { border: false, bordered: null, size: 'md' }); TypeLayoutBody.propTypes = propTypes; TypeLayoutBody.defaultProps = defaultProps; TypeLayoutCell.propTypes = propTypes; TypeLayoutCell.defaultProps = defaultProps; TypeLayoutRow.propTypes = propTypes; TypeLayoutRow.defaultProps = defaultProps; export { TypeLayout, TypeLayoutBody, TypeLayoutCell, TypeLayoutRow };