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

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 (124) hide show
  1. package/components/basic/anchor/index.js +3 -0
  2. package/components/basic/icon/index.js +36 -5
  3. package/components/basic/iframe/index.js +18 -8
  4. package/components/basic/label/index.js +4 -3
  5. package/components/basic/search/index.d.ts +72 -3
  6. package/components/basic/search/index.js +75 -21
  7. package/components/basic/search/props.d.ts +4 -0
  8. package/components/common/WmAppIcon/index.js +11 -8
  9. package/components/common/WmAppIcon/props.d.ts +2 -0
  10. package/components/container/accordion/accordion-pane/index.d.ts +1 -0
  11. package/components/container/accordion/accordion-pane/index.js +7 -3
  12. package/components/container/accordion/accordion-pane/props.d.ts +1 -0
  13. package/components/container/index.js +18 -5
  14. package/components/container/layout-grid/grid-row/index.js +1 -1
  15. package/components/container/panel/components/panel-header/index.js +1 -3
  16. package/components/container/tabs/tab-pane/index.d.ts +1 -0
  17. package/components/container/tabs/tab-pane/index.js +2 -2
  18. package/components/container/tabs/tab-pane/props.d.ts +1 -0
  19. package/components/container/wizard/index.js +11 -10
  20. package/components/container/wizard/utils.js +1 -0
  21. package/components/data/form/base-form/hooks/useFormSubmission.d.ts +1 -1
  22. package/components/data/form/base-form/hooks/useFormSubmission.js +3 -1
  23. package/components/data/form/base-form/index.js +11 -14
  24. package/components/data/form/base-form/props.d.ts +3 -0
  25. package/components/data/form/dynamic-fields/WmxDynamicFormField.d.ts +11 -0
  26. package/components/data/form/dynamic-fields/WmxDynamicFormField.js +77 -0
  27. package/components/data/form/dynamic-fields/index.js +12 -1
  28. package/components/data/form/form-controller/withFormController.js +19 -16
  29. package/components/data/form/form-field/base-field.js +8 -5
  30. package/components/data/form/form-field/index.js +15 -8
  31. package/components/data/form/form-field/props.d.ts +1 -0
  32. package/components/data/list/components/ListItemWithTemplate.js +5 -2
  33. package/components/data/list/hooks/useListEffects.js +1 -1
  34. package/components/data/list/index.js +14 -5
  35. package/components/data/list/utils/constants.d.ts +0 -1
  36. package/components/data/list/utils/constants.js +0 -2
  37. package/components/data/table/components/RowCells.js +20 -4
  38. package/components/data/table/components/TableBody.js +5 -3
  39. package/components/data/table/components/TableHeader.js +14 -8
  40. package/components/data/table/components/TablePanelHeading.js +1 -1
  41. package/components/data/table/hooks/useDynamicColumns.js +1 -1
  42. package/components/data/table/hooks/useRowExpansion.js +41 -31
  43. package/components/data/table/hooks/useRowHandlers.d.ts +4 -2
  44. package/components/data/table/hooks/useRowHandlers.js +23 -12
  45. package/components/data/table/hooks/useRowSelection.d.ts +1 -1
  46. package/components/data/table/hooks/useRowSelection.js +80 -66
  47. package/components/data/table/hooks/useServerSideSorting.js +0 -1
  48. package/components/data/table/hooks/useTableColumns.js +16 -8
  49. package/components/data/table/hooks/useTableData.js +0 -1
  50. package/components/data/table/hooks/useTableEdit.js +0 -1
  51. package/components/data/table/hooks/useTableState.js +14 -2
  52. package/components/data/table/index.js +94 -61
  53. package/components/data/table/live-table/index.js +0 -1
  54. package/components/data/table/props.d.ts +8 -0
  55. package/components/data/table/utils/buildSelectionColumns.js +2 -4
  56. package/components/data/table/utils/columnBuilder.d.ts +16 -2
  57. package/components/data/table/utils/columnBuilder.js +14 -9
  58. package/components/data/table/utils/columnWidthDistribution.js +10 -0
  59. package/components/data/table/utils/constants.d.ts +0 -4
  60. package/components/data/table/utils/constants.js +0 -7
  61. package/components/data/table/utils/dynamic-columns.d.ts +1 -1
  62. package/components/data/table/utils/dynamic-columns.js +3 -8
  63. package/components/data/table/utils/expansionColumn.d.ts +23 -0
  64. package/components/data/table/utils/expansionColumn.js +56 -0
  65. package/components/data/table/utils/index.d.ts +23 -3
  66. package/components/data/table/utils/index.js +60 -20
  67. package/components/data/table/utils/selectionUtils.d.ts +5 -0
  68. package/components/data/table/utils/selectionUtils.js +5 -0
  69. package/components/dialogs/dialog/index.js +3 -2
  70. package/components/dialogs/dialog-header/index.js +1 -1
  71. package/components/dialogs/index.js +14 -2
  72. package/components/input/chips/index.js +29 -5
  73. package/components/input/color-picker/index.js +4 -6
  74. package/components/input/default/radioset/index.js +2 -1
  75. package/components/input/epoch/date/index.js +1 -1
  76. package/components/input/select/index.js +3 -5
  77. package/components/input/text/index.js +2 -2
  78. package/components/input/textarea/index.js +42 -17
  79. package/components/navbar/nav/index.js +10 -5
  80. package/components/navigation/breadcrumb/index.js +2 -1
  81. package/components/navigation/popover/index.js +24 -8
  82. package/components/page/index.js +1 -1
  83. package/components/page/page-content/index.js +30 -6
  84. package/components/page/page-content/props.d.ts +1 -0
  85. package/components/page/partial-container/index.js +2 -1
  86. package/components/prefab/index.js +3 -2
  87. package/components/prefab/props.d.ts +1 -0
  88. package/components/wmx/WmxRenderer.d.ts +8 -0
  89. package/components/wmx/WmxRenderer.js +57 -0
  90. package/context/WidgetProvider.js +2 -1
  91. package/core/appstore.js +1 -1
  92. package/core/proxy-service.d.ts +1 -0
  93. package/core/proxy-service.js +53 -2
  94. package/core/util/index.d.ts +0 -2
  95. package/core/util/index.js +3 -30
  96. package/higherOrder/BasePage.js +36 -54
  97. package/higherOrder/DataNav.js +4 -1
  98. package/higherOrder/withBaseWrapper.js +9 -7
  99. package/hooks/useHttp.js +4 -2
  100. package/hooks/useLayoutSize.js +1 -1
  101. package/package-lock.json +240 -607
  102. package/package.json +3 -3
  103. package/runtime-dynamic/app-initializer.js +2 -1
  104. package/runtime-dynamic/components/partial-content.js +4 -1
  105. package/runtime-dynamic/components/wmx-placeholder.d.ts +18 -0
  106. package/runtime-dynamic/components/wmx-placeholder.js +48 -0
  107. package/runtime-dynamic/factories/dynamic-component.js +26 -3
  108. package/runtime-dynamic/main.js +6 -0
  109. package/runtime-dynamic/services/compile-render.js +75 -12
  110. package/runtime-dynamic/services/css-scoping.d.ts +2 -0
  111. package/runtime-dynamic/services/css-scoping.js +39 -20
  112. package/store/slices/i18nSlice.d.ts +0 -1
  113. package/store/slices/i18nSlice.js +0 -2
  114. package/utils/custom-expression/parser.js +11 -8
  115. package/utils/layoutsize-util.js +12 -7
  116. package/utils/style-utils.d.ts +6 -0
  117. package/utils/style-utils.js +10 -0
  118. package/utils/transformedDataset-utils.d.ts +3 -3
  119. package/utils/transformedDataset-utils.js +1 -2
  120. package/utils/wmx.utils.d.ts +6 -0
  121. package/utils/wmx.utils.js +41 -0
  122. package/variables/crud-variable.js +1 -1
  123. package/variables/live-variable.js +1 -1
  124. package/variables/service-variable.js +6 -3
