@wavemaker-ai/react-runtime 1.0.0-rc.647655 → 1.0.0-rc.647684
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/actions/notification-action.js +3 -3
- package/actions/toast.js +2 -1
- 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/message/index.js +1 -0
- package/components/basic/search/index.d.ts +72 -3
- package/components/basic/search/index.js +84 -32
- package/components/basic/search/props.d.ts +4 -0
- package/components/basic/search/providers.d.ts +1 -1
- package/components/basic/search/providers.js +6 -3
- 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 +13 -5
- package/components/container/layout-grid/index.js +1 -0
- package/components/container/linear-layout/index.js +0 -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/useFormOperations.js +9 -15
- package/components/data/form/base-form/index.js +17 -14
- package/components/data/form/base-form/utils.js +5 -4
- 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-action/index.d.ts +2 -2
- package/components/data/form/form-action/index.js +2 -2
- package/components/data/form/form-context.d.ts +12 -13
- package/components/data/form/form-context.js +4 -6
- package/components/data/form/form-controller/withFormController.js +4 -18
- package/components/data/form/form-field/index.js +10 -6
- package/components/data/list/components/ListItems.js +1 -3
- package/components/data/list/index.js +5 -4
- package/components/data/pagination/hooks/usePagination.js +2 -2
- package/components/data/table/components/RowCells.js +3 -1
- package/components/data/table/components/TableBody.js +2 -1
- package/components/data/table/components/TableDataRow.js +1 -1
- package/components/data/table/components/TableHeader.js +5 -1
- package/components/data/table/hooks/useRowHandlers.d.ts +4 -2
- package/components/data/table/hooks/useRowHandlers.js +23 -11
- package/components/data/table/hooks/useRowSelection.d.ts +1 -1
- package/components/data/table/hooks/useRowSelection.js +93 -74
- package/components/data/table/hooks/useTableColumns.js +5 -5
- package/components/data/table/hooks/useTableState.js +14 -2
- package/components/data/table/index.js +54 -50
- package/components/data/table/props.d.ts +12 -8
- package/components/data/table/utils/buildSelectionColumns.js +31 -31
- package/components/data/table/utils/columnBuilder.js +1 -1
- package/components/data/table/utils/index.d.ts +9 -1
- package/components/data/table/utils/index.js +30 -2
- package/components/data/table/utils/selectionUtils.d.ts +7 -0
- package/components/data/table/utils/selectionUtils.js +28 -1
- package/components/dialogs/dialog-actions/index.js +11 -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/epoch/date/index.js +3 -2
- package/components/input/epoch/date/utils.js +4 -2
- package/components/input/epoch/datetime/index.js +2 -2
- package/components/input/epoch/datetime/props.d.ts +2 -2
- package/components/input/epoch/time/utils.d.ts +1 -1
- package/components/input/epoch/time/utils.js +2 -2
- package/components/input/fileupload/useFileUpload.js +19 -24
- package/components/input/select/index.js +8 -6
- package/components/input/text/index.js +2 -2
- package/components/input/textarea/index.js +41 -16
- package/components/navbar/nav/index.js +10 -5
- package/components/navigation/breadcrumb/index.js +2 -1
- package/components/navigation/popover/index.d.ts +1 -1
- package/components/navigation/popover/index.js +10 -2
- package/components/navigation/popover/props.d.ts +1 -1
- package/components/page/page-content/index.js +24 -4
- package/components/page/page-content/props.d.ts +1 -0
- package/components/page/partial-container/index.js +1 -1
- package/components/wmx/WmxRenderer.d.ts +8 -0
- package/components/wmx/WmxRenderer.js +57 -0
- package/core/appstore.js +1 -1
- package/core/proxy-service.d.ts +16 -1
- package/core/proxy-service.js +39 -12
- package/core/util/index.d.ts +0 -2
- package/core/util/index.js +0 -29
- package/higherOrder/BaseDateTime.js +8 -1
- package/higherOrder/BasePage.js +31 -65
- package/higherOrder/DataNav.js +4 -1
- package/higherOrder/withBaseWrapper.js +3 -4
- package/hooks/useHttp.js +4 -2
- package/hooks/useLayoutSize.js +1 -1
- package/package-lock.json +360 -696
- package/package.json +3 -3
- package/runtime-dynamic/app-initializer.js +2 -1
- package/runtime-dynamic/components/partial-content.js +2 -1
- package/runtime-dynamic/components/wmx-placeholder.d.ts +18 -0
- package/runtime-dynamic/components/wmx-placeholder.js +48 -0
- package/runtime-dynamic/main.js +6 -0
- package/runtime-dynamic/services/compile-render.js +75 -12
- package/store/slices/i18nSlice.d.ts +0 -1
- package/store/slices/i18nSlice.js +0 -2
- package/utils/layoutsize-util.js +12 -7
- package/utils/style-utils.d.ts +6 -0
- package/utils/style-utils.js +10 -0
- 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
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
2
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
6
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -14,6 +16,7 @@ var __spreadValues = (a, b) => {
|
|
|
14
16
|
}
|
|
15
17
|
return a;
|
|
16
18
|
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
17
20
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
21
|
import clsx from "clsx";
|
|
19
22
|
import { WmAppIcon } from "../../../common/WmAppIcon";
|
|
@@ -61,12 +64,13 @@ const WmAccordionPane = memo((Props) => {
|
|
|
61
64
|
}, [props.onLoad]);
|
|
62
65
|
return /* @__PURE__ */ jsxs(
|
|
63
66
|
Accordion.Root,
|
|
64
|
-
{
|
|
67
|
+
__spreadProps(__spreadValues({
|
|
65
68
|
tabIndex: props.tabindex,
|
|
66
69
|
className: clsx(DEFAULT_CLASS, props.className, props.layoutClassName),
|
|
67
70
|
name: props.name,
|
|
68
71
|
show: (_a = props.show) != null ? _a : true,
|
|
69
|
-
hidden: (_b = props.hidden) != null ? _b : false
|
|
72
|
+
hidden: (_b = props.hidden) != null ? _b : false
|
|
73
|
+
}, props.direction ? { direction: props.direction } : {}), {
|
|
70
74
|
children: [
|
|
71
75
|
/* @__PURE__ */ jsx(
|
|
72
76
|
AccordionSummary,
|
|
@@ -111,7 +115,7 @@ const WmAccordionPane = memo((Props) => {
|
|
|
111
115
|
return (_a2 = props.onLoad) == null ? void 0 : _a2.call(props, props);
|
|
112
116
|
}) : props.children }) })
|
|
113
117
|
]
|
|
114
|
-
}
|
|
118
|
+
})
|
|
115
119
|
);
|
|
116
120
|
});
|
|
117
121
|
WmAccordionPane.displayName = "WmAccordionPane";
|
|
@@ -81,6 +81,7 @@ export interface AccordionPanePropsBase {
|
|
|
81
81
|
* Utility layout classes from Studio Auto Layout (merged on the pane root).
|
|
82
82
|
*/
|
|
83
83
|
layoutClassName?: string;
|
|
84
|
+
direction?: string;
|
|
84
85
|
}
|
|
85
86
|
/**
|
|
86
87
|
* Combined props for the WmAccordionPane component, including base WaveMaker props.
|
|
@@ -34,7 +34,8 @@ import {
|
|
|
34
34
|
useEffect,
|
|
35
35
|
useRef,
|
|
36
36
|
useMemo,
|
|
37
|
-
useCallback
|
|
37
|
+
useCallback,
|
|
38
|
+
useState
|
|
38
39
|
} from "react";
|
|
39
40
|
import { clsx } from "clsx";
|
|
40
41
|
import { withBaseWrapper } from "../../higherOrder/withBaseWrapper";
|
|
@@ -43,7 +44,7 @@ import { removeInvalidAttributes } from "../../utils/attr";
|
|
|
43
44
|
import { normalizeBackgroundImage } from "../../utils/style-utils";
|
|
44
45
|
const DEFAULT_CLASS = "app-container";
|
|
45
46
|
const WmContainer = (props) => {
|
|
46
|
-
var _c;
|
|
47
|
+
var _c, _d, _e;
|
|
47
48
|
const _a = props, { listener } = _a, restPartialProps = __objRest(_a, ["listener"]);
|
|
48
49
|
const _b = restPartialProps, {
|
|
49
50
|
className,
|
|
@@ -153,6 +154,9 @@ const WmContainer = (props) => {
|
|
|
153
154
|
const isLoaded = useRef(false);
|
|
154
155
|
const widget_instance = (_c = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _c[name];
|
|
155
156
|
const containerRef = useRef(null);
|
|
157
|
+
const [partialHostKey, setPartialHostKey] = useState(void 0);
|
|
158
|
+
const hostWidgetState = partialHostKey ? (_d = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _d[partialHostKey] : void 0;
|
|
159
|
+
const hostShouldHide = ((_e = hostWidgetState == null ? void 0 : hostWidgetState.show) == null ? void 0 : _e.toString()) === "false";
|
|
156
160
|
const containerStyles = useMemo(() => {
|
|
157
161
|
if (!(styles == null ? void 0 : styles.backgroundImage)) {
|
|
158
162
|
return styles;
|
|
@@ -205,6 +209,9 @@ const WmContainer = (props) => {
|
|
|
205
209
|
viewParent.Widgets[props.name || partialName] = widget || props;
|
|
206
210
|
isLoaded.current = true;
|
|
207
211
|
onLoad == null ? void 0 : onLoad(widget || props);
|
|
212
|
+
if (!props.name && partialName) {
|
|
213
|
+
setPartialHostKey(partialName);
|
|
214
|
+
}
|
|
208
215
|
}
|
|
209
216
|
},
|
|
210
217
|
[onLoad, props.name]
|
|
@@ -217,7 +224,7 @@ const WmContainer = (props) => {
|
|
|
217
224
|
const classNames = (className == null ? void 0 : className.split(" ")) || [];
|
|
218
225
|
return /* @__PURE__ */ jsx(
|
|
219
226
|
"div",
|
|
220
|
-
__spreadProps(__spreadValues(__spreadValues(__spreadValues({
|
|
227
|
+
__spreadProps(__spreadValues(__spreadProps(__spreadValues(__spreadValues(__spreadValues({
|
|
221
228
|
className: clsx(
|
|
222
229
|
{
|
|
223
230
|
[className || ""]: Boolean(className),
|
|
@@ -229,10 +236,11 @@ const WmContainer = (props) => {
|
|
|
229
236
|
),
|
|
230
237
|
"data-widget-id": props["data-widget-id"],
|
|
231
238
|
id,
|
|
232
|
-
hidden: props.hidden
|
|
239
|
+
hidden: props.hidden || hostShouldHide
|
|
233
240
|
}, removeInvalidAttributes(rest)), domEvents), { name }), {
|
|
234
241
|
style: __spreadValues(__spreadValues({}, containerStyles), conditionalstyle),
|
|
235
|
-
ref: containerRef
|
|
242
|
+
ref: containerRef
|
|
243
|
+
}), direction ? { direction } : {}), {
|
|
236
244
|
children: renderPartial ? renderPartial(restPartialProps, handleOnLoad) : children
|
|
237
245
|
})
|
|
238
246
|
);
|
|
@@ -46,7 +46,6 @@ function WmLinearLayout(props) {
|
|
|
46
46
|
} = props;
|
|
47
47
|
const computedStyles = useMemo(() => {
|
|
48
48
|
const flexStyles = __spreadProps(__spreadValues({}, styles), {
|
|
49
|
-
display: "flex",
|
|
50
49
|
flexDirection: direction
|
|
51
50
|
});
|
|
52
51
|
if (direction === "row" || direction === "row-reverse") {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, IconButton } from "@mui/material";
|
|
3
3
|
import DOMPurify from "dompurify";
|
|
4
|
-
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
|
5
|
-
import ExpandLessIcon from "@mui/icons-material/ExpandLess";
|
|
6
4
|
import FullscreenIcon from "@mui/icons-material/Fullscreen";
|
|
7
5
|
import FullscreenExitIcon from "@mui/icons-material/FullscreenExit";
|
|
8
6
|
import CloseIcon from "@mui/icons-material/Close";
|
|
@@ -137,7 +135,7 @@ const PanelHeader = ({
|
|
|
137
135
|
title: `${(_b = (_a = listener == null ? void 0 : listener.appLocale) == null ? void 0 : _a.LABEL_COLLAPSE) != null ? _b : "Collapse"}/${(_d = (_c = listener == null ? void 0 : listener.appLocale) == null ? void 0 : _c.LABEL_EXPAND) != null ? _d : "Expand"}`,
|
|
138
136
|
onClick: onToggleExpand,
|
|
139
137
|
"aria-expanded": isExpanded,
|
|
140
|
-
children:
|
|
138
|
+
children: /* @__PURE__ */ jsx(Box, { component: "i", className: isExpanded ? "wi-minus" : "wi-plus" })
|
|
141
139
|
}
|
|
142
140
|
),
|
|
143
141
|
enablefullscreen && /* @__PURE__ */ jsx(
|
|
@@ -39,6 +39,7 @@ declare const _default: React.ComponentType<{
|
|
|
39
39
|
onHeaderClick?: (event: React.SyntheticEvent, props: WmTabPaneProps, paneIndex: number) => void;
|
|
40
40
|
renderPartial?: (props: WmTabPaneProps, onLoad?: (widget?: WmTabPaneProps) => void) => React.ReactNode;
|
|
41
41
|
layoutClassName?: string;
|
|
42
|
+
direction?: string;
|
|
42
43
|
standalone?: boolean;
|
|
43
44
|
ref?: React.RefObject<HTMLElement> | React.RefObject<null>;
|
|
44
45
|
animation?: string;
|
|
@@ -98,7 +98,7 @@ const WmTabpane = (props) => {
|
|
|
98
98
|
}, [name, headerProps, updatePaneHeader]);
|
|
99
99
|
return /* @__PURE__ */ jsx(
|
|
100
100
|
Tabs.Panel,
|
|
101
|
-
__spreadProps(__spreadValues({
|
|
101
|
+
__spreadProps(__spreadValues(__spreadValues({
|
|
102
102
|
value: index,
|
|
103
103
|
keepMounted: true,
|
|
104
104
|
className: clsx("tab-pane", "wm-tab-pane-root", layoutClassName, {
|
|
@@ -113,7 +113,7 @@ const WmTabpane = (props) => {
|
|
|
113
113
|
style: props == null ? void 0 : props.styles,
|
|
114
114
|
"data-pane-name": name,
|
|
115
115
|
title: props == null ? void 0 : props.title
|
|
116
|
-
}, { name }), {
|
|
116
|
+
}, { name }), props.direction ? { direction: props.direction } : {}), {
|
|
117
117
|
children: /* @__PURE__ */ jsx("div", { className: "tab-body", "data-widget-id": props["data-widget-id"], children: renderPartial ? renderPartial(
|
|
118
118
|
props,
|
|
119
119
|
() => {
|
|
@@ -78,6 +78,7 @@ export interface TabPanePropsBase {
|
|
|
78
78
|
* Utility layout classes from Studio Auto Layout (merged on the outer tab-pane wrapper).
|
|
79
79
|
*/
|
|
80
80
|
layoutClassName?: string;
|
|
81
|
+
direction?: string;
|
|
81
82
|
}
|
|
82
83
|
/**
|
|
83
84
|
* Combined props for the WmTabPane component, including base WaveMaker props.
|
|
@@ -97,6 +97,7 @@ const WmWizardComponent = memo(
|
|
|
97
97
|
const formRefs = useRef({});
|
|
98
98
|
const stepContainerRefs = useRef({});
|
|
99
99
|
const navIndexRef = useRef(-1);
|
|
100
|
+
const loadedStepNameRef = useRef(null);
|
|
100
101
|
const [formReady, setFormReady] = useState(false);
|
|
101
102
|
const parentFormContext = useParentFormData();
|
|
102
103
|
const isInsideOuterForm = !!parentFormContext && Object.keys(parentFormContext).length > 0;
|
|
@@ -469,12 +470,6 @@ const WmWizardComponent = memo(
|
|
|
469
470
|
});
|
|
470
471
|
})
|
|
471
472
|
);
|
|
472
|
-
setTimeout(() => {
|
|
473
|
-
if (step.onLoad) {
|
|
474
|
-
const stepIndex = visibleSteps.findIndex((s) => s.name === step.name);
|
|
475
|
-
step.onLoad(step, stepIndex);
|
|
476
|
-
}
|
|
477
|
-
}, 100);
|
|
478
473
|
} else {
|
|
479
474
|
const nextValidStep = getNextValidStep(0, visibleSteps);
|
|
480
475
|
if (nextValidStep) {
|
|
@@ -583,10 +578,16 @@ const WmWizardComponent = memo(
|
|
|
583
578
|
visibleSteps
|
|
584
579
|
]);
|
|
585
580
|
useEffect(() => {
|
|
586
|
-
if (currentStep == null ? void 0 : currentStep.onLoad)
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
581
|
+
if (!(currentStep == null ? void 0 : currentStep.onLoad) || loadedStepNameRef.current === currentStep.name) return;
|
|
582
|
+
const step = currentStep;
|
|
583
|
+
const timer = setTimeout(() => {
|
|
584
|
+
var _a;
|
|
585
|
+
if (loadedStepNameRef.current === step.name) return;
|
|
586
|
+
loadedStepNameRef.current = step.name;
|
|
587
|
+
(_a = step.onLoad) == null ? void 0 : _a.call(step, step, currentStepIndex);
|
|
588
|
+
}, 100);
|
|
589
|
+
return () => clearTimeout(timer);
|
|
590
|
+
}, [currentStep == null ? void 0 : currentStep.name, currentStep == null ? void 0 : currentStep.onLoad, currentStepIndex]);
|
|
590
591
|
useEffect(() => {
|
|
591
592
|
if (type === "dynamic" && dataset.length > 0 && steps.length === 0) {
|
|
592
593
|
const dynamicSteps = createDynamicSteps(dataset);
|
|
@@ -44,6 +44,7 @@ const getStepByIndex = (index, visibleSteps) => {
|
|
|
44
44
|
};
|
|
45
45
|
const updateStepFocus = () => {
|
|
46
46
|
setTimeout(() => {
|
|
47
|
+
if (typeof document === "undefined") return;
|
|
47
48
|
const currentStepElement = document.querySelector(
|
|
48
49
|
".MuiStepButton-root[aria-current='step']"
|
|
49
50
|
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useState, useCallback } from "react";
|
|
2
|
+
import { getFormFieldEntries } from "../../../../../core/proxy-service";
|
|
2
3
|
import { cleanNullValues } from "../utils";
|
|
3
4
|
import { usesPrefixedFields } from "../props";
|
|
4
5
|
function useFormOperations({
|
|
@@ -22,25 +23,18 @@ function useFormOperations({
|
|
|
22
23
|
const formreset = useCallback(async () => {
|
|
23
24
|
const cleanedData = {};
|
|
24
25
|
const formNamePrefix = `${formName}.`;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (formfields[key].formName !== formName) return;
|
|
26
|
+
getFormFieldEntries(formfields).forEach(({ key, field }) => {
|
|
27
|
+
if (field.formName !== formName) return;
|
|
28
28
|
if (key.endsWith("_formWidget")) return;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
} else {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (formfields[key].readonly || formfields[key].readOnly || formfields[key].disabled) {
|
|
38
|
-
cleanedData[fieldKey] = formfields[key].defaultvalue || formfields[key].value;
|
|
29
|
+
if (hasPrefixedFields && !key.startsWith(formNamePrefix)) return;
|
|
30
|
+
const fieldKey = hasPrefixedFields ? key.slice(formNamePrefix.length) : key;
|
|
31
|
+
if (field.readonly || field.readOnly || field.disabled) {
|
|
32
|
+
cleanedData[fieldKey] = field.defaultvalue || field.value;
|
|
39
33
|
} else {
|
|
40
34
|
cleanedData[fieldKey] = "";
|
|
35
|
+
field.datavalue = "";
|
|
41
36
|
}
|
|
42
|
-
|
|
43
|
-
if (widgetFormType === "live-filter" && isRange) {
|
|
37
|
+
if (widgetFormType === "live-filter" && (field.isRange === true || field.isRange === "true")) {
|
|
44
38
|
cleanedData[`${fieldKey}_maxWidget`] = "";
|
|
45
39
|
}
|
|
46
40
|
});
|
|
@@ -50,6 +50,7 @@ import {
|
|
|
50
50
|
usesPrefixedFields
|
|
51
51
|
} from "./hooks";
|
|
52
52
|
import { useWidgetProxy } from "../../../../context/WidgetProvider";
|
|
53
|
+
import { getFormFieldList } from "../../../../core/proxy-service";
|
|
53
54
|
import {
|
|
54
55
|
useAppNotificationAction,
|
|
55
56
|
useNotifyApp
|
|
@@ -357,6 +358,11 @@ const BaseForm = (WrappedComponent) => {
|
|
|
357
358
|
widgetFormType: props["form-type"],
|
|
358
359
|
debouncedFilter
|
|
359
360
|
});
|
|
361
|
+
const formreset = useCallback(async () => {
|
|
362
|
+
var _a2;
|
|
363
|
+
await formresetFn();
|
|
364
|
+
(_a2 = props.onReset) == null ? void 0 : _a2.call(props);
|
|
365
|
+
}, [formresetFn, props.onReset]);
|
|
360
366
|
const clearFilter = useMemo(
|
|
361
367
|
() => handleSubmit((data, e) => {
|
|
362
368
|
e == null ? void 0 : e.preventDefault();
|
|
@@ -380,7 +386,6 @@ const BaseForm = (WrappedComponent) => {
|
|
|
380
386
|
setShowViewMode(true);
|
|
381
387
|
formresetFn();
|
|
382
388
|
}, [setShowViewMode, props.cancel, formresetFn]);
|
|
383
|
-
const getFieldValue = useCallback((fieldName) => watch(fieldName), [watch]);
|
|
384
389
|
const highlightInvalidFields = useCallback(async () => {
|
|
385
390
|
await validateFieldsOnSubmit();
|
|
386
391
|
}, [validateFieldsOnSubmit]);
|
|
@@ -454,16 +459,13 @@ const BaseForm = (WrappedComponent) => {
|
|
|
454
459
|
const registerFn = parentFormDataContext == null ? void 0 : parentFormDataContext.registerChildField;
|
|
455
460
|
if (!registerFn || !formName) return;
|
|
456
461
|
const widgetFormFields = getWidgetFormFields(listener, formName);
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
if (
|
|
460
|
-
const typedWidget = widget;
|
|
461
|
-
const formKey = (typedWidget == null ? void 0 : typedWidget.formKey) || (typedWidget == null ? void 0 : typedWidget.fieldName) || key;
|
|
462
|
-
const fieldName = (typedWidget == null ? void 0 : typedWidget.fieldName) || key;
|
|
462
|
+
getFormFieldList(widgetFormFields || formfields).forEach((field) => {
|
|
463
|
+
const fieldName = (field == null ? void 0 : field.fieldName) || (field == null ? void 0 : field.name);
|
|
464
|
+
if (!fieldName) return;
|
|
463
465
|
registerFn({
|
|
464
466
|
childFormName: formName,
|
|
465
|
-
widget,
|
|
466
|
-
formKey,
|
|
467
|
+
widget: field,
|
|
468
|
+
formKey: (field == null ? void 0 : field.formKey) || fieldName,
|
|
467
469
|
fieldName
|
|
468
470
|
});
|
|
469
471
|
});
|
|
@@ -532,8 +534,7 @@ const BaseForm = (WrappedComponent) => {
|
|
|
532
534
|
useEffect(() => {
|
|
533
535
|
if (!props.onDataSourceChange || !formName) return;
|
|
534
536
|
if (onDataSourceChangeFiredRef.current) return;
|
|
535
|
-
const
|
|
536
|
-
const currentFields = Object.keys(Widgets).filter((key) => !key.includes("formWidget") && Widgets[key]).map((key) => Widgets[key]);
|
|
537
|
+
const currentFields = getFormFieldList(formProxy == null ? void 0 : formProxy.formfields);
|
|
537
538
|
if (currentFields.length > 0) {
|
|
538
539
|
onDataSourceChangeFiredRef.current = true;
|
|
539
540
|
props.onDataSourceChange(currentFields);
|
|
@@ -588,7 +589,8 @@ const BaseForm = (WrappedComponent) => {
|
|
|
588
589
|
showViewMode,
|
|
589
590
|
formdata: computedFormdata,
|
|
590
591
|
submit,
|
|
591
|
-
formreset
|
|
592
|
+
formreset,
|
|
593
|
+
setValue
|
|
592
594
|
}),
|
|
593
595
|
[
|
|
594
596
|
updateFormData,
|
|
@@ -608,13 +610,14 @@ const BaseForm = (WrappedComponent) => {
|
|
|
608
610
|
showViewMode,
|
|
609
611
|
computedFormdata,
|
|
610
612
|
submit,
|
|
611
|
-
|
|
613
|
+
formreset,
|
|
614
|
+
setValue
|
|
612
615
|
]
|
|
613
616
|
);
|
|
614
617
|
const conditionalProps = __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, props.target && { target: props.target }), props.method && { method: props.method }), props.encType && { encType: props.encType }), props.action && { action: props.action });
|
|
615
618
|
const formProps = __spreadProps(__spreadValues(__spreadValues({}, props), conditionalProps), {
|
|
616
619
|
submit,
|
|
617
|
-
formreset
|
|
620
|
+
formreset,
|
|
618
621
|
formfields,
|
|
619
622
|
formWidgets: formfields,
|
|
620
623
|
headerActions,
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
some
|
|
30
30
|
} from "lodash-es";
|
|
31
31
|
import { REGEX } from "./constant";
|
|
32
|
+
import { defineFieldAlias } from "../../../../core/proxy-service";
|
|
32
33
|
let userAgent = "";
|
|
33
34
|
if (typeof window !== "undefined") {
|
|
34
35
|
userAgent = window.navigator.userAgent;
|
|
@@ -272,10 +273,10 @@ const registerChildFieldInWidget = (listener, formName, data) => {
|
|
|
272
273
|
const parentFormContext = listener.Widgets[formName];
|
|
273
274
|
parentFormContext.formfields = parentFormContext.formfields || {};
|
|
274
275
|
parentFormContext.formWidgets = parentFormContext.formWidgets || {};
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
276
|
+
const { formfields, formWidgets } = parentFormContext;
|
|
277
|
+
formfields[formKey] = widget;
|
|
278
|
+
formWidgets[fieldName] = widget;
|
|
279
|
+
defineFieldAlias(`${fieldName}_formWidget`, widget, formfields, formWidgets);
|
|
279
280
|
};
|
|
280
281
|
export {
|
|
281
282
|
cleanNullValues,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FormFieldMetadata } from "./props";
|
|
2
|
+
export type WmxFormFieldProps = Record<string, unknown> & {
|
|
3
|
+
class?: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
};
|
|
6
|
+
type WmxDynamicFormFieldProps = {
|
|
7
|
+
field: FormFieldMetadata;
|
|
8
|
+
fieldProps: WmxFormFieldProps;
|
|
9
|
+
};
|
|
10
|
+
export declare const WmxDynamicFormField: ({ field, fieldProps }: WmxDynamicFormFieldProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
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));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import { jsx } from "react/jsx-runtime";
|
|
33
|
+
import { useEffect, useMemo, useState } from "react";
|
|
34
|
+
import WmText from "../../../input/text";
|
|
35
|
+
import withFormController from "../form-controller/withFormController";
|
|
36
|
+
import { loadWmxComponent, getWmxComponentName } from "../../../../utils/wmx.utils";
|
|
37
|
+
const WmxDynamicFormField = ({ field, fieldProps }) => {
|
|
38
|
+
var _b;
|
|
39
|
+
const componentName = getWmxComponentName(String((field == null ? void 0 : field.widget) || ""));
|
|
40
|
+
const _a = fieldProps, { class: className } = _a, restProps = __objRest(_a, ["class"]);
|
|
41
|
+
const resolvedClassName = className || fieldProps.className;
|
|
42
|
+
const [RawComponent, setRawComponent] = useState(null);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (!componentName) return;
|
|
45
|
+
let isActive = true;
|
|
46
|
+
loadWmxComponent(componentName).then((component) => {
|
|
47
|
+
if (isActive) {
|
|
48
|
+
setRawComponent(component);
|
|
49
|
+
}
|
|
50
|
+
}).catch((e) => {
|
|
51
|
+
console.error(e);
|
|
52
|
+
});
|
|
53
|
+
return () => {
|
|
54
|
+
isActive = false;
|
|
55
|
+
};
|
|
56
|
+
}, [componentName]);
|
|
57
|
+
const EnhancedWmxComponent = useMemo(() => {
|
|
58
|
+
if (!RawComponent) return null;
|
|
59
|
+
return withFormController(RawComponent);
|
|
60
|
+
}, [RawComponent]);
|
|
61
|
+
if (!EnhancedWmxComponent) {
|
|
62
|
+
return /* @__PURE__ */ jsx(WmText, __spreadProps(__spreadValues({ name: field == null ? void 0 : field.name }, restProps), { className: resolvedClassName }));
|
|
63
|
+
}
|
|
64
|
+
const dataset = (_b = field == null ? void 0 : field.dataset) != null ? _b : fieldProps == null ? void 0 : fieldProps.dataset;
|
|
65
|
+
return /* @__PURE__ */ jsx(
|
|
66
|
+
EnhancedWmxComponent,
|
|
67
|
+
__spreadProps(__spreadValues({
|
|
68
|
+
componentname: componentName
|
|
69
|
+
}, restProps), {
|
|
70
|
+
className: resolvedClassName,
|
|
71
|
+
dataset
|
|
72
|
+
})
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
export {
|
|
76
|
+
WmxDynamicFormField
|
|
77
|
+
};
|
|
@@ -42,7 +42,12 @@ import WmLabel from "../../../basic/label";
|
|
|
42
42
|
import WmFormField from "../form-field";
|
|
43
43
|
import { updateMetadata } from "./utils";
|
|
44
44
|
import { COMPONENT_MAP } from "./constant";
|
|
45
|
+
import { WmxDynamicFormField } from "./WmxDynamicFormField";
|
|
45
46
|
const DEFAULT_FIELD_CLASS = "app-dynamic-form-field";
|
|
47
|
+
const isWmxComponent = (field) => {
|
|
48
|
+
var _a;
|
|
49
|
+
return (_a = field == null ? void 0 : field.widget) == null ? void 0 : _a.includes("wmx-");
|
|
50
|
+
};
|
|
46
51
|
function DynamicForm(props) {
|
|
47
52
|
const {
|
|
48
53
|
metadata,
|
|
@@ -74,7 +79,6 @@ function DynamicForm(props) {
|
|
|
74
79
|
return Math.floor(12 / columns);
|
|
75
80
|
};
|
|
76
81
|
const renderFormField = (field) => {
|
|
77
|
-
const ComponentToRender = COMPONENT_MAP[field.widget] || WmText;
|
|
78
82
|
const fieldProps = __spreadValues(__spreadProps(__spreadValues({}, field), {
|
|
79
83
|
className: field.class,
|
|
80
84
|
listener,
|
|
@@ -84,8 +88,15 @@ function DynamicForm(props) {
|
|
|
84
88
|
onChangeHandler: formContext.onChangeHandler
|
|
85
89
|
});
|
|
86
90
|
const _a = fieldProps, { class: className } = _a, restProps = __objRest(_a, ["class"]);
|
|
91
|
+
if (isWmxComponent(field)) {
|
|
92
|
+
return handleWmxFormFieldRendering(field, fieldProps);
|
|
93
|
+
}
|
|
94
|
+
const ComponentToRender = COMPONENT_MAP[field.widget] || WmText;
|
|
87
95
|
return /* @__PURE__ */ jsx(ComponentToRender, __spreadProps(__spreadValues({}, restProps), { className: className || fieldProps.className }));
|
|
88
96
|
};
|
|
97
|
+
const handleWmxFormFieldRendering = (field, fieldProps) => {
|
|
98
|
+
return /* @__PURE__ */ jsx(WmxDynamicFormField, { field, fieldProps });
|
|
99
|
+
};
|
|
89
100
|
const renderFormFieldWithWrapper = (field) => {
|
|
90
101
|
const columnWidth = getColumnWidth(field.columnwidth);
|
|
91
102
|
return /* @__PURE__ */ jsx(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare const WmFormActionsStandalone: import("react").ComponentType<{
|
|
2
|
-
onClick: ((event: any) => void) & ((event?: React.MouseEvent<HTMLElement>, widget?: Record<string, any>, newVal?: string | number | null, oldVal?: string | number | null) => void);
|
|
2
|
+
onClick: ((event: any, widget?: any) => void) & ((event?: React.MouseEvent<HTMLElement>, widget?: Record<string, any>, newVal?: string | number | null, oldVal?: string | number | null) => void);
|
|
3
3
|
formKey: string;
|
|
4
4
|
name: string;
|
|
5
5
|
displayName: string;
|
|
@@ -75,7 +75,7 @@ export { WmFormActionsStandalone as WmFormAction };
|
|
|
75
75
|
* @param props - {@link WmFormActionsProps}
|
|
76
76
|
*/
|
|
77
77
|
declare const _default: import("react").ComponentType<{
|
|
78
|
-
onClick: ((event: any) => void) & ((event?: React.MouseEvent<HTMLElement>, widget?: Record<string, any>, newVal?: string | number | null, oldVal?: string | number | null) => void);
|
|
78
|
+
onClick: ((event: any, widget?: any) => void) & ((event?: React.MouseEvent<HTMLElement>, widget?: Record<string, any>, newVal?: string | number | null, oldVal?: string | number | null) => void);
|
|
79
79
|
formKey: string;
|
|
80
80
|
name: string;
|
|
81
81
|
displayName: string;
|
|
@@ -59,7 +59,7 @@ const WmFormActions = memo((props) => {
|
|
|
59
59
|
const isheaderaction = position === "header" && !headeraction;
|
|
60
60
|
const formRef = useFormContext();
|
|
61
61
|
const handleClick = useCallback(
|
|
62
|
-
(event) => {
|
|
62
|
+
(event, widget) => {
|
|
63
63
|
var _a2, _b2, _c;
|
|
64
64
|
if (props.standalone) {
|
|
65
65
|
if (type === "submit") {
|
|
@@ -68,7 +68,7 @@ const WmFormActions = memo((props) => {
|
|
|
68
68
|
(_b2 = formRef == null ? void 0 : formRef.formreset) == null ? void 0 : _b2.call(formRef);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
(_c = props.onClick) == null ? void 0 : _c.call(props, event);
|
|
71
|
+
(_c = props.onClick) == null ? void 0 : _c.call(props, event, widget);
|
|
72
72
|
},
|
|
73
73
|
[formRef, props.onClick, type]
|
|
74
74
|
);
|
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import type { UseFormSetValue } from "react-hook-form";
|
|
2
3
|
export interface FormContextValue {
|
|
3
|
-
updateFormData?: (data: any) => void;
|
|
4
4
|
control?: any;
|
|
5
5
|
watch?: any;
|
|
6
|
-
registerFormField?: (formKey: string, fieldName: string, fieldInstance: any) => void;
|
|
7
|
-
registerFormWidget?: (widgetName: string, widgetInstance: any) => void;
|
|
8
|
-
registerHeaderAction?: (actionName: string, action: any) => void;
|
|
9
|
-
onChangeHandler?: (fieldName: string, value: any) => void;
|
|
10
|
-
getFieldValue?: (fieldName: string) => any;
|
|
11
6
|
trigger?: any;
|
|
12
7
|
errors?: any;
|
|
13
|
-
|
|
8
|
+
setValue?: UseFormSetValue<any>;
|
|
9
|
+
submitCount?: number;
|
|
10
|
+
submit?: (e?: any) => Promise<boolean | undefined>;
|
|
11
|
+
formreset?: () => Promise<void>;
|
|
12
|
+
updateFormData?: (data: any) => void;
|
|
13
|
+
onChangeHandler?: (fieldName: string, value: any) => void;
|
|
14
|
+
registerFormWidget?: (widgetName: string, widgetInstance: any) => void;
|
|
15
|
+
registerHeaderAction?: (actionName: string, action: any) => void;
|
|
14
16
|
captionposition?: string;
|
|
15
17
|
captionCls?: string;
|
|
16
18
|
widgetCls?: string;
|
|
17
|
-
|
|
19
|
+
itemsPerRow?: string;
|
|
18
20
|
isViewMode?: boolean;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
name?: string;
|
|
22
|
+
validationtype?: string;
|
|
21
23
|
ref?: any;
|
|
22
|
-
itemsPerRow?: string;
|
|
23
|
-
submit?: (e?: any) => Promise<boolean | undefined>;
|
|
24
|
-
formreset?: () => Promise<void>;
|
|
25
24
|
}
|
|
26
25
|
declare const FormContext: React.Context<FormContextValue>;
|
|
27
26
|
/**
|
|
@@ -18,17 +18,15 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
import { jsx } from "react/jsx-runtime";
|
|
21
|
-
import { createContext, useContext } from "react";
|
|
21
|
+
import { createContext, useContext, useMemo } from "react";
|
|
22
22
|
const FormContext = createContext(null);
|
|
23
23
|
const ParentFormDataContext = createContext(null);
|
|
24
24
|
const useParentFormData = () => useContext(ParentFormDataContext);
|
|
25
25
|
const FormProvider = ({ value, isViewMode, children }) => {
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
const useFormContext = () => {
|
|
29
|
-
const context = useContext(FormContext);
|
|
30
|
-
return context;
|
|
26
|
+
const contextValue = useMemo(() => __spreadProps(__spreadValues({}, value), { isViewMode }), [value, isViewMode]);
|
|
27
|
+
return /* @__PURE__ */ jsx(FormContext.Provider, { value: contextValue, children });
|
|
31
28
|
};
|
|
29
|
+
const useFormContext = () => useContext(FormContext);
|
|
32
30
|
const useIsViewMode = () => {
|
|
33
31
|
const context = useFormContext();
|
|
34
32
|
return context == null ? void 0 : context.isViewMode;
|