@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.
- package/components/basic/anchor/index.js +3 -0
- package/components/container/index.js +6 -1
- package/components/container/layout-grid/grid-row/index.js +1 -1
- 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/form-controller/withFormController.js +19 -2
- package/components/data/form/form-field/base-field.js +8 -5
- package/components/data/form/form-field/index.js +11 -7
- 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 +11 -3
- 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 +18 -4
- package/components/data/table/components/TableBody.js +5 -3
- package/components/data/table/components/TableHeader.js +9 -7
- 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.js +0 -1
- 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/index.js +47 -18
- package/components/data/table/live-table/index.js +0 -1
- package/components/data/table/props.d.ts +4 -0
- package/components/data/table/utils/buildSelectionColumns.js +0 -2
- package/components/data/table/utils/columnBuilder.d.ts +16 -2
- package/components/data/table/utils/columnBuilder.js +13 -8
- 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 +14 -2
- package/components/data/table/utils/index.js +45 -19
- package/components/dialogs/dialog/index.js +3 -2
- package/components/input/default/radioset/index.js +2 -1
- package/components/input/select/index.js +1 -2
- package/components/input/textarea/index.js +1 -1
- package/components/navigation/popover/index.js +15 -7
- package/components/page/index.js +1 -1
- package/components/page/page-content/index.js +6 -2
- 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/context/WidgetProvider.js +2 -1
- package/core/proxy-service.d.ts +1 -0
- package/core/proxy-service.js +53 -2
- package/core/util/index.js +3 -1
- package/higherOrder/BasePage.js +25 -4
- package/higherOrder/withBaseWrapper.js +9 -7
- package/package-lock.json +127 -138
- package/package.json +3 -3
- package/runtime-dynamic/components/partial-content.js +3 -1
- package/runtime-dynamic/factories/dynamic-component.js +26 -3
- package/runtime-dynamic/services/css-scoping.d.ts +2 -0
- package/runtime-dynamic/services/css-scoping.js +39 -20
- package/utils/custom-expression/parser.js +11 -8
- package/utils/transformedDataset-utils.d.ts +3 -3
- package/utils/transformedDataset-utils.js +1 -2
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const SYSTEM_HEADER_IDS = /* @__PURE__ */ new Set([
|
|
2
|
+
"multiSelect",
|
|
3
|
+
"radioSelect",
|
|
4
|
+
"row-index",
|
|
5
|
+
"rowIndex",
|
|
6
|
+
"actions"
|
|
7
|
+
]);
|
|
8
|
+
function findFirstDataColumnIndex(headers) {
|
|
9
|
+
for (let i = 0; i < headers.length; i++) {
|
|
10
|
+
if (!SYSTEM_HEADER_IDS.has(headers[i].id)) {
|
|
11
|
+
return i;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return 0;
|
|
15
|
+
}
|
|
16
|
+
function getExpansionColumnInsertIndex(headers, rowExpansionConfig, options) {
|
|
17
|
+
if (!rowExpansionConfig) return -1;
|
|
18
|
+
if (options == null ? void 0 : options.appendForGroupedTable) {
|
|
19
|
+
return headers.length;
|
|
20
|
+
}
|
|
21
|
+
const position = rowExpansionConfig.position;
|
|
22
|
+
if (position === "-1" || position === -1) {
|
|
23
|
+
return Math.max(0, headers.length - 1);
|
|
24
|
+
}
|
|
25
|
+
if (typeof position === "number" || typeof position === "string" && !isNaN(Number(position))) {
|
|
26
|
+
return findFirstDataColumnIndex([...headers]) + Number(position);
|
|
27
|
+
}
|
|
28
|
+
if (typeof position === "string") {
|
|
29
|
+
const columnIndex = headers.findIndex((header) => {
|
|
30
|
+
var _a;
|
|
31
|
+
if (header.id === position || header.column.id === position) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
const accessorKey = (_a = header.column.columnDef) == null ? void 0 : _a.accessorKey;
|
|
35
|
+
if (accessorKey === position) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
const normalizedPosition = position.replace(/\./g, "_");
|
|
39
|
+
return header.id === normalizedPosition || header.column.id === normalizedPosition;
|
|
40
|
+
});
|
|
41
|
+
return columnIndex >= 0 ? columnIndex + 1 : 0;
|
|
42
|
+
}
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
function buildExpansionColSpec(columnwidth) {
|
|
46
|
+
const w = columnwidth || "50px";
|
|
47
|
+
return {
|
|
48
|
+
key: "row-expansion",
|
|
49
|
+
width: w,
|
|
50
|
+
style: { width: w }
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
buildExpansionColSpec,
|
|
55
|
+
getExpansionColumnInsertIndex
|
|
56
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { type CSSProperties } from "react";
|
|
2
2
|
import { WmTableColumnProps, WmTableRowActionProps, WmTableRowProps, WmTableActionProps, ValidationResult } from "../props";
|
|
3
3
|
declare const formWidgets: readonly ["WmText", "WmTextarea", "WmCheckbox", "WmSlider", "WmCurrency", "WmSwitch", "WmSelect", "WmCheckboxSet", "WmRadioSet", "WmDate", "WmTime", "WmTimestamp", "WmRating", "WmDatetime", "WmSearch", "WmChips", "WmColorPicker"];
|
|
4
4
|
type FormWidgetType = (typeof formWidgets)[number];
|
|
@@ -46,6 +46,8 @@ export declare const parseTableStructureWithGroups: (children: React.ReactNode)
|
|
|
46
46
|
export declare const flattenTableStructure: (structure: TableStructureItem[]) => WmTableColumnProps[];
|
|
47
47
|
export declare const parseTableRowActions: (children: React.ReactNode) => WmTableRowActionProps[];
|
|
48
48
|
export declare const parseTableActions: (children: React.ReactNode) => WmTableActionProps[];
|
|
49
|
+
/** Resolve row-bound expansion props. Uses precomputed map first, then tableRowProps(rowData) fallback. */
|
|
50
|
+
export declare const getRowExpansionConfig: (config: WmTableRowProps | null, rowId: string, rowData?: any) => WmTableRowProps | null;
|
|
49
51
|
export declare const parseTableRowExpansion: (children: React.ReactNode) => WmTableRowProps | null;
|
|
50
52
|
export declare const isEditAction: (actionKey: string) => boolean;
|
|
51
53
|
export declare const isDeleteAction: (actionKey: string) => boolean;
|
|
@@ -95,8 +97,18 @@ export declare const INTERNAL_PROPERTIES: string[];
|
|
|
95
97
|
*/
|
|
96
98
|
export declare const cleanRowData: (data: any) => any;
|
|
97
99
|
export declare const parseWidth: (width: string | number, fallbackSize?: number) => number;
|
|
100
|
+
/**
|
|
101
|
+
* Angular datatable.js hides show:false columns via jQuery `.hide()` / `.show()`
|
|
102
|
+
* (sets element.style.display = "none"), not by removing th/td from the DOM.
|
|
103
|
+
* setColGroupWidths also hides the matching `<col>` ($headerCol.hide()).
|
|
104
|
+
*/
|
|
105
|
+
export declare function isColumnDomHidden(meta?: Record<string, unknown>): boolean;
|
|
106
|
+
/** Angular setColGroupWidths: jQuery `.hide()` plus width 0 on col for table-layout:fixed. */
|
|
107
|
+
export declare function getDomHiddenColStyle(meta?: Record<string, unknown>): CSSProperties | undefined;
|
|
108
|
+
/** Inline style for hidden th/td — display:none and zero box so flex sizing cannot leak width. */
|
|
109
|
+
export declare function getDomHiddenCellStyle(meta?: Record<string, unknown>): CSSProperties | undefined;
|
|
98
110
|
export declare const getColClass: (colClass: string, rowData: any, columnName: string) => string;
|
|
99
|
-
export { TABLE_CSS_CLASSES, TABLE_DATA_STATES, TABLE_MESSAGES, INTERACTIVE_CLASSES, INTERACTIVE_ROLES, INTERACTIVE_DATA_ROLES, INTERACTIVE_TAG_NAMES,
|
|
111
|
+
export { TABLE_CSS_CLASSES, TABLE_DATA_STATES, TABLE_MESSAGES, INTERACTIVE_CLASSES, INTERACTIVE_ROLES, INTERACTIVE_DATA_ROLES, INTERACTIVE_TAG_NAMES, UNSUPPORTED_STATE_PERSISTENCE_TYPES, } from "./constants";
|
|
100
112
|
export { renderDisplayCell } from "./renderDisplayCell";
|
|
101
113
|
export { buildSelectionColumns } from "./buildSelectionColumns";
|
|
102
114
|
export { validateField, resetValidationState, updateValidationErrors } from "./validation";
|
|
@@ -311,26 +311,17 @@ const flattenTableStructure = (structure) => {
|
|
|
311
311
|
});
|
|
312
312
|
return columns;
|
|
313
313
|
};
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
const actionProps = assign({}, props);
|
|
321
|
-
if (child.key) {
|
|
322
|
-
actionProps.key = child.key;
|
|
323
|
-
}
|
|
324
|
-
actions.push(actionProps);
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
return actions;
|
|
314
|
+
const isTableChildOfType = (child, namePattern, componentToken) => {
|
|
315
|
+
var _a;
|
|
316
|
+
if (!((_a = child == null ? void 0 : child.props) == null ? void 0 : _a.name)) return false;
|
|
317
|
+
const propName = child.props.name;
|
|
318
|
+
const displayName = getChildComponentDisplayName(child);
|
|
319
|
+
return propName.includes(namePattern) || displayName.includes(componentToken);
|
|
328
320
|
};
|
|
329
|
-
const
|
|
321
|
+
const parseTableChildActions = (children, namePattern, componentToken) => {
|
|
330
322
|
const actions = [];
|
|
331
323
|
React.Children.forEach(children, (child) => {
|
|
332
|
-
|
|
333
|
-
if (child && child.props && child.props.name && (child.props.name.includes("wm_table_action") || ((_a = child.type) == null ? void 0 : _a.displayName) === "WmTableAction")) {
|
|
324
|
+
if (isTableChildOfType(child, namePattern, componentToken)) {
|
|
334
325
|
const props = get(child, "props", {});
|
|
335
326
|
const actionProps = assign({}, props);
|
|
336
327
|
if (child.key) {
|
|
@@ -341,6 +332,8 @@ const parseTableActions = (children) => {
|
|
|
341
332
|
});
|
|
342
333
|
return actions;
|
|
343
334
|
};
|
|
335
|
+
const parseTableRowActions = (children) => parseTableChildActions(children, "wm_table_row_action", "WmTableRowAction");
|
|
336
|
+
const parseTableActions = (children) => parseTableChildActions(children, "wm_table_action", "WmTableAction");
|
|
344
337
|
function isTableRowComponent(child) {
|
|
345
338
|
if (!(child == null ? void 0 : child.type)) return false;
|
|
346
339
|
const name = child.type.displayName || child.type.name || "";
|
|
@@ -353,6 +346,11 @@ function isTableRowComponent(child) {
|
|
|
353
346
|
}
|
|
354
347
|
return false;
|
|
355
348
|
}
|
|
349
|
+
const getRowExpansionConfig = (config, rowId, rowData) => {
|
|
350
|
+
if (!config) return null;
|
|
351
|
+
const overrides = typeof config.tableRowProps === "function" && rowData !== void 0 ? config.tableRowProps(rowData) : {};
|
|
352
|
+
return __spreadValues(__spreadValues({}, config), overrides);
|
|
353
|
+
};
|
|
356
354
|
const parseTableRowExpansion = (children) => {
|
|
357
355
|
let rowExpansionConfig = null;
|
|
358
356
|
React.Children.forEach(children, (child) => {
|
|
@@ -570,6 +568,32 @@ const parseWidth = (width, fallbackSize = 150) => {
|
|
|
570
568
|
}
|
|
571
569
|
return columnSize;
|
|
572
570
|
};
|
|
571
|
+
function isColumnDomHidden(meta) {
|
|
572
|
+
return !!(meta == null ? void 0 : meta.domHidden);
|
|
573
|
+
}
|
|
574
|
+
function getDomHiddenColStyle(meta) {
|
|
575
|
+
if (!isColumnDomHidden(meta)) {
|
|
576
|
+
return void 0;
|
|
577
|
+
}
|
|
578
|
+
return {
|
|
579
|
+
display: "none",
|
|
580
|
+
width: 0,
|
|
581
|
+
minWidth: 0,
|
|
582
|
+
maxWidth: 0
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
function getDomHiddenCellStyle(meta) {
|
|
586
|
+
if (!isColumnDomHidden(meta)) {
|
|
587
|
+
return void 0;
|
|
588
|
+
}
|
|
589
|
+
return {
|
|
590
|
+
display: "none",
|
|
591
|
+
width: 0,
|
|
592
|
+
minWidth: 0,
|
|
593
|
+
maxWidth: 0,
|
|
594
|
+
padding: 0
|
|
595
|
+
};
|
|
596
|
+
}
|
|
573
597
|
const getColClass = (colClass, rowData, columnName) => {
|
|
574
598
|
if (!colClass || typeof colClass !== "string") {
|
|
575
599
|
return "";
|
|
@@ -611,7 +635,6 @@ import {
|
|
|
611
635
|
INTERACTIVE_ROLES,
|
|
612
636
|
INTERACTIVE_DATA_ROLES,
|
|
613
637
|
INTERACTIVE_TAG_NAMES,
|
|
614
|
-
DYNAMIC_COLUMNS_CONFIG,
|
|
615
638
|
UNSUPPORTED_STATE_PERSISTENCE_TYPES
|
|
616
639
|
} from "./constants";
|
|
617
640
|
import { renderDisplayCell } from "./renderDisplayCell";
|
|
@@ -642,7 +665,6 @@ import {
|
|
|
642
665
|
convertFilterObjectToArray
|
|
643
666
|
} from "./table-helpers";
|
|
644
667
|
export {
|
|
645
|
-
DYNAMIC_COLUMNS_CONFIG,
|
|
646
668
|
INTERACTIVE_CLASSES,
|
|
647
669
|
INTERACTIVE_DATA_ROLES,
|
|
648
670
|
INTERACTIVE_ROLES,
|
|
@@ -673,6 +695,9 @@ export {
|
|
|
673
695
|
getButtonClasses,
|
|
674
696
|
getChildComponentDisplayName,
|
|
675
697
|
getColClass,
|
|
698
|
+
getDomHiddenCellStyle,
|
|
699
|
+
getDomHiddenColStyle,
|
|
700
|
+
getRowExpansionConfig,
|
|
676
701
|
getRowIdsFromDataset,
|
|
677
702
|
getSpacingClasses,
|
|
678
703
|
getTableActionButtonClass,
|
|
@@ -683,6 +708,7 @@ export {
|
|
|
683
708
|
hasInteractiveAttributes,
|
|
684
709
|
hasInteractiveClass,
|
|
685
710
|
isAddNewAction,
|
|
711
|
+
isColumnDomHidden,
|
|
686
712
|
isColumnVisibleForViewport,
|
|
687
713
|
isDataColumn,
|
|
688
714
|
isDeleteAction,
|
|
@@ -18,13 +18,14 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
-
import { memo } from "react";
|
|
21
|
+
import { memo, Suspense } from "react";
|
|
22
22
|
import clsx from "clsx";
|
|
23
23
|
import withBaseWrapper from "../../../higherOrder/withBaseWrapper";
|
|
24
24
|
import Dialog from "..";
|
|
25
25
|
import BaseDialog from "../withDialogWrapper";
|
|
26
26
|
import { WmDialogHeader } from "../dialog-header";
|
|
27
27
|
import { WmDialogContent } from "../dialog-content";
|
|
28
|
+
import { WmSpinner } from "../../basic/spinner";
|
|
28
29
|
const WmDialog = memo(
|
|
29
30
|
(props) => {
|
|
30
31
|
var _a;
|
|
@@ -65,7 +66,7 @@ const WmDialog = memo(
|
|
|
65
66
|
closable: props.closable
|
|
66
67
|
}
|
|
67
68
|
),
|
|
68
|
-
props.children
|
|
69
|
+
/* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(WmSpinner, { show: true, name: "dialog" }), children: props.children })
|
|
69
70
|
] }))
|
|
70
71
|
})
|
|
71
72
|
);
|
|
@@ -334,10 +334,9 @@ const WmSelect = React.memo(
|
|
|
334
334
|
}
|
|
335
335
|
prevComputedValueRef.current = currentValue;
|
|
336
336
|
}, [computedSelectValue, multiple, listener, props.fieldName, name, localDatavalue]);
|
|
337
|
-
return /* @__PURE__ */ jsx("div", { className: clsx(DEFAULT_CLASS, className), children: /* @__PURE__ */ jsxs(
|
|
337
|
+
return /* @__PURE__ */ jsx("div", { className: clsx(DEFAULT_CLASS, className), hidden: props.hidden, children: /* @__PURE__ */ jsxs(
|
|
338
338
|
NativeSelect,
|
|
339
339
|
__spreadProps(__spreadValues({
|
|
340
|
-
hidden: props.hidden,
|
|
341
340
|
name,
|
|
342
341
|
IconComponent: () => null,
|
|
343
342
|
className: clsx(
|
|
@@ -303,7 +303,7 @@ const WmTextarea = memo(
|
|
|
303
303
|
pattern: regexp
|
|
304
304
|
}
|
|
305
305
|
},
|
|
306
|
-
slots: __spreadValues({}, maxchars ? { formHelperText: TextareaCount } : {})
|
|
306
|
+
slots: __spreadValues({}, maxchars && limitdisplaytext ? { formHelperText: TextareaCount } : {})
|
|
307
307
|
}, events)
|
|
308
308
|
) });
|
|
309
309
|
},
|
|
@@ -63,13 +63,20 @@ const WmPopover = (Props) => {
|
|
|
63
63
|
openPopover();
|
|
64
64
|
}
|
|
65
65
|
}, [isOpen, openPopover, closePopover]);
|
|
66
|
+
const apiRef = useRef({
|
|
67
|
+
open: openPopover,
|
|
68
|
+
close: closePopover,
|
|
69
|
+
toggle: togglePopover,
|
|
70
|
+
isOpen
|
|
71
|
+
});
|
|
72
|
+
apiRef.current = { open: openPopover, close: closePopover, toggle: togglePopover, isOpen };
|
|
66
73
|
useEffect(() => {
|
|
67
74
|
const { listener, name } = props;
|
|
68
75
|
if ((listener == null ? void 0 : listener.onChange) && name) {
|
|
69
76
|
listener.onChange(name, {
|
|
70
|
-
open:
|
|
71
|
-
close:
|
|
72
|
-
toggle:
|
|
77
|
+
open: () => apiRef.current.open(),
|
|
78
|
+
close: () => apiRef.current.close(),
|
|
79
|
+
toggle: () => apiRef.current.toggle(),
|
|
73
80
|
isOpen
|
|
74
81
|
});
|
|
75
82
|
}
|
|
@@ -86,7 +93,7 @@ const WmPopover = (Props) => {
|
|
|
86
93
|
}
|
|
87
94
|
handleLoad(__spreadValues({ isOpen }, props));
|
|
88
95
|
}, [isOpen]);
|
|
89
|
-
const calculatePlacement = () => {
|
|
96
|
+
const calculatePlacement = useCallback(() => {
|
|
90
97
|
if (!anchorRef.current) return;
|
|
91
98
|
const rect = anchorRef.current.getBoundingClientRect();
|
|
92
99
|
const viewHeight = window.innerHeight;
|
|
@@ -100,7 +107,7 @@ const WmPopover = (Props) => {
|
|
|
100
107
|
else if (props.popoverplacement === "right" && viewWidth - rect.right < width)
|
|
101
108
|
setPlacement("left");
|
|
102
109
|
else setPlacement(props.popoverplacement || "bottom");
|
|
103
|
-
};
|
|
110
|
+
}, [props.popoverplacement, props.popoverheight, props.popoverwidth]);
|
|
104
111
|
useLayoutEffect(() => {
|
|
105
112
|
var _a2, _b2;
|
|
106
113
|
if (!isOpen) return;
|
|
@@ -197,7 +204,7 @@ const WmPopover = (Props) => {
|
|
|
197
204
|
}), {
|
|
198
205
|
marginLeft: "-4px"
|
|
199
206
|
});
|
|
200
|
-
}, [placement
|
|
207
|
+
}, [placement]);
|
|
201
208
|
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
209
|
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
210
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -240,7 +247,8 @@ const WmPopover = (Props) => {
|
|
|
240
247
|
encodeurl: props.encodeurl,
|
|
241
248
|
shortcutkey: props.shortcutkey,
|
|
242
249
|
name: props.name
|
|
243
|
-
}
|
|
250
|
+
},
|
|
251
|
+
props.name
|
|
244
252
|
)
|
|
245
253
|
})
|
|
246
254
|
),
|
package/components/page/index.js
CHANGED
|
@@ -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",
|
|
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,10 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import clsx from "clsx";
|
|
4
|
+
import { useAppState } from "../../../context/WidgetProvider";
|
|
5
|
+
import { getCurrentPath } from "../../../core/util/utils";
|
|
4
6
|
const DEFAULT_CLASS = "app-page-content app-content-column";
|
|
5
7
|
function WmPageContent(props) {
|
|
6
8
|
const { className, columnwidth, styles, layoutClassName } = props;
|
|
7
|
-
|
|
9
|
+
const appState = useAppState();
|
|
10
|
+
const pageName = ((appState == null ? void 0 : appState.componentName) || (appState == null ? void 0 : appState.name) || getCurrentPath().split("/").pop() || "").toLowerCase();
|
|
11
|
+
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
12
|
"div",
|
|
9
13
|
{
|
|
10
14
|
style: styles,
|
|
@@ -16,7 +20,7 @@ function WmPageContent(props) {
|
|
|
16
20
|
),
|
|
17
21
|
children: props.children
|
|
18
22
|
}
|
|
19
|
-
);
|
|
23
|
+
) }) });
|
|
20
24
|
}
|
|
21
25
|
WmPageContent.displayName = "WmPageContent";
|
|
22
26
|
var page_content_default = WmPageContent;
|
|
@@ -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", 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 {
|
|
@@ -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/proxy-service.d.ts
CHANGED
|
@@ -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;
|
package/core/proxy-service.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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,
|
package/core/util/index.js
CHANGED
|
@@ -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,7 +90,8 @@ const getTimezone = () => {
|
|
|
89
90
|
return timezone || "UTC";
|
|
90
91
|
};
|
|
91
92
|
const formatMessage = (fragment, expression) => {
|
|
92
|
-
|
|
93
|
+
const path = `appLocale.${expression}`;
|
|
94
|
+
return has(fragment, path) ? get(fragment, path) : void 0;
|
|
93
95
|
};
|
|
94
96
|
function syncLocaleMessages(target, messages) {
|
|
95
97
|
if (!target || typeof target !== "object") {
|
package/higherOrder/BasePage.js
CHANGED
|
@@ -35,7 +35,10 @@ import { redirectToLogin } from "../store/slices/authSlice";
|
|
|
35
35
|
import {
|
|
36
36
|
VariableEvents
|
|
37
37
|
} from "../types";
|
|
38
|
-
import {
|
|
38
|
+
import {
|
|
39
|
+
clearPageWidgetProxyCache,
|
|
40
|
+
createStateProxy
|
|
41
|
+
} from "../core/proxy-service";
|
|
39
42
|
import {
|
|
40
43
|
accordionExpansionHandler,
|
|
41
44
|
mergeVariablesAndActions,
|
|
@@ -115,6 +118,7 @@ const withPageContext = (WrappedComponent, addPageScript, getVariables, componen
|
|
|
115
118
|
const overriddenPropsRegistryRef = useRef(null);
|
|
116
119
|
const onStartupCompletedRef = useRef(false);
|
|
117
120
|
const lastSyncedLocaleRevisionRef = useRef(-1);
|
|
121
|
+
const appliedLocaleRef = useRef(void 0);
|
|
118
122
|
const [isPageReady, setIsPageReady] = useState(false);
|
|
119
123
|
const pageReady = useCallback(() => {
|
|
120
124
|
setIsPageReady(true);
|
|
@@ -143,7 +147,8 @@ const withPageContext = (WrappedComponent, addPageScript, getVariables, componen
|
|
|
143
147
|
date: i18n.dateFormat,
|
|
144
148
|
time: i18n.timeFormat,
|
|
145
149
|
currency: i18n.currencyCode
|
|
146
|
-
}
|
|
150
|
+
},
|
|
151
|
+
i18n
|
|
147
152
|
}, prefabInfo), props), componentInfo), {
|
|
148
153
|
executeStartup,
|
|
149
154
|
formatters,
|
|
@@ -153,7 +158,6 @@ const withPageContext = (WrappedComponent, addPageScript, getVariables, componen
|
|
|
153
158
|
layoutReady,
|
|
154
159
|
activePageName: componentInfo == null ? void 0 : componentInfo.componentName
|
|
155
160
|
}));
|
|
156
|
-
const initialAppConfig = useMemo(() => appContext, [appContext]);
|
|
157
161
|
useActivePageReactivity({
|
|
158
162
|
componentType: componentInfo == null ? void 0 : componentInfo.componentType,
|
|
159
163
|
appProxy,
|
|
@@ -321,7 +325,7 @@ const withPageContext = (WrappedComponent, addPageScript, getVariables, componen
|
|
|
321
325
|
pageProxy.Variables = Variables;
|
|
322
326
|
pageProxy.Actions = Actions;
|
|
323
327
|
pageProxy.pageReady = pageReady;
|
|
324
|
-
pageProxy.App =
|
|
328
|
+
pageProxy.App = appProxy != null ? appProxy : appContext;
|
|
325
329
|
pageProxy.selectedLocale = i18n.selectedLocale || "en";
|
|
326
330
|
pageProxy.overriddenPropsRegistry = overriddenPropsRegistryRef.current;
|
|
327
331
|
setupVariableSubscriptions(pageVariables.Variables);
|
|
@@ -331,6 +335,7 @@ const withPageContext = (WrappedComponent, addPageScript, getVariables, componen
|
|
|
331
335
|
appProxy.updateActivePage(pageName2);
|
|
332
336
|
appProxy.activePage = pageProxy;
|
|
333
337
|
appProxy.activePageName = pageName2;
|
|
338
|
+
clearPageWidgetProxyCache(appProxy.Widgets);
|
|
334
339
|
Object.setPrototypeOf(appProxy.Widgets, pageProxy.Widgets);
|
|
335
340
|
} else if ((componentInfo == null ? void 0 : componentInfo.componentName) === "Common" && (componentInfo == null ? void 0 : componentInfo.componentType) === "PARTIAL" && appProxy) {
|
|
336
341
|
Object.keys(pageProxy.Widgets).forEach((key) => {
|
|
@@ -567,6 +572,22 @@ const withPageContext = (WrappedComponent, addPageScript, getVariables, componen
|
|
|
567
572
|
async function executeStartup() {
|
|
568
573
|
await (appContext == null ? void 0 : appContext.executeStartAppOperations());
|
|
569
574
|
}
|
|
575
|
+
useEffect(() => {
|
|
576
|
+
const prevLocale = appliedLocaleRef.current;
|
|
577
|
+
appliedLocaleRef.current = i18n.selectedLocale;
|
|
578
|
+
const isLocaleSwitch = prevLocale !== void 0 && prevLocale !== i18n.selectedLocale;
|
|
579
|
+
if (isLocaleSwitch && pageProxyRef.current) {
|
|
580
|
+
pageProxyRef.current.Widgets = {};
|
|
581
|
+
}
|
|
582
|
+
setPageContext((prev) => {
|
|
583
|
+
if (prev.selectedLocale === i18n.selectedLocale) {
|
|
584
|
+
return prev;
|
|
585
|
+
}
|
|
586
|
+
return __spreadValues(__spreadProps(__spreadValues({}, prev), {
|
|
587
|
+
selectedLocale: i18n.selectedLocale
|
|
588
|
+
}), isLocaleSwitch && { Widgets: {} });
|
|
589
|
+
});
|
|
590
|
+
}, [i18n.selectedLocale]);
|
|
570
591
|
const applyLocaleToProxies = useCallback(
|
|
571
592
|
(newAppLocale) => {
|
|
572
593
|
var _a2;
|