@trii/components 2.0.26 → 2.0.28

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 (30) hide show
  1. package/dist/cjs/index.js +2773 -100
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/components/EditContactModal/EditContactModal.d.ts +3 -2
  4. package/dist/cjs/types/components/EditContactModal/components/Header/Header.d.ts +13 -2
  5. package/dist/cjs/types/components/EditContactModal/components/Header/components/AvatarWithActions/AvatarWithActions.d.ts +12 -0
  6. package/dist/cjs/types/components/EditContactModal/components/Header/components/Tags/Tags.d.ts +8 -0
  7. package/dist/cjs/types/components/EditContactModal/components/Header/components/Tags/index.d.ts +1 -0
  8. package/dist/cjs/types/components/EditContactModal/components/Header/components/index.d.ts +1 -0
  9. package/dist/cjs/types/components/EditContactModal/components/TagsEditor/TagsEditor.d.ts +12 -0
  10. package/dist/cjs/types/components/EditContactModal/hooks/useEditContactModalController.d.ts +9 -2
  11. package/dist/cjs/types/components/EditContactModal/hooks/useImage.d.ts +27 -0
  12. package/dist/cjs/types/components/EditContactModal/services/api.d.ts +46 -3
  13. package/dist/cjs/types/components/EditContactModal/services/http.d.ts +8 -0
  14. package/dist/cjs/types/components/EditContactModal/services/urls.d.ts +6 -0
  15. package/dist/esm/index.js +2775 -102
  16. package/dist/esm/index.js.map +1 -1
  17. package/dist/esm/types/components/EditContactModal/EditContactModal.d.ts +3 -2
  18. package/dist/esm/types/components/EditContactModal/components/Header/Header.d.ts +13 -2
  19. package/dist/esm/types/components/EditContactModal/components/Header/components/AvatarWithActions/AvatarWithActions.d.ts +12 -0
  20. package/dist/esm/types/components/EditContactModal/components/Header/components/Tags/Tags.d.ts +8 -0
  21. package/dist/esm/types/components/EditContactModal/components/Header/components/Tags/index.d.ts +1 -0
  22. package/dist/esm/types/components/EditContactModal/components/Header/components/index.d.ts +1 -0
  23. package/dist/esm/types/components/EditContactModal/components/TagsEditor/TagsEditor.d.ts +12 -0
  24. package/dist/esm/types/components/EditContactModal/hooks/useEditContactModalController.d.ts +9 -2
  25. package/dist/esm/types/components/EditContactModal/hooks/useImage.d.ts +27 -0
  26. package/dist/esm/types/components/EditContactModal/services/api.d.ts +46 -3
  27. package/dist/esm/types/components/EditContactModal/services/http.d.ts +8 -0
  28. package/dist/esm/types/components/EditContactModal/services/urls.d.ts +6 -0
  29. package/dist/index.d.ts +3 -2
  30. package/package.json +2 -2
@@ -3,9 +3,10 @@ export interface ContactInfoPopupProps {
3
3
  open: boolean;
4
4
  onClose: () => void;
5
5
  baseUrl?: string;
6
+ spaceId?: string;
6
7
  contactId?: string;
7
- t?: (key: string) => string;
8
+ t: (key: string) => string;
8
9
  sx?: SxProps<Theme>;
9
10
  }
10
- declare const EditContactModal: ({ open, onClose, baseUrl, contactId, sx, }: ContactInfoPopupProps) => import("react/jsx-runtime").JSX.Element;
11
+ declare const EditContactModal: ({ open, onClose, baseUrl, spaceId, contactId, sx, t, }: ContactInfoPopupProps) => import("react/jsx-runtime").JSX.Element;
11
12
  export default EditContactModal;
@@ -1,7 +1,18 @@
1
+ import { IContactTag } from '@trii/types/dist/Contacts';
2
+ import type { ChangeEvent, RefObject } from 'react';
1
3
  type HeaderProps = {
2
4
  imgUrl?: string;
3
- displayName?: string;
5
+ displayName: string;
4
6
  onError?: (error: Error) => void;
7
+ tags: IContactTag[];
8
+ t: (key: string) => string;
9
+ onEditTags: () => void;
10
+ onUploadPhoto: () => void;
11
+ onPhotoFileChange: (event: ChangeEvent<HTMLInputElement>) => void;
12
+ photoInputRef: RefObject<HTMLInputElement>;
13
+ isUploadingPhoto: boolean;
14
+ onDeletePhoto: () => void;
15
+ isDeletingPhoto: boolean;
5
16
  };
