@hortiview/default-components 0.0.12022 → 0.0.12167

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 (2) hide show
  1. package/README.md +74 -31
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Hortiview Default Components
2
2
 
3
- This is a component library that provides default components that posess default translations for the basic languages used in the HortiView Platform.
3
+ This is a component library that provides default components that possess default translations for the basic languages used in the HortiView Platform.
4
4
 
5
5
  Supported languages are currently: English, spanish and turkish.
6
6
 
@@ -10,6 +10,49 @@ Supported languages are currently: English, spanish and turkish.
10
10
 
11
11
  `yarn add @hortiview/default-components`
12
12
 
13
+ ## Important Note
14
+
15
+ To ensure that this library´s components always have access to the current platform language, it is mandatory to pass the language from the base props or from the i18n instance the components are wrapped in.
16
+
17
+ To do so please call the useChangeDefaultComponentsLanguage-hook in a place where you can access the current language. The current language has to be provided to the hook as a parameter.
18
+ The hook only has to be called once inside of a module.
19
+
20
+ When using the current language from the base props this might look like shown in the following example:
21
+
22
+ ```tsx
23
+ import { useChangeDefaultComponentsLanguage } from '@hortiview/default-components';
24
+ import { useBasePropsStore } from './stores/BaseStore';
25
+
26
+ export const ModuleBase = () => {
27
+ const currentLanguage = useBasePropsStore(state => state.currentLanguage);
28
+
29
+ /**
30
+ * needed to handle translations of the default components
31
+ */
32
+ useChangeDefaultComponentsLanguage(currentLanguage);
33
+
34
+ return <AnyComponent />;
35
+ };
36
+ ```
37
+
38
+ When using i18next this might look like shown in the following example:
39
+
40
+ ```tsx
41
+ import { useChangeDefaultComponentsLanguage } from '@hortiview/default-components';
42
+ import { AVAILABLE_LANGUAGE_CODES } from '@hortiview/shared-components';
43
+ import { useTranslation } from 'react-i18next';
44
+
45
+ export const ModuleBase = () => {
46
+ const { i18n } = useTranslation();
47
+ /**
48
+ * needed to handle translations of the default components
49
+ */
50
+ useChangeDefaultComponentsLanguage(i18n.language as AVAILABLE_LANGUAGE_CODES);
51
+
52
+ return <AnyComponent />;
53
+ };
54
+ ```
55
+
13
56
  ## Remarks
14
57
 
