@uxland/primary-shell 5.1.2 → 5.2.1

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 (112) hide show
  1. package/dist/index.js +27064 -26699
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.umd.cjs +1660 -1531
  4. package/dist/index.umd.cjs.map +1 -1
  5. package/dist/primary/shell/src/UI/bootstrapper.d.ts +1 -0
  6. package/dist/primary/shell/src/UI/components/bootstrapper.d.ts +1 -0
  7. package/dist/primary/shell/src/UI/components/{shell-header → primaria-shell/shell-header}/shell-header.d.ts +3 -3
  8. package/dist/primary/shell/src/UI/components/primaria-shell/shell-header/template.d.ts +3 -0
  9. package/dist/primary/shell/src/UI/index.d.ts +0 -1
  10. package/dist/primary/shell/src/UI/shared-components/bootstrapper.d.ts +1 -0
  11. package/dist/primary/shell/src/UI/shared-components/index.d.ts +0 -1
  12. package/dist/primary/shell/src/UI/shared-components/primaria-character-limit-badge/primaria-character-limit-badge.d.ts +9 -0
  13. package/dist/primary/shell/src/api/api.d.ts +4 -4
  14. package/dist/primary/shell/src/api/ecap-event-manager/ecap-event-manager.test.d.ts +1 -0
  15. package/dist/primary/shell/src/api/notification-service/notification-service-impl.test.d.ts +1 -0
  16. package/dist/primary/shell/src/api/pdf-viewer-manager/constants.d.ts +1 -0
  17. package/dist/primary/shell/src/api/pdf-viewer-manager/handle-views.d.ts +2 -0
  18. package/dist/primary/shell/src/api/pdf-viewer-manager/pdf-viewer-manager.d.ts +2 -4
  19. package/dist/primary/shell/src/api/pdf-viewer-manager/pdf-viewer-manager.test.d.ts +1 -0
  20. package/dist/primary/shell/src/api/region-manager/region-manager.test.d.ts +1 -0
  21. package/dist/primary/shell/src/bootstrapper.d.ts +0 -1
  22. package/dist/primary/shell/src/constants.d.ts +0 -2
  23. package/dist/primary/shell/src/features/bootstrapper.d.ts +2 -2
  24. package/dist/primary/shell/src/features/clinical-monitoring/bootstrapper.d.ts +4 -0
  25. package/dist/primary/shell/src/features/clinical-monitoring/constants.d.ts +1 -0
  26. package/dist/primary/shell/src/features/clinical-monitoring/handle-views.d.ts +1 -0
  27. package/dist/primary/shell/src/features/exit/bootstrapper.d.ts +4 -2
  28. package/dist/primary/shell/src/features/exit/handler.test.d.ts +1 -0
  29. package/dist/primary/shell/src/features/get-patient-cip/action.d.ts +3 -0
  30. package/dist/primary/shell/src/features/get-user-info/bootstrapper.d.ts +4 -2
  31. package/dist/primary/shell/src/features/get-user-info/handler.d.ts +1 -1
  32. package/dist/primary/shell/src/features/get-user-info/handler.test.d.ts +1 -0
  33. package/dist/primary/shell/src/features/navigate-to-ecap/navigate-without-closing-and-with-cip.d.ts +1 -0
  34. package/dist/primary/shell/src/handle-views.d.ts +1 -2
  35. package/dist/primary/shell/src/internal-plugins/activity-history/utils/get-unique-values-by-prop-path.test.d.ts +1 -0
  36. package/dist/primary/shell/src/internal-plugins/activity-history/utils/normalize-string.d.ts +1 -1
  37. package/dist/primary/shell/src/internal-plugins/activity-history/utils/normalize-string.test.d.ts +1 -0
  38. package/dist/primary/shell/src/internal-plugins/activity-history/utils/prop-contains-string.test.d.ts +1 -0
  39. package/dist/primary/shell/src/locales.d.ts +1 -1
  40. package/package.json +2 -2
  41. package/src/UI/bootstrapper.ts +12 -0
  42. package/src/UI/components/bootstrapper.ts +17 -0
  43. package/src/UI/components/{primaria-error-view → error-view}/component.ts +2 -3
  44. package/src/UI/components/poc-events-ecap/poc-events-ecap.ts +3 -7
  45. package/src/UI/components/primaria-shell/primaria-shell.ts +8 -10
  46. package/src/UI/components/{shell-header → primaria-shell/shell-header}/shell-header.ts +8 -9
  47. package/src/UI/components/{shell-header → primaria-shell/shell-header}/template.ts +4 -4
  48. package/src/UI/components/primaria-shell/template.ts +14 -8
  49. package/src/UI/components/quick-actions-menu/quick-actions-menu.ts +0 -2
  50. package/src/UI/index.ts +0 -1
  51. package/src/UI/shared-components/bootstrapper.ts +14 -0
  52. package/src/UI/shared-components/index.ts +0 -3
  53. package/src/UI/shared-components/primaria-character-limit-badge/primaria-character-limit-badge.ts +29 -0
  54. package/src/UI/shared-components/primaria-character-limit-badge/styles.css +8 -0
  55. package/src/UI/shared-components/primaria-content-switcher/primaria-content-switcher.ts +1 -2
  56. package/src/UI/shared-components/primaria-nav-item/primaria-nav-item.ts +6 -7
  57. package/src/UI/shared-components/primaria-nav-tree-menu/primaria-nav-tree-menu.ts +3 -4
  58. package/src/UI/shared-components/primaria-text-editor/primaria-rich-text-editor.ts +1 -2
  59. package/src/api/api.ts +17 -14
  60. package/src/api/ecap-event-manager/ecap-event-manager.test.ts +48 -0
  61. package/src/api/notification-service/notification-service-impl.test.ts +56 -0
  62. package/src/api/pdf-viewer-manager/constants.ts +1 -0
  63. package/src/api/pdf-viewer-manager/handle-views.ts +32 -0
  64. package/src/api/pdf-viewer-manager/pdf-viewer-manager.test.ts +99 -0
  65. package/src/api/pdf-viewer-manager/pdf-viewer-manager.ts +15 -25
  66. package/src/{UI/components → api/pdf-viewer-manager}/pdf-visor/pdf-selector/pdf-selector.ts +3 -4
  67. package/src/{UI/components → api/pdf-viewer-manager}/pdf-visor/pdf-visor.ts +8 -9
  68. package/src/api/plugin-busy-manager/plugin-busy-list/component.ts +0 -2
  69. package/src/api/plugin-busy-manager/plugin-busy-manager.ts +7 -1
  70. package/src/api/region-manager/region-manager.test.ts +123 -0
  71. package/src/bootstrapper.ts +8 -9
  72. package/src/constants.ts +0 -2
  73. package/src/disposer.ts +2 -2
  74. package/src/features/bootstrapper.ts +14 -8
  75. package/src/features/clinical-monitoring/bootstrapper.ts +39 -0
  76. package/src/{UI/components/clinical-monitoring → features/clinical-monitoring/component}/clinical-monitoring.ts +3 -6
  77. package/src/features/clinical-monitoring/constants.ts +1 -0
  78. package/src/features/clinical-monitoring/handle-views.ts +6 -0
  79. package/src/features/exit/bootstrapper.ts +5 -5
  80. package/src/features/exit/handler.test.ts +103 -0
  81. package/src/features/get-patient-cip/action.ts +5 -0
  82. package/src/features/get-user-info/bootstrapper.ts +5 -5
  83. package/src/features/get-user-info/handler.test.ts +60 -0
  84. package/src/features/get-user-info/handler.ts +2 -4
  85. package/src/features/navigate-to-ecap/navigate-without-closing-and-with-cip.ts +7 -0
  86. package/src/handle-views.ts +78 -142
  87. package/src/internal-plugins/activity-history/utils/get-unique-values-by-prop-path.test.ts +61 -0
  88. package/src/internal-plugins/activity-history/utils/get-unique-values-by-prop-path.ts +2 -2
  89. package/src/internal-plugins/activity-history/utils/normalize-string.test.ts +29 -0
  90. package/src/internal-plugins/activity-history/utils/normalize-string.ts +5 -3
  91. package/src/internal-plugins/activity-history/utils/prop-contains-string.test.ts +47 -0
  92. package/src/locales.ts +1 -1
  93. package/dist/primary/shell/src/UI/components/index.d.ts +0 -1
  94. package/dist/primary/shell/src/UI/components/shell-header/template.d.ts +0 -3
  95. package/src/UI/components/index.ts +0 -7
  96. /package/dist/primary/shell/src/UI/components/{primaria-error-view → error-view}/component.d.ts +0 -0
  97. /package/dist/primary/shell/src/UI/components/{primaria-error-view → error-view}/template.d.ts +0 -0
  98. /package/dist/primary/shell/src/{UI/components → api/pdf-viewer-manager}/pdf-visor/pdf-selector/pdf-selector.d.ts +0 -0
  99. /package/dist/primary/shell/src/{UI/components → api/pdf-viewer-manager}/pdf-visor/pdf-selector/template.d.ts +0 -0
  100. /package/dist/primary/shell/src/{UI/components → api/pdf-viewer-manager}/pdf-visor/pdf-visor.d.ts +0 -0
  101. /package/dist/primary/shell/src/{UI/components → api/pdf-viewer-manager}/pdf-visor/utils.d.ts +0 -0
  102. /package/dist/primary/shell/src/{UI/components/clinical-monitoring → features/clinical-monitoring/component}/clinical-monitoring.d.ts +0 -0
  103. /package/dist/primary/shell/src/{UI/components/clinical-monitoring → features/clinical-monitoring/component}/template.d.ts +0 -0
  104. /package/src/UI/components/{primaria-error-view → error-view}/styles.css +0 -0
  105. /package/src/UI/components/{primaria-error-view → error-view}/template.ts +0 -0
  106. /package/src/UI/components/{shell-header → primaria-shell/shell-header}/styles.css +0 -0
  107. /package/src/{UI/components → api/pdf-viewer-manager}/pdf-visor/pdf-selector/styles.css +0 -0
  108. /package/src/{UI/components → api/pdf-viewer-manager}/pdf-visor/pdf-selector/template.ts +0 -0
  109. /package/src/{UI/components → api/pdf-viewer-manager}/pdf-visor/styles.css +0 -0
  110. /package/src/{UI/components → api/pdf-viewer-manager}/pdf-visor/utils.ts +0 -0
  111. /package/src/{UI/components/clinical-monitoring → features/clinical-monitoring/component}/styles.css +0 -0
  112. /package/src/{UI/components/clinical-monitoring → features/clinical-monitoring/component}/template.ts +0 -0
