@trii/components 2.0.13 → 2.0.15
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 +62 -32
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/ContactInfoPopup/components/Header/Header.d.ts +6 -4
- package/dist/esm/index.js +64 -34
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/ContactInfoPopup/components/Header/Header.d.ts +6 -4
- package/package.json +1 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
type HeaderProps = {
|
|
2
|
-
imgUrl
|
|
3
|
-
name
|
|
4
|
-
contactId
|
|
2
|
+
imgUrl?: string;
|
|
3
|
+
name?: string;
|
|
4
|
+
contactId?: string;
|
|
5
5
|
navigate: (path: string) => void;
|
|
6
|
+
isLoading?: boolean;
|
|
7
|
+
onError?: (error: Error) => void;
|
|
6
8
|
};
|
|
7
|
-
declare const Header: ({ imgUrl, name, contactId, navigate }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare const Header: ({ imgUrl, name, contactId, navigate, isLoading, onError, }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
10
|
export default Header;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import React__default, { useEffect } from 'react';
|
|
3
|
-
import { Button, styled as styled$3, Box, IconButton, Avatar, Typography, Tooltip, Chip, Popper, ClickAwayListener, CardContent } from '@mui/material';
|
|
2
|
+
import React__default, { useCallback, useEffect } from 'react';
|
|
3
|
+
import { Button, styled as styled$3, Box, IconButton, Avatar, Typography, CircularProgress, Tooltip, Chip, Popper, ClickAwayListener, CardContent } from '@mui/material';
|
|
4
4
|
import { withEmotionCache, ThemeContext, CacheProvider, Global, css, keyframes } from '@emotion/react';
|
|
5
5
|
|
|
6
6
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -7051,7 +7051,7 @@ var require$$1 = /*@__PURE__*/getAugmentedNamespace(formatMuiErrorMessage);
|
|
|
7051
7051
|
|
|
7052
7052
|
var require$$2 = /*@__PURE__*/getAugmentedNamespace(clamp);
|
|
7053
7053
|
|
|
7054
|
-
var _interopRequireDefault$
|
|
7054
|
+
var _interopRequireDefault$3 = interopRequireDefaultExports;
|
|
7055
7055
|
Object.defineProperty(colorManipulator, "__esModule", {
|
|
7056
7056
|
value: true
|
|
7057
7057
|
});
|
|
@@ -7073,8 +7073,8 @@ colorManipulator.private_safeEmphasize = private_safeEmphasize;
|
|
|
7073
7073
|
colorManipulator.private_safeLighten = private_safeLighten;
|
|
7074
7074
|
colorManipulator.recomposeColor = recomposeColor;
|
|
7075
7075
|
colorManipulator.rgbToHex = rgbToHex;
|
|
7076
|
-
var _formatMuiErrorMessage2 = _interopRequireDefault$
|
|
7077
|
-
var _clamp = _interopRequireDefault$
|
|
7076
|
+
var _formatMuiErrorMessage2 = _interopRequireDefault$3(require$$1);
|
|
7077
|
+
var _clamp = _interopRequireDefault$3(require$$2);
|
|
7078
7078
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
7079
7079
|
|
|
7080
7080
|
/**
|
|
@@ -8196,21 +8196,21 @@ var require$$7 = /*@__PURE__*/getAugmentedNamespace(createTheme$1);
|
|
|
8196
8196
|
|
|
8197
8197
|
var require$$8 = /*@__PURE__*/getAugmentedNamespace(styleFunctionSx);
|
|
8198
8198
|
|
|
8199
|
-
var _interopRequireDefault$
|
|
8199
|
+
var _interopRequireDefault$2 = interopRequireDefaultExports;
|
|
8200
8200
|
Object.defineProperty(createStyled$1, "__esModule", {
|
|
8201
8201
|
value: true
|
|
8202
8202
|
});
|
|
8203
8203
|
var _default = createStyled$1.default = createStyled;
|
|
8204
8204
|
createStyled$1.shouldForwardProp = shouldForwardProp;
|
|
8205
8205
|
createStyled$1.systemDefaultTheme = void 0;
|
|
8206
|
-
var _extends2 = _interopRequireDefault$
|
|
8207
|
-
var _objectWithoutPropertiesLoose2 = _interopRequireDefault$
|
|
8206
|
+
var _extends2 = _interopRequireDefault$2(require_extends());
|
|
8207
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault$2(requireObjectWithoutPropertiesLoose());
|
|
8208
8208
|
var _styledEngine = _interopRequireWildcard(require$$3);
|
|
8209
8209
|
var _deepmerge = require$$4;
|
|
8210
|
-
var _capitalize = _interopRequireDefault$
|
|
8211
|
-
var _getDisplayName = _interopRequireDefault$
|
|
8212
|
-
var _createTheme = _interopRequireDefault$
|
|
8213
|
-
var _styleFunctionSx = _interopRequireDefault$
|
|
8210
|
+
var _capitalize = _interopRequireDefault$2(require$$5);
|
|
8211
|
+
var _getDisplayName = _interopRequireDefault$2(require$$6);
|
|
8212
|
+
var _createTheme = _interopRequireDefault$2(require$$7);
|
|
8213
|
+
var _styleFunctionSx = _interopRequireDefault$2(require$$8);
|
|
8214
8214
|
const _excluded$1 = ["ownerState"],
|
|
8215
8215
|
_excluded2 = ["variants"],
|
|
8216
8216
|
_excluded3 = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"];
|
|
@@ -8709,10 +8709,6 @@ var Instagram = createSvgIcon$1( /*#__PURE__*/jsxRuntimeExports.jsx("path", {
|
|
|
8709
8709
|
d: "M7.8 2h8.4C19.4 2 22 4.6 22 7.8v8.4a5.8 5.8 0 0 1-5.8 5.8H7.8C4.6 22 2 19.4 2 16.2V7.8A5.8 5.8 0 0 1 7.8 2m-.2 2A3.6 3.6 0 0 0 4 7.6v8.8C4 18.39 5.61 20 7.6 20h8.8a3.6 3.6 0 0 0 3.6-3.6V7.6C20 5.61 18.39 4 16.4 4H7.6m9.65 1.5a1.25 1.25 0 0 1 1.25 1.25A1.25 1.25 0 0 1 17.25 8 1.25 1.25 0 0 1 16 6.75a1.25 1.25 0 0 1 1.25-1.25M12 7a5 5 0 0 1 5 5 5 5 0 0 1-5 5 5 5 0 0 1-5-5 5 5 0 0 1 5-5m0 2a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3z"
|
|
8710
8710
|
}), 'Instagram');
|
|
8711
8711
|
|
|
8712
|
-
var OpenInNew = createSvgIcon$1( /*#__PURE__*/jsxRuntimeExports.jsx("path", {
|
|
8713
|
-
d: "M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3z"
|
|
8714
|
-
}), 'OpenInNew');
|
|
8715
|
-
|
|
8716
8712
|
var PhoneEnabled = createSvgIcon$1( /*#__PURE__*/jsxRuntimeExports.jsx("path", {
|
|
8717
8713
|
d: "m17.38 10.79-2.2-2.2c-.28-.28-.36-.67-.25-1.02.37-1.12.57-2.32.57-3.57 0-.55.45-1 1-1H20c.55 0 1 .45 1 1 0 9.39-7.61 17-17 17-.55 0-1-.45-1-1v-3.49c0-.55.45-1 1-1 1.24 0 2.45-.2 3.57-.57.35-.12.75-.03 1.02.24l2.2 2.2c2.83-1.45 5.15-3.76 6.59-6.59"
|
|
8718
8714
|
}), 'PhoneEnabled');
|
|
@@ -8725,7 +8721,7 @@ var WhatsApp = createSvgIcon$1( /*#__PURE__*/jsxRuntimeExports.jsx("path", {
|
|
|
8725
8721
|
d: "M16.75 13.96c.25.13.41.2.46.3.06.11.04.61-.21 1.18-.2.56-1.24 1.1-1.7 1.12-.46.02-.47.36-2.96-.73-2.49-1.09-3.99-3.75-4.11-3.92-.12-.17-.96-1.38-.92-2.61.05-1.22.69-1.8.95-2.04.24-.26.51-.29.68-.26h.47c.15 0 .36-.06.55.45l.69 1.87c.06.13.1.28.01.44l-.27.41-.39.42c-.12.12-.26.25-.12.5.12.26.62 1.09 1.32 1.78.91.88 1.71 1.17 1.95 1.3.24.14.39.12.54-.04l.81-.94c.19-.25.35-.19.58-.11l1.67.88M12 2a10 10 0 0 1 10 10 10 10 0 0 1-10 10c-1.97 0-3.8-.57-5.35-1.55L2 22l1.55-4.65A9.969 9.969 0 0 1 2 12 10 10 0 0 1 12 2m0 2a8 8 0 0 0-8 8c0 1.72.54 3.31 1.46 4.61L4.5 19.5l2.89-.96A7.95 7.95 0 0 0 12 20a8 8 0 0 0 8-8 8 8 0 0 0-8-8z"
|
|
8726
8722
|
}), 'WhatsApp');
|
|
8727
8723
|
|
|
8728
|
-
var
|
|
8724
|
+
var ArrowForward = {};
|
|
8729
8725
|
|
|
8730
8726
|
var createSvgIcon = {};
|
|
8731
8727
|
|
|
@@ -8753,6 +8749,19 @@ function requireCreateSvgIcon () {
|
|
|
8753
8749
|
return createSvgIcon;
|
|
8754
8750
|
}
|
|
8755
8751
|
|
|
8752
|
+
var _interopRequireDefault$1 = interopRequireDefaultExports;
|
|
8753
|
+
Object.defineProperty(ArrowForward, "__esModule", {
|
|
8754
|
+
value: true
|
|
8755
|
+
});
|
|
8756
|
+
var default_1$1 = ArrowForward.default = void 0;
|
|
8757
|
+
var _createSvgIcon$1 = _interopRequireDefault$1(requireCreateSvgIcon());
|
|
8758
|
+
var _jsxRuntime$1 = jsxRuntimeExports;
|
|
8759
|
+
default_1$1 = ArrowForward.default = (0, _createSvgIcon$1.default)( /*#__PURE__*/(0, _jsxRuntime$1.jsx)("path", {
|
|
8760
|
+
d: "m12 4-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"
|
|
8761
|
+
}), 'ArrowForward');
|
|
8762
|
+
|
|
8763
|
+
var Message = {};
|
|
8764
|
+
|
|
8756
8765
|
var _interopRequireDefault = interopRequireDefaultExports;
|
|
8757
8766
|
Object.defineProperty(Message, "__esModule", {
|
|
8758
8767
|
value: true
|
|
@@ -8783,6 +8792,7 @@ const HeaderContainer = styled$3(Box)({
|
|
|
8783
8792
|
flexDirection: 'column',
|
|
8784
8793
|
alignItems: 'center',
|
|
8785
8794
|
marginBottom: '16px',
|
|
8795
|
+
position: 'relative',
|
|
8786
8796
|
});
|
|
8787
8797
|
const ContactAvatar = styled$3(Avatar)({
|
|
8788
8798
|
width: 60,
|
|
@@ -8796,21 +8806,39 @@ const ContactName = styled$3(Typography)({
|
|
|
8796
8806
|
maxWidth: 200,
|
|
8797
8807
|
textAlign: 'center',
|
|
8798
8808
|
});
|
|
8799
|
-
const
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
|
|
8809
|
+
const LoadingContainer = styled$3(Box)({
|
|
8810
|
+
display: 'flex',
|
|
8811
|
+
justifyContent: 'center',
|
|
8812
|
+
alignItems: 'center',
|
|
8813
|
+
width: 60,
|
|
8814
|
+
height: 60,
|
|
8815
|
+
marginBottom: 8,
|
|
8816
|
+
});
|
|
8817
|
+
const Header = ({ imgUrl, name, contactId, navigate, isLoading = false, onError, }) => {
|
|
8818
|
+
const handleNavigation = useCallback((url) => (event) => {
|
|
8819
|
+
try {
|
|
8820
|
+
event.preventDefault();
|
|
8821
|
+
event.stopPropagation();
|
|
8822
|
+
if (!url) {
|
|
8823
|
+
throw new Error('Navigation URL is required');
|
|
8824
|
+
}
|
|
8825
|
+
const isNewTab = event.ctrlKey || event.metaKey || event.button === 1; // Ctrl+Click, Cmd+Click, Middle Mouse
|
|
8826
|
+
if (isNewTab) {
|
|
8827
|
+
window.open(url, '_blank', 'noopener,noreferrer');
|
|
8828
|
+
}
|
|
8829
|
+
else {
|
|
8830
|
+
navigate(url);
|
|
8831
|
+
}
|
|
8832
|
+
}
|
|
8833
|
+
catch (error) {
|
|
8834
|
+
onError?.(error instanceof Error ? error : new Error('Navigation failed'));
|
|
8835
|
+
}
|
|
8836
|
+
}, [navigate, onError]);
|
|
8837
|
+
const handleNavigateToContacts = handleNavigation(`/a/contacts/contacts/${contactId}`);
|
|
8838
|
+
const handleNavigateToConversations = handleNavigation('/a/conversations/conversations');
|
|
8839
|
+
const displayName = name || 'Unknown Contact';
|
|
8840
|
+
const avatarAlt = `Avatar for ${displayName}`;
|
|
8841
|
+
return (jsxRuntimeExports.jsxs(HeaderContainer, { children: [jsxRuntimeExports.jsxs(ButtonsContainer, { children: [jsxRuntimeExports.jsx(SmallIconButton, { color: "info", size: "small", onClick: handleNavigateToContacts, disabled: !contactId, "aria-label": "View contact details", children: jsxRuntimeExports.jsx(default_1$1, { fontSize: "small" }) }), jsxRuntimeExports.jsx(SmallIconButton, { color: "info", size: "small", onClick: handleNavigateToConversations, "aria-label": "Go to conversations", children: jsxRuntimeExports.jsx(default_1, { fontSize: "small" }) })] }), isLoading ? (jsxRuntimeExports.jsx(LoadingContainer, { children: jsxRuntimeExports.jsx(CircularProgress, { size: 24 }) })) : (jsxRuntimeExports.jsx(ContactAvatar, { src: imgUrl, alt: avatarAlt, onError: () => onError?.(new Error('Failed to load avatar')) })), jsxRuntimeExports.jsx(ContactName, { variant: "h6", title: displayName, children: displayName })] }));
|
|
8814
8842
|
};
|
|
8815
8843
|
|
|
8816
8844
|
const Container$1 = styled$3(Box)({
|
|
@@ -14739,7 +14767,9 @@ const LabelsSection = ({ contactData, title }) => {
|
|
|
14739
14767
|
return null;
|
|
14740
14768
|
if (!contactData.tags?.length)
|
|
14741
14769
|
return null;
|
|
14742
|
-
return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(SectionTitle$2, { gutterBottom: true, mt: 2, variant: "subtitle1", children: title }), jsxRuntimeExports.jsx(TagContainer, { children: contactData?.tags
|
|
14770
|
+
return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(SectionTitle$2, { gutterBottom: true, mt: 2, variant: "subtitle1", children: title }), jsxRuntimeExports.jsx(TagContainer, { children: contactData?.tags
|
|
14771
|
+
?.filter((tag) => tag.name?.trim())
|
|
14772
|
+
.map((tag) => (jsxRuntimeExports.jsx(StyledChip, { label: tag.name, color: "primary", size: "small" }, tag.id))) })] }));
|
|
14743
14773
|
};
|
|
14744
14774
|
|
|
14745
14775
|
/**
|
|
@@ -14897,7 +14927,7 @@ const ContactInfoPopup = ({ open, anchorEl, onClose, contactData, avatarImgUrl,
|
|
|
14897
14927
|
window.removeEventListener('keydown', handleKeyDown);
|
|
14898
14928
|
};
|
|
14899
14929
|
}, [open, onClose]);
|
|
14900
|
-
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 }), 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('
|
|
14930
|
+
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 }), 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') })] }) }) }) }));
|
|
14901
14931
|
};
|
|
14902
14932
|
|
|
14903
14933
|
export { ContactInfoPopup, TestBox };
|