@hortiview/default-components 1.0.0 → 1.0.1

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 (47) hide show
  1. package/README.md +189 -50
  2. package/dist/HealthCheckFailed-j1XFU5px.js +1839 -0
  3. package/dist/InternationalizationWrapper-BtWuzVFG.js +41 -0
  4. package/dist/LoadingSpinner-BxqY1o89.js +514 -0
  5. package/dist/assets/DefaultFormNumber.css +1 -0
  6. package/dist/assets/HealthCheckFailed.css +1 -0
  7. package/dist/assets/LoadingSpinner.css +1 -0
  8. package/dist/assets/i18n.css +1 -0
  9. package/dist/assets/index.css +1 -0
  10. package/dist/component-DsB0poTj-B4NF-JCy.js +530 -0
  11. package/dist/components/DefaultFormNumber/DefaultFormNumber.d.ts +5 -0
  12. package/dist/components/DefaultFormNumber/DefaultFormNumber.js +3600 -0
  13. package/dist/components/DefaultLoadingSpinner/DefaultLoadingSpinner.d.ts +4 -0
  14. package/dist/components/DefaultLoadingSpinner/DefaultLoadingSpinner.js +12 -0
  15. package/dist/components/HealthChecks/DataBaseHealthCheck.d.ts +4 -0
  16. package/dist/components/HealthChecks/DataBaseHealthCheck.js +20 -0
  17. package/dist/components/HealthChecks/DefaultHealthCheck.d.ts +4 -0
  18. package/dist/components/HealthChecks/DefaultHealthCheck.js +20 -0
  19. package/dist/components/HealthChecks/HealthCheck.test.js +23910 -0
  20. package/dist/components/HealthChecks/IotServiceHealthCheck.d.ts +4 -0
  21. package/dist/components/HealthChecks/IotServiceHealthCheck.js +20 -0
  22. package/dist/components/HealthChecks/PlatformHealthCheck.d.ts +4 -0
  23. package/dist/components/HealthChecks/PlatformHealthCheck.js +20 -0
  24. package/dist/components/ImpatienceLoadingSpinner/ImpatienceLoadingSpinner.d.ts +4 -0
  25. package/dist/components/ImpatienceLoadingSpinner/ImpatienceLoadingSpinner.js +19 -0
  26. package/dist/components/InternationalizationWrapper/InternationalizationWrapper.d.ts +14 -0
  27. package/dist/components/InternationalizationWrapper/InternationalizationWrapper.js +8 -0
  28. package/dist/i18n-DIprVS_u.js +1749 -0
  29. package/dist/i18n.d.ts +2 -0
  30. package/dist/i18n.js +7 -0
  31. package/dist/index.es-D-CKRzIB-Cv9zF1oG.js +1029 -0
  32. package/dist/locales/en-US.js +11 -0
  33. package/dist/locales/en-US.json.d.ts +22 -0
  34. package/dist/locales/es-MX.js +12 -0
  35. package/dist/locales/es-MX.json.d.ts +24 -0
  36. package/dist/locales/tr-TR.js +12 -0
  37. package/dist/locales/tr-TR.json.d.ts +24 -0
  38. package/dist/magic-string.es-D4UQQyt0.js +859 -0
  39. package/dist/main.d.ts +14 -0
  40. package/dist/main.js +16 -4
  41. package/dist/useTranslation-Bh0VR1ML.js +4070 -0
  42. package/package.json +144 -67
  43. package/dist/assets/App.css +0 -1
  44. package/dist/assets/Button.css +0 -1
  45. package/dist/components/App/App.test.js +0 -32948
  46. package/dist/components/Button/Button.js +0 -11
  47. package/dist/components/Label/Label.js +0 -7