@@ -3,6 +3,7 @@ import clsx from "clsx";
3
3
  import Link from "next/link";
4
4
  import withDatasetAwareNavigation from "../../../higherOrder/DataNav";
5
5
  import withBaseWrapper from "../../../higherOrder/withBaseWrapper";
6
+ import { WmAppIcon } from "../../common/WmAppIcon";
6
7
  const BreadCrumb = (props) => {
7
8
  const { className, onBeforenavigate, itemtarget, navNodes = [] } = props;
8
9
  function handleBeforeNavigate(e, node) {
@@ -11,7 +12,7 @@ const BreadCrumb = (props) => {
11
12
  }
12
13
  }
13
14
  const renderNavItem = (node, index, isLast = false) => /* @__PURE__ */ jsx("li", { className: clsx(node.class, { active: isLast }), children: /* @__PURE__ */ jsxs(Fragment, { children: [
14
- node.icon ? /* @__PURE__ */ jsx("i", { className: node.icon }) : /* @__PURE__ */ jsx("i", {}),
15
+ node.icon && /* @__PURE__ */ jsx(WmAppIcon, { icon: node.icon }),
15
16
  !isLast ? /* @__PURE__ */ jsx(
16
17
  Link,
17
18
  {
@@ -18,7 +18,15 @@ 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, useLayoutEffect } from "react";
21
+ import {
22
+ useRef,
23
+ useState,
24
+ useEffect,
25
+ useMemo,
26
+ Suspense,
27
+ useCallback,
28
+ useLayoutEffect
29
+ } from "react";
22
30
  import clsx from "clsx";
23
31
  import debounce from "lodash-es/debounce";
24
32
  import Popover from "@mui/material/Popover";
@@ -63,13 +71,20 @@ const WmPopover = (Props) => {
63
71
  openPopover();
64
72
  }
65
73
  }, [isOpen, openPopover, closePopover]);
74
+ const apiRef = useRef({
75
+ open: openPopover,
76
+ close: closePopover,
77
+ toggle: togglePopover,
78
+ isOpen
79
+ });
80
+ apiRef.current = { open: openPopover, close: closePopover, toggle: togglePopover, isOpen };
66
81
  useEffect(() => {
67
82
  const { listener, name } = props;
68
83
  if ((listener == null ? void 0 : listener.onChange) && name) {
69
84
  listener.onChange(name, {
70
- open: openPopover,
71
- close: closePopover,
72
- toggle: togglePopover,
85
+ open: () => apiRef.current.open(),
86
+ close: () => apiRef.current.close(),
87
+ toggle: () => apiRef.current.toggle(),
73
88
  isOpen
74
89
  });
75
90
  }
@@ -86,7 +101,7 @@ const WmPopover = (Props) => {
86
101
  }
87
102
  handleLoad(__spreadValues({ isOpen }, props));
88
103
  }, [isOpen]);
89
- const calculatePlacement = () => {
104
+ const calculatePlacement = useCallback(() => {
90
105
  if (!anchorRef.current) return;
91
106
  const rect = anchorRef.current.getBoundingClientRect();
92
107
  const viewHeight = window.innerHeight;
@@ -100,7 +115,7 @@ const WmPopover = (Props) => {
100
115
  else if (props.popoverplacement === "right" && viewWidth - rect.right < width)
101
116
  setPlacement("left");
102
117
  else setPlacement(props.popoverplacement || "bottom");
103
- };
118
+ }, [props.popoverplacement, props.popoverheight, props.popoverwidth]);
104
119
  useLayoutEffect(() => {
105
120
  var _a2, _b2;
106
121
  if (!isOpen) return;
@@ -197,7 +212,7 @@ const WmPopover = (Props) => {
197
212
  }), {
198
213
  marginLeft: "-4px"
199
214
  });
200
- }, [placement, props.popoverplacement, calculatePlacement]);
215
+ }, [placement]);
201
216
  const popoverHeight = ((_a = props == null ? void 0 : props.popoverheight) == null ? void 0 : _a.includes("px")) ? props == null ? void 0 : props.popoverheight : `${props == null ? void 0 : props.popoverheight}px`;
202
217
  const popoverWidth = ((_b = props == null ? void 0 : props.popoverwidth) == null ? void 0 : _b.includes("px")) ? props == null ? void 0 : props.popoverwidth : `${props == null ? void 0 : props.popoverwidth}px`;
203
218
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -240,7 +255,8 @@ const WmPopover = (Props) => {
240
255
  encodeurl: props.encodeurl,
241
256
  shortcutkey: props.shortcutkey,
242
257
  name: props.name
243
- }
258
+ },
259
+ props.name
244
260
  )
