@monkvision/common 4.0.10 → 4.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.
@@ -24,6 +24,36 @@ specify to it which language you want it to use. The following languages are sup
24
24
  - Dutch
25
25
 
26
26
  # i18n Utilities
27
+ ## i18nWrap wrapper
28
+ ### Description
29
+ This wrapped is used by internal monk SDK to wrap the component with I18nextProvider.
30
+
31
+ ### Example of usage
32
+
33
+ ```ts
34
+ import i18n from '@monkvision/common';
35
+ import { i18nMyComponent } from './i18n';
36
+
37
+ const MyComponent = i18nWrap(function MyComponent(){
38
+ return <></>
39
+ }, i18nMyComponent)
40
+ /// in i18n.ts
41
+ import { i18nCreateSDKInstance } from '@monkvision/common';
42
+ import en from './translations/en.json';
43
+ import fr from './translations/fr.json';
44
+ import de from './translations/de.json';
45
+ import nl from './translations/nl.json';
46
+
47
+ const i18nMyComponent = i18nCreateSDKInstance({
48
+ resources: {
49
+ en: { translation: en },
50
+ fr: { translation: fr },
51
+ de: { translation: de },
52
+ nl: { translation: nl },
53
+ }
54
+ })
55
+ ```
56
+
27
57
  ## useI18nSync hook
28
58
  ### Description
29
59
  This hook is used mostly by MonkJs packages internally to synchronize their own i18n instance with the language param
@@ -31,7 +61,7 @@ or prop that they are provided.
31
61
 
32
62
  ### Example of usage
33
63
 
34
- ```typescript
64
+ ```ts
35
65
  import i18n from 'i18next';
36
66
  import { useI18nSync } from '@monkvision/common';
37
67
 
@@ -25,10 +25,10 @@ export interface I18NSDKOptions {
25
25
  */
26
26
  export declare function i18nCreateSDKInstance({ resources }: I18NSDKOptions): i18n;
27
27
  /**
28
- * This function is used internally by the Monk SDK to wrap its exported components in an I18nextProvder. The ref passed
29
- * to the resulting component is forwarded to the wrapped component.
28
+ * This function is used internally by the Monk SDK to wrap its exported components in an I18nextProvider. The ref
29
+ * passed to the resulting component is forwarded to the wrapped component.
30
30
  *
31
- * @param Component The component to wrap in the provider.
31
+ * @param Component The component to wrap in the provider. It should be an functional component
32
32
  * @param instance The i18n instance created using the `i18nCreateSDKInstance` function.
33
33
  * @typeParam T - The type of the ref of the wrapped component.
34
34
  * @typeParam P - The type of the props of the wrapped component.
package/lib/i18n/utils.js CHANGED
@@ -58,17 +58,19 @@ function i18nCreateSDKInstance(_a) {
58
58
  }
59
59
  exports.i18nCreateSDKInstance = i18nCreateSDKInstance;
60
60
  /**
61
- * This function is used internally by the Monk SDK to wrap its exported components in an I18nextProvder. The ref passed
62
- * to the resulting component is forwarded to the wrapped component.
61
+ * This function is used internally by the Monk SDK to wrap its exported components in an I18nextProvider. The ref
62
+ * passed to the resulting component is forwarded to the wrapped component.
63
63
  *
64
- * @param Component The component to wrap in the provider.
64
+ * @param Component The component to wrap in the provider. It should be an functional component
65
65
  * @param instance The i18n instance created using the `i18nCreateSDKInstance` function.
66
66
  * @typeParam T - The type of the ref of the wrapped component.
67
67
  * @typeParam P - The type of the props of the wrapped component.
68
68
  * @return The Component passed in the arguments. wrapped in an I18nextProvider.
69
69
  */
70
70
  function i18nWrap(Component, instance) {
71
- return (0, react_1.forwardRef)(function (props, ref) { return ((0, jsx_runtime_1.jsx)(react_i18next_1.I18nextProvider, __assign({ i18n: instance }, { children: (0, jsx_runtime_1.jsx)(Component, __assign({ ref: ref }, props)) }))); });
71
+ return (0, react_1.forwardRef)(function I18nWrappedComponent(props, ref) {
72
+ return ((0, jsx_runtime_1.jsx)(react_i18next_1.I18nextProvider, __assign({ i18n: instance }, { children: (0, jsx_runtime_1.jsx)(Component, __assign({ ref: ref }, props)) })));
73
+ });
72
74
  }
73
75
  exports.i18nWrap = i18nWrap;
74
76
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monkvision/common",
3
- "version": "4.0.10",
3
+ "version": "4.0.12",
4
4
  "license": "BSD-3-Clause-Clear",
5
5
  "packageManager": "yarn@3.2.4",
6
6
  "description": "MonkJs common logic package",
@@ -28,10 +28,10 @@
28
28
  "lint:fix": "yarn run prettier:fix && yarn run eslint:fix"
29
29
  },
30
30
  "dependencies": {
31
- "@monkvision/analytics": "4.0.10",
32
- "@monkvision/monitoring": "4.0.10",
33
- "@monkvision/sights": "4.0.10",
34
- "@monkvision/types": "4.0.10",
31
+ "@monkvision/analytics": "4.0.12",
32
+ "@monkvision/monitoring": "4.0.12",
33
+ "@monkvision/sights": "4.0.12",
34
+ "@monkvision/types": "4.0.12",
35
35
  "i18next": "^23.4.5",
36
36
  "jsonwebtoken": "^9.0.2",
37
37
  "jwt-decode": "^4.0.0",
@@ -47,13 +47,13 @@
47
47
  "react-router-dom": "^6.22.3"
48
48
  },
49
49
  "devDependencies": {
50
- "@monkvision/eslint-config-base": "4.0.10",
51
- "@monkvision/eslint-config-typescript": "4.0.10",
52
- "@monkvision/eslint-config-typescript-react": "4.0.10",
53
- "@monkvision/jest-config": "4.0.10",
54
- "@monkvision/prettier-config": "4.0.10",
55
- "@monkvision/test-utils": "4.0.10",
56
- "@monkvision/typescript-config": "4.0.10",
50
+ "@monkvision/eslint-config-base": "4.0.12",
51
+ "@monkvision/eslint-config-typescript": "4.0.12",
52
+ "@monkvision/eslint-config-typescript-react": "4.0.12",
53
+ "@monkvision/jest-config": "4.0.12",
54
+ "@monkvision/prettier-config": "4.0.12",
55
+ "@monkvision/test-utils": "4.0.12",
56
+ "@monkvision/typescript-config": "4.0.12",
57
57
  "@testing-library/react": "^12.1.5",
58
58
  "@testing-library/react-hooks": "^8.0.1",
59
59
  "@types/jest": "^29.2.2",
@@ -96,5 +96,5 @@
96
96
  "url": "https://github.com/monkvision/monkjs/issues"
97
97
  },
98
98
  "homepage": "https://github.com/monkvision/monkjs",
99
- "gitHead": "e3e512ea9f21560bd9625c32749d5a56898bed72"
99
+ "gitHead": "ea97b32b05c280175bbeda6b6af10f1cf1a192bf"
100
100
  }