@firedesktop/react-base 1.1.0 → 1.2.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.
- package/.babelrc +1 -2
- package/README.md +114 -114
- package/debug.log +2 -2
- package/dist/ConfigurationLoader.d.ts +7 -0
- package/dist/ConfigurationLoader.js +26 -2
- package/dist/ConfigurationManager.d.ts +4 -0
- package/dist/ConfigurationManager.js +62 -2
- package/dist/LanguageLoader.d.ts +8 -0
- package/dist/LanguageLoader.js +27 -2
- package/dist/LanguageManager.d.ts +5 -0
- package/dist/LanguageManager.js +80 -2
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -2
- package/package.json +60 -59
- package/public/index.html +43 -43
- package/public/manifest.json +25 -25
- package/public/robots.txt +3 -3
- package/src/App.test.tsx +9 -9
- package/src/App.tsx +51 -51
- package/src/TestLabelFunction.tsx +0 -1
- package/src/index.tsx +16 -16
- package/src/reportWebVitals.ts +15 -15
- package/src/setupTests.ts +5 -5
- package/src/types/ConfigurationLoader.d.ts +7 -0
- package/src/types/ConfigurationLoader.js +26 -0
- package/src/types/ConfigurationManager.d.ts +4 -0
- package/src/types/ConfigurationManager.js +62 -0
- package/src/types/LanguageLoader.d.ts +8 -0
- package/src/types/LanguageLoader.js +27 -0
- package/src/types/LanguageManager.d.ts +5 -0
- package/src/types/LanguageManager.js +80 -0
- package/src/types/index.d.ts +5 -0
- package/src/types/index.js +5 -0
- package/tsconfig.json +5 -3
- package/tsconfig.original.json +26 -0
package/.babelrc
CHANGED
package/README.md
CHANGED
|
@@ -1,114 +1,114 @@
|
|
|
1
|
-
This is the FireDesktop base package used to support every React Project in this Company.
|
|
2
|
-
|
|
3
|
-
## Usage of Configuration
|
|
4
|
-
1. Installation
|
|
5
|
-
|
|
6
|
-
- Login in the shell using your npmjs account
|
|
7
|
-
```bash
|
|
8
|
-
npm i @firedesktop/react-base
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
2. Create a file with a name like 'config.json' with the following format and put it in the public/configuration
|
|
12
|
-
sample name it-IT.json
|
|
13
|
-
|
|
14
|
-
```json
|
|
15
|
-
{
|
|
16
|
-
"myPropery": "myvalue",
|
|
17
|
-
"urls" : {
|
|
18
|
-
"first": "http..."
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
3. Import
|
|
24
|
-
```javascript
|
|
25
|
-
import { ConfigurationLoader } from '@firedesktop/react-base';
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
4. Load your configuration just put this component in the page where the Provider component is
|
|
29
|
-
|
|
30
|
-
```javascript
|
|
31
|
-
<Provider store={store}>
|
|
32
|
-
...
|
|
33
|
-
<ConfigurationLoader updateAppState={updateAppState} path={null} />
|
|
34
|
-
</Provider >
|
|
35
|
-
```
|
|
36
|
-
- updateAppState: is a function with two paramenters
|
|
37
|
-
```
|
|
38
|
-
updateAppState = (nameInState: string, configuration: object)
|
|
39
|
-
```
|
|
40
|
-
- nameInState: name of the property in the App state where to save the documentation
|
|
41
|
-
- path: is the path from where to load the configuration file (if null: /configuration/config.json)
|
|
42
|
-
|
|
43
|
-
## Usage of LabelManager
|
|
44
|
-
|
|
45
|
-
1. Installation
|
|
46
|
-
```bash
|
|
47
|
-
npm i @firedesktop/react-base
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
2. Create a file with a name like '[locale].json' with the following format and put it in the public/labels
|
|
51
|
-
sample name it-IT.json
|
|
52
|
-
|
|
53
|
-
```json
|
|
54
|
-
{
|
|
55
|
-
"language": "it-IT",
|
|
56
|
-
"demo": {
|
|
57
|
-
"label_01": "Demo Label 01",
|
|
58
|
-
"label_02": "Demo Label 02"
|
|
59
|
-
},
|
|
60
|
-
"anotherContext": {}
|
|
61
|
-
}
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
3. Import
|
|
65
|
-
```javascript
|
|
66
|
-
import { LanguageLoader } from '@firedesktop/react-base';
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
4. Load your language Labels just put this component in the page where the Provider component is
|
|
70
|
-
```javascript
|
|
71
|
-
<Provider store={store}>
|
|
72
|
-
...
|
|
73
|
-
<LanguageLoader updateAppState={updateAppState} locale='it-IT' path={null} />
|
|
74
|
-
</Provider >
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
4. Show a label in code
|
|
78
|
-
```javascript
|
|
79
|
-
import { useSelector } from "react-redux";
|
|
80
|
-
import LanguageManager from './lib/LanguageManager';
|
|
81
|
-
const { getLabel } = LanguageManager();
|
|
82
|
-
|
|
83
|
-
const { labels }: any = useSelector(state => state);
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<React.Fragment>
|
|
87
|
-
{getLabel(labels, 'demo.label_01', 'Ola')}
|
|
88
|
-
</React.Fragment>
|
|
89
|
-
);
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
## Available Scripts
|
|
93
|
-
|
|
94
|
-
In the project directory, you can run:
|
|
95
|
-
|
|
96
|
-
### `npm start`
|
|
97
|
-
|
|
98
|
-
Runs the Demo app in the development mode.<br />
|
|
99
|
-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
|
100
|
-
|
|
101
|
-
The page will reload if you make edits.<br />
|
|
102
|
-
You will also see any lint errors in the console.
|
|
103
|
-
|
|
104
|
-
### `npm run distribute`
|
|
105
|
-
|
|
106
|
-
Builds (made for windows) the app for production to the `dist` folder.<br />
|
|
107
|
-
It correctly bundles the React component.
|
|
108
|
-
|
|
109
|
-
### `npm publish`
|
|
110
|
-
|
|
111
|
-
Publish the dist on npmjs.
|
|
112
|
-
|
|
113
|
-
## License
|
|
114
|
-
[MIT](https://choosealicense.com/licenses/mit/)
|
|
1
|
+
This is the FireDesktop base package used to support every React Project in this Company.
|
|
2
|
+
|
|
3
|
+
## Usage of Configuration
|
|
4
|
+
1. Installation
|
|
5
|
+
|
|
6
|
+
- Login in the shell using your npmjs account
|
|
7
|
+
```bash
|
|
8
|
+
npm i @firedesktop/react-base
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
2. Create a file with a name like 'config.json' with the following format and put it in the public/configuration
|
|
12
|
+
sample name it-IT.json
|
|
13
|
+
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"myPropery": "myvalue",
|
|
17
|
+
"urls" : {
|
|
18
|
+
"first": "http..."
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
3. Import
|
|
24
|
+
```javascript
|
|
25
|
+
import { ConfigurationLoader } from '@firedesktop/react-base';
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
4. Load your configuration just put this component in the page where the Provider component is
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
<Provider store={store}>
|
|
32
|
+
...
|
|
33
|
+
<ConfigurationLoader updateAppState={updateAppState} path={null} />
|
|
34
|
+
</Provider >
|
|
35
|
+
```
|
|
36
|
+
- updateAppState: is a function with two paramenters
|
|
37
|
+
```
|
|
38
|
+
updateAppState = (nameInState: string, configuration: object)
|
|
39
|
+
```
|
|
40
|
+
- nameInState: name of the property in the App state where to save the documentation
|
|
41
|
+
- path: is the path from where to load the configuration file (if null: /configuration/config.json)
|
|
42
|
+
|
|
43
|
+
## Usage of LabelManager
|
|
44
|
+
|
|
45
|
+
1. Installation
|
|
46
|
+
```bash
|
|
47
|
+
npm i @firedesktop/react-base
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
2. Create a file with a name like '[locale].json' with the following format and put it in the public/labels
|
|
51
|
+
sample name it-IT.json
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"language": "it-IT",
|
|
56
|
+
"demo": {
|
|
57
|
+
"label_01": "Demo Label 01",
|
|
58
|
+
"label_02": "Demo Label 02"
|
|
59
|
+
},
|
|
60
|
+
"anotherContext": {}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
3. Import
|
|
65
|
+
```javascript
|
|
66
|
+
import { LanguageLoader } from '@firedesktop/react-base';
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
4. Load your language Labels just put this component in the page where the Provider component is
|
|
70
|
+
```javascript
|
|
71
|
+
<Provider store={store}>
|
|
72
|
+
...
|
|
73
|
+
<LanguageLoader updateAppState={updateAppState} locale='it-IT' path={null} />
|
|
74
|
+
</Provider >
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
4. Show a label in code
|
|
78
|
+
```javascript
|
|
79
|
+
import { useSelector } from "react-redux";
|
|
80
|
+
import LanguageManager from './lib/LanguageManager';
|
|
81
|
+
const { getLabel } = LanguageManager();
|
|
82
|
+
|
|
83
|
+
const { labels }: any = useSelector(state => state);
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<React.Fragment>
|
|
87
|
+
{getLabel(labels, 'demo.label_01', 'Ola')}
|
|
88
|
+
</React.Fragment>
|
|
89
|
+
);
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Available Scripts
|
|
93
|
+
|
|
94
|
+
In the project directory, you can run:
|
|
95
|
+
|
|
96
|
+
### `npm start`
|
|
97
|
+
|
|
98
|
+
Runs the Demo app in the development mode.<br />
|
|
99
|
+
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
|
100
|
+
|
|
101
|
+
The page will reload if you make edits.<br />
|
|
102
|
+
You will also see any lint errors in the console.
|
|
103
|
+
|
|
104
|
+
### `npm run distribute`
|
|
105
|
+
|
|
106
|
+
Builds (made for windows) the app for production to the `dist` folder.<br />
|
|
107
|
+
It correctly bundles the React component.
|
|
108
|
+
|
|
109
|
+
### `npm publish`
|
|
110
|
+
|
|
111
|
+
Publish the dist on npmjs.
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
[MIT](https://choosealicense.com/licenses/mit/)
|
package/debug.log
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
[1024/175356.424:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
|
|
2
|
-
[1025/090606.275:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
|
|
1
|
+
[1024/175356.424:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
|
|
2
|
+
[1025/090606.275:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare type configurationLoaderParamsType = {
|
|
3
|
+
updateAppState: any;
|
|
4
|
+
path: string | null;
|
|
5
|
+
};
|
|
6
|
+
declare function ConfigurationLoader({ updateAppState, path }: configurationLoaderParamsType): JSX.Element;
|
|
7
|
+
export default ConfigurationLoader;
|
|
@@ -1,2 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
|
+
import { useDispatch, useSelector } from "react-redux";
|
|
3
|
+
import ConfigurationManager from './ConfigurationManager';
|
|
4
|
+
function ConfigurationLoader(_a) {
|
|
5
|
+
var updateAppState = _a.updateAppState, path = _a.path;
|
|
6
|
+
var dispatch = useDispatch();
|
|
7
|
+
var configuration = useSelector(function (state) { return state; }).configuration;
|
|
8
|
+
var loadConfiguration = ConfigurationManager().loadConfiguration;
|
|
9
|
+
var fullPath = './configuration/config.json';
|
|
10
|
+
if (path)
|
|
11
|
+
fullPath = path;
|
|
12
|
+
useEffect(function () {
|
|
13
|
+
if (!configuration) {
|
|
14
|
+
console.log("Loading Configuration for this Site in this path: " + fullPath);
|
|
15
|
+
loadConfiguration(fullPath).then(function (response) {
|
|
16
|
+
console.log("Loaded Configuration for this Site in this path: " + fullPath, response);
|
|
17
|
+
dispatch(updateAppState("configuration", response));
|
|
18
|
+
})
|
|
19
|
+
.catch(function (err) {
|
|
20
|
+
console.log("Problem loading the Site Configuration in this path: " + fullPath);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}, [configuration, dispatch, loadConfiguration, fullPath, updateAppState]);
|
|
24
|
+
return (React.createElement(React.Fragment, null));
|
|
25
|
+
}
|
|
26
|
+
export default ConfigurationLoader;
|
|
@@ -1,2 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
function ConfigurationManager(formData) {
|
|
38
|
+
function loadConfiguration(fullPath) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
40
|
+
var res, err_1;
|
|
41
|
+
return __generator(this, function (_a) {
|
|
42
|
+
switch (_a.label) {
|
|
43
|
+
case 0:
|
|
44
|
+
_a.trys.push([0, 3, , 4]);
|
|
45
|
+
return [4 /*yield*/, fetch(fullPath, { headers: { "Content-Type": "application/json; charset=utf-8" } })];
|
|
46
|
+
case 1:
|
|
47
|
+
res = _a.sent();
|
|
48
|
+
return [4 /*yield*/, res.json()];
|
|
49
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
50
|
+
case 3:
|
|
51
|
+
err_1 = _a.sent();
|
|
52
|
+
console.log("Problem loading the Site Labels");
|
|
53
|
+
return [3 /*break*/, 4];
|
|
54
|
+
case 4: return [2 /*return*/];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
;
|
|
60
|
+
return { loadConfiguration: loadConfiguration };
|
|
61
|
+
}
|
|
62
|
+
export default ConfigurationManager;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare type languageLoaderParamsType = {
|
|
3
|
+
updateAppState: any;
|
|
4
|
+
locale: string;
|
|
5
|
+
path: string | null;
|
|
6
|
+
};
|
|
7
|
+
declare function LanguageLoader({ updateAppState, locale, path }: languageLoaderParamsType): JSX.Element;
|
|
8
|
+
export default LanguageLoader;
|
package/dist/LanguageLoader.js
CHANGED
|
@@ -1,2 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
|
+
import { useDispatch, useSelector } from "react-redux";
|
|
3
|
+
import LanguageManager from './LanguageManager';
|
|
4
|
+
function LanguageLoader(_a) {
|
|
5
|
+
var updateAppState = _a.updateAppState, locale = _a.locale, path = _a.path;
|
|
6
|
+
var dispatch = useDispatch();
|
|
7
|
+
var labels = useSelector(function (state) { return state; }).labels;
|
|
8
|
+
var loadLabels = LanguageManager().loadLabels;
|
|
9
|
+
var fileName = locale + ".json";
|
|
10
|
+
var fullPath = "./labels/" + fileName;
|
|
11
|
+
if (path)
|
|
12
|
+
fullPath = "./" + path + "/" + fileName;
|
|
13
|
+
useEffect(function () {
|
|
14
|
+
if (!labels) {
|
|
15
|
+
console.log("Loading Language Labels for this Site in this path: " + fullPath);
|
|
16
|
+
loadLabels(fullPath).then(function (response) {
|
|
17
|
+
console.log("Loaded Language Labels for this Site in this path: " + fullPath, response);
|
|
18
|
+
dispatch(updateAppState("labels", response));
|
|
19
|
+
})
|
|
20
|
+
.catch(function (err) {
|
|
21
|
+
console.log("Problem loading the Site Language Labels in this path: " + fullPath);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}, [labels, dispatch, loadLabels, fullPath, updateAppState]);
|
|
25
|
+
return (React.createElement(React.Fragment, null));
|
|
26
|
+
}
|
|
27
|
+
export default LanguageLoader;
|
package/dist/LanguageManager.js
CHANGED
|
@@ -1,2 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
function LanguageManager(formData) {
|
|
38
|
+
function loadLabels(fullPath) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
40
|
+
var res, err_1;
|
|
41
|
+
return __generator(this, function (_a) {
|
|
42
|
+
switch (_a.label) {
|
|
43
|
+
case 0:
|
|
44
|
+
_a.trys.push([0, 3, , 4]);
|
|
45
|
+
return [4 /*yield*/, fetch(fullPath, { headers: { "Content-Type": "application/json; charset=utf-8" } })];
|
|
46
|
+
case 1:
|
|
47
|
+
res = _a.sent();
|
|
48
|
+
return [4 /*yield*/, res.json()];
|
|
49
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
50
|
+
case 3:
|
|
51
|
+
err_1 = _a.sent();
|
|
52
|
+
console.log("Problem loading the Site Labels");
|
|
53
|
+
return [3 /*break*/, 4];
|
|
54
|
+
case 4: return [2 /*return*/];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
;
|
|
60
|
+
function getLabel(labels, id, defaultValue) {
|
|
61
|
+
if (labels === null || labels === undefined)
|
|
62
|
+
return defaultValue || '';
|
|
63
|
+
try {
|
|
64
|
+
var splits = id.split('.');
|
|
65
|
+
var message = labels;
|
|
66
|
+
for (var index = 0; index < splits.length; index++) {
|
|
67
|
+
var element = splits[index];
|
|
68
|
+
message = message[element];
|
|
69
|
+
}
|
|
70
|
+
if (message !== null && message !== undefined)
|
|
71
|
+
return message;
|
|
72
|
+
return defaultValue ? defaultValue : id;
|
|
73
|
+
}
|
|
74
|
+
catch (ex) {
|
|
75
|
+
return defaultValue ? defaultValue : id;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return { getLabel: getLabel, loadLabels: loadLabels };
|
|
79
|
+
}
|
|
80
|
+
export default LanguageManager;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import ConfigurationLoader from './ConfigurationLoader';
|
|
2
|
+
import ConfigurationManager from './ConfigurationManager';
|
|
3
|
+
import LanguageLoader from './LanguageLoader';
|
|
4
|
+
import LanguageManager from './LanguageManager';
|
|
5
|
+
export { ConfigurationLoader, ConfigurationManager, LanguageLoader, LanguageManager };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import ConfigurationLoader from './ConfigurationLoader';
|
|
2
|
+
import ConfigurationManager from './ConfigurationManager';
|
|
3
|
+
import LanguageLoader from './LanguageLoader';
|
|
4
|
+
import LanguageManager from './LanguageManager';
|
|
5
|
+
export { ConfigurationLoader, ConfigurationManager, LanguageLoader, LanguageManager };
|