UNPKG

carbon-react

Version:

A library of reusable React components for easily building user interfaces.

2 lines (1 loc) 2.91 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime");require("react"),require("../../style/utils/filter-styled-system-padding-props.js");var r=require("../../style/utils/filter-styled-system-margin-props.js"),t=require("../../__internal__/utils/helpers/tags/tags.js"),l=require("../../__internal__/utils/logger/index.js"),n=require("./profile.style.js");function o(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function a(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},l=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(l=l.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),l.forEach((function(r){o(e,r,t[r])}))}return e}let i=!1;const s=o=>{var{src:s,alt:c,className:u,initials:f,name:d,size:p,email:y,text:m,darkBackground:b,backgroundColor:g,foregroundColor:j}=o,O=function(e,r){if(null==e)return{};var t,l,n=function(e,r){if(null==e)return{};var t,l,n={},o=Object.keys(e);for(l=0;l<o.length;l++)t=o[l],r.indexOf(t)>=0||(n[t]=e[t]);return n}(e,r);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(l=0;l<o.length;l++)t=o[l],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}(o,["src","alt","className","initials","name","size","email","text","darkBackground","backgroundColor","foregroundColor"]);const P={darkBackground:b,alt:c,name:d,initials:f||function(e){if(!e)return"";const r=e.match(/\b\w/g);return r?r.join(""):""}(d).slice(0,3).toUpperCase(),size:p,backgroundColor:g,foregroundColor:j,"data-role":"profile-portrait"};return i||d||!y&&!m||(i=!0,l.default.warn("[WARNING] The `email` or `text` prop should not be used without the `name` prop in `Profile`. Please use the `name` prop as well as `email` or `text`.")),e.jsxs(n.ProfileStyle,(h=a({className:u,hasSrc:!!s,darkBackground:b},t.default("profile",O),r.default(O)),x=null!=(x={children:[s?e.jsx(n.ProfileAvatarStyle,a({src:s,"data-element":"user-image"},P)):e.jsx(n.ProfileAvatarStyle,a({},P)),d?e.jsxs(n.ProfileDetailsStyle,{size:p,hasSrc:!!s,"data-element":"details",children:[e.jsx(n.ProfileNameStyle,{size:p,"data-element":"name",children:d}),y&&e.jsx(n.ProfileEmailStyle,{href:`mailto: ${y}`,size:p,"data-role":"email-link",darkBackground:b,"data-element":"email",children:y}),m&&e.jsx(n.ProfileTextStyle,{size:p,"data-element":"text",children:m})]}):null]})?x:{},Object.getOwnPropertyDescriptors?Object.defineProperties(h,Object.getOwnPropertyDescriptors(x)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(x)).forEach((function(e){Object.defineProperty(h,e,Object.getOwnPropertyDescriptor(x,e))})),h));var h,x};exports.Profile=s,exports.default=s;