@@ -1,158 +1,122 @@
1
1
  import { shellApi } from "./api/api";
2
+ import { registerPDFVisorMainView } from "./api/pdf-viewer-manager/handle-views";
2
3
  import { shellRegions } from "./api/region-manager/regions";
3
- import { clinicalMonitoringId, pdfViewerId, pocTestEventsId } from "./constants";
4
- import { shellEvents } from "./events";
4
+ import { pocTestEventsId } from "./constants";
5
5
  import { ExitShell } from "./features/exit/request";
6
- import { ClinicalMonitoring } from "./UI/components/clinical-monitoring/clinical-monitoring";
7
- import { PdfVisor } from "./UI/components/pdf-visor/pdf-visor";
8
- import { PocEventsEcap } from "./UI/components/poc-events-ecap/poc-events-ecap";
6
+ import { getPatientCip } from "./features/get-patient-cip/action";
7
+ import { navigateToEcapWithoutClosingWithCip } from "./features/navigate-to-ecap/navigate-without-closing-and-with-cip";
9
8
  import { PrimariaNavItem } from "./UI/shared-components/primaria-nav-item/primaria-nav-item";
10
9
  import { PrimariaNavTreeMenu } from "./UI/shared-components/primaria-nav-tree-menu/primaria-nav-tree-menu";
