@beinformed/ui 1.25.5 → 1.26.0

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 (69) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/esm/hooks/useModularUIModel.js +7 -0
  3. package/esm/hooks/useModularUIModel.js.map +1 -1
  4. package/esm/hooks/useModularUIRequest.js +7 -5
  5. package/esm/hooks/useModularUIRequest.js.map +1 -1
  6. package/esm/models/attributes/ChoiceAttributeOptionCollection.js +3 -12
  7. package/esm/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
  8. package/esm/modularui/ModularUIRequest.js +31 -0
  9. package/esm/modularui/ModularUIRequest.js.map +1 -1
  10. package/esm/react-server/serverNoSSR.js +2 -1
  11. package/esm/react-server/serverNoSSR.js.map +1 -1
  12. package/esm/react-server/serverUtil.js +31 -5
  13. package/esm/react-server/serverUtil.js.map +1 -1
  14. package/esm/redux/_modularui/ModularUIActions.js +7 -0
  15. package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
  16. package/esm/redux/_modularui/ModularUIReducer.js +21 -1
  17. package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
  18. package/esm/redux/_modularui/types.js.map +1 -1
  19. package/esm/redux/store/configureStore.js +1 -1
  20. package/esm/redux/store/configureStore.js.map +1 -1
  21. package/esm/redux/types.js.map +1 -1
  22. package/lib/hooks/useModularUIModel.js +9 -1
  23. package/lib/hooks/useModularUIModel.js.flow +8 -0
  24. package/lib/hooks/useModularUIModel.js.map +1 -1
  25. package/lib/hooks/useModularUIRequest.js +7 -5
  26. package/lib/hooks/useModularUIRequest.js.flow +10 -11
  27. package/lib/hooks/useModularUIRequest.js.map +1 -1
  28. package/lib/models/attributes/ChoiceAttributeOptionCollection.js +3 -12
  29. package/lib/models/attributes/ChoiceAttributeOptionCollection.js.flow +3 -17
  30. package/lib/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
  31. package/lib/modularui/ModularUIRequest.js +31 -0
  32. package/lib/modularui/ModularUIRequest.js.flow +39 -0
  33. package/lib/modularui/ModularUIRequest.js.map +1 -1
  34. package/lib/react-server/serverNoSSR.js +1 -0
  35. package/lib/react-server/serverNoSSR.js.flow +5 -0
  36. package/lib/react-server/serverNoSSR.js.map +1 -1
  37. package/lib/react-server/serverUtil.js +32 -5
  38. package/lib/react-server/serverUtil.js.flow +40 -6
  39. package/lib/react-server/serverUtil.js.map +1 -1
  40. package/lib/redux/_modularui/ModularUIActions.js +9 -1
  41. package/lib/redux/_modularui/ModularUIActions.js.flow +10 -0
  42. package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
  43. package/lib/redux/_modularui/ModularUIReducer.js +21 -1
  44. package/lib/redux/_modularui/ModularUIReducer.js.flow +22 -0
  45. package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
  46. package/lib/redux/_modularui/types.js.flow +8 -0
  47. package/lib/redux/_modularui/types.js.map +1 -1
  48. package/lib/redux/store/configureStore.js +1 -1
  49. package/lib/redux/store/configureStore.js.flow +1 -1
  50. package/lib/redux/store/configureStore.js.map +1 -1
  51. package/lib/redux/types.js.flow +2 -0
  52. package/lib/redux/types.js.map +1 -1
  53. package/package.json +2 -2
  54. package/src/hooks/useModularUIModel.js +8 -0
  55. package/src/hooks/useModularUIRequest.js +10 -11
  56. package/src/models/attributes/ChoiceAttributeOptionCollection.js +3 -17
  57. package/src/modularui/ModularUIRequest.js +39 -0
  58. package/src/react-server/serverNoSSR.js +5 -0
  59. package/src/react-server/serverUtil.js +40 -6
  60. package/src/redux/_modularui/ModularUIActions.js +10 -0
  61. package/src/redux/_modularui/ModularUIReducer.js +22 -0
  62. package/src/redux/_modularui/types.js +8 -0
  63. package/src/redux/store/configureStore.js +1 -1
  64. package/src/redux/types.js +2 -0
  65. package/types/models/attributes/ChoiceAttributeOptionCollection.d.ts +0 -3
  66. package/types/modularui/ModularUIRequest.d.ts +18 -3
  67. package/types/redux/_modularui/types.d.ts +8 -0
  68. package/types/redux/types.d.ts +1 -1
  69. package/types/utils/fetch/types.d.ts +1 -0
