UNPKG

@pantheon-systems/design-toolkit-react

Version:
110 lines (103 loc) 4.1 kB
import _defineProperty from '@babel/runtime/helpers/defineProperty'; import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties'; import PropTypes from 'prop-types'; import React from 'react'; import Icon from '../Icons/Icon.js'; import { FAIcon } from '../lib/customPropTypes.js'; import { jsx, jsxs } from 'react/jsx-runtime'; var _excluded = ["children", "icon", "iconAlt"], _excluded2 = ["as", "children", "className", "icon"]; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } var ListStepped = function ListStepped(_ref) { var children = _ref.children, className = _ref.className; return /*#__PURE__*/jsx("ol", { className: "step-list ".concat(className), children: children }); }; ListStepped.defaultProps = { className: '' }; ListStepped.propTypes = { children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired, className: PropTypes.string }; // // TODO: Deprecate and remove this component. Too much overhead for a simple CSS class change. // var ListUnstyled = function ListUnstyled(_ref2) { var children = _ref2.children, className = _ref2.className; return /*#__PURE__*/jsx("ul", { className: "pl-0 list-none ".concat(className), children: children }); }; ListUnstyled.defaultProps = ListStepped.defaultProps; ListUnstyled.propTypes = ListStepped.propTypes; // // TODO: Deprecate and remove this component. Too much overhead for a simple CSS class change. // var IconListItem = function IconListItem(_ref3) { var children = _ref3.children, icon = _ref3.icon, iconAlt = _ref3.iconAlt, rest = _objectWithoutProperties(_ref3, _excluded); return /*#__PURE__*/jsxs("li", _objectSpread(_objectSpread({}, rest), {}, { children: [icon && /*#__PURE__*/jsx(Icon, { alt: iconAlt, className: "mr-2", fixedWidth: true, icon: icon }), children] })); }; IconListItem.defaultProps = { icon: null, iconAlt: '' }; IconListItem.propTypes = { children: PropTypes.node.isRequired, icon: FAIcon, iconAlt: PropTypes.string }; // // TODO: Deprecate and remove this component. Too much overhead for something that can easily be done in raw HTML. // var IconList = function IconList(_ref4) { var Component = _ref4.as, children = _ref4.children, className = _ref4.className, icon = _ref4.icon, rest = _objectWithoutProperties(_ref4, _excluded2); var childrenWithIcons = React.Children.map(children, function (child) { if (!icon && !child.props.icon) { throw new Error('an `icon` prop must be passed to either the `IconList` or `IconListItem` component.'); } // If the ListItem has an `icon` prop, use it. return child.props.icon ? child : /*#__PURE__*/React.cloneElement(child, { icon: icon }); }); return /*#__PURE__*/jsx(Component, _objectSpread(_objectSpread({ className: "list-none ".concat(className) }, rest), {}, { children: childrenWithIcons })); }; IconList.defaultProps = { as: 'ul', children: null, className: '', icon: null }; IconList.propTypes = { as: PropTypes.oneOf(['ol', 'ul']), children: PropTypes.node, className: PropTypes.string, icon: FAIcon }; export { IconList, IconListItem, ListStepped, ListUnstyled }; //# sourceMappingURL=Lists.js.map