6
- declare const Header: ({ imgUrl, displayName, onError, }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
17
+ declare const Header: ({ imgUrl, displayName, onError, tags, t, onEditTags, onUploadPhoto, onPhotoFileChange, photoInputRef, isUploadingPhoto, onDeletePhoto, isDeletingPhoto, }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
7
18
  export default Header;
@@ -0,0 +1,12 @@
1
+ type AvatarWithActionsProps = {
2
+ src?: string;
3
+ alt: string;
4
+ onError?: () => void;
5
+ onUpload?: () => void;
6
+ onDelete?: () => void;
7
+ isUploading?: boolean;
8
+ isDeleting?: boolean;
9
+ t: (key: string) => string;
10
+ };
11
+ declare const AvatarWithActions: ({ src, alt, onError, onUpload, onDelete, isUploading, isDeleting, t, }: AvatarWithActionsProps) => import("react/jsx-runtime").JSX.Element;
12
+ export default AvatarWithActions;
@@ -0,0 +1,8 @@
1
+ import { IContactTag } from '@trii/types/dist/Contacts';
2
+ interface TagsProps {
3
+ tags: IContactTag[];
4
+ t: (key: string) => string;
5
+ onEditTags: () => void;
6
+ }
7
+ declare const Tags: ({ tags, t, onEditTags }: TagsProps) => import("react/jsx-runtime").JSX.Element;
8
+ export default Tags;
@@ -0,0 +1 @@
1
+ export { default as Tags } from './Tags';
@@ -0,0 +1,12 @@
1
+ import { ILabel } from '@trii/types/dist/Contacts';
2
+ type TagsEditorProps = {
3
+ value: ILabel[];
4
+ options: ILabel[];
5
+ onChange: (value: ILabel[]) => void;
6
+ onBack: () => void;
7
+ onSave: () => void;
8
+ isSaving: boolean;
9
+ t: (key: string) => string;
10
+ };
11
+ declare const TagsEditor: ({ value, options, onChange, onBack, onSave, isSaving, t }: TagsEditorProps) => import("react/jsx-runtime").JSX.Element;
12
+ export default TagsEditor;
@@ -1,7 +1,9 @@
1
- import { IBusiness, IContact } from '@trii/types/dist/Contacts/contacts';
1
+ import { IBusiness, IContact, IContactTag } from '@trii/types/dist/Contacts/contacts';
2
+ import { ILabel } from '@trii/types/dist/Contacts';
2
3
  export type UseEditContactModalControllerArgs = {
3
4
  open: boolean;
4
5
  baseUrl?: string;
6
+ spaceId?: string;
5
7
  contactId?: string;
6
8
  initialContactData?: IContact | IBusiness;
7
9
  };
@@ -9,14 +11,19 @@ type ControllerState = {
9
11
  isLoading: boolean;
10
12
  error: unknown;
11
13
  contactData: IContact | IBusiness | null;
14
+ labels: ILabel[];
15
+ labelsLoading: boolean;
16
+ labelsError: unknown;
12
17
  };
13
- export declare function useEditContactModalController({ open, baseUrl, contactId, }: UseEditContactModalControllerArgs): {
18
+ export declare function useEditContactModalController({ open, baseUrl, spaceId, contactId, }: UseEditContactModalControllerArgs): {
14
19
  state: ControllerState;
15
20
  selectors: {
16
21
  isBusiness: boolean;
17
22
  isContact: boolean;
18
23
  contactType: "business" | "contact" | "unknown";
19
24
  displayName: string;
25
+ tags: IContactTag[];
26
+ labels: ILabel[];
20
27
  };
21
28
  actions: {
22
29
  setContactData: (contactData?: IContact | IBusiness) => void;
@@ -0,0 +1,27 @@
1
+ import { ChangeEvent } from 'react';
2
+ export type UseImageType = {
3
+ inputAtributes: {
4
+ onChange: (event: ChangeEvent<HTMLInputElement>) => void;
5
+ ref: React.RefObject<HTMLInputElement>;
6
+ type: string;
7
+ accept: string;
8
+ };
9
+ action: {
10
+ uploadImage: () => void;
11
+ deleteImage: () => Promise<void>;
12
+ };
13
+ imageUrl: string;
14
+ removeParams: (url: string) => string;
15
+ isUploading: boolean;
16
+ isDeleting: boolean;
17
+ };
18
+ type UseImageArgs = {
19
+ baseUrl?: string;
20
+ spaceId?: string;
21
+ entityType?: 'contact' | 'business';
22
+ entityId?: string;
23
+ initialImageUrl?: string;
24
+ onEntityUpdated?: (entity: unknown) => void;
25
+ };
26
+ declare const useImage: ({ baseUrl, spaceId, entityType, entityId, initialImageUrl, onEntityUpdated, }: UseImageArgs) => UseImageType;
27
+ export default useImage;
@@ -1,15 +1,58 @@
1
- import { IBusiness, IContact } from '@trii/types/dist/Contacts/contacts';
1
+ import { IBusiness, IContact, IContactTag } from '@trii/types/dist/Contacts/contacts';
2
+ import { ILabel } from '@trii/types/dist/Contacts';
3
+ import { UserTrii } from '@trii/types/dist/Users';
2
4
  type FetchContactArgs = {
3
5
  baseUrl: string;
6
+ spaceId: string;
4
7
  contactId: string;
5
8
  signal?: AbortSignal;
6
9
  };
7
- export declare function fetchContact({ baseUrl, contactId, signal }: FetchContactArgs): Promise<IContact | IBusiness>;
10
+ type FetchLabelsArgs = {
11
+ baseUrl: string;
12
+ spaceId: string;
13
+ signal?: AbortSignal;
14
+ };
15
+ export declare function fetchLabels({ baseUrl, spaceId, signal }: FetchLabelsArgs): Promise<ILabel[]>;
16
+ export declare function fetchContact({ baseUrl, spaceId, contactId, signal }: FetchContactArgs): Promise<IContact | IBusiness>;
17
+ type UpdateEntityArgs = {
18
+ baseUrl: string;
19
+ spaceId: string;
20
+ entityType: 'contact' | 'business';
21
+ entityId: string;
22
+ body: Partial<IContact> | Partial<IBusiness> | {
23
+ tags: IContactTag[];
24
+ };
25
+ signal?: AbortSignal;
26
+ };
27
+ export declare function updateEntity({ baseUrl, spaceId, entityType, entityId, body, signal }: UpdateEntityArgs): Promise<IContact | IBusiness>;
28
+ type DeleteEntityPhotoArgs = {
29
+ baseUrl: string;
30
+ spaceId: string;
31
+ entityType: 'contact' | 'business';
32
+ entityId: string;
33
+ signal?: AbortSignal;
34
+ };
35
+ export declare function deleteEntityPhoto({ baseUrl, spaceId, entityType, entityId, signal }: DeleteEntityPhotoArgs): Promise<unknown>;
8
36
  type UpdateContactArgs = {
9
37
  baseUrl: string;
38
+ spaceId: string;
10
39
  contactId: string;
11
40
  patch: Partial<IContact> | Partial<IBusiness>;
12
41
  signal?: AbortSignal;
13
42
  };
14
- export declare function updateContact({ baseUrl, contactId, patch, signal }: UpdateContactArgs): Promise<IContact | IBusiness>;
43
+ export declare function updateContact({ baseUrl, spaceId, contactId, patch, signal }: UpdateContactArgs): Promise<IContact | IBusiness>;
44
+ type FetchSettingsUserArgs = {
45
+ baseUrl: string;
46
+ spaceId: string;
47
+ signal?: AbortSignal;
48
+ };
49
+ export declare function fetchUserTrii({ baseUrl, spaceId, signal }: FetchSettingsUserArgs): Promise<UserTrii>;
50
+ type UploadAvatarArgs = {
51
+ baseUrl: string;
52
+ spaceId: string;
53
+ contactId: string;
54
+ file: File;
55
+ signal?: AbortSignal;
56
+ };
57
+ export declare function uploadAvatar({ baseUrl, spaceId, contactId, file, signal }: UploadAvatarArgs): Promise<string>;
15
58
  export {};
@@ -12,4 +12,12 @@ type RequestJsonArgs = {
12
12
  signal?: AbortSignal;
13
13
  };
14
14
  export declare function requestJson<T>({ url, method, headers, body, signal, }: RequestJsonArgs): Promise<T>;
15
+ type RequestFormDataArgs = {
16
+ url: string;
17
+ method?: HttpMethod;
18
+ headers?: HeadersInit;
19
+ formData: FormData;
20
+ signal?: AbortSignal;
21
+ };
22
+ export declare function requestFormData<T>({ url, method, headers, formData, signal, }: RequestFormDataArgs): Promise<T>;
15
23
  export {};
@@ -0,0 +1,6 @@
1
+ export declare function joinUrl(baseUrl: string, path: string): string;
2
+ export declare function getApiUrls(baseUrl: string, spaceId: string): {
3
+ CONTACTS: string;
4
+ MEDIA: string;
5
+ SETTINGS: string;
6
+ };
package/dist/index.d.ts CHANGED
@@ -18,10 +18,11 @@ interface ContactInfoPopupProps {
18
18
  open: boolean;
19
19
  onClose: () => void;
20
20
  baseUrl?: string;
21
+ spaceId?: string;
21
22
  contactId?: string;
22
- t?: (key: string) => string;
23
+ t: (key: string) => string;
23
24
  sx?: SxProps<Theme>;
24
25
  }
25
- declare const EditContactModal: ({ open, onClose, baseUrl, contactId, sx, }: ContactInfoPopupProps) => react_jsx_runtime.JSX.Element;
26
+ declare const EditContactModal: ({ open, onClose, baseUrl, spaceId, contactId, sx, t, }: ContactInfoPopupProps) => react_jsx_runtime.JSX.Element;
26
27
 
27
28
  export { ContactInfoPopup, EditContactModal };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trii/components",
3
- "version": "2.0.26",
3
+ "version": "2.0.28",
4
4
  "description": "Trii components package",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -94,7 +94,7 @@
94
94
  "react-dom": ">=17.0.2 <19.0.0"
95
95
  },
96
96
  "dependencies": {
97
- "@trii/types": "^2.10.398",
97
+ "@trii/types": "^2.10.586",
98
98
  "moment": "^2.30.1"
99
99
  }
100
100
  }