@wavemaker/react-runtime 11.14.1-15.6409

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 (402) hide show
  1. package/actions/base-action.js +32 -0
  2. package/actions/login-action.js +53 -0
  3. package/actions/logout-action.js +41 -0
  4. package/actions/navigation-action.js +145 -0
  5. package/actions/notification-action.js +147 -0
  6. package/actions/timer-action.js +164 -0
  7. package/actions/toast-provider.js +111 -0
  8. package/actions/toast.js +115 -0
  9. package/actions/toast.service.js +94 -0
  10. package/actions/types/index.js +11 -0
  11. package/components/advanced/carousel/index.js +456 -0
  12. package/components/advanced/carousel/props.js +5 -0
  13. package/components/advanced/carousel/template.js +72 -0
  14. package/components/advanced/login/index.js +307 -0
  15. package/components/advanced/login/props.js +5 -0
  16. package/components/advanced/marquee/index.js +158 -0
  17. package/components/advanced/marquee/props.js +5 -0
  18. package/components/basic/anchor/index.js +239 -0
  19. package/components/basic/anchor/props.js +5 -0
  20. package/components/basic/audio/index.js +61 -0
  21. package/components/basic/html/index.js +158 -0
  22. package/components/basic/icon/index.js +85 -0
  23. package/components/basic/iframe/iframe.utils.js +10 -0
  24. package/components/basic/iframe/index.js +95 -0
  25. package/components/basic/label/index.js +139 -0
  26. package/components/basic/message/index.js +120 -0
  27. package/components/basic/message/props.js +5 -0
  28. package/components/basic/picture/index.js +117 -0
  29. package/components/basic/picture/props.js +5 -0
  30. package/components/basic/progress-bar/index.js +168 -0
  31. package/components/basic/progress-bar/props.js +18 -0
  32. package/components/basic/progress-circle/index.js +196 -0
  33. package/components/basic/progress-circle/props.js +16 -0
  34. package/components/basic/richtexteditor/index.js +533 -0
  35. package/components/basic/richtexteditor/props.js +5 -0
  36. package/components/basic/search/index.js +1023 -0
  37. package/components/basic/search/props.js +5 -0
  38. package/components/basic/search/providers.js +350 -0
  39. package/components/basic/spinner/index.js +202 -0
  40. package/components/basic/spinner/props.js +12 -0
  41. package/components/basic/tile/index.js +91 -0
  42. package/components/basic/tree/Components/TreeNodeComponent.js +142 -0
  43. package/components/basic/tree/index.js +503 -0
  44. package/components/basic/tree/props.js +5 -0
  45. package/components/basic/tree/utils.js +154 -0
  46. package/components/basic/video/index.js +85 -0
  47. package/components/basic/video/props.js +5 -0
  48. package/components/chart/components/barColumnChart/index.js +132 -0
  49. package/components/chart/components/barColumnChart/props.js +5 -0
  50. package/components/chart/components/bubbleChart/index.js +176 -0
  51. package/components/chart/components/bubbleChart/props.js +5 -0
  52. package/components/chart/components/chartLegend/components/ClassicLegendItem.js +39 -0
  53. package/components/chart/components/chartLegend/components/FuriousLegendItem.js +81 -0
  54. package/components/chart/components/chartLegend/index.js +69 -0
  55. package/components/chart/components/chartLegend/props.js +5 -0
  56. package/components/chart/components/chartLegend/utils.js +31 -0
  57. package/components/chart/components/chartTooltip/index.js +53 -0
  58. package/components/chart/components/chartTooltip/styles.js +37 -0
  59. package/components/chart/components/chartTooltip/utils.js +23 -0
  60. package/components/chart/components/cumulativeLineChart/index.js +113 -0
  61. package/components/chart/components/cumulativeLineChart/props.js +5 -0
  62. package/components/chart/components/cumulativeLineChart/utils.js +34 -0
  63. package/components/chart/components/index.js +40 -0
  64. package/components/chart/components/lineAreaChart/index.js +140 -0
  65. package/components/chart/components/lineAreaChart/props.js +5 -0
  66. package/components/chart/components/noDataMessage/index.js +27 -0
  67. package/components/chart/components/pieDonutChart/index.js +171 -0
  68. package/components/chart/components/pieDonutChart/props.js +5 -0
  69. package/components/chart/constant.js +72 -0
  70. package/components/chart/index.js +930 -0
  71. package/components/chart/props.js +5 -0
  72. package/components/chart/utils.js +691 -0
  73. package/components/common/AppSpinner.js +36 -0
  74. package/components/common/app-spinner.js +26 -0
  75. package/components/common/index.js +12 -0
  76. package/components/constants.js +1208 -0
  77. package/components/container/accordion/accordion-pane/index.js +108 -0
  78. package/components/container/accordion/accordion-pane/props.js +11 -0
  79. package/components/container/accordion/index.js +232 -0
  80. package/components/container/accordion/props.js +13 -0
  81. package/components/container/alignment-utils.js +183 -0
  82. package/components/container/index.js +188 -0
  83. package/components/container/layout-grid/grid-column/index.js +34 -0
  84. package/components/container/layout-grid/grid-row/index.js +24 -0
  85. package/components/container/layout-grid/index.js +33 -0
  86. package/components/container/linear-layout/index.js +72 -0
  87. package/components/container/linear-layout/linear-layout-item/index.js +43 -0
  88. package/components/container/panel/components/panel-header/index.js +144 -0
  89. package/components/container/panel/components/panel-header/props.js +5 -0
  90. package/components/container/panel/hooks.js +144 -0
  91. package/components/container/panel/index.js +286 -0
  92. package/components/container/panel/props.js +5 -0
  93. package/components/container/props.js +5 -0
  94. package/components/container/tabs/index.js +379 -0
  95. package/components/container/tabs/props.js +20 -0
  96. package/components/container/tabs/tab-pane/index.js +42 -0
  97. package/components/container/tabs/tab-pane/props.js +5 -0
  98. package/components/container/wizard/WizardContext.js +16 -0
  99. package/components/container/wizard/components/StepComponents.js +100 -0
  100. package/components/container/wizard/components/WizardStep.js +89 -0
  101. package/components/container/wizard/index.js +710 -0
  102. package/components/container/wizard/props.js +5 -0
  103. package/components/container/wizard/utils.js +133 -0
  104. package/components/container/wizard/wizard-action/index.js +22 -0
  105. package/components/container/wizard/wizard-step/index.js +94 -0
  106. package/components/data/card/card-actions/index.js +24 -0
  107. package/components/data/card/card-content/index.js +38 -0
  108. package/components/data/card/card-footer/index.js +24 -0
  109. package/components/data/card/index.js +246 -0
  110. package/components/data/card/props.js +5 -0
  111. package/components/data/form/base-form/constant.js +39 -0
  112. package/components/data/form/base-form/index.js +460 -0
  113. package/components/data/form/base-form/props.js +29 -0
  114. package/components/data/form/base-form/utils.js +42 -0
  115. package/components/data/form/dynamic-fields/index.js +196 -0
  116. package/components/data/form/dynamic-fields/props.js +5 -0
  117. package/components/data/form/dynamic-fields/utils.js +237 -0
  118. package/components/data/form/form-action/index.js +71 -0
  119. package/components/data/form/form-body/index.js +26 -0
  120. package/components/data/form/form-context.js +34 -0
  121. package/components/data/form/form-controller/props.js +19 -0
  122. package/components/data/form/form-controller/validation-contrustor.js +313 -0
  123. package/components/data/form/form-controller/withFormController.js +320 -0
  124. package/components/data/form/form-field/base-field.js +138 -0
  125. package/components/data/form/form-field/index.js +36 -0
  126. package/components/data/form/form-field/props.js +5 -0
  127. package/components/data/form/form-footer/index.js +26 -0
  128. package/components/data/form/form-header/index.js +56 -0
  129. package/components/data/form/index.js +39 -0
  130. package/components/data/form/props.js +5 -0
  131. package/components/data/list/components/GroupHeader.js +35 -0
  132. package/components/data/list/components/GroupedListItems.js +98 -0
  133. package/components/data/list/components/ListContainer.js +27 -0
  134. package/components/data/list/components/ListDND.js +241 -0
  135. package/components/data/list/components/ListHeader.js +59 -0
  136. package/components/data/list/components/ListItem.js +148 -0
  137. package/components/data/list/components/ListItemWithTemplate.js +59 -0
  138. package/components/data/list/components/ListItems.js +231 -0
  139. package/components/data/list/components/ListPagination.js +165 -0
  140. package/components/data/list/components/LoadMoreButton.js +39 -0
  141. package/components/data/list/components/NoDataMessage.js +22 -0
  142. package/components/data/list/components/StandardListItems.js +84 -0
  143. package/components/data/list/components/index.js +119 -0
  144. package/components/data/list/components/props.js +5 -0
  145. package/components/data/list/hooks/index.js +75 -0
  146. package/components/data/list/hooks/props.js +5 -0
  147. package/components/data/list/hooks/useCurrentPageItems.js +48 -0
  148. package/components/data/list/hooks/useGroupedData.js +37 -0
  149. package/components/data/list/hooks/useListData.js +60 -0
  150. package/components/data/list/hooks/useListEffects.js +285 -0
  151. package/components/data/list/hooks/useListEventHandlers.js +291 -0
  152. package/components/data/list/hooks/useListPagination.js +168 -0
  153. package/components/data/list/hooks/useListState.js +98 -0
  154. package/components/data/list/hooks/useListStateManager.js +195 -0
  155. package/components/data/list/hooks/usePaginatedGroupedData.js +121 -0
  156. package/components/data/list/index.js +611 -0
  157. package/components/data/list/props.js +5 -0
  158. package/components/data/list/templates/media-template.js +53 -0
  159. package/components/data/list/utils/constants.js +81 -0
  160. package/components/data/list/utils/list-helpers.js +173 -0
  161. package/components/data/list/utils/list-widget-methods.js +114 -0
  162. package/components/data/live-filter/index.js +279 -0
  163. package/components/data/live-filter/props.js +12 -0
  164. package/components/data/live-form/index.js +93 -0
  165. package/components/data/live-form/props.js +16 -0
  166. package/components/data/pagination/components/BasicPagination.js +77 -0
  167. package/components/data/pagination/components/ClassicPagination.js +191 -0
  168. package/components/data/pagination/components/InlinePagination.js +99 -0
  169. package/components/data/pagination/components/LoadingComponent.js +31 -0
  170. package/components/data/pagination/components/PageSizeSelector.js +175 -0
  171. package/components/data/pagination/components/PagerNavigation.js +105 -0
  172. package/components/data/pagination/components/TotalRecords.js +52 -0
  173. package/components/data/pagination/components/index.js +47 -0
  174. package/components/data/pagination/components/props.js +5 -0
  175. package/components/data/pagination/hooks/index.js +19 -0
  176. package/components/data/pagination/hooks/props.js +5 -0
  177. package/components/data/pagination/hooks/useNavigationSize.js +44 -0
  178. package/components/data/pagination/hooks/usePagination.js +796 -0
  179. package/components/data/pagination/index.js +322 -0
  180. package/components/data/table/components/AddNewRow.js +190 -0
  181. package/components/data/table/components/EditableCell.js +91 -0
  182. package/components/data/table/components/FieldValidationError.js +24 -0
  183. package/components/data/table/components/RowExpansionButton.js +74 -0
  184. package/components/data/table/components/TableBody.js +279 -0
  185. package/components/data/table/components/TableFilters.js +325 -0
  186. package/components/data/table/components/TableFooterActions.js +48 -0
  187. package/components/data/table/components/TableHeader.js +174 -0
  188. package/components/data/table/components/TablePanelHeading.js +68 -0
  189. package/components/data/table/components/index.js +74 -0
  190. package/components/data/table/hooks/index.js +219 -0
  191. package/components/data/table/hooks/useCellState.js +117 -0
  192. package/components/data/table/hooks/useDynamicColumns.js +85 -0
  193. package/components/data/table/hooks/useEditingState.js +47 -0
  194. package/components/data/table/hooks/useFormWidget.js +184 -0
  195. package/components/data/table/hooks/usePaginationState.js +60 -0
  196. package/components/data/table/hooks/usePanelStructure.js +40 -0
  197. package/components/data/table/hooks/useResponsiveColumns.js +34 -0
  198. package/components/data/table/hooks/useRowExpansion.js +110 -0
  199. package/components/data/table/hooks/useRowHandlers.js +38 -0
  200. package/components/data/table/hooks/useRowSelection.js +213 -0
  201. package/components/data/table/hooks/useServerSideSorting.js +165 -0
  202. package/components/data/table/hooks/useTableColumns.js +263 -0
  203. package/components/data/table/hooks/useTableData.js +154 -0
  204. package/components/data/table/hooks/useTableEdit.js +467 -0
  205. package/components/data/table/hooks/useTableEffects.js +139 -0
  206. package/components/data/table/hooks/useTableFilter.js +389 -0
  207. package/components/data/table/hooks/useTableInitialization.js +103 -0
  208. package/components/data/table/hooks/useTableState.js +69 -0
  209. package/components/data/table/hooks/useTableStateManager.js +558 -0
  210. package/components/data/table/index.js +1295 -0
  211. package/components/data/table/live-table/index.js +232 -0
  212. package/components/data/table/props.js +5 -0
  213. package/components/data/table/table-action/index.js +78 -0
  214. package/components/data/table/table-column/index.js +35 -0
  215. package/components/data/table/table-row/index.js +49 -0
  216. package/components/data/table/table-row-action/index.js +74 -0
  217. package/components/data/table/utils/buildSelectionColumns.js +173 -0
  218. package/components/data/table/utils/columnBuilder.js +209 -0
  219. package/components/data/table/utils/columnProxy.js +48 -0
  220. package/components/data/table/utils/columnWidthDistribution.js +98 -0
  221. package/components/data/table/utils/constants.js +80 -0
  222. package/components/data/table/utils/crud-handlers.js +518 -0
  223. package/components/data/table/utils/dynamic-columns.js +118 -0
  224. package/components/data/table/utils/index.js +607 -0
  225. package/components/data/table/utils/renderDisplayCell.js +183 -0
  226. package/components/data/table/utils/selectionUtils.js +166 -0
  227. package/components/data/table/utils/table-helpers.js +100 -0
  228. package/components/data/table/utils/validation.js +124 -0
  229. package/components/data/types.js +113 -0
  230. package/components/data/utils/field-data-utils.js +66 -0
  231. package/components/data/utils/filter-field-util.js +81 -0
  232. package/components/data/utils/index.js +216 -0
  233. package/components/dialogs/alert-dialog/index.js +80 -0
  234. package/components/dialogs/confirm-dialog/index.js +105 -0
  235. package/components/dialogs/dialog/index.js +56 -0
  236. package/components/dialogs/dialog-actions/index.js +18 -0
  237. package/components/dialogs/dialog-body/index.js +21 -0
  238. package/components/dialogs/dialog-content/index.js +30 -0
  239. package/components/dialogs/dialog-header/index.js +93 -0
  240. package/components/dialogs/iframe-dialog/index.js +114 -0
  241. package/components/dialogs/index.js +129 -0
  242. package/components/dialogs/login-dialog/index.js +369 -0
  243. package/components/dialogs/login-dialog/props.js +5 -0
  244. package/components/dialogs/page-dialog/index.js +96 -0
  245. package/components/dialogs/withDialogWrapper.js +108 -0
  246. package/components/form/button/index.js +216 -0
  247. package/components/form/button-group/index.js +60 -0
  248. package/components/input/calendar/index.js +546 -0
  249. package/components/input/calendar/props.js +5 -0
  250. package/components/input/calendar/utils.js +340 -0
  251. package/components/input/chips/SortableChip/index.js +115 -0
  252. package/components/input/chips/SortableChip/props.js +5 -0
  253. package/components/input/chips/index.js +488 -0
  254. package/components/input/chips/props.js +5 -0
  255. package/components/input/chips/utils.js +259 -0
  256. package/components/input/color-picker/index.js +678 -0
  257. package/components/input/color-picker/props.js +5 -0
  258. package/components/input/composite/index.js +137 -0
  259. package/components/input/currency/index.js +263 -0
  260. package/components/input/currency/props.js +5 -0
  261. package/components/input/default/checkbox/index.js +230 -0
  262. package/components/input/default/checkbox/props.js +5 -0
  263. package/components/input/default/checkboxset/index.js +476 -0
  264. package/components/input/default/checkboxset/props.js +5 -0
  265. package/components/input/default/radioset/index.js +379 -0
  266. package/components/input/default/radioset/props.js +5 -0
  267. package/components/input/default/switch/index.js +490 -0
  268. package/components/input/default/switch/prop.js +5 -0
  269. package/components/input/epoch/date/components/DatePickerPopover.js +220 -0
  270. package/components/input/epoch/date/index.js +520 -0
  271. package/components/input/epoch/date/props.js +5 -0
  272. package/components/input/epoch/date/styled.js +70 -0
  273. package/components/input/epoch/date/utils.js +108 -0
  274. package/components/input/epoch/datetime/index.js +656 -0
  275. package/components/input/epoch/datetime/props.js +5 -0
  276. package/components/input/epoch/datetime/styled.js +90 -0
  277. package/components/input/epoch/datetime/utils.js +244 -0
  278. package/components/input/epoch/time/index.js +412 -0
  279. package/components/input/epoch/time/props.js +5 -0
  280. package/components/input/epoch/time/utils.js +209 -0
  281. package/components/input/fileupload/Utils.js +134 -0
  282. package/components/input/fileupload/components/ListItems.js +140 -0
  283. package/components/input/fileupload/components/MultiUpload.js +85 -0
  284. package/components/input/fileupload/components/SingleUpload.js +65 -0
  285. package/components/input/fileupload/index.js +170 -0
  286. package/components/input/fileupload/props.js +5 -0
  287. package/components/input/fileupload/useFileUpload.js +400 -0
  288. package/components/input/number/index.js +295 -0
  289. package/components/input/number/props.js +5 -0
  290. package/components/input/rating/index.js +368 -0
  291. package/components/input/rating/props.js +5 -0
  292. package/components/input/select/index.js +344 -0
  293. package/components/input/select/props.js +5 -0
  294. package/components/input/slider/index.js +167 -0
  295. package/components/input/slider/props.js +5 -0
  296. package/components/input/text/index.js +434 -0
  297. package/components/input/text/props.js +5 -0
  298. package/components/input/text/util.js +179 -0
  299. package/components/input/textarea/index.js +347 -0
  300. package/components/input/textarea/props.js +5 -0
  301. package/components/layout/footer/index.js +30 -0
  302. package/components/layout/header/index.js +30 -0
  303. package/components/layout/leftnav/index.js +44 -0
  304. package/components/layout/rightnav/index.js +32 -0
  305. package/components/layout/topnav/index.js +34 -0
  306. package/components/navbar/index.js +41 -0
  307. package/components/navbar/nav/index.js +102 -0
  308. package/components/navbar/nav/props.js +5 -0
  309. package/components/navbar/nav-item/index.js +44 -0
  310. package/components/navigation/breadcrumb/index.js +56 -0
  311. package/components/navigation/breadcrumb/props.js +5 -0
  312. package/components/navigation/menu/components/ListItems.js +66 -0
  313. package/components/navigation/menu/constants.js +101 -0
  314. package/components/navigation/menu/index.js +807 -0
  315. package/components/navigation/menu/props.js +5 -0
  316. package/components/navigation/popover/index.js +209 -0
  317. package/components/navigation/popover/props.js +15 -0
  318. package/components/page/content/index.js +28 -0
  319. package/components/page/error-boundary/index.js +108 -0
  320. package/components/page/index.js +137 -0
  321. package/components/page/page-content/index.js +23 -0
  322. package/components/page/partial/index.js +36 -0
  323. package/components/page/partial-container/index.js +48 -0
  324. package/components/page/props.js +5 -0
  325. package/components/page/toast-container/index.js +33 -0
  326. package/components/prefab/container/index.js +46 -0
  327. package/components/prefab/index.js +67 -0
  328. package/context/AppContext.js +25 -0
  329. package/context/AppSpinnerProvider.js +43 -0
  330. package/context/LocalizationProvider.js +79 -0
  331. package/context/PrefabContext.js +66 -0
  332. package/context/WidgetProvider.js +187 -0
  333. package/core/app-config.js +1 -0
  334. package/core/app.service.js +357 -0
  335. package/core/appVariablesStore.js +20 -0
  336. package/core/appstore.js +88 -0
  337. package/core/constants/currency-constant.js +1071 -0
  338. package/core/constants/events.js +34 -0
  339. package/core/constants/index.js +27 -0
  340. package/core/dialog.service.js +76 -0
  341. package/core/event-notifier.js +151 -0
  342. package/core/formatter/date-formatters.js +222 -0
  343. package/core/formatter/index.js +131 -0
  344. package/core/formatter/number-formatters.js +142 -0
  345. package/core/formatter/security-formatters.js +323 -0
  346. package/core/formatter/string-formatters.js +52 -0
  347. package/core/formatter/types.js +18 -0
  348. package/core/formatters.js +24 -0
  349. package/core/proxy-service.js +412 -0
  350. package/core/script-registry.js +63 -0
  351. package/core/security.service.js +11 -0
  352. package/core/util/common.js +33 -0
  353. package/core/util/dom.js +107 -0
  354. package/core/util/index.js +136 -0
  355. package/core/util/security.js +184 -0
  356. package/core/util/utils.js +189 -0
  357. package/core/widget-observer.js +98 -0
  358. package/higherOrder/BaseApp.js +430 -0
  359. package/higherOrder/BaseAppProps.js +5 -0
  360. package/higherOrder/BaseDateTime.js +251 -0
  361. package/higherOrder/BasePage.js +715 -0
  362. package/higherOrder/BasePartial.js +124 -0
  363. package/higherOrder/BasePrefab.js +145 -0
  364. package/higherOrder/DataNav.js +377 -0
  365. package/higherOrder/helper.js +43 -0
  366. package/higherOrder/props.js +5 -0
  367. package/higherOrder/withBaseWrapper.js +183 -0
  368. package/hooks/useAccess.js +308 -0
  369. package/hooks/useAppConfig.js +42 -0
  370. package/hooks/useAuth.js +562 -0
  371. package/hooks/useDataSourceSubscription.js +125 -0
  372. package/hooks/useDebounce.js +76 -0
  373. package/hooks/useDeviceVisibility.js +49 -0
  374. package/hooks/useHttp.js +338 -0
  375. package/libs/index.js +20 -0
  376. package/mui-config/theme-provider.js +17 -0
  377. package/mui-config/theme.js +371 -0
  378. package/package-lock.json +10177 -0
  379. package/package.json +95 -0
  380. package/store/index.js +33 -0
  381. package/store/middleware/navigationMiddleware.js +48 -0
  382. package/store/slices/appConfigSlice.js +103 -0
  383. package/store/slices/authSlice.js +508 -0
  384. package/store/slices/i18nSlice.js +206 -0
  385. package/types/index.js +15 -0
  386. package/utils/dataset-util.js +174 -0
  387. package/utils/eval-expression.js +32 -0
  388. package/utils/form-state.util.js +140 -0
  389. package/utils/form-utils.js +187 -0
  390. package/utils/format-util.js +260 -0
  391. package/utils/page-params-util.js +24 -0
  392. package/utils/resource-url.js +27 -0
  393. package/utils/state-persistance.js +343 -0
  394. package/utils/style-utils.js +73 -0
  395. package/utils/transformedDataset-utils.js +633 -0
  396. package/utils/widget-cleanup-util.js +84 -0
  397. package/utils/widgets.js +99 -0
  398. package/variables/base-variable.js +173 -0
  399. package/variables/constants.js +27 -0
  400. package/variables/live-variable.js +166 -0
  401. package/variables/model-variable.js +77 -0
  402. package/variables/service-variable.js +307 -0
