@trii/components 2.0.47 → 2.0.50

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.
Files changed (21) hide show
  1. package/dist/cjs/index.js +365 -118
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/components/EditContactModal/components/TagsEditor/TagsEditor.d.ts +4 -1
  4. package/dist/cjs/types/components/EditContactModal/context/EditContactApiContext.d.ts +10 -0
  5. package/dist/cjs/types/components/EditContactModal/hooks/useEditBusiness/useEditBusiness.d.ts +1 -1
  6. package/dist/cjs/types/components/EditContactModal/hooks/useEditContact/useEditContact.d.ts +1 -1
  7. package/dist/cjs/types/components/EditContactModal/hooks/useModalCloseHandler.d.ts +1 -1
  8. package/dist/cjs/types/components/EditContactModal/hooks/useTagsEditorController.d.ts +3 -0
  9. package/dist/cjs/types/components/EditContactModal/layout/Section.d.ts +1 -1
  10. package/dist/cjs/types/components/EditContactModal/services/api.d.ts +14 -6
  11. package/dist/esm/index.js +365 -118
  12. package/dist/esm/index.js.map +1 -1
  13. package/dist/esm/types/components/EditContactModal/components/TagsEditor/TagsEditor.d.ts +4 -1
  14. package/dist/esm/types/components/EditContactModal/context/EditContactApiContext.d.ts +10 -0
  15. package/dist/esm/types/components/EditContactModal/hooks/useEditBusiness/useEditBusiness.d.ts +1 -1
  16. package/dist/esm/types/components/EditContactModal/hooks/useEditContact/useEditContact.d.ts +1 -1
  17. package/dist/esm/types/components/EditContactModal/hooks/useModalCloseHandler.d.ts +1 -1
  18. package/dist/esm/types/components/EditContactModal/hooks/useTagsEditorController.d.ts +3 -0
  19. package/dist/esm/types/components/EditContactModal/layout/Section.d.ts +1 -1
  20. package/dist/esm/types/components/EditContactModal/services/api.d.ts +14 -6
  21. package/package.json +1 -1
package/dist/cjs/index.js CHANGED
@@ -7421,21 +7421,21 @@ var styleFunctionSx = /*#__PURE__*/Object.freeze({
7421
7421
 
7422
7422
  var require$$8 = /*@__PURE__*/getAugmentedNamespace(styleFunctionSx);
7423
7423
 
7424
- var _interopRequireDefault$i = interopRequireDefaultExports;
7424
+ var _interopRequireDefault$j = interopRequireDefaultExports;
7425
7425
  Object.defineProperty(createStyled$3, "__esModule", {
7426
7426
  value: true
7427
7427
  });
7428
7428
  var _default = createStyled$3.default = createStyled$1;
7429
7429
  var shouldForwardProp_1 = createStyled$3.shouldForwardProp = shouldForwardProp$1;
7430
7430
  createStyled$3.systemDefaultTheme = void 0;
7431
- var _extends2 = _interopRequireDefault$i(require_extends());
7432
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault$i(requireObjectWithoutPropertiesLoose());
7431
+ var _extends2 = _interopRequireDefault$j(require_extends());
7432
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault$j(requireObjectWithoutPropertiesLoose());
7433
7433
  var _styledEngine$1 = _interopRequireWildcard$2(require$$1$1);
7434
7434
  var _deepmerge = require$$4;
7435
- var _capitalize = _interopRequireDefault$i(require$$5);
7436
- var _getDisplayName = _interopRequireDefault$i(require$$6);
7437
- var _createTheme = _interopRequireDefault$i(require$$7);
7438
- var _styleFunctionSx = _interopRequireDefault$i(require$$8);
7435
+ var _capitalize = _interopRequireDefault$j(require$$5);
7436
+ var _getDisplayName = _interopRequireDefault$j(require$$6);
7437
+ var _createTheme = _interopRequireDefault$j(require$$7);
7438
+ var _styleFunctionSx = _interopRequireDefault$j(require$$8);
7439
7439
  const _excluded$1v = ["ownerState"],
7440
7440
  _excluded2$d = ["variants"],
7441
7441
  _excluded3$4 = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"];
@@ -7705,7 +7705,7 @@ var require$$1 = /*@__PURE__*/getAugmentedNamespace(formatMuiErrorMessage$1);
7705
7705
 
7706
7706
  var require$$2 = /*@__PURE__*/getAugmentedNamespace(clamp);
7707
7707
 
7708
- var _interopRequireDefault$h = interopRequireDefaultExports;
7708
+ var _interopRequireDefault$i = interopRequireDefaultExports;
7709
7709
  Object.defineProperty(colorManipulator, "__esModule", {
7710
7710
  value: true
7711
7711
  });
@@ -7727,8 +7727,8 @@ colorManipulator.private_safeEmphasize = private_safeEmphasize;
7727
7727
  colorManipulator.private_safeLighten = private_safeLighten;
7728
7728
  colorManipulator.recomposeColor = recomposeColor$1;
7729
7729
  colorManipulator.rgbToHex = rgbToHex;
7730
- var _formatMuiErrorMessage2 = _interopRequireDefault$h(require$$1);
7731
- var _clamp = _interopRequireDefault$h(require$$2);
7730
+ var _formatMuiErrorMessage2 = _interopRequireDefault$i(require$$1);
7731
+ var _clamp = _interopRequireDefault$i(require$$2);
7732
7732
  /* eslint-disable @typescript-eslint/naming-convention */
7733
7733
 
7734
7734
  /**
@@ -9094,27 +9094,27 @@ function requireCreateSvgIcon () {
9094
9094
  return createSvgIcon;
9095
9095
  }
9096
9096
 
9097
- var _interopRequireDefault$g = interopRequireDefaultExports;
9097
+ var _interopRequireDefault$h = interopRequireDefaultExports;
9098
9098
  Object.defineProperty(ArrowForward, "__esModule", {
9099
9099
  value: true
9100
9100
  });
9101
- var default_1$h = ArrowForward.default = void 0;
9102
- var _createSvgIcon$g = _interopRequireDefault$g(requireCreateSvgIcon());
9103
- var _jsxRuntime$g = jsxRuntimeExports;
9104
- default_1$h = ArrowForward.default = (0, _createSvgIcon$g.default)( /*#__PURE__*/(0, _jsxRuntime$g.jsx)("path", {
9101
+ var default_1$i = ArrowForward.default = void 0;
9102
+ var _createSvgIcon$h = _interopRequireDefault$h(requireCreateSvgIcon());
9103
+ var _jsxRuntime$h = jsxRuntimeExports;
9104
+ default_1$i = ArrowForward.default = (0, _createSvgIcon$h.default)( /*#__PURE__*/(0, _jsxRuntime$h.jsx)("path", {
9105
9105
  d: "m12 4-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"
9106
9106
  }), 'ArrowForward');
9107
9107
 
9108
9108
  var Message = {};
9109
9109
 
9110
- var _interopRequireDefault$f = interopRequireDefaultExports;
9110
+ var _interopRequireDefault$g = interopRequireDefaultExports;
9111
9111
  Object.defineProperty(Message, "__esModule", {
9112
9112
  value: true
9113
9113
  });
9114
- var default_1$g = Message.default = void 0;
9115
- var _createSvgIcon$f = _interopRequireDefault$f(requireCreateSvgIcon());
9116
- var _jsxRuntime$f = jsxRuntimeExports;
9117
- default_1$g = Message.default = (0, _createSvgIcon$f.default)( /*#__PURE__*/(0, _jsxRuntime$f.jsx)("path", {
9114
+ var default_1$h = Message.default = void 0;
9115
+ var _createSvgIcon$g = _interopRequireDefault$g(requireCreateSvgIcon());
9116
+ var _jsxRuntime$g = jsxRuntimeExports;
9117
+ default_1$h = Message.default = (0, _createSvgIcon$g.default)( /*#__PURE__*/(0, _jsxRuntime$g.jsx)("path", {
9118
9118
  d: "M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2m-2 12H6v-2h12zm0-3H6V9h12zm0-3H6V6h12z"
9119
9119
  }), 'Message');
9120
9120
 
@@ -9194,7 +9194,7 @@ const Header$1 = ({ imgUrl, name, contactId, navigate, isLoading = false, onErro
9194
9194
  handleNavigateToContacts(e);
9195
9195
  onClose();
9196
9196
  }
9197
- }, disabled: !contactId, "aria-label": "View contact details", children: jsxRuntimeExports.jsx(default_1$h, { fontSize: "small" }) }), jsxRuntimeExports.jsx(SmallIconButton, { color: "info", size: "small", onClick: (e) => {
9197
+ }, disabled: !contactId, "aria-label": "View contact details", children: jsxRuntimeExports.jsx(default_1$i, { fontSize: "small" }) }), jsxRuntimeExports.jsx(SmallIconButton, { color: "info", size: "small", onClick: (e) => {
9198
9198
  handleNavigateToConversations(e);
9199
9199
  onClose();
9200
9200
  }, onMouseDown: (e) => {
@@ -9203,7 +9203,7 @@ const Header$1 = ({ imgUrl, name, contactId, navigate, isLoading = false, onErro
9203
9203
  handleNavigateToConversations(e);
9204
9204
  onClose();
9205
9205
  }
9206
- }, "aria-label": "Go to conversations", children: jsxRuntimeExports.jsx(default_1$g, { fontSize: "small" }) })] }), isLoading ? (jsxRuntimeExports.jsx(LoadingContainer, { children: jsxRuntimeExports.jsx(material.CircularProgress, { size: 24 }) })) : (jsxRuntimeExports.jsx(ContactAvatar, { src: imgUrl, alt: avatarAlt, onError: () => onError?.(new Error('Failed to load avatar')) })), jsxRuntimeExports.jsx(ContactName$1, { variant: "h6", title: displayName, children: displayName })] }));
9206
+ }, "aria-label": "Go to conversations", children: jsxRuntimeExports.jsx(default_1$h, { fontSize: "small" }) })] }), isLoading ? (jsxRuntimeExports.jsx(LoadingContainer, { children: jsxRuntimeExports.jsx(material.CircularProgress, { size: 24 }) })) : (jsxRuntimeExports.jsx(ContactAvatar, { src: imgUrl, alt: avatarAlt, onError: () => onError?.(new Error('Failed to load avatar')) })), jsxRuntimeExports.jsx(ContactName$1, { variant: "h6", title: displayName, children: displayName })] }));
9207
9207
  };
9208
9208
 
