@trii/components 2.0.14 → 2.0.16

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.
@@ -1,8 +1,11 @@
1
1
  type HeaderProps = {
2
- imgUrl: string | undefined;
3
- name: string | undefined;
4
- contactId: string | undefined;
2
+ imgUrl?: string;
3
+ name?: string;
4
+ contactId?: string;
5
5
  navigate: (path: string) => void;
6
+ isLoading?: boolean;
7
+ onError?: (error: Error) => void;
8
+ onClose: () => void;
6
9
  };
7
- declare const Header: ({ imgUrl, name, contactId, navigate }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
10
+ declare const Header: ({ imgUrl, name, contactId, navigate, isLoading, onError, onClose, }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
8
11
  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$2 = interopRequireDefaultExports;
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$2(require$$1);
7077
- var _clamp = _interopRequireDefault$2(require$$2);
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$1 = interopRequireDefaultExports;
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$1(require_extends());
8207
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault$1(requireObjectWithoutPropertiesLoose());
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$1(require$$5);
8211
- var _getDisplayName = _interopRequireDefault$1(require$$6);
8212
- var _createTheme = _interopRequireDefault$1(require$$7);
8213
- var _styleFunctionSx = _interopRequireDefault$1(require$$8);
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 Message = {};
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,57 @@ const ContactName = styled$3(Typography)({
8796
8806
  maxWidth: 200,
8797
8807
  textAlign: 'center',
8798
8808
  });
8799
- const Header = ({ imgUrl, name, contactId, navigate }) => {
8800
- const handleOpenInNewTab = (event) => {
8801
- event.preventDefault();
8802
- event.stopPropagation();
8803
- const url = `/a/contacts/contacts/${contactId}`;
8804
- window.open(url, '_blank');
8805
- };
8806
- const handleNavigateToConversations = (event) => {
8807
- event.preventDefault();
8808
- event.stopPropagation();
8809
- const url = `/a/conversations/conversations`;
8810
- // Navigate in the same tab
8811
- navigate(url);
8812
- };
8813
- return (jsxRuntimeExports.jsxs(HeaderContainer, { children: [jsxRuntimeExports.jsxs(ButtonsContainer, { children: [jsxRuntimeExports.jsx(SmallIconButton, { color: "info", size: "small", onClick: handleOpenInNewTab, children: jsxRuntimeExports.jsx(OpenInNew, { fontSize: "small" }) }), jsxRuntimeExports.jsx(SmallIconButton, { color: "info", size: "small", onClick: handleNavigateToConversations, children: jsxRuntimeExports.jsx(default_1, { fontSize: "small" }) })] }), jsxRuntimeExports.jsx(ContactAvatar, { src: imgUrl, alt: "Contact Avatar" }), jsxRuntimeExports.jsx(ContactName, { variant: "h6", children: name })] }));
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, onClose, }) => {
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: (e) => {
8842
+ handleNavigateToContacts(e);
8843
+ onClose();
8844
+ }, onMouseDown: (e) => {
8845
+ if (e.button === 1) {
8846
+ // Middle mouse button
8847
+ handleNavigateToContacts(e);
8848
+ onClose();
8849
+ }
8850
+ }, disabled: !contactId, "aria-label": "View contact details", children: jsxRuntimeExports.jsx(default_1$1, { fontSize: "small" }) }), jsxRuntimeExports.jsx(SmallIconButton, { color: "info", size: "small", onClick: (e) => {
8851
+ handleNavigateToConversations(e);
8852
+ onClose();
8853
+ }, onMouseDown: (e) => {
8854
+ if (e.button === 1) {
8855
+ // Middle mouse button
8856
+ handleNavigateToConversations(e);
8857
+ onClose();
8858
+ }
8859
+ }, "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
8860
  };
8815
8861
 
8816
8862
  const Container$1 = styled$3(Box)({
@@ -14739,7 +14785,9 @@ const LabelsSection = ({ contactData, title }) => {
14739
14785
  return null;
14740
14786
  if (!contactData.tags?.length)
14741
14787
  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?.map((tag) => (jsxRuntimeExports.jsx(StyledChip, { label: tag.name, color: "primary", size: "small" }, tag.id))) })] }));
14788
+ return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(SectionTitle$2, { gutterBottom: true, mt: 2, variant: "subtitle1", children: title }), jsxRuntimeExports.jsx(TagContainer, { children: contactData?.tags
14789
+ ?.filter((tag) => tag.name?.trim())
14790
+ .map((tag) => (jsxRuntimeExports.jsx(StyledChip, { label: tag.name, color: "primary", size: "small" }, tag.id))) })] }));
14743
14791
  };
14744
14792
 
14745
14793
  /**
@@ -14897,7 +14945,7 @@ const ContactInfoPopup = ({ open, anchorEl, onClose, contactData, avatarImgUrl,
14897
14945
  window.removeEventListener('keydown', handleKeyDown);
14898
14946
  };
14899
14947
  }, [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('properties') })] }) }) }) }));
14948
+ 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 }), 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
14949
  };
14902
14950
 
14903
14951
  export { ContactInfoPopup, TestBox };