@beinformed/ui 1.60.4 → 1.60.5
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 +8 -0
- package/esm/hooks/__tests__/useForm.spec.js.flow +1 -1
- package/esm/hooks/useForm.js +20 -15
- package/esm/hooks/useForm.js.flow +14 -5
- package/esm/hooks/useForm.js.map +1 -1
- package/esm/hooks/useModularUI.d.ts +1 -0
- package/esm/hooks/useModularUI.js +11 -3
- package/esm/hooks/useModularUI.js.flow +23 -4
- package/esm/hooks/useModularUI.js.map +1 -1
- package/esm/models/application/ApplicationModel.js +3 -1
- package/esm/models/application/ApplicationModel.js.map +1 -1
- package/esm/models/attributes/CompositeAttributeModel.js +6 -5
- package/esm/models/attributes/CompositeAttributeModel.js.map +1 -1
- package/esm/models/content/ContentTOCModel.js +2 -1
- package/esm/models/content/ContentTOCModel.js.map +1 -1
- package/esm/models/href/Href.js +12 -11
- package/esm/models/href/Href.js.map +1 -1
- package/esm/models/list/ListModel.js +2 -1
- package/esm/models/list/ListModel.js.map +1 -1
- package/esm/modularui/ModularUIRequest.js +6 -3
- package/esm/modularui/ModularUIRequest.js.map +1 -1
- package/esm/redux/_modularui/ModularUIUtils.js +3 -1
- package/esm/redux/_modularui/ModularUIUtils.js.map +1 -1
- package/lib/hooks/useForm.js +19 -14
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/hooks/useModularUI.d.ts +1 -0
- package/lib/hooks/useModularUI.js +13 -4
- package/lib/hooks/useModularUI.js.map +1 -1
- package/lib/models/application/ApplicationModel.js +3 -1
- package/lib/models/application/ApplicationModel.js.map +1 -1
- package/lib/models/attributes/CompositeAttributeModel.js +6 -5
- package/lib/models/attributes/CompositeAttributeModel.js.map +1 -1
- package/lib/models/content/ContentTOCModel.js +2 -1
- package/lib/models/content/ContentTOCModel.js.map +1 -1
- package/lib/models/href/Href.js +12 -11
- package/lib/models/href/Href.js.map +1 -1
- package/lib/models/list/ListModel.js +2 -1
- package/lib/models/list/ListModel.js.map +1 -1
- package/lib/modularui/ModularUIRequest.js +6 -3
- package/lib/modularui/ModularUIRequest.js.map +1 -1
- package/lib/redux/_modularui/ModularUIUtils.js +3 -1
- package/lib/redux/_modularui/ModularUIUtils.js.map +1 -1
- package/package.json +22 -22
- package/src/hooks/__tests__/useForm.spec.js +1 -1
- package/src/hooks/useForm.js +14 -5
- package/src/hooks/useModularUI.js +23 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beinformed/ui",
|
|
3
|
-
"version": "1.60.
|
|
3
|
+
"version": "1.60.5",
|
|
4
4
|
"description": "Toolbox for be informed javascript layouts",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"bugs": "https://support.beinformed.com",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"styled-components": "^5.0.0"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@babel/runtime-corejs3": "^7.
|
|
71
|
+
"@babel/runtime-corejs3": "^7.27.0",
|
|
72
72
|
"@date-fns/tz": "^1.2.0",
|
|
73
73
|
"big.js": "^6.2.2",
|
|
74
74
|
"date-fns": "^4.1.0",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"dequal": "^2.0.3",
|
|
77
77
|
"file-size": "^1.0.0",
|
|
78
78
|
"format-message": "^6.2.4",
|
|
79
|
-
"html-entities": "^2.
|
|
79
|
+
"html-entities": "^2.6.0",
|
|
80
80
|
"iban": "^0.0.14",
|
|
81
81
|
"js-cookie": "^3.0.5",
|
|
82
82
|
"klona": "^2.0.6",
|
|
@@ -86,62 +86,62 @@
|
|
|
86
86
|
"timezone-soft": "^1.5.2"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
-
"@babel/cli": "^7.
|
|
90
|
-
"@babel/core": "^7.26.
|
|
91
|
-
"@babel/eslint-parser": "^7.
|
|
92
|
-
"@babel/eslint-plugin": "^7.
|
|
89
|
+
"@babel/cli": "^7.27.0",
|
|
90
|
+
"@babel/core": "^7.26.10",
|
|
91
|
+
"@babel/eslint-parser": "^7.27.0",
|
|
92
|
+
"@babel/eslint-plugin": "^7.27.0",
|
|
93
93
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
94
94
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
95
|
-
"@babel/plugin-transform-runtime": "^7.26.
|
|
95
|
+
"@babel/plugin-transform-runtime": "^7.26.10",
|
|
96
96
|
"@babel/preset-env": "^7.26.9",
|
|
97
97
|
"@babel/preset-flow": "^7.25.9",
|
|
98
98
|
"@babel/preset-react": "^7.26.3",
|
|
99
|
-
"@commitlint/cli": "^19.
|
|
100
|
-
"@commitlint/config-conventional": "^19.
|
|
99
|
+
"@commitlint/cli": "^19.8.0",
|
|
100
|
+
"@commitlint/config-conventional": "^19.8.0",
|
|
101
101
|
"@testing-library/dom": "^10.4.0",
|
|
102
|
-
"@testing-library/react": "^16.
|
|
102
|
+
"@testing-library/react": "^16.3.0",
|
|
103
103
|
"auditjs": "^4.0.46",
|
|
104
104
|
"babel-jest": "^29.7.0",
|
|
105
105
|
"babel-plugin-styled-components": "^2.1.4",
|
|
106
106
|
"cherry-pick": "^0.5.0",
|
|
107
|
-
"commit-and-tag-version": "^12.5.
|
|
107
|
+
"commit-and-tag-version": "^12.5.1",
|
|
108
108
|
"cross-env": "^7.0.3",
|
|
109
109
|
"documentation": "^14.0.2",
|
|
110
110
|
"eslint": "^8.57.0",
|
|
111
|
-
"eslint-config-prettier": "^10.
|
|
111
|
+
"eslint-config-prettier": "^10.1.2",
|
|
112
112
|
"eslint-plugin-babel": "^5.3.1",
|
|
113
113
|
"eslint-plugin-ft-flow": "^3.0.11",
|
|
114
114
|
"eslint-plugin-jest": "^28.11.0",
|
|
115
|
-
"eslint-plugin-jsdoc": "^50.6.
|
|
116
|
-
"eslint-plugin-react": "^7.37.
|
|
115
|
+
"eslint-plugin-jsdoc": "^50.6.9",
|
|
116
|
+
"eslint-plugin-react": "^7.37.5",
|
|
117
117
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
118
118
|
"eslint-plugin-you-dont-need-lodash-underscore": "^6.14.0",
|
|
119
119
|
"flow-bin": "^0.200.1",
|
|
120
120
|
"flow-copy-source": "^2.0.9",
|
|
121
121
|
"flow-typed": "^3.9.0",
|
|
122
|
-
"hermes-eslint": "^0.
|
|
122
|
+
"hermes-eslint": "^0.28.0",
|
|
123
123
|
"history": "^4.0.0",
|
|
124
124
|
"husky": "^9.1.7",
|
|
125
125
|
"jest": "^29.7.0",
|
|
126
126
|
"jest-environment-jsdom": "^29.7.0",
|
|
127
127
|
"jest-junit": "^16.0.0",
|
|
128
128
|
"jest-sonar-reporter": "^2.0.0",
|
|
129
|
-
"jscodeshift": "^17.
|
|
130
|
-
"lint-staged": "^15.
|
|
129
|
+
"jscodeshift": "^17.3.0",
|
|
130
|
+
"lint-staged": "^15.5.1",
|
|
131
131
|
"polished": "^4.0.0",
|
|
132
132
|
"prettier": "^3.5.3",
|
|
133
|
-
"react": "^19.
|
|
134
|
-
"react-dom": "^19.
|
|
133
|
+
"react": "^19.1.0",
|
|
134
|
+
"react-dom": "^19.1.0",
|
|
135
135
|
"react-helmet-async": "^2.0.5",
|
|
136
136
|
"react-redux": "^8.1.3",
|
|
137
137
|
"react-router": "^5.0.0",
|
|
138
|
-
"react-test-renderer": "^19.
|
|
138
|
+
"react-test-renderer": "^19.1.0",
|
|
139
139
|
"redux": "^4.2.1",
|
|
140
140
|
"redux-mock-store": "^1.5.5",
|
|
141
141
|
"redux-thunk": "^2.4.2",
|
|
142
142
|
"rimraf": "^6.0.1",
|
|
143
143
|
"styled-components": "^5.3.11",
|
|
144
|
-
"typescript": "^5.8.
|
|
144
|
+
"typescript": "^5.8.3",
|
|
145
145
|
"xhr-mock": "^2.5.1"
|
|
146
146
|
},
|
|
147
147
|
"scarfSettings": {
|
package/src/hooks/useForm.js
CHANGED
|
@@ -10,7 +10,7 @@ import type {
|
|
|
10
10
|
UpdateFormAction,
|
|
11
11
|
} from "../redux/_modularui";
|
|
12
12
|
import { loadModularUI, removeModelByKey } from "../redux/_modularui";
|
|
13
|
-
import { useModularUI } from "./useModularUI";
|
|
13
|
+
import { createKeyForModularUIStore, useModularUI } from "./useModularUI";
|
|
14
14
|
|
|
15
15
|
import {
|
|
16
16
|
addRepeatableAttributeSet,
|
|
@@ -47,6 +47,8 @@ type AttributeUpdateHook = (
|
|
|
47
47
|
options: UpdateFormOptions,
|
|
48
48
|
) => void;
|
|
49
49
|
|
|
50
|
+
const FORM_MODEL_KEY = "form";
|
|
51
|
+
|
|
50
52
|
/**
|
|
51
53
|
* Load a form by href
|
|
52
54
|
*/
|
|
@@ -57,7 +59,7 @@ export const useForm = (href: string | Href, data?: Object): ?FormModel => {
|
|
|
57
59
|
formHref.addParameter("commit", "false");
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
const form = useModularUI(
|
|
62
|
+
const form = useModularUI(FORM_MODEL_KEY, formHref, {
|
|
61
63
|
method: HTTP_METHODS.POST,
|
|
62
64
|
targetModel: FormModel,
|
|
63
65
|
removeOnUnmount: true,
|
|
@@ -81,9 +83,15 @@ export const useFormNavigation = (): FormNavigationHook => {
|
|
|
81
83
|
|
|
82
84
|
const cancel = (form: FormModel) => dispatch(cancelForm(form));
|
|
83
85
|
|
|
84
|
-
const submit = (form: FormModel) =>
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
const submit = (form: FormModel) => {
|
|
87
|
+
const connectKey = createKeyForModularUIStore(
|
|
88
|
+
FORM_MODEL_KEY,
|
|
89
|
+
form.selfhref.toString(),
|
|
90
|
+
form.locale,
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
return dispatch(
|
|
94
|
+
loadModularUI(connectKey, form.selfhref, {
|
|
87
95
|
method: HTTP_METHODS.POST,
|
|
88
96
|
data: form.formdata,
|
|
89
97
|
updateHandler: (newModel: ModularUIModel): ModularUIModel => {
|
|
@@ -97,6 +105,7 @@ export const useFormNavigation = (): FormNavigationHook => {
|
|
|
97
105
|
targetModel: FormModel,
|
|
98
106
|
}),
|
|
99
107
|
);
|
|
108
|
+
};
|
|
100
109
|
|
|
101
110
|
const remove = (form: FormModel) =>
|
|
102
111
|
dispatch(removeModelByKey(form.connectKey));
|
|
@@ -18,11 +18,26 @@ import type { RequestModularUIOptions } from "../utils";
|
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
*/
|
|
21
|
-
const
|
|
21
|
+
export const createKeyForModularUIStore = (
|
|
22
|
+
modelKey: string,
|
|
23
|
+
url: string,
|
|
24
|
+
locale: string,
|
|
25
|
+
): string => {
|
|
26
|
+
return `${modelKey}(${url})(${locale})`;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
*/
|
|
31
|
+
const useKeyForHook = (
|
|
32
|
+
modelKey: string,
|
|
33
|
+
url: string,
|
|
34
|
+
removeQuerystringFromKey: boolean = true,
|
|
35
|
+
): string => {
|
|
22
36
|
const locale = useLocale();
|
|
37
|
+
const href = removeQuerystringFromKey ? url.split("?")[0] : url;
|
|
23
38
|
return useMemo(
|
|
24
|
-
() =>
|
|
25
|
-
[modelKey,
|
|
39
|
+
() => createKeyForModularUIStore(modelKey, href, locale),
|
|
40
|
+
[modelKey, href, locale],
|
|
26
41
|
);
|
|
27
42
|
};
|
|
28
43
|
|
|
@@ -39,7 +54,11 @@ export const useModularUI = (
|
|
|
39
54
|
): any => {
|
|
40
55
|
const dispatch = useDispatch();
|
|
41
56
|
const href = useMemo(() => url?.toString() || "", [url]);
|
|
42
|
-
const key = useKeyForHook(
|
|
57
|
+
const key = useKeyForHook(
|
|
58
|
+
modelKey,
|
|
59
|
+
href,
|
|
60
|
+
!options.method || options.method === HTTP_METHODS.GET,
|
|
61
|
+
);
|
|
43
62
|
|
|
44
63
|
const modelSelector = useMemo(() => (state) => state.modularui[key], [key]);
|
|
45
64
|
const model = useSelector(modelSelector);
|