9209
9209
  const Container$1 = material.styled(material.Box)({
@@ -15297,14 +15297,23 @@ var business$1 = "Business";
15297
15297
  var businessMembers$1 = "Business Members";
15298
15298
  var properties$1 = "Properties";
15299
15299
  var view$1 = "View";
15300
- var email$1 = "Email";
15301
15300
  var tags$1 = "Tags";
15302
15301
  var global$2 = {
15302
+ add: "Add",
15303
+ note: "Note",
15304
+ number: "Number",
15305
+ email: "Email",
15306
+ phones: "Phones",
15307
+ close: "Close",
15303
15308
  back: "Back",
15309
+ createNew: "Create new",
15310
+ "delete": "Delete",
15311
+ cancel: "Cancel",
15304
15312
  save: "Save",
15305
15313
  noOptions: "No options",
15306
15314
  noValue: "No value",
15307
- birthdate: "Birthdate"
15315
+ birthdate: "Birthdate",
15316
+ country: "Country"
15308
15317
  };
15309
15318
  var avatar$1 = {
15310
15319
  upload: "Upload photo",
@@ -15345,7 +15354,6 @@ var en = {
15345
15354
  businessMembers: businessMembers$1,
15346
15355
  properties: properties$1,
15347
15356
  view: view$1,
15348
- email: email$1,
15349
15357
  tags: tags$1,
15350
15358
  global: global$2,
15351
15359
  avatar: avatar$1,
@@ -15359,14 +15367,23 @@ var business = "Empresa";
15359
15367
  var businessMembers = "Miembros de la empresa";
15360
15368
  var properties = "Propiedades";
15361
15369
  var view = "Ver";
15362
- var email = "Correo Electrónico";
15363
15370
  var tags = "Etiquetas";
15364
15371
  var global$1 = {
15372
+ add: "Agregar",
15373
+ note: "Nota",
15374
+ number: "Número",
15375
+ email: "Correo Electrónico",
15376
+ close: "Cerrar",
15377
+ phones: "Teléfonos",
15378
+ "delete": "Eliminar",
15379
+ cancel: "Cancelar",
15380
+ createNew: "Crear nuevo",
15365
15381
  back: "Atrás",
15366
15382
  save: "Guardar",
15367
15383
  noOptions: "Sin opciones",
15368
15384
  noValue: "Sin valor",
15369
- birthdate: "Fecha de nacimiento"
15385
+ birthdate: "Fecha de nacimiento",
15386
+ country: "País"
15370
15387
  };
15371
15388
  var avatar = {
15372
15389
  upload: "Subir foto",
@@ -15407,7 +15424,6 @@ var es = {
15407
15424
  businessMembers: businessMembers,
15408
15425
  properties: properties,
15409
15426
  view: view,
15410
- email: email,
15411
15427
  tags: tags,
15412
15428
  global: global$1,
15413
15429
  avatar: avatar,
@@ -15519,6 +15535,19 @@ const ContactInfoPopup = ({ open, anchorEl, onClose, contactData, avatarImgUrl,
15519
15535
  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$1, { 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$1, { icon: method.icon, title: method.title, contactList: method.contactList, showTitle: method.showTitle }, index))), jsxRuntimeExports.jsx(Properties, { properties: contactData?.properties, title: t('properties') })] }) }) }) }));
15520
15536
  };
15521
15537
 
15538
+ var Close = {};
15539
+
15540
+ var _interopRequireDefault$f = interopRequireDefaultExports;
15541
+ Object.defineProperty(Close, "__esModule", {
15542
+ value: true
15543
+ });
15544
+ var default_1$g = Close.default = void 0;
15545
+ var _createSvgIcon$f = _interopRequireDefault$f(requireCreateSvgIcon());
15546
+ var _jsxRuntime$f = jsxRuntimeExports;
15547
+ default_1$g = Close.default = (0, _createSvgIcon$f.default)( /*#__PURE__*/(0, _jsxRuntime$f.jsx)("path", {
15548
+ d: "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
15549
+ }), 'Close');
15550
+
15522
15551
  var Edit = {};
15523
15552
 
15524
15553
  var _interopRequireDefault$e = interopRequireDefaultExports;
