@trii/components 2.0.23 → 2.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -8834,7 +8834,7 @@ const LoadingContainer = material.styled(material.Box)({
8834
8834
  height: 60,
8835
8835
  marginBottom: 8,
8836
8836
  });
8837
- const Header = ({ imgUrl, name, contactId, navigate, isLoading = false, onError, onClose, isBusiness }) => {
8837
+ const Header = ({ imgUrl, name, contactId, navigate, isLoading = false, onError, onClose, isBusiness = false, }) => {
8838
8838
  const handleNavigation = React.useCallback((url) => (event) => {
8839
8839
  try {
8840
8840
  event.preventDefault();
@@ -8857,9 +8857,7 @@ const Header = ({ imgUrl, name, contactId, navigate, isLoading = false, onError,
8857
8857
  const handleNavigateToContacts = handleNavigation(isBusiness
8858
8858
  ? `/a/contacts/business/${contactId}`
8859
8859
  : `/a/contacts/contacts/${contactId}`);
8860
- const handleNavigateToConversations = handleNavigation(contactId
8861
- ? `/a/conversations/conversations?${isBusiness ? 'businessId' : 'contactId'}=${contactId}`
8862
- : '/a/conversations/conversations');
8860
+ const handleNavigateToConversations = handleNavigation('/a/conversations/conversations');
8863
8861
  const displayName = name || 'Unknown Contact';
8864
8862
  const avatarAlt = `Avatar for ${displayName}`;
8865
8863
  return (jsxRuntimeExports.jsxs(HeaderContainer, { children: [jsxRuntimeExports.jsxs(ButtonsContainer, { children: [jsxRuntimeExports.jsx(SmallIconButton, { color: "info", size: "small", onClick: (e) => {
@@ -14820,6 +14818,10 @@ const LabelsSection = ({ contactData, title }) => {
14820
14818
  * @returns True if the object is an IContact
14821
14819
  */
14822
14820
  function isContact(obj) {
14821
+ // Si está marcado explícitamente como negocio, no es un contacto regular
14822
+ if (obj?.isBusiness === true) {
14823
+ return false;
14824
+ }
14823
14825
  return (obj !== null &&
14824
14826
  typeof obj === 'object' &&
14825
14827
  typeof obj.id === 'string' &&
@@ -14852,11 +14854,10 @@ const BusinessSection = ({ contactData, title }) => {
14852
14854
  * @returns True if the object is an IBusiness
14853
14855
  */
14854
14856
  function isBusiness(obj) {
14855
- // Si el objeto tiene explícitamente la propiedad isBusiness como true, lo consideramos un negocio
14856
14857
  if (obj?.isBusiness === true) {
14858
+ // Si se ha marcado explícitamente como negocio con la propiedad isBusiness
14857
14859
  return true;
14858
14860
  }
14859
- // De lo contrario, realizamos las comprobaciones tradicionales
14860
14861
  return (obj !== null &&
14861
14862
  typeof obj === 'object' &&
14862
14863
  typeof obj.id === 'string' &&
@@ -14871,9 +14872,28 @@ function isBusiness(obj) {
14871
14872
  !('lastName' in obj));
14872
14873
  }
14873
14874
 
14874
- // Components
14875
- const MemberItem = ({ name }) => {
14876
- return (jsxRuntimeExports.jsx(material.Typography, { variant: "body2", color: "text.secondary", children: name }));
14875
+ const MemberItem = ({ name, memberId, navigate }) => {
14876
+ const url = `/a/contacts/contacts/${memberId}`;
14877
+ const handleNavigation = (event) => {
14878
+ event.preventDefault();
14879
+ event.stopPropagation();
14880
+ const isNewTab = event.ctrlKey || event.metaKey || event.button === 1; // Ctrl+Click, Cmd+Click, Middle Mouse
14881
+ if (isNewTab) {
14882
+ window.open(url, '_blank', 'noopener,noreferrer');
14883
+ }
14884
+ else {
14885
+ navigate(url);
14886
+ }
14887
+ };
14888
+ return (jsxRuntimeExports.jsx(material.Typography, { variant: "body2", color: "text.secondary", role: "link", tabIndex: 0, sx: { cursor: 'pointer', '&:hover': { textDecoration: 'underline' } }, onClick: handleNavigation, onMouseDown: (e) => {
14889
+ if (e.button === 1) {
14890
+ handleNavigation(e);
14891
+ }
14892
+ }, onKeyDown: (e) => {
14893
+ if (e.key === 'Enter' || e.key === ' ') {
14894
+ handleNavigation(e);
14895
+ }
14896
+ }, children: name }));
14877
14897
  };
14878
14898
 
14879
14899
  const SectionTitle = material.styled(material.Typography)({
@@ -14882,10 +14902,10 @@ const SectionTitle = material.styled(material.Typography)({
14882
14902
  marginTop: '16px',
14883
14903
  borderBottom: `1px solid lightgray`,
14884
14904
  });
14885
- const MembersSection = ({ contactData, title }) => {
14905
+ const MembersSection = ({ contactData, title, navigate }) => {
14886
14906
  if (!contactData || !isBusiness(contactData) || !contactData.members?.length)
14887
14907
  return null;
14888
- return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(SectionTitle, { gutterBottom: true, mt: 2, variant: "subtitle1", children: title }), jsxRuntimeExports.jsx(material.Typography, { variant: "body2", color: "text.secondary", children: contactData?.members.map((member) => (jsxRuntimeExports.jsx(MemberItem, { name: member.name }, member.id))) })] }));
14908
+ return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(SectionTitle, { gutterBottom: true, mt: 2, variant: "subtitle1", children: title }), contactData?.members.map((member) => (jsxRuntimeExports.jsx(MemberItem, { memberId: String(member.id), name: member.name, navigate: navigate }, member.id)))] }));
14889
14909
  };
14890
14910
 
14891
14911
  const PopupContainer = material.styled(material.Box)(({ theme }) => ({
@@ -14974,7 +14994,7 @@ const ContactInfoPopup = ({ open, anchorEl, onClose, contactData, avatarImgUrl,
14974
14994
  window.removeEventListener('keydown', handleKeyDown);
14975
14995
  };
14976
14996
  }, [open, onClose]);
14977
- return (jsxRuntimeExports.jsx(material.Popper, { sx: { zIndex: 1300 }, open: open, anchorEl: anchorEl, placement: "bottom-start", "data-popper-child": "true", children: jsxRuntimeExports.jsx(material.ClickAwayListener, { onClickAway: onClose, children: jsxRuntimeExports.jsx(PopupContainer, { children: jsxRuntimeExports.jsxs(material.CardContent, { children: [jsxRuntimeExports.jsx(Header, { navigate: navigate, contactId: contactData?.id, imgUrl: avatarImgUrl, name: contactData?.name, onClose: onClose, isBusiness: dataIsBusiness }), jsxRuntimeExports.jsx(LabelsSection, { contactData: contactData, title: t('labels') }), dataIsContact && (jsxRuntimeExports.jsx(BusinessSection, { contactData: contactData, title: t('business') })), dataIsBusiness && (jsxRuntimeExports.jsx(MembersSection, { contactData: contactData, title: t('businessMembers') })), contactMethods.map((method, index) => (jsxRuntimeExports.jsx(ContactMethod, { icon: method.icon, title: method.title, contactList: method.contactList, showTitle: method.showTitle }, index))), jsxRuntimeExports.jsx(Properties, { properties: contactData?.properties, title: t('properties') })] }) }) }) }));
14997
+ return (jsxRuntimeExports.jsx(material.Popper, { sx: { zIndex: 1300 }, open: open, anchorEl: anchorEl, placement: "bottom-start", "data-popper-child": "true", children: jsxRuntimeExports.jsx(material.ClickAwayListener, { onClickAway: onClose, children: jsxRuntimeExports.jsx(PopupContainer, { children: jsxRuntimeExports.jsxs(material.CardContent, { children: [jsxRuntimeExports.jsx(Header, { navigate: navigate, contactId: contactData?.id, imgUrl: avatarImgUrl, name: contactData?.name, onClose: onClose, isBusiness: dataIsBusiness }), jsxRuntimeExports.jsx(LabelsSection, { contactData: contactData, title: t('labels') }), dataIsContact && (jsxRuntimeExports.jsx(BusinessSection, { contactData: contactData, title: t('business') })), dataIsBusiness && (jsxRuntimeExports.jsx(MembersSection, { contactData: contactData, title: t('businessMembers'), navigate: navigate })), contactMethods.map((method, index) => (jsxRuntimeExports.jsx(ContactMethod, { icon: method.icon, title: method.title, contactList: method.contactList, showTitle: method.showTitle }, index))), jsxRuntimeExports.jsx(Properties, { properties: contactData?.properties, title: t('properties') })] }) }) }) }));
14978
14998
  };
14979
14999
 
14980
15000
  exports.ContactInfoPopup = ContactInfoPopup;