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

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 (67) hide show
  1. package/components/basic/anchor/index.js +3 -0
  2. package/components/container/index.js +6 -1
  3. package/components/container/layout-grid/grid-row/index.js +1 -1
  4. package/components/data/form/base-form/hooks/useFormSubmission.d.ts +1 -1
  5. package/components/data/form/base-form/hooks/useFormSubmission.js +3 -1
  6. package/components/data/form/base-form/index.js +11 -14
  7. package/components/data/form/base-form/props.d.ts +3 -0
  8. package/components/data/form/form-controller/withFormController.js +19 -2
  9. package/components/data/form/form-field/base-field.js +8 -5
  10. package/components/data/form/form-field/index.js +11 -7
  11. package/components/data/form/form-field/props.d.ts +1 -0
  12. package/components/data/list/components/ListItemWithTemplate.js +5 -2
  13. package/components/data/list/hooks/useListEffects.js +1 -1
  14. package/components/data/list/index.js +11 -3
  15. package/components/data/list/utils/constants.d.ts +0 -1
  16. package/components/data/list/utils/constants.js +0 -2
  17. package/components/data/table/components/RowCells.js +18 -4
  18. package/components/data/table/components/TableBody.js +5 -3
  19. package/components/data/table/components/TableHeader.js +9 -7
  20. package/components/data/table/components/TablePanelHeading.js +1 -1
  21. package/components/data/table/hooks/useDynamicColumns.js +1 -1
  22. package/components/data/table/hooks/useRowExpansion.js +41 -31
  23. package/components/data/table/hooks/useRowHandlers.js +0 -1
  24. package/components/data/table/hooks/useServerSideSorting.js +0 -1
  25. package/components/data/table/hooks/useTableColumns.js +16 -8
  26. package/components/data/table/hooks/useTableData.js +0 -1
  27. package/components/data/table/hooks/useTableEdit.js +0 -1
  28. package/components/data/table/index.js +47 -18
  29. package/components/data/table/live-table/index.js +0 -1
  30. package/components/data/table/props.d.ts +4 -0
  31. package/components/data/table/utils/buildSelectionColumns.js +0 -2
  32. package/components/data/table/utils/columnBuilder.d.ts +16 -2
  33. package/components/data/table/utils/columnBuilder.js +13 -8
  34. package/components/data/table/utils/columnWidthDistribution.js +10 -0
  35. package/components/data/table/utils/constants.d.ts +0 -4
  36. package/components/data/table/utils/constants.js +0 -7
  37. package/components/data/table/utils/dynamic-columns.d.ts +1 -1
  38. package/components/data/table/utils/dynamic-columns.js +3 -8
  39. package/components/data/table/utils/expansionColumn.d.ts +23 -0
  40. package/components/data/table/utils/expansionColumn.js +56 -0
  41. package/components/data/table/utils/index.d.ts +14 -2
  42. package/components/data/table/utils/index.js +45 -19
  43. package/components/dialogs/dialog/index.js +3 -2
  44. package/components/input/default/radioset/index.js +2 -1
  45. package/components/input/select/index.js +1 -2
  46. package/components/input/textarea/index.js +1 -1
  47. package/components/navigation/popover/index.js +15 -7
  48. package/components/page/index.js +1 -1
  49. package/components/page/page-content/index.js +6 -2
  50. package/components/page/partial-container/index.js +2 -1
  51. package/components/prefab/index.js +3 -2
  52. package/components/prefab/props.d.ts +1 -0
  53. package/context/WidgetProvider.js +2 -1
  54. package/core/proxy-service.d.ts +1 -0
  55. package/core/proxy-service.js +53 -2
  56. package/core/util/index.js +3 -1
  57. package/higherOrder/BasePage.js +25 -4
  58. package/higherOrder/withBaseWrapper.js +9 -7
  59. package/package-lock.json +127 -138
  60. package/package.json +3 -3
  61. package/runtime-dynamic/components/partial-content.js +3 -1
  62. package/runtime-dynamic/factories/dynamic-component.js +26 -3
  63. package/runtime-dynamic/services/css-scoping.d.ts +2 -0
  64. package/runtime-dynamic/services/css-scoping.js +39 -20
  65. package/utils/custom-expression/parser.js +11 -8
  66. package/utils/transformedDataset-utils.d.ts +3 -3
  67. package/utils/transformedDataset-utils.js +1 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wavemaker-ai/react-runtime",
3
- "version": "1.0.0-rc.324",
3
+ "version": "1.0.0-rc.326",
4
4
  "description": "React runtime package for Wavemaker",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -58,8 +58,8 @@
58
58
  "@mui/x-date-pickers": "8.5.3",
59
59
  "@reduxjs/toolkit": "2.9.1",
60
60
  "@tanstack/react-table": "8.21.3",