@@ -15583,7 +15612,6 @@ const Tags = ({ tags, onEditTags }) => {
15583
15612
  justifyContent: 'center',
15584
15613
  }, children: [jsxRuntimeExports.jsxs(material.Box, { sx: {
15585
15614
  maxWidth: 320,
15586
- pr: 4,
15587
15615
  position: 'relative',
15588
15616
  '&:hover .tags-action, &:focus-within .tags-action': {
15589
15617
  opacity: 1,
@@ -15597,7 +15625,8 @@ const Tags = ({ tags, onEditTags }) => {
15597
15625
  },
15598
15626
  } }, tag.id))), hiddenCount > 0 ? (jsxRuntimeExports.jsx(material.Chip, { label: `+${hiddenCount}`, size: "small", variant: "outlined", onClick: handleOpen, sx: { borderRadius: 999 } })) : null] }), jsxRuntimeExports.jsx(material.IconButton, { className: "tags-action", size: "small", "aria-label": safeTags.length ? t('tags.edit') : t('tags.add'), onClick: onEditTags, sx: {
15599
15627
  position: 'absolute',
15600
- right: 0,
15628
+ left: '100%',
15629
+ ml: 1,
15601
15630
  top: '50%',
15602
15631
  transform: 'translateY(-50%)',
15603
15632
  color: 'text.secondary',
@@ -15608,7 +15637,7 @@ const Tags = ({ tags, onEditTags }) => {
15608
15637
  bgcolor: 'action.hover',
15609
15638
  color: 'text.primary',
15610
15639
  },
15611
- }, children: safeTags.length ? (jsxRuntimeExports.jsx(default_1$f, { fontSize: "small" })) : (jsxRuntimeExports.jsx(default_1$e, { fontSize: "small" })) })] }), jsxRuntimeExports.jsx(material.Popover, { open: open, anchorEl: anchorEl, onClose: handleClose, anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' }, children: jsxRuntimeExports.jsxs(material.Box, { sx: { p: 1.5, maxWidth: 320, maxHeight: 240, overflowY: 'auto' }, children: [jsxRuntimeExports.jsx(material.Typography, { variant: "subtitle2", sx: { mb: 1 }, children: t('tags') }), jsxRuntimeExports.jsx(material.Stack, { direction: "row", spacing: 1, useFlexGap: true, flexWrap: "wrap", children: safeTags.map((tag) => (jsxRuntimeExports.jsx(material.Chip, { label: tag.name, size: "small", variant: "outlined", sx: {
15640
+ }, children: safeTags.length ? jsxRuntimeExports.jsx(default_1$f, { fontSize: "small" }) : jsxRuntimeExports.jsx(default_1$e, { fontSize: "small" }) })] }), jsxRuntimeExports.jsx(material.Popover, { open: open, anchorEl: anchorEl, onClose: handleClose, anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' }, children: jsxRuntimeExports.jsxs(material.Box, { sx: { p: 1.5, maxWidth: 320, maxHeight: 240, overflowY: 'auto' }, children: [jsxRuntimeExports.jsx(material.Typography, { variant: "subtitle2", sx: { mb: 1 }, children: t('tags') }), jsxRuntimeExports.jsx(material.Stack, { direction: "row", spacing: 1, useFlexGap: true, flexWrap: "wrap", children: safeTags.map((tag) => (jsxRuntimeExports.jsx(material.Chip, { label: tag.name, size: "small", variant: "outlined", sx: {
15612
15641
  borderRadius: 999,
15613
15642
  maxWidth: 160,
15614
15643
  '& .MuiChip-label': {
@@ -15635,8 +15664,13 @@ const NameWrapper = material.styled(material.Box)({
15635
15664
  display: 'flex',
15636
15665
  alignItems: 'center',
15637
15666
  justifyContent: 'center',
15638
- gap: '8px',
15639
15667
  width: '100%',
15668
+ });
15669
+ const NameContainer = material.styled(material.Box)({
15670
+ position: 'relative',
15671
+ display: 'flex',
15672
+ justifyContent: 'center',
15673
+ maxWidth: '100%',
15640
15674
  '&:hover .edit-icon': {
15641
15675
  opacity: 1,
15642
15676
  visibility: 'visible',
@@ -15646,6 +15680,10 @@ const EditButton = material.styled(material.IconButton)({
15646
15680
  opacity: 0,
15647
15681
  visibility: 'hidden',
15648
15682
  transition: 'all 0.2s',
15683
+ position: 'absolute',
15684
+ left: '100%',
15685
+ top: '50%',
15686
+ transform: 'translateY(-50%)',
15649
15687
  });
15650
15688
  const ContactName = ({ displayName, contactType, firstName, lastName, name, entityId, onEntityUpdated, }) => {
15651
15689
  const api = useEditContactApi();
@@ -15696,7 +15734,7 @@ const ContactName = ({ displayName, contactType, firstName, lastName, name, enti
15696
15734
  if (isEditing) {
15697
15735
  return (jsxRuntimeExports.jsxs(material.Box, { sx: { display: 'flex', alignItems: 'center', gap: 1, mt: 1 }, children: [contactType === 'contact' ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(material.TextField, { value: values.firstName, onChange: (e) => setValues({ ...values, firstName: e.target.value }), size: "small", placeholder: "First Name", sx: { width: 140 } }), jsxRuntimeExports.jsx(material.TextField, { value: values.lastName, onChange: (e) => setValues({ ...values, lastName: e.target.value }), size: "small", placeholder: "Last Name", sx: { width: 140 } })] })) : (jsxRuntimeExports.jsx(material.TextField, { value: values.name, onChange: (e) => setValues({ ...values, name: e.target.value }), size: "small", placeholder: "Name", sx: { width: 280 } })), jsxRuntimeExports.jsx(material.IconButton, { onClick: handleSave, disabled: loading, color: "primary", children: loading ? jsxRuntimeExports.jsx(material.CircularProgress, { size: 24 }) : jsxRuntimeExports.jsx(Save$1, {}) })] }));
15698
15736
  }
15699
- return (jsxRuntimeExports.jsxs(NameWrapper, { children: [jsxRuntimeExports.jsx(NameText, { variant: "h6", title: displayName, children: displayName }), showEdit && (jsxRuntimeExports.jsx(EditButton, { size: "small", onClick: () => setIsEditing(true), className: "edit-icon", children: jsxRuntimeExports.jsx(Edit$1, { fontSize: "small" }) }))] }));
15737
+ return (jsxRuntimeExports.jsx(NameWrapper, { children: jsxRuntimeExports.jsxs(NameContainer, { children: [jsxRuntimeExports.jsx(NameText, { variant: "h6", title: displayName, children: displayName }), showEdit && (jsxRuntimeExports.jsx(EditButton, { size: "small", onClick: () => setIsEditing(true), className: "edit-icon", sx: { ml: 1 }, children: jsxRuntimeExports.jsx(Edit$1, { fontSize: "small" }) }))] }) }));
15700
15738
  };
15701
15739
 
15702
15740
  var Delete = {};
@@ -24808,10 +24846,11 @@ Grow.muiSupportAuto = true;
24808
24846
  var Grow$1 = Grow;
24809
24847
 
24810
24848
  const PAGE_SIZE = 20;
24811
- const AutocompletePopper = styled$3(MuiPopper)(({ theme }) => ({
24812
- zIndex: theme.zIndex.modal + 1,
24813
- }));
24814
- const TagsEditor = ({ value, options, onChange, onBack, onSave, isSaving }) => {
24849
+ const AutocompletePopper = (props) => {
24850
+ const { popperContainer, ...rest } = props;
24851
+ return (jsxRuntimeExports.jsx(MuiPopper, { ...rest, container: popperContainer ?? rest.container, style: { ...(rest.style ?? {}), zIndex: 20000 } }));
24852
+ };
24853
+ const TagsEditor = ({ value, options, onChange, onBack, onSave, isSaving, onCreateNew, isCreatingNew, popperContainer, }) => {
24815
24854
  const t = useTranslationContext();
24816
24855
  const [searchValue, setSearchValue] = React$1.useState('');
24817
24856
  const [limit, setLimit] = React$1.useState(PAGE_SIZE);
@@ -24827,10 +24866,19 @@ const TagsEditor = ({ value, options, onChange, onBack, onSave, isSaving }) => {
24827
24866
  if (nearBottom)
24828
24867
  setLimit((l) => l + PAGE_SIZE);
24829
24868
  };
24830
- return (jsxRuntimeExports.jsxs(material.Box, { sx: { width: '100%' }, children: [jsxRuntimeExports.jsxs(material.Stack, { direction: "row", alignItems: "center", spacing: 1, sx: { mb: 2 }, children: [jsxRuntimeExports.jsx(material.IconButton, { size: "small", onClick: onBack, "aria-label": t('global.back'), disabled: isSaving, children: jsxRuntimeExports.jsx(default_1$b, { fontSize: "small" }) }), jsxRuntimeExports.jsx(material.Typography, { variant: "subtitle1", children: t('tags') }), jsxRuntimeExports.jsx(material.Box, { sx: { flex: 1 } }), jsxRuntimeExports.jsx(LoadingButton$1, { variant: "contained", size: "small", startIcon: jsxRuntimeExports.jsx(default_1$a, {}), onClick: onSave, loading: isSaving, disabled: isSaving, children: t('global.save') })] }), jsxRuntimeExports.jsx(material.Autocomplete, { multiple: true, value: value, onChange: (_, newValue) => onChange(newValue), options: visibleOptions, filterOptions: (x) => x, inputValue: searchValue, onInputChange: handleSearchChange, getOptionLabel: (option) => option?.name ?? '', isOptionEqualToValue: (o, v) => String(o?.id) === String(v?.id), PopperComponent: AutocompletePopper, renderOption: (props, option) => jsxRuntimeExports.jsx("li", { ...props, children: option.name ?? '' }), renderTags: (tagValue, getTagProps) => tagValue.map((option, index) => (jsxRuntimeExports.jsx(material.Chip, { label: option.name ?? '', ...getTagProps({ index }) }))), size: "small", renderInput: (params) => jsxRuntimeExports.jsx(material.TextField, { ...params, size: "small" }), ListboxProps: {
24869
+ const CustomNoOptionsMessage = () => {
24870
+ const trimmedSearchValue = String(searchValue ?? '').trim();
24871
+ const isDisabled = !trimmedSearchValue || isSaving || isCreatingNew;
24872
+ return (jsxRuntimeExports.jsxs(material.Box, { sx: {
24873
+ display: 'flex',
24874
+ justifyContent: 'space-between',
24875
+ alignItems: 'center',
24876
+ }, children: [t('global.noOptions'), jsxRuntimeExports.jsx(LoadingButton$1, { onClick: () => onCreateNew(trimmedSearchValue), loading: isCreatingNew, disabled: isDisabled, variant: "contained", size: "small", sx: { marginTop: 1.3 }, children: t('global.createNew') })] }));
24877
+ };
24878
+ return (jsxRuntimeExports.jsxs(material.Box, { sx: { width: '100%' }, children: [jsxRuntimeExports.jsxs(material.Stack, { direction: "row", alignItems: "center", spacing: 1, sx: { mb: 2 }, children: [jsxRuntimeExports.jsx(material.IconButton, { size: "small", onClick: onBack, "aria-label": t('global.back'), disabled: isSaving, children: jsxRuntimeExports.jsx(default_1$b, { fontSize: "small" }) }), jsxRuntimeExports.jsx(material.Typography, { variant: "subtitle1", children: t('tags') }), jsxRuntimeExports.jsx(material.Box, { sx: { flex: 1 } }), jsxRuntimeExports.jsx(LoadingButton$1, { variant: "contained", size: "small", startIcon: jsxRuntimeExports.jsx(default_1$a, {}), onClick: onSave, loading: isSaving, disabled: isSaving, children: t('global.save') })] }), jsxRuntimeExports.jsx(material.Autocomplete, { multiple: true, disablePortal: false, value: value, onChange: (_, newValue) => onChange(newValue), options: visibleOptions, filterOptions: (x) => x, inputValue: searchValue, onInputChange: handleSearchChange, getOptionLabel: (option) => option?.name ?? '', isOptionEqualToValue: (o, v) => String(o?.id) === String(v?.id), PopperComponent: (props) => (jsxRuntimeExports.jsx(AutocompletePopper, { ...props, popperContainer: popperContainer })), renderOption: (props, option) => jsxRuntimeExports.jsx("li", { ...props, children: option.name ?? '' }), renderTags: (tagValue, getTagProps) => tagValue.map((option, index) => (jsxRuntimeExports.jsx(material.Chip, { label: option.name ?? '', ...getTagProps({ index }) }))), size: "small", renderInput: (params) => jsxRuntimeExports.jsx(material.TextField, { ...params, size: "small" }), ListboxProps: {
24831
24879
  onScroll: onListboxScroll,
24832
24880
  sx: { maxHeight: 280, overflowY: 'auto' },
24833
- }, noOptionsText: t('global.noOptions'), sx: { width: '100%' } })] }));
24881
+ }, noOptionsText: jsxRuntimeExports.jsx(CustomNoOptionsMessage, {}), sx: { width: '100%' } })] }));
24834
24882
  };
24835
24883
 
24836
24884
  class ApiError extends Error {
@@ -24904,17 +24952,22 @@ async function fetchLabels({ baseUrl, spaceId, signal }) {
24904
24952
  const url = joinUrl(urls.CONTACTS, '/labels');
24905
24953
  return requestJson({ url, signal });
24906
24954
  }
24955
+ async function createLabel({ baseUrl, spaceId, name, signal }) {
24956
+ const urls = getApiUrls(baseUrl, spaceId);
24957
+ const url = joinUrl(urls.CONTACTS, '/labels');
24958
+ return requestJson({ url, method: 'POST', body: { name }, signal });
24959
+ }
24907
24960
  async function fetchContact({ baseUrl, spaceId, contactId, signal }) {
24908
24961
  const urls = getApiUrls(baseUrl, spaceId);
24909
24962
  const url = joinUrl(urls.CONTACTS, `/contacts/${encodeURIComponent(contactId)}`);
24910
24963
  return requestJson({ url, signal });
24911
24964
  }
24912
- async function fetchContactFields({ baseUrl, spaceId, forType, signal }) {
24965
+ async function fetchContactFields({ baseUrl, spaceId, forType, signal, }) {
24913
24966
  const urls = getApiUrls(baseUrl, spaceId);
24914
24967
  const url = `${joinUrl(urls.CONTACTS, '/ContactFields')}?filter=custom&for=${encodeURIComponent(forType)}`;
24915
24968
  return requestJson({ url, signal });
24916
24969
  }
24917
- async function updateEntity({ baseUrl, spaceId, entityType, entityId, body, signal }) {
24970
+ async function updateEntity({ baseUrl, spaceId, entityType, entityId, body, signal, }) {
24918
24971
  const path = entityType === 'business'
24919
24972
  ? `/business/${encodeURIComponent(entityId)}`
24920
24973
  : `/contacts/${encodeURIComponent(entityId)}`;
@@ -24927,7 +24980,7 @@ async function deleteAddress({ baseUrl, spaceId, data, signal }) {
24927
24980
  const url = joinUrl(urls.CONTACTS, '/contactAddresses');
24928
24981
  return requestJson({ url, method: 'DELETE', body: data, signal });
24929
24982
  }
24930
- async function checkContactAddress({ baseUrl, spaceId, data, signal }) {
24983
+ async function checkContactAddress({ baseUrl, spaceId, data, signal, }) {
24931
24984
  const urls = getApiUrls(baseUrl, spaceId);
24932
24985
  const url = joinUrl(urls.CONTACTS, '/contactAddresses/check');
24933
24986
  return requestJson({ url, method: 'POST', body: data, signal });
@@ -24937,7 +24990,7 @@ async function setContactAddress({ baseUrl, spaceId, data, signal }) {
24937
24990
  const url = joinUrl(urls.CONTACTS, '/contactAddresses/set');
24938
24991
  return requestJson({ url, method: 'POST', body: data, signal });
24939
24992
  }
24940
- async function updateContactAddress({ baseUrl, spaceId, data, signal }) {
24993
+ async function updateContactAddress({ baseUrl, spaceId, data, signal, }) {
24941
24994
  const urls = getApiUrls(baseUrl, spaceId);
24942
24995
  const url = joinUrl(urls.CONTACTS, `/contactAddresses/${encodeURIComponent(data.contactAddressId)}`);
24943
24996
  return requestJson({ url, method: 'PUT', body: data, signal });
@@ -24952,12 +25005,12 @@ async function fetchUsers({ baseUrl, spaceId, signal }) {
24952
25005
  const url = joinUrl(urls.SETTINGS, `/users`);
24953
25006
  return requestJson({ url, signal });
24954
25007
  }
24955
- async function fetchUserTriiById({ baseUrl, spaceId, signal, userId }) {
25008
+ async function fetchUserTriiById({ baseUrl, spaceId, signal, userId, }) {
24956
25009
  const urls = getApiUrls(baseUrl, spaceId);
24957
25010
  const url = joinUrl(urls.SETTINGS, `/usersInfor/${userId}`);
24958
25011
  return requestJson({ url, signal });
24959
25012
  }
24960
- async function uploadAvatar({ baseUrl, spaceId, contactId, file, signal }) {
25013
+ async function uploadAvatar({ baseUrl, spaceId, contactId, file, signal, }) {
24961
25014
  const urls = getApiUrls(baseUrl, spaceId);
24962
25015
  const fd = new FormData();
24963
25016
  fd.append('file', file, file.name);
@@ -24966,6 +25019,7 @@ async function uploadAvatar({ baseUrl, spaceId, contactId, file, signal }) {
24966
25019
  }
24967
25020
  const createEditContactApi = (baseUrl, spaceId) => ({
24968
25021
  fetchLabels: ({ signal } = {}) => fetchLabels({ baseUrl, spaceId, signal }),
25022
+ createLabel: ({ name, signal }) => createLabel({ baseUrl, spaceId, name, signal }),
24969
25023
  fetchContact: ({ contactId, signal }) => fetchContact({ baseUrl, spaceId, contactId, signal }),
24970
25024
  fetchContactFields: ({ forType, signal }) => fetchContactFields({ baseUrl, spaceId, forType, signal }),
24971
25025
  updateEntity: ({ entityType, entityId, body, signal }) => updateEntity({ baseUrl, spaceId, entityType, entityId, body, signal }),
@@ -25772,6 +25826,7 @@ var editContactHelper = { getEditedField, getAddressesWithUpdatedValues };
25772
25826
 
25773
25827
  const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, }) => {
25774
25828
  const [isDeletingAddress, setIsDeletingAddress] = React$1.useState(false);
25829
+ const [initialSnapshot, setInitialSnapshot] = React$1.useState(() => initial);
25775
25830
  const [imsFacebooks, setImsFacebooks] = React$1.useState(initial?.ims_facebook || []);
25776
25831
  const [imsMercadolibre, setImsMercadolibre] = React$1.useState(initial?.ims_mercadolibre || []);
25777
25832
  const [imsWebchats, setImsWebchats] = React$1.useState(initial?.ims_webchat || []);
@@ -25803,6 +25858,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
25803
25858
  const addWhatsappVerified = (newWhatsapp) => {
25804
25859
  const updatedWhatsapps = [...imsWhatsapp, newWhatsapp];
25805
25860
  setImsWhatsApp(updatedWhatsapps);
25861
+ setInitialSnapshot((prev) => ({
25862
+ ...(prev ?? {}),
25863
+ ims_whatsapp: updatedWhatsapps,
25864
+ }));
25806
25865
  };
25807
25866
  const replaceAddress = (addressId, newAddress) => {
25808
25867
  if (!newAddress) {
@@ -25816,6 +25875,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
25816
25875
  return email;
25817
25876
  });
25818
25877
  setEmails(newEmails);
25878
+ setInitialSnapshot((prev) => ({
25879
+ ...(prev ?? {}),
25880
+ emails: newEmails,
25881
+ }));
25819
25882
  }
25820
25883
  if (newAddress.channelType === 5) {
25821
25884
  const newPhoneNumbers = phoneNumbers.map((phoneNumber) => {
@@ -25825,6 +25888,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
25825
25888
  return phoneNumber;
25826
25889
  });
25827
25890
  setPhoneNumbers(newPhoneNumbers);
25891
+ setInitialSnapshot((prev) => ({
25892
+ ...(prev ?? {}),
25893
+ phones: newPhoneNumbers,
25894
+ }));
25828
25895
  }
25829
25896
  if (newAddress.channelType === 13) {
25830
25897
  const newImsWhatsapp = imsWhatsapp.map((item) => {
@@ -25834,6 +25901,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
25834
25901
  return item;
25835
25902
  });
25836
25903
  setImsWhatsApp(newImsWhatsapp);
25904
+ setInitialSnapshot((prev) => ({
25905
+ ...(prev ?? {}),
25906
+ ims_whatsapp: newImsWhatsapp,
25907
+ }));
25837
25908
  }
25838
25909
  if (newAddress.channelType === 21) {
25839
25910
  const newImsRCS = imsRCS.map((item) => {
@@ -25843,6 +25914,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
25843
25914
  return item;
25844
25915
  });
25845
25916
  setImsRCS(newImsRCS);
25917
+ setInitialSnapshot((prev) => ({
25918
+ ...(prev ?? {}),
25919
+ ims_rcs: newImsRCS,
25920
+ }));
25846
25921
  }
25847
25922
  if (newAddress.channelType === 41) {
25848
25923
  const newImsMercadolibre = imsMercadolibre.map((item) => {
@@ -25852,6 +25927,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
25852
25927
  return item;
25853
25928
  });
25854
25929
  setImsMercadolibre(newImsMercadolibre);
25930
+ setInitialSnapshot((prev) => ({
25931
+ ...(prev ?? {}),
25932
+ ims_mercadolibre: newImsMercadolibre,
25933
+ }));
25855
25934
  }
25856
25935
  };
25857
25936
  const handleAddressFieldChange = async (e, fieldId, type) => {
@@ -26004,49 +26083,82 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
26004
26083
  case 3:
26005
26084
  const newEmails = emails.filter((email) => email.id !== fieldId);
26006
26085
  setEmails(newEmails);
26086
+ setInitialSnapshot((prev) => ({
26087
+ ...(prev ?? {}),
26088
+ emails: newEmails,
26089
+ }));
26007
26090
  break;
26008
26091
  case 5:
26009
26092
  const newPhoneNumbers = phoneNumbers.filter((phoneNumber) => phoneNumber.id !== fieldId);
26010
26093
  setPhoneNumbers(newPhoneNumbers);
26094
+ setInitialSnapshot((prev) => ({
26095
+ ...(prev ?? {}),
26096
+ phones: newPhoneNumbers,
26097
+ }));
26011
26098
  break;
26012
26099
  case 13:
26013
26100
  const newImsWhatsapp = imsWhatsapp.filter((item) => item.id !== fieldId);
26014
26101
  setImsWhatsApp(newImsWhatsapp);
26102
+ setInitialSnapshot((prev) => ({
26103
+ ...(prev ?? {}),
26104
+ ims_whatsapp: newImsWhatsapp,
26105
+ }));
26015
26106
  break;
26016
26107
  case 21:
26017
26108
  const newImsRCS = imsRCS.filter((item) => item.id !== fieldId);
26018
26109
  setImsRCS(newImsRCS);
26110
+ setInitialSnapshot((prev) => ({
26111
+ ...(prev ?? {}),
26112
+ ims_rcs: newImsRCS,
26113
+ }));
26019
26114
  break;
26020
26115
  case 41:
26021
26116
  const newImsMercadolibre = imsMercadolibre.filter((item) => item.id !== fieldId);
26022
26117
  setImsMercadolibre(newImsMercadolibre);
26118
+ setInitialSnapshot((prev) => ({
26119
+ ...(prev ?? {}),
26120
+ ims_mercadolibre: newImsMercadolibre,
26121
+ }));
26023
26122
  break;
26024
26123
  case 14:
26025
26124
  const newImsFacebooks = imsFacebooks.filter((item) => item.id !== fieldId);
26026
26125
  setImsFacebooks(newImsFacebooks);
26126
+ setInitialSnapshot((prev) => ({
26127
+ ...(prev ?? {}),
26128
+ ims_facebook: newImsFacebooks,
26129
+ }));
26027
26130
  break;
26028
26131
  case 20:
26029
26132
  const newImsWebchats = imsWebchats.filter((item) => item.id !== fieldId);
26030
26133
  setImsWebchats(newImsWebchats);
26134
+ setInitialSnapshot((prev) => ({
26135
+ ...(prev ?? {}),
26136
+ ims_webchat: newImsWebchats,
26137
+ }));
26031
26138
  break;
26032
26139
  case 16:
26033
26140
  const newImsInstagrams = imsInstagrams.filter((item) => item.id !== fieldId);
26034
26141
  setImsInstagrams(newImsInstagrams);
26142
+ setInitialSnapshot((prev) => ({
26143
+ ...(prev ?? {}),
26144
+ ims_instagram: newImsInstagrams,
26145
+ }));
26035
26146
  break;
26036
26147
  }
26037
26148
  }
26038
26149
  };
26039
26150
  function resetToInitialContactInformation() {
26040
- setImsFacebooks(initial?.ims_facebook || []);
26041
- setImsMercadolibre(initial?.ims_mercadolibre || []);
26042
- setImsWebchats(initial?.ims_webchat || []);
26043
- setImsInstagrams(initial?.ims_instagram || []);
26044
- setImsWhatsApp(initial?.ims_whatsapp || []);
26045
- setImsRCS(initial?.ims_rcs || []);
26046
- setEmails(initial?.emails || []);
26047
- setPhoneNumbers(initial?.phones || []);
26151
+ setImsFacebooks(initialSnapshot?.ims_facebook || []);
26152
+ setImsMercadolibre(initialSnapshot?.ims_mercadolibre || []);
26153
+ setImsWebchats(initialSnapshot?.ims_webchat || []);
26154
+ setImsInstagrams(initialSnapshot?.ims_instagram || []);
26155
+ setImsWhatsApp(initialSnapshot?.ims_whatsapp || []);
26156
+ setImsRCS(initialSnapshot?.ims_rcs || []);
26157
+ setEmails(initialSnapshot?.emails || []);
26158
+ setPhoneNumbers(initialSnapshot?.phones || []);
26048
26159
  }
26049
26160
  React$1.useEffect(() => {
26161
+ setInitialSnapshot(initial);
26050
26162
  if (initial?.emails && initial?.phones) {
26051
26163
  setEmails(initial.emails);
26052
26164
  setPhoneNumbers(initial.phones);
@@ -26111,7 +26223,7 @@ const useMultipleSelect = ({ initialState = [], } = {}) => {
26111
26223
  };
26112
26224
  };
26113
26225
 
26114
- const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) => {
26226
+ const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId, }) => {
26115
26227
  const apiDeleteAddress = React$1.useMemo(() => async (payload) => {
26116
26228
  if (!baseUrl || !spaceId)
26117
26229
  return;
@@ -26151,8 +26263,7 @@ const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) =>
26151
26263
  const country = useField$1('text', business?.address1?.country || '');
26152
26264
  const secondaryCountry = useField$1('text', business?.address2?.country || '');
26153
26265
  const getEditedField = (key, originalValue, editedValue) => {
26154
- if (originalValue !== editedValue &&
26155
- !(originalValue === null && editedValue === '')) {
26266
+ if (originalValue !== editedValue && !(originalValue === null && editedValue === '')) {
26156
26267
  return { [key]: editedValue };
26157
26268
  }
26158
26269
  return {};
@@ -26179,9 +26290,7 @@ const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) =>
26179
26290
  id: business.id,
26180
26291
  ...getEditedField('owner', business.owner, contactPropietary.attributes.value),
26181
26292
  ...getEditedField('name', business.name, name.attributes.value),
26182
- imageUrl: contactImage.imageUrl
26183
- ? contactImage.removeParams(contactImage.imageUrl)
26184
- : null,
26293
+ imageUrl: contactImage.imageUrl ? contactImage.removeParams(contactImage.imageUrl) : null,
26185
26294
  tags: labelMultipleSelect.attributes.value,
26186
26295
  properties: customProperties,
26187
26296
  members: selectedContacts,
@@ -26196,26 +26305,23 @@ const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) =>
26196
26305
  function resetCustomProperty(nameKey) {
26197
26306
  if (!business)
26198
26307
  return;
26199
- const defaultProperty = business.properties.find((property) => property.nameKey === nameKey);
26308
+ const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
26309
+ const defaultProperty = business.properties.find((property) => property.nameKey === nameKey) ??
26310
+ business.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(nameKey));
26200
26311
  if (!defaultProperty) {
26201
26312
  console.error(`No se encontró una propiedad con nameKey: ${nameKey}`);
26202
26313
  return; // Salir de la función si no se encuentra la propiedad
26203
26314
  }
26204
- const updatedProperties = customProperties.map((property) => property.nameKey === nameKey
26205
- ? { ...property, value: defaultProperty.value }
26206
- : property);
26315
+ const updatedProperties = customProperties.map((property) => property.nameKey === nameKey ? { ...property, value: defaultProperty.value } : property);
26207
26316
  setCustomProperties(updatedProperties);
26208
26317
  }
26209
- function replaceSpacesWithHyphen(input) {
26210
- const result = input.replace(/ /g, '-');
26211
- return result;
26212
- }
26213
26318
  const getFilteredCustomProperties = () => {
26214
26319
  if (!business)
26215
26320
  return [];
26216
26321
  return customContactFields.map((customField) => {
26217
- const customFieldWithHyphen = replaceSpacesWithHyphen(customField.nameKey);
26218
- const existingBusinessProperty = business.properties.find((property) => property.nameKey === customFieldWithHyphen);
26322
+ const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
26323
+ const existingBusinessProperty = business.properties.find((property) => property.nameKey === customField.nameKey) ??
26324
+ business.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(customField.nameKey));
26219
26325
  if (existingBusinessProperty) {
26220
26326
  return {
26221
26327
  ...existingBusinessProperty,
@@ -26300,7 +26406,7 @@ var dayjs_min = {exports: {}};
26300
26406
  var dayjs_minExports = dayjs_min.exports;
26301
26407
  var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
26302
26408
 
26303
- const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
26409
+ const useEditContact = ({ contact, customContactFields, baseUrl, spaceId, }) => {
26304
26410
  const apiDeleteAddress = React$1.useMemo(() => async (payload) => {
26305
26411
  if (!baseUrl || !spaceId)
26306
26412
  return;
@@ -26384,9 +26490,7 @@ const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
26384
26490
  phones: modifiedPhones,
26385
26491
  // ims_whatsapp: modifiedImsWhatsapp,
26386
26492
  tags: modifiedTags,
26387
- imageUrl: contactImage.imageUrl
26388
- ? contactImage.removeParams(contactImage.imageUrl)
26389
- : null,
26493
+ imageUrl: contactImage.imageUrl ? contactImage.removeParams(contactImage.imageUrl) : null,
26390
26494
  properties: customProperties,
26391
26495
  // businessId: selectedBusiness[0]?.businessId || '',
26392
26496
  // businessName: selectedBusiness[0]?.businessName || '',
@@ -26412,27 +26516,23 @@ const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
26412
26516
  function resetCustomProperty(nameKey) {
26413
26517
  if (!contact)
26414
26518
  return;
26415
- const defaultProperty = contact.properties.find((property) => property.nameKey === nameKey);
26519
+ const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
26520
+ const defaultProperty = contact.properties.find((property) => property.nameKey === nameKey) ??
26521
+ contact.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(nameKey));
26416
26522
  if (!defaultProperty) {
26417
26523
  console.error(`No se encontró una propiedad con nameKey: ${nameKey}`);
26418
26524
  return; // Salir de la función si no se encuentra la propiedad
26419
26525
  }
26420
- const updatedProperties = customProperties.map((property) => property.nameKey === nameKey
26421
- ? { ...property, value: defaultProperty.value }
26422
- : property);
26526
+ const updatedProperties = customProperties.map((property) => property.nameKey === nameKey ? { ...property, value: defaultProperty.value } : property);
26423
26527
  setCustomProperties(updatedProperties);
26424
26528
  }
26425
- // Utils
26426
- function replaceSpacesWithHyphen(input) {
26427
- const result = input.replace(/ /g, '-');
26428
- return result;
26429
- }
26430
26529
  const getFilteredCustomProperties = () => {
26431
26530
  if (!contact)
26432
26531
  return [];
26433
26532
  return customContactFields.map((customField) => {
26434
- const customFieldWithHypen = replaceSpacesWithHyphen(customField.nameKey);
26435
- const existingProperty = contact.properties.find((property) => property.nameKey === customFieldWithHypen);
26533
+ const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
26534
+ const existingProperty = contact.properties.find((property) => property.nameKey === customField.nameKey) ??
26535
+ contact.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(customField.nameKey));
26436
26536
  if (existingProperty) {
26437
26537
  return {
26438
26538
  ...existingProperty,
@@ -26564,7 +26664,7 @@ const Section = ({ title, children }) => {
26564
26664
  borderRadius: 2,
26565
26665
  p: 2,
26566
26666
  mb: 2,
26567
- }, children: [jsxRuntimeExports.jsx(material.Typography, { variant: "subtitle1", sx: { fontWeight: 600 }, children: title }), jsxRuntimeExports.jsx(material.Divider, { sx: { my: 1.5 } }), children] }));
26667
+ }, children: [jsxRuntimeExports.jsx(material.Typography, { variant: "subtitle1", children: title }), jsxRuntimeExports.jsx(material.Divider, { sx: { my: 1.5 } }), children] }));
26568
26668
  };
26569
26669
 
26570
26670
  const SectionContent = ({ children, ...boxProps }) => {
@@ -52712,7 +52812,7 @@ function SelectBusinessLabel({ value, displayValue, businessId }) {
52712
52812
  }
52713
52813
  setAnchorEl(targetElement);
52714
52814
  };
52715
- return (jsxRuntimeExports.jsxs(material.Box, { display: "flex", alignItems: "center", children: [jsxRuntimeExports.jsx(material.Typography, { onClick: handleOpenInfoPopover, fontWeight: '600', sx: {
52815
+ return (jsxRuntimeExports.jsxs(material.Box, { display: "flex", alignItems: "center", children: [jsxRuntimeExports.jsx(material.Typography, { onClick: handleOpenInfoPopover, variant: "body2", fontWeight: '600', sx: {
52716
52816
  padding: 1,
52717
52817
  cursor: 'pointer',
52718
52818
  }, color: (theme) => theme.palette.text.primary, children: displayValue || (typeof value === 'string' && value) || '-' }), businessData && (jsxRuntimeExports.jsx(ContactInfoPopup, { contactData: businessData, open: Boolean(anchorEl), anchorEl: anchorEl, onClose: () => setAnchorEl(null), navigate: navigate, avatarImgUrl: userImage.imageUrl })), isLoadingData && (jsxRuntimeExports.jsx(material.Box, { display: "flex", alignItems: "center", justifyContent: "center", p: 1, children: jsxRuntimeExports.jsx(material.CircularProgress, { size: 20 }) }))] }));
@@ -52741,11 +52841,38 @@ const EntityInfoLabel = (props) => {
52741
52841
  const inputType = props.inputType ?? 'text';
52742
52842
  const [isEditing, setIsEditing] = React$1.useState(false);
52743
52843
  const [isSaving, setIsSaving] = React$1.useState(false);
52844
+ const titleRef = React$1.useRef(null);
52845
+ const [isTitleTruncated, setIsTitleTruncated] = React$1.useState(false);
52744
52846
  const [inputValue, setInputValue] = React$1.useState(() => {
52745
52847
  if (props.entityType === 'business')
52746
52848
  return value;
52747
52849
  return typeof value === 'string' ? value : undefined;
52748
52850
  });
52851
+ React$1.useEffect(() => {
52852
+ const el = titleRef.current;
52853
+ if (!el)
52854
+ return;
52855
+ const check = () => {
52856
+ const next = el.scrollWidth > el.clientWidth;
52857
+ setIsTitleTruncated(next);
52858
+ };
52859
+ check();
52860
+ if (typeof ResizeObserver !== 'undefined') {
52861
+ const ro = new ResizeObserver(() => {
52862
+ check();
52863
+ });
52864
+ ro.observe(el);
52865
+ return () => {
52866
+ ro.disconnect();
52867
+ };
52868
+ }
52869
+ if (typeof window === 'undefined')
52870
+ return;
52871
+ window.addEventListener('resize', check);
52872
+ return () => {
52873
+ window.removeEventListener('resize', check);
52874
+ };
52875
+ }, [title, isEditing]);
52749
52876
  React$1.useEffect(() => {
52750
52877
  if (props.entityType === 'business') {
52751
52878
  setInputValue(value);
@@ -52850,12 +52977,17 @@ const EntityInfoLabel = (props) => {
52850
52977
  '&:hover .edit-icon': {
52851
52978
  opacity: 1,
52852
52979
  },
52853
- }, children: [jsxRuntimeExports.jsxs(material.Box, { display: "flex", position: "relative", minHeight: '25px', children: [jsxRuntimeExports.jsx(material.Typography, { letterSpacing: -0.5, fontWeight: '600', alignSelf: 'center', flexGrow: isEditing ? 1 : 0, color: (theme) => theme.palette.text.primary, children: title }), isNotEditable ? null : isEditing ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(StyledSaveCancelButton$1, { size: "small", onClick: handleSave, children: isSaving ? jsxRuntimeExports.jsx(material.CircularProgress, { size: 24 }) : jsxRuntimeExports.jsx(default_1$a, {}) }), jsxRuntimeExports.jsx(StyledSaveCancelButton$1, { size: "small", onClick: handleCancel, children: jsxRuntimeExports.jsx(default_1$8, {}) })] })) : (jsxRuntimeExports.jsx(StyledIconButton$3, { className: "edit-icon", size: "small", onClick: handleEditClick, children: jsxRuntimeExports.jsx(default_1$f, {}) }))] }), jsxRuntimeExports.jsx(material.Box, { width: isEditing ? '100%' : '50%', position: "relative", children: isEditing && inputType === 'text' ? (jsxRuntimeExports.jsx(material.TextField, { value: textValue, onChange: handleInputChange, variant: "standard", size: "small", sx: { width: '100%' } })) : isEditing && (inputType === 'select' || inputType === 'selectMembers') ? (jsxRuntimeExports.jsxs(material.Select, { value: selectValue, onChange: handleSelectChange, variant: "standard", size: "small", sx: { width: '100%' }, children: [props.entityType === 'contact' ? (jsxRuntimeExports.jsx(material.MenuItem, { value: "", children: t('conversations.contactDetails.contactInfo.emptySelection') })) : null, options.map((option, index) => (jsxRuntimeExports.jsx(material.MenuItem, { value: option.id, children: props.entityType === 'contact'
52980
+ }, children: [jsxRuntimeExports.jsxs(material.Box, { display: "flex", position: "relative", minHeight: '25px', children: [isTitleTruncated ? (jsxRuntimeExports.jsx(material.Tooltip, { title: title, arrow: true, children: jsxRuntimeExports.jsx(material.Typography, { ref: titleRef, component: "span", variant: "body2", letterSpacing: -0.5, fontWeight: '600', alignSelf: 'center', flexGrow: isEditing ? 1 : 0, color: (theme) => theme.palette.text.primary, noWrap: true, sx: {
52981
+ minWidth: 0,
52982
+ overflow: 'hidden',
52983
+ textOverflow: 'ellipsis',
52984
+ whiteSpace: 'nowrap',
52985
+ }, children: title }) })) : (jsxRuntimeExports.jsx(material.Typography, { ref: titleRef, component: "span", variant: "body2", letterSpacing: -0.5, fontWeight: '600', alignSelf: 'center', flexGrow: isEditing ? 1 : 0, color: (theme) => theme.palette.text.primary, noWrap: true, sx: { minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, children: title })), isNotEditable ? null : isEditing ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(StyledSaveCancelButton$1, { size: "small", onClick: handleSave, children: isSaving ? jsxRuntimeExports.jsx(material.CircularProgress, { size: 24 }) : jsxRuntimeExports.jsx(default_1$a, {}) }), jsxRuntimeExports.jsx(StyledSaveCancelButton$1, { size: "small", onClick: handleCancel, children: jsxRuntimeExports.jsx(default_1$8, {}) })] })) : (jsxRuntimeExports.jsx(StyledIconButton$3, { className: "edit-icon", size: "small", onClick: handleEditClick, children: jsxRuntimeExports.jsx(default_1$f, {}) }))] }), jsxRuntimeExports.jsx(material.Box, { width: isEditing ? '100%' : '50%', position: "relative", children: isEditing && inputType === 'text' ? (jsxRuntimeExports.jsx(material.TextField, { value: textValue, onChange: handleInputChange, variant: "standard", size: "small", sx: { width: '100%' } })) : isEditing && (inputType === 'select' || inputType === 'selectMembers') ? (jsxRuntimeExports.jsxs(material.Select, { value: selectValue, onChange: handleSelectChange, variant: "standard", size: "small", sx: { width: '100%' }, children: [props.entityType === 'contact' ? (jsxRuntimeExports.jsx(material.MenuItem, { value: "", children: t('conversations.contactDetails.contactInfo.emptySelection') })) : null, options.map((option, index) => (jsxRuntimeExports.jsx(material.MenuItem, { value: option.id, children: props.entityType === 'contact'
52854
52986
  ? option.name?.trim() || (isUserInfo(option) ? option.email : '') || 'Sin nombre'
52855
52987
  : option.name?.trim() || option.email || 'Sin nombre' }, index)))] })) : isEditing && isContactBirthdayProps(props) ? (jsxRuntimeExports.jsx(DateSelect, { birthDate: props.contact.field.birthDate, setBirthDate: props.contact.action.setBirthDate, dateFormat: props.dateFormat })) : !isEditing &&
52856
52988
  props.entityType === 'contact' &&
52857
52989
  inputType === 'selectBusiness' &&
52858
- props.businessId ? (jsxRuntimeExports.jsx(SelectBusinessLabel, { value: value, displayValue: displayValue, businessId: props.businessId })) : (jsxRuntimeExports.jsx(material.Typography, { fontWeight: '400', sx: { padding: '2.5px 14px 8.5px 0px' }, color: (theme) => theme.palette.text.primary, children: displayValue || (typeof value === 'string' && value) || '-' })) })] }));
52990
+ props.businessId ? (jsxRuntimeExports.jsx(SelectBusinessLabel, { value: String(value ?? ''), displayValue: String(displayValue ?? ''), businessId: props.businessId })) : (jsxRuntimeExports.jsx(material.Typography, { variant: "body2", fontWeight: '400', sx: { padding: '2.5px 14px 8.5px 0px' }, color: (theme) => theme.palette.text.primary, children: displayValue || (typeof value === 'string' && value) || '-' })) })] }));
52859
52991
  };
52860
52992
 
52861
52993
  const ContactInfoLabel = (props) => {
@@ -54687,13 +54819,19 @@ const ContactBox = material.styled(material.Box)(({ theme }) => ({
54687
54819
  }));
54688
54820
  const FieldName = material.styled(material.Typography)(({ theme }) => ({
54689
54821
  fontWeight: 600,
54822
+ fontSize: '0.875rem',
54690
54823
  alignSelf: 'center',
54691
54824
  color: theme.palette.text.primary,
54692
54825
  letterSpacing: -0.5,
54693
54826
  padding: 0,
54827
+ whiteSpace: 'nowrap',
54828
+ overflow: 'hidden',
54829
+ textOverflow: 'ellipsis',
54830
+ minWidth: 0,
54694
54831
  }));
54695
54832
  const FieldValue = material.styled(material.Typography)(({ theme }) => ({
54696
54833
  fontWeight: 400,
54834
+ fontSize: '0.875rem',
54697
54835
  padding: '2.5px 14px 8.5px 0px',
54698
54836
  color: theme.palette.text.primary,
54699
54837
  wordWrap: 'break-word',
@@ -54706,6 +54844,8 @@ const EntityCustomFieldLabel = ({ property, entity, entityType, entityId, custom
54706
54844
  const { setCustomProperties } = entity.action;
54707
54845
  const [isEditing, setIsEditing] = React$1.useState(false);
54708
54846
  const [isSaving, setIsSaving] = React$1.useState(false);
54847
+ const titleRef = React$1.useRef(null);
54848
+ const [isTitleTruncated, setIsTitleTruncated] = React$1.useState(false);
54709
54849
  const userDateFormat = (userTrii?.regCon_dateFormat || 'YYYY/MM/DD').toUpperCase();
54710
54850
  const userTimeFormat = userTrii?.regCon_timeFormat || '24';
54711
54851
  // Determina si el tipo de campo es numérico
@@ -54811,6 +54951,42 @@ const EntityCustomFieldLabel = ({ property, entity, entityType, entityId, custom
54811
54951
  const foundField = customContactFields.find((field) => field.nameKey === propertyNameKey);
54812
54952
  return foundField?.name || propertyNameKey;
54813
54953
  };
54954
+ React$1.useEffect(() => {
54955
+ const el = titleRef.current;
54956
+ if (!el)
54957
+ return;
54958
+ const check = () => {
54959
+ const next = el.scrollWidth > el.clientWidth;
54960
+ setIsTitleTruncated((prev) => (prev === next ? prev : next));
54961
+ };
54962
+ check();
54963
+ if (typeof ResizeObserver !== 'undefined') {
54964
+ let rafId = 0;
54965
+ const ro = new ResizeObserver(() => {
54966
+ if (typeof window === 'undefined') {
54967
+ check();
54968
+ return;
54969
+ }
54970
+ if (rafId)
54971
+ window.cancelAnimationFrame(rafId);
54972
+ rafId = window.requestAnimationFrame(() => {
54973
+ check();
54974
+ });
54975
+ });
54976
+ ro.observe(el);
54977
+ return () => {
54978
+ if (typeof window !== 'undefined' && rafId)
54979
+ window.cancelAnimationFrame(rafId);
54980
+ ro.disconnect();
54981
+ };
54982
+ }
54983
+ if (typeof window === 'undefined')
54984
+ return;
54985
+ window.addEventListener('resize', check);
54986
+ return () => {
54987
+ window.removeEventListener('resize', check);
54988
+ };
54989
+ }, [customContactFields, property.nameKey]);
54814
54990
  const handleInputChange = (name, value) => {
54815
54991
  const updatedValue = property.type === Contacts.ContactField_type.DATERANGE
54816
54992
  ? Array.isArray(value) && value[0] && value[1]
@@ -54863,7 +55039,7 @@ const EntityCustomFieldLabel = ({ property, entity, entityType, entityId, custom
54863
55039
  else
54864
55040
  return (jsxRuntimeExports.jsx(CustomPropertyInput, { type: type, nameKey: nameKey, value: value, onChange: handleInputChange }));
54865
55041
  };
54866
- return (jsxRuntimeExports.jsxs(ContactBox, { className: `fadein ${property.type === Contacts.ContactField_type.LONGTEXT ? 'contacts-col-12' : 'contacts-col-5'}`, children: [jsxRuntimeExports.jsxs(material.Box, { display: "flex", position: "relative", minHeight: "25px", children: [jsxRuntimeExports.jsx(FieldName, { flexGrow: isEditing ? 1 : 0, children: getPropertyName(property.nameKey) }), isEditing ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(StyledSaveCancelButton, { size: "small", onClick: handleSave, children: isSaving ? jsxRuntimeExports.jsx(material.CircularProgress, { size: 24 }) : jsxRuntimeExports.jsx(default_1$a, {}) }), jsxRuntimeExports.jsx(StyledSaveCancelButton, { size: "small", onClick: handleCancel, children: jsxRuntimeExports.jsx(default_1$8, {}) })] })) : (jsxRuntimeExports.jsx(StyledIconButton$2, { className: "edit-icon", size: "small", onClick: toggleEdit, children: jsxRuntimeExports.jsx(default_1$f, {}) }))] }), jsxRuntimeExports.jsx(material.Box, { width: isEditing || property.type === Contacts.ContactField_type.LONGTEXT ? '100%' : '50%', position: "relative", children: isEditing ? (EditField()) : (jsxRuntimeExports.jsx(FieldValue, { children: hasValue(property?.value)
55042
+ return (jsxRuntimeExports.jsxs(ContactBox, { className: `fadein ${property.type === Contacts.ContactField_type.LONGTEXT ? 'contacts-col-12' : 'contacts-col-5'}`, children: [jsxRuntimeExports.jsxs(material.Box, { display: "flex", position: "relative", minHeight: "25px", alignItems: "center", children: [isTitleTruncated ? (jsxRuntimeExports.jsx(material.Tooltip, { title: getPropertyName(property.nameKey), arrow: true, children: jsxRuntimeExports.jsx(FieldName, { ref: titleRef, flexGrow: 1, noWrap: true, children: getPropertyName(property.nameKey) }) })) : (jsxRuntimeExports.jsx(FieldName, { ref: titleRef, flexGrow: 1, noWrap: true, children: getPropertyName(property.nameKey) })), isEditing ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(StyledSaveCancelButton, { size: "small", onClick: handleSave, children: isSaving ? jsxRuntimeExports.jsx(material.CircularProgress, { size: 24 }) : jsxRuntimeExports.jsx(default_1$a, {}) }), jsxRuntimeExports.jsx(StyledSaveCancelButton, { size: "small", onClick: handleCancel, children: jsxRuntimeExports.jsx(default_1$8, {}) })] })) : (jsxRuntimeExports.jsx(StyledIconButton$2, { className: "edit-icon", size: "small", onClick: toggleEdit, children: jsxRuntimeExports.jsx(default_1$f, {}) }))] }), jsxRuntimeExports.jsx(material.Box, { width: isEditing || property.type === Contacts.ContactField_type.LONGTEXT ? '100%' : '50%', position: "relative", children: isEditing ? (EditField()) : (jsxRuntimeExports.jsx(FieldValue, { children: hasValue(property?.value)
54867
55043
  ? property.type === Contacts.ContactField_type.DATERANGE
54868
55044
  ? (() => {
54869
55045
  if (typeof property.value === 'string') {
@@ -56519,7 +56695,6 @@ const StyledBox = material.styled(material.Box)(({ theme }) => ({
56519
56695
  const StyledTypography = material.styled(material.Typography)(({}) => ({
56520
56696
  letterSpacing: -0.5,
56521
56697
  fontSize: 14,
56522
- fontWeight: 600,
56523
56698
  }));
56524
56699
  const HeaderBox = material.styled(material.Box)(({}) => ({
56525
56700
  display: 'flex',
@@ -57330,7 +57505,7 @@ const AddressInformation = ({ entityType, entityData, baseUrl, spaceId, onEntity
57330
57505
  onEntityUpdated,
57331
57506
  };
57332
57507
  const t = useTranslationContext();
57333
- const AddressGroup = ({ addressNumber, title, }) => (jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-4 rounded-xl p-4", children: [jsxRuntimeExports.jsx(material.Typography, { variant: "h6", children: title }), jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-2 gap-x-4 gap-y-3", children: [jsxRuntimeExports.jsx("div", { className: "col-span-2", children: jsxRuntimeExports.jsx(EntityInfoLabel, { entityType: entityType, title: t('conversations.contactDetails.street'), value: entityData[addressNumber]?.street ?? '', ...commonProps, constructUpdateObject: (value) => ({
57508
+ const AddressGroup = ({ addressNumber, title, }) => (jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-4 rounded-xl p-4", children: [jsxRuntimeExports.jsx(material.Typography, { variant: "body2", children: title }), jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-2 gap-x-4 gap-y-3", children: [jsxRuntimeExports.jsx("div", { className: "col-span-2", children: jsxRuntimeExports.jsx(EntityInfoLabel, { entityType: entityType, title: t('conversations.contactDetails.street'), value: entityData[addressNumber]?.street ?? '', ...commonProps, constructUpdateObject: (value) => ({
57334
57509
  [addressNumber]: { street: value },
57335
57510
  }), minWidth: "100%" }) }), jsxRuntimeExports.jsx(EntityInfoLabel, { entityType: entityType, title: t('conversations.contactDetails.city'), value: entityData[addressNumber]?.city ?? '', ...commonProps, constructUpdateObject: (value) => ({
57336
57511
  [addressNumber]: { city: value },
@@ -57370,11 +57545,31 @@ const useTagsEditorController = ({ open, baseUrl, spaceId, contactData, contactT
57370
57545
  const [draftLabels, setDraftLabels] = React$1.useState([]);
57371
57546
  const [tagsEditorInitialized, setTagsEditorInitialized] = React$1.useState(false);
57372
57547
  const [isSaving, setIsSaving] = React$1.useState(false);
57548
+ const [createdLabels, setCreatedLabels] = React$1.useState([]);
57549
+ const [isCreatingLabel, setIsCreatingLabel] = React$1.useState(false);
57550
+ const labelsOptions = React$1.useMemo(() => {
57551
+ const safeLabels = labels ?? [];
57552
+ const safeCreated = createdLabels ?? [];
57553
+ const byId = new Map();
57554
+ for (const label of safeLabels) {
57555
+ if (!label?.id)
57556
+ continue;
57557
+ byId.set(String(label.id), label);
57558
+ }
57559
+ for (const label of safeCreated) {
57560
+ if (!label?.id)
57561
+ continue;
57562
+ byId.set(String(label.id), label);
57563
+ }
57564
+ return Array.from(byId.values());
57565
+ }, [labels, createdLabels]);
57373
57566
  const reset = React$1.useCallback(() => {
57374
57567
  setView('main');
57375
57568
  setDraftLabels([]);
57376
57569
  setTagsEditorInitialized(false);
57377
57570
  setIsSaving(false);
57571
+ setCreatedLabels([]);
57572
+ setIsCreatingLabel(false);
57378
57573
  }, []);
57379
57574
  React$1.useEffect(() => {
57380
57575
  if (!open) {
@@ -57388,13 +57583,61 @@ const useTagsEditorController = ({ open, baseUrl, spaceId, contactData, contactT
57388
57583
  }
57389
57584
  if (tagsEditorInitialized)
57390
57585
  return;
57391
- if (!labels.length)
57586
+ if (!labelsOptions.length)
57392
57587
  return;
57393
57588
  const selectedTagIds = new Set(selectedTags.map((t) => String(t.id)));
57394
- const initialDraft = labels.filter((l) => selectedTagIds.has(String(l?.id)));
57589
+ const initialDraft = labelsOptions.filter((l) => selectedTagIds.has(String(l?.id)));
57395
57590
  setDraftLabels(initialDraft);
57396
57591
  setTagsEditorInitialized(true);
57397
- }, [view, tagsEditorInitialized, labels, selectedTags]);
57592
+ }, [view, tagsEditorInitialized, labelsOptions, selectedTags]);
57593
+ const handleCreateLabel = React$1.useCallback(async (name) => {
57594
+ if (isCreatingLabel)
57595
+ return;
57596
+ if (!baseUrl || !spaceId)
57597
+ return;
57598
+ const trimmedName = String(name ?? '').trim();
57599
+ if (!trimmedName)
57600
+ return;
57601
+ const normalizedName = trimmedName.toLowerCase();
57602
+ const existing = labelsOptions.find((l) => String(l?.name ?? '')
57603
+ .trim()
57604
+ .toLowerCase() === normalizedName);
57605
+ if (existing?.id) {
57606
+ setDraftLabels((prev) => {
57607
+ const safePrev = prev ?? [];
57608
+ const existsInDraft = safePrev.some((p) => String(p?.id) === String(existing.id));
57609
+ if (existsInDraft)
57610
+ return safePrev;
57611
+ return [...safePrev, existing];
57612
+ });
57613
+ return;
57614
+ }
57615
+ setIsCreatingLabel(true);
57616
+ try {
57617
+ const created = await createLabel({ baseUrl, spaceId, name: trimmedName });
57618
+ setCreatedLabels((prev) => {
57619
+ const safePrev = prev ?? [];
57620
+ if (!created?.id)
57621
+ return safePrev;
57622
+ const existsInCreated = safePrev.some((p) => String(p?.id) === String(created.id));
57623
+ if (existsInCreated)
57624
+ return safePrev;
57625
+ return [...safePrev, created];
57626
+ });
57627
+ setDraftLabels((prev) => {
57628
+ const safePrev = prev ?? [];
57629
+ if (!created?.id)
57630
+ return safePrev;
57631
+ const existsInDraft = safePrev.some((p) => String(p?.id) === String(created.id));
57632
+ if (existsInDraft)
57633
+ return safePrev;
57634
+ return [...safePrev, created];
57635
+ });
57636
+ }
57637
+ finally {
57638
+ setIsCreatingLabel(false);
57639
+ }
57640
+ }, [isCreatingLabel, baseUrl, spaceId, labelsOptions]);
57398
57641
  const handleSaveTags = React$1.useCallback(async () => {
57399
57642
  if (isSaving)
57400
57643
  return;
@@ -57428,21 +57671,18 @@ const useTagsEditorController = ({ open, baseUrl, spaceId, contactData, contactT
57428
57671
  setView,
57429
57672
  draftLabels,
57430
57673
  setDraftLabels,
57674
+ labelsOptions,
57431
57675
  isSaving,
57676
+ isCreatingLabel,
57677
+ handleCreateLabel,
57432
57678
  handleSaveTags,
57433
57679
  };
57434
57680
  };
57435
57681
 
57436
57682
  const useModalCloseHandler = ({ onClose }) => {
57437
- const handleClose = React$1.useCallback((event, reason) => {
57683
+ const handleClose = React$1.useCallback((_event, reason) => {
57438
57684
  if (reason === 'escapeKeyDown') {
57439
- const maybeEvent = event;
57440
- if (typeof maybeEvent?.stopPropagation === 'function') {
57441
- maybeEvent.stopPropagation();
57442
- }
57443
- if (typeof maybeEvent?.preventDefault === 'function') {
57444
- maybeEvent.preventDefault();
57445
- }
57685
+ return;
57446
57686
  }
57447
57687
  onClose();
57448
57688
  }, [onClose]);
@@ -57451,6 +57691,7 @@ const useModalCloseHandler = ({ onClose }) => {
57451
57691
 
57452
57692
  const EditContactModal = ({ open, onClose, baseUrl, spaceId, contactId, sx, language = 'en', navigate, }) => {
57453
57693
  const { t: i18nT, i18n } = reactI18next.useTranslation();
57694
+ const modalContentRef = React$1.useRef(null);
57454
57695
  React$1.useEffect(() => {
57455
57696
  if (language) {
57456
57697
  i18n.changeLanguage(language);
@@ -57472,7 +57713,7 @@ const EditContactModal = ({ open, onClose, baseUrl, spaceId, contactId, sx, lang
57472
57713
  entity: state.contactData,
57473
57714
  setEntity: (next) => actions.setContactData(next ?? undefined),
57474
57715
  });
57475
- const { view, setView, draftLabels, setDraftLabels, isSaving: isSavingTags, handleSaveTags, } = useTagsEditorController({
57716
+ const { view, setView, draftLabels, setDraftLabels, labelsOptions, isSaving: isSavingTags, isCreatingLabel, handleCreateLabel, handleSaveTags, } = useTagsEditorController({
57476
57717
  open,
57477
57718
  baseUrl,
57478
57719
  spaceId,
@@ -57509,23 +57750,29 @@ const EditContactModal = ({ open, onClose, baseUrl, spaceId, contactId, sx, lang
57509
57750
  boxShadow: 24,
57510
57751
  outline: 0,
57511
57752
  p: 3,
57512
- overflow: 'hidden',
57753
+ overflow: 'visible',
57513
57754
  };
57514
57755
  const mergedSx = Array.isArray(sx) ? [baseSx, ...sx] : sx ? [baseSx, sx] : baseSx;
57515
- return (jsxRuntimeExports.jsx(EditContactApiProvider, { value: api, children: jsxRuntimeExports.jsx(TranslationProvider, { t: t, children: jsxRuntimeExports.jsx(NavigateProvider, { navigate: navigate, children: jsxRuntimeExports.jsx(material.Modal, { open: open, onClose: handleClose, closeAfterTransition: true, slots: { backdrop: material.Backdrop }, slotProps: { backdrop: { timeout: 200 } }, children: jsxRuntimeExports.jsx(material.Fade, { in: open, timeout: 200, children: jsxRuntimeExports.jsx(material.Box, { sx: mergedSx, children: state.isLoading && !state.contactData ? (jsxRuntimeExports.jsx(material.Box, { sx: {
57516
- display: 'flex',
57517
- justifyContent: 'center',
57518
- alignItems: 'center',
57519
- minHeight: 220,
57520
- }, children: jsxRuntimeExports.jsx(material.CircularProgress, {}) })) : state.error ? (jsxRuntimeExports.jsx(material.Box, { sx: { mb: 2 }, children: "Failed to load contact" })) : state.contactData ? (jsxRuntimeExports.jsx(EditEntityProvider, { entityType: selectors.contactType === 'business' ? 'business' : 'contact', entityData: state.contactData, customContactFields: selectors.contactFields, baseUrl: baseUrl, spaceId: spaceId, children: jsxRuntimeExports.jsxs(material.Box, { sx: { position: 'relative', height: '100%' }, children: [jsxRuntimeExports.jsx(material.Fade, { in: view === 'main', timeout: 200, mountOnEnter: true, unmountOnExit: true, children: jsxRuntimeExports.jsxs(material.Box, { sx: { pt: 0.5, position: 'absolute', inset: 0, overflowY: 'auto' }, children: [jsxRuntimeExports.jsx(Header, { imgUrl: image.imageUrl, displayName: selectors.displayName, tags: selectors.tags, onEditTags: () => {
57521
- setView('tags');
57522
- }, onUploadPhoto: image.action.uploadImage, onPhotoFileChange: image.inputAtributes.onChange, photoInputRef: image.inputAtributes.ref, isUploadingPhoto: image.isUploading, onDeletePhoto: image.action.deleteImage, isDeletingPhoto: image.isDeleting, contactType: selectors.contactType, entityId: state.contactData?.id, firstName: selectors.isContact ? state.contactData.firstName : undefined, lastName: selectors.isContact ? state.contactData.lastName : undefined, name: selectors.isBusiness ? state.contactData.name : undefined, onEntityUpdated: handleEntityUpdated }), jsxRuntimeExports.jsxs(material.Box, { sx: { px: 1, pb: 2 }, children: [jsxRuntimeExports.jsx(General, { dateFormat: selectors.userTrii?.regCon_dateFormat || 'MM/dd/yyyy', entityType: selectors.contactType === 'contact' ||
57523
- selectors.contactType === 'business'
57524
- ? selectors.contactType
57525
- : 'contact', entityData: state.contactData, customContactFields: selectors.contactFields, baseUrl: baseUrl, spaceId: spaceId, onEntityUpdated: handleEntityUpdated, currentUser: selectors.userTrii }), jsxRuntimeExports.jsx(AddressInformation, { entityType: selectors.contactType === 'contact' ||
57526
- selectors.contactType === 'business'
57527
- ? selectors.contactType
57528
- : 'contact', entityData: state.contactData, baseUrl: baseUrl, spaceId: spaceId, onEntityUpdated: handleEntityUpdated }), jsxRuntimeExports.jsx(ContactInformation, { ownerData: state.contactData })] })] }) }), jsxRuntimeExports.jsx(material.Fade, { in: view === 'tags', timeout: 200, mountOnEnter: true, unmountOnExit: true, children: jsxRuntimeExports.jsx(material.Box, { sx: { pt: 0.5, position: 'absolute', inset: 0, overflowY: 'auto' }, children: jsxRuntimeExports.jsx(TagsEditor, { value: draftLabels, options: selectors.labels, onChange: setDraftLabels, onBack: () => setView('main'), onSave: handleSaveTags, isSaving: isSavingTags }) }) })] }) })) : null }) }) }) }) }) }));
57756
+ return (jsxRuntimeExports.jsx(EditContactApiProvider, { value: api, children: jsxRuntimeExports.jsx(TranslationProvider, { t: t, children: jsxRuntimeExports.jsx(NavigateProvider, { navigate: navigate, children: jsxRuntimeExports.jsx(material.Modal, { open: open, onClose: handleClose, closeAfterTransition: true, slots: { backdrop: material.Backdrop }, slotProps: { backdrop: { timeout: 200 } }, children: jsxRuntimeExports.jsx(material.Fade, { in: open, timeout: 200, children: jsxRuntimeExports.jsxs(material.Box, { sx: mergedSx, ref: modalContentRef, children: [jsxRuntimeExports.jsx(material.IconButton, { "aria-label": "close", onClick: handleClose, sx: {
57757
+ position: 'absolute',
57758
+ right: 5,
57759
+ top: 5,
57760
+ color: (theme) => theme.palette.grey[500],
57761
+ zIndex: 1,
57762
+ }, size: "small", children: jsxRuntimeExports.jsx(default_1$g, { sx: { fontSize: 20 } }) }), state.isLoading && !state.contactData ? (jsxRuntimeExports.jsx(material.Box, { sx: {
57763
+ display: 'flex',
57764
+ justifyContent: 'center',
57765
+ alignItems: 'center',
57766
+ minHeight: 220,
57767
+ }, children: jsxRuntimeExports.jsx(material.CircularProgress, {}) })) : state.error ? (jsxRuntimeExports.jsx(material.Box, { sx: { mb: 2 }, children: "Failed to load contact" })) : state.contactData ? (jsxRuntimeExports.jsx(EditEntityProvider, { entityType: selectors.contactType === 'business' ? 'business' : 'contact', entityData: state.contactData, customContactFields: selectors.contactFields, baseUrl: baseUrl, spaceId: spaceId, children: jsxRuntimeExports.jsxs(material.Box, { sx: { position: 'relative', height: '100%' }, children: [jsxRuntimeExports.jsx(material.Fade, { in: view === 'main', timeout: 200, mountOnEnter: true, unmountOnExit: true, children: jsxRuntimeExports.jsxs(material.Box, { sx: { pt: 0.5, position: 'absolute', inset: 0, overflowY: 'auto' }, children: [jsxRuntimeExports.jsx(Header, { imgUrl: image.imageUrl, displayName: selectors.displayName, tags: selectors.tags, onEditTags: () => {
57768
+ setView('tags');
57769
+ }, onUploadPhoto: image.action.uploadImage, onPhotoFileChange: image.inputAtributes.onChange, photoInputRef: image.inputAtributes.ref, isUploadingPhoto: image.isUploading, onDeletePhoto: image.action.deleteImage, isDeletingPhoto: image.isDeleting, contactType: selectors.contactType, entityId: state.contactData?.id, firstName: selectors.isContact ? state.contactData.firstName : undefined, lastName: selectors.isContact ? state.contactData.lastName : undefined, name: selectors.isBusiness ? state.contactData.name : undefined, onEntityUpdated: handleEntityUpdated }), jsxRuntimeExports.jsxs(material.Box, { sx: { px: 1, pb: 2 }, children: [jsxRuntimeExports.jsx(General, { dateFormat: selectors.userTrii?.regCon_dateFormat || 'MM/dd/yyyy', entityType: selectors.contactType === 'contact' ||
57770
+ selectors.contactType === 'business'
57771
+ ? selectors.contactType
57772
+ : 'contact', entityData: state.contactData, customContactFields: selectors.contactFields, baseUrl: baseUrl, spaceId: spaceId, onEntityUpdated: handleEntityUpdated, currentUser: selectors.userTrii }), jsxRuntimeExports.jsx(AddressInformation, { entityType: selectors.contactType === 'contact' ||
57773
+ selectors.contactType === 'business'
57774
+ ? selectors.contactType
57775
+ : 'contact', entityData: state.contactData, baseUrl: baseUrl, spaceId: spaceId, onEntityUpdated: handleEntityUpdated }), jsxRuntimeExports.jsx(ContactInformation, { ownerData: state.contactData })] })] }) }), jsxRuntimeExports.jsx(material.Fade, { in: view === 'tags', timeout: 200, mountOnEnter: true, unmountOnExit: true, children: jsxRuntimeExports.jsx(material.Box, { sx: { pt: 0.5, position: 'absolute', inset: 0, overflowY: 'auto' }, children: jsxRuntimeExports.jsx(TagsEditor, { value: draftLabels, options: labelsOptions, onChange: setDraftLabels, onBack: () => setView('main'), onSave: handleSaveTags, isSaving: isSavingTags, onCreateNew: handleCreateLabel, isCreatingNew: isCreatingLabel, popperContainer: modalContentRef.current }) }) })] }) })) : null] }) }) }) }) }) }));
57529
57776
  };
57530
57777
 
57531
57778
  exports.i18n = i18n;