@trii/components 2.0.11 → 2.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +2814 -45
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/ContactInfoPopup/ContactInfoPopup.d.ts +1 -2
- package/dist/cjs/types/components/ContactInfoPopup/components/Header/Header.d.ts +6 -6
- package/dist/cjs/types/components/ContactInfoPopup/hooks/useContactInfoPopupTranslation.d.ts +24 -0
- package/dist/cjs/types/components/LanguageSelector.d.ts +2 -0
- package/dist/cjs/types/contexts/LanguageContext.d.ts +10 -0
- package/dist/cjs/types/i18n.d.ts +2 -0
- package/dist/cjs/types/index.d.ts +5 -0
- package/dist/cjs/types/translations/en.d.ts +31 -0
- package/dist/cjs/types/translations/es.d.ts +31 -0
- package/dist/cjs/types/translations/index.d.ts +2 -0
- package/dist/cjs/types/types/translations.d.ts +25 -0
- package/dist/cjs/types/utils/translation.d.ts +7 -0
- package/dist/esm/index.js +2811 -48
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/ContactInfoPopup/ContactInfoPopup.d.ts +1 -2
- package/dist/esm/types/components/ContactInfoPopup/components/Header/Header.d.ts +6 -6
- package/dist/esm/types/components/ContactInfoPopup/hooks/useContactInfoPopupTranslation.d.ts +24 -0
- package/dist/esm/types/components/LanguageSelector.d.ts +2 -0
- package/dist/esm/types/contexts/LanguageContext.d.ts +10 -0
- package/dist/esm/types/i18n.d.ts +2 -0
- package/dist/esm/types/index.d.ts +5 -0
- package/dist/esm/types/translations/en.d.ts +31 -0
- package/dist/esm/types/translations/es.d.ts +31 -0
- package/dist/esm/types/translations/index.d.ts +2 -0
- package/dist/esm/types/types/translations.d.ts +25 -0
- package/dist/esm/types/utils/translation.d.ts +7 -0
- package/dist/index.d.ts +84 -3
- package/package.json +6 -2
- package/readme +42 -0
|
@@ -4,11 +4,10 @@ export interface ContactInfoPopupProps {
|
|
|
4
4
|
open: boolean;
|
|
5
5
|
anchorEl: HTMLElement | null;
|
|
6
6
|
onClose: () => void;
|
|
7
|
-
t?: (key: string) => string;
|
|
8
7
|
contactData?: IContact | IBusiness;
|
|
9
8
|
avatarImgUrl?: string;
|
|
10
9
|
sx?: SxProps<Theme>;
|
|
11
10
|
navigate: (path: string) => void;
|
|
12
11
|
}
|
|
13
|
-
declare const ContactInfoPopup: ({ open, anchorEl, onClose, contactData, avatarImgUrl, navigate,
|
|
12
|
+
declare const ContactInfoPopup: ({ open, anchorEl, onClose, contactData, avatarImgUrl, navigate, }: ContactInfoPopupProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
13
|
export default ContactInfoPopup;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export interface HeaderProps {
|
|
2
|
+
contactId?: string;
|
|
3
|
+
imgUrl?: string;
|
|
4
|
+
name?: string;
|
|
5
5
|
navigate: (path: string) => void;
|
|
6
|
-
}
|
|
7
|
-
declare const Header: ({ imgUrl, name,
|
|
6
|
+
}
|
|
7
|
+
export declare const Header: ({ contactId, imgUrl, name, navigate }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
export default Header;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const useContactInfoPopupTranslation: () => {
|
|
2
|
+
businessSection: {
|
|
3
|
+
title: string;
|
|
4
|
+
description: string;
|
|
5
|
+
};
|
|
6
|
+
contactMethod: {
|
|
7
|
+
email: string;
|
|
8
|
+
phone: string;
|
|
9
|
+
website: string;
|
|
10
|
+
};
|
|
11
|
+
labelsSection: {
|
|
12
|
+
title: string;
|
|
13
|
+
};
|
|
14
|
+
membersSection: {
|
|
15
|
+
title: string;
|
|
16
|
+
noMembers: string;
|
|
17
|
+
};
|
|
18
|
+
global: {
|
|
19
|
+
properties: string;
|
|
20
|
+
business: string;
|
|
21
|
+
businessMembers: string;
|
|
22
|
+
labels: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface LanguageContextType {
|
|
3
|
+
language: string;
|
|
4
|
+
setLanguage: (lang: string) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare const LanguageProvider: React.FC<{
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const useLanguage: () => LanguageContextType;
|
|
10
|
+
export {};
|
|
@@ -1 +1,6 @@
|
|
|
1
1
|
export * from './components';
|
|
2
|
+
export { LanguageProvider, useLanguage } from './contexts/LanguageContext';
|
|
3
|
+
export { LanguageSelector } from './components/LanguageSelector';
|
|
4
|
+
export { useTriiTranslation } from './utils/translation';
|
|
5
|
+
export { enTranslations } from './translations/en';
|
|
6
|
+
export { esTranslations } from './translations/es';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare const enTranslations: {
|
|
2
|
+
components: {
|
|
3
|
+
contactInfoPopup: {
|
|
4
|
+
businessSection: {
|
|
5
|
+
title: string;
|
|
6
|
+
description: string;
|
|
7
|
+
};
|
|
8
|
+
contactMethod: {
|
|
9
|
+
email: string;
|
|
10
|
+
phone: string;
|
|
11
|
+
website: string;
|
|
12
|
+
};
|
|
13
|
+
labelsSection: {
|
|
14
|
+
title: string;
|
|
15
|
+
};
|
|
16
|
+
membersSection: {
|
|
17
|
+
title: string;
|
|
18
|
+
noMembers: string;
|
|
19
|
+
};
|
|
20
|
+
global: {
|
|
21
|
+
properties: string;
|
|
22
|
+
business: string;
|
|
23
|
+
businessMembers: string;
|
|
24
|
+
labels: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
textBox: {
|
|
28
|
+
placeholder: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare const esTranslations: {
|
|
2
|
+
components: {
|
|
3
|
+
contactInfoPopup: {
|
|
4
|
+
businessSection: {
|
|
5
|
+
title: string;
|
|
6
|
+
description: string;
|
|
7
|
+
};
|
|
8
|
+
contactMethod: {
|
|
9
|
+
email: string;
|
|
10
|
+
phone: string;
|
|
11
|
+
website: string;
|
|
12
|
+
};
|
|
13
|
+
labelsSection: {
|
|
14
|
+
title: string;
|
|
15
|
+
};
|
|
16
|
+
membersSection: {
|
|
17
|
+
title: string;
|
|
18
|
+
noMembers: string;
|
|
19
|
+
};
|
|
20
|
+
global: {
|
|
21
|
+
properties: string;
|
|
22
|
+
business: string;
|
|
23
|
+
businessMembers: string;
|
|
24
|
+
labels: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
textBox: {
|
|
28
|
+
placeholder: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface TriiTranslations {
|
|
2
|
+
components: {
|
|
3
|
+
contactInfoPopup: {
|
|
4
|
+
businessSection: {
|
|
5
|
+
title: string;
|
|
6
|
+
description: string;
|
|
7
|
+
};
|
|
8
|
+
contactMethod: {
|
|
9
|
+
email: string;
|
|
10
|
+
phone: string;
|
|
11
|
+
website: string;
|
|
12
|
+
};
|
|
13
|
+
labelsSection: {
|
|
14
|
+
title: string;
|
|
15
|
+
};
|
|
16
|
+
membersSection: {
|
|
17
|
+
title: string;
|
|
18
|
+
noMembers: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
textBox: {
|
|
22
|
+
placeholder: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { IContact, IBusiness } from '@trii/types/dist/Contacts';
|
|
3
3
|
import { SxProps, Theme } from '@mui/material';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import * as i18next from 'i18next';
|
|
4
6
|
|
|
5
7
|
interface TestBoxProps {
|
|
6
8
|
/**
|
|
@@ -14,12 +16,91 @@ interface ContactInfoPopupProps {
|
|
|
14
16
|
open: boolean;
|
|
15
17
|
anchorEl: HTMLElement | null;
|
|
16
18
|
onClose: () => void;
|
|
17
|
-
t?: (key: string) => string;
|
|
18
19
|
contactData?: IContact | IBusiness;
|
|
19
20
|
avatarImgUrl?: string;
|
|
20
21
|
sx?: SxProps<Theme>;
|
|
21
22
|
navigate: (path: string) => void;
|
|
22
23
|
}
|
|
23
|
-
declare const ContactInfoPopup: ({ open, anchorEl, onClose, contactData, avatarImgUrl, navigate,
|
|
24
|
+
declare const ContactInfoPopup: ({ open, anchorEl, onClose, contactData, avatarImgUrl, navigate, }: ContactInfoPopupProps) => react_jsx_runtime.JSX.Element;
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
interface LanguageContextType {
|
|
27
|
+
language: string;
|
|
28
|
+
setLanguage: (lang: string) => void;
|
|
29
|
+
}
|
|
30
|
+
declare const LanguageProvider: React.FC<{
|
|
31
|
+
children: React.ReactNode;
|
|
32
|
+
}>;
|
|
33
|
+
declare const useLanguage: () => LanguageContextType;
|
|
34
|
+
|
|
35
|
+
declare const LanguageSelector: React.FC;
|
|
36
|
+
|
|
37
|
+
declare const useTriiTranslation: (namespace?: string) => {
|
|
38
|
+
t: (key: string, options?: Record<string, any>) => string;
|
|
39
|
+
i18n: i18next.i18n;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
declare const enTranslations: {
|
|
43
|
+
components: {
|
|
44
|
+
contactInfoPopup: {
|
|
45
|
+
businessSection: {
|
|
46
|
+
title: string;
|
|
47
|
+
description: string;
|
|
48
|
+
};
|
|
49
|
+
contactMethod: {
|
|
50
|
+
email: string;
|
|
51
|
+
phone: string;
|
|
52
|
+
website: string;
|
|
53
|
+
};
|
|
54
|
+
labelsSection: {
|
|
55
|
+
title: string;
|
|
56
|
+
};
|
|
57
|
+
membersSection: {
|
|
58
|
+
title: string;
|
|
59
|
+
noMembers: string;
|
|
60
|
+
};
|
|
61
|
+
global: {
|
|
62
|
+
properties: string;
|
|
63
|
+
business: string;
|
|
64
|
+
businessMembers: string;
|
|
65
|
+
labels: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
textBox: {
|
|
69
|
+
placeholder: string;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
declare const esTranslations: {
|
|
75
|
+
components: {
|
|
76
|
+
contactInfoPopup: {
|
|
77
|
+
businessSection: {
|
|
78
|
+
title: string;
|
|
79
|
+
description: string;
|
|
80
|
+
};
|
|
81
|
+
contactMethod: {
|
|
82
|
+
email: string;
|
|
83
|
+
phone: string;
|
|
84
|
+
website: string;
|
|
85
|
+
};
|
|
86
|
+
labelsSection: {
|
|
87
|
+
title: string;
|
|
88
|
+
};
|
|
89
|
+
membersSection: {
|
|
90
|
+
title: string;
|
|
91
|
+
noMembers: string;
|
|
92
|
+
};
|
|
93
|
+
global: {
|
|
94
|
+
properties: string;
|
|
95
|
+
business: string;
|
|
96
|
+
businessMembers: string;
|
|
97
|
+
labels: string;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
textBox: {
|
|
101
|
+
placeholder: string;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export { ContactInfoPopup, LanguageProvider, LanguageSelector, TestBox, enTranslations, esTranslations, useLanguage, useTriiTranslation };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trii/components",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.12",
|
|
4
4
|
"description": "Trii components package",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -74,12 +74,14 @@
|
|
|
74
74
|
"@types/jest": "^29.5.5",
|
|
75
75
|
"@types/react": "^18.2.23",
|
|
76
76
|
"babel-jest": "^29.7.0",
|
|
77
|
+
"i18next": "^23.7.16",
|
|
77
78
|
"jest": "^29.7.0",
|
|
78
79
|
"jest-environment-jsdom": "^29.7.0",
|
|
79
80
|
"postcss": "^8.4.31",
|
|
80
81
|
"postcss-import": "^15.1.0",
|
|
81
82
|
"react": "^18.2.0",
|
|
82
83
|
"react-dom": "^18.2.0",
|
|
84
|
+
"react-i18next": "^14.0.5",
|
|
83
85
|
"rollup": "^3.29.4",
|
|
84
86
|
"rollup-plugin-dts": "^6.0.2",
|
|
85
87
|
"rollup-plugin-postcss": "^4.0.2",
|
|
@@ -90,7 +92,9 @@
|
|
|
90
92
|
"peerDependencies": {
|
|
91
93
|
"@emotion/react": "^11.11.4",
|
|
92
94
|
"react": ">=17.0.2 <19.0.0",
|
|
93
|
-
"react-dom": ">=17.0.2 <19.0.0"
|
|
95
|
+
"react-dom": ">=17.0.2 <19.0.0",
|
|
96
|
+
"i18next": ">=21.0.0",
|
|
97
|
+
"react-i18next": ">=13.0.0"
|
|
94
98
|
},
|
|
95
99
|
"dependencies": {
|
|
96
100
|
"@trii/types": "^2.10.398",
|
package/readme
CHANGED
|
@@ -69,3 +69,45 @@ or
|
|
|
69
69
|
```sh
|
|
70
70
|
yarn publish
|
|
71
71
|
```
|
|
72
|
+
|
|
73
|
+
## Translations
|
|
74
|
+
|
|
75
|
+
The components support translations using react-i18next. To use translations in your project:
|
|
76
|
+
|
|
77
|
+
1. Make sure you have react-i18next installed in your project
|
|
78
|
+
2. Import the translation utility:
|
|
79
|
+
```typescript
|
|
80
|
+
import { useTriiTranslation } from '@trii/components';
|
|
81
|
+
```
|
|
82
|
+
3. Use the translation hook in your components:
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
const { t } = useTriiTranslation();
|
|
86
|
+
|
|
87
|
+
// Use translations
|
|
88
|
+
<div>{t('components.contactInfoPopup.businessSection.title')}</div>;
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Default Translations
|
|
92
|
+
|
|
93
|
+
The package includes default English translations. You can extend or override these translations in your project by adding them to your i18next configuration:
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { enTranslations } from '@trii/components/translations/en';
|
|
97
|
+
|
|
98
|
+
i18n.addResourceBundle('en', 'translation', enTranslations, true, true);
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Type Safety
|
|
102
|
+
|
|
103
|
+
The package includes TypeScript types for translations. You can extend the `TriiTranslations` interface to add your own translations:
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
import { TriiTranslations } from '@trii/components/types/translations';
|
|
107
|
+
|
|
108
|
+
declare module '@trii/components/types/translations' {
|
|
109
|
+
interface TriiTranslations {
|
|
110
|
+
// Add your custom translations here
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
```
|