@bluealba/pae-ui-react-core 3.0.2-feature-rename-ba-libraries-scope-1169

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 (206) hide show
  1. package/LICENSE +134 -0
  2. package/README.md +368 -0
  3. package/dist/index.cjs.js +252 -0
  4. package/dist/index.css +1 -0
  5. package/dist/index.esm.js +9741 -0
  6. package/dist/index.systemjs.js +253 -0
  7. package/dist/index.umd.js +253 -0
  8. package/dist/src/MicrofrontendProps.d.ts +9 -0
  9. package/dist/src/components/ApplicationIcon.d.ts +7 -0
  10. package/dist/src/components/Authorized.d.ts +12 -0
  11. package/dist/src/components/ExtendExtensionPoint.d.ts +20 -0
  12. package/dist/src/components/ExtensionPoint.d.ts +39 -0
  13. package/dist/src/components/ModulePlaceHolder/BaseContainer.d.ts +4 -0
  14. package/dist/src/components/ModulePlaceHolder/BaseError.d.ts +7 -0
  15. package/dist/src/components/ModulePlaceHolder/BaseLoading.d.ts +7 -0
  16. package/dist/src/components/ModulePlaceHolder/ModulePlaceHolder.d.ts +22 -0
  17. package/dist/src/components/ModulePlaceHolder/index.d.ts +2 -0
  18. package/dist/src/components/PAEModule.d.ts +18 -0
  19. package/dist/src/components/PlatformEventListener.d.ts +12 -0
  20. package/dist/src/components/common/Alert/Alert.d.ts +16 -0
  21. package/dist/src/components/common/Alert/index.d.ts +2 -0
  22. package/dist/src/components/common/Badge/Badge.d.ts +9 -0
  23. package/dist/src/components/common/Badge/Badge.stories.d.ts +20 -0
  24. package/dist/src/components/common/Badge/Badges.d.ts +6 -0
  25. package/dist/src/components/common/Button/Button.d.ts +10 -0
  26. package/dist/src/components/common/Button/Button.stories.d.ts +45 -0
  27. package/dist/src/components/common/ConfirmDialog/ConfirmDialog.d.ts +11 -0
  28. package/dist/src/components/common/ConfirmDialog/ConfirmDialog.stories.d.ts +14 -0
  29. package/dist/src/components/common/CopyToClipboardButton/CopyToClipboardButton.d.ts +7 -0
  30. package/dist/src/components/common/CopyToClipboardButton/CopyToClipboardButton.stories.d.ts +15 -0
  31. package/dist/src/components/common/Dialog/Dialog.d.ts +26 -0
  32. package/dist/src/components/common/Dialog/Dialog.stories.d.ts +14 -0
  33. package/dist/src/components/common/Dialog/index.d.ts +2 -0
  34. package/dist/src/components/common/Dialog/subComponents/Actions.d.ts +6 -0
  35. package/dist/src/components/common/Dialog/subComponents/Close.d.ts +6 -0
  36. package/dist/src/components/common/Dialog/subComponents/Content.d.ts +6 -0
  37. package/dist/src/components/common/Dialog/subComponents/Description.d.ts +6 -0
  38. package/dist/src/components/common/Dialog/subComponents/Footer.d.ts +6 -0
  39. package/dist/src/components/common/Dialog/subComponents/Header.d.ts +6 -0
  40. package/dist/src/components/common/Dialog/subComponents/Title.d.ts +6 -0
  41. package/dist/src/components/common/DropdownList/DropdownList.d.ts +8 -0
  42. package/dist/src/components/common/DropdownList/index.d.ts +3 -0
  43. package/dist/src/components/common/EmptyState/EmptyState.d.ts +7 -0
  44. package/dist/src/components/common/EmptyState/EmptyState.stories.d.ts +16 -0
  45. package/dist/src/components/common/EmptyState/EmptyStateIcon.d.ts +7 -0
  46. package/dist/src/components/common/ErrorState/ErrorState.d.ts +9 -0
  47. package/dist/src/components/common/ErrorState/ErrorState.stories.d.ts +11 -0
  48. package/dist/src/components/common/ErrorState/WarningIcon.d.ts +6 -0
  49. package/dist/src/components/common/ErrorState/index.d.ts +2 -0
  50. package/dist/src/components/common/FieldGroup/FieldGroup.d.ts +7 -0
  51. package/dist/src/components/common/Icon/ArrowDown.d.ts +7 -0
  52. package/dist/src/components/common/Icon/ChevronLeft.d.ts +7 -0
  53. package/dist/src/components/common/Icon/ChevronRight.d.ts +7 -0
  54. package/dist/src/components/common/Icon/ClipboardCheckIcon.d.ts +13 -0
  55. package/dist/src/components/common/Icon/ClipboardIcon.d.ts +14 -0
  56. package/dist/src/components/common/Icon/EyeIcon.d.ts +13 -0
  57. package/dist/src/components/common/Icon/HorizontalDots.d.ts +7 -0
  58. package/dist/src/components/common/Input/Input.d.ts +7 -0
  59. package/dist/src/components/common/Input/Input.stories.d.ts +23 -0
  60. package/dist/src/components/common/InputError/InputError.d.ts +6 -0
  61. package/dist/src/components/common/Label/Label.d.ts +7 -0
  62. package/dist/src/components/common/List/List.d.ts +26 -0
  63. package/dist/src/components/common/List/List.stories.d.ts +27 -0
  64. package/dist/src/components/common/List/index.d.ts +2 -0
  65. package/dist/src/components/common/List/subComponents/Action.d.ts +6 -0
  66. package/dist/src/components/common/List/subComponents/Actions.d.ts +6 -0
  67. package/dist/src/components/common/List/subComponents/Description.d.ts +6 -0
  68. package/dist/src/components/common/List/subComponents/Icon.d.ts +6 -0
  69. package/dist/src/components/common/List/subComponents/Item.d.ts +8 -0
  70. package/dist/src/components/common/List/subComponents/Title.d.ts +6 -0
  71. package/dist/src/components/common/Pagination/Pagination.d.ts +31 -0
  72. package/dist/src/components/common/PasswordInput/PasswordInput.d.ts +8 -0
  73. package/dist/src/components/common/PasswordInput/PasswordInput.stories.d.ts +20 -0
  74. package/dist/src/components/common/Pill/Pill.d.ts +8 -0
  75. package/dist/src/components/common/Pill/Pill.stories.d.ts +26 -0
  76. package/dist/src/components/common/PluralizeCounter/PluralizeCounter.d.ts +9 -0
  77. package/dist/src/components/common/PluralizeCounter/PluralizeCounter.stories.d.ts +14 -0
  78. package/dist/src/components/common/SearchAutocomplete/AutocompleteHighlighter.d.ts +8 -0
  79. package/dist/src/components/common/SearchAutocomplete/AutocompleteItem.d.ts +7 -0
  80. package/dist/src/components/common/SearchAutocomplete/SearchAutocomplete.d.ts +27 -0
  81. package/dist/src/components/common/SearchAutocomplete/SearchAutocomplete.stories.d.ts +51 -0
  82. package/dist/src/components/common/SearchAutocomplete/hooks/useAutocomplete.d.ts +13 -0
  83. package/dist/src/components/common/SearchAutocomplete/types.d.ts +12 -0
  84. package/dist/src/components/common/SearchInput/SearchInput.d.ts +9 -0
  85. package/dist/src/components/common/SearchInput/SearchInput.stories.d.ts +30 -0
  86. package/dist/src/components/common/Select/Option.d.ts +6 -0
  87. package/dist/src/components/common/Select/Select.d.ts +13 -0
  88. package/dist/src/components/common/Select/Select.stories.d.ts +20 -0
  89. package/dist/src/components/common/Show/Show.d.ts +32 -0
  90. package/dist/src/components/common/Skeleton/Skeleton.d.ts +11 -0
  91. package/dist/src/components/common/Skeleton/Skeleton.stories.d.ts +11 -0
  92. package/dist/src/components/common/Skeleton/SkeletonList.d.ts +10 -0
  93. package/dist/src/components/common/Skeleton/SkeletonList.stories.d.ts +11 -0
  94. package/dist/src/components/common/Spinner/Spinner.d.ts +10 -0
  95. package/dist/src/components/common/Spinner/Spinner.stories.d.ts +11 -0
  96. package/dist/src/components/common/Switch/Switch.d.ts +15 -0
  97. package/dist/src/components/common/Switch/Switch.stories.d.ts +8 -0
  98. package/dist/src/components/common/Table/Table.d.ts +43 -0
  99. package/dist/src/components/common/Table/Table.stories.d.ts +65 -0
  100. package/dist/src/components/common/Table/TablePagination.d.ts +9 -0
  101. package/dist/src/components/common/Table/generatePagination.d.ts +1 -0
  102. package/dist/src/components/common/Table/table.test.d.ts +1 -0
  103. package/dist/src/components/common/Tabs/Tabs.d.ts +30 -0
  104. package/dist/src/components/common/TextArea/TextArea.d.ts +6 -0
  105. package/dist/src/components/common/TextArea/TextArea.stories.d.ts +17 -0
  106. package/dist/src/components/common/Tooltip/Tooltip.d.ts +15 -0
  107. package/dist/src/components/common/Tooltip/Tooltip.stories.d.ts +35 -0
  108. package/dist/src/components/common/index.d.ts +58 -0
  109. package/dist/src/components/index.d.ts +6 -0
  110. package/dist/src/constants/index.d.ts +5 -0
  111. package/dist/src/core/PlatformEvents.d.ts +13 -0
  112. package/dist/src/core/gateway/GatewayHttpHeaders.d.ts +10 -0
  113. package/dist/src/core/index.d.ts +1 -0
  114. package/dist/src/getGlobalState.d.ts +1 -0
  115. package/dist/src/hocs/authorized.d.ts +4 -0
  116. package/dist/src/hocs/extensionPoint.d.ts +17 -0
  117. package/dist/src/hocs/index.d.ts +2 -0
  118. package/dist/src/hooks/applications/ApplicationMenu.d.ts +18 -0
  119. package/dist/src/hooks/applications/PlatformApplication.d.ts +10 -0
  120. package/dist/src/hooks/applications/useApplicationIcon.d.ts +4 -0
  121. package/dist/src/hooks/applications/useApplicationJSModule.d.ts +18 -0
  122. package/dist/src/hooks/applications/useApplicationMenu.d.ts +11 -0
  123. package/dist/src/hooks/applications/useApplicationUIModule.d.ts +4 -0
  124. package/dist/src/hooks/applications/useApplications.d.ts +4 -0
  125. package/dist/src/hooks/applications/useCurrentApplication.d.ts +8 -0
  126. package/dist/src/hooks/applications/useCurrentApplication.test.d.ts +1 -0
  127. package/dist/src/hooks/applications/useCurrentApplicationName.d.ts +6 -0
  128. package/dist/src/hooks/applications/useCurrentJSModule.d.ts +9 -0
  129. package/dist/src/hooks/catalog/useCatalog.d.ts +14 -0
  130. package/dist/src/hooks/catalog/useMutableCatalog.d.ts +28 -0
  131. package/dist/src/hooks/catalog/userCatalog.test.d.ts +1 -0
  132. package/dist/src/hooks/commons/useObservable.d.ts +8 -0
  133. package/dist/src/hooks/commons/useResource.d.ts +21 -0
  134. package/dist/src/hooks/commons/useResourceActions.d.ts +56 -0
  135. package/dist/src/hooks/commons/useSubjectObservable.d.ts +11 -0
  136. package/dist/src/hooks/customizations/useDynamicFonts.d.ts +13 -0
  137. package/dist/src/hooks/customizations/useDynamicStyleSheet.d.ts +1 -0
  138. package/dist/src/hooks/customizations/useGetPlatformTheme.d.ts +3 -0
  139. package/dist/src/hooks/customizations/usePAECustomizationsLoadingState.d.ts +2 -0
  140. package/dist/src/hooks/customizations/usePlatformCustomization.d.ts +8 -0
  141. package/dist/src/hooks/customizations/utils.d.ts +2 -0
  142. package/dist/src/hooks/events/usePlatformEventListener.d.ts +2 -0
  143. package/dist/src/hooks/extensions/useExtendExtensionPoint.d.ts +11 -0
  144. package/dist/src/hooks/extensions/useExtensionPoint.d.ts +16 -0
  145. package/dist/src/hooks/habits/ApplicationEvent.d.ts +4 -0
  146. package/dist/src/hooks/habits/mapEvent.d.ts +17 -0
  147. package/dist/src/hooks/habits/trackEvents.d.ts +9 -0
  148. package/dist/src/hooks/habits/useTrackEvent.d.ts +5 -0
  149. package/dist/src/hooks/habits/useTrackEvents.d.ts +9 -0
  150. package/dist/src/hooks/habits/useTrackEvents.test.d.ts +1 -0
  151. package/dist/src/hooks/index.d.ts +42 -0
  152. package/dist/src/hooks/module/useModule.d.ts +6 -0
  153. package/dist/src/hooks/module/useModuleCommonPaths.d.ts +9 -0
  154. package/dist/src/hooks/module/useModuleConfig.d.ts +5 -0
  155. package/dist/src/hooks/module/useModuleConfigByName.d.ts +5 -0
  156. package/dist/src/hooks/module/useModuleMetadata.d.ts +8 -0
  157. package/dist/src/hooks/routing/useLocation.d.ts +7 -0
  158. package/dist/src/hooks/tenants/constants.d.ts +21 -0
  159. package/dist/src/hooks/tenants/getClientTenantStrategy.d.ts +4 -0
  160. package/dist/src/hooks/tenants/strategies/cookie.d.ts +7 -0
  161. package/dist/src/hooks/tenants/strategies/queryParams.d.ts +7 -0
  162. package/dist/src/hooks/tenants/strategies/sessionStorage.d.ts +7 -0
  163. package/dist/src/hooks/tenants/strategies/subdomain.d.ts +9 -0
  164. package/dist/src/hooks/tenants/strategies/tenantStrategy.interface.d.ts +6 -0
  165. package/dist/src/hooks/tenants/useTenants.d.ts +8 -0
  166. package/dist/src/hooks/useAppStatus.d.ts +6 -0
  167. package/dist/src/hooks/useAppsState.d.ts +18 -0
  168. package/dist/src/hooks/useAuth.d.ts +14 -0
  169. package/dist/src/hooks/useAuth.test.d.ts +1 -0
  170. package/dist/src/hooks/useHasNoSession.d.ts +2 -0
  171. package/dist/src/hooks/useNotifications.d.ts +4 -0
  172. package/dist/src/hooks/useOperations.d.ts +1 -0
  173. package/dist/src/hooks/usePAEState.d.ts +7 -0
  174. package/dist/src/hooks/useServiceBaseURL.d.ts +6 -0
  175. package/dist/src/hooks/useServiceInvoker.d.ts +20 -0
  176. package/dist/src/hooks/useServiceInvoker.test.d.ts +1 -0
  177. package/dist/src/hooks/useUIApplications.d.ts +5 -0
  178. package/dist/src/hooks/userState/UserState.d.ts +7 -0
  179. package/dist/src/hooks/userState/UserStateApiClient.d.ts +9 -0
  180. package/dist/src/hooks/userState/useUserState.d.ts +24 -0
  181. package/dist/src/index.d.ts +11 -0
  182. package/dist/src/model/ModuleMetadata.d.ts +6 -0
  183. package/dist/src/test-utils/setupTestEnvironment.d.ts +15 -0
  184. package/dist/src/types.d.ts +37 -0
  185. package/dist/src/utils/Request.d.ts +7 -0
  186. package/dist/src/utils/URL.d.ts +6 -0
  187. package/dist/src/utils/alphaColor.d.ts +1 -0
  188. package/dist/src/utils/createRootComponent.d.ts +9 -0
  189. package/dist/src/utils/fonts.d.ts +5 -0
  190. package/dist/src/utils/getApplicationUIModule.d.ts +10 -0
  191. package/dist/src/utils/getApplications.d.ts +4 -0
  192. package/dist/src/utils/getOperations.d.ts +5 -0
  193. package/dist/src/utils/hasAccess.d.ts +8 -0
  194. package/dist/src/utils/immutable.d.ts +18 -0
  195. package/dist/src/utils/index.d.ts +18 -0
  196. package/dist/src/utils/initializeMicroFrontend.d.ts +17 -0
  197. package/dist/src/utils/isValidEmail.d.ts +1 -0
  198. package/dist/src/utils/isValidEmail.test.d.ts +1 -0
  199. package/dist/src/utils/logout.d.ts +1 -0
  200. package/dist/src/utils/logout.test.d.ts +1 -0
  201. package/dist/src/utils/navigateTo.d.ts +1 -0
  202. package/dist/src/utils/promises.d.ts +4 -0
  203. package/dist/tests/renderHookWithProviders.d.ts +3 -0
  204. package/dist/tests/testUtils.d.ts +7 -0
  205. package/package.json +61 -0
  206. package/src/global.css +32 -0
