@wavemaker-ai/react-runtime 1.0.0-rc.319 → 1.0.0-rc.324

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 (217) hide show
  1. package/actions/login-action.js +1 -1
  2. package/components/advanced/carousel/index.d.ts +1 -0
  3. package/components/advanced/carousel/template.d.ts +1 -0
  4. package/components/advanced/login/index.d.ts +1 -0
  5. package/components/advanced/marquee/index.d.ts +1 -0
  6. package/components/basic/anchor/index.d.ts +1 -0
  7. package/components/basic/anchor/index.js +16 -14
  8. package/components/basic/audio/index.d.ts +1 -0
  9. package/components/basic/html/index.d.ts +1 -0
  10. package/components/basic/icon/index.d.ts +1 -0
  11. package/components/basic/icon/index.js +13 -16
  12. package/components/basic/iframe/index.d.ts +1 -0
  13. package/components/basic/label/index.d.ts +1 -0
  14. package/components/basic/label/index.js +5 -3
  15. package/components/basic/label/props.d.ts +1 -1
  16. package/components/basic/picture/index.d.ts +1 -0
  17. package/components/basic/picture/index.js +3 -2
  18. package/components/basic/progress-bar/index.d.ts +1 -0
  19. package/components/basic/progress-circle/index.d.ts +1 -0
  20. package/components/basic/richtexteditor/index.d.ts +2 -0
  21. package/components/basic/search/index.d.ts +6 -0
  22. package/components/basic/search/index.js +69 -9
  23. package/components/basic/search/props.d.ts +4 -0
  24. package/components/basic/spinner/index.d.ts +2 -0
  25. package/components/basic/spinner/index.js +11 -9
  26. package/components/basic/spinner/props.d.ts +5 -0
  27. package/components/basic/tile/index.d.ts +1 -0
  28. package/components/basic/tree/index.d.ts +1 -0
  29. package/components/basic/video/index.d.ts +1 -0
  30. package/components/chart/index.d.ts +2 -0
  31. package/components/chart/props.d.ts +1 -0
  32. package/components/chart/src/chart.js +12 -1
  33. package/components/chart/src/types.d.ts +2 -0
  34. package/components/common/WmAppIcon/index.d.ts +15 -0
  35. package/components/common/WmAppIcon/index.js +130 -0
  36. package/components/common/WmAppIcon/props.d.ts +17 -0
  37. package/components/common/WmAppIcon/props.js +0 -0
  38. package/components/common/index.d.ts +3 -1
  39. package/components/common/index.js +10 -2
  40. package/components/common/wm-skeleton.d.ts +7 -0
  41. package/components/common/wm-skeleton.js +11 -1
  42. package/components/container/accordion/accordion-pane/index.d.ts +2 -0
  43. package/components/container/accordion/accordion-pane/index.js +10 -1
  44. package/components/container/accordion/accordion-pane/props.d.ts +1 -0
  45. package/components/container/accordion/index.d.ts +1 -0
  46. package/components/container/accordion/index.js +2 -2
  47. package/components/container/index.d.ts +1 -0
  48. package/components/container/layout-grid/grid-column/index.d.ts +1 -0
  49. package/components/container/layout-grid/grid-row/index.d.ts +1 -0
  50. package/components/container/layout-grid/index.d.ts +1 -0
  51. package/components/container/linear-layout/index.d.ts +1 -0
  52. package/components/container/linear-layout/linear-layout-item/index.d.ts +1 -0
  53. package/components/container/panel/components/panel-header/index.js +16 -16
  54. package/components/container/panel/index.d.ts +1 -0
  55. package/components/container/repeat-template/index.d.ts +1 -0
  56. package/components/container/tabs/index.d.ts +1 -0
  57. package/components/container/tabs/index.js +18 -18
  58. package/components/container/tabs/props.d.ts +1 -0
  59. package/components/container/tabs/tab-pane/index.d.ts +2 -0
  60. package/components/container/tabs/tab-pane/index.js +2 -0
  61. package/components/container/tabs/tab-pane/props.d.ts +1 -0
  62. package/components/container/wizard/components/StepComponents.js +14 -6
  63. package/components/container/wizard/index.d.ts +2 -0
  64. package/components/container/wizard/index.js +2 -2
  65. package/components/container/wizard/props.d.ts +4 -0
  66. package/components/container/wizard/wizard-step/index.d.ts +1 -0
  67. package/components/container/wizard/wizard-step/index.js +6 -0
  68. package/components/data/card/card-actions/index.d.ts +1 -0
  69. package/components/data/card/card-content/index.d.ts +1 -0
  70. package/components/data/card/card-footer/index.d.ts +1 -0
  71. package/components/data/card/index.d.ts +1 -0
  72. package/components/data/card/index.js +13 -6
  73. package/components/data/form/dynamic-fields/index.js +1 -0
  74. package/components/data/form/form-action/index.d.ts +2 -0
  75. package/components/data/form/form-action/index.js +6 -4
  76. package/components/data/form/form-field/index.js +5 -4
  77. package/components/data/form/form-header/index.d.ts +1 -1
  78. package/components/data/form/form-header/index.js +10 -1
  79. package/components/data/form/index.js +5 -3
  80. package/components/data/form/props.d.ts +1 -0
  81. package/components/data/list/components/ListHeader.js +19 -3
  82. package/components/data/list/components/ListItemWithTemplate.js +5 -1
  83. package/components/data/list/components/ListItems.d.ts +1 -1
  84. package/components/data/list/components/ListItems.js +5 -1
  85. package/components/data/list/components/LoadMoreButton.js +14 -2
  86. package/components/data/list/components/StandardListItems.js +1 -1
  87. package/components/data/list/components/props.d.ts +11 -5
  88. package/components/data/list/hooks/props.d.ts +2 -2
  89. package/components/data/list/hooks/useListEventHandlers.js +3 -2
  90. package/components/data/list/index.d.ts +5 -1
  91. package/components/data/list/index.js +17 -4
  92. package/components/data/list/props.d.ts +14 -2
  93. package/components/data/list/utils/list-helpers.d.ts +5 -1
  94. package/components/data/list/utils/list-helpers.js +10 -0
  95. package/components/data/pagination/components/PageSizeSelector.js +49 -155
  96. package/components/data/pagination/hooks/usePagination.js +24 -1
  97. package/components/data/table/components/RowCells.js +1 -1
  98. package/components/data/table/components/TableDataRow.js +16 -3
  99. package/components/data/table/components/TableHeader.js +1 -1
  100. package/components/data/table/components/TablePanelHeading.js +14 -2
  101. package/components/data/table/hooks/useResponsiveColumns.d.ts +1 -0
  102. package/components/data/table/hooks/useTableColumns.js +2 -2
  103. package/components/data/table/hooks/useTableData.js +30 -1
  104. package/components/data/table/index.d.ts +4 -0
  105. package/components/data/table/index.js +47 -30
  106. package/components/data/table/live-table/index.d.ts +1 -0
  107. package/components/data/table/props.d.ts +11 -2
  108. package/components/data/table/table-action/index.d.ts +1 -0
  109. package/components/data/table/table-column/index.d.ts +1 -0
  110. package/components/data/table/table-row/index.d.ts +1 -0
  111. package/components/data/table/table-row-action/index.d.ts +1 -0
  112. package/components/data/table/utils/buildSelectionColumns.d.ts +1 -1
  113. package/components/data/table/utils/buildSelectionColumns.js +97 -71
  114. package/components/data/table/utils/columnBuilder.d.ts +13 -0
  115. package/components/data/table/utils/columnBuilder.js +27 -18
  116. package/components/data/table/utils/columnWidthDistribution.d.ts +1 -1
  117. package/components/data/table/utils/columnWidthDistribution.js +4 -1
  118. package/components/data/table/utils/constants.d.ts +1 -1
  119. package/components/data/table/utils/constants.js +1 -1
  120. package/components/dialogs/alert-dialog/index.d.ts +2 -0
  121. package/components/dialogs/confirm-dialog/index.d.ts +2 -0
  122. package/components/dialogs/dialog/index.d.ts +2 -0
  123. package/components/dialogs/dialog-actions/index.d.ts +1 -0
  124. package/components/dialogs/dialog-body/index.d.ts +1 -0
  125. package/components/dialogs/dialog-content/index.d.ts +1 -0
  126. package/components/dialogs/dialog-header/index.d.ts +1 -0
  127. package/components/dialogs/dialog-header/index.js +11 -12
  128. package/components/dialogs/iframe-dialog/index.d.ts +2 -0
  129. package/components/dialogs/login-dialog/index.d.ts +4 -0
  130. package/components/dialogs/login-dialog/index.js +2 -1
  131. package/components/dialogs/login-dialog/props.d.ts +1 -0
  132. package/components/dialogs/page-dialog/index.d.ts +4 -0
  133. package/components/dialogs/page-dialog/index.js +2 -1
  134. package/components/dialogs/page-dialog/props.d.ts +1 -0
  135. package/components/form/button/index.d.ts +1 -0
  136. package/components/form/button/index.js +29 -33
  137. package/components/form/button-group/index.d.ts +1 -0
  138. package/components/input/calendar/index.d.ts +2 -0
  139. package/components/input/chips/index.d.ts +2 -0
  140. package/components/input/chips/index.js +9 -3
  141. package/components/input/chips/utils.d.ts +5 -0
  142. package/components/input/chips/utils.js +29 -0
  143. package/components/input/color-picker/index.d.ts +2 -0
  144. package/components/input/composite/index.d.ts +1 -0
  145. package/components/input/composite/index.js +1 -0
  146. package/components/input/currency/index.d.ts +2 -0
  147. package/components/input/default/checkbox/index.d.ts +6 -0
  148. package/components/input/default/checkbox/index.js +48 -18
  149. package/components/input/default/checkbox/props.d.ts +8 -0
  150. package/components/input/default/checkboxset/index.d.ts +2 -0
  151. package/components/input/default/radioset/index.d.ts +2 -0
  152. package/components/input/default/switch/index.d.ts +6 -0
  153. package/components/input/default/switch/index.js +36 -9
  154. package/components/input/default/switch/prop.d.ts +2 -0
  155. package/components/input/epoch/date/index.d.ts +1 -0
  156. package/components/input/epoch/datetime/index.d.ts +1 -0
  157. package/components/input/epoch/time/index.d.ts +1 -0
  158. package/components/input/fileupload/components/ListItems.d.ts +5 -1
  159. package/components/input/fileupload/components/ListItems.js +27 -5
  160. package/components/input/fileupload/components/MultiUpload.js +12 -1
  161. package/components/input/fileupload/components/SingleUpload.js +12 -1
  162. package/components/input/fileupload/index.d.ts +3 -0
  163. package/components/input/fileupload/index.js +11 -0
  164. package/components/input/fileupload/props.d.ts +10 -0
  165. package/components/input/number/index.d.ts +2 -0
  166. package/components/input/rating/index.d.ts +6 -0
  167. package/components/input/rating/index.js +10 -5
  168. package/components/input/rating/props.d.ts +8 -0
  169. package/components/input/select/index.d.ts +2 -0
  170. package/components/input/slider/index.d.ts +6 -0
  171. package/components/input/slider/index.js +19 -2
  172. package/components/input/slider/props.d.ts +2 -0
  173. package/components/input/text/index.d.ts +7 -1
  174. package/components/input/text/index.js +25 -6
  175. package/components/input/text/props.d.ts +8 -0
  176. package/components/input/textarea/index.d.ts +2 -0
  177. package/components/input/textarea/index.js +9 -4
  178. package/components/input/textarea/util.d.ts +1 -0
  179. package/components/input/textarea/util.js +17 -0
  180. package/components/input/upload/index.d.ts +2 -0
  181. package/components/navbar/index.d.ts +7 -0
  182. package/components/navbar/index.js +21 -7
  183. package/components/navbar/nav/index.d.ts +1 -0
  184. package/components/navbar/nav-item/index.d.ts +1 -0
  185. package/components/navigation/breadcrumb/index.d.ts +1 -0
  186. package/components/navigation/menu/index.d.ts +3 -1
  187. package/components/navigation/menu/index.js +22 -4
  188. package/components/navigation/menu/props.d.ts +1 -0
  189. package/components/navigation/popover/index.d.ts +1 -0
  190. package/components/navigation/popover/index.js +8 -2
  191. package/components/page/partial/index.d.ts +1 -0
  192. package/core/appstore.d.ts +10 -0
  193. package/core/appstore.js +9 -1
  194. package/core/constants/events.d.ts +3 -0
  195. package/core/constants/events.js +13 -1
  196. package/core/proxy-service.js +1 -1
  197. package/core/util/index.d.ts +2 -0
  198. package/core/util/index.js +29 -0
  199. package/higherOrder/BasePage.js +81 -26
  200. package/higherOrder/props.d.ts +1 -0
  201. package/higherOrder/useActivePageReactivity.d.ts +21 -0
  202. package/higherOrder/useActivePageReactivity.js +57 -0
  203. package/higherOrder/withBaseWrapper.js +2 -0
  204. package/higherOrder/withRenderLogger.d.ts +15 -0
  205. package/higherOrder/withRenderLogger.js +53 -0
  206. package/hooks/useAuth.js +7 -1
  207. package/package-lock.json +219 -198
  208. package/package.json +4 -3
  209. package/runtime-dynamic/factories/dynamic-component.js +18 -5
  210. package/runtime-dynamic/factories/utils.js +7 -1
  211. package/runtime-dynamic/services/compile-render.js +2 -1
  212. package/store/slices/i18nSlice.d.ts +2 -0
  213. package/store/slices/i18nSlice.js +3 -1
  214. package/types/index.d.ts +6 -0
  215. package/utils/attr.js +4 -1
  216. package/utils/svg-icon.d.ts +27 -0
  217. package/utils/svg-icon.js +75 -0
