UNPKG

@procore/core-react

Version:
89 lines (83 loc) 4.15 kB
var _excluded = ["imageUrl", "icon", "initials", "selected", "disabled", "clickable", "children"], _excluded2 = ["children"], _excluded3 = ["children"]; function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; } import React from 'react'; import { Avatar } from '../Avatar/Avatar'; import { addSubcomponents } from '../_utils/addSubcomponents'; import { ContactItemAvatar, ContactItemAvatarWrapper, ContactItemText, ContactItemTextWrapper, ContactItemWrapper } from './ContactItem.styles'; var ContactItem_ = /*#__PURE__*/React.forwardRef(function ContactItem(_ref, ref) { var imageUrl = _ref.imageUrl, icon = _ref.icon, initials = _ref.initials, _ref$selected = _ref.selected, selected = _ref$selected === void 0 ? false : _ref$selected, _ref$disabled = _ref.disabled, disabled = _ref$disabled === void 0 ? false : _ref$disabled, _ref$clickable = _ref.clickable, clickable = _ref$clickable === void 0 ? false : _ref$clickable, children = _ref.children, props = _objectWithoutProperties(_ref, _excluded); var showAvatar = imageUrl || icon || initials; return /*#__PURE__*/React.createElement(ContactItemWrapper, _extends({ $selected: selected, $disabled: disabled, $clickable: clickable, "aria-disabled": disabled || undefined, "aria-selected": selected || undefined, ref: ref }, props), showAvatar && /*#__PURE__*/React.createElement(ContactItemAvatarWrapper, null, /*#__PURE__*/React.createElement(ContactItemAvatar, { "aria-hidden": true, size: "lg", disabled: disabled }, function () { if (imageUrl) return /*#__PURE__*/React.createElement(Avatar.Portrait, { imageUrl: imageUrl, "aria-hidden": true }); if (icon) return /*#__PURE__*/React.createElement(Avatar.Icon, { icon: icon, "aria-hidden": true }); if (initials) return /*#__PURE__*/React.createElement(Avatar.Label, { "aria-hidden": true }, initials); }())), /*#__PURE__*/React.createElement(ContactItemTextWrapper, null, children)); }); var Title = /*#__PURE__*/React.forwardRef(function Title(_ref2, ref) { var children = _ref2.children, props = _objectWithoutProperties(_ref2, _excluded2); return /*#__PURE__*/React.createElement(ContactItemText, _extends({ weight: "bold", color: "gray15", ref: ref }, props), children); }); var Description = /*#__PURE__*/React.forwardRef(function Description(_ref3, ref) { var children = _ref3.children, props = _objectWithoutProperties(_ref3, _excluded3); return /*#__PURE__*/React.createElement(ContactItemText, _extends({ weight: "regular", color: "gray45", ref: ref }, props), children); }); ContactItem_.displayName = 'ContactItem'; Title.displayName = 'ContactItem.Title'; Description.displayName = 'ContactItem.Description'; /** The contact item component is a more complex alternative to a standard line of text found in a list or form component. Use this component when you have a list or set of items that can benefit from an additional line of content or an avatar. @since 10.19.0 @see [Storybook](https://stories.core.procore.com/?path=/story/core-react_demos-contact-item--demo) @see [Design Guidelines](https://design.procore.com/contact-item) */ export var ContactItem = addSubcomponents({ Title: Title, Description: Description }, ContactItem_); //# sourceMappingURL=ContactItem.js.map