package/LICENSE ADDED
@@ -0,0 +1,134 @@
1
+ Required Notice: Copyright Blue Alba LLC 2025 (https://bluealba.com)
2
+
3
+ # PolyForm Noncommercial License 1.0.0
4
+
5
+ <https://polyformproject.org/licenses/noncommercial/1.0.0>
6
+
7
+ ## Acceptance
8
+
9
+ In order to get any license under these terms, you
10
+ must agree to them as both strict obligations and
11
+ conditions to all your licenses.
12
+
13
+ ## Copyright License
14
+
15
+ The licensor grants you a copyright license for the
16
+ software to do everything you might do with the
17
+ software that would otherwise infringe the licensor's
18
+ copyright in it for any permitted purpose. However,
19
+ you may only distribute the software according to
20
+ [Distribution License](#distribution-license) and make
21
+ changes or new works based on the software according to
22
+ [Changes and New Works License](#changes-and-new-works-license).
23
+
24
+ ## Distribution License
25
+
26
+ The licensor grants you an additional copyright license
27
+ to distribute copies of the software. Your license
28
+ to distribute covers distributing the software with
29
+ changes and new works permitted by [Changes and New Works
30
+ License](#changes-and-new-works-license).
31
+
32
+ ## Notices
33
+
34
+ You must ensure that anyone who gets a copy of any part of
35
+ the software from you also gets a copy of these terms or
36
+ the URL for them above, as well as copies of any plain-text
37
+ lines beginning with `Required Notice:` that the licensor
38
+ provided with the software. For example:
39
+
40
+ > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
41
+
42
+ ## Changes and New Works License
43
+
44
+ The licensor grants you an additional copyright license to
45
+ make changes and new works based on the software for any
46
+ permitted purpose.
47
+
48
+ ## Patent License
49
+
50
+ The licensor grants you a patent license for the software
51
+ that covers patent claims the licensor can license, as well
52
+ as patent claims that the licensor becomes able to license.
53
+
54
+ ## Noncommercial Purposes
55
+
56
+ Any noncommercial purpose is a permitted purpose.
57
+
58
+ ## Personal Uses
59
+
60
+ Personal use for research, experiment, and testing for
61
+ the benefit of public knowledge, personal study, private
62
+ entertainment, hobby projects, amateur pursuits, or religious
63
+ observance, without any anticipated commercial application,
64
+ is use for a permitted purpose.
65
+
66
+ ## Noncommercial Organizations
67
+
68
+ Use by any charitable organization, educational institution,
69
+ public research organization, public safety or health
70
+ organization, environmental protection organization, or
71
+ government institution is use for a permitted purpose
72
+ regardless of the source of funding or obligations resulting
73
+ from the funding.
74
+
75
+ ## Fair Use
76
+
77
+ You may have "fair use" rights for the software under the
78
+ law. These terms do not limit them.
79
+
80
+ ## No Other Rights
81
+
82
+ These terms do not allow you to sublicense or transfer any of
83
+ your licenses to anyone else, or prevent the licensor from
84
+ granting licenses to anyone else. These terms do not imply
85
+ any other licenses.
86
+
87
+ ## Patent Defense
88
+
89
+ If you make any written claim that the software infringes or
90
+ contributes to infringement of any patent, your patent license
91
+ for the software granted under these terms ends immediately. If
92
+ your company makes such a claim, your patent license ends
93
+ immediately for work on behalf of your company.
94
+
95
+ ## Violations
96
+
97
+ The first time you are notified in writing that you have
98
+ violated any of these terms, or done anything with the software
99
+ not covered by your licenses, your licenses can nonetheless
100
+ continue if you come into full compliance with these terms,
101
+ and take practical steps to correct past violations, within
102
+ 32 days of receiving notice. Otherwise, all your licenses
103
+ end immediately.
104
+
105
+ ## No Liability
106
+
107
+ ***As far as the law allows, the software comes as is, without
108
+ any warranty or condition, and the licensor will not be liable
109
+ to you for any damages arising out of these terms or the use
110
+ or nature of the software, under any kind of legal claim.***
111
+
112
+ ## Definitions
113
+
114
+ The **licensor** is the individual or entity offering these
115
+ terms, and the **software** is the software the licensor makes
116
+ available under these terms, including any portion of the
117
+ software.
118
+
119
+ **You** refers to the individual or entity agreeing to these
120
+ terms.
121
+
122
+ **Your company** is any legal entity, sole proprietorship,
123
+ or other kind of organization that you work for, plus all
124
+ organizations that have control over, are under the control of,
125
+ or are under common control with that organization. **Control**
126
+ means ownership of substantially all the assets of an entity,
127
+ or the power to direct its management and policies by vote,
128
+ contract, or otherwise. Control can be direct or indirect.
129
+
130
+ **Your licenses** are all the licenses granted to you for the
131
+ software under these terms.
132
+
133
+ **Use** means anything you do with the software requiring one
134
+ of your licenses.
package/README.md ADDED
@@ -0,0 +1,368 @@
1
+ # PAE - UI React Core
2
+
3
+ [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=bluealba_pae-react-utils&metric=alert_status&token=171e950fb2dac9f76dc3deaf0bda73068df11647)](https://sonarcloud.io/summary/new_code?id=bluealba_pae-react-utils)
4
+ [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=bluealba_pae-react-utils&metric=bugs&token=171e950fb2dac9f76dc3deaf0bda73068df11647)](https://sonarcloud.io/summary/new_code?id=bluealba_pae-react-utils)
5
+ [![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=bluealba_pae-react-utils&metric=code_smells&token=171e950fb2dac9f76dc3deaf0bda73068df11647)](https://sonarcloud.io/summary/new_code?id=bluealba_pae-react-utils)
6
+ [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=bluealba_pae-react-utils&metric=coverage&token=171e950fb2dac9f76dc3deaf0bda73068df11647)](https://sonarcloud.io/summary/new_code?id=bluealba_pae-react-utils)
7
+ [![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=bluealba_pae-react-utils&metric=duplicated_lines_density&token=171e950fb2dac9f76dc3deaf0bda73068df11647)](https://sonarcloud.io/summary/new_code?id=bluealba_pae-react-utils)
8
+ [![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=bluealba_pae-react-utils&metric=ncloc&token=171e950fb2dac9f76dc3deaf0bda73068df11647)](https://sonarcloud.io/summary/new_code?id=bluealba_pae-react-utils)
9
+ [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=bluealba_pae-react-utils&metric=reliability_rating&token=171e950fb2dac9f76dc3deaf0bda73068df11647)](https://sonarcloud.io/summary/new_code?id=bluealba_pae-react-utils)
10
+ [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=bluealba_pae-react-utils&metric=security_rating&token=171e950fb2dac9f76dc3deaf0bda73068df11647)](https://sonarcloud.io/summary/new_code?id=bluealba_pae-react-utils)
11
+ [![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=bluealba_pae-react-utils&metric=sqale_index&token=171e950fb2dac9f76dc3deaf0bda73068df11647)](https://sonarcloud.io/summary/new_code?id=bluealba_pae-react-utils)
12
+ [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=bluealba_pae-react-utils&metric=sqale_rating&token=171e950fb2dac9f76dc3deaf0bda73068df11647)](https://sonarcloud.io/summary/new_code?id=bluealba_pae-react-utils)
13
+ [![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=bluealba_pae-react-utils&metric=vulnerabilities&token=171e950fb2dac9f76dc3deaf0bda73068df11647)](https://sonarcloud.io/summary/new_code?id=bluealba_pae-react-utils)
14
+
15
+ Core PAE library for PAE microfrontend applications.
16
+ It exposes PAE functionality in the form of react elements such as hooks, components, etc. which provide cross-cutting
17
+ concerns such as Authentication (Impersonation), Authorization, Service Interaction, Monitoring, etc.
18
+
19
+ # Usage
20
+
21
+ ## Initialize your Microfrontend
22
+
23
+ A PAE microfrontend must be created by calling the `initiliazeMicroFrontend()` function (not although you could directly create a SingleSPA application
24
+ that will tied you to SPA and you won't be able to use all the functionality of this PAE library).
25
+
26
+ ```jsx
27
+ import React from "react";
28
+ import ReactDOMClient from "react-dom/client";
29
+ import { initializeMicroFrontend } from "@bluealba/pae-ui-react-core";
30
+ import Root from "./root.component";
31
+
32
+ export const { bootstrap, mount, unmount } = initializeMicroFrontend({
33
+ React,
34
+ ReactDOMClient,
35
+ rootComponent: Root,
36
+ errorBoundary(err) {
37
+ console.error(err);
38
+ return (
39
+ <div>
40
+ <h1>Something went wrong</h1>
41
+ <p>{err.message}</p>
42
+ </div>
43
+ );
44
+ }
45
+ });
46
+ ```
47
+
48
+ The most important part here is that you specify your `rootComponent` of your app and a way to handle errors locally.
49
+
50
+ ## Utility Functions
51
+
52
+ ### navigateTo() utility function
53
+
54
+ Use this function to navigate to a different url. This function is a wrapper around the `single-spa` `navigateToURL` function
55
+
56
+ ```typescript jsx
57
+ import { navigateTo } from '@bluealba/pae-ui-react-core';
58
+
59
+ navigateTo('/path/to/another/module');
60
+ ```
61
+
62
+ ## Hooks
63
+
64
+ PAE provides the following hooks to access data and interact with PAE services.
65
+
66
+ ### useAuth
67
+
68
+ Retrieve the current user information as well as a method to check authorization access.
69
+
70
+ ```jsx
71
+ import { useAuth } from '@bluealba/pae-ui-react-core';
72
+
73
+ const TestComponent = () => {
74
+ const { authUser, hasAccess } = useAuth();
75
+ return (
76
+ <div>
77
+ <h1>{authUser.displayName}</h1> {/* e.g: John Doe */}
78
+ <p>{authUser.username}</p> {/* e.g: johndoe */}
79
+ <p>{authUser.familyName}</p> {/* e.g: Doe */}
80
+ <p>{authUser.givenName}</p> {/* e.g: John */}
81
+ <p>{authUser.initials}</p> {/* e.g: JD */}
82
+ <p>{hasAccess('operation1', 'operation2')}</p>
83
+ </div>
84
+ );
85
+ };
86
+ ```
87
+
88
+ ### useCatalog
89
+
90
+ Use this hook to get access to the current ecosystem applications and modules catalog
91
+
92
+ ```jsx
93
+ import { useCatalog } from '@bluealba/pae-ui-react-core';
94
+
95
+ const TestComponent = () => {
96
+ const { catalog } = useCatalog();
97
+ return (
98
+ <div>
99
+ {catalog.map((item) => (
100
+ <div key={item.name}>
101
+ <h1>{item.name}</h1>
102
+ <p>{item.version}</p>
103
+ </div>
104
+ ))}
105
+ </div>
106
+ );
107
+ };
108
+ ```
109
+
110
+ ### useServiceInvoker
111
+
112
+ Use this service to make a request to a PAE microservice. This way you don't need to know under which path it is exposed
113
+ by the system (gateway). And you just need to know the service/module full name.
114
+ It returns a function that is fully compatible with the `fetch` function
115
+
116
+ ```typescript jsx
117
+ const invoker = useServiceInvoker("@acme/my-wheather-service");
118
+
119
+ return (
120
+ <button onClick={() => invoker('/get-temperature', { method: 'GET' })}>Load</button>
121
+ )
122
+ ```
123
+
124
+ Internally this hook uses the catalog to resolve the service full URL (there is also a `useServiceBaseUrl` hook)
125
+
126
+ ### useTrackEvent
127
+
128
+ Use this service to track Application Usage Events. This is the frontend API to PAE Habits Service.
129
+
130
+ ```typescript jsx
131
+ const trackEvent = useTrackEvent();
132
+
133
+ const trackClickEvent = useCallback(async e => {
134
+ await trackEvent("button-click-app2", {
135
+ buttonText: e.target.innerText
136
+ });
137
+ },
138
+ [trackEvent]
139
+ );
140
+
141
+ return (
142
+ <button onClick={trackClickEvent}>Click Me</button>
143
+ )
144
+ ```
145
+
146
+ The `trackEvent()` function receives the name of the event and a custom payload that can be anything you want.
147
+ PAE will automatically store this event with contextual information such as: the current User, the Module that triggered
148
+ this event and its version and the associated Application (if the module has one), together with timestamps.
149
+
150
+ Alternatively you can also use `useTrackEvents()` (plural) hook to publish more than one event in a single call.
151
+
152
+ ## Authorization
153
+
154
+ In order to render a piece of JSX conditionally based on authorization there are two ways to do this.
155
+ * using the `useAuth()` hook: which is more "manual" but powerful
156
+ * using the `<Authorized>` component
157
+
158
+ ### useAuth()
159
+
160
+ With this hook you get the current user and a utility function `hasAccess()`
161
+
162
+ ```typescript jsx
163
+ const MyComponent = () => {
164
+ const { authUser, hasAccess } = useAuth();
165
+ return (
166
+ <div>
167
+ {hasAccess('operation1', 'operation2') && (
168
+ <div>access granted</div>
169
+ )}
170
+ </div>
171
+ )
172
+ }
173
+ ```
174
+
175
+ ### `<Authorized>` component (recommended)
176
+
177
+ This component only renders the children content if the user has the specified operations
178
+
179
+ ```typescript jsx
180
+ const MyComponent = () => {
181
+ return (
182
+ <Authorized operations={['create-entity', 'update-entity']}>
183
+ <SectionContent>
184
+ <p>You have access to this section</p>
185
+ </SectionContent>
186
+ </Authorized>
187
+ )
188
+ }
189
+ ```
190
+ If it has no access then nothing is rendered.
191
+
192
+ There's also an optional property `forbiddenContent` with which you can specify the content to be displayed in case the user has no grant on the operations.
193
+
194
+ This prop is overloaded and you can pass different content.
195
+ * The name of a React component
196
+ * A render function
197
+ * A straight JSX content
198
+
199
+ For example a render function
200
+
201
+ ```typescript jsx
202
+ // passing a React component
203
+ <Authorized operations={['create-entity', 'update-entity']} forbiddenContent={ForbiddenComponent}>
204
+ <SectionContent>
205
+ <p>You have access to this section</p>
206
+ </SectionContent>
207
+ </Authorized>
208
+
209
+ // passing a render prop function
210
+ <Authorized operations={['create-entity', 'update-entity']} forbiddenContent={({ operations }) => <ForbiddenComponent operations={operations} />}>
211
+ <SectionContent>
212
+ <p>You have access to this section</p>
213
+ </SectionContent>
214
+ </Authorized>
215
+
216
+ // passing content directly
217
+ <Authorized operations={['create-entity', 'update-entity']} forbiddenContent={<div>Section not allowed</div>}>
218
+ <SectionContent>
219
+ <p>You have access to this section</p>
220
+ </SectionContent>
221
+ </Authorized>
222
+ ```
223
+
224
+
225
+ ## Extension Points
226
+
227
+ They allow UI modules to declare points such as React components that can be later replaced by another value/component
228
+ from another UI module dynamically.
229
+
230
+ ### Declaring an extension point
231
+ There are two ways for a MF to declare an extension point that can be later extended by other MFs. Internally they both the the same thing, it is just a matter of a different flavor of API.
232
+
233
+ * `<ExtensionPoint>` component: useful to declare an extension point inline within a JSX
234
+ * `extensionPoint()` HOC (high-order component): useful to make a whole component replaceable as an extension point.
235
+
236
+ #### Declaring an extension point inline with ExtensionPoint component
237
+
238
+ In any component’s JSX you can declare an extension point, like a “slot” to be extended by other MFs.
239
+
240
+ ```typescript jsx
241
+ const MyComponent = () => {
242
+ return (
243
+ <div>
244
+ Hello <ExtensionPoint name="Greeting" />
245
+ </div>
246
+ )
247
+ }
248
+ ```
249
+
250
+ This will create an extension point that is scoped to the current module with the given name. For example `my-module::Greeting`
251
+
252
+ You can include children elements that will be the fallback/default content in case nobody extends this extension point
253
+
254
+ ```typescript jsx
255
+ const MyComponent = () => {
256
+ return (
257
+ <div>
258
+ Hello <ExtensionPoint name="Greeting"> World </ExtensionPoint>
259
+ </div>
260
+ )
261
+ }
262
+ ```
263
+
264
+ #### Declaring a component as an extension point with the HOC
265
+ There’s another common case where you want a whole component to be “replaceable” completely as an extension point. In this case you can use the `extensionPoint(component)` HOC as a shortcut to void creating a wrapper component just for this.
266
+
267
+ For example the `pae-shell-ui` (or any MF) declares a React component to be an “extension point” by simply using a new `pae-ui-react-core` HOC wrapping the component that is the menu
268
+
269
+ ```typescript jsx
270
+ const MenuApplicationSelector: React.FC = () => {
271
+ // regular react component
272
+ }
273
+
274
+ // the displayName becomes the extension point name by inference (it can be set manual optionally in the hoc call)
275
+ MenuApplicationSelector.displayName = 'ApplicationSelector';
276
+
277
+ // here we are wrapping the component using the HOC which makes it an extension point
278
+ export default extensionPoint(MenuApplicationSelector);
279
+ ```
280
+
281
+ If no-one is extending the point the the component will be rendered. If someone extends it then this component won’t be mounted at all, and it will be replaced by the extending component.
282
+
283
+ ### Extending an Extension Point
284
+
285
+ Then another MF can extend that point in two different ways:
286
+
287
+ * `ExtendExtensionPoint`: Using a built-in component rendering the content inline
288
+ * `useExtendExtensionPoint`: using a hook which allows more programmatic control
289
+
290
+ We will see both options below:
291
+
292
+ #### Using the ExtendExtensionPoint component
293
+
294
+ With a React Component provided by pae-ui-react-core
295
+
296
+ ```typescript jsx
297
+ // somewhere in your MF DOM
298
+ <ExtendExtensionPoint module="@bluealba/pae-shell-ui" point="ApplicationSelector">
299
+ Hello <strong>World</strong> From an Extension!
300
+ </ExtendExtensionPoint>
301
+ ```
302
+
303
+ #### Using the useExtendExtensionPoint hook
304
+
305
+ Or more "manually" using the useExtendExtensionPoint hook
306
+
307
+ ```typescript jsx
308
+ const Root = () => {
309
+ // register the extension
310
+ useExtendExtensionPoint('@bluealba/pae-shell-ui', 'ApplicationSelector', CustomApplicationMenu)
311
+
312
+ return <div> your app content here </div>
313
+ }
314
+ ```
315
+
316
+ In both cases the extension follows the regular React lifecycle ! Meaning that when the component that called the hook/included the extension component gets unmounted, then the extension point gets un-registered dynamically.
317
+ Then this means that components are extended / disengaged dynamically.
318
+
319
+ # Library Development
320
+
321
+ This section is for PAE platform developers or anyone that wants to make changes to this repository.
322
+ This Library is one of the "client facing" API for PAE. Meaning that it is the API that exposes all PAE behavior to
323
+ microfrontends for different customers and projects.
324
+ Because of this we must be very careful with changes in terms of backward compatibility. This is the first layer of
325
+ integration. Some projects might be using different versions of PAE and this library.
326
+
327
+ Therefore we should try to reduce the number of non-backwards compatible changes !!
328
+
329
+ ## Development Process and Releasing
330
+
331
+ To make modifications and have them automatically picked while working locally you should run
332
+
333
+ ```bash
334
+ npm run build-and-publish:watch
335
+ ```
336
+ Just make sure that you have the `pae-orchestrator-service` cloned as a sibling folder to this repo.
337
+
338
+ The following content describes what happens under the hood.
339
+ The cycle goes like this:
340
+ * Create feature branches to work in a feature
341
+ * Eventually merge them into `develop` branch. This will build but not publish any package
342
+ * Once you reached a point where you want to publish a new release. Bump the version to the target version you want to publish and create a PR to `main`
343
+ * Once merged into main the pipeline will automatically build and publish the version to NPMjs public repository.
344
+
345
+ Now there are 2 more steps to follow in order to start using this published version (next sections)
346
+
347
+ ### Update PAE Orchestrator
348
+
349
+ In the PAE architecture the orchestrator is the one that automatically includes this library in runtime for all
350
+ applications. It has its own locally cached bundle js of this library.
351
+ To update it you must
352
+
353
+ * Edit the `build/libs/build-libs.mjs` file in `pae-orchestrator-service` to update the "shared-libraries" entry with the version you just published
354
+ * Run `npm run build:libs` in the orchestrator so that it fetches this new version and caches it
355
+ * Merge to develop to create a new build/image of the orchestrator
356
+ * Apply it to any environment / product you want
357
+
358
+ ### Projects Microfrontends
359
+
360
+ Every microfrontend includes this library as a `devDependency` so that Typescript can use it for type checking.
361
+ Then once built this is not included, because the orchestrator includes it in runtime (think of it as a dynamically
362
+ linked library).
363
+ Nevertheless this means that in order to catch errors and be consistent each microfrontend dependency must match
364
+ the same version of this lib as the orchestrator has for its specific product.
365
+
366
+ So once you release a new version of this lib and update the orchestrator to use it. When you bump the orchestrator
367
+ version for a particular product, you should be going through all your microfrontends and update the devDependency
368
+ to match the released version.