@@ -36,6 +36,14 @@ export type SetModelAction = {
36
36
  },
37
37
  };
38
38
 
39
+ export type InitModelAction = {
40
+ type: "MODULARUI/INIT",
41
+ payload: Array<{
42
+ key: string,
43
+ model: ModularUIModel,
44
+ }>,
45
+ };
46
+
39
47
  export type UpdateModelAction = {
40
48
  type: "MODULARUI/UPDATE",
41
49
  payload: ModularUIModel,
@@ -49,7 +49,7 @@ const configureStore = (
49
49
  enhancers
50
50
  );
51
51
 
52
- if (!initialState) {
52
+ if (!initialState?.router) {
53
53
  store.dispatch(locationChange(history.location, "PUSH"));
54
54
  }
55
55
  return { history, store };
@@ -23,6 +23,7 @@ import type {
23
23
  UpdateModelAction,
24
24
  RemoveModelByKeyAction,
25
25
  ResetModularUIAction,
26
+ InitModelAction,
26
27
  } from "./_modularui/types";
27
28
  import type {
28
29
  RouterState,
@@ -135,6 +136,7 @@ export type UpdateAutosaveAction = {
135
136
  export type ReduxAction =
136
137
  | UpdateStatusAction
137
138
  | SetModelAction
139
+ | InitModelAction
138
140
  | UpdateModelAction
139
141
  | RemoveModelByKeyAction
140
142
  | ResetModularUIAction
@@ -30,9 +30,6 @@ declare class ChoiceAttributeOptionCollection extends ResourceCollection<ChoiceA
30
30
  /**
31
31
  */
32
32
  addBooleanOption(code: "true" | "false", defaultLabel: string, data: string | Array<string>, options?: Array<Object>): void;
33
- /**
34
- */
35
- getDefaultValueForOption(value: any, contributions: Object): string;
36
33
  /**
37
34
  * Create two static options for true and false,
38
35
  * there might be alternative labels configured for each option value
@@ -11,11 +11,13 @@ declare class ModularUIRequest {
11
11
  _href: Href;
12
12
  _options: RequestModularUIOptions;
13
13
  _targetModel: TargetModel | null;
14
+ _forceTargetModel: boolean;
14
15
  _contributionsHref: string;
15
16
  _locale: string;
16
17
  _method: $Keys<{
17
18
  POST: string;
18
- GET: string;
19
+ GET: string; /**
20
+ */
19
21
  }>;
20
22
  _progressEvent: ProgressEventHandler;
21
23
  /**
@@ -46,13 +48,15 @@ declare class ModularUIRequest {
46
48
  */
47
49
  set method(arg: $Keys<{
48
50
  POST: string;
49
- GET: string;
51
+ GET: string; /**
52
+ */
50
53
  }>);
51
54
  /**
52
55
  */
53
56
  get method(): $Keys<{
54
57
  POST: string;
55
- GET: string;
58
+ GET: string; /**
59
+ */
56
60
  }>;
57
61
  /**
58
62
  */
@@ -69,6 +73,12 @@ declare class ModularUIRequest {
69
73
  /**
70
74
  */
71
75
  get withChildModels(): boolean;
76
+ /**
77
+ */
78
+ set forceTargetModel(arg: boolean);
79
+ /**
80
+ */
81
+ get forceTargetModel(): boolean;
72
82
  /**
73
83
  */
74
84
  resolveModel(): Class<ModularUIModel>;
@@ -174,6 +184,11 @@ declare class ModularUIRequest {
174
184
  * @returns {Promise<FormModel>}
175
185
  */
176
186
  postForm(form: FormModel): Promise<FormModel>;
187
+ /**
188
+ * Simplified synchronous version of fetch (returns the model, not a Promise)
189
+ * This can be used on the server to retrieve a model. It only loads the request url and it's child models
190
+ */
191
+ fetchSync(): ModularUIModel;
177
192
  }
178
193
  import ModularUIResponse from "./ModularUIResponse";
179
194
  import Href from "../models/href/Href";
@@ -12,6 +12,13 @@ type SetModelAction = {
12
12
  model: ModularUIModel;
13
13
  };
14
14
  };
15
+ type InitModelAction = {
16
+ type: "MODULARUI/INIT";
17
+ payload: {
18
+ key: string;
19
+ model: ModularUIModel;
20
+ }[];
21
+ };
15
22
  type UpdateModelAction = {
16
23
  type: "MODULARUI/UPDATE";
17
24
  payload: ModularUIModel;
@@ -29,6 +36,7 @@ type ModularUIAction = {
29
36
  locale: string;
30
37
  childmodels?: boolean;
31
38
  targetModel?: any;
39
+ forceTargetModel?: boolean;
32
40
  successAction: (model: ModularUIModel) => SetModelAction | UpdateModelAction;
33
41
  errorAction?: ErrorAction;
34
42
  };
@@ -84,7 +84,7 @@ type UpdateAutosaveAction = {
84
84
  model: FormModel;
85
85
  };
86
86
  };
87
- type ReduxAction = UpdateLocaleAction | SetLocalesAction | SetModelAction | UpdateModelAction | UpdateStatusAction | RemoveModelByKeyAction | NoAction | ModularUIAction | ResetModularUIAction | LocationChangeAction | PushAction | ReplaceAction | GoAction | GoBackAction | GoForwardAction | SaveErrorAction | ShowModalAction | CloseModalAction | DismissNotificationAction | ShowNotificationAction | SetPreferenceAction | SetPreferencesAction | StartProgressAction | FinishProgressAction | ResetProgressAction | UpdateProgressAction | SendAuthenticationErrorAction | ResetAuthErrorsAction | LoginSuccessAction | ChangePasswordAction | LogoutSuccessAction | UpdateAutosaveAction;
87
+ type ReduxAction = UpdateLocaleAction | SetLocalesAction | SetModelAction | InitModelAction | UpdateModelAction | UpdateStatusAction | RemoveModelByKeyAction | NoAction | ModularUIAction | ResetModularUIAction | LocationChangeAction | PushAction | ReplaceAction | GoAction | GoBackAction | GoForwardAction | SaveErrorAction | ShowModalAction | CloseModalAction | DismissNotificationAction | ShowNotificationAction | SetPreferenceAction | SetPreferencesAction | StartProgressAction | FinishProgressAction | ResetProgressAction | UpdateProgressAction | SendAuthenticationErrorAction | ResetAuthErrorsAction | LoginSuccessAction | ChangePasswordAction | LogoutSuccessAction | UpdateAutosaveAction;
88
88
  type AuthState = {};
89
89
  type ErrorState = ErrorResponse;
90
90
  type ModalState = {};
@@ -33,6 +33,7 @@ type RequestOptions = {
33
33
  type RequestModularUIOptions = {
34
34
  RequestBaseOptions: any;
35
35
  targetModel?: any;
36
+ forceTargetModel?: boolean;
36
37
  updateModel?: ModularUIModel;
37
38
  childmodels?: boolean;
38
39
  isValidationRequest?: boolean;