@@ -0,0 +1,715 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.withPageContext = exports["default"] = void 0;
9
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+ var _react = _interopRequireWildcard(require("react"));
14
+ var _navigation = require("next/navigation");
15
+ var _isEqual = _interopRequireDefault(require("lodash-es/isEqual"));
16
+ var _cloneDeep = _interopRequireDefault(require("lodash-es/cloneDeep"));
17
+ var _merge = _interopRequireDefault(require("lodash-es/merge"));
18
+ var _WidgetProvider = require("@wavemaker/react-runtime/context/WidgetProvider");
19
+ var _spinner = require("@wavemaker/react-runtime/components/basic/spinner");
20
+ var _appVariablesStore = require("@wavemaker/react-runtime/core/appVariablesStore");
21
+ var _store = require("@wavemaker/react-runtime/store");
22
+ var _AppContext = require("@wavemaker/react-runtime/context/AppContext");
23
+ var _useAccess2 = _interopRequireDefault(require("@wavemaker/react-runtime/hooks/useAccess"));
24
+ var _authSlice = require("@wavemaker/react-runtime/store/slices/authSlice");
25
+ var _types = require("@wavemaker/react-runtime/types");
26
+ var _proxyService = require("@wavemaker/react-runtime/core/proxy-service");
27
+ var _navigationMiddleware = require("@wavemaker/react-runtime/store/middleware/navigationMiddleware");
28
+ var _helper = require("@wavemaker/react-runtime/higherOrder/helper");
29
+ var _toast = require("@wavemaker/react-runtime/actions/toast.service");
30
+ var _appstore = _interopRequireDefault(require("@wavemaker/react-runtime/core/appstore"));
31
+ var _scriptRegistry = require("@wavemaker/react-runtime/core/script-registry");
32
+ var _formatters = _interopRequireDefault(require("../core/formatters"));
33
+ var _AppContext2 = require("../context/AppContext");
34
+ var _utils = require("../core/util/utils");
35
+ var _widgetCleanupUtil = require("../utils/widget-cleanup-util");
36
+ var _pageParamsUtil = require("../utils/page-params-util");
37
+ var _constants = require("../core/constants");
38
+ var _AppSpinnerProvider = require("../context/AppSpinnerProvider");
39
+ var _lodash = require("lodash");
40
+ var _events = require("../core/constants/events");
41
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
42
+ var __jsx = _react["default"].createElement;
43
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
44
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
45
+ // Add global declaration for wm property
46
+
47
+ var withPageContext = exports.withPageContext = function withPageContext(WrappedComponent, addPageScript, getVariables, componentInfo, prefabInfo) {
48
+ var PageContextComponent = function PageContextComponent(props) {
49
+ var _info$appConfig;
50
+ var dispatch = (0, _store.useAppDispatch)();
51
+ var _useAppSpinner = (0, _AppSpinnerProvider.useAppSpinner)(),
52
+ show = _useAppSpinner.show,
53
+ hide = _useAppSpinner.hide;
54
+ var i18n = (0, _store.useAppSelector)(function (state) {
55
+ return state.i18n;
56
+ });
57
+ var info = (0, _store.useAppSelector)(function (state) {
58
+ return state.info;
59
+ });
60
+ var pageParams = (0, _navigation.useSearchParams)();
61
+ // Get app context if available (when used within BaseApp)
62
+ var appContext = (0, _AppContext.useAppContext)();
63
+ var appProxy = (0, _AppContext2.useAppProxy)();
64
+
65
+ // Use optimized access hook instead of useAccess
66
+ var _useAccess = (0, _useAccess2["default"])({
67
+ componentName: (componentInfo === null || componentInfo === void 0 ? void 0 : componentInfo.componentName) || "Main",
68
+ type: (componentInfo === null || componentInfo === void 0 ? void 0 : componentInfo.componentType) || "PAGE"
69
+ }),
70
+ hasAccess = _useAccess.hasAccess,
71
+ accessLoading = _useAccess.loading,
72
+ accessError = _useAccess.error;
73
+
74
+ // Get security status for debugging
75
+ var isSecurityEnabled = (0, _store.useAppSelector)(function (state) {
76
+ var _state$auth$securityC;
77
+ return (_state$auth$securityC = state.auth.securityConfig) === null || _state$auth$securityC === void 0 ? void 0 : _state$auth$securityC.isSecurityEnabled;
78
+ });
79
+ var securityConfig = (0, _store.useAppSelector)(function (state) {
80
+ return state.auth.securityConfig;
81
+ });
82
+ var isAuthenticated = (0, _store.useAppSelector)(function (state) {
83
+ var _state$auth$loggedInU;
84
+ return (_state$auth$loggedInU = state.auth.loggedInUser) === null || _state$auth$loggedInU === void 0 ? void 0 : _state$auth$loggedInU.isAuthenticated;
85
+ });
86
+ var loggedInUser = (0, _store.useAppSelector)(function (state) {
87
+ return state.auth.loggedInUser;
88
+ });
89
+ var appConfig = (0, _store.useAppSelector)(function (state) {
90
+ return state.info.appConfig;
91
+ });
92
+
93
+ // Initialization state management
94
+ var _useState = (0, _react.useState)(false),
95
+ isInitialized = _useState[0],
96
+ setIsInitialized = _useState[1];
97
+ var _useState2 = (0, _react.useState)(false),
98
+ startupComplete = _useState2[0],
99
+ setStartupComplete = _useState2[1];
100
+ var redirectHandledRef = (0, _react.useRef)(false);
101
+
102
+ // Refs for managing component lifecycle
103
+ var subscriptionsRef = (0, _react.useRef)([]);
104
+ var pendingStartupOpsRef = (0, _react.useRef)(new Set());
105
+ var startUpVariableLoadedRef = (0, _react.useRef)(false);
106
+ var pageProxyRef = (0, _react.useRef)(null);
107
+ var isInitializingRef = (0, _react.useRef)(false);
108
+ var isMountedRef = (0, _react.useRef)(true);
109
+ var startupInvokedRef = (0, _react.useRef)(false);
110
+ var usedFallbackAppVarsRef = (0, _react.useRef)(false);
111
+ var appVarSubscriptionsDoneRef = (0, _react.useRef)(false);
112
+ var subscribedVariableNamesRef = (0, _react.useRef)(new Set());
113
+ var cleanupUtilRef = (0, _react.useRef)(null);
114
+
115
+ // Initial page context state
116
+ var _useState3 = (0, _react.useState)(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
117
+ Widgets: {},
118
+ Variables: {},
119
+ Actions: {},
120
+ onReady: function onReady() {},
121
+ serviceDefinitions: (0, _cloneDeep["default"])((prefabInfo === null || prefabInfo === void 0 ? void 0 : prefabInfo.serviceDefs) || (appContext === null || appContext === void 0 ? void 0 : appContext.serviceDefinitions) || {}),
122
+ pageParams: {},
123
+ baseUrl: (prefabInfo === null || prefabInfo === void 0 ? void 0 : prefabInfo.baseUrl) || (info === null || info === void 0 || (_info$appConfig = info.appConfig) === null || _info$appConfig === void 0 ? void 0 : _info$appConfig.url) || "",
124
+ appConfig: appContext === null || appContext === void 0 ? void 0 : appContext.appConfig,
125
+ notification: {},
126
+ toaster: _toast.toastService,
127
+ onContentReady: onContentReady,
128
+ onChange: updateWidgetState,
129
+ cleanup: cleanup,
130
+ App: {},
131
+ eval: appContext === null || appContext === void 0 ? void 0 : appContext.eval,
132
+ appLocale: componentInfo.appLocale || i18n.appLocale || {}
133
+ }, prefabInfo), props), componentInfo), {}, {
134
+ executeStartup: executeStartup,
135
+ formatters: _formatters["default"]
136
+ })),
137
+ pageContext = _useState3[0],
138
+ setPageContext = _useState3[1];
139
+
140
+ // Enhanced initial app config that inherits from app context if available
141
+ var initialAppConfig = (0, _react.useMemo)(function () {
142
+ return appContext;
143
+ }, [appContext]);
144
+
145
+ // Handle redirect to login if authentication is required
146
+ (0, _react.useEffect)(function () {
147
+ var _appConfig$pages;
148
+ if ((componentInfo === null || componentInfo === void 0 ? void 0 : componentInfo.componentType) !== "PAGE" || redirectHandledRef.current || accessLoading || !isSecurityEnabled) {
149
+ return;
150
+ }
151
+
152
+ // Check if page requires authentication
153
+ var pageConfig = appConfig === null || appConfig === void 0 || (_appConfig$pages = appConfig.pages) === null || _appConfig$pages === void 0 ? void 0 : _appConfig$pages.find(function (p) {
154
+ var _componentInfo$compon;
155
+ return p.name.toLowerCase() === (componentInfo === null || componentInfo === void 0 || (_componentInfo$compon = componentInfo.componentName) === null || _componentInfo$compon === void 0 ? void 0 : _componentInfo$compon.toLowerCase());
156
+ });
157
+
158
+ // Redirect to login if page requires authentication and user is not authenticated
159
+ var requiresAuth = (pageConfig === null || pageConfig === void 0 ? void 0 : pageConfig.permission) === "Authenticated" || (pageConfig === null || pageConfig === void 0 ? void 0 : pageConfig.permission) === "Role";
160
+ if (requiresAuth && !isAuthenticated) {
161
+ redirectHandledRef.current = true;
162
+ dispatch((0, _authSlice.redirectToLogin)({
163
+ redirectTo: componentInfo === null || componentInfo === void 0 ? void 0 : componentInfo.componentName,
164
+ securityConfig: securityConfig
165
+ }));
166
+ }
167
+ }, [accessLoading, isSecurityEnabled, isAuthenticated, appConfig, componentInfo === null || componentInfo === void 0 ? void 0 : componentInfo.componentType, componentInfo === null || componentInfo === void 0 ? void 0 : componentInfo.componentName, dispatch, securityConfig]);
168
+
169
+ // Handle redirect from login page to landing page if already authenticated
170
+ (0, _react.useEffect)(function () {
171
+ var _securityConfig$login;
172
+ if ((componentInfo === null || componentInfo === void 0 ? void 0 : componentInfo.componentType) !== "PAGE" || !isSecurityEnabled || !isAuthenticated || accessLoading) {
173
+ return;
174
+ }
175
+ var loginPage = securityConfig === null || securityConfig === void 0 || (_securityConfig$login = securityConfig.loginConfig) === null || _securityConfig$login === void 0 ? void 0 : _securityConfig$login.pageName;
176
+ var landingPage = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.landingPage;
177
+ if (!loginPage || !landingPage) {
178
+ return;
179
+ }
180
+
181
+ // Extract the last segment of the pathname (the page name)
182
+ var currentPageName = componentInfo.componentName;
183
+ var isOnLoginPage = currentPageName === loginPage;
184
+
185
+ // If authenticated user is on login page, redirect to landing page
186
+ if (isOnLoginPage) {
187
+ var router = (0, _navigationMiddleware.getRouterInstance)();
188
+ if (router) {
189
+ console.log("BasePage: Redirecting authenticated user from login to landing page", landingPage);
190
+ router.push("/".concat(_constants.ROUTING_BASEPATH, "/").concat(landingPage));
191
+ }
192
+ }
193
+ }, [componentInfo === null || componentInfo === void 0 ? void 0 : componentInfo.componentType, isSecurityEnabled, isAuthenticated, accessLoading, securityConfig, loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.landingPage]);
194
+
195
+ // Check if we should proceed with initialization
196
+ var shouldInitialize = (0, _react.useMemo)(function () {
197
+ // Wait for app to be ready (if app context exists)
198
+ if (appContext && !appContext.isAppReady) {
199
+ return false;
200
+ }
201
+
202
+ // Wait for access check to complete
203
+ if (accessLoading) {
204
+ return false;
205
+ }
206
+
207
+ // Don't initialize if no access
208
+ if (!hasAccess && isSecurityEnabled) {
209
+ if (isAuthenticated) {
210
+ var _pageContext$appLocal;
211
+ appContext === null || appContext === void 0 || appContext.notifyApp((pageContext === null || pageContext === void 0 || (_pageContext$appLocal = pageContext.appLocale) === null || _pageContext$appLocal === void 0 || (_pageContext$appLocal = _pageContext$appLocal.LABELS) === null || _pageContext$appLocal === void 0 ? void 0 : _pageContext$appLocal.ACCESS_DENIED) || "Access Denied", "Error");
212
+ }
213
+ return false;
214
+ }
215
+ return true;
216
+ }, [appContext === null || appContext === void 0 ? void 0 : appContext.isAppReady, accessLoading, hasAccess, isSecurityEnabled, isAuthenticated]);
217
+
218
+ // Update page context with app variables when app context changes
219
+ (0, _react.useEffect)(function () {
220
+ if (!(appContext !== null && appContext !== void 0 && appContext.isAppReady) || !pageProxyRef.current) {
221
+ return;
222
+ }
223
+
224
+ // Update page context with app variables without triggering re-initialization
225
+ setPageContext(function (prev) {
226
+ var updatedVariables = _objectSpread(_objectSpread({}, prev.Variables), appContext.Variables || {});
227
+ var updatedActions = _objectSpread(_objectSpread({}, prev.Actions), appContext.Actions || {});
228
+
229
+ // Update proxy with the same object references
230
+ pageProxyRef.current.Variables = updatedVariables;
231
+ pageProxyRef.current.Actions = updatedActions;
232
+ pageProxyRef.current.App = _objectSpread(_objectSpread({}, pageProxyRef.current.App), {}, {
233
+ Variables: appContext.Variables || {},
234
+ Actions: appContext.Actions || {}
235
+ });
236
+ return _objectSpread(_objectSpread({}, prev), {}, {
237
+ Variables: updatedVariables,
238
+ Actions: updatedActions
239
+ });
240
+ });
241
+ }, [appContext === null || appContext === void 0 ? void 0 : appContext.isAppReady]);
242
+
243
+ // Main initialization effect - runs only when conditions are met
244
+ (0, _react.useEffect)(function () {
245
+ // Early returns for non-initialization cases
246
+ if (!shouldInitialize || isInitialized || isInitializingRef.current || !isMountedRef.current) {
247
+ return;
248
+ }
249
+
250
+ // Set initialization flag
251
+ isInitializingRef.current = true;
252
+ var initializeComponent = /*#__PURE__*/function () {
253
+ var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
254
+ var pageProxy, pageVariables, appVariables, APP_VARIABLES, _mergeVariablesAndAct, Variables, Actions, urlParams, newParams, pageName;
255
+ return _regenerator["default"].wrap(function _callee$(_context) {
256
+ while (1) switch (_context.prev = _context.next) {
257
+ case 0:
258
+ try {
259
+ // Create page proxy
260
+ pageProxy = (0, _proxyService.createStateProxy)(pageContext, [], setPageContext);
261
+ pageProxyRef.current = pageProxy;
262
+
263
+ // Initialize cleanup utility
264
+ if (!cleanupUtilRef.current) {
265
+ cleanupUtilRef.current = (0, _widgetCleanupUtil.createWidgetCleanup)({
266
+ setPageContext: setPageContext,
267
+ proxyRef: pageProxyRef,
268
+ debounceDelay: 100
269
+ });
270
+ }
271
+
272
+ // Initialize variables and actions
273
+ pageVariables = getVariables(pageProxy); // Handle app variables based on app context availability
274
+ appVariables = {
275
+ Variables: {},
276
+ Actions: {}
277
+ };
278
+ if (appContext !== null && appContext !== void 0 && appContext.isAppReady) {
279
+ // If app context is available and ready, use app variables directly
280
+ appVariables = {
281
+ Variables: appContext.Variables || {},
282
+ Actions: appContext.Actions || {}
283
+ };
284
+ usedFallbackAppVarsRef.current = false;
285
+ } else {
286
+ // Fallback to traditional app variable initialization
287
+ // @ts-ignore
288
+ APP_VARIABLES = _appstore["default"].get("AppConfig").appVariables;
289
+ appVariables = APP_VARIABLES ? (0, _appVariablesStore.getAppVariablesInstance)(pageProxy, APP_VARIABLES) : {
290
+ Variables: {},
291
+ Actions: {}
292
+ };
293
+ usedFallbackAppVarsRef.current = true;
294
+ }
295
+ _mergeVariablesAndAct = (0, _helper.mergeVariablesAndActions)(pageVariables, appVariables), Variables = _mergeVariablesAndAct.Variables, Actions = _mergeVariablesAndAct.Actions; // Compute page params from URL and include partial params when applicable
296
+ urlParams = Object.fromEntries(pageParams.entries());
297
+ newParams = (0, _pageParamsUtil.computeMergedPageParams)(urlParams, {
298
+ componentType: componentInfo === null || componentInfo === void 0 ? void 0 : componentInfo.componentType,
299
+ props: props
300
+ }); // Update proxy with merged variables and actions
301
+ pageProxy.Variables = Variables;
302
+ pageProxy.Actions = Actions;
303
+ pageProxy.pageParams = _objectSpread({}, newParams);
304
+ pageProxy.App = _objectSpread(_objectSpread(_objectSpread({}, initialAppConfig), appVariables), {}, {
305
+ pageParams: _objectSpread({}, newParams),
306
+ selectedLocale: i18n.selectedLocale || "en"
307
+ });
308
+
309
+ // Setup variable event handlers
310
+ setupVariableSubscriptions(pageVariables.Variables);
311
+ if ((componentInfo === null || componentInfo === void 0 ? void 0 : componentInfo.componentType) === "PAGE" && appProxy) {
312
+ pageName = componentInfo === null || componentInfo === void 0 ? void 0 : componentInfo.componentName;
313
+ appProxy.updateActivePage(pageName);
314
+ }
315
+
316
+ // Initialize page script
317
+ try {
318
+ addPageScript(appProxy, pageProxy);
319
+ } catch (e) {
320
+ if ((0, _utils.isJQueryError)(e)) {
321
+ appContext === null || appContext === void 0 || appContext.notifyApp("React App is not supporting this functionality check console for more details", "Error");
322
+ }
323
+ console.error(e);
324
+ }
325
+
326
+ // Setup global wm object for pages
327
+ if ((componentInfo === null || componentInfo === void 0 ? void 0 : componentInfo.componentType) === "PAGE") {
328
+ global.wm = appProxy ? _objectSpread(_objectSpread({}, pageProxy), {}, {
329
+ App: appProxy
330
+ }) : pageProxy;
331
+ }
332
+
333
+ // Mark as initialized
334
+ setIsInitialized(true);
335
+ } catch (error) {
336
+ console.error("Error during component initialization:", error);
337
+ // Still mark as initialized to prevent hanging
338
+ setIsInitialized(true);
339
+ } finally {
340
+ isInitializingRef.current = false;
341
+ }
342
+ case 1:
343
+ case "end":
344
+ return _context.stop();
345
+ }
346
+ }, _callee);
347
+ }));
348
+ return function initializeComponent() {
349
+ return _ref.apply(this, arguments);
350
+ };
351
+ }();
352
+ initializeComponent();
353
+
354
+ // Cleanup function
355
+ return function () {
356
+ var _cleanupUtilRef$curre;
357
+ // Cancel all pending page operations
358
+ if (pageProxyRef.current) {
359
+ var _ref2 = getVariables(pageProxyRef.current) || {},
360
+ _ref2$Variables = _ref2.Variables,
361
+ Variables = _ref2$Variables === void 0 ? {} : _ref2$Variables,
362
+ _ref2$Actions = _ref2.Actions,
363
+ Actions = _ref2$Actions === void 0 ? {} : _ref2$Actions;
364
+
365
+ // Cancel page variables
366
+ Object.values(Variables).forEach(function (variable) {
367
+ if (variable !== null && variable !== void 0 && variable.cancel && typeof variable.cancel === "function") {
368
+ try {
369
+ variable.cancel();
370
+ } catch (error) {
371
+ console.warn("Failed to cancel page variable:", error);
372
+ }
373
+ }
374
+ });
375
+
376
+ // Cancel page actions
377
+ Object.values(Actions).forEach(function (action) {
378
+ if (action !== null && action !== void 0 && action.cancel && typeof action.cancel === "function") {
379
+ try {
380
+ action.cancel();
381
+ } catch (error) {
382
+ console.warn("Failed to cancel page timer action:", error);
383
+ }
384
+ }
385
+ });
386
+ }
387
+
388
+ // Clear pending startup operations
389
+ pendingStartupOpsRef.current.clear();
390
+ (0, _scriptRegistry.clearOverriddenProps)();
391
+
392
+ // Unsubscribe from events
393
+ subscriptionsRef.current.forEach(function (_ref3) {
394
+ var variable = _ref3.variable,
395
+ event = _ref3.event,
396
+ handler = _ref3.handler;
397
+ if (variable !== null && variable !== void 0 && variable.unsubscribe) {
398
+ try {
399
+ variable.unsubscribe(event, handler);
400
+ } catch (error) {
401
+ console.warn("Failed to unsubscribe from ".concat(event, ":"), error);
402
+ }
403
+ }
404
+ });
405
+ subscriptionsRef.current = [];
406
+
407
+ // Cancel any pending cleanup operations
408
+ (_cleanupUtilRef$curre = cleanupUtilRef.current) === null || _cleanupUtilRef$curre === void 0 || _cleanupUtilRef$curre.cancel();
409
+ };
410
+ }, [shouldInitialize]); // Only depend on shouldInitialize
411
+
412
+ // If initialized with fallback app vars, subscribe to real app vars when app becomes ready
413
+ (0, _react.useEffect)(function () {
414
+ if (!(appContext !== null && appContext !== void 0 && appContext.isAppReady) || !pageProxyRef.current || !usedFallbackAppVarsRef.current || appVarSubscriptionsDoneRef.current) {
415
+ return;
416
+ }
417
+ try {
418
+ var _ref4 = getVariables(pageProxyRef.current) || {
419
+ Variables: {}
420
+ },
421
+ _ref4$Variables = _ref4.Variables,
422
+ pageVars = _ref4$Variables === void 0 ? {} : _ref4$Variables;
423
+ var pageVarNames = new Set(Object.keys(pageVars || {}));
424
+ subscribeAppVariablesIfNeeded(appContext.Variables || {}, pageVarNames);
425
+ appVarSubscriptionsDoneRef.current = true;
426
+ } catch (e) {
427
+ // no-op
428
+ }
429
+ }, [appContext === null || appContext === void 0 ? void 0 : appContext.isAppReady]);
430
+
431
+ // Prefab state sync
432
+ (0, _react.useEffect)(function () {
433
+ if (prefabInfo && (componentInfo === null || componentInfo === void 0 ? void 0 : componentInfo.componentType) === "PREFAB") {
434
+ var handlePrefabStateRefresh = function handlePrefabStateRefresh(data) {
435
+ Object.keys(data).forEach(function (key) {
436
+ var onPropertyChange = pageProxyRef.current.onPropertyChange;
437
+ if (onPropertyChange) {
438
+ onPropertyChange(data[key].key, data[key].newValue, data[key].oldValue);
439
+ // pageProxyRef.current[data[key].key] = data[key].newValue;
440
+ pageContext.Widgets[data[key].key] = data[key].newValue;
441
+ }
442
+ });
443
+ };
444
+ _events.EVENTEMITTER_METHODS.PREFAB_STATE_SYNC_ON(handlePrefabStateRefresh);
445
+ return function () {
446
+ _events.EVENTEMITTER_METHODS.PREFAB_STATE_SYNC_OFF(handlePrefabStateRefresh);
447
+ };
448
+ }
449
+ }, [prefabInfo, componentInfo === null || componentInfo === void 0 ? void 0 : componentInfo.componentType]);
450
+
451
+ // Setup variable subscriptions
452
+ var setupVariableSubscriptions = function setupVariableSubscriptions(variables) {
453
+ var handleVariableEvent = function handleVariableEvent(variableName, event, variable) {
454
+ // not required because while unmounting page,variables invocation get cancelled and state update will not happen
455
+
456
+ var updateState = variable;
457
+ updateState.loading = event === _types.VariableEvents.BEFORE_INVOKE;
458
+ updateState.error = event === _types.VariableEvents.ERROR ? variable : null;
459
+ if ((0, _lodash.get)(variable, "spinnerContext") === "page") {
460
+ if (updateState.loading) {
461
+ var message = (0, _lodash.get)(variable, "spinnerMessage");
462
+ show(message);
463
+ } else {
464
+ hide();
465
+ }
466
+ }
467
+ setPageContext(function (prev) {
468
+ return _objectSpread(_objectSpread({}, prev), {}, {
469
+ Variables: _objectSpread(_objectSpread({}, prev.Variables), {}, (0, _defineProperty2["default"])({}, variableName, updateState))
470
+ });
471
+ });
472
+ if (event === _types.VariableEvents.AFTER_INVOKE) {
473
+ pendingStartupOpsRef.current["delete"](variableName);
474
+ }
475
+ };
476
+
477
+ // Set up subscriptions (avoid duplicates by name)
478
+ Object.entries(variables).forEach(function (_ref5) {
479
+ var _ref6 = (0, _slicedToArray2["default"])(_ref5, 2),
480
+ name = _ref6[0],
481
+ variable = _ref6[1];
482
+ if (subscribedVariableNamesRef.current.has(name)) {
483
+ return;
484
+ }
485
+ Object.values(_types.VariableEvents).forEach(function (event) {
486
+ var handler = function handler() {
487
+ return handleVariableEvent(name, event, variable);
488
+ };
489
+ if (variable && typeof variable.subscribe === "function") {
490
+ variable.subscribe(event, handler);
491
+ subscriptionsRef.current.push({
492
+ variable: variable,
493
+ event: event,
494
+ handler: handler
495
+ });
496
+ }
497
+ });
498
+ subscribedVariableNamesRef.current.add(name);
499
+ });
500
+ };
501
+
502
+ // Subscribe to app-level variables that are not shadowed by page variables
503
+ var subscribeAppVariablesIfNeeded = function subscribeAppVariablesIfNeeded(appVars, pageVarNames) {
504
+ var appVarsOnly = {};
505
+ Object.entries(appVars || {}).forEach(function (_ref7) {
506
+ var _ref8 = (0, _slicedToArray2["default"])(_ref7, 2),
507
+ name = _ref8[0],
508
+ variable = _ref8[1];
509
+ if (!pageVarNames.has(name) && !subscribedVariableNamesRef.current.has(name)) {
510
+ appVarsOnly[name] = variable;
511
+ }
512
+ });
513
+ if (Object.keys(appVarsOnly).length) {
514
+ setupVariableSubscriptions(appVarsOnly);
515
+ }
516
+ };
517
+
518
+ // Execute startup operations
519
+ var executeStartupOperations = /*#__PURE__*/function () {
520
+ var _ref9 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(Variables, Actions) {
521
+ var _ref0, _ref0$startUpActions, startUpActions, _ref0$startUpVariable, startUpVariables, variablePromises;
522
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
523
+ while (1) switch (_context2.prev = _context2.next) {
524
+ case 0:
525
+ _ref0 = componentInfo || {}, _ref0$startUpActions = _ref0.startUpActions, startUpActions = _ref0$startUpActions === void 0 ? [] : _ref0$startUpActions, _ref0$startUpVariable = _ref0.startUpVariables, startUpVariables = _ref0$startUpVariable === void 0 ? [] : _ref0$startUpVariable; // Track startup operations
526
+ startUpVariables.forEach(function (name) {
527
+ return pendingStartupOpsRef.current.add(name);
528
+ });
529
+ startUpActions.forEach(function (name) {
530
+ return pendingStartupOpsRef.current.add(name);
531
+ });
532
+
533
+ // If no startup operations, mark as complete immediately
534
+ if (!(startUpActions.length === 0 && startUpVariables.length === 0)) {
535
+ _context2.next = 6;
536
+ break;
537
+ }
538
+ setTimeout(function () {
539
+ if (isMountedRef.current) {
540
+ setStartupComplete(true);
541
+ }
542
+ }, 100);
543
+ return _context2.abrupt("return");
544
+ case 6:
545
+ _context2.prev = 6;
546
+ // Execute startup actions
547
+ startUpActions.forEach(function (actionName) {
548
+ var _Actions$actionName;
549
+ if ((_Actions$actionName = Actions[actionName]) !== null && _Actions$actionName !== void 0 && _Actions$actionName.invoke) {
550
+ Actions[actionName].invoke();
551
+ }
552
+ pendingStartupOpsRef.current["delete"](String(actionName));
553
+ });
554
+
555
+ // Execute startup variables
556
+ variablePromises = startUpVariables.map(function (varName) {
557
+ var _Variables$varName;
558
+ if ((_Variables$varName = Variables[varName]) !== null && _Variables$varName !== void 0 && _Variables$varName.invoke) {
559
+ return Variables[varName].invoke()["catch"](function (error) {
560
+ console.log("Error invoking ".concat(varName, ":"), error);
561
+ return null;
562
+ });
563
+ }
564
+ return Promise.resolve();
565
+ });
566
+ _context2.next = 11;
567
+ return Promise.allSettled(variablePromises);
568
+ case 11:
569
+ startUpVariableLoadedRef.current = true;
570
+ pendingStartupOpsRef.current.clear();
571
+ if (isMountedRef.current) {
572
+ setStartupComplete(true);
573
+ }
574
+ _context2.next = 20;
575
+ break;
576
+ case 16:
577
+ _context2.prev = 16;
578
+ _context2.t0 = _context2["catch"](6);
579
+ console.error("Error during startup operations:", _context2.t0);
580
+ if (isMountedRef.current) {
581
+ setStartupComplete(true); // Set complete even on error to prevent hanging
582
+ }
583
+ case 20:
584
+ case "end":
585
+ return _context2.stop();
586
+ }
587
+ }, _callee2, null, [[6, 16]]);
588
+ }));
589
+ return function executeStartupOperations(_x, _x2) {
590
+ return _ref9.apply(this, arguments);
591
+ };
592
+ }();
593
+
594
+ // Cleanup function for unmounting widgets
595
+ function cleanup(name) {
596
+ var _cleanupUtilRef$curre2;
597
+ (_cleanupUtilRef$curre2 = cleanupUtilRef.current) === null || _cleanupUtilRef$curre2 === void 0 || _cleanupUtilRef$curre2.cleanup(name);
598
+ }
599
+
600
+ // Widget state update function
601
+ function updateWidgetState(widgetName, newProps) {
602
+ if (!widgetName || !newProps || Object.keys(newProps).length === 0) return;
603
+ if ((0, _isEqual["default"])(pageContext.Widgets[widgetName], newProps)) return;
604
+ setPageContext(function (prev) {
605
+ return _objectSpread(_objectSpread({}, prev), {}, {
606
+ Widgets: _objectSpread(_objectSpread({}, prev.Widgets), {}, (0, _defineProperty2["default"])({}, widgetName, _objectSpread(_objectSpread({}, prev.Widgets[widgetName]), newProps)))
607
+ });
608
+ });
609
+ Object.keys(newProps).forEach(function (key) {
610
+ var _pageContext$Widgets$;
611
+ if (!(0, _isEqual["default"])((_pageContext$Widgets$ = pageContext.Widgets[widgetName]) === null || _pageContext$Widgets$ === void 0 ? void 0 : _pageContext$Widgets$[key], newProps === null || newProps === void 0 ? void 0 : newProps[key]) && (newProps === null || newProps === void 0 ? void 0 : newProps[key]) !== undefined) {
612
+ pageProxyRef.current.Widgets[widgetName][key] = newProps[key];
613
+ }
614
+ });
615
+ }
616
+
617
+ // Content ready callback
618
+ function onContentReady() {
619
+ if (appContext !== null && appContext !== void 0 && appContext.onPageReady && pageContext.type === "PAGE") {
620
+ appContext.onPageReady(pageContext.componentName, pageProxyRef.current, undefined);
621
+ }
622
+ if (pageContext.onReady) {
623
+ try {
624
+ pageContext.onReady();
625
+ } catch (e) {
626
+ if ((0, _utils.isJQueryError)(e)) {
627
+ appContext === null || appContext === void 0 || appContext.notifyApp("React App is not supporting this functionality check console for more details", "Error");
628
+ }
629
+ console.error(e);
630
+ }
631
+ }
632
+ }
633
+ function executeStartup() {
634
+ return _executeStartup.apply(this, arguments);
635
+ } // Update pageContext.appLocale when i18n.appLocale changes
636
+ function _executeStartup() {
637
+ _executeStartup = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3() {
638
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
639
+ while (1) switch (_context3.prev = _context3.next) {
640
+ case 0:
641
+ appContext === null || appContext === void 0 || appContext.executeStartAppOperations();
642
+ _context3.next = 3;
643
+ return executeStartupOperations(pageContext.Variables, pageContext.Actions);
644
+ case 3:
645
+ case "end":
646
+ return _context3.stop();
647
+ }
648
+ }, _callee3);
649
+ }));
650
+ return _executeStartup.apply(this, arguments);
651
+ }
652
+ (0, _react.useEffect)(function () {
653
+ var newAppLocale = (0, _merge["default"])({}, i18n.appLocale || {}, (prefabInfo === null || prefabInfo === void 0 ? void 0 : prefabInfo.appLocale) || {});
654
+ if (!(0, _isEqual["default"])(pageContext.appLocale, newAppLocale)) {
655
+ setPageContext(function (prev) {
656
+ return _objectSpread(_objectSpread({}, prev), {}, {
657
+ appLocale: newAppLocale
658
+ });
659
+ });
660
+ }
661
+ }, [i18n.appLocale]);
662
+
663
+ // Call onContentReady when startup operations are complete
664
+ (0, _react.useEffect)(function () {
665
+ if (isMountedRef.current) {
666
+ onContentReady();
667
+ }
668
+ }, []);
669
+
670
+ // Cleanup on unmount
671
+ (0, _react.useEffect)(function () {
672
+ return function () {
673
+ isMountedRef.current = false;
674
+ };
675
+ }, []);
676
+
677
+ // Handle access denied case
678
+ if (!accessLoading && !hasAccess && !(componentInfo !== null && componentInfo !== void 0 && componentInfo.isPartOfPrefab)) {
679
+ return null;
680
+ }
681
+
682
+ // Handle access error case
683
+ if (accessError && !accessLoading) {
684
+ console.error("Access check failed for ".concat(componentInfo === null || componentInfo === void 0 ? void 0 : componentInfo.componentName, ":"), accessError);
685
+ return null;
686
+ }
687
+
688
+ // Show loading spinner while checking access or app is not ready
689
+ if (accessLoading || appContext && !appContext.isAppReady || !isInitialized) {
690
+ return __jsx(_spinner.WmSpinner, {
691
+ name: "page",
692
+ caption: "",
693
+ listener: {}
694
+ });
695
+ }
696
+ if (pageContext.autoUpdateVariables) {
697
+ var pageVariables = pageContext.Variables;
698
+ componentInfo.autoUpdateVariables.forEach(function (value) {
699
+ var _pageVariables$value, _pageVariables$value2;
700
+ ((_pageVariables$value = pageVariables[value]) === null || _pageVariables$value === void 0 ? void 0 : _pageVariables$value.invokeOnParamChange) && ((_pageVariables$value2 = pageVariables[value]) === null || _pageVariables$value2 === void 0 ? void 0 : _pageVariables$value2.invokeOnParamChange());
701
+ });
702
+ }
703
+
704
+ // Render the component
705
+ return __jsx(_WidgetProvider.WidgetProvider, {
706
+ value: {
707
+ value: pageContext,
708
+ proxy: pageProxyRef.current
709
+ }
710
+ }, __jsx(WrappedComponent, props));
711
+ };
712
+ PageContextComponent.displayName = "WithPageContext(".concat(WrappedComponent.displayName || WrappedComponent.name || "Component", ")");
713
+ return PageContextComponent;
714
+ };
715
+ var _default = exports["default"] = withPageContext;