@trii/components 2.0.7 → 2.0.9

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,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { IContact } from '@trii/types/dist/Contacts';
3
2
  import { SxProps, Theme } from '@mui/material';
4
3
  export interface ContactInfoPopupProps {
@@ -8,8 +7,7 @@ export interface ContactInfoPopupProps {
8
7
  t?: (key: string) => string;
9
8
  contactData?: IContact;
10
9
  avatarImgUrl?: string;
11
- handleNavigateToContacts?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
12
10
  sx?: SxProps<Theme>;
13
11
  }
14
- declare const ContactInfoPopup: ({ open, anchorEl, onClose, contactData, avatarImgUrl, handleNavigateToContacts, t, }: ContactInfoPopupProps) => import("react/jsx-runtime").JSX.Element;
12
+ declare const ContactInfoPopup: ({ open, anchorEl, onClose, contactData, avatarImgUrl, t, }: ContactInfoPopupProps) => import("react/jsx-runtime").JSX.Element;
15
13
  export default ContactInfoPopup;
@@ -1,10 +1,7 @@
1
- /// <reference types="react" />
2
1
  type HeaderProps = {
3
2
  imgUrl: string | undefined;
4
3
  name: string | undefined;
5
4
  contactId: string | undefined;
6
- t: (key: string) => string;
7
- handleNavigateToContacts: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void | undefined;
8
5
  };
9
- declare const Header: ({ handleNavigateToContacts, imgUrl, name, contactId, t, }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
6
+ declare const Header: ({ imgUrl, name, contactId, }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
10
7
  export default Header;
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import React__default from 'react';
2
+ import React__default, { useEffect } from 'react';
3
3
  import { Button, styled as styled$3, Box, IconButton, Avatar, Typography, Tooltip, Chip, Popper, ClickAwayListener, CardContent } from '@mui/material';
4
4
  import { withEmotionCache, ThemeContext, CacheProvider, Global, css, keyframes } from '@emotion/react';
5
5
 
@@ -8242,6 +8242,10 @@ function createSvgIcon(path, displayName) {
8242
8242
  return /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(Component));
8243
8243
  }
8244
8244
 
8245
+ var Email = createSvgIcon( /*#__PURE__*/jsxRuntimeExports.jsx("path", {
8246
+ d: "M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2m0 4-8 5-8-5V6l8 5 8-5z"
8247
+ }), 'Email');
8248
+
8245
8249
  var Facebook = createSvgIcon( /*#__PURE__*/jsxRuntimeExports.jsx("path", {
8246
8250
  d: "M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2m13 2h-2.5A3.5 3.5 0 0 0 12 8.5V11h-2v3h2v7h3v-7h3v-3h-3V9a1 1 0 0 1 1-1h2V5z"
8247
8251
  }), 'Facebook');
@@ -8268,10 +8272,6 @@ var ThreeP = createSvgIcon( /*#__PURE__*/jsxRuntimeExports.jsx("path", {
8268
8272
  d: "M20 2H4.01c-1.1 0-2 .9-2 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2m-8 4c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2m4 8H8v-.57c0-.81.48-1.53 1.22-1.85.85-.37 1.79-.58 2.78-.58.99 0 1.93.21 2.78.58.74.32 1.22 1.04 1.22 1.85z"
8269
8273
  }), 'ThreeP');
8270
8274
 
8271
- var Visibility = createSvgIcon( /*#__PURE__*/jsxRuntimeExports.jsx("path", {
8272
- d: "M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5M12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5m0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3"
8273
- }), 'Visibility');
8274
-
8275
8275
  var WhatsApp = createSvgIcon( /*#__PURE__*/jsxRuntimeExports.jsx("path", {
8276
8276
  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"
8277
8277
  }), 'WhatsApp');
@@ -8307,14 +8307,14 @@ const ContactName = styled$3(Typography)({
8307
8307
  maxWidth: 200,
8308
8308
  textAlign: 'center',
8309
8309
  });
8310
- const Header = ({ handleNavigateToContacts, imgUrl, name, contactId, t = (key) => key, }) => {
8310
+ const Header = ({ imgUrl, name, contactId, }) => {
8311
8311
  const handleOpenInNewTab = (event) => {
8312
8312
  event.preventDefault();
8313
8313
  event.stopPropagation();
8314
8314
  const url = `/a/contacts/contacts/${contactId}`;
8315
8315
  window.open(url, '_blank');
8316
8316
  };
8317
- return (jsxRuntimeExports.jsxs(HeaderContainer, { children: [jsxRuntimeExports.jsxs(ButtonsContainer, { children: [jsxRuntimeExports.jsx(Button, { variant: "outlined", size: "small", startIcon: jsxRuntimeExports.jsx(Visibility, {}), onClick: handleNavigateToContacts, color: "info", children: t('view') }), jsxRuntimeExports.jsx(SmallIconButton, { color: "info", size: "small", onClick: handleOpenInNewTab, children: jsxRuntimeExports.jsx(OpenInNew, { fontSize: "small" }) })] }), jsxRuntimeExports.jsx(ContactAvatar, { src: imgUrl, alt: "Contact Avatar" }), jsxRuntimeExports.jsx(ContactName, { variant: "h6", children: name })] }));
8317
+ return (jsxRuntimeExports.jsxs(HeaderContainer, { children: [jsxRuntimeExports.jsx(ButtonsContainer, { children: jsxRuntimeExports.jsx(SmallIconButton, { color: "info", size: "small", onClick: handleOpenInNewTab, children: jsxRuntimeExports.jsx(OpenInNew, { fontSize: "small" }) }) }), jsxRuntimeExports.jsx(ContactAvatar, { src: imgUrl, alt: "Contact Avatar" }), jsxRuntimeExports.jsx(ContactName, { variant: "h6", children: name })] }));
8318
8318
  };
8319
8319
 
8320
8320
  const Container$1 = styled$3(Box)({
@@ -14265,12 +14265,13 @@ const StyledChip = styled$3(Chip)(({ theme }) => ({
14265
14265
  marginBottom: 8,
14266
14266
  backgroundColor: `${theme.palette.primary.main}b3`
14267
14267
  }));
14268
- const ContactInfoPopup = ({ open, anchorEl, onClose, contactData, avatarImgUrl, handleNavigateToContacts = () => { }, t = (key) => ({
14268
+ const ContactInfoPopup = ({ open, anchorEl, onClose, contactData, avatarImgUrl, t = (key) => ({
14269
14269
  labels: 'Etiquetas',
14270
14270
  phone: 'Teléfono',
14271
14271
  business: 'Empresa',
14272
14272
  properties: 'Propiedades',
14273
14273
  view: 'Ver',
14274
+ 'E-mail Address': 'Correo Electrónico'
14274
14275
  }[key] || key), }) => {
14275
14276
  const contactMethods = [
14276
14277
  {
@@ -14279,6 +14280,12 @@ const ContactInfoPopup = ({ open, anchorEl, onClose, contactData, avatarImgUrl,
14279
14280
  contactList: contactData?.phones || [],
14280
14281
  showTitle: true,
14281
14282
  },
14283
+ {
14284
+ icon: jsxRuntimeExports.jsx(Email, { fontSize: "small" }),
14285
+ title: t('E-mail Address'),
14286
+ contactList: contactData?.emails || [],
14287
+ showTitle: true,
14288
+ },
14282
14289
  {
14283
14290
  icon: jsxRuntimeExports.jsx(WhatsApp, { fontSize: "small" }),
14284
14291
  title: 'IM',
@@ -14301,7 +14308,20 @@ const ContactInfoPopup = ({ open, anchorEl, onClose, contactData, avatarImgUrl,
14301
14308
  showTitle: false,
14302
14309
  },
14303
14310
  ];
14304
- 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, { contactId: contactData?.id, imgUrl: avatarImgUrl, name: contactData?.name, t: t, handleNavigateToContacts: handleNavigateToContacts }), jsxRuntimeExports.jsx(SectionTitle, { gutterBottom: true, mt: 2, variant: "subtitle1", children: t('labels') }), jsxRuntimeExports.jsx(TagContainer, { children: contactData?.tags?.map((tag) => (jsxRuntimeExports.jsx(StyledChip, { label: tag.name, color: "primary", size: "small" }, tag.id))) }), jsxRuntimeExports.jsx(SectionTitle, { gutterBottom: true, mt: 2, variant: "subtitle1", children: t('business') }), jsxRuntimeExports.jsx(Typography, { variant: "body2", color: "text.secondary", children: contactData?.businessName }), 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') })] }) }) }) }));
14311
+ useEffect(() => {
14312
+ const handleKeyDown = (event) => {
14313
+ if (event.key === 'Escape') {
14314
+ onClose();
14315
+ }
14316
+ };
14317
+ if (open) {
14318
+ window.addEventListener('keydown', handleKeyDown);
14319
+ }
14320
+ return () => {
14321
+ window.removeEventListener('keydown', handleKeyDown);
14322
+ };
14323
+ }, [open, onClose]);
14324
+ 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, { contactId: contactData?.id, imgUrl: avatarImgUrl, name: contactData?.name }), jsxRuntimeExports.jsx(SectionTitle, { gutterBottom: true, mt: 2, variant: "subtitle1", children: t('labels') }), jsxRuntimeExports.jsx(TagContainer, { children: contactData?.tags?.map((tag) => (jsxRuntimeExports.jsx(StyledChip, { label: tag.name, color: "primary", size: "small" }, tag.id))) }), jsxRuntimeExports.jsx(SectionTitle, { gutterBottom: true, mt: 2, variant: "subtitle1", children: t('business') }), jsxRuntimeExports.jsx(Typography, { variant: "body2", color: "text.secondary", children: contactData?.businessName }), 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') })] }) }) }) }));
14305
14325
  };
14306
14326
 
14307
14327
  export { ContactInfoPopup, TestBox };