@beinformed/ui 1.59.10 → 1.59.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/CHANGELOG.md +14 -0
- package/esm/hooks/useModelCatalog.js +1 -4
- package/esm/hooks/useModelCatalog.js.map +1 -1
- package/esm/modularui/ModularUIRequest.js +14 -1
- package/esm/modularui/ModularUIRequest.js.map +1 -1
- package/esm/redux/_i18n/I18nReducer.js +7 -1
- package/esm/redux/_i18n/I18nReducer.js.map +1 -1
- package/esm/redux/_modularui/ModularUIActions.js +14 -1
- package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
- package/esm/utils/helpers/createHref.js.map +1 -1
- package/lib/hooks/__tests__/useModelCatalog.spec.js.flow +1 -1
- package/lib/hooks/useModelCatalog.js +1 -4
- package/lib/hooks/useModelCatalog.js.flow +1 -4
- package/lib/hooks/useModelCatalog.js.map +1 -1
- package/lib/modularui/ModularUIRequest.js +14 -1
- package/lib/modularui/ModularUIRequest.js.flow +16 -1
- package/lib/modularui/ModularUIRequest.js.map +1 -1
- package/lib/redux/_i18n/I18nReducer.js +7 -1
- package/lib/redux/_i18n/I18nReducer.js.flow +8 -1
- package/lib/redux/_i18n/I18nReducer.js.map +1 -1
- package/lib/redux/_modularui/ModularUIActions.js +14 -1
- package/lib/redux/_modularui/ModularUIActions.js.flow +16 -1
- package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
- package/lib/utils/helpers/createHref.js.flow +1 -1
- package/lib/utils/helpers/createHref.js.map +1 -1
- package/package.json +6 -6
- package/src/hooks/__tests__/useModelCatalog.spec.js +1 -1
- package/src/hooks/useModelCatalog.js +1 -4
- package/src/modularui/ModularUIRequest.js +16 -1
- package/src/redux/_i18n/I18nReducer.js +8 -1
- package/src/redux/_modularui/ModularUIActions.js +16 -1
- package/src/utils/helpers/createHref.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beinformed/ui",
|
|
3
|
-
"version": "1.59.
|
|
3
|
+
"version": "1.59.12",
|
|
4
4
|
"description": "Toolbox for be informed javascript layouts",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"bugs": "http://support.beinformed.com",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"@babel/preset-env": "^7.26.0",
|
|
111
111
|
"@babel/preset-flow": "^7.25.9",
|
|
112
112
|
"@babel/preset-react": "^7.26.3",
|
|
113
|
-
"@commitlint/cli": "^19.6.
|
|
113
|
+
"@commitlint/cli": "^19.6.1",
|
|
114
114
|
"@commitlint/config-conventional": "^19.6.0",
|
|
115
115
|
"@testing-library/react": "^16.1.0",
|
|
116
116
|
"auditjs": "^4.0.46",
|
|
@@ -125,9 +125,9 @@
|
|
|
125
125
|
"eslint-plugin-babel": "^5.3.1",
|
|
126
126
|
"eslint-plugin-ft-flow": "^3.0.11",
|
|
127
127
|
"eslint-plugin-import": "^2.31.0",
|
|
128
|
-
"eslint-plugin-jest": "^28.
|
|
129
|
-
"eslint-plugin-jsdoc": "^50.6.
|
|
130
|
-
"eslint-plugin-react": "^7.37.
|
|
128
|
+
"eslint-plugin-jest": "^28.10.0",
|
|
129
|
+
"eslint-plugin-jsdoc": "^50.6.1",
|
|
130
|
+
"eslint-plugin-react": "^7.37.3",
|
|
131
131
|
"eslint-plugin-react-hooks": "^5.1.0",
|
|
132
132
|
"eslint-plugin-you-dont-need-lodash-underscore": "^6.14.0",
|
|
133
133
|
"flow-bin": "^0.200.1",
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"jest-junit": "^16.0.0",
|
|
142
142
|
"jest-sonar-reporter": "^2.0.0",
|
|
143
143
|
"jscodeshift": "^17.1.1",
|
|
144
|
-
"lint-staged": "^15.
|
|
144
|
+
"lint-staged": "^15.3.0",
|
|
145
145
|
"polished": "^4.0.0",
|
|
146
146
|
"prettier": "^3.4.2",
|
|
147
147
|
"react": "^18.3.1",
|
|
@@ -156,7 +156,7 @@ describe("modelcatalog hooks", () => {
|
|
|
156
156
|
assertTargetModel(
|
|
157
157
|
() => useContentType("/contenttypes/contenttype"),
|
|
158
158
|
"contenttypes",
|
|
159
|
-
"/contenttypes/contenttype
|
|
159
|
+
"/contenttypes/contenttype",
|
|
160
160
|
ContentTypeModel,
|
|
161
161
|
);
|
|
162
162
|
});
|
|
@@ -142,10 +142,7 @@ export const useContentType = (
|
|
|
142
142
|
key?: string = "contenttypes",
|
|
143
143
|
options?: UseModularUIBasicOptions<ContentTypeModel>,
|
|
144
144
|
): ?ContentTypeModel => {
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
const href = createHref("contenttypes", contentType, entryDate, null, []);
|
|
148
|
-
|
|
145
|
+
const href = createHref("contenttypes", contentType, null, null, []);
|
|
149
146
|
return useModularUIBasic(key, href, {
|
|
150
147
|
expectedModels: ["ContentType"],
|
|
151
148
|
targetModel: ContentTypeModel,
|
|
@@ -66,7 +66,7 @@ class ModularUIRequest {
|
|
|
66
66
|
this._response = new ModularUIResponse();
|
|
67
67
|
|
|
68
68
|
this.href = typeof href === "string" ? new Href(href) : href;
|
|
69
|
-
this.locale = options.locale
|
|
69
|
+
this.locale = this.getRequestLocale(options.locale);
|
|
70
70
|
|
|
71
71
|
// copy request parameters to response, to be able to use them in the models
|
|
72
72
|
// self links are missing the request parameters
|
|
@@ -95,6 +95,21 @@ class ModularUIRequest {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Retrieve the preferred language for this request, falls back to the browser language or english
|
|
100
|
+
*/
|
|
101
|
+
getRequestLocale(optionLocale: ?string): string {
|
|
102
|
+
if (optionLocale) {
|
|
103
|
+
return optionLocale;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (navigator.language) {
|
|
107
|
+
return navigator.language.split("-")[0] || "en";
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return "en";
|
|
111
|
+
}
|
|
112
|
+
|
|
98
113
|
/**
|
|
99
114
|
*/
|
|
100
115
|
get origin(): string {
|
|
@@ -46,10 +46,17 @@ const setLocales = (
|
|
|
46
46
|
};
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
+
const getDefaultLocale = () => {
|
|
50
|
+
if (navigator?.language) {
|
|
51
|
+
return navigator?.language.split("-")[0] || "en";
|
|
52
|
+
}
|
|
53
|
+
return "en";
|
|
54
|
+
};
|
|
55
|
+
|
|
49
56
|
// REDUCER
|
|
50
57
|
const initialState: I18nState = {
|
|
51
58
|
locales: new Locales(),
|
|
52
|
-
locale:
|
|
59
|
+
locale: getDefaultLocale(),
|
|
53
60
|
};
|
|
54
61
|
|
|
55
62
|
/**
|
|
@@ -99,6 +99,21 @@ const loadModelSuccessAction = (
|
|
|
99
99
|
return setModel(key, model);
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Retrieve the preferred language for this request, falls back to the browser language or english
|
|
104
|
+
*/
|
|
105
|
+
const getRequestLocale = (optionLocale: ?string): string => {
|
|
106
|
+
if (optionLocale) {
|
|
107
|
+
return optionLocale;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (navigator.language) {
|
|
111
|
+
return navigator.language.split("-")[0] || "en";
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return "en";
|
|
115
|
+
};
|
|
116
|
+
|
|
102
117
|
/**
|
|
103
118
|
* This action is handled by the modularui middleware
|
|
104
119
|
*/
|
|
@@ -121,7 +136,7 @@ export const loadModel = (
|
|
|
121
136
|
}),
|
|
122
137
|
method: options?.method ?? HTTP_METHODS.GET,
|
|
123
138
|
data: options?.data,
|
|
124
|
-
locale: options?.locale
|
|
139
|
+
locale: getRequestLocale(options?.locale),
|
|
125
140
|
childmodels: options?.childmodels,
|
|
126
141
|
targetModel: options?.targetModel,
|
|
127
142
|
forceTargetModel: options?.forceTargetModel,
|