@beinformed/ui 1.18.6 → 1.18.8

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 (76) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/esm/models/attributes/AttributeModel.js +5 -2
  3. package/esm/models/attributes/AttributeModel.js.map +1 -1
  4. package/esm/models/list/ListModel.js +3 -2
  5. package/esm/models/list/ListModel.js.map +1 -1
  6. package/esm/react-client/Init.js.map +1 -1
  7. package/esm/react-client/client.js +10 -16
  8. package/esm/react-client/client.js.map +1 -1
  9. package/esm/react-server/htmlpage.js +11 -18
  10. package/esm/react-server/htmlpage.js.map +1 -1
  11. package/esm/react-server/renderSSRMinimal.js +1 -2
  12. package/esm/react-server/renderSSRMinimal.js.map +1 -1
  13. package/esm/react-server/serverNoSSR.js +2 -3
  14. package/esm/react-server/serverNoSSR.js.map +1 -1
  15. package/esm/react-theme/ThemeProvider.js +2 -1
  16. package/esm/react-theme/ThemeProvider.js.map +1 -1
  17. package/esm/utils/browser/Cookies.js +5 -19
  18. package/esm/utils/browser/Cookies.js.map +1 -1
  19. package/lib/hooks/__tests__/UseModularUIModel.spec.js.flow +1 -1
  20. package/lib/hooks/__tests__/useAuthentication.spec.js.flow +1 -1
  21. package/lib/hooks/__tests__/useForm.spec.js.flow +1 -1
  22. package/lib/hooks/__tests__/useModal.spec.js.flow +1 -1
  23. package/lib/hooks/__tests__/useModelCatalog.spec.js.flow +1 -1
  24. package/lib/hooks/__tests__/useModels.spec.js.flow +1 -1
  25. package/lib/hooks/__tests__/useModularUIBasic.spec.js.flow +1 -18
  26. package/lib/hooks/__tests__/useNotification.spec.js.flow +1 -1
  27. package/lib/hooks/__tests__/usePreference.spec.js.flow +1 -1
  28. package/lib/hooks/__tests__/useProgressIndicator.spec.js.flow +1 -1
  29. package/lib/models/attributes/AttributeModel.js +3 -1
  30. package/lib/models/attributes/AttributeModel.js.flow +20 -16
  31. package/lib/models/attributes/AttributeModel.js.map +1 -1
  32. package/lib/models/list/ListModel.js +3 -2
  33. package/lib/models/list/ListModel.js.flow +14 -13
  34. package/lib/models/list/ListModel.js.map +1 -1
  35. package/lib/react-client/Init.js.flow +1 -1
  36. package/lib/react-client/Init.js.map +1 -1
  37. package/lib/react-client/client.js +10 -16
  38. package/lib/react-client/client.js.flow +12 -10
  39. package/lib/react-client/client.js.map +1 -1
  40. package/lib/react-server/htmlpage.js +10 -18
  41. package/lib/react-server/htmlpage.js.flow +9 -13
  42. package/lib/react-server/htmlpage.js.map +1 -1
  43. package/lib/react-server/renderSSRMinimal.js +1 -2
  44. package/lib/react-server/renderSSRMinimal.js.flow +2 -2
  45. package/lib/react-server/renderSSRMinimal.js.map +1 -1
  46. package/lib/react-server/serverNoSSR.js +2 -3
  47. package/lib/react-server/serverNoSSR.js.flow +4 -3
  48. package/lib/react-server/serverNoSSR.js.map +1 -1
  49. package/lib/react-theme/ThemeProvider.js +2 -1
  50. package/lib/react-theme/ThemeProvider.js.flow +2 -2
  51. package/lib/react-theme/ThemeProvider.js.map +1 -1
  52. package/lib/redux/_router/__tests__/hooks.spec.js.flow +1 -1
  53. package/lib/utils/browser/Cookies.js +5 -18
  54. package/lib/utils/browser/Cookies.js.flow +4 -14
  55. package/lib/utils/browser/Cookies.js.map +1 -1
  56. package/package.json +26 -26
  57. package/src/hooks/__tests__/UseModularUIModel.spec.js +1 -1
  58. package/src/hooks/__tests__/useAuthentication.spec.js +1 -1
  59. package/src/hooks/__tests__/useForm.spec.js +1 -1
  60. package/src/hooks/__tests__/useModal.spec.js +1 -1
  61. package/src/hooks/__tests__/useModelCatalog.spec.js +1 -1
  62. package/src/hooks/__tests__/useModels.spec.js +1 -1
  63. package/src/hooks/__tests__/useModularUIBasic.spec.js +1 -18
  64. package/src/hooks/__tests__/useNotification.spec.js +1 -1
  65. package/src/hooks/__tests__/usePreference.spec.js +1 -1
  66. package/src/hooks/__tests__/useProgressIndicator.spec.js +1 -1
  67. package/src/models/attributes/AttributeModel.js +20 -16
  68. package/src/models/list/ListModel.js +14 -13
  69. package/src/react-client/Init.js +1 -1
  70. package/src/react-client/client.js +12 -10
  71. package/src/react-server/htmlpage.js +9 -13
  72. package/src/react-server/renderSSRMinimal.js +2 -2
  73. package/src/react-server/serverNoSSR.js +4 -3
  74. package/src/react-theme/ThemeProvider.js +2 -2
  75. package/src/redux/_router/__tests__/hooks.spec.js +1 -1
  76. package/src/utils/browser/Cookies.js +4 -14