245
261
  })
246
262
  ),
@@ -38,7 +38,7 @@ import React from "react";
38
38
  import { removeInvalidAttributes } from "../../utils/attr";
39
39
  import { PageLayoutContext } from "./page-context";
40
40
  import { getCurrentPath } from "../../core/util/utils";
41
- const getDefaultClass = (pageName) => clsx("app-page", pageName ? `app-page-${pageName.toLowerCase()}` : "", "container");
41
+ const getDefaultClass = (pageName) => clsx("app-page", "container");
42
42
  function WmPage(props) {
43
43
  const pathname = getCurrentPath();
44
44
  const pageName = pathname.split("/").pop();
@@ -1,22 +1,46 @@
1
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));
2
21
  import { jsx } from "react/jsx-runtime";
3
22
  import clsx from "clsx";
23
+ import { useAppState } from "../../../context/WidgetProvider";
24
+ import { getCurrentPath } from "../../../core/util/utils";
4
25
  const DEFAULT_CLASS = "app-page-content app-content-column";
5
26
  function WmPageContent(props) {
6
- const { className, columnwidth, styles, layoutClassName } = props;
7
- return /* @__PURE__ */ jsx(
27
+ const { className, columnwidth, styles, layoutClassName, direction } = props;
28
+ const appState = useAppState();
29
+ const pageName = ((appState == null ? void 0 : appState.componentName) || (appState == null ? void 0 : appState.name) || getCurrentPath().split("/").pop() || "").toLowerCase();
30
+ return /* @__PURE__ */ jsx("div", { className: "app-content-column-wrapper", children: /* @__PURE__ */ jsx("div", { className: clsx(pageName && `app-page-${pageName}`), style: { display: "inline" }, children: /* @__PURE__ */ jsx(
8
31
  "div",
9
- {
32
+ __spreadProps(__spreadValues({
10
33
  style: styles,
11
34
  className: clsx(
12
35
  DEFAULT_CLASS,
13
36
  className,
14
37
  `col-sm-${columnwidth} col-md-${columnwidth}`,
15
38
  layoutClassName
16
- ),
39
+ )
40
+ }, direction ? { direction } : {}), {
17
41
  children: props.children
18
- }
19
- );
42
+ })
43
+ ) }) });
20
44
  }
