@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.
- package/components/basic/anchor/index.js +3 -0
- package/components/basic/icon/index.js +36 -5
- package/components/basic/iframe/index.js +18 -8
- package/components/basic/label/index.js +4 -3
- package/components/basic/search/index.d.ts +72 -3
- package/components/basic/search/index.js +75 -21
- package/components/basic/search/props.d.ts +4 -0
- package/components/common/WmAppIcon/index.js +11 -8
- package/components/common/WmAppIcon/props.d.ts +2 -0
- package/components/container/accordion/accordion-pane/index.d.ts +1 -0
- package/components/container/accordion/accordion-pane/index.js +7 -3
- package/components/container/accordion/accordion-pane/props.d.ts +1 -0
- package/components/container/index.js +18 -5
- package/components/container/layout-grid/grid-row/index.js +1 -1
- package/components/container/panel/components/panel-header/index.js +1 -3
- package/components/container/tabs/tab-pane/index.d.ts +1 -0
- package/components/container/tabs/tab-pane/index.js +2 -2
- package/components/container/tabs/tab-pane/props.d.ts +1 -0
- package/components/container/wizard/index.js +11 -10
- package/components/container/wizard/utils.js +1 -0
- package/components/data/form/base-form/hooks/useFormSubmission.d.ts +1 -1
- package/components/data/form/base-form/hooks/useFormSubmission.js +3 -1
- package/components/data/form/base-form/index.js +11 -14
- package/components/data/form/base-form/props.d.ts +3 -0
- package/components/data/form/dynamic-fields/WmxDynamicFormField.d.ts +11 -0
- package/components/data/form/dynamic-fields/WmxDynamicFormField.js +77 -0
- package/components/data/form/dynamic-fields/index.js +12 -1
- package/components/data/form/form-controller/withFormController.js +19 -16
- package/components/data/form/form-field/base-field.js +8 -5
- package/components/data/form/form-field/index.js +15 -8
- package/components/data/form/form-field/props.d.ts +1 -0
- package/components/data/list/components/ListItemWithTemplate.js +5 -2
- package/components/data/list/hooks/useListEffects.js +1 -1
- package/components/data/list/index.js +14 -5
- package/components/data/list/utils/constants.d.ts +0 -1
- package/components/data/list/utils/constants.js +0 -2
- package/components/data/table/components/RowCells.js +20 -4
- package/components/data/table/components/TableBody.js +5 -3
- package/components/data/table/components/TableHeader.js +14 -8
- package/components/data/table/components/TablePanelHeading.js +1 -1
- package/components/data/table/hooks/useDynamicColumns.js +1 -1
- package/components/data/table/hooks/useRowExpansion.js +41 -31
- package/components/data/table/hooks/useRowHandlers.d.ts +4 -2
- package/components/data/table/hooks/useRowHandlers.js +23 -12
- package/components/data/table/hooks/useRowSelection.d.ts +1 -1
- package/components/data/table/hooks/useRowSelection.js +80 -66
- package/components/data/table/hooks/useServerSideSorting.js +0 -1
- package/components/data/table/hooks/useTableColumns.js +16 -8
- package/components/data/table/hooks/useTableData.js +0 -1
- package/components/data/table/hooks/useTableEdit.js +0 -1
- package/components/data/table/hooks/useTableState.js +14 -2
- package/components/data/table/index.js +94 -61
- package/components/data/table/live-table/index.js +0 -1
- package/components/data/table/props.d.ts +8 -0
- package/components/data/table/utils/buildSelectionColumns.js +2 -4
- package/components/data/table/utils/columnBuilder.d.ts +16 -2
- package/components/data/table/utils/columnBuilder.js +14 -9
- package/components/data/table/utils/columnWidthDistribution.js +10 -0
- package/components/data/table/utils/constants.d.ts +0 -4
- package/components/data/table/utils/constants.js +0 -7
- package/components/data/table/utils/dynamic-columns.d.ts +1 -1
- package/components/data/table/utils/dynamic-columns.js +3 -8
- package/components/data/table/utils/expansionColumn.d.ts +23 -0
- package/components/data/table/utils/expansionColumn.js +56 -0
- package/components/data/table/utils/index.d.ts +23 -3
- package/components/data/table/utils/index.js +60 -20
- package/components/data/table/utils/selectionUtils.d.ts +5 -0
- package/components/data/table/utils/selectionUtils.js +5 -0
- package/components/dialogs/dialog/index.js +3 -2
- package/components/dialogs/dialog-header/index.js +1 -1
- package/components/dialogs/index.js +14 -2
- package/components/input/chips/index.js +29 -5
- package/components/input/color-picker/index.js +4 -6
- package/components/input/default/radioset/index.js +2 -1
- package/components/input/epoch/date/index.js +1 -1
- package/components/input/select/index.js +3 -5
- package/components/input/text/index.js +2 -2
- package/components/input/textarea/index.js +42 -17
- package/components/navbar/nav/index.js +10 -5
- package/components/navigation/breadcrumb/index.js +2 -1
- package/components/navigation/popover/index.js +24 -8
- package/components/page/index.js +1 -1
- package/components/page/page-content/index.js +30 -6
- package/components/page/page-content/props.d.ts +1 -0
- package/components/page/partial-container/index.js +2 -1
- package/components/prefab/index.js +3 -2
- package/components/prefab/props.d.ts +1 -0
- package/components/wmx/WmxRenderer.d.ts +8 -0
- package/components/wmx/WmxRenderer.js +57 -0
- package/context/WidgetProvider.js +2 -1
- package/core/appstore.js +1 -1
- package/core/proxy-service.d.ts +1 -0
- package/core/proxy-service.js +53 -2
- package/core/util/index.d.ts +0 -2
- package/core/util/index.js +3 -30
- package/higherOrder/BasePage.js +36 -54
- package/higherOrder/DataNav.js +4 -1
- package/higherOrder/withBaseWrapper.js +9 -7
- package/hooks/useHttp.js +4 -2
- package/hooks/useLayoutSize.js +1 -1
- package/package-lock.json +240 -607
- package/package.json +3 -3
- package/runtime-dynamic/app-initializer.js +2 -1
- package/runtime-dynamic/components/partial-content.js +4 -1
- package/runtime-dynamic/components/wmx-placeholder.d.ts +18 -0
- package/runtime-dynamic/components/wmx-placeholder.js +48 -0
- package/runtime-dynamic/factories/dynamic-component.js +26 -3
- package/runtime-dynamic/main.js +6 -0
- package/runtime-dynamic/services/compile-render.js +75 -12
- package/runtime-dynamic/services/css-scoping.d.ts +2 -0
- package/runtime-dynamic/services/css-scoping.js +39 -20
- package/store/slices/i18nSlice.d.ts +0 -1
- package/store/slices/i18nSlice.js +0 -2
- package/utils/custom-expression/parser.js +11 -8
- package/utils/layoutsize-util.js +12 -7
- package/utils/style-utils.d.ts +6 -0
- package/utils/style-utils.js +10 -0
- package/utils/transformedDataset-utils.d.ts +3 -3
- package/utils/transformedDataset-utils.js +1 -2
- package/utils/wmx.utils.d.ts +6 -0
- package/utils/wmx.utils.js +41 -0
- package/variables/crud-variable.js +1 -1
- package/variables/live-variable.js +1 -1
- package/variables/service-variable.js +6 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wavemaker-ai/react-runtime",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.328",
|
|
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.
|
|
62
|
-
"@wavemaker-ai/variables": "1.0.0-rc.
|
|
61
|
+
"@wavemaker-ai/react-codegen": "1.0.0-rc.328",
|
|
62
|
+
"@wavemaker-ai/variables": "1.0.0-rc.328",
|
|
63
63
|
"@wavemaker/nvd3": "1.8.16",
|
|
64
64
|
"axios": "1.15.1",
|
|
65
65
|
"d3": "7.8.5",
|
|
@@ -36,6 +36,7 @@ import { isRuntimePreviewPrefab } from "./preview-mode";
|
|
|
36
36
|
import { createLazyPartial } from "./services/variable-registry";
|
|
37
37
|
import { resolvePreviewFetchUrl } from "./preview-resource-base";
|
|
38
38
|
import { fetchResource } from "./services/resource-manager";
|
|
39
|
+
import { loadAppExtensions } from "./services/app-extension-provider";
|
|
39
40
|
async function fetchOptionalText(url) {
|
|
40
41
|
var _a;
|
|
41
42
|
try {
|
|
@@ -207,6 +208,7 @@ async function initializeApp() {
|
|
|
207
208
|
initAppModes();
|
|
208
209
|
setupAxiosInterceptors();
|
|
209
210
|
await dispatchInitialConfig();
|
|
211
|
+
await loadAppExtensions();
|
|
210
212
|
const isPrefabPreview = isRuntimePreviewPrefab();
|
|
211
213
|
syncAppstoreCommonPartial(isPrefabPreview);
|
|
212
214
|
if (!isPrefabPreview) {
|
|
@@ -217,7 +219,6 @@ async function initializeApp() {
|
|
|
217
219
|
loadAppVariables(),
|
|
218
220
|
loadAppScript(),
|
|
219
221
|
isPrefabPreview ? Promise.resolve({}) : loadCustomFormatters()
|
|
220
|
-
// loadAppExtensions(),
|
|
221
222
|
]);
|
|
222
223
|
appVariablesJson = loadedVariables;
|
|
223
224
|
customFormatters = loadedFormatters;
|
|
@@ -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";
|
|
@@ -26,6 +28,7 @@ import { ComponentErrorBoundary } from "./ErrorBoundary";
|
|
|
26
28
|
import { useDynamicComponent } from "./use-dynamic-component";
|
|
27
29
|
const WmPartialContent = memo(
|
|
28
30
|
(props) => {
|
|
31
|
+
var _a;
|
|
29
32
|
const { Component } = useDynamicComponent(props == null ? void 0 : props.content, ComponentType.PARTIAL);
|
|
30
33
|
const handleOnLoad = useCallback(
|
|
31
34
|
(widget) => {
|
|
@@ -38,7 +41,7 @@ const WmPartialContent = memo(
|
|
|
38
41
|
const mergedProps = __spreadProps(__spreadValues({}, props), {
|
|
39
42
|
onLoad: handleOnLoad
|
|
40
43
|
});
|
|
41
|
-
return /* @__PURE__ */ jsx(ComponentErrorBoundary, { scope: "partial", componentName: props.content, children: Component && /* @__PURE__ */ jsx(Component, __spreadValues({}, mergedProps)) });
|
|
44
|
+
return /* @__PURE__ */ jsx("div", { className: clsx(props.content && `app-partial-${(_a = props.content) == null ? void 0 : _a.toLocaleLowerCase()}`), children: /* @__PURE__ */ jsx(Container, { className: "partial-container", style: { height: "inherit" }, children: /* @__PURE__ */ jsx(ComponentErrorBoundary, { scope: "partial", componentName: props.content, children: Component && /* @__PURE__ */ jsx(Component, __spreadValues({}, mergedProps)) }) }) });
|
|
42
45
|
},
|
|
43
46
|
(prevProps, nextProps) => {
|
|
44
47
|
const staticKeys = [
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type WmxComponentPlaceholderProps = {
|
|
2
|
+
/** Studio markup: componentname="MultiSelect" → renders as `<MultiSelect/>` */
|
|
3
|
+
componentname?: string;
|
|
4
|
+
componentName?: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
class?: string;
|
|
8
|
+
};
|
|
9
|
+
/** Short widget label for placeholder text (e.g. MultiSelect, not WmxMultiSelect). */
|
|
10
|
+
export declare function resolveWmxPlaceholderLabel(props: WmxComponentPlaceholderProps, scopeTag?: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Generic fallback when a WMX widget is not registered in preview.
|
|
13
|
+
* Matches Studio placeholder: dashed box + `<ComponentName/>` in serif gray type.
|
|
14
|
+
*/
|
|
15
|
+
export declare function WmxComponentPlaceholder(props: WmxComponentPlaceholderProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare namespace WmxComponentPlaceholder {
|
|
17
|
+
var displayName: string;
|
|
18
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import Box from "@mui/material/Box";
|
|
3
|
+
function resolveWmxPlaceholderLabel(props, scopeTag) {
|
|
4
|
+
var _a;
|
|
5
|
+
const fromProp = (_a = props.componentname) != null ? _a : props.componentName;
|
|
6
|
+
if (fromProp) return String(fromProp);
|
|
7
|
+
if (scopeTag == null ? void 0 : scopeTag.startsWith("Wmx")) return scopeTag.slice(3);
|
|
8
|
+
if (scopeTag) return scopeTag;
|
|
9
|
+
return "Component";
|
|
10
|
+
}
|
|
11
|
+
const PLACEHOLDER_SX = {
|
|
12
|
+
display: "flex",
|
|
13
|
+
alignItems: "center",
|
|
14
|
+
justifyContent: "center",
|
|
15
|
+
width: "100%",
|
|
16
|
+
minHeight: 120,
|
|
17
|
+
boxSizing: "border-box",
|
|
18
|
+
padding: 3,
|
|
19
|
+
backgroundColor: "#f2f2f2",
|
|
20
|
+
border: "1px dashed #8c8c8c",
|
|
21
|
+
fontFamily: 'Georgia, "Times New Roman", Times, serif',
|
|
22
|
+
fontSize: "2.25rem",
|
|
23
|
+
fontWeight: 400,
|
|
24
|
+
color: "#b8b8b8",
|
|
25
|
+
lineHeight: 1.2,
|
|
26
|
+
textAlign: "center"
|
|
27
|
+
};
|
|
28
|
+
function WmxComponentPlaceholder(props) {
|
|
29
|
+
const label = resolveWmxPlaceholderLabel(props);
|
|
30
|
+
const tagText = `<${label}/>`;
|
|
31
|
+
const className = ["wm-wmx-component-placeholder", props.className, props.class].filter(Boolean).join(" ");
|
|
32
|
+
return /* @__PURE__ */ jsx(
|
|
33
|
+
Box,
|
|
34
|
+
{
|
|
35
|
+
className,
|
|
36
|
+
"data-wmx-component": label,
|
|
37
|
+
role: "status",
|
|
38
|
+
"aria-label": `WMX component placeholder: ${tagText}`,
|
|
39
|
+
sx: PLACEHOLDER_SX,
|
|
40
|
+
children: tagText
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
WmxComponentPlaceholder.displayName = "WmxComponentPlaceholder";
|
|
45
|
+
export {
|
|
46
|
+
WmxComponentPlaceholder,
|
|
47
|
+
resolveWmxPlaceholderLabel
|
|
48
|
+
};
|
|
@@ -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 {
|
|
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
|
-
|
|
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
|
}
|
package/runtime-dynamic/main.js
CHANGED
|
@@ -3,7 +3,13 @@ import { createRoot } from "react-dom/client";
|
|
|
3
3
|
import wmGlobalsCss from "@wavemaker-ai/react-codegen/styles/wm-styles.css";
|
|
4
4
|
import { App, initPreviewRuntimeRouter } from "./App";
|
|
5
5
|
import { initializeApp } from "./app-initializer";
|
|
6
|
+
import { registerCustomWidget, getCustomWidget, hasCustomWidget } from "./registry";
|
|
6
7
|
import { createAppRouter } from "./routes";
|
|
8
|
+
window.WMPreview = {
|
|
9
|
+
registerCustomWidget,
|
|
10
|
+
getCustomWidget,
|
|
11
|
+
hasCustomWidget
|
|
12
|
+
};
|
|
7
13
|
function injectGlobalStyles() {
|
|
8
14
|
if (document.querySelector('style[data-wm-scope="globals"]')) return;
|
|
9
15
|
const style = document.createElement("style");
|
|
@@ -1,11 +1,35 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1
20
|
import React from "react";
|
|
2
21
|
import { transform } from "sucrase";
|
|
3
22
|
import { getComponent } from "../registry/component-registry";
|
|
23
|
+
import { getCustomWidget } from "../registry/custom-widget-registry";
|
|
24
|
+
import {
|
|
25
|
+
WmxComponentPlaceholder
|
|
26
|
+
} from "../components/wmx-placeholder";
|
|
4
27
|
import { formatMessage, _get, toNumber } from "../../core/util";
|
|
5
28
|
import { getPartialNames } from "../app-initializer";
|
|
6
29
|
import { createLazyPartial } from "./variable-registry";
|
|
7
30
|
const compiledCache = /* @__PURE__ */ new Map();
|
|
8
31
|
const componentNameCache = /* @__PURE__ */ new Map();
|
|
32
|
+
const wmxComponentNameCache = /* @__PURE__ */ new Map();
|
|
9
33
|
const UTIL_SCOPE = {
|
|
10
34
|
formatMessage,
|
|
11
35
|
_get,
|
|
@@ -24,6 +48,47 @@ function extractMarkupComponents(markup) {
|
|
|
24
48
|
componentNameCache.set(markup, result);
|
|
25
49
|
return result;
|
|
26
50
|
}
|
|
51
|
+
function extractWmxComponents(markup) {
|
|
52
|
+
const cached = wmxComponentNameCache.get(markup);
|
|
53
|
+
if (cached) return cached;
|
|
54
|
+
const matches = markup.match(/\bWmx[A-Z]\w*/g);
|
|
55
|
+
const result = matches ? [...new Set(matches)] : [];
|
|
56
|
+
wmxComponentNameCache.set(markup, result);
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
function tryAddScopeComponent(name, seen, names, values) {
|
|
60
|
+
var _a;
|
|
61
|
+
if (seen.has(name)) return false;
|
|
62
|
+
const component = (_a = getComponent(name)) != null ? _a : getCustomWidget(name);
|
|
63
|
+
if (!component) return false;
|
|
64
|
+
seen.add(name);
|
|
65
|
+
names.push(name);
|
|
66
|
+
values.push(component);
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
function tryAddWmxScopeComponent(scopeName, seen, names, values) {
|
|
70
|
+
if (seen.has(scopeName)) return false;
|
|
71
|
+
const registered = getCustomWidget(scopeName);
|
|
72
|
+
if (registered) {
|
|
73
|
+
seen.add(scopeName);
|
|
74
|
+
names.push(scopeName);
|
|
75
|
+
values.push(registered);
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
const component = (props) => {
|
|
79
|
+
var _a, _b;
|
|
80
|
+
return React.createElement(WmxComponentPlaceholder, __spreadProps(__spreadValues({}, props), {
|
|
81
|
+
componentname: (_b = (_a = props.componentname) != null ? _a : props.componentName) != null ? _b : scopeName.replace(/^Wmx/, "")
|
|
82
|
+
}));
|
|
83
|
+
};
|
|
84
|
+
seen.add(scopeName);
|
|
85
|
+
names.push(scopeName);
|
|
86
|
+
values.push(component);
|
|
87
|
+
console.warn(
|
|
88
|
+
`[markup-transpiler] WMX "${scopeName}" not registered \u2014 placeholder shown. Load app.extensions.js.`
|
|
89
|
+
);
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
27
92
|
function resolveScope(imports, appState, markup) {
|
|
28
93
|
const fragment = appState;
|
|
29
94
|
const names = ["React", "fragment", "Widgets", "Variables"];
|
|
@@ -33,11 +98,11 @@ function resolveScope(imports, appState, markup) {
|
|
|
33
98
|
for (const importDef of imports) {
|
|
34
99
|
const name = importDef.as || importDef.name;
|
|
35
100
|
if (seen.has(name)) continue;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
101
|
+
if (name.startsWith("Wmx")) {
|
|
102
|
+
tryAddWmxScopeComponent(name, seen, names, values);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (tryAddScopeComponent(name, seen, names, values)) {
|
|
41
106
|
continue;
|
|
42
107
|
}
|
|
43
108
|
const partialName = [...knownPartials].find((p) => p.toLowerCase() === name.toLowerCase());
|
|
@@ -52,13 +117,10 @@ function resolveScope(imports, appState, markup) {
|
|
|
52
117
|
}
|
|
53
118
|
if (markup) {
|
|
54
119
|
for (const name of extractMarkupComponents(markup)) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
names.push(name);
|
|
60
|
-
values.push(component);
|
|
61
|
-
}
|
|
120
|
+
tryAddScopeComponent(name, seen, names, values);
|
|
121
|
+
}
|
|
122
|
+
for (const name of extractWmxComponents(markup)) {
|
|
123
|
+
tryAddWmxScopeComponent(name, seen, names, values);
|
|
62
124
|
}
|
|
63
125
|
}
|
|
64
126
|
for (const [name, value] of Object.entries(UTIL_SCOPE)) {
|
|
@@ -133,6 +195,7 @@ return __render__();`;
|
|
|
133
195
|
function clearCompiledCache() {
|
|
134
196
|
compiledCache.clear();
|
|
135
197
|
componentNameCache.clear();
|
|
198
|
+
wmxComponentNameCache.clear();
|
|
136
199
|
lazyPartialCache.clear();
|
|
137
200
|
}
|
|
138
201
|
export {
|
|
@@ -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
|
|
3
|
-
|
|
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
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
|
24
|
-
const
|
|
41
|
+
const scopeOptions = getCssScopeOptions(componentType, componentName);
|
|
42
|
+
const basePath = getPreviewCssBasePath();
|
|
25
43
|
const scopeAttribute = `${componentType}-${componentName}`;
|
|
26
|
-
const cacheKey = `${
|
|
44
|
+
const cacheKey = `${scopeAttribute}::${basePath != null ? basePath : ""}::${styles}`;
|
|
27
45
|
let scopedCss = scopedCssCache.get(cacheKey);
|
|
28
46
|
if (!scopedCss) {
|
|
29
|
-
scopedCss =
|
|
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
|
};
|
|
@@ -70,7 +70,6 @@ const RTL_LANGUAGE_CODES = [
|
|
|
70
70
|
];
|
|
71
71
|
const initialState = {
|
|
72
72
|
selectedLocale: "",
|
|
73
|
-
localeRevision: 0,
|
|
74
73
|
defaultSupportedLocale: "en",
|
|
75
74
|
appLocale: {},
|
|
76
75
|
dateFormat: "MMM d, y",
|
|
@@ -189,7 +188,6 @@ const i18nSlice = createSlice({
|
|
|
189
188
|
state.dateTimeFormat = `${state.dateFormat} ${state.timeFormat}`;
|
|
190
189
|
state.prefabMessages = action.payload.data.prefabMessages || {};
|
|
191
190
|
state.selectedLocale = action.payload.locale || state.selectedLocale;
|
|
192
|
-
state.localeRevision += 1;
|
|
193
191
|
}).addCase(loadLocaleBundle.rejected, (state, action) => {
|
|
194
192
|
state.error = action.payload;
|
|
195
193
|
});
|
|
@@ -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 =
|
|
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;
|
package/utils/layoutsize-util.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
function applySize(el, key, nv) {
|
|
2
2
|
const parent = el.parentElement;
|
|
3
3
|
const parentStyle = parent ? getComputedStyle(parent) : null;
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const isLayoutWrapper = !!parent && (parent.classList.contains("app-page-content") || parent.classList.contains("app-content-column"));
|
|
5
|
+
const isParentFlex = !isLayoutWrapper && !!parentStyle && ["flex", "inline-flex"].includes(parentStyle.display);
|
|
6
|
+
let isWidthMainAxis = false;
|
|
7
|
+
let isHeightMainAxis = false;
|
|
6
8
|
if (isParentFlex) {
|
|
7
9
|
const flexDir = parentStyle.flexDirection;
|
|
8
10
|
const isRow = ["row", "row-reverse"].includes(flexDir);
|
|
9
|
-
|
|
11
|
+
isWidthMainAxis = key === "width" && isRow;
|
|
12
|
+
isHeightMainAxis = key === "height" && !isRow;
|
|
10
13
|
}
|
|
11
14
|
const minKey = key === "width" ? "minWidth" : "minHeight";
|
|
12
15
|
if (nv === "fill") {
|
|
@@ -14,9 +17,10 @@ function applySize(el, key, nv) {
|
|
|
14
17
|
el.style[key] = "100%";
|
|
15
18
|
} else {
|
|
16
19
|
el.style[key] = "";
|
|
17
|
-
if (
|
|
20
|
+
if (isWidthMainAxis || isHeightMainAxis) {
|
|
18
21
|
el.style.flexGrow = "1";
|
|
19
|
-
el.style.flexShrink = "";
|
|
22
|
+
el.style.flexShrink = "0";
|
|
23
|
+
el.style.flexBasis = isHeightMainAxis ? "" : "0";
|
|
20
24
|
el.style[minKey] = "0";
|
|
21
25
|
} else {
|
|
22
26
|
el.style.alignSelf = "stretch";
|
|
@@ -27,8 +31,8 @@ function applySize(el, key, nv) {
|
|
|
27
31
|
el.style[key] = "fit-content";
|
|
28
32
|
}
|
|
29
33
|
if (isParentFlex) {
|
|
30
|
-
if (
|
|
31
|
-
el.style.
|
|
34
|
+
if (isWidthMainAxis || isHeightMainAxis) {
|
|
35
|
+
el.style.flexBasis = "";
|
|
32
36
|
el.style.flexShrink = "0";
|
|
33
37
|
el.style[minKey] = "";
|
|
34
38
|
} else {
|
|
@@ -37,6 +41,7 @@ function applySize(el, key, nv) {
|
|
|
37
41
|
} else {
|
|
38
42
|
el.style.flexGrow = "";
|
|
39
43
|
el.style.flexShrink = "0";
|
|
44
|
+
el.style.flexBasis = "";
|
|
40
45
|
el.style.alignSelf = "";
|
|
41
46
|
el.style[minKey] = "";
|
|
42
47
|
}
|
package/utils/style-utils.d.ts
CHANGED
|
@@ -28,3 +28,9 @@ export declare const filterAutoLayoutClasses: (layoutClassName: string | undefin
|
|
|
28
28
|
export declare const toCssLength: (value: string | number) => string;
|
|
29
29
|
/** Ensures a CSS `background-image` value is wrapped in `url(...)` when needed. */
|
|
30
30
|
export declare const normalizeBackgroundImage: (value: string) => string;
|
|
31
|
+
export declare function getFragmentCssScopeClass(appState: {
|
|
32
|
+
componentName?: string;
|
|
33
|
+
name?: string;
|
|
34
|
+
componentType?: string;
|
|
35
|
+
type?: string;
|
|
36
|
+
} | null): string | undefined;
|
package/utils/style-utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getCurrentPath } from "../core/util/utils";
|
|
1
2
|
const sanitizeStyleObject = (styleObj) => {
|
|
2
3
|
if (!styleObj || typeof styleObj !== "object") {
|
|
3
4
|
return {};
|
|
@@ -33,8 +34,17 @@ const filterAutoLayoutClasses = (layoutClassName, prefixesToGet, mode = "include
|
|
|
33
34
|
};
|
|
34
35
|
const toCssLength = (value) => typeof value === "number" ? `${value}px` : String(value);
|
|
35
36
|
const normalizeBackgroundImage = (value) => value.includes("url(") ? value : `url(${value})`;
|
|
37
|
+
function getFragmentCssScopeClass(appState) {
|
|
38
|
+
const name = ((appState == null ? void 0 : appState.componentName) || (appState == null ? void 0 : appState.name) || getCurrentPath().split("/").pop() || "").toLowerCase();
|
|
39
|
+
if (!name) return void 0;
|
|
40
|
+
const type = String((appState == null ? void 0 : appState.componentType) || (appState == null ? void 0 : appState.type) || "PAGE").toUpperCase();
|
|
41
|
+
if (type === "PARTIAL") return `app-partial-${name}`;
|
|
42
|
+
if (type === "PREFAB") return `app-prefab-${name}`;
|
|
43
|
+
return `app-page-${name}`;
|
|
44
|
+
}
|
|
36
45
|
export {
|
|
37
46
|
filterAutoLayoutClasses,
|
|
47
|
+
getFragmentCssScopeClass,
|
|
38
48
|
isValidStyleObject,
|
|
39
49
|
mergeStyleObjects,
|
|
40
50
|
normalizeBackgroundImage,
|
|
@@ -14,7 +14,7 @@ export declare class DataSetItem {
|
|
|
14
14
|
match?: string;
|
|
15
15
|
dateformat?: string;
|
|
16
16
|
}
|
|
17
|
-
export declare const transformDataset: (
|
|
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:
|
|
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<
|
|
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 =
|
|
118
|
+
const transformDataset = _internalTransformDataset;
|
|
120
119
|
const getOrderedDataset = (dataSet, orderBy, innerItem) => {
|
|
121
120
|
if (!orderBy) {
|
|
122
121
|
return cloneDeep(dataSet);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ComponentType } from "react";
|
|
2
|
+
export type WmxComponentModule = Record<string, ComponentType<any>>;
|
|
3
|
+
export declare const registerWmxComponents: (module: WmxComponentModule) => void;
|
|
4
|
+
export declare const getWmxModule: () => WmxComponentModule | null;
|
|
5
|
+
export declare const getWmxComponentName: (widgetName: string) => string | null;
|
|
6
|
+
export declare const loadWmxComponent: (componentName: string) => Promise<ComponentType<any> | null>;
|