@beinformed/ui 1.60.0 → 1.60.2

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 CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [1.60.2](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.60.1...v1.60.2) (2025-03-03)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **upload:** improve error handling on form uploads ([134de76](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/134de76b6b10dbcaecdd007fe27afc0a9a2a80f6))
11
+
12
+ ## [1.60.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.60.0...v1.60.1) (2025-02-19)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * **react:** use hydrateRoot and createRoot from react/dom ([7f9d544](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/7f9d54468a7cdbb6b93befc898094efb79cd2692))
18
+
5
19
  ## [1.60.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.59.23...v1.60.0) (2025-02-18)
6
20
 
7
21
 
@@ -284,6 +284,8 @@ describe("formModel", () => {
284
284
 
285
285
  form.currentFormObject.getAttributeByKey("DateOfBirth").inputvalue = "bla";
286
286
 
287
+ expect(form.errorCollection).toHaveLength(0);
288
+
287
289
  form.handleErrors({
288
290
  data: {
289
291
  errors: [
@@ -1,9 +1,10 @@
1
1
  import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
2
2
  import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
3
3
  import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
4
- import { getBasePathModularUI, getUploadPath, HTTP_METHODS } from "../constants";
4
+ import { getBasePathModularUI, getSetting, getUploadPath, HTTP_METHODS } from "../constants";
5
5
  import xhr from "../utils/fetch/xhr";
6
6
  import ErrorModel from "../models/error/ErrorModel";
7
+ import { ErrorResponse } from "../models";
7
8
  /**
8
9
  * Upload a file to the upload file service of Be Informed
9
10
  */
@@ -50,7 +51,7 @@ class UploadRequest {
50
51
  */
51
52
  uploadFile(file) {
52
53
  const maxFileSize = this._uploadConstraints?.maxFileSize?.fileSize ?? -1;
53
- if (this.exceedsMaxFileSize(file)) {
54
+ if (getSetting("USE_CLIENTSIDE_VALIDATION") && this.exceedsMaxFileSize(file)) {
54
55
  this._progressHandler(file, {
55
56
  error: "errorExceedsMaxFileSize"
56
57
  });
@@ -58,7 +59,7 @@ class UploadRequest {
58
59
  "max-filesize": maxFileSize
59
60
  }, true));
60
61
  }
61
- if (this.isNotAllowedFileType(file)) {
62
+ if (getSetting("USE_CLIENTSIDE_VALIDATION") && this.isNotAllowedFileType(file)) {
62
63
  this._progressHandler(file, {
63
64
  error: "errorExtensionNotAllowed"
64
65
  });
@@ -89,7 +90,7 @@ class UploadRequest {
89
90
  token: response.token
90
91
  });
91
92
  return response;
92
- });
93
+ }).catch(e => _Promise.reject(new ErrorResponse(e)));
93
94
  }
94
95
  }
95
96
  export default UploadRequest;
@@ -1,6 +1,7 @@
1
1
  // @flow
2
2
  import {
3
3
  getBasePathModularUI,
4
+ getSetting,
4
5
  getUploadPath,
5
6
  HTTP_METHODS,
6
7
  } from "../constants";
@@ -12,6 +13,7 @@ import type {
12
13
  FiletypeConstraintsType,
13
14
  } from "../models";
14
15
  import ErrorModel from "../models/error/ErrorModel";
16
+ import { ErrorResponse } from "../models";
15
17
 
16
18
  type ProgressHandler = (file: File, uploadInfo: Object) => void;
17
19
 
@@ -86,7 +88,10 @@ class UploadRequest {
86
88
  uploadFile(file: File): Promise<UploadResponse> {
87
89
  const maxFileSize = this._uploadConstraints?.maxFileSize?.fileSize ?? -1;
88
90
 
89
- if (this.exceedsMaxFileSize(file)) {
91
+ if (
92
+ getSetting("USE_CLIENTSIDE_VALIDATION") &&
93
+ this.exceedsMaxFileSize(file)
94
+ ) {
90
95
  this._progressHandler(file, { error: "errorExceedsMaxFileSize" });
91
96
  return Promise.reject(
92
97
  new ErrorModel(
@@ -100,7 +105,10 @@ class UploadRequest {
100
105
  );
101
106
  }
102
107
 
103
- if (this.isNotAllowedFileType(file)) {
108
+ if (
109
+ getSetting("USE_CLIENTSIDE_VALIDATION") &&
110
+ this.isNotAllowedFileType(file)
111
+ ) {
104
112
  this._progressHandler(file, { error: "errorExtensionNotAllowed" });
105
113
  return Promise.reject(
106
114
  new ErrorModel(
@@ -131,10 +139,12 @@ class UploadRequest {
131
139
  }
132
140
  },
133
141
  data: file,
134
- }).then((response) => {
135
- this._progressHandler(file, { progress: 100, token: response.token });
136
- return response;
137
- });
142
+ })
143
+ .then((response) => {
144
+ this._progressHandler(file, { progress: 100, token: response.token });
145
+ return response;
146
+ })
147
+ .catch((e) => Promise.reject(new ErrorResponse(e)));
138
148
  }
139
149
  }
140
150
 
@@ -1 +1 @@
1
- {"version":3,"file":"UploadRequest.js","names":["getBasePathModularUI","getUploadPath","HTTP_METHODS","xhr","ErrorModel","UploadRequest","constructor","uploadConstraints","progressHandler","options","_defineProperty","_uploadConstraints","_progressHandler","_origin","origin","_contextPath","contextPath","getFileExtension","file","name","split","pop","toLowerCase","isNotAllowedFileType","allowedFileTypes","fileTypes","length","fileExtension","some","fileType","_context","_includesInstanceProperty","extensions","call","exceedsMaxFileSize","maxFileSize","fileSize","size","uploadFile","error","_Promise","reject","extension","join","url","method","POST","headers","type","encodeURIComponent","toString","onProgress","e","lengthComputable","progress","Math","ceil","loaded","total","data","then","response","token"],"sources":["../../src/modularui/UploadRequest.js"],"sourcesContent":["// @flow\nimport {\n getBasePathModularUI,\n getUploadPath,\n HTTP_METHODS,\n} from \"../constants\";\n\nimport xhr from \"../utils/fetch/xhr\";\n\nimport type {\n FilesizeConstraintsType,\n FiletypeConstraintsType,\n} from \"../models\";\nimport ErrorModel from \"../models/error/ErrorModel\";\n\ntype ProgressHandler = (file: File, uploadInfo: Object) => void;\n\ntype UploadRequestOptions = {\n origin?: string,\n contextPath?: string,\n};\n\ntype UploadResponse = {\n token: string,\n};\n\n/**\n * Upload a file to the upload file service of Be Informed\n */\nclass UploadRequest {\n _uploadConstraints: {\n fileTypes: FiletypeConstraintsType,\n maxFileSize: FilesizeConstraintsType,\n acceptedFiles: Array<string>,\n };\n _progressHandler: ProgressHandler;\n _origin: string = \"\";\n _contextPath: string = getBasePathModularUI();\n\n constructor(\n uploadConstraints: {\n fileTypes: FiletypeConstraintsType,\n maxFileSize: FilesizeConstraintsType,\n acceptedFiles: Array<string>,\n },\n progressHandler: ProgressHandler,\n options?: UploadRequestOptions,\n ) {\n this._uploadConstraints = uploadConstraints;\n this._progressHandler = progressHandler;\n this._origin = options?.origin || \"\";\n this._contextPath = options?.contextPath || getBasePathModularUI();\n }\n\n /**\n */\n getFileExtension(file: File): string {\n return file.name.split(\".\").pop().toLowerCase();\n }\n\n /**\n */\n isNotAllowedFileType(file: File): boolean {\n const allowedFileTypes = this._uploadConstraints.fileTypes;\n\n if (allowedFileTypes.length > 0) {\n const fileExtension = this.getFileExtension(file);\n\n return !allowedFileTypes.some((fileType) =>\n fileType.extensions.includes(fileExtension),\n );\n }\n\n return false;\n }\n\n /**\n */\n exceedsMaxFileSize(file: File): boolean {\n const maxFileSize = this._uploadConstraints?.maxFileSize?.fileSize ?? -1;\n return maxFileSize > -1 && file.size > maxFileSize;\n }\n\n /**\n */\n uploadFile(file: File): Promise<UploadResponse> {\n const maxFileSize = this._uploadConstraints?.maxFileSize?.fileSize ?? -1;\n\n if (this.exceedsMaxFileSize(file)) {\n this._progressHandler(file, { error: \"errorExceedsMaxFileSize\" });\n return Promise.reject(\n new ErrorModel(\n \"Constraint.File.MaxFileSizeExceeded\",\n \"Maximum file upload size is ${max-filesize}\",\n {\n \"max-filesize\": maxFileSize,\n },\n true,\n ),\n );\n }\n\n if (this.isNotAllowedFileType(file)) {\n this._progressHandler(file, { error: \"errorExtensionNotAllowed\" });\n return Promise.reject(\n new ErrorModel(\n \"Constraint.File.InvalidExtension\",\n \"Allowed extensions are: ${extensions}\",\n {\n extension: this.getFileExtension(file),\n extensions: this._uploadConstraints.fileTypes.join(\", \"),\n },\n true,\n ),\n );\n }\n\n return xhr({\n url: getUploadPath(this._contextPath, this._origin),\n method: HTTP_METHODS.POST,\n headers: {\n \"Content-Type\": file.type,\n \"x-filename\": encodeURIComponent(file.name),\n \"x-filesize\": file.size.toString(),\n },\n onProgress: (e: ProgressEvent) => {\n if (this._progressHandler && e.lengthComputable) {\n this._progressHandler(file, {\n progress: Math.ceil((e.loaded / e.total) * 100),\n });\n }\n },\n data: file,\n }).then((response) => {\n this._progressHandler(file, { progress: 100, token: response.token });\n return response;\n });\n }\n}\n\nexport default UploadRequest;\n"],"mappings":";;;AACA,SACEA,oBAAoB,EACpBC,aAAa,EACbC,YAAY,QACP,cAAc;AAErB,OAAOC,GAAG,MAAM,oBAAoB;AAMpC,OAAOC,UAAU,MAAM,4BAA4B;AAanD;AACA;AACA;AACA,MAAMC,aAAa,CAAC;EAUlBC,WAAWA,CACTC,iBAIC,EACDC,eAAgC,EAChCC,OAA8B,EAC9B;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA,kBAXgB,EAAE;IAAAA,eAAA,uBACGV,oBAAoB,CAAC,CAAC;IAW3C,IAAI,CAACW,kBAAkB,GAAGJ,iBAAiB;IAC3C,IAAI,CAACK,gBAAgB,GAAGJ,eAAe;IACvC,IAAI,CAACK,OAAO,GAAGJ,OAAO,EAAEK,MAAM,IAAI,EAAE;IACpC,IAAI,CAACC,YAAY,GAAGN,OAAO,EAAEO,WAAW,IAAIhB,oBAAoB,CAAC,CAAC;EACpE;;EAEA;AACF;EACEiB,gBAAgBA,CAACC,IAAU,EAAU;IACnC,OAAOA,IAAI,CAACC,IAAI,CAACC,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAA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3,"file":"UploadRequest.js","names":["getBasePathModularUI","getSetting","getUploadPath","HTTP_METHODS","xhr","ErrorModel","ErrorResponse","UploadRequest","constructor","uploadConstraints","progressHandler","options","_defineProperty","_uploadConstraints","_progressHandler","_origin","origin","_contextPath","contextPath","getFileExtension","file","name","split","pop","toLowerCase","isNotAllowedFileType","allowedFileTypes","fileTypes","length","fileExtension","some","fileType","_context","_includesInstanceProperty","extensions","call","exceedsMaxFileSize","maxFileSize","fileSize","size","uploadFile","error","_Promise","reject","extension","join","url","method","POST","headers","type","encodeURIComponent","toString","onProgress","e","lengthComputable","progress","Math","ceil","loaded","total","data","then","response","token","catch"],"sources":["../../src/modularui/UploadRequest.js"],"sourcesContent":["// @flow\nimport {\n getBasePathModularUI,\n getSetting,\n getUploadPath,\n HTTP_METHODS,\n} from \"../constants\";\n\nimport xhr from \"../utils/fetch/xhr\";\n\nimport type {\n FilesizeConstraintsType,\n FiletypeConstraintsType,\n} from \"../models\";\nimport ErrorModel from \"../models/error/ErrorModel\";\nimport { ErrorResponse } from \"../models\";\n\ntype ProgressHandler = (file: File, uploadInfo: Object) => void;\n\ntype UploadRequestOptions = {\n origin?: string,\n contextPath?: string,\n};\n\ntype UploadResponse = {\n token: string,\n};\n\n/**\n * Upload a file to the upload file service of Be Informed\n */\nclass UploadRequest {\n _uploadConstraints: {\n fileTypes: FiletypeConstraintsType,\n maxFileSize: FilesizeConstraintsType,\n acceptedFiles: Array<string>,\n };\n _progressHandler: ProgressHandler;\n _origin: string = \"\";\n _contextPath: string = getBasePathModularUI();\n\n constructor(\n uploadConstraints: {\n fileTypes: FiletypeConstraintsType,\n maxFileSize: FilesizeConstraintsType,\n acceptedFiles: Array<string>,\n },\n progressHandler: ProgressHandler,\n options?: UploadRequestOptions,\n ) {\n this._uploadConstraints = uploadConstraints;\n this._progressHandler = progressHandler;\n this._origin = options?.origin || \"\";\n this._contextPath = options?.contextPath || getBasePathModularUI();\n }\n\n /**\n */\n getFileExtension(file: File): string {\n return file.name.split(\".\").pop().toLowerCase();\n }\n\n /**\n */\n isNotAllowedFileType(file: File): boolean {\n const allowedFileTypes = this._uploadConstraints.fileTypes;\n\n if (allowedFileTypes.length > 0) {\n const fileExtension = this.getFileExtension(file);\n\n return !allowedFileTypes.some((fileType) =>\n fileType.extensions.includes(fileExtension),\n );\n }\n\n return false;\n }\n\n /**\n */\n exceedsMaxFileSize(file: File): boolean {\n const maxFileSize = this._uploadConstraints?.maxFileSize?.fileSize ?? -1;\n return maxFileSize > -1 && file.size > maxFileSize;\n }\n\n /**\n */\n uploadFile(file: File): Promise<UploadResponse> {\n const maxFileSize = this._uploadConstraints?.maxFileSize?.fileSize ?? -1;\n\n if (\n getSetting(\"USE_CLIENTSIDE_VALIDATION\") &&\n this.exceedsMaxFileSize(file)\n ) {\n this._progressHandler(file, { error: \"errorExceedsMaxFileSize\" });\n return Promise.reject(\n new ErrorModel(\n \"Constraint.File.MaxFileSizeExceeded\",\n \"Maximum file upload size is ${max-filesize}\",\n {\n \"max-filesize\": maxFileSize,\n },\n true,\n ),\n );\n }\n\n if (\n getSetting(\"USE_CLIENTSIDE_VALIDATION\") &&\n this.isNotAllowedFileType(file)\n ) {\n this._progressHandler(file, { error: \"errorExtensionNotAllowed\" });\n return Promise.reject(\n new ErrorModel(\n \"Constraint.File.InvalidExtension\",\n \"Allowed extensions are: ${extensions}\",\n {\n extension: this.getFileExtension(file),\n extensions: this._uploadConstraints.fileTypes.join(\", \"),\n },\n true,\n ),\n );\n }\n\n return xhr({\n url: getUploadPath(this._contextPath, this._origin),\n method: HTTP_METHODS.POST,\n headers: {\n \"Content-Type\": file.type,\n \"x-filename\": encodeURIComponent(file.name),\n \"x-filesize\": file.size.toString(),\n },\n onProgress: (e: ProgressEvent) => {\n if (this._progressHandler && e.lengthComputable) {\n this._progressHandler(file, {\n progress: Math.ceil((e.loaded / e.total) * 100),\n });\n }\n },\n data: file,\n })\n .then((response) => {\n this._progressHandler(file, { progress: 100, token: response.token });\n return response;\n })\n .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AC,IAAI,CAACe,YAAY,EAAE,IAAI,CAACF,OAAO,CAAC;MACnDgC,MAAM,EAAE5C,YAAY,CAAC6C,IAAI;MACzBC,OAAO,EAAE;QACP,cAAc,EAAE7B,IAAI,CAAC8B,IAAI;QACzB,YAAY,EAAEC,kBAAkB,CAAC/B,IAAI,CAACC,IAAI,CAAC;QAC3C,YAAY,EAAED,IAAI,CAACmB,IAAI,CAACa,QAAQ,CAAC;MACnC,CAAC;MACDC,UAAU,EAAGC,CAAgB,IAAK;QAChC,IAAI,IAAI,CAACxC,gBAAgB,IAAIwC,CAAC,CAACC,gBAAgB,EAAE;UAC/C,IAAI,CAACzC,gBAAgB,CAACM,IAAI,EAAE;YAC1BoC,QAAQ,EAAEC,IAAI,CAACC,IAAI,CAAEJ,CAAC,CAACK,MAAM,GAAGL,CAAC,CAACM,KAAK,GAAI,GAAG;UAChD,CAAC,CAAC;QACJ;MACF,CAAC;MACDC,IAAI,EAAEzC;IACR,CAAC,CAAC,CACC0C,IAAI,CAAEC,QAAQ,IAAK;MAClB,IAAI,CAACjD,gBAAgB,CAACM,IAAI,EAAE;QAAEoC,QAAQ,EAAE,GAAG;QAAEQ,KAAK,EAAED,QAAQ,CAACC;MAAM,CAAC,CAAC;MACrE,OAAOD,QAAQ;IACjB,CAAC,CAAC,CACDE,KAAK,CAAEX,CAAC,IAAKZ,QAAA,CAAQC,MAAM,CAAC,IAAIrC,aAAa,CAACgD,CAAC,CAAC,CAAC,CAAC;EACvD;AACF;AAEA,eAAe/C,aAAa","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import _trimInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/trim";
2
2
  import _URLSearchParams from "@babel/runtime-corejs3/core-js-stable/url-search-params";
3
3
  // eslint-disable-next-line react/no-deprecated
4
- import { hydrate, render } from "react-dom";
4
+ import { hydrateRoot, createRoot } from "react-dom/client";
5
5
  import { has } from "../utils/helpers/objects";
6
6
  import setImmediate from "setimmediate";
7
7
  import Cache from "../utils/browser/Cache";
@@ -177,9 +177,10 @@ export const addContentLoadedEvent = (store, routerHistory, theme, render, Error
177
177
  const mountClient = (applicationNode, element) => {
178
178
  const isSSR = applicationNode.querySelector(".application");
179
179
  if (isSSR) {
180
- hydrate(element, applicationNode);
180
+ hydrateRoot(element, applicationNode);
181
181
  } else {
182
- render(element, applicationNode);
182
+ const root = createRoot(element);
183
+ root.render(applicationNode);
183
184
  }
184
185
  };
185
186
 
@@ -1,6 +1,6 @@
1
1
  // @flow
2
2
  // eslint-disable-next-line react/no-deprecated
3
- import { hydrate, render } from "react-dom";
3
+ import { hydrateRoot, createRoot } from "react-dom/client";
4
4
 
5
5
  import { has } from "../utils/helpers/objects";
6
6
  import setImmediate from "setimmediate";
@@ -253,9 +253,10 @@ const mountClient = (
253
253
  ) => {
254
254
  const isSSR = applicationNode.querySelector(".application");
255
255
  if (isSSR) {
256
- hydrate(element, applicationNode);
256
+ hydrateRoot(element, applicationNode);
257
257
  } else {
258
- render(element, applicationNode);
258
+ const root = createRoot(element);
259
+ root.render(applicationNode);
259
260
  }
260
261
  };
261
262
 
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":["hydrate","render","has","setImmediate","Cache","xhr","createBrowserHistory","configureStore","rehydrate","getBasePathModularUI","getBasePathServer","getSetting","setAllContentInDataSetting","setDateTimeSettings","setLoginPreferences","showXHRErrorNotification","handleError","loginSuccess","updateEntryDate","locationChange","replace","JsonParseException","FetchException","Init","handleBeforeRenderHooks","jsx","_jsx","parseDataToJSON","data","JSON","parse","error","getDataFromServer","_context","dataElement","document","querySelector","Error","_trimInstanceProperty","textContent","call","setUnhandledRejectionEvent","store","window","onunhandledrejection","event","detail","errorMessage","reason","message","toString","dispatch","handleRedirectURI","urlParams","_URLSearchParams","location","search","redirectURI","get","url","catch","e","id","LOGIN_PATH","from","pathname","modal","setModelCatalogEntryDate","entryDateFromUrl","hasItem","getItem","setupClient","customReducers","arguments","length","undefined","beforeRenderHooks","contextPath","clear","browserHistory","basename","routerHistory","getState","loadOtherBrowserTabs","response","listen","action","body","className","addContentLoadedEvent","theme","ErrorFallbackComponent","mount","addEventListener","applicationNode","children","mountClient","element","isSSR","client","_ref"],"sources":["../../src/react-client/client.js"],"sourcesContent":["// @flow\n// eslint-disable-next-line react/no-deprecated\nimport { hydrate, render } from \"react-dom\";\n\nimport { has } from \"../utils/helpers/objects\";\nimport setImmediate from \"setimmediate\";\n\nimport Cache from \"../utils/browser/Cache\";\n\nimport xhr from \"../utils/fetch/xhr\";\n\nimport { createBrowserHistory } from \"history\";\nimport configureStore from \"../redux/store/configureStore\";\n\nimport rehydrate from \"./rehydrate\";\nimport {\n getBasePathModularUI,\n getBasePathServer,\n getSetting,\n} from \"../constants/Settings\";\n\nimport {\n setAllContentInDataSetting,\n setDateTimeSettings,\n setLoginPreferences,\n} from \"../redux/actions/Preferences\";\nimport { showXHRErrorNotification } from \"../redux/actions/Notification\";\nimport { handleError } from \"../redux/actions/Error\";\nimport { loginSuccess } from \"../redux/actions/SignIn\";\nimport { updateEntryDate } from \"../redux/actions/ModelCatalog\";\n\nimport { locationChange, replace } from \"../redux/_router/RouterActions\";\n\nimport { JsonParseException, FetchException } from \"../exceptions\";\n\nimport { Init } from \"./Init\";\n\nimport { handleBeforeRenderHooks } from \"../redux/store/beforeRenderHooks\";\n\nimport type {\n ComponentType,\n Element as ReactElement,\n ElementType,\n} from \"react\";\nimport type { Theme } from \"../react-theme/types\";\nimport type { CustomReducers, ReduxStore } from \"../redux/types\";\nimport type { RouterHistory } from \"react-router\";\nimport type { BeforeRenderHook } from \"../redux/store/beforeRenderHooks\";\nimport type { Props as FallbackProps } from \"../react/ErrorBoundaryFallback\";\n\ntype RenderFunction = () => ReactElement<ElementType>;\ntype MountFunction = (\n applicationNode: Element,\n element: ReactElement<ElementType>,\n) => void;\ntype Props = {\n customReducers?: CustomReducers,\n theme?: Theme | Array<Theme>,\n render: RenderFunction,\n mount: MountFunction,\n beforeRenderHooks?: Array<BeforeRenderHook>,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n};\n\n/*\n * deserialize serialized data from the server to provide a smooth dehydration.\n */\nconst parseDataToJSON = (data: string) => {\n try {\n return JSON.parse(data);\n } catch (error) {\n throw new JsonParseException(`Error parsing content ${data}`);\n }\n};\n\nconst getDataFromServer = () => {\n const dataElement = document.querySelector(\n 'script[type=\"application/json\"][data-app-state=\"app-json\"]',\n );\n\n if (!dataElement) {\n throw new Error(\"Error loading state, json not found\");\n } else if (dataElement.textContent.trim() === \"\") {\n return {};\n }\n\n return parseDataToJSON(dataElement.textContent);\n};\n\n/**\n */\nexport const setUnhandledRejectionEvent = (store: ReduxStore) => {\n window.onunhandledrejection = (event) => {\n if (event.detail) {\n return setImmediate(() => {\n const errorMessage = event.detail.reason.message.toString();\n\n store.dispatch(showXHRErrorNotification(errorMessage));\n throw event.detail.reason;\n });\n }\n\n return event;\n };\n};\n\n/**\n * The redirectURI querystring parameter is available when the server is redirecting an unauthorized deep link\n * @param store\n */\nconst handleRedirectURI = (store: ReduxStore) => {\n const urlParams = new URLSearchParams(window.location.search);\n const redirectURI = urlParams.get(\"redirectURI\");\n if (redirectURI) {\n xhr({ url: `${getBasePathModularUI()}${redirectURI}` }).catch((e) => {\n if (\n e.id === \"UnauthorizedException\" ||\n e.id === \"Error.NotAuthorized\" ||\n e.id === \"Error.Authentication.Required\" ||\n e.id === \"Error.Authentication.InvalidCredentials\"\n ) {\n const LOGIN_PATH = getSetting(\"LOGIN_PATH\", \"/signin\");\n store.dispatch(\n replace(LOGIN_PATH, {\n from: { pathname: redirectURI },\n modal: false,\n }),\n );\n }\n });\n }\n};\n\n/**\n */\nexport const setModelCatalogEntryDate = (store: ReduxStore) => {\n if (typeof window !== \"undefined\") {\n const entryDateFromUrl = new URLSearchParams(window.location?.search).get(\n \"entryDate\",\n );\n if (entryDateFromUrl) {\n store.dispatch(updateEntryDate(entryDateFromUrl));\n } else if (Cache.hasItem(\"ModelCatalogEntryDate\")) {\n store.dispatch(Cache.getItem(\"ModelCatalogEntryDate\"));\n }\n }\n};\n\n/**\n */\nexport const setupClient = (\n customReducers: CustomReducers = {},\n beforeRenderHooks: ?Array<BeforeRenderHook>,\n): { store: ReduxStore, routerHistory: RouterHistory } => {\n if (typeof window.contextPath === \"undefined\") {\n throw new Error(\"Missing contextPath on window object\");\n }\n\n const data = getDataFromServer();\n\n // remove all resources from cache\n Cache.clear(\"^res:\");\n\n // $FlowExpectedError\n const browserHistory: RouterHistory = createBrowserHistory({\n basename: getBasePathServer(),\n });\n const { routerHistory, store } = configureStore(\n browserHistory,\n customReducers,\n rehydrate(data),\n );\n\n handleRedirectURI(store);\n setModelCatalogEntryDate(store);\n\n setAllContentInDataSetting(store.getState());\n setLoginPreferences(store.getState());\n setDateTimeSettings(store.getState());\n\n // load existing cache from other browser tabs\n Cache.loadOtherBrowserTabs(() => {\n if (Cache.getItem(\"auth\")) {\n store.dispatch(loginSuccess());\n }\n });\n\n if (has(data, \"error.name\")) {\n const error = new FetchException(data?.error?.response);\n store.dispatch(handleError(error));\n }\n\n if (Cache.getItem(\"auth\")) {\n store.dispatch(loginSuccess());\n }\n\n // listen to history change and update the redux router store\n routerHistory.listen((location, action) => {\n store.dispatch(locationChange(location, action));\n });\n\n setUnhandledRejectionEvent(store);\n\n if (document.body) {\n document.body.className = \"js\";\n }\n\n if (beforeRenderHooks) {\n handleBeforeRenderHooks(beforeRenderHooks, { store });\n }\n\n return { store, routerHistory };\n};\n\n/**\n */\nexport const addContentLoadedEvent = (\n store: ReduxStore,\n routerHistory: RouterHistory,\n theme?: Theme | Array<Theme>,\n render: RenderFunction,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n mount: MountFunction,\n) => {\n window.addEventListener(\"DOMContentLoaded\", () => {\n const applicationNode = document.querySelector(\"#application\");\n if (!applicationNode) {\n throw new Error(\n \"No DOM element with id application found to attach client to\",\n );\n }\n\n mount(\n applicationNode,\n <Init\n store={store}\n routerHistory={routerHistory}\n contextPath={window.contextPath}\n theme={theme}\n ErrorFallbackComponent={ErrorFallbackComponent}\n >\n {render()}\n </Init>,\n );\n });\n};\n\n/**\n */\nconst mountClient = (\n applicationNode: Element,\n element: ReactElement<ElementType>,\n) => {\n const isSSR = applicationNode.querySelector(\".application\");\n if (isSSR) {\n hydrate(element, applicationNode);\n } else {\n render(element, applicationNode);\n }\n};\n\n/**\n * Mount the webapplication to the DOM, setup redux store and caches, add unhandledRejectionEvent, used client side when JavaScript is enabled.\n */\nexport const client = ({\n customReducers,\n theme,\n render,\n beforeRenderHooks,\n ErrorFallbackComponent,\n mount,\n}: Props) => {\n const { store, routerHistory } = setupClient(\n customReducers,\n beforeRenderHooks,\n );\n\n addContentLoadedEvent(\n store,\n routerHistory,\n theme,\n render,\n ErrorFallbackComponent,\n mount ?? mountClient,\n );\n};\n"],"mappings":";;AACA;AACA,SAASA,OAAO,EAAEC,MAAM,QAAQ,WAAW;AAE3C,SAASC,GAAG,QAAQ,0BAA0B;AAC9C,OAAOC,YAAY,MAAM,cAAc;AAEvC,OAAOC,KAAK,MAAM,wBAAwB;AAE1C,OAAOC,GAAG,MAAM,oBAAoB;AAEpC,SAASC,oBAAoB,QAAQ,SAAS;AAC9C,OAAOC,cAAc,MAAM,+BAA+B;AAE1D,OAAOC,SAAS,MAAM,aAAa;AACnC,SACEC,oBAAoB,EACpBC,iBAAiB,EACjBC,UAAU,QACL,uBAAuB;AAE9B,SACEC,0BAA0B,EAC1BC,mBAAmB,EACnBC,mBAAmB,QACd,8BAA8B;AACrC,SAASC,wBAAwB,QAAQ,+BAA+B;AACxE,SAASC,WAAW,QAAQ,wBAAwB;AACpD,SAASC,YAAY,QAAQ,yBAAyB;AACtD,SAASC,eAAe,QAAQ,+BAA+B;AAE/D,SAASC,cAAc,EAAEC,OAAO,QAAQ,gCAAgC;AAExE,SAASC,kBAAkB,EAAEC,cAAc,QAAQ,eAAe;AAElE,SAASC,IAAI,QAAQ,QAAQ;AAE7B,SAASC,uBAAuB,QAAQ,kCAAkC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E9C9F,MAAM,CAAC;IAAC,CACL,CACR,CAAC;EACH,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA,MAAM+F,WAAW,GAAGA,CAClBF,eAAwB,EACxBG,OAAkC,KAC/B;EACH,MAAMC,KAAK,GAAGJ,eAAe,CAAC1D,aAAa,CAAC,cAAc,CAAC;EAC3D,IAAI8D,KAAK,EAAE;IACTlG,OAAO,CAACiG,OAAO,EAAEH,eAAe,CAAC;EACnC,CAAC,MAAM;IACL7F,MAAM,CAACgG,OAAO,EAAEH,eAAe,CAAC;EAClC;AACF,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMK,MAAM,GAAGC,IAAA,IAOT;EAAA,IAPU;IACrB5B,cAAc;IACdkB,KAAK;IACLzF,MAAM;IACN2E,iBAAiB;IACjBe,sBAAsB;IACtBC;EACK,CAAC,GAAAQ,IAAA;EACN,MAAM;IAAE1D,KAAK;IAAEuC;EAAc,CAAC,GAAGV,WAAW,CAC1CC,cAAc,EACdI,iBACF,CAAC;EAEDa,qBAAqB,CACnB/C,KAAK,EACLuC,aAAa,EACbS,KAAK,EACLzF,MAAM,EACN0F,sBAAsB,EACtBC,KAAK,IAAII,WACX,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"client.js","names":["hydrateRoot","createRoot","has","setImmediate","Cache","xhr","createBrowserHistory","configureStore","rehydrate","getBasePathModularUI","getBasePathServer","getSetting","setAllContentInDataSetting","setDateTimeSettings","setLoginPreferences","showXHRErrorNotification","handleError","loginSuccess","updateEntryDate","locationChange","replace","JsonParseException","FetchException","Init","handleBeforeRenderHooks","jsx","_jsx","parseDataToJSON","data","JSON","parse","error","getDataFromServer","_context","dataElement","document","querySelector","Error","_trimInstanceProperty","textContent","call","setUnhandledRejectionEvent","store","window","onunhandledrejection","event","detail","errorMessage","reason","message","toString","dispatch","handleRedirectURI","urlParams","_URLSearchParams","location","search","redirectURI","get","url","catch","e","id","LOGIN_PATH","from","pathname","modal","setModelCatalogEntryDate","entryDateFromUrl","hasItem","getItem","setupClient","customReducers","arguments","length","undefined","beforeRenderHooks","contextPath","clear","browserHistory","basename","routerHistory","getState","loadOtherBrowserTabs","response","listen","action","body","className","addContentLoadedEvent","theme","render","ErrorFallbackComponent","mount","addEventListener","applicationNode","children","mountClient","element","isSSR","root","client","_ref"],"sources":["../../src/react-client/client.js"],"sourcesContent":["// @flow\n// eslint-disable-next-line react/no-deprecated\nimport { hydrateRoot, createRoot } from \"react-dom/client\";\n\nimport { has } from \"../utils/helpers/objects\";\nimport setImmediate from \"setimmediate\";\n\nimport Cache from \"../utils/browser/Cache\";\n\nimport xhr from \"../utils/fetch/xhr\";\n\nimport { createBrowserHistory } from \"history\";\nimport configureStore from \"../redux/store/configureStore\";\n\nimport rehydrate from \"./rehydrate\";\nimport {\n getBasePathModularUI,\n getBasePathServer,\n getSetting,\n} from \"../constants/Settings\";\n\nimport {\n setAllContentInDataSetting,\n setDateTimeSettings,\n setLoginPreferences,\n} from \"../redux/actions/Preferences\";\nimport { showXHRErrorNotification } from \"../redux/actions/Notification\";\nimport { handleError } from \"../redux/actions/Error\";\nimport { loginSuccess } from \"../redux/actions/SignIn\";\nimport { updateEntryDate } from \"../redux/actions/ModelCatalog\";\n\nimport { locationChange, replace } from \"../redux/_router/RouterActions\";\n\nimport { JsonParseException, FetchException } from \"../exceptions\";\n\nimport { Init } from \"./Init\";\n\nimport { handleBeforeRenderHooks } from \"../redux/store/beforeRenderHooks\";\n\nimport type {\n ComponentType,\n Element as ReactElement,\n ElementType,\n} from \"react\";\nimport type { Theme } from \"../react-theme/types\";\nimport type { CustomReducers, ReduxStore } from \"../redux/types\";\nimport type { RouterHistory } from \"react-router\";\nimport type { BeforeRenderHook } from \"../redux/store/beforeRenderHooks\";\nimport type { Props as FallbackProps } from \"../react/ErrorBoundaryFallback\";\n\ntype RenderFunction = () => ReactElement<ElementType>;\ntype MountFunction = (\n applicationNode: Element,\n element: ReactElement<ElementType>,\n) => void;\ntype Props = {\n customReducers?: CustomReducers,\n theme?: Theme | Array<Theme>,\n render: RenderFunction,\n mount: MountFunction,\n beforeRenderHooks?: Array<BeforeRenderHook>,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n};\n\n/*\n * deserialize serialized data from the server to provide a smooth dehydration.\n */\nconst parseDataToJSON = (data: string) => {\n try {\n return JSON.parse(data);\n } catch (error) {\n throw new JsonParseException(`Error parsing content ${data}`);\n }\n};\n\nconst getDataFromServer = () => {\n const dataElement = document.querySelector(\n 'script[type=\"application/json\"][data-app-state=\"app-json\"]',\n );\n\n if (!dataElement) {\n throw new Error(\"Error loading state, json not found\");\n } else if (dataElement.textContent.trim() === \"\") {\n return {};\n }\n\n return parseDataToJSON(dataElement.textContent);\n};\n\n/**\n */\nexport const setUnhandledRejectionEvent = (store: ReduxStore) => {\n window.onunhandledrejection = (event) => {\n if (event.detail) {\n return setImmediate(() => {\n const errorMessage = event.detail.reason.message.toString();\n\n store.dispatch(showXHRErrorNotification(errorMessage));\n throw event.detail.reason;\n });\n }\n\n return event;\n };\n};\n\n/**\n * The redirectURI querystring parameter is available when the server is redirecting an unauthorized deep link\n * @param store\n */\nconst handleRedirectURI = (store: ReduxStore) => {\n const urlParams = new URLSearchParams(window.location.search);\n const redirectURI = urlParams.get(\"redirectURI\");\n if (redirectURI) {\n xhr({ url: `${getBasePathModularUI()}${redirectURI}` }).catch((e) => {\n if (\n e.id === \"UnauthorizedException\" ||\n e.id === \"Error.NotAuthorized\" ||\n e.id === \"Error.Authentication.Required\" ||\n e.id === \"Error.Authentication.InvalidCredentials\"\n ) {\n const LOGIN_PATH = getSetting(\"LOGIN_PATH\", \"/signin\");\n store.dispatch(\n replace(LOGIN_PATH, {\n from: { pathname: redirectURI },\n modal: false,\n }),\n );\n }\n });\n }\n};\n\n/**\n */\nexport const setModelCatalogEntryDate = (store: ReduxStore) => {\n if (typeof window !== \"undefined\") {\n const entryDateFromUrl = new URLSearchParams(window.location?.search).get(\n \"entryDate\",\n );\n if (entryDateFromUrl) {\n store.dispatch(updateEntryDate(entryDateFromUrl));\n } else if (Cache.hasItem(\"ModelCatalogEntryDate\")) {\n store.dispatch(Cache.getItem(\"ModelCatalogEntryDate\"));\n }\n }\n};\n\n/**\n */\nexport const setupClient = (\n customReducers: CustomReducers = {},\n beforeRenderHooks: ?Array<BeforeRenderHook>,\n): { store: ReduxStore, routerHistory: RouterHistory } => {\n if (typeof window.contextPath === \"undefined\") {\n throw new Error(\"Missing contextPath on window object\");\n }\n\n const data = getDataFromServer();\n\n // remove all resources from cache\n Cache.clear(\"^res:\");\n\n // $FlowExpectedError\n const browserHistory: RouterHistory = createBrowserHistory({\n basename: getBasePathServer(),\n });\n const { routerHistory, store } = configureStore(\n browserHistory,\n customReducers,\n rehydrate(data),\n );\n\n handleRedirectURI(store);\n setModelCatalogEntryDate(store);\n\n setAllContentInDataSetting(store.getState());\n setLoginPreferences(store.getState());\n setDateTimeSettings(store.getState());\n\n // load existing cache from other browser tabs\n Cache.loadOtherBrowserTabs(() => {\n if (Cache.getItem(\"auth\")) {\n store.dispatch(loginSuccess());\n }\n });\n\n if (has(data, \"error.name\")) {\n const error = new FetchException(data?.error?.response);\n store.dispatch(handleError(error));\n }\n\n if (Cache.getItem(\"auth\")) {\n store.dispatch(loginSuccess());\n }\n\n // listen to history change and update the redux router store\n routerHistory.listen((location, action) => {\n store.dispatch(locationChange(location, action));\n });\n\n setUnhandledRejectionEvent(store);\n\n if (document.body) {\n document.body.className = \"js\";\n }\n\n if (beforeRenderHooks) {\n handleBeforeRenderHooks(beforeRenderHooks, { store });\n }\n\n return { store, routerHistory };\n};\n\n/**\n */\nexport const addContentLoadedEvent = (\n store: ReduxStore,\n routerHistory: RouterHistory,\n theme?: Theme | Array<Theme>,\n render: RenderFunction,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n mount: MountFunction,\n) => {\n window.addEventListener(\"DOMContentLoaded\", () => {\n const applicationNode = document.querySelector(\"#application\");\n if (!applicationNode) {\n throw new Error(\n \"No DOM element with id application found to attach client to\",\n );\n }\n\n mount(\n applicationNode,\n <Init\n store={store}\n routerHistory={routerHistory}\n contextPath={window.contextPath}\n theme={theme}\n ErrorFallbackComponent={ErrorFallbackComponent}\n >\n {render()}\n </Init>,\n );\n });\n};\n\n/**\n */\nconst mountClient = (\n applicationNode: Element,\n element: ReactElement<ElementType>,\n) => {\n const isSSR = applicationNode.querySelector(\".application\");\n if (isSSR) {\n hydrateRoot(element, applicationNode);\n } else {\n const root = createRoot(element);\n root.render(applicationNode);\n }\n};\n\n/**\n * Mount the webapplication to the DOM, setup redux store and caches, add unhandledRejectionEvent, used client side when JavaScript is enabled.\n */\nexport const client = ({\n customReducers,\n theme,\n render,\n beforeRenderHooks,\n ErrorFallbackComponent,\n mount,\n}: Props) => {\n const { store, routerHistory } = setupClient(\n customReducers,\n beforeRenderHooks,\n );\n\n addContentLoadedEvent(\n store,\n routerHistory,\n theme,\n render,\n ErrorFallbackComponent,\n mount ?? mountClient,\n );\n};\n"],"mappings":";;AACA;AACA,SAASA,WAAW,EAAEC,UAAU,QAAQ,kBAAkB;AAE1D,SAASC,GAAG,QAAQ,0BAA0B;AAC9C,OAAOC,YAAY,MAAM,cAAc;AAEvC,OAAOC,KAAK,MAAM,wBAAwB;AAE1C,OAAOC,GAAG,MAAM,oBAAoB;AAEpC,SAASC,oBAAoB,QAAQ,SAAS;AAC9C,OAAOC,cAAc,MAAM,+BAA+B;AAE1D,OAAOC,SAAS,MAAM,aAAa;AACnC,SACEC,oBAAoB,EACpBC,iBAAiB,EACjBC,UAAU,QACL,uBAAuB;AAE9B,SACEC,0BAA0B,EAC1BC,mBAAmB,EACnBC,mBAAmB,QACd,8BAA8B;AACrC,SAASC,wBAAwB,QAAQ,+BAA+B;AACxE,SAASC,WAAW,QAAQ,wBAAwB;AACpD,SAASC,YAAY,QAAQ,yBAAyB;AACtD,SAASC,eAAe,QAAQ,+BAA+B;AAE/D,SAASC,cAAc,EAAEC,OAAO,QAAQ,gCAAgC;AAEx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BJ,WAAW,EAAElC,MAAM,CAACkC,WAAY;MAChCa,KAAK,EAAEA,KAAM;MACbE,sBAAsB,EAAEA,sBAAuB;MAAAI,QAAA,EAE9CL,MAAM,CAAC;IAAC,CACL,CACR,CAAC;EACH,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA,MAAMM,WAAW,GAAGA,CAClBF,eAAwB,EACxBG,OAAkC,KAC/B;EACH,MAAMC,KAAK,GAAGJ,eAAe,CAAC3D,aAAa,CAAC,cAAc,CAAC;EAC3D,IAAI+D,KAAK,EAAE;IACTnG,WAAW,CAACkG,OAAO,EAAEH,eAAe,CAAC;EACvC,CAAC,MAAM;IACL,MAAMK,IAAI,GAAGnG,UAAU,CAACiG,OAAO,CAAC;IAChCE,IAAI,CAACT,MAAM,CAACI,eAAe,CAAC;EAC9B;AACF,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMM,MAAM,GAAGC,IAAA,IAOT;EAAA,IAPU;IACrB9B,cAAc;IACdkB,KAAK;IACLC,MAAM;IACNf,iBAAiB;IACjBgB,sBAAsB;IACtBC;EACK,CAAC,GAAAS,IAAA;EACN,MAAM;IAAE5D,KAAK;IAAEuC;EAAc,CAAC,GAAGV,WAAW,CAC1CC,cAAc,EACdI,iBACF,CAAC;EAEDa,qBAAqB,CACnB/C,KAAK,EACLuC,aAAa,EACbS,KAAK,EACLC,MAAM,EACNC,sBAAsB,EACtBC,KAAK,IAAII,WACX,CAAC;AACH,CAAC","ignoreList":[]}
@@ -11,6 +11,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/he
11
11
  var _constants = require("../constants");
12
12
  var _xhr = _interopRequireDefault(require("../utils/fetch/xhr"));
13
13
  var _ErrorModel = _interopRequireDefault(require("../models/error/ErrorModel"));
14
+ var _models = require("../models");
14
15
  /**
15
16
  * Upload a file to the upload file service of Be Informed
16
17
  */
@@ -57,7 +58,7 @@ class UploadRequest {
57
58
  */
58
59
  uploadFile(file) {
59
60
  const maxFileSize = this._uploadConstraints?.maxFileSize?.fileSize ?? -1;
60
- if (this.exceedsMaxFileSize(file)) {
61
+ if ((0, _constants.getSetting)("USE_CLIENTSIDE_VALIDATION") && this.exceedsMaxFileSize(file)) {
61
62
  this._progressHandler(file, {
62
63
  error: "errorExceedsMaxFileSize"
63
64
  });
@@ -65,7 +66,7 @@ class UploadRequest {
65
66
  "max-filesize": maxFileSize
66
67
  }, true));
67
68
  }
68
- if (this.isNotAllowedFileType(file)) {
69
+ if ((0, _constants.getSetting)("USE_CLIENTSIDE_VALIDATION") && this.isNotAllowedFileType(file)) {
69
70
  this._progressHandler(file, {
70
71
  error: "errorExtensionNotAllowed"
71
72
  });
@@ -96,7 +97,7 @@ class UploadRequest {
96
97
  token: response.token
97
98
  });
98
99
  return response;
99
- });
100
+ }).catch(e => _promise.default.reject(new _models.ErrorResponse(e)));
100
101
  }
101
102
  }
102
103
  var _default = exports.default = UploadRequest;
@@ -1 +1 @@
1
- {"version":3,"file":"UploadRequest.js","names":["_constants","require","_xhr","_interopRequireDefault","_ErrorModel","UploadRequest","constructor","uploadConstraints","progressHandler","options","_defineProperty2","default","getBasePathModularUI","_uploadConstraints","_progressHandler","_origin","origin","_contextPath","contextPath","getFileExtension","file","name","split","pop","toLowerCase","isNotAllowedFileType","allowedFileTypes","fileTypes","length","fileExtension","some","fileType","_context","_includes","extensions","call","exceedsMaxFileSize","maxFileSize","fileSize","size","uploadFile","error","_promise","reject","ErrorModel","extension","join","xhr","url","getUploadPath","method","HTTP_METHODS","POST","headers","type","encodeURIComponent","toString","onProgress","e","lengthComputable","progress","Math","ceil","loaded","total","data","then","response","token","_default","exports"],"sources":["../../src/modularui/UploadRequest.js"],"sourcesContent":["// @flow\nimport {\n getBasePathModularUI,\n getUploadPath,\n HTTP_METHODS,\n} from \"../constants\";\n\nimport xhr from \"../utils/fetch/xhr\";\n\nimport type {\n FilesizeConstraintsType,\n FiletypeConstraintsType,\n} from \"../models\";\nimport ErrorModel from \"../models/error/ErrorModel\";\n\ntype ProgressHandler = (file: File, uploadInfo: Object) => void;\n\ntype UploadRequestOptions = {\n origin?: string,\n contextPath?: string,\n};\n\ntype UploadResponse = {\n token: string,\n};\n\n/**\n * Upload a file to the upload file service of Be Informed\n */\nclass UploadRequest {\n _uploadConstraints: {\n fileTypes: FiletypeConstraintsType,\n maxFileSize: FilesizeConstraintsType,\n acceptedFiles: Array<string>,\n };\n _progressHandler: ProgressHandler;\n _origin: string = \"\";\n _contextPath: string = getBasePathModularUI();\n\n constructor(\n uploadConstraints: {\n fileTypes: FiletypeConstraintsType,\n maxFileSize: FilesizeConstraintsType,\n acceptedFiles: Array<string>,\n },\n progressHandler: ProgressHandler,\n options?: UploadRequestOptions,\n ) {\n this._uploadConstraints = uploadConstraints;\n this._progressHandler = progressHandler;\n this._origin = options?.origin || \"\";\n this._contextPath = options?.contextPath || getBasePathModularUI();\n }\n\n /**\n */\n getFileExtension(file: File): string {\n return file.name.split(\".\").pop().toLowerCase();\n }\n\n /**\n */\n isNotAllowedFileType(file: File): boolean {\n const allowedFileTypes = this._uploadConstraints.fileTypes;\n\n if (allowedFileTypes.length > 0) {\n const fileExtension = this.getFileExtension(file);\n\n return !allowedFileTypes.some((fileType) =>\n fileType.extensions.includes(fileExtension),\n );\n }\n\n return false;\n }\n\n /**\n */\n exceedsMaxFileSize(file: File): boolean {\n const maxFileSize = this._uploadConstraints?.maxFileSize?.fileSize ?? -1;\n return maxFileSize > -1 && file.size > maxFileSize;\n }\n\n /**\n */\n uploadFile(file: File): Promise<UploadResponse> {\n const maxFileSize = this._uploadConstraints?.maxFileSize?.fileSize ?? -1;\n\n if (this.exceedsMaxFileSize(file)) {\n this._progressHandler(file, { error: \"errorExceedsMaxFileSize\" });\n return Promise.reject(\n new ErrorModel(\n \"Constraint.File.MaxFileSizeExceeded\",\n \"Maximum file upload size is ${max-filesize}\",\n {\n \"max-filesize\": maxFileSize,\n },\n true,\n ),\n );\n }\n\n if (this.isNotAllowedFileType(file)) {\n this._progressHandler(file, { error: \"errorExtensionNotAllowed\" });\n return Promise.reject(\n new ErrorModel(\n \"Constraint.File.InvalidExtension\",\n \"Allowed extensions are: ${extensions}\",\n {\n extension: this.getFileExtension(file),\n extensions: this._uploadConstraints.fileTypes.join(\", \"),\n },\n true,\n ),\n );\n }\n\n return xhr({\n url: getUploadPath(this._contextPath, this._origin),\n method: HTTP_METHODS.POST,\n headers: {\n \"Content-Type\": file.type,\n \"x-filename\": encodeURIComponent(file.name),\n \"x-filesize\": file.size.toString(),\n },\n onProgress: (e: ProgressEvent) => {\n if (this._progressHandler && e.lengthComputable) {\n this._progressHandler(file, {\n progress: Math.ceil((e.loaded / e.total) * 100),\n });\n }\n },\n data: file,\n }).then((response) => {\n this._progressHandler(file, { progress: 100, token: response.token });\n return response;\n });\n }\n}\n\nexport default UploadRequest;\n"],"mappings":";;;;;;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AAMA,IAAAC,IAAA,GAAAC,sBAAA,CAAAF,OAAA;AAMA,IAAAG,WAAA,GAAAD,sBAAA,CAAAF,OAAA;AAaA;AACA;AACA;AACA,MAAMI,aAAa,CAAC;EAUlBC,WAAWA,CACTC,iBAIC,EACDC,eAAgC,EAChCC,OAA8B,EAC9B;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA,mBAXgB,EAAE;IAAA,IAAAD,gBAAA,CAAAC,OAAA,wBACG,IAAAC,+BAAoB,EAAC,CAAC;IAW3C,IAAI,CAACC,kBAAkB,GAAGN,iBAAiB;IAC3C,IAAI,CAACO,gBAAgB,GAAGN,eAAe;IACvC,IAAI,CAACO,OAAO,GAAGN,OAAO,EAAEO,MAAM,IAAI,EAAE;IACpC,IAAI,CAACC,YAAY,GAAGR,OAAO,EAAES,WAAW,IAAI,IAAAN,+BAAoB,EAAC,CAAC;EACpE;;EAEA;AACF;EACEO,gBAAgBA,CAACC,IAAU,EAAU;IACnC,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AK,EAAED,QAAQ,CAACC;MAAM,CAAC,CAAC;MACrE,OAAOD,QAAQ;IACjB,CAAC,CAAC;EACJ;AACF;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAA3D,OAAA,GAEcN,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"UploadRequest.js","names":["_constants","require","_xhr","_interopRequireDefault","_ErrorModel","_models","UploadRequest","constructor","uploadConstraints","progressHandler","options","_defineProperty2","default","getBasePathModularUI","_uploadConstraints","_progressHandler","_origin","origin","_contextPath","contextPath","getFileExtension","file","name","split","pop","toLowerCase","isNotAllowedFileType","allowedFileTypes","fileTypes","length","fileExtension","some","fileType","_context","_includes","extensions","call","exceedsMaxFileSize","maxFileSize","fileSize","size","uploadFile","getSetting","error","_promise","reject","ErrorModel","extension","join","xhr","url","getUploadPath","method","HTTP_METHODS","POST","headers","type","encodeURIComponent","toString","onProgress","e","lengthComputable","progress","Math","ceil","loaded","total","data","then","response","token","catch","ErrorResponse","_default","exports"],"sources":["../../src/modularui/UploadRequest.js"],"sourcesContent":["// @flow\nimport {\n getBasePathModularUI,\n getSetting,\n getUploadPath,\n HTTP_METHODS,\n} from \"../constants\";\n\nimport xhr from \"../utils/fetch/xhr\";\n\nimport type {\n FilesizeConstraintsType,\n FiletypeConstraintsType,\n} from \"../models\";\nimport ErrorModel from \"../models/error/ErrorModel\";\nimport { ErrorResponse } from \"../models\";\n\ntype ProgressHandler = (file: File, uploadInfo: Object) => void;\n\ntype UploadRequestOptions = {\n origin?: string,\n contextPath?: string,\n};\n\ntype UploadResponse = {\n token: string,\n};\n\n/**\n * Upload a file to the upload file service of Be Informed\n */\nclass UploadRequest {\n _uploadConstraints: {\n fileTypes: FiletypeConstraintsType,\n maxFileSize: FilesizeConstraintsType,\n acceptedFiles: Array<string>,\n };\n _progressHandler: ProgressHandler;\n _origin: string = \"\";\n _contextPath: string = getBasePathModularUI();\n\n constructor(\n uploadConstraints: {\n fileTypes: FiletypeConstraintsType,\n maxFileSize: FilesizeConstraintsType,\n acceptedFiles: Array<string>,\n },\n progressHandler: ProgressHandler,\n options?: UploadRequestOptions,\n ) {\n this._uploadConstraints = uploadConstraints;\n this._progressHandler = progressHandler;\n this._origin = options?.origin || \"\";\n this._contextPath = options?.contextPath || getBasePathModularUI();\n }\n\n /**\n */\n getFileExtension(file: File): string {\n return file.name.split(\".\").pop().toLowerCase();\n }\n\n /**\n */\n isNotAllowedFileType(file: File): boolean {\n const allowedFileTypes = this._uploadConstraints.fileTypes;\n\n if (allowedFileTypes.length > 0) {\n const fileExtension = this.getFileExtension(file);\n\n return !allowedFileTypes.some((fileType) =>\n fileType.extensions.includes(fileExtension),\n );\n }\n\n return false;\n }\n\n /**\n */\n exceedsMaxFileSize(file: File): boolean {\n const maxFileSize = this._uploadConstraints?.maxFileSize?.fileSize ?? -1;\n return maxFileSize > -1 && file.size > maxFileSize;\n }\n\n /**\n */\n uploadFile(file: File): Promise<UploadResponse> {\n const maxFileSize = this._uploadConstraints?.maxFileSize?.fileSize ?? -1;\n\n if (\n getSetting(\"USE_CLIENTSIDE_VALIDATION\") &&\n this.exceedsMaxFileSize(file)\n ) {\n this._progressHandler(file, { error: \"errorExceedsMaxFileSize\" });\n return Promise.reject(\n new ErrorModel(\n \"Constraint.File.MaxFileSizeExceeded\",\n \"Maximum file upload size is ${max-filesize}\",\n {\n \"max-filesize\": maxFileSize,\n },\n true,\n ),\n );\n }\n\n if (\n getSetting(\"USE_CLIENTSIDE_VALIDATION\") &&\n this.isNotAllowedFileType(file)\n ) {\n this._progressHandler(file, { error: \"errorExtensionNotAllowed\" });\n return Promise.reject(\n new ErrorModel(\n \"Constraint.File.InvalidExtension\",\n \"Allowed extensions are: ${extensions}\",\n {\n extension: this.getFileExtension(file),\n extensions: this._uploadConstraints.fileTypes.join(\", \"),\n },\n true,\n ),\n );\n }\n\n return xhr({\n url: getUploadPath(this._contextPath, this._origin),\n method: HTTP_METHODS.POST,\n headers: {\n \"Content-Type\": file.type,\n \"x-filename\": encodeURIComponent(file.name),\n \"x-filesize\": file.size.toString(),\n },\n onProgress: (e: ProgressEvent) => {\n if (this._progressHandler && e.lengthComputable) {\n this._progressHandler(file, {\n progress: Math.ceil((e.loaded / e.total) * 100),\n });\n }\n },\n data: file,\n })\n .then((response) => {\n this._progressHandler(file, { progress: 100, token: response.token });\n return response;\n })\n .catch((e) => Promise.reject(new ErrorResponse(e)));\n }\n}\n\nexport default UploadRequest;\n"],"mappings":";;;;;;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AAOA,IAAAC,IAAA,GAAAC,sBAAA,CAAAF,OAAA;AAMA,IAAAG,WAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAaA;AACA;AACA;AACA,MAAMK,aAAa,CAAC;EAUlBC,WAAWA,CACTC,iBAIC,EACDC,eAAgC,EAChCC,OAA8B,EAC9B;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA,mBAXgB,EAAE;IAAA,IAAAD,gBAAA,CAAAC,OAAA,wBACG,IAAAC,+BAAoB,EAAC,CAAC;IAW3C,IAAI,CAACC,kBAAkB,GAAGN,iBAAiB;IAC3C,IAAI,CAACO,gBAAgB,GAAGN,eAAe;IACvC,IAAI,CAACO,OAAO,GAAGN,OAAO,EAAEO,MAAM,IAAI,EAAE;IACpC,IAAI,CAACC,YAAY,GAAGR,OAAO,EAAES,WAAW,IAAI,IAAAN,+BAAoB,EAAC,CAAC;EACpE;;EAEA;AACF;EACEO,gBAAgBA,CAACC,IAAU,EAAU;IACnC,OAAOA,IAAI,CAACC,IAAI,CAACC,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC;EACjD;;EAEA;AACF;EACEC,oBAAoBA,CAACL,IAAU,EAAW;IACxC,MAAMM,gBAAgB,GAAG,IAAI,CAACb,kBAAkB,CAACc,SA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AQiC,MAAM,CAAC,IAAI2B,qBAAa,CAACZ,CAAC,CAAC,CAAC,CAAC;EACvD;AACF;AAAC,IAAAa,QAAA,GAAAC,OAAA,CAAA9D,OAAA,GAEcN,aAAa","ignoreList":[]}
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.setupClient = exports.setUnhandledRejectionEvent = exports.setModelCatalogEntryDate = exports.client = exports.addContentLoadedEvent = void 0;
8
8
  var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
9
9
  var _urlSearchParams = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/url-search-params"));
10
- var _reactDom = require("react-dom");
10
+ var _client = require("react-dom/client");
11
11
  var _objects = require("../utils/helpers/objects");
12
12
  var _setimmediate = _interopRequireDefault(require("setimmediate"));
13
13
  var _Cache = _interopRequireDefault(require("../utils/browser/Cache"));
@@ -188,9 +188,10 @@ exports.addContentLoadedEvent = addContentLoadedEvent;
188
188
  const mountClient = (applicationNode, element) => {
189
189
  const isSSR = applicationNode.querySelector(".application");
190
190
  if (isSSR) {
191
- (0, _reactDom.hydrate)(element, applicationNode);
191
+ (0, _client.hydrateRoot)(element, applicationNode);
192
192
  } else {
193
- (0, _reactDom.render)(element, applicationNode);
193
+ const root = (0, _client.createRoot)(element);
194
+ root.render(applicationNode);
194
195
  }
195
196
  };
196
197
 
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":["_reactDom","require","_objects","_setimmediate","_interopRequireDefault","_Cache","_xhr","_history","_configureStore","_rehydrate","_Settings","_Preferences","_Notification","_Error","_SignIn","_ModelCatalog","_RouterActions","_exceptions","_Init","_beforeRenderHooks","_jsxRuntime","parseDataToJSON","data","JSON","parse","error","JsonParseException","getDataFromServer","_context","dataElement","document","querySelector","Error","_trim","default","textContent","call","setUnhandledRejectionEvent","store","window","onunhandledrejection","event","detail","setImmediate","errorMessage","reason","message","toString","dispatch","showXHRErrorNotification","exports","handleRedirectURI","urlParams","_urlSearchParams","location","search","redirectURI","get","xhr","url","getBasePathModularUI","catch","e","id","LOGIN_PATH","getSetting","replace","from","pathname","modal","setModelCatalogEntryDate","entryDateFromUrl","updateEntryDate","Cache","hasItem","getItem","setupClient","customReducers","arguments","length","undefined","beforeRenderHooks","contextPath","clear","browserHistory","createBrowserHistory","basename","getBasePathServer","routerHistory","configureStore","rehydrate","setAllContentInDataSetting","getState","setLoginPreferences","setDateTimeSettings","loadOtherBrowserTabs","loginSuccess","has","FetchException","response","handleError","listen","action","locationChange","body","className","handleBeforeRenderHooks","addContentLoadedEvent","theme","render","ErrorFallbackComponent","mount","addEventListener","applicationNode","jsx","Init","children","mountClient","element","isSSR","hydrate","client","_ref"],"sources":["../../src/react-client/client.js"],"sourcesContent":["// @flow\n// eslint-disable-next-line react/no-deprecated\nimport { hydrate, render } from \"react-dom\";\n\nimport { has } from \"../utils/helpers/objects\";\nimport setImmediate from \"setimmediate\";\n\nimport Cache from \"../utils/browser/Cache\";\n\nimport xhr from \"../utils/fetch/xhr\";\n\nimport { createBrowserHistory } from \"history\";\nimport configureStore from \"../redux/store/configureStore\";\n\nimport rehydrate from \"./rehydrate\";\nimport {\n getBasePathModularUI,\n getBasePathServer,\n getSetting,\n} from \"../constants/Settings\";\n\nimport {\n setAllContentInDataSetting,\n setDateTimeSettings,\n setLoginPreferences,\n} from \"../redux/actions/Preferences\";\nimport { showXHRErrorNotification } from \"../redux/actions/Notification\";\nimport { handleError } from \"../redux/actions/Error\";\nimport { loginSuccess } from \"../redux/actions/SignIn\";\nimport { updateEntryDate } from \"../redux/actions/ModelCatalog\";\n\nimport { locationChange, replace } from \"../redux/_router/RouterActions\";\n\nimport { JsonParseException, FetchException } from \"../exceptions\";\n\nimport { Init } from \"./Init\";\n\nimport { handleBeforeRenderHooks } from \"../redux/store/beforeRenderHooks\";\n\nimport type {\n ComponentType,\n Element as ReactElement,\n ElementType,\n} from \"react\";\nimport type { Theme } from \"../react-theme/types\";\nimport type { CustomReducers, ReduxStore } from \"../redux/types\";\nimport type { RouterHistory } from \"react-router\";\nimport type { BeforeRenderHook } from \"../redux/store/beforeRenderHooks\";\nimport type { Props as FallbackProps } from \"../react/ErrorBoundaryFallback\";\n\ntype RenderFunction = () => ReactElement<ElementType>;\ntype MountFunction = (\n applicationNode: Element,\n element: ReactElement<ElementType>,\n) => void;\ntype Props = {\n customReducers?: CustomReducers,\n theme?: Theme | Array<Theme>,\n render: RenderFunction,\n mount: MountFunction,\n beforeRenderHooks?: Array<BeforeRenderHook>,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n};\n\n/*\n * deserialize serialized data from the server to provide a smooth dehydration.\n */\nconst parseDataToJSON = (data: string) => {\n try {\n return JSON.parse(data);\n } catch (error) {\n throw new JsonParseException(`Error parsing content ${data}`);\n }\n};\n\nconst getDataFromServer = () => {\n const dataElement = document.querySelector(\n 'script[type=\"application/json\"][data-app-state=\"app-json\"]',\n );\n\n if (!dataElement) {\n throw new Error(\"Error loading state, json not found\");\n } else if (dataElement.textContent.trim() === \"\") {\n return {};\n }\n\n return parseDataToJSON(dataElement.textContent);\n};\n\n/**\n */\nexport const setUnhandledRejectionEvent = (store: ReduxStore) => {\n window.onunhandledrejection = (event) => {\n if (event.detail) {\n return setImmediate(() => {\n const errorMessage = event.detail.reason.message.toString();\n\n store.dispatch(showXHRErrorNotification(errorMessage));\n throw event.detail.reason;\n });\n }\n\n return event;\n };\n};\n\n/**\n * The redirectURI querystring parameter is available when the server is redirecting an unauthorized deep link\n * @param store\n */\nconst handleRedirectURI = (store: ReduxStore) => {\n const urlParams = new URLSearchParams(window.location.search);\n const redirectURI = urlParams.get(\"redirectURI\");\n if (redirectURI) {\n xhr({ url: `${getBasePathModularUI()}${redirectURI}` }).catch((e) => {\n if (\n e.id === \"UnauthorizedException\" ||\n e.id === \"Error.NotAuthorized\" ||\n e.id === \"Error.Authentication.Required\" ||\n e.id === \"Error.Authentication.InvalidCredentials\"\n ) {\n const LOGIN_PATH = getSetting(\"LOGIN_PATH\", \"/signin\");\n store.dispatch(\n replace(LOGIN_PATH, {\n from: { pathname: redirectURI },\n modal: false,\n }),\n );\n }\n });\n }\n};\n\n/**\n */\nexport const setModelCatalogEntryDate = (store: ReduxStore) => {\n if (typeof window !== \"undefined\") {\n const entryDateFromUrl = new URLSearchParams(window.location?.search).get(\n \"entryDate\",\n );\n if (entryDateFromUrl) {\n store.dispatch(updateEntryDate(entryDateFromUrl));\n } else if (Cache.hasItem(\"ModelCatalogEntryDate\")) {\n store.dispatch(Cache.getItem(\"ModelCatalogEntryDate\"));\n }\n }\n};\n\n/**\n */\nexport const setupClient = (\n customReducers: CustomReducers = {},\n beforeRenderHooks: ?Array<BeforeRenderHook>,\n): { store: ReduxStore, routerHistory: RouterHistory } => {\n if (typeof window.contextPath === \"undefined\") {\n throw new Error(\"Missing contextPath on window object\");\n }\n\n const data = getDataFromServer();\n\n // remove all resources from cache\n Cache.clear(\"^res:\");\n\n // $FlowExpectedError\n const browserHistory: RouterHistory = createBrowserHistory({\n basename: getBasePathServer(),\n });\n const { routerHistory, store } = configureStore(\n browserHistory,\n customReducers,\n rehydrate(data),\n );\n\n handleRedirectURI(store);\n setModelCatalogEntryDate(store);\n\n setAllContentInDataSetting(store.getState());\n setLoginPreferences(store.getState());\n setDateTimeSettings(store.getState());\n\n // load existing cache from other browser tabs\n Cache.loadOtherBrowserTabs(() => {\n if (Cache.getItem(\"auth\")) {\n store.dispatch(loginSuccess());\n }\n });\n\n if (has(data, \"error.name\")) {\n const error = new FetchException(data?.error?.response);\n store.dispatch(handleError(error));\n }\n\n if (Cache.getItem(\"auth\")) {\n store.dispatch(loginSuccess());\n }\n\n // listen to history change and update the redux router store\n routerHistory.listen((location, action) => {\n store.dispatch(locationChange(location, action));\n });\n\n setUnhandledRejectionEvent(store);\n\n if (document.body) {\n document.body.className = \"js\";\n }\n\n if (beforeRenderHooks) {\n handleBeforeRenderHooks(beforeRenderHooks, { store });\n }\n\n return { store, routerHistory };\n};\n\n/**\n */\nexport const addContentLoadedEvent = (\n store: ReduxStore,\n routerHistory: RouterHistory,\n theme?: Theme | Array<Theme>,\n render: RenderFunction,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n mount: MountFunction,\n) => {\n window.addEventListener(\"DOMContentLoaded\", () => {\n const applicationNode = document.querySelector(\"#application\");\n if (!applicationNode) {\n throw new Error(\n \"No DOM element with id application found to attach client to\",\n );\n }\n\n mount(\n applicationNode,\n <Init\n store={store}\n routerHistory={routerHistory}\n contextPath={window.contextPath}\n theme={theme}\n ErrorFallbackComponent={ErrorFallbackComponent}\n >\n {render()}\n </Init>,\n );\n });\n};\n\n/**\n */\nconst mountClient = (\n applicationNode: Element,\n element: ReactElement<ElementType>,\n) => {\n const isSSR = applicationNode.querySelector(\".application\");\n if (isSSR) {\n hydrate(element, applicationNode);\n } else {\n render(element, applicationNode);\n }\n};\n\n/**\n * Mount the webapplication to the DOM, setup redux store and caches, add unhandledRejectionEvent, used client side when JavaScript is enabled.\n */\nexport const client = ({\n customReducers,\n theme,\n render,\n beforeRenderHooks,\n ErrorFallbackComponent,\n mount,\n}: Props) => {\n const { store, routerHistory } = setupClient(\n customReducers,\n beforeRenderHooks,\n );\n\n addContentLoadedEvent(\n store,\n routerHistory,\n theme,\n render,\n ErrorFallbackComponent,\n mount ?? mountClient,\n );\n};\n"],"mappings":";;;;;;;;;AAEA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAD,sBAAA,CAAAH,OAAA;AAEA,IAAAK,IAAA,GAAAF,sBAAA,CAAAH,OAAA;AAEA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,eAAA,GAAAJ,sBAAA,CAAAH,OAAA;AAEA,IAAAQ,UAAA,GAAAL,sBAAA,CAAAH,OAAA;AACA,IAAAS,SAAA,GAAAT,OAAA;AAMA,IAAAU,YAAA,GAAAV,O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CAC1CC,cAAc,EACdI,iBACF,CAAC;EAED0B,qBAAqB,CACnBrE,KAAK,EACLkD,aAAa,EACboB,KAAK,EACLC,MAAM,EACNC,sBAAsB,EACtBC,KAAK,IAAIM,WACX,CAAC;AACH,CAAC;AAACnE,OAAA,CAAAuE,MAAA,GAAAA,MAAA","ignoreList":[]}
1
+ {"version":3,"file":"client.js","names":["_client","require","_objects","_setimmediate","_interopRequireDefault","_Cache","_xhr","_history","_configureStore","_rehydrate","_Settings","_Preferences","_Notification","_Error","_SignIn","_ModelCatalog","_RouterActions","_exceptions","_Init","_beforeRenderHooks","_jsxRuntime","parseDataToJSON","data","JSON","parse","error","JsonParseException","getDataFromServer","_context","dataElement","document","querySelector","Error","_trim","default","textContent","call","setUnhandledRejectionEvent","store","window","onunhandledrejection","event","detail","setImmediate","errorMessage","reason","message","toString","dispatch","showXHRErrorNotification","exports","handleRedirectURI","urlParams","_urlSearchParams","location","search","redirectURI","get","xhr","url","getBasePathModularUI","catch","e","id","LOGIN_PATH","getSetting","replace","from","pathname","modal","setModelCatalogEntryDate","entryDateFromUrl","updateEntryDate","Cache","hasItem","getItem","setupClient","customReducers","arguments","length","undefined","beforeRenderHooks","contextPath","clear","browserHistory","createBrowserHistory","basename","getBasePathServer","routerHistory","configureStore","rehydrate","setAllContentInDataSetting","getState","setLoginPreferences","setDateTimeSettings","loadOtherBrowserTabs","loginSuccess","has","FetchException","response","handleError","listen","action","locationChange","body","className","handleBeforeRenderHooks","addContentLoadedEvent","theme","render","ErrorFallbackComponent","mount","addEventListener","applicationNode","jsx","Init","children","mountClient","element","isSSR","hydrateRoot","root","createRoot","client","_ref"],"sources":["../../src/react-client/client.js"],"sourcesContent":["// @flow\n// eslint-disable-next-line react/no-deprecated\nimport { hydrateRoot, createRoot } from \"react-dom/client\";\n\nimport { has } from \"../utils/helpers/objects\";\nimport setImmediate from \"setimmediate\";\n\nimport Cache from \"../utils/browser/Cache\";\n\nimport xhr from \"../utils/fetch/xhr\";\n\nimport { createBrowserHistory } from \"history\";\nimport configureStore from \"../redux/store/configureStore\";\n\nimport rehydrate from \"./rehydrate\";\nimport {\n getBasePathModularUI,\n getBasePathServer,\n getSetting,\n} from \"../constants/Settings\";\n\nimport {\n setAllContentInDataSetting,\n setDateTimeSettings,\n setLoginPreferences,\n} from \"../redux/actions/Preferences\";\nimport { showXHRErrorNotification } from \"../redux/actions/Notification\";\nimport { handleError } from \"../redux/actions/Error\";\nimport { loginSuccess } from \"../redux/actions/SignIn\";\nimport { updateEntryDate } from \"../redux/actions/ModelCatalog\";\n\nimport { locationChange, replace } from \"../redux/_router/RouterActions\";\n\nimport { JsonParseException, FetchException } from \"../exceptions\";\n\nimport { Init } from \"./Init\";\n\nimport { handleBeforeRenderHooks } from \"../redux/store/beforeRenderHooks\";\n\nimport type {\n ComponentType,\n Element as ReactElement,\n ElementType,\n} from \"react\";\nimport type { Theme } from \"../react-theme/types\";\nimport type { CustomReducers, ReduxStore } from \"../redux/types\";\nimport type { RouterHistory } from \"react-router\";\nimport type { BeforeRenderHook } from \"../redux/store/beforeRenderHooks\";\nimport type { Props as FallbackProps } from \"../react/ErrorBoundaryFallback\";\n\ntype RenderFunction = () => ReactElement<ElementType>;\ntype MountFunction = (\n applicationNode: Element,\n element: ReactElement<ElementType>,\n) => void;\ntype Props = {\n customReducers?: CustomReducers,\n theme?: Theme | Array<Theme>,\n render: RenderFunction,\n mount: MountFunction,\n beforeRenderHooks?: Array<BeforeRenderHook>,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n};\n\n/*\n * deserialize serialized data from the server to provide a smooth dehydration.\n */\nconst parseDataToJSON = (data: string) => {\n try {\n return JSON.parse(data);\n } catch (error) {\n throw new JsonParseException(`Error parsing content ${data}`);\n }\n};\n\nconst getDataFromServer = () => {\n const dataElement = document.querySelector(\n 'script[type=\"application/json\"][data-app-state=\"app-json\"]',\n );\n\n if (!dataElement) {\n throw new Error(\"Error loading state, json not found\");\n } else if (dataElement.textContent.trim() === \"\") {\n return {};\n }\n\n return parseDataToJSON(dataElement.textContent);\n};\n\n/**\n */\nexport const setUnhandledRejectionEvent = (store: ReduxStore) => {\n window.onunhandledrejection = (event) => {\n if (event.detail) {\n return setImmediate(() => {\n const errorMessage = event.detail.reason.message.toString();\n\n store.dispatch(showXHRErrorNotification(errorMessage));\n throw event.detail.reason;\n });\n }\n\n return event;\n };\n};\n\n/**\n * The redirectURI querystring parameter is available when the server is redirecting an unauthorized deep link\n * @param store\n */\nconst handleRedirectURI = (store: ReduxStore) => {\n const urlParams = new URLSearchParams(window.location.search);\n const redirectURI = urlParams.get(\"redirectURI\");\n if (redirectURI) {\n xhr({ url: `${getBasePathModularUI()}${redirectURI}` }).catch((e) => {\n if (\n e.id === \"UnauthorizedException\" ||\n e.id === \"Error.NotAuthorized\" ||\n e.id === \"Error.Authentication.Required\" ||\n e.id === \"Error.Authentication.InvalidCredentials\"\n ) {\n const LOGIN_PATH = getSetting(\"LOGIN_PATH\", \"/signin\");\n store.dispatch(\n replace(LOGIN_PATH, {\n from: { pathname: redirectURI },\n modal: false,\n }),\n );\n }\n });\n }\n};\n\n/**\n */\nexport const setModelCatalogEntryDate = (store: ReduxStore) => {\n if (typeof window !== \"undefined\") {\n const entryDateFromUrl = new URLSearchParams(window.location?.search).get(\n \"entryDate\",\n );\n if (entryDateFromUrl) {\n store.dispatch(updateEntryDate(entryDateFromUrl));\n } else if (Cache.hasItem(\"ModelCatalogEntryDate\")) {\n store.dispatch(Cache.getItem(\"ModelCatalogEntryDate\"));\n }\n }\n};\n\n/**\n */\nexport const setupClient = (\n customReducers: CustomReducers = {},\n beforeRenderHooks: ?Array<BeforeRenderHook>,\n): { store: ReduxStore, routerHistory: RouterHistory } => {\n if (typeof window.contextPath === \"undefined\") {\n throw new Error(\"Missing contextPath on window object\");\n }\n\n const data = getDataFromServer();\n\n // remove all resources from cache\n Cache.clear(\"^res:\");\n\n // $FlowExpectedError\n const browserHistory: RouterHistory = createBrowserHistory({\n basename: getBasePathServer(),\n });\n const { routerHistory, store } = configureStore(\n browserHistory,\n customReducers,\n rehydrate(data),\n );\n\n handleRedirectURI(store);\n setModelCatalogEntryDate(store);\n\n setAllContentInDataSetting(store.getState());\n setLoginPreferences(store.getState());\n setDateTimeSettings(store.getState());\n\n // load existing cache from other browser tabs\n Cache.loadOtherBrowserTabs(() => {\n if (Cache.getItem(\"auth\")) {\n store.dispatch(loginSuccess());\n }\n });\n\n if (has(data, \"error.name\")) {\n const error = new FetchException(data?.error?.response);\n store.dispatch(handleError(error));\n }\n\n if (Cache.getItem(\"auth\")) {\n store.dispatch(loginSuccess());\n }\n\n // listen to history change and update the redux router store\n routerHistory.listen((location, action) => {\n store.dispatch(locationChange(location, action));\n });\n\n setUnhandledRejectionEvent(store);\n\n if (document.body) {\n document.body.className = \"js\";\n }\n\n if (beforeRenderHooks) {\n handleBeforeRenderHooks(beforeRenderHooks, { store });\n }\n\n return { store, routerHistory };\n};\n\n/**\n */\nexport const addContentLoadedEvent = (\n store: ReduxStore,\n routerHistory: RouterHistory,\n theme?: Theme | Array<Theme>,\n render: RenderFunction,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n mount: MountFunction,\n) => {\n window.addEventListener(\"DOMContentLoaded\", () => {\n const applicationNode = document.querySelector(\"#application\");\n if (!applicationNode) {\n throw new Error(\n \"No DOM element with id application found to attach client to\",\n );\n }\n\n mount(\n applicationNode,\n <Init\n store={store}\n routerHistory={routerHistory}\n contextPath={window.contextPath}\n theme={theme}\n ErrorFallbackComponent={ErrorFallbackComponent}\n >\n {render()}\n </Init>,\n );\n });\n};\n\n/**\n */\nconst mountClient = (\n applicationNode: Element,\n element: ReactElement<ElementType>,\n) => {\n const isSSR = applicationNode.querySelector(\".application\");\n if (isSSR) {\n hydrateRoot(element, applicationNode);\n } else {\n const root = createRoot(element);\n root.render(applicationNode);\n }\n};\n\n/**\n * Mount the webapplication to the DOM, setup redux store and caches, add unhandledRejectionEvent, used client side when JavaScript is enabled.\n */\nexport const client = ({\n customReducers,\n theme,\n render,\n beforeRenderHooks,\n ErrorFallbackComponent,\n mount,\n}: Props) => {\n const { store, routerHistory } = setupClient(\n customReducers,\n beforeRenderHooks,\n );\n\n addContentLoadedEvent(\n store,\n routerHistory,\n theme,\n render,\n ErrorFallbackComponent,\n mount ?? mountClient,\n );\n};\n"],"mappings":";;;;;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAD,sBAAA,CAAAH,OAAA;AAEA,IAAAK,IAAA,GAAAF,sBAAA,CAAAH,OAAA;AAEA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,eAAA,GAAAJ,sBAAA,CAAAH,OAAA;AAEA,IAAAQ,UAAA,GAAAL,sBAAA,CAAAH,OAAA;AACA,IAAAS,SAAA,GAAAT,OAAA;AAMA,IAAAU,YAAA,GAAAV,OAAA;AAKA,IAAAW,aAAA,GAAAX,OAAA;AACA,IAAAY,MAAA,GAAAZ,OAAA;AACA,IAAAa,OAAA,GAAAb,OAAA;AACA,IAAAc,aAAA,GAAAd,OAAA;AAEA,IAAAe,cAAA,GAAAf,OAAA;AAEA,IAAAgB,WAAA,GAAAhB,OAAA;AAEA,IAAAiB,KAAA,GAAAjB,OAAA;AAEA,IAAAkB,kBAAA,GAAAlB,OAAA;AAA2E,IAAAmB,WAAA,GAAAnB,OAAA;AApC3E;AA+DA;AACA;AACA;AACA,MAAMoB,eAAe,GAAIC,IAAY,IAAK;EACxC,IAAI;IACF,OAAOC,IAAI,CAACC,KAAK,CAACF,IAAI,CAAC;EACzB,CAAC,CAAC,OAAOG,KAAK,EAAE;IACd,MAAM,IAAIC,8BAAkB,CAAC,yBAAyBJ,IAAI,EAAE,CAAC;EAC/D;AACF,CAAC;AAED,MAAMK,iBAAiB,GAAGA,CAAA,KAAM;EAAA,IAAAC,QAAA;EAC9B,MAAMC,WAAW,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C;EACH,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AADA3D,OAAA,CAAAyD,qBAAA,GAAAA,qBAAA;AAEA,MAAMU,WAAW,GAAGA,CAClBJ,eAAwB,EACxBK,OAAkC,KAC/B;EACH,MAAMC,KAAK,GAAGN,eAAe,CAAClF,aAAa,CAAC,cAAc,CAAC;EAC3D,IAAIwF,KAAK,EAAE;IACT,IAAAC,mBAAW,EAACF,OAAO,EAAEL,eAAe,CAAC;EACvC,CAAC,MAAM;IACL,MAAMQ,IAAI,GAAG,IAAAC,kBAAU,EAACJ,OAAO,CAAC;IAChCG,IAAI,CAACZ,MAAM,CAACI,eAAe,CAAC;EAC9B;AACF,CAAC;;AAED;AACA;AACA;AACO,MAAMU,MAAM,GAAGC,IAAA,IAOT;EAAA,IAPU;IACrB/C,cAAc;IACd+B,KAAK;IACLC,MAAM;IACN5B,iBAAiB;IACjB6B,sBAAsB;IACtBC;EACK,CAAC,GAAAa,IAAA;EACN,MAAM;IAAEtF,KAAK;IAAEkD;EAAc,CAAC,GAAGZ,WAAW,CAC1CC,cAAc,EACdI,iBACF,CAAC;EAED0B,qBAAqB,CACnBrE,KAAK,EACLkD,aAAa,EACboB,KAAK,EACLC,MAAM,EACNC,sBAAsB,EACtBC,KAAK,IAAIM,WACX,CAAC;AACH,CAAC;AAACnE,OAAA,CAAAyE,MAAA,GAAAA,MAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.60.0",
3
+ "version": "1.60.2",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "https://support.beinformed.com",
@@ -18,7 +18,7 @@
18
18
  "watch:esm": "cross-env BABEL_ENV=esm babel --watch src --out-dir esm --ignore \"**/__tests__/**\" --ignore \"**/__mock__/**\" --ignore \"**/__mocks__/**\"",
19
19
  "quality": "npm run lint && npm run flow && npm run test",
20
20
  "dev": "npm run clean && npm run build:lib && npm run build:flow && npm run build:proxies && npm run build:esm",
21
- "build": "npm run quality && npm run clean && npm run build:lib && npm run build:flow && npm run build:proxies && npm run build:esm && npm run build:ts && npm run docs",
21
+ "build": "npm run clean && npm run build:lib && npm run build:flow && npm run build:proxies && npm run build:esm && npm run build:ts && npm run docs",
22
22
  "build:lib": "babel src --out-dir lib --ignore \"**/__tests__/**\" --ignore \"**/__mock__/**\" --ignore \"**/__mocks__/**\" --source-maps",
23
23
  "build:esm": "cross-env BABEL_ENV=esm babel src --out-dir esm --ignore \"**/__tests__/**\" --ignore \"**/__mock__/**\" --ignore \"**/__mocks__/**\" --source-maps",
24
24
  "build:proxies": "node .build/proxies.js",
@@ -35,8 +35,7 @@
35
35
  "test:ci": "jest --ci",
36
36
  "test:changed": "jest --onlyChanged",
37
37
  "upgrade-interactive": "npm-check -u",
38
- "prerelease": "",
39
- "release": "commit-and-tag-version",
38
+ "release": "npm run quality && commit-and-tag-version",
40
39
  "beta-release": "commit-and-tag-version --prerelease beta",
41
40
  "prepublishOnly": "npm run build",
42
41
  "docs": "rimraf docs && node ./.build/docs.mjs",
@@ -59,8 +58,8 @@
59
58
  "peerDependencies": {
60
59
  "history": "^4.0.0",
61
60
  "polished": "^4.0.0",
62
- "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
63
- "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0",
61
+ "react": "^18.0.0 || ^19.0.0",
62
+ "react-dom": "^18.0.0 || ^19.0.0",
64
63
  "react-helmet-async": "^1.0.0 || ^2.0.0",
65
64
  "react-redux": "^7.0.0 || ^8.0.0",
66
65
  "react-router": "^5.0.0",
@@ -109,13 +108,13 @@
109
108
  "cross-env": "^7.0.3",
110
109
  "documentation": "^14.0.2",
111
110
  "eslint": "^8.57.0",
112
- "eslint-config-prettier": "^10.0.1",
111
+ "eslint-config-prettier": "^10.0.2",
113
112
  "eslint-plugin-babel": "^5.3.1",
114
113
  "eslint-plugin-ft-flow": "^3.0.11",
115
114
  "eslint-plugin-jest": "^28.11.0",
116
115
  "eslint-plugin-jsdoc": "^50.6.3",
117
116
  "eslint-plugin-react": "^7.37.4",
118
- "eslint-plugin-react-hooks": "^5.1.0",
117
+ "eslint-plugin-react-hooks": "^5.2.0",
119
118
  "eslint-plugin-you-dont-need-lodash-underscore": "^6.14.0",
120
119
  "flow-bin": "^0.200.1",
121
120
  "flow-copy-source": "^2.0.9",
@@ -130,7 +129,7 @@
130
129
  "jscodeshift": "^17.1.2",
131
130
  "lint-staged": "^15.4.3",
132
131
  "polished": "^4.0.0",
133
- "prettier": "^3.5.1",
132
+ "prettier": "^3.5.3",
134
133
  "react": "^19.0.0",
135
134
  "react-dom": "^19.0.0",
136
135
  "react-helmet-async": "^2.0.5",
@@ -142,7 +141,7 @@
142
141
  "redux-thunk": "^2.4.2",
143
142
  "rimraf": "^6.0.1",
144
143
  "styled-components": "^5.3.11",
145
- "typescript": "^5.7.3",
144
+ "typescript": "^5.8.2",
146
145
  "xhr-mock": "^2.5.1"
147
146
  },
148
147
  "scarfSettings": {
@@ -284,6 +284,8 @@ describe("formModel", () => {
284
284
 
285
285
  form.currentFormObject.getAttributeByKey("DateOfBirth").inputvalue = "bla";
286
286
 
287
+ expect(form.errorCollection).toHaveLength(0);
288
+
287
289
  form.handleErrors({
288
290
  data: {
289
291
  errors: [
@@ -1,6 +1,7 @@
1
1
  // @flow
2
2
  import {
3
3
  getBasePathModularUI,
4
+ getSetting,
4
5
  getUploadPath,
5
6
  HTTP_METHODS,
6
7
  } from "../constants";
@@ -12,6 +13,7 @@ import type {
12
13
  FiletypeConstraintsType,
13
14
  } from "../models";
14
15
  import ErrorModel from "../models/error/ErrorModel";
16
+ import { ErrorResponse } from "../models";
15
17
 
16
18
  type ProgressHandler = (file: File, uploadInfo: Object) => void;
17
19
 
@@ -86,7 +88,10 @@ class UploadRequest {
86
88
  uploadFile(file: File): Promise<UploadResponse> {
87
89
  const maxFileSize = this._uploadConstraints?.maxFileSize?.fileSize ?? -1;
88
90
 
89
- if (this.exceedsMaxFileSize(file)) {
91
+ if (
92
+ getSetting("USE_CLIENTSIDE_VALIDATION") &&
93
+ this.exceedsMaxFileSize(file)
94
+ ) {
90
95
  this._progressHandler(file, { error: "errorExceedsMaxFileSize" });
91
96
  return Promise.reject(
92
97
  new ErrorModel(
@@ -100,7 +105,10 @@ class UploadRequest {
100
105
  );
101
106
  }
102
107
 
103
- if (this.isNotAllowedFileType(file)) {
108
+ if (
109
+ getSetting("USE_CLIENTSIDE_VALIDATION") &&
110
+ this.isNotAllowedFileType(file)
111
+ ) {
104
112
  this._progressHandler(file, { error: "errorExtensionNotAllowed" });
105
113
  return Promise.reject(
106
114
  new ErrorModel(
@@ -131,10 +139,12 @@ class UploadRequest {
131
139
  }
132
140
  },
133
141
  data: file,
134
- }).then((response) => {
135
- this._progressHandler(file, { progress: 100, token: response.token });
136
- return response;
137
- });
142
+ })
143
+ .then((response) => {
144
+ this._progressHandler(file, { progress: 100, token: response.token });
145
+ return response;
146
+ })
147
+ .catch((e) => Promise.reject(new ErrorResponse(e)));
138
148
  }
139
149
  }
140
150
 
@@ -1,6 +1,6 @@
1
1
  // @flow
2
2
  // eslint-disable-next-line react/no-deprecated
3
- import { hydrate, render } from "react-dom";
3
+ import { hydrateRoot, createRoot } from "react-dom/client";
4
4
 
5
5
  import { has } from "../utils/helpers/objects";
6
6
  import setImmediate from "setimmediate";
@@ -253,9 +253,10 @@ const mountClient = (
253
253
  ) => {
254
254
  const isSSR = applicationNode.querySelector(".application");
255
255
  if (isSSR) {
256
- hydrate(element, applicationNode);
256
+ hydrateRoot(element, applicationNode);
257
257
  } else {
258
- render(element, applicationNode);
258
+ const root = createRoot(element);
259
+ root.render(applicationNode);
259
260
  }
260
261
  };
261
262