21
45
  WmPageContent.displayName = "WmPageContent";
22
46
  var page_content_default = WmPageContent;
@@ -9,6 +9,7 @@ export interface PageContentProps {
9
9
  * Utility layout classes from Studio Auto Layout (merged on the page-content root).
10
10
  */
11
11
  layoutClassName?: string;
12
+ direction?: string;
12
13
  }
13
14
  /**
14
15
  * Combined props for the WmPageContent component, including base WaveMaker props.
@@ -19,6 +19,7 @@ var __spreadValues = (a, b) => {
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  import { jsx } from "react/jsx-runtime";
21
21
  import React, { memo, useCallback } from "react";
22
+ import clsx from "clsx";
22
23
  import Container from "@mui/material/Container";
23
24
  import appstore from "../../../core/appstore";
24
25
  import isEqual from "lodash-es/isEqual";
@@ -69,7 +70,7 @@ const CodegenPartialContainer = memo((props) => {
69
70
  const partial = partials.find((p) => p.name === content);
70
71
  return partial ? React.createElement(partial.component, __spreadProps(__spreadValues({}, params), { onLoad: handleOnLoad })) : null;
71
72
  };
72
- return /* @__PURE__ */ jsx(Container, { className: "partial-container", children: contentToRender() });
73
+ return /* @__PURE__ */ jsx("div", { className: clsx(content && `app-partial-${content.toLowerCase()}`), children: /* @__PURE__ */ jsx(Container, { className: "partial-container", style: { height: "inherit" }, children: contentToRender() }) });
73
74
  }, arePropsEqual);
74
75
  CodegenPartialContainer.displayName = "WmPartialContainer";
75
76
  const WmPartialContainer = memo((props) => {
@@ -31,6 +31,7 @@ var __objRest = (source, exclude) => {
31
31
  };
32
32
  import { jsx } from "react/jsx-runtime";
33
33
  import { useEffect, useRef } from "react";
34
+ import clsx from "clsx";
34
35
  import { removeInvalidAttributes } from "../../utils/attr";
35
36
  const WmPrefab = (props) => {
36
37
  const _a = props, {
@@ -69,14 +70,14 @@ const WmPrefab = (props) => {
69
70
  }
70
71
  };
71
72
  }, [onLoad, onDestroy]);
72
- return /* @__PURE__ */ jsx(
73
+ return /* @__PURE__ */ jsx("div", { className: clsx(props.prefabname && `app-prefab-${props.prefabname.toLowerCase()}`), children: /* @__PURE__ */ jsx(
73
74
  "div",
74
75
  __spreadProps(__spreadValues({}, removeInvalidAttributes(rest, ["hidden"])), {
75
76
  style: __spreadValues(__spreadValues(__spreadValues({}, styles), width !== void 0 && { width: parseFloat(width) }), height !== void 0 && { height: parseFloat(height) }),
76
77
  ref,
77
78
  children
78
79
  })
79
- );
80
+ ) });
80
81
  };
81
82
  var prefab_default = WmPrefab;