61
- "@wavemaker-ai/react-codegen": "1.0.0-rc.324",
62
- "@wavemaker-ai/variables": "1.0.0-rc.324",
61
+ "@wavemaker-ai/react-codegen": "1.0.0-rc.326",
62
+ "@wavemaker-ai/variables": "1.0.0-rc.326",
63
63
  "@wavemaker/nvd3": "1.8.16",
64
64
  "axios": "1.15.1",
65
65
  "d3": "7.8.5",
@@ -19,6 +19,8 @@ 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 { memo, useCallback } from "react";
22
+ import clsx from "clsx";
23
+ import Container from "@mui/material/Container";
22
24
  import isEqual from "lodash-es/isEqual";
23
25
  import { registerComponent } from "../registry/store";
24
26
  import { ComponentType } from "../services/fragment-url";
@@ -38,7 +40,7 @@ const WmPartialContent = memo(
38
40
  const mergedProps = __spreadProps(__spreadValues({}, props), {
39
41
  onLoad: handleOnLoad
40
42
  });
41
- return /* @__PURE__ */ jsx(ComponentErrorBoundary, { scope: "partial", componentName: props.content, children: Component && /* @__PURE__ */ jsx(Component, __spreadValues({}, mergedProps)) });
43
+ return /* @__PURE__ */ jsx("div", { className: clsx(props.content && `app-partial-${props.content}`), children: /* @__PURE__ */ jsx(Container, { className: "partial-container", children: /* @__PURE__ */ jsx(ComponentErrorBoundary, { scope: "partial", componentName: props.content, children: Component && /* @__PURE__ */ jsx(Component, __spreadValues({}, mergedProps)) }) }) });
42
44
  },