11
10
 
12
- const getPatientCip = async (): Promise<string> => {
13
- return (await shellApi.broker.send("get_patient_cip")) as string;
14
- };
15
-
16
- const publishEcapNoCloseWithCip = async (eventName: string) => {
17
- const CIP = await getPatientCip();
18
- shellApi.ecapEventManager.publish(eventName, "NO_TANCAR", { CIP });
19
- };
20
-
21
11
  const registerUpperNavMenuViews = () => {
22
12
  shellApi.regionManager.registerView(shellRegions.navigationMenu, {
23
- id: pocTestEventsId,
13
+ id: "landing",
24
14
  factory: () => {
25
15
  const menuItem = new PrimariaNavItem({
26
- icon: "bolt",
27
- label: "Prova Events ECAP",
16
+ icon: "home",
17
+ label: "Pàgina inici",
28
18
  callbackFn: () => {
29
- shellApi.regionManager.activateMainView(pocTestEventsId);
19
+ shellApi.broker.send(new ExitShell());
30
20
  },
31
21
  });
32
22
  return Promise.resolve(menuItem);
33
23
  },
34
24
  sortHint: "000100",
35
25
  });
26
+
36
27
  shellApi.regionManager.registerView(shellRegions.navigationMenu, {
37
- id: "communication",
28
+ id: "processes",
38
29
  factory: () => {
39
30
  const menuItem = new PrimariaNavTreeMenu({
40
- icon: "add_box",
41
- label: "Comunicació",
31
+ icon: "account_tree",
32
+ label: "Vies clíniques",
42
33
  actionMenuItems: [
43
34
  {
44
35
  icon: "open_in_new",
45
- label: "SMS",
46
- callbackFn: async (): Promise<void> => {
47
- const CIP = await getPatientCip();
48
- shellApi.ecapEventManager.publish("MISSATGES_DEV", "NO_TANCAR", {
49
- CIP: CIP || "",
50
- TipusMissatge: "SMS",
51
- });
36
+ label: "ARES",
37
+ callbackFn: async () => {
38
+ navigateToEcapWithoutClosingWithCip("PROCES_ATENCIO");
52
39
  },
53
40
  },
54
41
  {
55
42
  icon: "open_in_new",
56
- label: "Econsulta",
43
+ label: "Procés Obstètric",
57
44
  callbackFn: (): void => {},
58
45
  },
59
46
  {
60
47
  icon: "open_in_new",
61
- label: "Mail",
62
- callbackFn: (): void => {},
48
+ label: "Nen sa",
49
+ callbackFn: async () => {
50
+ navigateToEcapWithoutClosingWithCip("NEN_SA");
51
+ },
63
52
  },
64
53
  {
65
54
  icon: "open_in_new",
66
- label: "Veu IP",
67
- callbackFn: async (): Promise<void> => {
68
- publishEcapNoCloseWithCip("VOIP");
55
+ label: "Odontologia",
56
+ callbackFn: async () => {
57
+ navigateToEcapWithoutClosingWithCip("ODONTOLOGO");
69
58
  },
70
59
  },
71
60
  {
72
61
  icon: "open_in_new",
73
- label: "Videoconsulta",
74
- callbackFn: (): void => {},
62
+ label: "Situació d'especial cura",
63
+ callbackFn: async () => {
64
+ navigateToEcapWithoutClosingWithCip("SIT_ESPEC_CURA_DEV");
65
+ },
75
66
  },
76
67
  ],
77
68
  });
78
69
  return Promise.resolve(menuItem);
79
70
  },
80
- });
81
- shellApi.regionManager.registerView(shellRegions.navigationMenu, {
82
- id: "visits",
83
- factory: () => {
84
- const menuItem = new PrimariaNavItem({
85
- icon: "add_box",
86
- label: "Visites",
87
- callbackFn: async (): Promise<void> => {
88
- publishEcapNoCloseWithCip("CONSULTA_VISITES");
89
- },
90
- });
91
- return Promise.resolve(menuItem);
92
- },
93
- });
94
- shellApi.regionManager.registerView(shellRegions.navigationMenu, {
95
- id: "it",
96
- factory: () => {
97
- const menuItem = new PrimariaNavItem({
98
- icon: "add_box",
99
- label: "IT",
100
- callbackFn: async (): Promise<void> => {
101
- publishEcapNoCloseWithCip("REV_IT");
102
- },
103
- });
104
- return Promise.resolve(menuItem);
105
- },
71
+ sortHint: "000400",
106
72
  });
107
73
  shellApi.regionManager.registerView(shellRegions.navigationMenu, {
108
74
  id: "unique-petition",
109
75
  factory: () => {
110
76
  const menuItem = new PrimariaNavTreeMenu({
111
- icon: "add_box",
112
- label: "Petitori únic",
77
+ icon: "playlist_add",
78
+ label: "Petitori",
113
79
  actionMenuItems: [
114
80
  {
115
81
  icon: "open_in_new",
116
82
  label: "Analítiques",
117
83
  callbackFn: async (): Promise<void> => {
118
- publishEcapNoCloseWithCip("LABORATORI");
84
+ navigateToEcapWithoutClosingWithCip("LABORATORI");
119
85
  },
120
86
  },
121
87
  {
122
88
  icon: "open_in_new",
123
- label: "OC",
89
+ label: "Ordres Clíniques",
124
90
  callbackFn: async (): Promise<void> => {
125
- const CIP = await getPatientCip();
126
- publishEcapNoCloseWithCip("RESULT_OC");
91
+ navigateToEcapWithoutClosingWithCip("RESULT_OC");
127
92
  },
128
93
  },
129
94
  {
130
95
  icon: "open_in_new",
131
96
  label: "OC Exprés",
132
97
  callbackFn: async (): Promise<void> => {
133
- const CIP = await getPatientCip();
134
- publishEcapNoCloseWithCip("OC_EXPRES");
98
+ navigateToEcapWithoutClosingWithCip("OC_EXPRES");
135
99
  },
136
100
  },
137
101
  {
138
102
  icon: "open_in_new",
139
103
  label: "Sol·licitud de trasllat",
140
104
  callbackFn: async (): Promise<void> => {
141
- const CIP = await getPatientCip();
142
- publishEcapNoCloseWithCip("TRANSPORT");
105
+ navigateToEcapWithoutClosingWithCip("TRANSPORT");
143
106
  },
144
107
  },
145
108
  ],
146
109
  });
147
110
  return Promise.resolve(menuItem);
148
111
  },
112
+ sortHint: "000500",
149
113
  });
150
114
  shellApi.regionManager.registerView(shellRegions.navigationMenu, {
151
115
  id: "results-reports",
152
116
  factory: () => {
153
117
  const menuItem = new PrimariaNavTreeMenu({
154
- icon: "add_box",
155
- label: "Resultats i informes",
118
+ icon: "folder_shared",
119
+ label: "Documents",
156
120
  actionMenuItems: [
157
121
  {
158
122
  icon: "open_in_new",
@@ -163,9 +127,8 @@ const registerUpperNavMenuViews = () => {
163
127
  icon: "open_in_new",
164
128
  label: "Documents usuari",
165
129
  callbackFn: async (): Promise<void> => {
166
- const CIP = await getPatientCip();
167
130
  setTimeout(() => {
168
- publishEcapNoCloseWithCip("CRIDA_DOCS_USU");
131
+ navigateToEcapWithoutClosingWithCip("CRIDA_DOCS_USU");
169
132
  }, 0);
170
133
  },
171
134
  },
@@ -173,92 +136,91 @@ const registerUpperNavMenuViews = () => {
173
136
  });
174
137
  return Promise.resolve(menuItem);
175
138
  },
139
+ sortHint: "000700",
176
140
  });
177
141
  shellApi.regionManager.registerView(shellRegions.navigationMenu, {
178
- id: "processes",
142
+ id: "communication",
179
143
  factory: () => {
180
144
  const menuItem = new PrimariaNavTreeMenu({
181
- icon: "add_box",
182
- label: "Processos",
145
+ icon: "3p",
146
+ label: "Comunicació",
183
147
  actionMenuItems: [
184
148
  {
185
149
  icon: "open_in_new",
186
- label: "ARES",
187
- callbackFn: async () => {
188
- const CIP = await getPatientCip();
189
- publishEcapNoCloseWithCip("PROCES_ATENCIO");
150
+ label: "SMS",
151
+ callbackFn: async (): Promise<void> => {
152
+ const CIP = await getPatientCip(shellApi);
153
+ shellApi.ecapEventManager.publish("MISSATGES_DEV", "NO_TANCAR", {
154
+ CIP: CIP || "",
155
+ TipusMissatge: "SMS",
156
+ });
190
157
  },
191
158
  },
192
159
  {
193
160
  icon: "open_in_new",
194
- label: "Nen sa",
195
- callbackFn: async () => {
196
- const CIP = await getPatientCip();
197
- publishEcapNoCloseWithCip("NEN_SA");
198
- },
161
+ label: "Econsulta",
162
+ callbackFn: (): void => {},
199
163
  },
200
164
  {
201
165
  icon: "open_in_new",
202
- label: "Procés Obstètric",
166
+ label: "Mail",
203
167
  callbackFn: (): void => {},
204
168
  },
205
169
  {
206
170
  icon: "open_in_new",
207
- label: "Odontologia",
208
- callbackFn: async () => {
209
- const CIP = await getPatientCip();
210
- publishEcapNoCloseWithCip("ODONTOLOGO");
171
+ label: "Veu IP",
172
+ callbackFn: async (): Promise<void> => {
173
+ navigateToEcapWithoutClosingWithCip("VOIP");
211
174
  },
212
175
  },
213
176
  {
214
177
  icon: "open_in_new",
215
- label: "Situació d'especial cura",
216
- callbackFn: async () => {
217
- const CIP = await getPatientCip();
218
- publishEcapNoCloseWithCip("SIT_ESPEC_CURA_DEV");
219
- },
178
+ label: "Videoconsulta",
179
+ callbackFn: (): void => {},
220
180
  },
221
181
  ],
222
182
  });
223
183
  return Promise.resolve(menuItem);
224
184
  },
185
+ sortHint: "001200",
225
186
  });
226
187
  shellApi.regionManager.registerView(shellRegions.navigationMenu, {
227
- id: "variable activities",
188
+ id: "visits",
228
189
  factory: () => {
229
190
  const menuItem = new PrimariaNavItem({
230
- icon: "add_box",
231
- label: "Activitats variables",
232
- callbackFn: async () => {
233
- const CIP = await getPatientCip();
234
- publishEcapNoCloseWithCip("SIA_DEV");
191
+ icon: "event",
192
+ label: "Visites",
193
+ callbackFn: async (): Promise<void> => {
194
+ navigateToEcapWithoutClosingWithCip("CONSULTA_VISITES");
235
195
  },
236
196
  });
237
197
  return Promise.resolve(menuItem);
238
198
  },
199
+ sortHint: "001300",
239
200
  });
201
+
240
202
  shellApi.regionManager.registerView(shellRegions.navigationMenu, {
241
- id: clinicalMonitoringId,
203
+ id: "it",
242
204
  factory: () => {
243
205
  const menuItem = new PrimariaNavItem({
244
206
  icon: "add_box",
245
- label: "Seguiment clínic",
246
- callbackFn: () => {
247
- shellApi.regionManager.activateMainView(clinicalMonitoringId);
248
- shellApi.broker.publish(shellEvents.openClinicalMonitoringRequested);
207
+ label: "IT",
208
+ callbackFn: async (): Promise<void> => {
209
+ navigateToEcapWithoutClosingWithCip("REV_IT");
249
210
  },
250
211
  });
251
212
  return Promise.resolve(menuItem);
252
213
  },
253
214
  });
215
+
254
216
  shellApi.regionManager.registerView(shellRegions.navigationMenu, {
255
- id: "landing",
217
+ id: "variable activities",
256
218
  factory: () => {
257
219
  const menuItem = new PrimariaNavItem({
258
220
  icon: "add_box",
259
- label: "Pàgina inici",
260
- callbackFn: () => {
261
- shellApi.broker.send(new ExitShell());
221
+ label: "Activitats variables",
222
+ callbackFn: async () => {
223
+ navigateToEcapWithoutClosingWithCip("SIA_DEV");
262
224
  },
263
225
  });
264
226
  return Promise.resolve(menuItem);
@@ -271,7 +233,7 @@ const registerLowerNavMenuViews = () => {
271
233
  id: "configuration-center",
272
234
  factory: () => {
273
235
  const menuItem = new PrimariaNavItem({
274
- icon: "add_box",
236
+ icon: "settings",
275
237
  label: "Centre de configuració",
276
238
  callbackFn: () => {
277
239
  // shellApi.regionManager.activateView(shellRegions.main, "");
@@ -283,37 +245,11 @@ const registerLowerNavMenuViews = () => {
283
245
  };
284
246
 
285
247
  const registerMainViews = () => {
286
- shellApi.regionManager.registerMainView({
287
- id: clinicalMonitoringId,
288
- factory: () => {
289
- const mainItem = new ClinicalMonitoring();
290
- return Promise.resolve(mainItem as unknown as HTMLElement);
291
- },
292
- isDefault: true,
293
- });
294
- shellApi.regionManager.registerMainView({
295
- id: pocTestEventsId,
296
- factory: () => {
297
- const mainItem = new PocEventsEcap();
298
- return Promise.resolve(mainItem as unknown as HTMLElement);
299
- },
300
- });
301
-
302
- shellApi.regionManager.registerMainView({
303
- id: pdfViewerId,
304
- factory: () => {
305
- const mainItem = new PdfVisor();
306
- return Promise.resolve(mainItem as unknown as HTMLElement);
307
- },
308
- });
248
+ registerPDFVisorMainView();
309
249
  };
310
250
 
311
- export const registerInternalViews = () => {
251
+ export const useInternalViews = () => {
312
252
  registerMainViews();
313
253
  registerUpperNavMenuViews();
314
254
  registerLowerNavMenuViews();
315
255
  };
316
-
317
- export const activateDefaultView = () => {
318
- shellApi.regionManager.activateMainView(clinicalMonitoringId);
319
- };
@@ -0,0 +1,61 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { getUniqueObjects } from "./get-unique-values-by-prop-path";
3
+
4
+ describe("getUniqueObjects", () => {
5
+ it("should return unique objects by id, keeping the last occurrence", () => {
6
+ const items = [
7
+ { data: { id: "1", label: "Item 1" } },
8
+ { data: { id: "2", label: "Item 2" } },
9
+ { data: { id: "1", label: "Item 1 (duplicate)" } }, // <- este debe sobrescribir
10
+ ];
11
+
12
+ const result = getUniqueObjects(items, ["data", "id"], ["data", "label"]);
13
+
14
+ expect(result).toEqual([
15
+ { id: "1", description: "Item 1 (duplicate)" }, // 👈 el último
16
+ { id: "2", description: "Item 2" },
17
+ ]);
18
+ });
19
+
20
+ it("should skip items with missing id or title", () => {
21
+ const items = [
22
+ { data: { id: "1", label: "Valid" } },
23
+ { data: { id: 2, label: "Invalid ID" } },
24
+ { data: { id: "3", label: null } },
25
+ ];
26
+
27
+ const result = getUniqueObjects(items, ["data", "id"], ["data", "label"]);
28
+
29
+ expect(result).toEqual([{ id: "1", description: "Valid" }]);
30
+ });
31
+
32
+ it("should return an empty array if input is empty", () => {
33
+ const result = getUniqueObjects([], ["a"], ["b"]);
34
+ expect(result).toEqual([]);
35
+ });
36
+
37
+ it("should handle deeply nested paths", () => {
38
+ const items = [
39
+ { a: { b: { c: { id: "x1", name: "Deep 1" } } } },
40
+ { a: { b: { c: { id: "x2", name: "Deep 2" } } } },
41
+ ];
42
+
43
+ const result = getUniqueObjects(items, ["a", "b", "c", "id"], ["a", "b", "c", "name"]);
44
+
45
+ expect(result).toEqual([
46
+ { id: "x1", description: "Deep 1" },
47
+ { id: "x2", description: "Deep 2" },
48
+ ]);
49
+ });
50
+
51
+ it("should handle invalid path safely", () => {
52
+ const items = [
53
+ { a: { b: { id: "1", name: "Good" } } },
54
+ { x: { y: { id: "2", name: "Missing Path" } } },
55
+ ];
56
+
57
+ const result = getUniqueObjects(items, ["a", "b", "id"], ["a", "b", "name"]);
58
+
59
+ expect(result).toEqual([{ id: "1", description: "Good" }]);
60
+ });
61
+ });
@@ -7,9 +7,9 @@ export function getUniqueObjects<T>(
7
7
  items
8
8
  .map((item) => ({
9
9
  id: propPathId.reduce((acc, key) => acc?.[key], item),
10
- title: propPathDescription.reduce((acc, key) => acc?.[key], item),
10
+ description: propPathDescription.reduce((acc, key) => acc?.[key], item),
11
11
  }))
12
- .filter((obj) => typeof obj.id === "string" && typeof obj.title === "string")
12
+ .filter((obj) => typeof obj.id === "string" && typeof obj.description === "string")
13
13
  .reduce(
14
14
  (map, obj) => map.set(obj.id, obj),
15
15
  new Map<string, { id: string; description: string }>(),
@@ -0,0 +1,29 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { normalizeStringToNFD } from "./normalize-string";
3
+
4
+ describe("normalizeStringToNFD", () => {
5
+ it("should remove accents and convert to lowercase", () => {
6
+ expect(normalizeStringToNFD("Árbol")).toBe("arbol");
7
+ expect(normalizeStringToNFD("ÉLÉPHANT")).toBe("elephant");
8
+ expect(normalizeStringToNFD("Niño")).toBe("nino");
9
+ expect(normalizeStringToNFD("Cañón")).toBe("canon");
10
+ });
11
+
12
+ it("should convert only to lowercase if no accents", () => {
13
+ expect(normalizeStringToNFD("HELLO")).toBe("hello");
14
+ expect(normalizeStringToNFD("WORLD")).toBe("world");
15
+ });
16
+
17
+ it("should handle empty string", () => {
18
+ expect(normalizeStringToNFD("")).toBe("");
19
+ });
20
+
21
+ it("should return lowercase even if no normalization is needed", () => {
22
+ expect(normalizeStringToNFD("AlreadyClean")).toBe("alreadyclean");
23
+ });
24
+
25
+ it("should remove accents from multicharacter words", () => {
26
+ expect(normalizeStringToNFD("José Álvarez")).toBe("jose alvarez");
27
+ expect(normalizeStringToNFD("mañana será otro día")).toBe("manana sera otro dia");
28
+ });
29
+ });
@@ -1,4 +1,6 @@
1
- export const normalizeStringToNFD = (text: string) => {
2
- const normalized = text.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
3
- return normalized ? normalized.toLocaleLowerCase() : text;
1
+ export const normalizeStringToNFD = (text: string | number | boolean | null | undefined) => {
2
+ if (text == null) return "";
3
+ const str = String(text);
4
+ const normalized = str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
5
+ return normalized.toLocaleLowerCase();
4
6
  };
@@ -0,0 +1,47 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { propContainsString } from "./prop-contains-string";
3
+
4
+ describe("propContainsString", () => {
5
+ it("should return true if string contains search string (case-insensitive)", () => {
6
+ expect(propContainsString("Leo Messi", "messi")).toBe(true);
7
+ });
8
+
9
+ it("should return true if string contains search string with accents", () => {
10
+ expect(propContainsString("José Álvarez", "alvarez")).toBe(true);
11
+ expect(propContainsString("mañana", "manana")).toBe(true);
12
+ });
13
+
14
+ it("should return true for numeric values", () => {
15
+ expect(propContainsString(12345, "234")).toBe(true);
16
+ expect(propContainsString(2024, "202")).toBe(true);
17
+ });
18
+
19
+ it("should return false if no match", () => {
20
+ expect(propContainsString("Barcelona", "Madrid")).toBe(false);
21
+ });
22
+
23
+ it("should return true if match is exact", () => {
24
+ expect(propContainsString("Hola", "Hola")).toBe(true);
25
+ expect(propContainsString("hola", "HOLA")).toBe(true);
26
+ });
27
+
28
+ it("should handle boolean props", () => {
29
+ expect(propContainsString(true, "tru")).toBe(true);
30
+ expect(propContainsString(false, "false")).toBe(true);
31
+ expect(propContainsString(true, "nope")).toBe(false);
32
+ });
33
+
34
+ it("should return false if prop is null or undefined", () => {
35
+ expect(propContainsString(null, "a")).toBe(false);
36
+ expect(propContainsString(undefined, "a")).toBe(false);
37
+ });
38
+
39
+ it("should return false if search string is not in prop", () => {
40
+ expect(propContainsString("casa", "zzz")).toBe(false);
41
+ });
42
+
43
+ it("should be accent-insensitive and case-insensitive", () => {
44
+ expect(propContainsString("Éxito", "exito")).toBe(true);
45
+ expect(propContainsString("árbol", "ARBOL")).toBe(true);
46
+ });
47
+ });
package/src/locales.ts CHANGED
@@ -4,7 +4,7 @@ import { primariaShellId } from "./constants";
4
4
 
5
5
  let shellLocaleManager;
6
6
 
7
- export const initializeLocalization = async (api: PrimariaApi) => {
7
+ export const useLocalization = async (api: PrimariaApi) => {
8
8
  setLanguage("ca");
9
9
  const localeManager = await api.createLocaleManager(locales);
10
10
  shellLocaleManager = localeManager;
@@ -1,3 +0,0 @@
1
- import { ShellHeader } from './shell-header';
2
-
3
- export declare const template: (props: ShellHeader) => import('lit').TemplateResult<1>;
@@ -1,7 +0,0 @@
1
- import "./primaria-shell/primaria-shell";
2
- import "./clinical-monitoring/clinical-monitoring";
3
- import "../shared-components";
4
- import "./shell-header/shell-header";
5
- import "./quick-actions-menu/quick-actions-menu";
6
- import "../../api/plugin-busy-manager/plugin-busy-list/component";
7
- import "./pdf-visor/pdf-selector/pdf-selector";