82
83
  export {
@@ -13,6 +13,7 @@ interface PrefabProps {
13
13
  width?: number | string;
14
14
  height?: string;
15
15
  styles?: React.CSSProperties;
16
+ prefabname?: string;
16
17
  }
17
18
  export type WmPrefabProps = Prettify<PrefabProps & BaseProps>;
18
19
  export {};
@@ -0,0 +1,8 @@
1
+ import { BaseProps } from "@wavemaker-ai/react-runtime/higherOrder/props";
2
+ type WmxRendererProps = {
3
+ componentname: string;
4
+ field?: boolean;
5
+ };
6
+ type WmxRendererExtendedProps = WmxRendererProps & BaseProps;
7
+ declare const WmxRenderer: (props: WmxRendererExtendedProps) => import("react/jsx-runtime").JSX.Element;
8
+ export default WmxRenderer;
@@ -0,0 +1,57 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ var __objRest = (source, exclude) => {
18
+ var target = {};
19
+ for (var prop in source)
20
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
21
+ target[prop] = source[prop];
22
+ if (source != null && __getOwnPropSymbols)
23
+ for (var prop of __getOwnPropSymbols(source)) {
24
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
25
+ target[prop] = source[prop];
26
+ }
27
+ return target;
28
+ };
29
+ import { jsx } from "react/jsx-runtime";
30
+ import { useMemo } from "react";
31
+ import { getWmxModule } from "../../utils/wmx.utils";
32
+ import withFormController from "../data/form/form-controller/withFormController";
33
+ import withBaseWrapper from "../../higherOrder/withBaseWrapper";
34
+ const WmxRenderer = (props) => {
35
+ var _b;
36
+ const _a = props, { componentname, field } = _a, restProps = __objRest(_a, ["componentname", "field"]);
37
+ const wmxModule = getWmxModule();
38
+ const RawComponent = (_b = wmxModule == null ? void 0 : wmxModule[`Wmx${componentname}`]) != null ? _b : null;
39
+ const FormFieldComponent = useMemo(
40
+ () => RawComponent ? withBaseWrapper(withFormController(RawComponent)) : null,
41
+ [RawComponent]
42
+ );
43
+ const BaseWrappedComponent = useMemo(
44
+ () => RawComponent ? withBaseWrapper(RawComponent) : null,
45
+ [RawComponent]
46
+ );
47
+ if (!wmxModule || !RawComponent || !FormFieldComponent || !BaseWrappedComponent) return null;
48
+ const isFormField = String(field) === "true";
49
+ if (isFormField) {
50
+ return /* @__PURE__ */ jsx(FormFieldComponent, __spreadValues({ componentname }, restProps));
51
+ }
52
+ return /* @__PURE__ */ jsx(BaseWrappedComponent, __spreadValues({ componentname }, restProps));
53
+ };
54
+ var WmxRenderer_default = WmxRenderer;
55
+ export {
56
+ WmxRenderer_default as default
57
+ };
@@ -87,10 +87,11 @@ const WidgetProvider = ({
87
87
  Object.keys(value.Widgets).forEach((widgetName) => {
88
88
  var _a2;
89
89
  const currentWidget = newContext.Widgets[widgetName];
90
- const incomingWidget = value.Widgets[widgetName];
90
+ const incomingWidget = proxy.Widgets[widgetName] || value.Widgets[widgetName];
91
91
  if (currentWidget == null ? void 0 : currentWidget.App) {
92
92
  registerMethod(newContext, (_a2 = pageContextRef.current) == null ? void 0 : _a2.Widgets[widgetName], widgetName);
93
93
  } else {
94
+ if (incomingWidget.__isProxy) return;
94
95
  if (!isPage && (incomingWidget == null ? void 0 : incomingWidget.isLayout)) return;
95
96
  const registry = value == null ? void 0 : value.overriddenPropsRegistry;
96
97
  const widgetProxy = createWidgetProxy(
package/core/appstore.js CHANGED
@@ -43,7 +43,7 @@ const appstore = {
43
43
  };
44
44
  if (!appstore.I18nService.get()) {
45
45
  appstore.I18nService.set({
46
- selectedLocale: getSessionLocaleSafe() || "en",
46
+ selectedLocale: "en",
47
47
  messages: {},
48
48
  getSelectedLocale: function() {
49
49
  try {
@@ -2,6 +2,7 @@ import { PageContextState, ProxyTarget } from "@wavemaker-ai/react-runtime/types
2
2
  import { OverriddenPropsRegistry } from "@wavemaker-ai/react-runtime/core/script-registry";
3
3
  import BaseAppProps from "../higherOrder/BaseAppProps";
4
4
  import { FormFieldProps } from "../components/data/form/form-field/props";
5
+ export declare function clearPageWidgetProxyCache(widgetsProxy: object | null | undefined): void;
5
6
  export declare const createWidgetProxy: (widget: any, widgetName: string, setPageContext: any, overriddenPropsRegistry?: OverriddenPropsRegistry) => any;
6
7
  export declare const createPageProxy: (target: ProxyTarget, setPageContext: React.Dispatch<React.SetStateAction<PageContextState>>, overriddenPropsRegistry?: OverriddenPropsRegistry) => ProxyTarget;
7
8
  export declare const createStateProxy: (obj: PageContextState | BaseAppProps, path: string[], setPageContext: React.Dispatch<React.SetStateAction<PageContextState>> | React.Dispatch<React.SetStateAction<BaseAppProps>>, overriddenPropsRegistry?: OverriddenPropsRegistry) => ProxyTarget;
@@ -28,6 +28,11 @@ import LiveVariable from "../variables/live-variable";
28
28
  import { ModelVariable } from "../variables/model-variable";
29
29
  import CrudVariable from "../variables/crud-variable";
30
30
  const proxyMap = /* @__PURE__ */ new WeakMap();
31
+ const pageWidgetProxyCaches = /* @__PURE__ */ new WeakMap();
32
+ function clearPageWidgetProxyCache(widgetsProxy) {
33
+ var _a;
34
+ (_a = pageWidgetProxyCaches.get(widgetsProxy)) == null ? void 0 : _a.clear();
35
+ }
31
36
  let pendingWidgetContextUpdates = null;
32
37
  let batchedSetPageContextForWidgets = null;
33
38
  function flushPendingWidgetContextUpdates() {
@@ -201,6 +206,7 @@ const createWidgetProxy = (widget, widgetName, setPageContext, overriddenPropsRe
201
206
  if (widget == null) {
202
207
  return widget;
203
208
  }
209
+ widget.__isProxy = true;
204
210
  const proxy = new Proxy(widget, {
205
211
  set(target, prop, value, receiver) {
206
212
  if (typeof prop === "symbol" || prop === "prototype") {
@@ -231,6 +237,7 @@ const createWidgetProxy = (widget, widgetName, setPageContext, overriddenPropsRe
231
237
  return this;
232
238
  };
233
239
  }
240
+ if (prop === "__isProxy") return true;
234
241
  if (prop === "$element") {
235
242
  const rawElement = Reflect.get(target, prop, receiver);
236
243
  if (rawElement) {
@@ -310,7 +317,7 @@ const createWidgetProxy = (widget, widgetName, setPageContext, overriddenPropsRe
310
317
  };
311
318
  const createPageProxy = (target, setPageContext, overriddenPropsRegistry) => {
312
319
  const widgetProxies = /* @__PURE__ */ new Map();
313
- return new Proxy(target, {
320
+ const widgetsProxy = new Proxy(target, {
314
321
  get(widgetsTarget, widgetName) {
315
322
  if (widgetName === void 0 || widgetName === "undefined") {
316
323
  return void 0;
@@ -378,6 +385,39 @@ const createPageProxy = (target, setPageContext, overriddenPropsRegistry) => {
378
385
  return true;
379
386
  }
380
387
  });
388
+ pageWidgetProxyCaches.set(widgetsProxy, widgetProxies);
389
+ return widgetsProxy;
390
+ };
391
+ const wrapVariableProxy = (variable, path, varName, setPageContext) => {
392
+ if (proxyMap.has(variable)) {
393
+ return variable;
394
+ }
395
+ const varProxy = new Proxy(variable, {
396
+ set(target, prop, value, receiver) {
397
+ if (typeof prop === "symbol") {
398
+ return Reflect.set(target, prop, value, receiver);
399
+ }
400
+ const prevVal = Reflect.get(target, prop, receiver);
401
+ const result = Reflect.set(target, prop, value, receiver);
402
+ if (prevVal !== value) {
403
+ setPageContext((prev) => {
404
+ const newState = __spreadValues({}, prev);
405
+ let current = newState;
406
+ for (let i = 0; i < path.length; i++) {
407
+ const key = path[i];
408
+ const existing = current[key];
409
+ current[key] = existing ? __spreadValues({}, existing) : {};
410
+ current = current[key];
411
+ }
412
+ current[varName] = target;
413
+ return newState;
414
+ });
415
+ }
416
+ return result;
417
+ }
418
+ });
419
+ proxyMap.set(varProxy, true);
420
+ return varProxy;
381
421
  };
382
422
  const createStateProxy = (obj, path = [], setPageContext, overriddenPropsRegistry) => {
383
423
  const nestedProxies = /* @__PURE__ */ new Map();
@@ -432,7 +472,17 @@ const createStateProxy = (obj, path = [], setPageContext, overriddenPropsRegistr
432
472
  return value;
433
473
  }
434
474
  if (value instanceof ServiceVariable || value instanceof LiveVariable || value instanceof ModelVariable || value instanceof CrudVariable) {
435
- return value;
475
+ if (nestedProxies.has(prop)) {
476
+ return nestedProxies.get(prop);
477
+ }
478
+ const varProxy = wrapVariableProxy(
479
+ value,
480
+ path,
481
+ prop,
482
+ setPageContext
483
+ );
484
+ nestedProxies.set(prop, varProxy);
485
+ return varProxy;
436
486
  }
437
487
  if (isDOMElement(value)) {
438
488
  return value;
@@ -525,6 +575,7 @@ const createFormFieldProxy = (formField, setState, overriddenItemsRef, formProxy
525
575
  return fieldProxy;
526
576
  };
527
577
  export {
578
+ clearPageWidgetProxyCache,
528
579
  createFormFieldProxy,
529
580
  createPageProxy,
530
581
  createStateProxy,
@@ -38,8 +38,6 @@ 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;
43
41
  export declare function reload(): void;
44
42
  export declare const toNumber: (value: any) => number;
45
43
  export declare const _get: {
@@ -1,4 +1,5 @@
1
1
  import get from "lodash-es/get";
2
+ import has from "lodash-es/has";
2
3
  import { store } from "../../store";
3
4
  import { isArray, isObject, isString } from "lodash-es";
4
5
  const VALIDATOR = {
@@ -89,36 +90,9 @@ const getTimezone = () => {
89
90
  return timezone || "UTC";
90
91
  };
91
92
  const formatMessage = (fragment, expression) => {
92
- return get(fragment, `appLocale.${expression}`, expression);
93
+ const path = `appLocale.${expression}`;
94
+ return has(fragment, path) ? get(fragment, path) : void 0;
93
95
  };
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
- }
122
96
  function reload() {
123
97
  window.location.reload();
124
98
  }
@@ -214,7 +188,6 @@ export {
214
188
  reload,
215
189
  replace,
216
190
  setSessionStorageItem,
217
- syncLocaleMessages,
218
191
  toBoolean,
219
192
  toNumber
220
193
  };
@@ -35,7 +35,10 @@ import { redirectToLogin } from "../store/slices/authSlice";
35
35
  import {
36
36
  VariableEvents
37
37
  } from "../types";
38
- import { createStateProxy } from "../core/proxy-service";
38
+ import {
39
+ clearPageWidgetProxyCache,
40
+ createStateProxy
41
+ } from "../core/proxy-service";
39
42
  import {
40
43
  accordionExpansionHandler,
41
44
  mergeVariablesAndActions,
@@ -49,7 +52,6 @@ import {
49
52
  } from "../core/script-registry";
50
53
  import formatters from "../core/formatters";
51
54
  import { useAppProxy } from "../context/AppContext";
52
- import { syncLocaleMessages } from "../core/util";
53
55
  import {
54
56
  computeMergedPageParams,
55
57
  computePartialParamKey,
@@ -64,7 +66,7 @@ import { viewportService } from "../store/viewport.service";
64
66
  import { formatMessage } from "../core/util";
65
67
  const withPageContext = (WrappedComponent, addPageScript, getVariables, componentInfo, prefabInfo) => {
66
68
  const PageContextComponent = (props) => {
67
- var _a, _b, _c, _d, _e, _f;
69
+ var _a, _b, _c;
68
70
  const dispatch = useAppDispatch();
69
71
  const { show, hide } = (_a = useAppSpinner()) != null ? _a : {};
70
72
  const i18n = useAppSelector((state) => state.i18n);
@@ -115,6 +117,7 @@ const withPageContext = (WrappedComponent, addPageScript, getVariables, componen
115
117
  const overriddenPropsRegistryRef = useRef(null);
116
118
  const onStartupCompletedRef = useRef(false);
117
119
  const lastSyncedLocaleRevisionRef = useRef(-1);
120
+ const appliedLocaleRef = useRef(void 0);
118
121
  const [isPageReady, setIsPageReady] = useState(false);
119
122
  const pageReady = useCallback(() => {
120
123
  setIsPageReady(true);
@@ -153,7 +156,6 @@ const withPageContext = (WrappedComponent, addPageScript, getVariables, componen
153
156
  layoutReady,
154
157
  activePageName: componentInfo == null ? void 0 : componentInfo.componentName
155
158
  }));
156
- const initialAppConfig = useMemo(() => appContext, [appContext]);
157
159
  useActivePageReactivity({
158
160
  componentType: componentInfo == null ? void 0 : componentInfo.componentType,
159
161
  appProxy,
@@ -308,9 +310,7 @@ const withPageContext = (WrappedComponent, addPageScript, getVariables, componen
308
310
  if (!appProxy.appLocale) {
309
311
  appProxy.appLocale = {};
310
312
  }
311
- if (!syncLocaleMessages(appProxy.appLocale, mergedAppLocale)) {
312
- appProxy.appLocale = __spreadValues({}, mergedAppLocale);
313
- }
313
+ appProxy.appLocale = __spreadValues({}, mergedAppLocale);
314
314
  const localeFormats = {
315
315
  date: i18n.dateFormat,
316
316
  time: i18n.timeFormat,
@@ -321,7 +321,7 @@ const withPageContext = (WrappedComponent, addPageScript, getVariables, componen
321
321
  pageProxy.Variables = Variables;
322
322
  pageProxy.Actions = Actions;
323
323
  pageProxy.pageReady = pageReady;
324
- pageProxy.App = __spreadValues(__spreadValues({}, appProxy), initialAppConfig);
324
+ pageProxy.App = appProxy != null ? appProxy : appContext;
325
325
  pageProxy.selectedLocale = i18n.selectedLocale || "en";
326
326
  pageProxy.overriddenPropsRegistry = overriddenPropsRegistryRef.current;
327
327
  setupVariableSubscriptions(pageVariables.Variables);
@@ -331,6 +331,7 @@ const withPageContext = (WrappedComponent, addPageScript, getVariables, componen
331
331
  appProxy.updateActivePage(pageName2);
332
332
  appProxy.activePage = pageProxy;
333
333
  appProxy.activePageName = pageName2;
334
+ clearPageWidgetProxyCache(appProxy.Widgets);
334
335
  Object.setPrototypeOf(appProxy.Widgets, pageProxy.Widgets);
335
336
  } else if ((componentInfo == null ? void 0 : componentInfo.componentName) === "Common" && (componentInfo == null ? void 0 : componentInfo.componentType) === "PARTIAL" && appProxy) {
336
337
  Object.keys(pageProxy.Widgets).forEach((key) => {
@@ -567,63 +568,44 @@ const withPageContext = (WrappedComponent, addPageScript, getVariables, componen
567
568
  async function executeStartup() {
568
569
  await (appContext == null ? void 0 : appContext.executeStartAppOperations());
569
570
  }
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
- }
602
- }
603
571
  useEffect(() => {
604
- const newAppLocale = merge({}, i18n.appLocale || {}, (prefabInfo == null ? void 0 : prefabInfo.appLocale) || {});
605
- if (!isEqual(pageContext.appLocale, newAppLocale)) {
606
- setPageContext((prev) => __spreadProps(__spreadValues({}, prev), {
607
- appLocale: newAppLocale
608
- }));
572
+ const prevLocale = appliedLocaleRef.current;
573
+ appliedLocaleRef.current = i18n.selectedLocale;
574
+ const isLocaleSwitch = prevLocale !== void 0 && prevLocale !== i18n.selectedLocale;
575
+ if (isLocaleSwitch && pageProxyRef.current) {
576
+ pageProxyRef.current.Widgets = {};
609
577
  }
610
- }, [i18n.appLocale]);
611
- useEffect(() => {
578
+ const newAppLocale = merge({}, i18n.appLocale || {}, (prefabInfo == null ? void 0 : prefabInfo.appLocale) || {});
612
579
  const localeFormats = {
613
580
  date: i18n.dateFormat,
614
581
  time: i18n.timeFormat,
615
582
  currency: i18n.currencyCode
616
583
  };
617
- setPageContext((prev) => __spreadProps(__spreadValues({}, prev), {
618
- localeFormats
619
- }));
620
584
  if (pageProxyRef.current) {
585
+ const appLocaleChanged = !isEqual(pageProxyRef.current.appLocale, newAppLocale);
586
+ if (appLocaleChanged) {
587
+ appProxy.appLocale = newAppLocale;
588
+ pageProxyRef.current.appLocale = newAppLocale;
589
+ pageProxyRef.current.App.appLocale = newAppLocale;
590
+ }
621
591
  pageProxyRef.current.localeFormats = localeFormats;
622
592
  if (pageProxyRef.current.App) {
623
593
  pageProxyRef.current.App.localeFormats = localeFormats;
624
594
  }
625
595
  }
626
- }, [i18n.dateFormat, i18n.timeFormat, i18n.currencyCode]);
596
+ setPageContext((prev) => {
597
+ const appLocaleChanged = !isEqual(prev.appLocale, newAppLocale);
598
+ if (prev.selectedLocale === i18n.selectedLocale && !appLocaleChanged) {
599
+ return __spreadProps(__spreadValues({}, prev), { localeFormats });
600
+ }
601
+ return __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, prev), {
602
+ selectedLocale: i18n.selectedLocale
603
+ }), isLocaleSwitch && { Widgets: {} }), {
604
+ appLocale: newAppLocale,
605
+ localeFormats
606
+ });
607
+ });
608
+ }, [i18n.selectedLocale, i18n.appLocale, i18n.dateFormat, i18n.timeFormat, i18n.currencyCode]);
627
609
  const pageName = (appProxy == null ? void 0 : appProxy.activePageName) || "";
628
610
  useEffect(() => {
629
611
  if ((componentInfo == null ? void 0 : componentInfo.componentType) === "PARTIAL" && pageName) {
@@ -681,14 +663,14 @@ const withPageContext = (WrappedComponent, addPageScript, getVariables, componen
681
663
  ((_a2 = appVariables[value]) == null ? void 0 : _a2.invokeOnParamChange) && ((_b2 = appVariables[value]) == null ? void 0 : _b2.invokeOnParamChange());
682
664
  });
683
665
  }
684
- if (((_e = componentInfo == null ? void 0 : componentInfo.autoUpdateVariables) == null ? void 0 : _e.length) && onStartupCompletedRef.current) {
666
+ if (((_c = componentInfo == null ? void 0 : componentInfo.autoUpdateVariables) == null ? void 0 : _c.length) && onStartupCompletedRef.current) {
685
667
  const pageVariables = pageContext.Variables;
686
668
  componentInfo.autoUpdateVariables.forEach((value) => {
687
669
  var _a2, _b2;
688
670
  (_b2 = (_a2 = pageVariables[value]) == null ? void 0 : _a2.invokeOnParamChange) == null ? void 0 : _b2.call(_a2);
689
671
  });
690
672
  }
691
- return /* @__PURE__ */ jsx(WidgetProvider, { value: { value: pageContext, proxy: pageProxyRef.current }, children: /* @__PURE__ */ jsx(WrappedComponent, __spreadValues({}, props), `locale-${(_f = i18n.localeRevision) != null ? _f : 0}`) });
673
+ return /* @__PURE__ */ jsx(WidgetProvider, { value: { value: pageContext, proxy: pageProxyRef.current }, children: /* @__PURE__ */ jsx(WrappedComponent, __spreadValues({}, props)) });
692
674
  };
693
675
  PageContextComponent.displayName = `WithPageContext(${WrappedComponent.displayName || WrappedComponent.name || "Component"})`;
694
676
  return PageContextComponent;