package/README.md CHANGED
@@ -1,50 +1,189 @@
1
- # React + TypeScript + Vite
2
-
3
- This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
-
5
- Currently, two official plugins are available:
6
-
7
- - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8
- - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9
-
10
- ## Expanding the ESLint configuration
11
-
12
- If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
13
-
14
- - Configure the top-level `parserOptions` property like this:
15
-
16
- ```js
17
- export default tseslint.config({
18
- languageOptions: {
19
- // other options...
20
- parserOptions: {
21
- project: ['./tsconfig.node.json', './tsconfig.app.json'],
22
- tsconfigRootDir: import.meta.dirname,
23
- },
24
- },
25
- })
26
- ```
27
-
28
- - Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
29
- - Optionally add `...tseslint.configs.stylisticTypeChecked`
30
- - Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:
31
-
32
- ```js
33
- // eslint.config.js
34
- import react from 'eslint-plugin-react'
35
-
36
- export default tseslint.config({
37
- // Set the react version
38
- settings: { react: { version: '18.3' } },
39
- plugins: {
40
- // Add the react plugin
41
- react,
42
- },
43
- rules: {
44
- // other rules...
45
- // Enable its recommended rules
46
- ...react.configs.recommended.rules,
47
- ...react.configs['jsx-runtime'].rules,
48
- },
49
- })
50
- ```
1
+ # Hortiview Default Components
2
+
3
+ This is a component library that provides default components that possess default translations for the basic languages used in the HortiView Platform.
4
+
5
+ Supported languages are currently: English, spanish and turkish.
6
+
7
+ ## Install
8
+
9
+ `npm i @hortiview/default-components`
10
+
11
+ `yarn add @hortiview/default-components`
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
+
56
+ ## Remarks
57
+
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.
59
+
60
+ ## Available Components
61
+
62
+ 1. [DefaultFormNumber](#defaultformnumber)
63
+ 1. [DefaultLoadingSpinner](#defaultloadingspinner)
64
+ 1. [HealthCheckComponents](#healthcheckcomponents)
65
+ 1. [DataBaseHealthCheck](#databasehealthcheck)
66
+ 1. [DefaultHealthCheck](#defaulthealthcheck)
67
+ 1. [IotServiceHealthCheck](#iotservicehealthcheck)
68
+ 1. [PlatformHealthCheck](#platformhealthcheck)
69
+ 1. [ImpatienceLoadingSpinner](#impatienceloadingspinner)
70
+
71
+ ## Available Components
72
+
73
+ ### DefaultFormNumber
74
+
75
+ Number input field that formats the users input depending on the input language. The component automatically sets the language specific thousand separators and only allows the language specific decimal separator.
76
+
77
+ ```tsx
78
+ import { DefaultFormNumber } from '@hortiview/default-components';
79
+ import { FormProvider, SubmitHandler, useForm } from 'react-hook-form';
80
+
81
+ const formMethods = useForm<{ birthday: string }>({
82
+ mode: 'onSubmit',
83
+ });
84
+
85
+ const { handleSubmit } = formMethods;
86
+
87
+ <FormProvider {...formMethods}>
88
+ <form onSubmit={handleSubmit(onSubmit)}>
89
+ <DefaultFormNumber<{ price: number }>
90
+ propertyName='price'
91
+ label='module.price'
92
+ decimalScale={5}
93
+ fixedDecimalScale={true}
94
+ allowNegative={false}
95
+ allowLeadingZeros={false}
96
+ prefix=' €'
97
+ />
98
+ </form>
99
+ </FormProvider>;
100
+ ```
101
+
102
+ ### DefaultLoadingSpinner
103
+
104
+ Renders a loading spinner. The loading spinner can be customized in size and color. It can also be centered.
105
+
106
+ ```tsx
107
+ import { DefaultLoadingSpinner } from '@hortiview/default-components';
108
+
109
+ const [isLoading, setIsLoading] = useState(false);
110
+
111
+ /** add logic that changes state of isLoading */
112
+
113
+ if (isLoading) return <DefaultLoadingSpinner />;
114
+ return <DefaultComponent />;
115
+ ```
116
+
117
+ ### HealthCheckComponents
118
+
119
+ A screen that shows a health check failed message. It can be used if the check for database health, iot health or HV platform health fails. Please use the default components provided here to ensure a consistent user experience for the HV platform.
120
+
121
+ If a custom text and type should be displayed please use the shared component `<HealthCheckFailed />` and provide a custom `title` and `subtitle`.
122
+
123
+ #### DataBaseHealthCheck
124
+
125
+ ```tsx
126
+ import { DataBaseHealthCheck } from '@hortiview/default-components';
127
+
128
+ const [isHealthy, setIsHealthy] = useState(false);
129
+
130
+ /** add logic that changes state of isHealthy */
131
+
132
+ if (!isHealthy) return <DataBaseHealthCheck />;
133
+ return <DefaultComponent />;
134
+ ```
135
+
136
+ #### DataBaseHealthCheck
137
+
138
+ ```tsx
139
+ import { DataBaseHealthCheck } from '@hortiview/default-components';
140
+
141
+ const [isHealthy, setIsHealthy] = useState(false);
142
+
143
+ /** add logic that changes state of isHealthy */
144
+
145
+ if (!isHealthy) return <DataBaseHealthCheck />;
146
+ return <DefaultComponent />;
147
+ ```
148
+
149
+ #### IotServiceHealthCheck
150
+
151
+ ```tsx
152
+ import { IotServiceHealthCheck } from '@hortiview/default-components';
153
+
154
+ const [isHealthy, setIsHealthy] = useState(false);
155
+
156
+ /** add logic that changes state of isHealthy */
157
+
158
+ if (!isHealthy) return <IotServiceHealthCheck />;
159
+ return <DefaultComponent />;
160
+ ```
161
+
162
+ #### PlatformHealthCheck
163
+
164
+ ```tsx
165
+ import { PlatformHealthCheck } from '@hortiview/default-components';
166
+
167
+ const [isHealthy, setIsHealthy] = useState(false);
168
+
169
+ /** add logic that changes state of isHealthy */
170
+
171
+ if (!isHealthy) return <PlatformHealthCheck />;
172
+ return <DefaultComponent />;
173
+ ```
174
+
175
+ ### ImpatienceLoadingSpinner
176
+
177
+ This Loading spinner will automatically change to a specific text, after a certain waiting time, the time is adjustable.
178
+ The default waiting time are 10 seconds.
179
+
180
+ ```tsx
181
+ import { ImpatienceLoadingSpinner } from '@hortiview/default-components';
182
+
183
+ const [isLoading, setIsLoading] = useState(false);
184
+
185
+ /** add logic that changes state of isLoading */
186
+
187
+ if (isLoading) return <ImpatienceLoadingSpinner />;
188
+ return <DefaultComponent />;
189
+ ```