@@ -24,21 +24,11 @@ const getCookie = (name: string): null | string => {
24
24
 
25
25
  /**
26
26
  */
27
- const setCookie = (
28
- name: string,
29
- value: any,
30
- { days, sameSite = "Strict", secure }: CookieOptions = {}
31
- ) => {
27
+ const setCookie = (name: string, value: any, options?: CookieOptions) => {
32
28
  const attributes: CookieAttributes = { path: BASE };
33
- if (days) {
34
- attributes.expires = days;
35
- }
36
- if (sameSite) {
37
- attributes.sameSite = sameSite;
38
- }
39
- if (secure) {
40
- attributes.secure = secure;
41
- }
29
+ attributes.expires = options?.days;
30
+ attributes.sameSite = options?.sameSite ?? "Strict";
31
+ attributes.secure = options?.secure;
42
32
 
43
33
  Cookies.set(name, value, attributes);
44
34
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Cookies.js","names":["getCookie","name","Cookies","get","setCookie","value","days","sameSite","secure","attributes","path","BASE","expires","set","clearCookie","remove"],"sources":["../../../src/utils/browser/Cookies.js"],"sourcesContent":["// @flow\nimport Cookies from \"js-cookie\";\n\nimport { BASE } from \"../../constants/Constants\";\n\ntype CookieOptions = {\n days?: number,\n sameSite?: \"None\" | \"Lax\" | \"Strict\",\n secure?: boolean,\n};\n\ntype CookieAttributes = {\n path: string,\n expires?: number,\n sameSite?: string,\n secure?: boolean,\n};\n\n/**\n */\nconst getCookie = (name: string): null | string => {\n return Cookies.get(name);\n};\n\n/**\n */\nconst setCookie = (\n name: string,\n value: any,\n { days, sameSite = \"Strict\", secure }: CookieOptions = {}\n) => {\n const attributes: CookieAttributes = { path: BASE };\n if (days) {\n attributes.expires = days;\n }\n if (sameSite) {\n attributes.sameSite = sameSite;\n }\n if (secure) {\n attributes.secure = secure;\n }\n\n Cookies.set(name, value, attributes);\n};\n\n/**\n */\nconst clearCookie = (name: string) => {\n Cookies.remove(name, { path: BASE });\n};\n\nexport { getCookie, setCookie, clearCookie };\n"],"mappings":";;;;;;;;;AACA;;AAEA;;AAeA;AACA;AACA,IAAMA,SAAS,GAAG,SAAZA,SAAY,CAACC,IAAD,EAAiC;EACjD,OAAOC,iBAAA,CAAQC,GAAR,CAAYF,IAAZ,CAAP;AACD,CAFD;AAIA;AACA;;;;;AACA,IAAMG,SAAS,GAAG,SAAZA,SAAY,CAChBH,IADgB,EAEhBI,KAFgB,EAIb;EAAA,+EADoD,EACpD;EAAA,IADDC,IACC,QADDA,IACC;EAAA,yBADKC,QACL;EAAA,IADKA,QACL,8BADgB,QAChB;EAAA,IAD0BC,MAC1B,QAD0BA,MAC1B;;EACH,IAAMC,UAA4B,GAAG;IAAEC,IAAI,EAAEC;EAAR,CAArC;;EACA,IAAIL,IAAJ,EAAU;IACRG,UAAU,CAACG,OAAX,GAAqBN,IAArB;EACD;;EACD,IAAIC,QAAJ,EAAc;IACZE,UAAU,CAACF,QAAX,GAAsBA,QAAtB;EACD;;EACD,IAAIC,MAAJ,EAAY;IACVC,UAAU,CAACD,MAAX,GAAoBA,MAApB;EACD;;EAEDN,iBAAA,CAAQW,GAAR,CAAYZ,IAAZ,EAAkBI,KAAlB,EAAyBI,UAAzB;AACD,CAjBD;AAmBA;AACA;;;;;AACA,IAAMK,WAAW,GAAG,SAAdA,WAAc,CAACb,IAAD,EAAkB;EACpCC,iBAAA,CAAQa,MAAR,CAAed,IAAf,EAAqB;IAAES,IAAI,EAAEC;EAAR,CAArB;AACD,CAFD"}
1
+ {"version":3,"file":"Cookies.js","names":["getCookie","name","Cookies","get","setCookie","value","options","attributes","path","BASE","expires","days","sameSite","secure","set","clearCookie","remove"],"sources":["../../../src/utils/browser/Cookies.js"],"sourcesContent":["// @flow\nimport Cookies from \"js-cookie\";\n\nimport { BASE } from \"../../constants/Constants\";\n\ntype CookieOptions = {\n days?: number,\n sameSite?: \"None\" | \"Lax\" | \"Strict\",\n secure?: boolean,\n};\n\ntype CookieAttributes = {\n path: string,\n expires?: number,\n sameSite?: string,\n secure?: boolean,\n};\n\n/**\n */\nconst getCookie = (name: string): null | string => {\n return Cookies.get(name);\n};\n\n/**\n */\nconst setCookie = (name: string, value: any, options?: CookieOptions) => {\n const attributes: CookieAttributes = { path: BASE };\n attributes.expires = options?.days;\n attributes.sameSite = options?.sameSite ?? \"Strict\";\n attributes.secure = options?.secure;\n\n Cookies.set(name, value, attributes);\n};\n\n/**\n */\nconst clearCookie = (name: string) => {\n Cookies.remove(name, { path: BASE });\n};\n\nexport { getCookie, setCookie, clearCookie };\n"],"mappings":";;;;;;;;;AACA;;AAEA;;AAeA;AACA;AACA,IAAMA,SAAS,GAAG,SAAZA,SAAY,CAACC,IAAD,EAAiC;EACjD,OAAOC,iBAAA,CAAQC,GAAR,CAAYF,IAAZ,CAAP;AACD,CAFD;AAIA;AACA;;;;;AACA,IAAMG,SAAS,GAAG,SAAZA,SAAY,CAACH,IAAD,EAAeI,KAAf,EAA2BC,OAA3B,EAAuD;EAAA;;EACvE,IAAMC,UAA4B,GAAG;IAAEC,IAAI,EAAEC;EAAR,CAArC;EACAF,UAAU,CAACG,OAAX,GAAqBJ,OAArB,aAAqBA,OAArB,uBAAqBA,OAAO,CAAEK,IAA9B;EACAJ,UAAU,CAACK,QAAX,wBAAsBN,OAAtB,aAAsBA,OAAtB,uBAAsBA,OAAO,CAAEM,QAA/B,iEAA2C,QAA3C;EACAL,UAAU,CAACM,MAAX,GAAoBP,OAApB,aAAoBA,OAApB,uBAAoBA,OAAO,CAAEO,MAA7B;;EAEAX,iBAAA,CAAQY,GAAR,CAAYb,IAAZ,EAAkBI,KAAlB,EAAyBE,UAAzB;AACD,CAPD;AASA;AACA;;;;;AACA,IAAMQ,WAAW,GAAG,SAAdA,WAAc,CAACd,IAAD,EAAkB;EACpCC,iBAAA,CAAQc,MAAR,CAAef,IAAf,EAAqB;IAAEO,IAAI,EAAEC;EAAR,CAArB;AACD,CAFD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.18.6",
3
+ "version": "1.18.8",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "http://support.beinformed.com",
@@ -68,18 +68,18 @@
68
68
  "peerDependencies": {
69
69
  "history": "^4.0.0",
70
70
  "polished": "^4.0.0",
71
- "react": "^16.14.0 || ^17.0.0",
72
- "react-dom": "^16.14.0 || ^17.0.0",
71
+ "react": "^16.14.0 || ^17.0.0 || ^18.0.0",
72
+ "react-dom": "^16.14.0 || ^17.0.0 || ^18.0.0",
73
73
  "react-helmet-async": "^1.0.0",
74
- "react-redux": "^7.0.0",
74
+ "react-redux": "^7.0.0 || ^8.0.0",
75
75
  "react-router": "^5.2.0",
76
76
  "redux": "^4.0.0",
77
77
  "redux-thunk": "^2.3.0",
78
78
  "styled-components": "^5.2.0"
79
79
  },
80
80
  "dependencies": {
81
- "@babel/runtime-corejs3": "^7.18.0",
82
- "big.js": "^6.1.1",
81
+ "@babel/runtime-corejs3": "^7.18.3",
82
+ "big.js": "^6.2.0",
83
83
  "date-fns": "^2.28.0",
84
84
  "deepmerge": "^4.2.2",
85
85
  "dequal": "^2.0.2",
@@ -91,58 +91,58 @@
91
91
  "iban": "^0.0.14",
92
92
  "js-cookie": "^3.0.1",
93
93
  "lodash": "^4.17.21",
94
- "reselect": "^4.1.5",
94
+ "reselect": "^4.1.6",
95
95
  "setimmediate": "^1.0.5"
96
96
  },
97
97
  "devDependencies": {
98
98
  "@babel/cli": "^7.17.10",
99
- "@babel/core": "^7.18.0",
100
- "@babel/eslint-parser": "^7.17.0",
99
+ "@babel/core": "^7.18.5",
100
+ "@babel/eslint-parser": "^7.18.2",
101
101
  "@babel/eslint-plugin": "^7.16.5",
102
102
  "@babel/plugin-proposal-class-properties": "^7.17.12",
103
103
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
104
- "@babel/plugin-transform-runtime": "^7.18.0",
105
- "@babel/preset-env": "^7.18.0",
104
+ "@babel/plugin-transform-runtime": "^7.18.5",
105
+ "@babel/preset-env": "^7.18.2",
106
106
  "@babel/preset-flow": "^7.17.12",
107
107
  "@babel/preset-react": "^7.17.12",
108
- "@commitlint/cli": "^17.0.0",
109
- "@commitlint/config-conventional": "^17.0.0",
110
- "@testing-library/react-hooks": "^8.0.0",
108
+ "@commitlint/cli": "^17.0.2",
109
+ "@commitlint/config-conventional": "^17.0.2",
110
+ "@testing-library/react": "^13.3.0",
111
111
  "auditjs": "^4.0.37",
112
- "babel-jest": "^28.1.0",
112
+ "babel-jest": "^28.1.1",
113
113
  "babel-plugin-styled-components": "^2.0.7",
114
114
  "cherry-pick": "^0.5.0",
115
115
  "cross-env": "^7.0.3",
116
116
  "documentation": "^13.2.5",
117
- "eslint": "^8.15.0",
117
+ "eslint": "^8.17.0",
118
118
  "eslint-config-prettier": "^8.3.0",
119
119
  "eslint-plugin-babel": "^5.3.1",
120
120
  "eslint-plugin-ft-flow": "^2.0.1",
121
121
  "eslint-plugin-import": "^2.26.0",
122
- "eslint-plugin-jest": "^26.2.2",
123
- "eslint-plugin-jsdoc": "^39.3.0",
122
+ "eslint-plugin-jest": "^26.5.3",
123
+ "eslint-plugin-jsdoc": "^39.3.2",
124
124
  "eslint-plugin-react": "^7.30.0",
125
125
  "eslint-plugin-react-hooks": "^4.5.0",
126
- "flow-bin": "^0.178.0",
126
+ "flow-bin": "^0.180.0",
127
127
  "flow-copy-source": "^2.0.9",
128
128
  "flow-typed": "^3.6.1",
129
129
  "glob": "^8.0.3",
130
130
  "history": "^4.0.0",
131
131
  "husky": "^8.0.1",
132
- "jest": "^28.1.0",
133
- "jest-environment-jsdom": "^28.1.0",
132
+ "jest": "^28.1.1",
133
+ "jest-environment-jsdom": "^28.1.1",
134
134
  "jest-junit": "^13.2.0",
135
135
  "jest-sonar-reporter": "^2.0.0",
136
136
  "jscodeshift": "^0.13.1",
137
- "lint-staged": "^12.4.1",
137
+ "lint-staged": "^13.0.1",
138
138
  "polished": "^4.2.2",
139
139
  "prettier": "^2.6.2",
140
- "react": "^17.0.2",
141
- "react-dom": "^17.0.2",
140
+ "react": "^18.1.0",
141
+ "react-dom": "^18.1.0",
142
142
  "react-helmet-async": "^1.3.0",
143
- "react-redux": "^7.2.8",
143
+ "react-redux": "^8.0.2",
144
144
  "react-router": "^5.2.0",
145
- "react-test-renderer": "^17.0.2",
145
+ "react-test-renderer": "^18.1.0",
146
146
  "redux": "^4.2.0",
147
147
  "redux-mock-store": "^1.5.4",
148
148
  "redux-thunk": "^2.4.1",
@@ -1,7 +1,7 @@
1
1
  import configureMockStore from "redux-mock-store";
2
2
  import thunk from "redux-thunk";
3
3
  import { Provider } from "react-redux";
4
- import { renderHook } from "@testing-library/react-hooks";
4
+ import { renderHook } from "@testing-library/react";
5
5
  import xhrMock from "xhr-mock";
6
6
 
7
7
  import {
@@ -1,7 +1,7 @@
1
1
  import configureMockStore from "redux-mock-store";
2
2
  import thunk from "redux-thunk";
3
3
  import { Provider } from "react-redux";
4
- import { renderHook } from "@testing-library/react-hooks";
4
+ import { renderHook } from "@testing-library/react";
5
5
  import xhrMock from "xhr-mock";
6
6
 
7
7
  import { useLogin, useLogout } from "../useAuthentication";
@@ -1,7 +1,7 @@
1
1
  import configureMockStore from "redux-mock-store";
2
2
  import thunk from "redux-thunk";
3
3
  import { Provider } from "react-redux";
4
- import { renderHook } from "@testing-library/react-hooks";
4
+ import { renderHook } from "@testing-library/react";
5
5
  import xhrMock from "xhr-mock";
6
6
 
7
7
  import {
@@ -1,6 +1,6 @@
1
1
  import configureMockStore from "redux-mock-store";
2
2
  import { Provider } from "react-redux";
3
- import { renderHook } from "@testing-library/react-hooks";
3
+ import { renderHook } from "@testing-library/react";
4
4
 
5
5
  import { useModal } from "../useModal";
6
6
  import { IllegalArgumentException } from "../../exceptions";
@@ -1,7 +1,7 @@
1
1
  import configureMockStore from "redux-mock-store";
2
2
  import thunk from "redux-thunk";
3
3
  import { Provider } from "react-redux";
4
- import { renderHook } from "@testing-library/react-hooks";
4
+ import { renderHook } from "@testing-library/react";
5
5
  import xhrMock from "xhr-mock";
6
6
 
7
7
  import {
@@ -1,5 +1,5 @@
1
1
  import { useModels } from "../useModels";
2
- import { renderHook } from "@testing-library/react-hooks";
2
+ import { renderHook } from "@testing-library/react";
3
3
  import { Provider } from "react-redux";
4
4
  import configureMockStore from "redux-mock-store";
5
5
 
@@ -1,12 +1,11 @@
1
1
  import configureMockStore from "redux-mock-store";
2
2
  import thunk from "redux-thunk";
3
3
  import { Provider } from "react-redux";
4
- import { renderHook } from "@testing-library/react-hooks";
4
+ import { renderHook } from "@testing-library/react";
5
5
  import xhrMock from "xhr-mock";
6
6
 
7
7
  import { useModularUIBasic } from "../useModularUIBasic";
8
8
  import { ApplicationModel, Href } from "../../models";
9
- import { IllegalArgumentException } from "../../exceptions";
10
9
 
11
10
  const middlewares = [thunk];
12
11
  const mockStore = configureMockStore(middlewares);
@@ -74,22 +73,6 @@ describe("modularui hooks", () => {
74
73
  ]);
75
74
  });
76
75
 
77
- it("missing href", () => {
78
- const store = mockStore({
79
- modularui: {},
80
- router: { location: { pathname: "/", state: { reload: true } } },
81
- i18n: { locale: "en" },
82
- });
83
- /**
84
- */
85
- const wrapper = ({ children }) => (
86
- <Provider store={store}>{children}</Provider>
87
- );
88
-
89
- const { result } = renderHook(() => useModularUIBasic(), { wrapper });
90
- expect(result.error).toBeInstanceOf(IllegalArgumentException);
91
- });
92
-
93
76
  it("useModularUIBasic with reload", () => {
94
77
  expect.assertions(2);
95
78
 
@@ -1,6 +1,6 @@
1
1
  import configureMockStore from "redux-mock-store";
2
2
  import { Provider } from "react-redux";
3
- import { renderHook } from "@testing-library/react-hooks";
3
+ import { renderHook } from "@testing-library/react";
4
4
  import { useNotification } from "../useNotification";
5
5
 
6
6
  const mockStore = configureMockStore();
@@ -1,6 +1,6 @@
1
1
  import configureMockStore from "redux-mock-store";
2
2
  import { Provider } from "react-redux";
3
- import { renderHook } from "@testing-library/react-hooks";
3
+ import { renderHook } from "@testing-library/react";
4
4
  import { usePreference } from "../usePreference";
5
5
 
6
6
  const mockStore = configureMockStore();
@@ -1,6 +1,6 @@
1
1
  import configureMockStore from "redux-mock-store";
2
2
  import { Provider } from "react-redux";
3
- import { renderHook } from "@testing-library/react-hooks";
3
+ import { renderHook } from "@testing-library/react";
4
4
  import { useProgressIndicator } from "../useProgressIndicator";
5
5
 
6
6
  const mockStore = configureMockStore();
@@ -12,7 +12,7 @@ import MandatoryConstraint from "./input-constraints/MandatoryConstraint";
12
12
 
13
13
  import ConceptDetailModel from "../concepts/ConceptDetailModel";
14
14
 
15
- import { MANDATORY, DISABLED } from "../../constants/LayoutHints";
15
+ import { DISABLED, MANDATORY } from "../../constants/LayoutHints";
16
16
  import {
17
17
  ATTRIBUTE_WIDTH,
18
18
  TIMEVERSION_FILTER_NAME,
@@ -804,21 +804,25 @@ export default class AttributeModel
804
804
  this._serverConstraints = new ConstraintCollection();
805
805
  this.resetErrors();
806
806
 
807
- errors.forEach((error) => {
808
- if (this.hasValue()) {
809
- this._errorCollection.addServerError(
810
- error.id,
811
- error.message,
812
- this.formatParameters(error.properties)
813
- );
814
- } else {
815
- this.addServerConstraint(
816
- error.id,
817
- error.message,
818
- this.formatParameters(error.properties)
819
- );
820
- }
821
- });
807
+ errors
808
+ .filter(
809
+ (error) => error.id !== "Constraint.Mandatory" || !this.hasValue()
810
+ )
811
+ .forEach((error) => {
812
+ if (this.hasValue()) {
813
+ this._errorCollection.addServerError(
814
+ error.id,
815
+ error.message,
816
+ this.formatParameters(error.properties)
817
+ );
818
+ } else {
819
+ this.addServerConstraint(
820
+ error.id,
821
+ error.message,
822
+ this.formatParameters(error.properties)
823
+ );
824
+ }
825
+ });
822
826
  }
823
827
 
824
828
  /**
@@ -44,20 +44,21 @@ export default class ListModel extends ResourceModel {
44
44
  /**
45
45
  */
46
46
  static isApplicableModel(data: ModularUIResponse): boolean {
47
+ const resourceType = data.contributions?.resourcetype ?? "";
47
48
  return (
48
- data.contributions.resourcetype &&
49
- (data.contributions.resourcetype.endsWith("List") ||
50
- data.contributions.resourcetype.endsWith("ListPanel") ||
51
- data.contributions.resourcetype.endsWith("RelatedDataStorePanel") ||
52
- [
53
- "list-related-cases",
54
- "RecordPanel",
55
- "EventHistoryPanel",
56
- "NotePanel",
57
- "AppointmentPanel",
58
- "DocumentPanel",
59
- "AssignmentPanel",
60
- ].includes(data.contributions.resourcetype))
49
+ resourceType.endsWith("List") ||
50
+ resourceType.endsWith("ListPanel") ||
51
+ resourceType.endsWith("RelatedDataStorePanel") ||
52
+ resourceType.endsWith("RelatedDatastorePanel") ||
53
+ [
54
+ "list-related-cases",
55
+ "RecordPanel",
56
+ "EventHistoryPanel",
57
+ "NotePanel",
58
+ "AppointmentPanel",
59
+ "DocumentPanel",
60
+ "AssignmentPanel",
61
+ ].includes(resourceType)
61
62
  );
62
63
  }
63
64
 
@@ -16,7 +16,7 @@ export type Props = {
16
16
  +store: ReduxStore,
17
17
  +history: RouterHistory,
18
18
  +contextPath: string,
19
- +theme: Theme | Array<Theme>,
19
+ +theme?: Theme | Array<Theme>,
20
20
  +children: ?Node,
21
21
  +ErrorFallbackComponent?: ComponentType<FallbackProps>,
22
22
  };
@@ -66,13 +66,7 @@ const parseDataToJSON = (data) => {
66
66
  /**
67
67
  * Mount the webapplication to the DOM, used client side when JavaScript is enabled.
68
68
  */
69
- const client = ({
70
- customReducers = {},
71
- theme = {},
72
- render,
73
- beforeRenderHooks,
74
- ErrorFallbackComponent,
75
- }: Props = {}) => {
69
+ const client = (props: Props) => {
76
70
  if (typeof window.contextPath === "undefined") {
77
71
  throw new Error("Missing contextPath on window object");
78
72
  }
@@ -97,7 +91,7 @@ const client = ({
97
91
  });
98
92
  const { history, store } = configureStore(
99
93
  browserHistory,
100
- customReducers,
94
+ props.customReducers ?? {},
101
95
  rehydrate(data)
102
96
  );
103
97
 
@@ -144,9 +138,17 @@ const client = ({
144
138
  document.body.className = "js";
145
139
  }
146
140
 
147
- handleBeforeRenderHooks(beforeRenderHooks, { store });
141
+ if (props.beforeRenderHooks) {
142
+ handleBeforeRenderHooks(props.beforeRenderHooks, { store });
143
+ }
148
144
 
149
- addContentLoadedEvent(store, history, theme, render, ErrorFallbackComponent);
145
+ addContentLoadedEvent(
146
+ store,
147
+ history,
148
+ props.theme,
149
+ props.render,
150
+ props.ErrorFallbackComponent
151
+ );
150
152
  };
151
153
 
152
154
  /**
@@ -11,23 +11,19 @@ export type TemplateProps = {
11
11
 
12
12
  /**
13
13
  */
14
- const htmlpage = ({
15
- contextPath,
16
- html,
17
- head = {},
18
- state = "",
19
- UUID = "",
20
- }: TemplateProps = {}): string => {
21
- if (contextPath === undefined) {
14
+ const htmlpage = (props: TemplateProps): string => {
15
+ if (props?.contextPath === undefined) {
22
16
  throw new IllegalArgumentException("Missing contextPath argument");
23
17
  }
24
- if (html === undefined) {
18
+ if (props.html === undefined) {
25
19
  throw new IllegalArgumentException("Missing html for server");
26
20
  }
27
21
 
22
+ const { head = {} } = props;
23
+
28
24
  const template = `
29
25
  <!doctype html>
30
- <html ${head && head.htmlAttributes ? head.htmlAttributes.toString() : ""}>
26
+ <html ${head.htmlAttributes ? head.htmlAttributes.toString() : ""}>
31
27
  <head>
32
28
  <meta charset="utf-8" />
33
29
  ${Object.keys(head)
@@ -37,14 +33,14 @@ const htmlpage = ({
37
33
  {CSSASSETS:<link rel="stylesheet" type="text/css" href="{CONTEXT_PATH}/{FILE}" />:CSSASSETS}
38
34
  </head>
39
35
  <body class="nojs">
40
- <div id="application">${html}</div>
36
+ <div id="application">${props.html}</div>
41
37
  <div id="portal"></div>
42
38
  <script
43
39
  type="application/json"
44
40
  data-app-state="app-json"
45
41
  data-app-contextpath="{CONTEXT_PATH}"
46
42
  data-app-filepath="{FILEPATH}"
47
- data-app-nonce="${UUID}">${state}</script>
43
+ data-app-nonce="${props.UUID ?? ""}">${props.state ?? ""}</script>
48
44
  {JSASSETS:<script src="{CONTEXT_PATH}/{FILE}"></script>:JSASSETS}
49
45
  </body>
50
46
  </html>
@@ -53,7 +49,7 @@ const htmlpage = ({
53
49
  // It is important to replace the context afterwards,
54
50
  // the JSASSESTS and CSSASSETS parts act as a small template for all generated javascript and css files
55
51
  // these templates must be pure strings to make it possible to add the context path in all situations
56
- return template.replace(/{CONTEXT_PATH}/g, contextPath).trim();
52
+ return template.replace(/{CONTEXT_PATH}/g, props.contextPath).trim();
57
53
  };
58
54
 
59
55
  export default htmlpage;
@@ -16,7 +16,7 @@ import type { ReduxStore } from "../redux/types";
16
16
  import type { TemplateProps } from "./htmlpage";
17
17
  type Props = {
18
18
  store: ReduxStore,
19
- theme: Theme,
19
+ theme?: Theme | Array<Theme>,
20
20
  UUID: string,
21
21
  render: Function,
22
22
  template?: (TemplateProps) => string,
@@ -26,7 +26,7 @@ type Props = {
26
26
  */
27
27
  const renderSSRMinimal = ({
28
28
  store,
29
- theme = {},
29
+ theme,
30
30
  UUID = "",
31
31
  render,
32
32
  template = htmlpage,
@@ -22,11 +22,12 @@ import type { TemplateProps } from "./htmlpage";
22
22
  import type { BeforeRenderHook } from "../redux/store/beforeRenderHooks";
23
23
  import type { PreferenceValue } from "./serverUtil";
24
24
  import type { LocaleConfiguration } from "../i18n/types";
25
+ import type { Theme } from "../react-theme/types";
25
26
  type serverProps = {
26
27
  request: HttpServletRequestJava,
27
28
  locales?: Array<LocaleConfiguration>,
28
29
  customReducers?: Object,
29
- theme?: Object,
30
+ theme?: Theme | Array<Theme>,
30
31
  serverPreferences?: Array<string | PreferenceValue>,
31
32
  render: Function,
32
33
  template?: (TemplateProps) => string,
@@ -40,7 +41,7 @@ const serverNoSSR = ({
40
41
  locales,
41
42
  customReducers,
42
43
  serverPreferences = [],
43
- theme = null,
44
+ theme,
44
45
  render,
45
46
  template,
46
47
  beforeRenderHooks,
@@ -56,7 +57,7 @@ const serverNoSSR = ({
56
57
 
57
58
  if (theme) {
58
59
  const storedTheme = store.getState()?.preferences?.theme;
59
- // $FlowFixMe[incompatible-call]
60
+ //$FlowFixMe[incompatible-call]
60
61
  createTheme(storedTheme, theme);
61
62
  }
62
63
 
@@ -8,13 +8,13 @@ import type { Node } from "react";
8
8
  import type { Theme } from "./types";
9
9
 
10
10
  export type Props = {
11
- +theme: Theme | Array<Theme>,
11
+ +theme?: Theme | Array<Theme>,
12
12
  +children: Node,
13
13
  };
14
14
 
15
15
  /**
16
16
  */
17
- const ThemeProvider = ({ theme, children }: Props): Node => {
17
+ const ThemeProvider = ({ theme = {}, children }: Props): Node => {
18
18
  const storedTheme = useSelector(({ preferences }) => preferences.theme);
19
19
  const finalTheme = createTheme(storedTheme, theme);
20
20
 
@@ -1,6 +1,6 @@
1
1
  import configureMockStore from "redux-mock-store";
2
2
  import { Provider } from "react-redux";
3
- import { renderHook } from "@testing-library/react-hooks";
3
+ import { renderHook } from "@testing-library/react";
4
4
  import {
5
5
  useLocation,
6
6
  useLocationKey,
@@ -24,21 +24,11 @@ const getCookie = (name: string): null | string => {
24
24
 
25
25
  /**
26
26
  */
27
- const setCookie = (
28
- name: string,
29
- value: any,
30
- { days, sameSite = "Strict", secure }: CookieOptions = {}
31
- ) => {
27
+ const setCookie = (name: string, value: any, options?: CookieOptions) => {
32
28
  const attributes: CookieAttributes = { path: BASE };
33
- if (days) {
34
- attributes.expires = days;
35
- }
36
- if (sameSite) {
37
- attributes.sameSite = sameSite;
38
- }
39
- if (secure) {
40
- attributes.secure = secure;
41
- }
29
+ attributes.expires = options?.days;
30
+ attributes.sameSite = options?.sameSite ?? "Strict";
31
+ attributes.secure = options?.secure;
42
32
 
43
33
  Cookies.set(name, value, attributes);
44
34
  };