15
58
  This library provides form components using [react-hook-form](https://react-hook-form.com/get-started). When you want to use these components please install `react-hook-form` before using them.
@@ -60,15 +103,15 @@ const { handleSubmit } = formMethods;
60
103
 
61
104
  Renders a loading spinner. The loading spinner can be customized in size and color. It can also be centered.
62
105
 
63
- ```TSX
64
- import { DefaultLoadingSpinner } from '@hortiview/default-components';
106
+ ```tsx
107
+ import { DefaultLoadingSpinner } from '@hortiview/default-components';
65
108
 
66
- const [isLoading, setIsLoading] = useState(false)
109
+ const [isLoading, setIsLoading] = useState(false);
67
110
 
68
111
  /** add logic that changes state of isLoading */
69
112
 
70
- if (isLoading) return <DefaultLoadingSpinner />
71
- return <DefaultComponent />
113
+ if (isLoading) return <DefaultLoadingSpinner />;
114
+ return <DefaultComponent />;
72
115
  ```
73
116
 
74
117
  ### HealthCheckComponents
@@ -79,54 +122,54 @@ If a custom text and type should be displayed please use the shared component `<
79
122
 
80
123
  #### DataBaseHealthCheck
81
124
 
82
- ```TSX
83
- import { DataBaseHealthCheck } from '@hortiview/default-components';
125
+ ```tsx
126
+ import { DataBaseHealthCheck } from '@hortiview/default-components';
84
127
 
85
- const [isHealthy, setIsHealthy] = useState(false)
128
+ const [isHealthy, setIsHealthy] = useState(false);
86
129
 
87
130
  /** add logic that changes state of isHealthy */
88
131
 
89
- if (!isHealthy) return <DataBaseHealthCheck />
90
- return <DefaultComponent />
132
+ if (!isHealthy) return <DataBaseHealthCheck />;
133
+ return <DefaultComponent />;
91
134
  ```
92
135
 
93
136
  #### DataBaseHealthCheck
94
137
 
95
- ```TSX
96
- import { DataBaseHealthCheck } from '@hortiview/default-components';
138
+ ```tsx
139
+ import { DataBaseHealthCheck } from '@hortiview/default-components';
97
140
 
98
- const [isHealthy, setIsHealthy] = useState(false)
141
+ const [isHealthy, setIsHealthy] = useState(false);
99
142
 
100
143
  /** add logic that changes state of isHealthy */
101
144
 
102
- if (!isHealthy) return <DataBaseHealthCheck />
103
- return <DefaultComponent />
145
+ if (!isHealthy) return <DataBaseHealthCheck />;
146
+ return <DefaultComponent />;
104
147
  ```
105
148
 
106
149
  #### IotServiceHealthCheck
107
150
 
108
- ```TSX
109
- import { IotServiceHealthCheck } from '@hortiview/default-components';
151
+ ```tsx
152
+ import { IotServiceHealthCheck } from '@hortiview/default-components';
110
153
 
111
- const [isHealthy, setIsHealthy] = useState(false)
154
+ const [isHealthy, setIsHealthy] = useState(false);
112
155
 
113
156
  /** add logic that changes state of isHealthy */
114
157
 
115
- if (!isHealthy) return <IotServiceHealthCheck />
116
- return <DefaultComponent />
158
+ if (!isHealthy) return <IotServiceHealthCheck />;
159
+ return <DefaultComponent />;
117
160
  ```
118
161
 
119
162
  #### PlatformHealthCheck
120
163
 
121
- ```TSX
122
- import { PlatformHealthCheck } from '@hortiview/default-components';
164
+ ```tsx
165
+ import { PlatformHealthCheck } from '@hortiview/default-components';
123
166
 
124
- const [isHealthy, setIsHealthy] = useState(false)
167
+ const [isHealthy, setIsHealthy] = useState(false);
125
168
 
126
169
  /** add logic that changes state of isHealthy */
127
170
 
128
- if (!isHealthy) return <PlatformHealthCheck />
129
- return <DefaultComponent />
171
+ if (!isHealthy) return <PlatformHealthCheck />;
172
+ return <DefaultComponent />;
130
173
  ```
131
174
 
132
175
  ### ImpatienceLoadingSpinner
@@ -134,13 +177,13 @@ return <DefaultComponent />
134
177
  This Loading spinner will automatically change to a specific text, after a certain waiting time, the time is adjustable.
135
178
  The default waiting time are 10 seconds.
136
179
 
137
- ```TSX
138
- import { ImpatienceLoadingSpinner } from '@hortiview/default-components';
180
+ ```tsx
181
+ import { ImpatienceLoadingSpinner } from '@hortiview/default-components';
139
182
 
140
- const [isLoading, setIsLoading] = useState(false)
183
+ const [isLoading, setIsLoading] = useState(false);
141
184
 
142
185
  /** add logic that changes state of isLoading */
143
186
 
144
- if (isLoading) return <ImpatienceLoadingSpinner />
145
- return <DefaultComponent />
187
+ if (isLoading) return <ImpatienceLoadingSpinner />;
188
+ return <DefaultComponent />;
146
189
  ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hortiview/default-components",
3
3
  "description": "This is a component library that should be used in the HortiView platform and its modules. The components provided here have default translation strings.",
4
- "version": "0.0.12022",
4
+ "version": "0.0.12167",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",