@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 +32 -12
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/ContactInfoPopup/components/Header/Header.d.ts +1 -1
- package/dist/cjs/types/components/ContactInfoPopup/components/MembersSection/MembersSection.d.ts +2 -1
- package/dist/cjs/types/components/ContactInfoPopup/components/MembersSection/components/MemberItem/MemberItem.d.ts +5 -2
- package/dist/esm/index.js +32 -12
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/ContactInfoPopup/components/Header/Header.d.ts +1 -1
- package/dist/esm/types/components/ContactInfoPopup/components/MembersSection/MembersSection.d.ts +2 -1
- package/dist/esm/types/components/ContactInfoPopup/components/MembersSection/components/MemberItem/MemberItem.d.ts +5 -2
- package/package.json +1 -1
|
@@ -8,5 +8,5 @@ type HeaderProps = {
|
|
|
8
8
|
onClose: () => void;
|
|
9
9
|
isBusiness?: boolean;
|
|
10
10
|
};
|
|
11
|
-
declare const Header: ({ imgUrl, name, contactId, navigate, isLoading, onError, onClose, isBusiness }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
declare const Header: ({ imgUrl, name, contactId, navigate, isLoading, onError, onClose, isBusiness, }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
export default Header;
|
package/dist/cjs/types/components/ContactInfoPopup/components/MembersSection/MembersSection.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { IBusiness } from '@trii/types/dist/Contacts';
|
|
|
2
2
|
interface MembersSectionProps {
|
|
3
3
|
contactData?: IBusiness;
|
|
4
4
|
title: string;
|
|
5
|
+
navigate: (path: string) => void;
|
|
5
6
|
}
|
|
6
|
-
declare const MembersSection: ({ contactData, title }: MembersSectionProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
7
|
+
declare const MembersSection: ({ contactData, title, navigate }: MembersSectionProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
7
8
|
export default MembersSection;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
type MemberItemProps = {
|
|
2
2
|
name: string;
|
|
3
|
-
|
|
3
|
+
memberId: string;
|
|
4
|
+
navigate: (path: string) => void;
|
|
5
|
+
};
|
|
6
|
+
declare const MemberItem: ({ name, memberId, navigate }: MemberItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
7
|
export default MemberItem;
|
package/dist/esm/index.js
CHANGED
|
@@ -8814,7 +8814,7 @@ const LoadingContainer = styled$3(Box)({
|
|
|
8814
8814
|
height: 60,
|
|
8815
8815
|
marginBottom: 8,
|
|
8816
8816
|
});
|
|
8817
|
-
const Header = ({ imgUrl, name, contactId, navigate, isLoading = false, onError, onClose, isBusiness }) => {
|
|
8817
|
+
const Header = ({ imgUrl, name, contactId, navigate, isLoading = false, onError, onClose, isBusiness = false, }) => {
|
|
8818
8818
|
const handleNavigation = useCallback((url) => (event) => {
|
|
8819
8819
|
try {
|
|
8820
8820
|
event.preventDefault();
|
|
@@ -8837,9 +8837,7 @@ const Header = ({ imgUrl, name, contactId, navigate, isLoading = false, onError,
|
|
|
8837
8837
|
const handleNavigateToContacts = handleNavigation(isBusiness
|
|
8838
8838
|
? `/a/contacts/business/${contactId}`
|
|
8839
8839
|
: `/a/contacts/contacts/${contactId}`);
|
|
8840
|
-
const handleNavigateToConversations = handleNavigation(
|
|
8841
|
-
? `/a/conversations/conversations?${isBusiness ? 'businessId' : 'contactId'}=${contactId}`
|
|
8842
|
-
: '/a/conversations/conversations');
|
|
8840
|
+
const handleNavigateToConversations = handleNavigation('/a/conversations/conversations');
|
|
8843
8841
|
const displayName = name || 'Unknown Contact';
|
|
8844
8842
|
const avatarAlt = `Avatar for ${displayName}`;
|
|
8845
8843
|
return (jsxRuntimeExports.jsxs(HeaderContainer, { children: [jsxRuntimeExports.jsxs(ButtonsContainer, { children: [jsxRuntimeExports.jsx(SmallIconButton, { color: "info", size: "small", onClick: (e) => {
|
|
@@ -14800,6 +14798,10 @@ const LabelsSection = ({ contactData, title }) => {
|
|
|
14800
14798
|
* @returns True if the object is an IContact
|
|
14801
14799
|
*/
|
|
14802
14800
|
function isContact(obj) {
|
|
14801
|
+
// Si está marcado explícitamente como negocio, no es un contacto regular
|
|
14802
|
+
if (obj?.isBusiness === true) {
|
|
14803
|
+
return false;
|
|
14804
|
+
}
|
|
14803
14805
|
return (obj !== null &&
|
|
14804
14806
|
typeof obj === 'object' &&
|
|
14805
14807
|
typeof obj.id === 'string' &&
|
|
@@ -14832,11 +14834,10 @@ const BusinessSection = ({ contactData, title }) => {
|
|
|
14832
14834
|
* @returns True if the object is an IBusiness
|
|
14833
14835
|
*/
|
|
14834
14836
|
function isBusiness(obj) {
|
|
14835
|
-
// Si el objeto tiene explícitamente la propiedad isBusiness como true, lo consideramos un negocio
|
|
14836
14837
|
if (obj?.isBusiness === true) {
|
|
14838
|
+
// Si se ha marcado explícitamente como negocio con la propiedad isBusiness
|
|
14837
14839
|
return true;
|
|
14838
14840
|
}
|
|
14839
|
-
// De lo contrario, realizamos las comprobaciones tradicionales
|
|
14840
14841
|
return (obj !== null &&
|
|
14841
14842
|
typeof obj === 'object' &&
|
|
14842
14843
|
typeof obj.id === 'string' &&
|
|
@@ -14851,9 +14852,28 @@ function isBusiness(obj) {
|
|
|
14851
14852
|
!('lastName' in obj));
|
|
14852
14853
|
}
|
|
14853
14854
|
|
|
14854
|
-
|
|
14855
|
-
const
|
|
14856
|
-
|
|
14855
|
+
const MemberItem = ({ name, memberId, navigate }) => {
|
|
14856
|
+
const url = `/a/contacts/contacts/${memberId}`;
|
|
14857
|
+
const handleNavigation = (event) => {
|
|
14858
|
+
event.preventDefault();
|
|
14859
|
+
event.stopPropagation();
|
|
14860
|
+
const isNewTab = event.ctrlKey || event.metaKey || event.button === 1; // Ctrl+Click, Cmd+Click, Middle Mouse
|
|
14861
|
+
if (isNewTab) {
|
|
14862
|
+
window.open(url, '_blank', 'noopener,noreferrer');
|
|
14863
|
+
}
|
|
14864
|
+
else {
|
|
14865
|
+
navigate(url);
|
|
14866
|
+
}
|
|
14867
|
+
};
|
|
14868
|
+
return (jsxRuntimeExports.jsx(Typography, { variant: "body2", color: "text.secondary", role: "link", tabIndex: 0, sx: { cursor: 'pointer', '&:hover': { textDecoration: 'underline' } }, onClick: handleNavigation, onMouseDown: (e) => {
|
|
14869
|
+
if (e.button === 1) {
|
|
14870
|
+
handleNavigation(e);
|
|
14871
|
+
}
|
|
14872
|
+
}, onKeyDown: (e) => {
|
|
14873
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
14874
|
+
handleNavigation(e);
|
|
14875
|
+
}
|
|
14876
|
+
}, children: name }));
|
|
14857
14877
|
};
|
|
14858
14878
|
|
|
14859
14879
|
const SectionTitle = styled$3(Typography)({
|
|
@@ -14862,10 +14882,10 @@ const SectionTitle = styled$3(Typography)({
|
|
|
14862
14882
|
marginTop: '16px',
|
|
14863
14883
|
borderBottom: `1px solid lightgray`,
|
|
14864
14884
|
});
|
|
14865
|
-
const MembersSection = ({ contactData, title }) => {
|
|
14885
|
+
const MembersSection = ({ contactData, title, navigate }) => {
|
|
14866
14886
|
if (!contactData || !isBusiness(contactData) || !contactData.members?.length)
|
|
14867
14887
|
return null;
|
|
14868
|
-
return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(SectionTitle, { gutterBottom: true, mt: 2, variant: "subtitle1", children: title }),
|
|
14888
|
+
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)))] }));
|
|
14869
14889
|
};
|
|
14870
14890
|
|
|
14871
14891
|
const PopupContainer = styled$3(Box)(({ theme }) => ({
|
|
@@ -14954,7 +14974,7 @@ const ContactInfoPopup = ({ open, anchorEl, onClose, contactData, avatarImgUrl,
|
|
|
14954
14974
|
window.removeEventListener('keydown', handleKeyDown);
|
|
14955
14975
|
};
|
|
14956
14976
|
}, [open, onClose]);
|
|
14957
|
-
return (jsxRuntimeExports.jsx(Popper, { sx: { zIndex: 1300 }, open: open, anchorEl: anchorEl, placement: "bottom-start", "data-popper-child": "true", children: jsxRuntimeExports.jsx(ClickAwayListener, { onClickAway: onClose, children: jsxRuntimeExports.jsx(PopupContainer, { children: jsxRuntimeExports.jsxs(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') })] }) }) }) }));
|
|
14977
|
+
return (jsxRuntimeExports.jsx(Popper, { sx: { zIndex: 1300 }, open: open, anchorEl: anchorEl, placement: "bottom-start", "data-popper-child": "true", children: jsxRuntimeExports.jsx(ClickAwayListener, { onClickAway: onClose, children: jsxRuntimeExports.jsx(PopupContainer, { children: jsxRuntimeExports.jsxs(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') })] }) }) }) }));
|
|
14958
14978
|
};
|
|
14959
14979
|
|
|
14960
14980
|
export { ContactInfoPopup, TestBox };
|