43
45
  (prevProps, nextProps) => {
44
46
  const staticKeys = [
@@ -19,10 +19,15 @@ 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, { useEffect, useReducer, useRef } from "react";
22
+ import WmPrefab from "../../components/prefab";
22
23
  import { useAppState } from "../../context/WidgetProvider";
23
24
  import { useAppContext } from "../../context/AppContext";
24
25
  import { renderTranspiledMarkup } from "../services/markup-transpiler";
25
- import { scopeComponentStyles, removeComponentStyles } from "../services/css-scoping";
26
+ import {
27
+ scopeComponentStyles,
28
+ removeComponentStyles,
29
+ resolvePrefabScopeName
30
+ } from "../services/css-scoping";
26
31
  function useCrossScopeDataRefresh(appContext, componentType) {
27
32
  const [, forceRender] = useReducer((count) => count + 1, 0);
28
33
  useEffect(() => {
@@ -68,7 +73,7 @@ function createDynamicComponent({
68
73
  transpiled,
69
74
  styles
70
75
  }) {
71
- const InnerComponent = () => {
76
+ const InnerComponent = (props) => {
72
77
  const appState = useAppState();
73
78
  usePageEvents(appState, componentType);
74
79
  const appContext = useAppContext();
@@ -95,7 +100,25 @@ function createDynamicComponent({
95
100
  }, []);
96
101
  if (!transpiled) return null;
97
102
  const renderState = notification ? __spreadProps(__spreadValues({}, appState), { notification }) : appState;
98
- return /* @__PURE__ */ jsx(React.Fragment, { children: renderTranspiledMarkup(transpiled, renderState) });
103
+ const markup = renderTranspiledMarkup(transpiled, renderState);
104
+ if (componentType === "prefab") {
105
+ return /* @__PURE__ */ jsx(
106
+ WmPrefab,
107
+ {
108
+ prefabname: resolvePrefabScopeName(componentName, props.prefabname),
109
+ onLoad: props.onLoad,
110
+ onDestroy: props.onDestroy,
111
+ onRender: props.onRender,
112
+ styles: props.styles,
113
+ width: props.width,
114
+ height: props.height,
115
+ listener: props.listener,
116
+ show: props.show,
117
+ children: markup
118
+ }
119
+ );
120
+ }
121
+ return /* @__PURE__ */ jsx(React.Fragment, { children: markup });
99
122
  };
100
123
  return InnerComponent;
101
124
  }
@@ -1,2 +1,4 @@
1
+ /** Resolves the prefab name used for CSS scope classes and `app-prefab-{name}` wrappers. */
2
+ export declare function resolvePrefabScopeName(componentName: string, prefabname?: string): string;
1
3
  export declare function scopeComponentStyles(componentName: string, componentType: string, styles: string): string;
2
4
  export declare function removeComponentStyles(componentName: string, componentType: string): void;
@@ -1,32 +1,50 @@
1
+ import { fixURLPathAndScope } from "@wavemaker-ai/react-codegen/transpiler";
2
+ import { store } from "../../store";
3
+ import { getProjectConfig } from "../app-initializer";
4
+ import { isPrefabSelfPreview } from "./fragment-url";
5
+ function resolvePrefabScopeName(componentName, prefabname) {
6
+ var _a, _b;
7
+ if (prefabname) {
8
+ return prefabname;
9
+ }
10
+ if (isPrefabSelfPreview(componentName)) {
11
+ const appProps = (_b = (_a = store.getState().info) == null ? void 0 : _a.appConfig) == null ? void 0 : _b.appProperties;
12
+ return (appProps == null ? void 0 : appProps.displayName) || (appProps == null ? void 0 : appProps.name) || componentName;
13
+ }
14
+ return componentName;
15
+ }
1
16
  const scopedCssCache = /* @__PURE__ */ new Map();
2
- function isWmAppScopedInStyles(styles) {
3
- return /\.wm-app(?![\w-])/.test(styles);
17
+ function getPreviewCssBasePath() {
18
+ var _a;
19
+ const deployUrl = ((_a = getProjectConfig().deployUrl) == null ? void 0 : _a.replace(/\/+$/, "")) || "";
20
+ if (!deployUrl || deployUrl === ".") {
21
+ return void 0;
22
+ }
23
+ return deployUrl;
4
24
  }
5
- function prefixSelectors(css, scope) {
6
- return css.replace(/([^{}@]+)\{/g, (match, selectorsStr) => {
7
- if (selectorsStr.trim().startsWith("@")) return match;
8
- const selectors = selectorsStr.split(",");
9
- const prefixed = selectors.map((selector) => {
10
- const trimmed = selector.trim();
11
- if (!trimmed) return selector;
12
- if (trimmed.startsWith(":root") || trimmed.startsWith("html") || trimmed.startsWith("body")) {
13
- return selector;
14
- }
15
- return `${scope} ${trimmed}`;
16
- });
17
- return `${prefixed.join(", ")} {`;
18
- });
25
+ function getCssScopeOptions(componentType, componentName) {
26
+ const normalizedType = componentType.toLowerCase();
27
+ if (normalizedType === "page") {
28
+ return { scopeType: "page", name: componentName };
29
+ }
30
+ if (normalizedType === "partial") {
31
+ return { scopeType: "partial", name: componentName };
32
+ }
33
+ if (normalizedType === "prefab") {
34
+ return { scopeType: "prefab", name: resolvePrefabScopeName(componentName) };
35
+ }
36
+ return void 0;
19
37
  }
20
38
  function scopeComponentStyles(componentName, componentType, styles) {
21
39
  var _a;
22
40
  if (!styles) return "";
23
- const isWmAppScoped = isWmAppScopedInStyles(styles);
24
- const scopeSelector = isWmAppScoped ? "" : `.wm-app`;
41
+ const scopeOptions = getCssScopeOptions(componentType, componentName);
42
+ const basePath = getPreviewCssBasePath();
25
43
  const scopeAttribute = `${componentType}-${componentName}`;
26
- const cacheKey = `${scopeSelector}::${styles}`;
44
+ const cacheKey = `${scopeAttribute}::${basePath != null ? basePath : ""}::${styles}`;
27
45
  let scopedCss = scopedCssCache.get(cacheKey);
28
46
  if (!scopedCss) {
29
- scopedCss = isWmAppScoped ? styles : prefixSelectors(styles, scopeSelector);
47
+ scopedCss = fixURLPathAndScope(styles, basePath, true, scopeOptions);
30
48
  scopedCssCache.set(cacheKey, scopedCss);
31
49
  }
32
50
  const styleElement = document.createElement("style");
@@ -48,5 +66,6 @@ function removeComponentStyles(componentName, componentType) {
48
66
  }
49
67
  export {
50
68
  removeComponentStyles,
69
+ resolvePrefabScopeName,
51
70
  scopeComponentStyles
52
71
  };
@@ -2,11 +2,19 @@ import React from "react";
2
2
  import { transform } from "sucrase";
3
3
  import { getComponent } from "../../runtime-dynamic/registry";
4
4
  import { formatMessage, _get, toNumber } from "../../core/util";
5
+ import { useAppState } from "../../context/WidgetProvider";
5
6
  const UTIL_SCOPE = {
6
7
  formatMessage,
7
8
  _get,
8
- toNumber
9
+ toNumber,
10
+ useAppState
9
11
  };
12
+ function wrapCustomExpressionComponentBody(jsxInner) {
13
+ return `function __render__() {
14
+ const fragment = useAppState();
15
+ return (<React.Fragment>${jsxInner.trim() || "null"}</React.Fragment>);
16
+ }`;
17
+ }
10
18
  function stripLeadingArrow(markup) {
11
19
  const trimmed = markup.trim();
12
20
  const arrow = trimmed.match(/^\([^)]*\)\s*=>\s*/);
@@ -67,7 +75,7 @@ async function parseCustomExpressionToJsx(transformedMarkup, fragment) {
67
75
  return cache.get(markup);
68
76
  }
69
77
  const jsxInner = stripLeadingArrow(markup);
70
- const jsxWrapped = `function __render__() { return (<React.Fragment>${jsxInner.trim() || "null"}</React.Fragment>); }`;
78
+ const jsxWrapped = wrapCustomExpressionComponentBody(jsxInner);
71
79
  let compiledCode;
72
80
  try {
73
81
  compiledCode = compileJsxToRenderBody(jsxWrapped);
@@ -106,7 +114,6 @@ ${jsxInner}`
106
114
  cache.set(markup, fallback);
107
115
  return fallback;
108
116
  }
109
- const stopPropagation = (e) => e.stopPropagation();
110
117
  const renderComponent = (rowData) => {
111
118
  try {
112
119
  const args = templateValues.slice();
@@ -116,11 +123,7 @@ ${jsxInner}`
116
123
  if (fragmentIdx >= 0) args[fragmentIdx] = fragment;
117
124
  if (widgetsIdx >= 0) args[widgetsIdx] = fr == null ? void 0 : fr.Widgets;
118
125
  if (variablesIdx >= 0) args[variablesIdx] = fr == null ? void 0 : fr.Variables;
119
- return React.createElement(
120
- "span",
121
- { className: "custom-expr-wrapper", onClick: stopPropagation },
122
- renderFn(...args)
123
- );
126
+ return React.createElement("span", { className: "custom-expr-wrapper" }, renderFn(...args));
124
127
  } catch (err) {
125
128
  console.error("[customExpressionParser] Render error:", err);
126
129
  return null;
@@ -14,7 +14,7 @@ export declare class DataSetItem {
14
14
  match?: string;
15
15
  dateformat?: string;
16
16
  }
17
- export declare const transformDataset: ((dataset: any, datafield: any, displayfield: any, displaylabel: any, displayexpression: any, orderby: any, groupby: any, dataPath: any, itemchildren?: any, match?: string) => DataSetItem[]) & import("lodash").MemoizedFunction;
17
+ export declare const transformDataset: (dataset: any, datafield: any, displayfield: any, displaylabel: any, displayexpression: any, orderby: any, groupby: any, dataPath: any, itemchildren?: any, match?: string) => DataSetItem[];
18
18
  /**
19
19
  * function to get the ordered dataset based on the given orderby
20
20
  */
@@ -27,10 +27,10 @@ export declare const extractDataAsArray: (data: any) => any[];
27
27
  export declare const convertDataToObject: (dataResult: any) => any;
28
28
  export declare const transformFormData: (context: any, dataSet: any, myDataField: string, displayOptions?: any, startIndex?: number, scope?: any, dataPath?: string) => Array<DataSetItem>;
29
29
  export declare const getUniqObjsByDataField: (data: Array<DataSetItem>, dataField: string, displayField: string, allowEmptyFields?: boolean) => any;
30
- export declare const setItemByCompare: (datasetItems: Array<DataSetItem>, compareWithDataObj: Object, compareByField: string) => DataSetItem | undefined;
30
+ export declare const setItemByCompare: (datasetItems: Array<DataSetItem>, compareWithDataObj: object, compareByField: string) => DataSetItem | undefined;
31
31
  export declare const datasetItems: (dataset: any, datafield: string, displayfield: string, displaylabel: string, displayexpression: string, orderby: string, groupby?: string, dataPath?: string, itemchildren?: any, match?: string) => DataSetItem[];
32
32
  export declare const groupData: (compRef: any, // In React, this would likely be component props or state
33
- data: Array<Object | DataSetItem>, groupby: string, match: string, orderby: string, dateformat?: string, innerItem?: string, AppDefaults?: any) => any[];
33
+ data: Array<object | DataSetItem>, groupby: string, match: string, orderby: string, dateformat?: string, innerItem?: string, AppDefaults?: any) => any[];
34
34
  /**
35
35
  * Utility functions for list group operations
36
36
  */
@@ -24,7 +24,6 @@ import {
24
24
  includes,
25
25
  isArray,
26
26
  isEqual,
27
- memoize,
28
27
  isNull,
29
28
  isObject,
30
29
  isString,
@@ -116,7 +115,7 @@ const resolver = (...args) => {
116
115
  return JSON.stringify(arg);
117
116
  }).join("|");
118
117
  };
119
- const transformDataset = memoize(_internalTransformDataset, resolver);
118
+ const transformDataset = _internalTransformDataset;
120
119
  const getOrderedDataset = (dataSet, orderBy, innerItem) => {
121
120
  if (!orderBy) {
122
121
  return cloneDeep(dataSet);