@@ -9,6 +9,7 @@ export interface WmMenuProps extends BaseProps {
9
9
  menuclass?: string;
10
10
  linktarget?: string;
11
11
  iconclass?: string;
12
+ iconurl?: string;
12
13
  animateitems?: string;
13
14
  disableMenuContext?: boolean;
14
15
  showonhover?: boolean;
@@ -95,5 +95,6 @@ declare const _default: React.ComponentType<{
95
95
  prefabName?: string;
96
96
  loading?: boolean;
97
97
  showSkeleton?: boolean;
98
+ widget?: string;
98
99
  }>;
99
100
  export default _default;
@@ -18,7 +18,7 @@ var __spreadValues = (a, b) => {
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
21
- import { useRef, useState, useEffect, useMemo, Suspense, useCallback } from "react";
21
+ import { useRef, useState, useEffect, useMemo, Suspense, useCallback, useLayoutEffect } from "react";
22
22
  import clsx from "clsx";
23
23
  import debounce from "lodash-es/debounce";
24
24
  import Popover from "@mui/material/Popover";
@@ -33,6 +33,7 @@ const WmPopover = (Props) => {
33
33
  const [isDialogOpen, setIsDialogOpen] = useState(false);
34
34
  const anchorRef = useRef(null);
35
35
  const popoverContentRef = useRef(null);
36
+ const popoverActionsRef = useRef(null);
36
37
  const loadedRef = useRef(false);
37
38
  const [open, setOpen] = useState(false);
38
39
  const isOpen = Boolean(anchorEl);
@@ -100,6 +101,11 @@ const WmPopover = (Props) => {
100
101
  setPlacement("left");
101
102
  else setPlacement(props.popoverplacement || "bottom");
102
103
  };
104
+ useLayoutEffect(() => {
105
+ var _a2, _b2;
106
+ if (!isOpen) return;
107
+ (_b2 = (_a2 = popoverActionsRef.current) == null ? void 0 : _a2.updatePosition) == null ? void 0 : _b2.call(_a2);
108
+ }, [props.children]);
103
109
  useEffect(() => {
104
110
  if (!isOpen || props.autoclose === "disabled") return;
105
111
  const handleOutsideClick = (event) => {
@@ -202,7 +208,6 @@ const WmPopover = (Props) => {
202
208
  "disable-popover": props.disabled,
203
209
  "app-popover-wrapper": true
204
210
  }),
205
- style: props.styles,
206
211
  hidden: props.hidden
207
212
  }, { name: props.name }), {
208
213
  children: /* @__PURE__ */ jsx(
@@ -242,6 +247,7 @@ const WmPopover = (Props) => {
242
247
  /* @__PURE__ */ jsxs(
243
248
  Popover,
244
249
  {
250
+ action: popoverActionsRef,
245
251
  hidden: props.hidden,
246
252
  open: isOpen,
247
253
  anchorEl,
@@ -59,5 +59,6 @@ declare const _default: import("react").ComponentType<{
59
59
  prefabName?: string;
60
60
  loading?: boolean;
61
61
  showSkeleton?: boolean;
62
+ widget?: string;
62
63
  }>;
63
64
  export default _default;
@@ -1,8 +1,18 @@
1
1
  interface I18nService {
2
2
  selectedLocale?: string;
3
+ messages?: Record<string, string>;
4
+ formats?: {
5
+ currency?: string;
6
+ date?: string;
7
+ time?: string;
8
+ };
9
+ prefabMessages?: Record<string, string>;
3
10
  getSelectedLocale: () => string;
4
11
  isRTLLocale: (newLocale?: string) => any;
5
12
  setRTL: (locale?: string) => any;
13
+ setSelectedLocale: (locale: string | {
14
+ datavalue: string;
15
+ }) => unknown;
6
16
  }
7
17
  interface DialogServiceInterface {
8
18
  registerDialog: (name: string, dialogInstance: any) => void;
package/core/appstore.js CHANGED
@@ -1,4 +1,7 @@
1
+ import { isObject } from "lodash-es";
1
2
  import { getSessionLocaleSafe } from "./util";
3
+ import { store } from "../store";
4
+ import { setSelectedLocaleAndLoadBundle } from "../store/slices/i18nSlice";
2
5
  const map = /* @__PURE__ */ new Map();
3
6
  const get = (t) => {
4
7
  return map.get(t);
@@ -35,12 +38,13 @@ const appstore = {
35
38
  remove,
36
39
  getDependency,
37
40
  getApp,
38
- I18nService: getInstance("I18nService"),
41
+ I18nService: getInstance("i18nService"),
39
42
  DialogService: getInstance("DialogService")
40
43
  };
41
44
  if (!appstore.I18nService.get()) {
42
45
  appstore.I18nService.set({
43
46
  selectedLocale: getSessionLocaleSafe() || "en",
47
+ messages: {},
44
48
  getSelectedLocale: function() {
45
49
  try {
46
50
  const sessionLocale = getSessionLocaleSafe();
@@ -63,6 +67,10 @@ if (!appstore.I18nService.get()) {
63
67
  const isRTL = (_a = appstore.I18nService.get()) == null ? void 0 : _a.isRTLLocale(locale);
64
68
  document.body.style.direction = isRTL ? "rtl" : "ltr";
65
69
  }
70
+ },
71
+ setSelectedLocale: (locale) => {
72
+ const localeValue = isObject(locale) ? locale.datavalue : locale;
73
+ return store.dispatch(setSelectedLocaleAndLoadBundle({ locale: localeValue }));
66
74
  }
67
75
  });
68
76
  }
@@ -21,4 +21,7 @@ export declare const EVENTEMITTER_METHODS: {
21
21
  layout: Record<string, any>;
22
22
  proxy: any;
23
23
  }) => boolean;
24
+ ACTIVE_PAGE_SYNC_ON: (callback: () => void) => EventEmitter<[never]>;
25
+ ACTIVE_PAGE_SYNC_OFF: (callback: () => void) => EventEmitter<[never]>;
26
+ ACTIVE_PAGE_SYNC_EMIT: () => boolean;
24
27
  };
@@ -2,13 +2,16 @@ import EventEmitter from "events";
2
2
  const partialStateSyncEmitter = new EventEmitter();
3
3
  const prefabStateSyncEmitter = new EventEmitter();
4
4
  const layoutSyncEmitter = new EventEmitter();
5
+ const activePageSyncEmitter = new EventEmitter();
5
6
  partialStateSyncEmitter.setMaxListeners(50);
6
7
  prefabStateSyncEmitter.setMaxListeners(50);
7
8
  layoutSyncEmitter.setMaxListeners(50);
9
+ activePageSyncEmitter.setMaxListeners(50);
8
10
  const EVENTEMITTER = {
9
11
  LAYOUT_STATE_REFRESH: "layout-state-refresh",
10
12
  PARTIAL_STATE_SYNC: "partial-state-sync",
11
- PREFAB_STATE_SYNC: "prefab-state-sync"
13
+ PREFAB_STATE_SYNC: "prefab-state-sync",
14
+ ACTIVE_PAGE_SYNC: "active-page-sync"
12
15
  };
13
16
  const EVENTEMITTER_METHODS = {
14
17
  PREFAB_STATE_SYNC_ON: (name = "", callback) => {
@@ -46,6 +49,15 @@ const EVENTEMITTER_METHODS = {
46
49
  },
47
50
  LAYOUT_STATE_REFRESH_EMIT: (data) => {
48
51
  return layoutSyncEmitter.emit(EVENTEMITTER.LAYOUT_STATE_REFRESH, data);
52
+ },
53
+ ACTIVE_PAGE_SYNC_ON: (callback) => {
54
+ return activePageSyncEmitter.on(EVENTEMITTER.ACTIVE_PAGE_SYNC, callback);
55
+ },
56
+ ACTIVE_PAGE_SYNC_OFF: (callback) => {
57
+ return activePageSyncEmitter.off(EVENTEMITTER.ACTIVE_PAGE_SYNC, callback);
58
+ },
59
+ ACTIVE_PAGE_SYNC_EMIT: () => {
60
+ return activePageSyncEmitter.emit(EVENTEMITTER.ACTIVE_PAGE_SYNC);
49
61
  }
50
62
  };
51
63
  export {
@@ -431,7 +431,7 @@ const createStateProxy = (obj, path = [], setPageContext, overriddenPropsRegistr
431
431
  if (descriptor && !descriptor.configurable && !descriptor.writable) {
432
432
  return value;
433
433
  }
434
- if (value instanceof ServiceVariable || value instanceof LiveVariable) {
434
+ if (value instanceof ServiceVariable || value instanceof LiveVariable || value instanceof ModelVariable || value instanceof CrudVariable) {
435
435
  return value;
436
436
  }
437
437
  if (isDOMElement(value)) {
@@ -38,6 +38,8 @@ export declare const getSessionStorageItem: (key: string) => any;
38
38
  export declare const getSessionLocaleSafe: () => string | undefined;
39
39
  export declare const getTimezone: () => string;
40
40
  export declare const formatMessage: (fragment: any, expression: string) => any;
41
+ /** Angular parity: same appLocale object, swap message keys in place so bindings stay valid. */
42
+ export declare function syncLocaleMessages(target: Record<string, any> | undefined, messages: Record<string, any>): boolean;
41
43
  export declare function reload(): void;
42
44
  export declare const toNumber: (value: any) => number;
43
45
  export declare const _get: {
@@ -91,6 +91,34 @@ const getTimezone = () => {
91
91
  const formatMessage = (fragment, expression) => {
92
92
  return get(fragment, `appLocale.${expression}`, expression);
93
93
  };
94
+ function syncLocaleMessages(target, messages) {
95
+ if (!target || typeof target !== "object") {
96
+ return false;
97
+ }
98
+ let synced = true;
99
+ Object.keys(target).forEach((key) => {
100
+ if (!(key in messages)) {
101
+ try {
102
+ delete target[key];
103
+ } catch (e) {
104
+ synced = false;
105
+ }
106
+ }
107
+ });
108
+ Object.keys(messages).forEach((key) => {
109
+ try {
110
+ const descriptor = Object.getOwnPropertyDescriptor(target, key);
111
+ if (descriptor && !descriptor.configurable && !descriptor.writable) {
112
+ synced = false;
113
+ return;
114
+ }
115
+ target[key] = messages[key];
116
+ } catch (e) {
117
+ synced = false;
118
+ }
119
+ });
120
+ return synced;
121
+ }
94
122
  function reload() {
95
123
  window.location.reload();
96
124
  }
@@ -186,6 +214,7 @@ export {
186
214
  reload,
187
215
  replace,
188
216
  setSessionStorageItem,
217
+ syncLocaleMessages,
189
218
  toBoolean,
190
219
  toNumber
191
220
  };
@@ -49,6 +49,7 @@ import {
49
49
  } from "../core/script-registry";
50
50
  import formatters from "../core/formatters";
51
51
  import { useAppProxy } from "../context/AppContext";
52
+ import { syncLocaleMessages } from "../core/util";
52
53
  import {
53
54
  computeMergedPageParams,
54
55
  computePartialParamKey,
@@ -57,12 +58,13 @@ import {
57
58
  import { useAppSpinner } from "../context/AppSpinnerProvider";
58
59
  import get from "lodash-es/get";
59
60
  import { EVENTEMITTER_METHODS } from "../core/constants/events";
61
+ import { useActivePageReactivity } from "./useActivePageReactivity";
60
62
  import { wrapWithThirdPartyErrorGuard } from "../utils/lib-error-skipper";
61
63
  import { viewportService } from "../store/viewport.service";
62
64
  import { formatMessage } from "../core/util";
63
65
  const withPageContext = (WrappedComponent, addPageScript, getVariables, componentInfo, prefabInfo) => {
64
66
  const PageContextComponent = (props) => {
65
- var _a, _b, _c;
67
+ var _a, _b, _c, _d, _e, _f;
66
68
  const dispatch = useAppDispatch();
67
69
  const { show, hide } = (_a = useAppSpinner()) != null ? _a : {};
68
70
  const i18n = useAppSelector((state) => state.i18n);
@@ -112,6 +114,7 @@ const withPageContext = (WrappedComponent, addPageScript, getVariables, componen
112
114
  const subscribedVariableNamesRef = useRef(/* @__PURE__ */ new Set());
113
115
  const overriddenPropsRegistryRef = useRef(null);
114
116
  const onStartupCompletedRef = useRef(false);
117
+ const lastSyncedLocaleRevisionRef = useRef(-1);
115
118
  const [isPageReady, setIsPageReady] = useState(false);
116
119
  const pageReady = useCallback(() => {
117
120
  setIsPageReady(true);
@@ -151,6 +154,18 @@ const withPageContext = (WrappedComponent, addPageScript, getVariables, componen
151
154
  activePageName: componentInfo == null ? void 0 : componentInfo.componentName
152
155
  }));
153
156
  const initialAppConfig = useMemo(() => appContext, [appContext]);
157
+ useActivePageReactivity({
158
+ componentType: componentInfo == null ? void 0 : componentInfo.componentType,
159
+ appProxy,
160
+ setPageContext,
161
+ isMountedRef,
162
+ activePageDeps: componentInfo == null ? void 0 : componentInfo.activePageDeps
163
+ });
164
+ useEffect(() => {
165
+ if ((componentInfo == null ? void 0 : componentInfo.componentType) === "PAGE" && (appProxy == null ? void 0 : appProxy.activePageName) === (componentInfo == null ? void 0 : componentInfo.componentName)) {
166
+ EVENTEMITTER_METHODS.ACTIVE_PAGE_SYNC_EMIT();
167
+ }
168
+ }, [pageContext, componentInfo == null ? void 0 : componentInfo.componentType, componentInfo == null ? void 0 : componentInfo.componentName, appProxy]);
154
169
  const partialParamValuesKey = computePartialParamKey(
155
170
  componentInfo == null ? void 0 : componentInfo.componentType,
156
171
  props.params,
@@ -289,7 +304,13 @@ const withPageContext = (WrappedComponent, addPageScript, getVariables, componen
289
304
  pageProxy.partialParams = newParams;
290
305
  (_a2 = props.onLoad) == null ? void 0 : _a2.call(props, pageProxy);
291
306
  }
292
- appProxy.appLocale = i18n.appLocale || {};
307
+ const mergedAppLocale = i18n.appLocale || {};
308
+ if (!appProxy.appLocale) {
309
+ appProxy.appLocale = {};
310
+ }
311
+ if (!syncLocaleMessages(appProxy.appLocale, mergedAppLocale)) {
312
+ appProxy.appLocale = __spreadValues({}, mergedAppLocale);
313
+ }
293
314
  const localeFormats = {
294
315
  date: i18n.dateFormat,
295
316
  time: i18n.timeFormat,
@@ -304,6 +325,7 @@ const withPageContext = (WrappedComponent, addPageScript, getVariables, componen
304
325
  pageProxy.selectedLocale = i18n.selectedLocale || "en";
305
326
  pageProxy.overriddenPropsRegistry = overriddenPropsRegistryRef.current;
306
327
  setupVariableSubscriptions(pageVariables.Variables);
328
+ await executeStartupVariables(pageVariables.Variables);
307
329
  if ((componentInfo == null ? void 0 : componentInfo.componentType) === "PAGE" && appProxy) {
308
330
  const pageName2 = componentInfo == null ? void 0 : componentInfo.componentName;
309
331
  appProxy.updateActivePage(pageName2);
@@ -457,21 +479,11 @@ const withPageContext = (WrappedComponent, addPageScript, getVariables, componen
457
479
  setupVariableSubscriptions(appVarsOnly);
458
480
  }
459
481
  };
460
- const executeStartupOperations = async (Variables, Actions) => {
461
- const { startUpActions = [], startUpVariables = [] } = componentInfo || {};
482
+ const executeStartupVariables = async (Variables) => {
483
+ const startUpVariables = (componentInfo == null ? void 0 : componentInfo.startUpVariables) || [];
484
+ if (!startUpVariables.length) return;
462
485
  startUpVariables.forEach((name) => pendingStartupOpsRef.current.add(name));
463
- startUpActions.forEach((name) => pendingStartupOpsRef.current.add(name));
464
- if (startUpActions.length === 0 && startUpVariables.length === 0) {
465
- return;
466
- }
467
486
  try {
468
- startUpActions.forEach((actionName) => {
469
- var _a2;
470
- if ((_a2 = Actions[actionName]) == null ? void 0 : _a2.invoke) {
471
- Actions[actionName].invoke();
472
- }
473
- pendingStartupOpsRef.current.delete(String(actionName));
474
- });
475
487
  const variablePromises = startUpVariables.map((varName) => {
476
488
  var _a2;
477
489
  if ((_a2 = Variables[varName]) == null ? void 0 : _a2.invoke) {
@@ -493,7 +505,24 @@ const withPageContext = (WrappedComponent, addPageScript, getVariables, componen
493
505
  }
494
506
  }, 0);
495
507
  } catch (error) {
496
- console.error("Error during startup operations:", error);
508
+ console.error("Error during startup variables:", error);
509
+ }
510
+ };
511
+ const executeStartupActions = async (Actions) => {
512
+ const startUpActions = (componentInfo == null ? void 0 : componentInfo.startUpActions) || [];
513
+ if (!startUpActions.length) return;
514
+ startUpActions.forEach((name) => pendingStartupOpsRef.current.add(name));
515
+ try {
516
+ startUpActions.forEach((actionName) => {
517
+ var _a2;
518
+ if ((_a2 = Actions[actionName]) == null ? void 0 : _a2.invoke) {
519
+ Actions[actionName].invoke();
520
+ }
521
+ pendingStartupOpsRef.current.delete(String(actionName));
522
+ });
523
+ pendingStartupOpsRef.current.clear();
524
+ } catch (error) {
525
+ console.error("Error during startup actions:", error);
497
526
  }
498
527
  };
499
528
  function layoutReady() {
@@ -538,19 +567,45 @@ const withPageContext = (WrappedComponent, addPageScript, getVariables, componen
538
567
  async function executeStartup() {
539
568
  await (appContext == null ? void 0 : appContext.executeStartAppOperations());
540
569
  }
541
- async function executePageStartup() {
542
- await executeStartupOperations(pageContext.Variables, pageContext.Actions);
570
+ const applyLocaleToProxies = useCallback(
571
+ (newAppLocale) => {
572
+ var _a2;
573
+ if (appProxy) {
574
+ if (!appProxy.appLocale) {
575
+ appProxy.appLocale = {};
576
+ }
577
+ if (!syncLocaleMessages(appProxy.appLocale, newAppLocale)) {
578
+ appProxy.appLocale = __spreadValues({}, newAppLocale);
579
+ }
580
+ }
581
+ if (pageProxyRef.current) {
582
+ if (!pageProxyRef.current.appLocale) {
583
+ pageProxyRef.current.appLocale = {};
584
+ }
585
+ if (!syncLocaleMessages(pageProxyRef.current.appLocale, newAppLocale)) {
586
+ pageProxyRef.current.appLocale = __spreadValues({}, newAppLocale);
587
+ }
588
+ if (pageProxyRef.current.App) {
589
+ pageProxyRef.current.App.appLocale = (_a2 = appProxy == null ? void 0 : appProxy.appLocale) != null ? _a2 : newAppLocale;
590
+ }
591
+ }
592
+ },
593
+ [appProxy == null ? void 0 : appProxy.appLocale]
594
+ );
595
+ if (isInitialized && pageProxyRef.current && ((_c = i18n.localeRevision) != null ? _c : 0) !== lastSyncedLocaleRevisionRef.current) {
596
+ const isLocaleChange = lastSyncedLocaleRevisionRef.current >= 0;
597
+ lastSyncedLocaleRevisionRef.current = (_d = i18n.localeRevision) != null ? _d : 0;
598
+ applyLocaleToProxies(i18n.appLocale);
599
+ if (isLocaleChange && (componentInfo == null ? void 0 : componentInfo.componentType) === "PAGE") {
600
+ addPageScript(appProxy, pageProxyRef.current);
601
+ }
543
602
  }
544
603
  useEffect(() => {
545
- var _a2;
546
604
  const newAppLocale = merge({}, i18n.appLocale || {}, (prefabInfo == null ? void 0 : prefabInfo.appLocale) || {});
547
605
  if (!isEqual(pageContext.appLocale, newAppLocale)) {
548
606
  setPageContext((prev) => __spreadProps(__spreadValues({}, prev), {
549
607
  appLocale: newAppLocale
550
608
  }));
551
- if ((_a2 = pageProxyRef.current) == null ? void 0 : _a2.App) {
552
- pageProxyRef.current.App.appLocale = newAppLocale;
553
- }
554
609
  }
555
610
  }, [i18n.appLocale]);
556
611
  useEffect(() => {
@@ -586,9 +641,9 @@ const withPageContext = (WrappedComponent, addPageScript, getVariables, componen
586
641
  if ((securityConfig == null ? void 0 : securityConfig.authenticated) && (appProxy == null ? void 0 : appProxy.executeSessionFailureRequests)) {
587
642
  await appProxy.executeSessionFailureRequests();
588
643
  }
589
- await executeStartup();
644
+ await (appContext == null ? void 0 : appContext.executeStartAppOperations());
590
645
  await onContentReady();
591
- await executePageStartup();
646
+ executeStartupActions(pageContext.Actions);
592
647
  onStartupCompletedRef.current = true;
593
648
  if (pendingAccordionExpansion) {
594
649
  accordionExpansionHandler(pageProxyRef, pendingAccordionExpansion, dispatch);
@@ -626,14 +681,14 @@ const withPageContext = (WrappedComponent, addPageScript, getVariables, componen
626
681
  ((_a2 = appVariables[value]) == null ? void 0 : _a2.invokeOnParamChange) && ((_b2 = appVariables[value]) == null ? void 0 : _b2.invokeOnParamChange());
627
682
  });
628
683
  }
629
- if (((_c = componentInfo == null ? void 0 : componentInfo.autoUpdateVariables) == null ? void 0 : _c.length) && onStartupCompletedRef.current) {
684
+ if (((_e = componentInfo == null ? void 0 : componentInfo.autoUpdateVariables) == null ? void 0 : _e.length) && onStartupCompletedRef.current) {
630
685
  const pageVariables = pageContext.Variables;
631
686
  componentInfo.autoUpdateVariables.forEach((value) => {
632
687
  var _a2, _b2;
633
688
  (_b2 = (_a2 = pageVariables[value]) == null ? void 0 : _a2.invokeOnParamChange) == null ? void 0 : _b2.call(_a2);
634
689
  });
635
690
  }
636
- return /* @__PURE__ */ jsx(WidgetProvider, { value: { value: pageContext, proxy: pageProxyRef.current }, children: /* @__PURE__ */ jsx(WrappedComponent, __spreadValues({}, props)) });
691
+ return /* @__PURE__ */ jsx(WidgetProvider, { value: { value: pageContext, proxy: pageProxyRef.current }, children: /* @__PURE__ */ jsx(WrappedComponent, __spreadValues({}, props), `locale-${(_f = i18n.localeRevision) != null ? _f : 0}`) });
637
692
  };
638
693
  PageContextComponent.displayName = `WithPageContext(${WrappedComponent.displayName || WrappedComponent.name || "Component"})`;
639
694
  return PageContextComponent;
@@ -77,6 +77,7 @@ export interface Props {
77
77
  * Not emitted by codegen — omit (default) to show skeleton when `loading` is true.
78
78
  */
79
79
  showSkeleton?: boolean;
80
+ widget?: string;
80
81
  }
81
82
  /**
82
83
  * Interface for props injected by the BaseDialog (withDialogWrapper) HOC.
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import { PageContextState } from "@wavemaker-ai/react-runtime/types";
3
+ interface UseActivePageReactivityParams {
4
+ componentType?: string;
5
+ appProxy: any;
6
+ setPageContext: React.Dispatch<React.SetStateAction<PageContextState>>;
7
+ isMountedRef: React.RefObject<boolean>;
8
+ /** Active-page dependency paths this component reads (`App.activePage.*`), declared by codegen. */
9
+ activePageDeps?: string[];
10
+ }
11
+ /**
12
+ * Cross-context reactivity (value-gated): the active page broadcasts on every commit; this hook
13
+ * re-renders the consuming partial/prefab only when one of its codegen-declared `App.activePage.*`
14
+ * dependency paths actually changed. Works for Variables, Widgets, or anything after `activePage`,
15
+ * since the comparison is on the resolved value (the runtime creates new references on change).
16
+ *
17
+ * Propagation is page -> island only (acyclic). Partials with no declared deps never subscribe, so
18
+ * unrelated partials (header/footer) stay untouched. Re-subscribes/resets on navigation.
19
+ */
20
+ export declare const useActivePageReactivity: ({ componentType, appProxy, setPageContext, isMountedRef, activePageDeps, }: UseActivePageReactivityParams) => void;
21
+ export default useActivePageReactivity;
@@ -0,0 +1,57 @@
1
+ "use client";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __spreadValues = (a, b) => {
10
+ for (var prop in b || (b = {}))
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
13
+ if (__getOwnPropSymbols)
14
+ for (var prop of __getOwnPropSymbols(b)) {
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ }
18
+ return a;
19
+ };
20
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
+ import { useEffect, useRef } from "react";
22
+ import { EVENTEMITTER_METHODS } from "../core/constants/events";
23
+ const resolvePath = (root, path) => path.split(".").reduce((obj, key) => obj == null ? void 0 : obj[key], root);
24
+ const useActivePageReactivity = ({
25
+ componentType,
26
+ appProxy,
27
+ setPageContext,
28
+ isMountedRef,
29
+ activePageDeps
30
+ }) => {
31
+ var _a;
32
+ const snapshotRef = useRef([]);
33
+ const activePage = appProxy == null ? void 0 : appProxy.activePage;
34
+ const declaredKey = (_a = activePageDeps == null ? void 0 : activePageDeps.join("|")) != null ? _a : "";
35
+ useEffect(() => {
36
+ if (componentType === "PAGE" || !(activePageDeps == null ? void 0 : activePageDeps.length)) return;
37
+ const readValues = () => activePageDeps.map((path) => resolvePath(activePage, path));
38
+ snapshotRef.current = readValues();
39
+ const onActivePageChange = () => {
40
+ if (!isMountedRef.current) return;
41
+ const next = readValues();
42
+ if (next.some((value, i) => !Object.is(value, snapshotRef.current[i]))) {
43
+ snapshotRef.current = next;
44
+ setPageContext((prev) => __spreadProps(__spreadValues({}, prev), { App: __spreadValues({}, prev.App) }));
45
+ }
46
+ };
47
+ EVENTEMITTER_METHODS.ACTIVE_PAGE_SYNC_ON(onActivePageChange);
48
+ return () => {
49
+ EVENTEMITTER_METHODS.ACTIVE_PAGE_SYNC_OFF(onActivePageChange);
50
+ };
51
+ }, [componentType, activePage, declaredKey]);
52
+ };
53
+ var useActivePageReactivity_default = useActivePageReactivity;
54
+ export {
55
+ useActivePageReactivity_default as default,
56
+ useActivePageReactivity
57
+ };
@@ -122,6 +122,8 @@ const withBaseWrapper = (WrappedComponent) => {
122
122
  delete propsForComparison.listener;
123
123
  delete stateForComparison.viewParent;
124
124
  delete propsForComparison.viewParent;
125
+ delete stateForComparison.children;
126
+ delete propsForComparison.children;
125
127
  if (!isEqual(stateForComparison, propsForComparison)) {
126
128
  updateWidgetState(name, mergedProps);
127
129
  }
@@ -0,0 +1,15 @@
1
+ import { ComponentType } from "react";
2
+ /**
3
+ * Dev HOC that logs why a component re-rendered.
4
+ *
5
+ * On every render it diffs the current props against the previous render's
6
+ * props (shallow, by reference) and logs which keys changed, with prev/next
7
+ * values. Useful for spotting unstable props (new object/array/fn identity)
8
+ * that cause avoidable re-renders.
9
+ *
10
+ * Pure React (no jsx-runtime patching, no external dep), so it works in any
11
+ * bundler/runtime — unlike why-did-you-render.
12
+ *
13
+ * NOTE: no NODE_ENV gate for now (per request) — logs in all environments.
14
+ */
15
+ export declare function withRenderLogger<P extends Record<string, any>>(WrappedComponent: ComponentType<P>, label?: string): ComponentType<P>;
@@ -0,0 +1,53 @@
1
+ "use client";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
+ var __spreadValues = (a, b) => {
8
+ for (var prop in b || (b = {}))
9
+ if (__hasOwnProp.call(b, prop))
10
+ __defNormalProp(a, prop, b[prop]);
11
+ if (__getOwnPropSymbols)
12
+ for (var prop of __getOwnPropSymbols(b)) {
13
+ if (__propIsEnum.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ }
16
+ return a;
17
+ };
18
+ import { jsx } from "react/jsx-runtime";
19
+ import { useRef } from "react";
20
+ function withRenderLogger(WrappedComponent, label) {
21
+ const name = label || WrappedComponent.displayName || WrappedComponent.name || "Component";
22
+ const WithRenderLogger = (props) => {
23
+ const prevProps = useRef(null);
24
+ const renderCount = useRef(0);
25
+ renderCount.current += 1;
26
+ const changed = {};
27
+ if (prevProps.current) {
28
+ const keys = /* @__PURE__ */ new Set([...Object.keys(prevProps.current), ...Object.keys(props)]);
29
+ keys.forEach((key) => {
30
+ if (prevProps.current[key] !== props[key]) {
31
+ changed[key] = { prev: prevProps.current[key], next: props[key] };
32
+ }
33
+ });
34
+ }
35
+ const changedKeys = Object.keys(changed);
36
+ if (prevProps.current === null) {
37
+ console.log(`%c[render] ${name} #${renderCount.current} (mount)`, "color:#888");
38
+ } else {
39
+ console.log(
40
+ `%c[render] ${name} #${renderCount.current} \u2014 ${changedKeys.length ? `changed: ${changedKeys.join(", ")}` : "no prop changes (state/context/parent re-render)"}`,
41
+ changedKeys.length ? "color:#d9480f" : "color:#1971c2",
42
+ changedKeys.length ? changed : ""
43
+ );
44
+ }
45
+ prevProps.current = props;
46
+ return /* @__PURE__ */ jsx(WrappedComponent, __spreadValues({}, props));
47
+ };
48
+ WithRenderLogger.displayName = `withRenderLogger(${name})`;
49
+ return WithRenderLogger;
50
+ }
51
+ export {
52
+ withRenderLogger
53
+ };
package/hooks/useAuth.js CHANGED
@@ -36,6 +36,12 @@ const useAuth = () => {
36
36
  const { isLoggedIn, loggedInUser, securityConfig, isPageLoading, error } = useAppSelector(
37
37
  (state) => state.auth
38
38
  );
39
+ const securityEnabled = useAppSelector(
40
+ (state) => {
41
+ var _a, _b, _c;
42
+ return !!((_c = (_b = (_a = state.info) == null ? void 0 : _a.appConfig) == null ? void 0 : _b.appProperties) == null ? void 0 : _c.securityEnabled);
43
+ }
44
+ );
39
45
  const handleLogin = async (options) => {
40
46
  try {
41
47
  const loginResponse = await dispatch(login(options)).unwrap();
@@ -76,7 +82,7 @@ const useAuth = () => {
76
82
  return widgetRoles.some((role) => includes(userRoles, role));
77
83
  };
78
84
  const getLoggedInUserDetails = async (baseURL) => {
79
- if (!baseURL) {
85
+ if (!securityEnabled) {
80
86
  dispatch(setPageLoading(true));
81
87
  await dispatch(getServiceDefinitions(baseURL)).unwrap();
82
88
  dispatch(setPageLoading(false));