carbon-react
Version:
A library of reusable React components for easily building user interfaces.
2 lines (1 loc) • 2.79 kB
JavaScript
import{jsxs as e,jsx as r}from"react/jsx-runtime";import"react";import"../../style/utils/filter-styled-system-padding-props.js";import t from"../../style/utils/filter-styled-system-margin-props.js";import o from"../../__internal__/utils/helpers/tags/tags.js";import n from"../../__internal__/utils/logger/index.js";import{ProfileStyle as a,ProfileAvatarStyle as l,ProfileDetailsStyle as i,ProfileNameStyle as s,ProfileEmailStyle as c,ProfileTextStyle as u}from"./profile.style.js";function p(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function m(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),o.forEach((function(r){p(e,r,t[r])}))}return e}let f=!1;const d=p=>{var{src:d,alt:b,className:g,initials:y,name:O,size:j,email:h,text:k,darkBackground:w,backgroundColor:P,foregroundColor:v}=p,x=function(e,r){if(null==e)return{};var t,o,n=function(e,r){if(null==e)return{};var t,o,n={},a=Object.keys(e);for(o=0;o<a.length;o++)t=a[o],r.indexOf(t)>=0||(n[t]=e[t]);return n}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)t=a[o],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}(p,["src","alt","className","initials","name","size","email","text","darkBackground","backgroundColor","foregroundColor"]);const S={darkBackground:w,alt:b,name:O,initials:y||function(e){if(!e)return"";const r=e.match(/\b\w/g);return r?r.join(""):""}(O).slice(0,3).toUpperCase(),size:j,backgroundColor:P,foregroundColor:v,"data-role":"profile-portrait"};return f||O||!h&&!k||(f=!0,n.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(a,(_=m({className:g,hasSrc:!!d,darkBackground:w},o("profile",x),t(x)),z=null!=(z={children:[r(l,m(d?{src:d,"data-element":"user-image"}:{},S)),O?e(i,{size:j,hasSrc:!!d,"data-element":"details",children:[r(s,{size:j,"data-element":"name",children:O}),h&&r(c,{href:`mailto: ${h}`,size:j,"data-role":"email-link",darkBackground:w,"data-element":"email",children:h}),k&&r(u,{size:j,"data-element":"text",children:k})]}):null]})?z:{},Object.getOwnPropertyDescriptors?Object.defineProperties(_,Object.getOwnPropertyDescriptors(z)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(z)).forEach((function(e){Object.defineProperty(_,e,Object.getOwnPropertyDescriptor(z,e))})),_));var _,z};export{d as Profile,d as default};