@wavemaker-ai/react-runtime 1.0.0-rc.317 → 1.0.0-rc.319
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/advanced/carousel/index.d.ts +2 -0
- package/components/advanced/carousel/template.d.ts +2 -0
- package/components/advanced/login/index.d.ts +2 -0
- package/components/advanced/marquee/index.d.ts +2 -0
- package/components/auth/RoleAuthGuard.js +1 -0
- package/components/basic/anchor/index.d.ts +2 -0
- package/components/basic/anchor/index.js +1 -1
- package/components/basic/audio/index.d.ts +2 -0
- package/components/basic/html/index.d.ts +2 -0
- package/components/basic/icon/index.d.ts +2 -0
- package/components/basic/iframe/index.d.ts +2 -0
- package/components/basic/label/index.d.ts +2 -0
- package/components/basic/label/index.js +17 -3
- package/components/basic/picture/index.d.ts +2 -0
- package/components/basic/picture/index.js +20 -1
- package/components/basic/progress-bar/index.d.ts +2 -0
- package/components/basic/progress-circle/index.d.ts +2 -0
- package/components/basic/progress-circle/index.js +2 -1
- package/components/basic/richtexteditor/index.d.ts +4 -0
- package/components/basic/richtexteditor/index.js +16 -15
- package/components/basic/search/index.d.ts +4 -0
- package/components/basic/spinner/index.d.ts +2 -0
- package/components/basic/tile/index.d.ts +2 -0
- package/components/basic/tree/index.d.ts +2 -0
- package/components/basic/video/index.d.ts +2 -0
- package/components/chart/index.d.ts +2 -0
- package/components/common/index.d.ts +2 -0
- package/components/common/index.js +5 -1
- package/components/common/wm-skeleton.d.ts +95 -0
- package/components/common/wm-skeleton.js +346 -0
- package/components/container/accordion/accordion-pane/index.d.ts +2 -0
- package/components/container/accordion/index.d.ts +4 -0
- package/components/container/accordion/index.js +23 -1
- package/components/container/accordion/props.d.ts +10 -0
- package/components/container/index.d.ts +2 -0
- package/components/container/index.js +2 -4
- package/components/container/layout-grid/grid-column/index.d.ts +2 -0
- package/components/container/layout-grid/grid-row/index.d.ts +2 -0
- package/components/container/layout-grid/index.d.ts +2 -0
- package/components/container/linear-layout/index.d.ts +2 -0
- package/components/container/linear-layout/linear-layout-item/index.d.ts +2 -0
- package/components/container/panel/index.d.ts +2 -0
- package/components/container/repeat-template/index.d.ts +2 -0
- package/components/container/tabs/index.d.ts +4 -0
- package/components/container/tabs/index.js +23 -1
- package/components/container/tabs/props.d.ts +10 -0
- package/components/container/tabs/tab-pane/index.d.ts +2 -0
- package/components/container/wizard/index.d.ts +8 -0
- package/components/container/wizard/index.js +27 -3
- package/components/container/wizard/props.d.ts +10 -0
- package/components/container/wizard/wizard-step/index.d.ts +2 -0
- package/components/data/card/card-actions/index.d.ts +2 -0
- package/components/data/card/card-content/index.d.ts +2 -0
- package/components/data/card/card-footer/index.d.ts +2 -0
- package/components/data/card/index.d.ts +2 -0
- package/components/data/card/index.js +12 -6
- package/components/data/form/base-form/hooks/useFormOperations.d.ts +1 -1
- package/components/data/form/base-form/hooks/useFormOperations.js +3 -3
- package/components/data/form/base-form/index.js +30 -25
- package/components/data/form/base-form/props.d.ts +1 -1
- package/components/data/form/dynamic-fields/index.js +3 -0
- package/components/data/form/form-action/index.d.ts +4 -0
- package/components/data/form/form-controller/hooks/index.js +2 -1
- package/components/data/form/form-controller/withFormController.js +11 -16
- package/components/data/form/form-field/base-field.js +0 -5
- package/components/data/form/form-field/index.js +99 -13
- package/components/data/form/form-field/props.d.ts +8 -0
- package/components/data/form/index.js +13 -0
- package/components/data/list/index.d.ts +7 -0
- package/components/data/list/index.js +18 -0
- package/components/data/list/props.d.ts +7 -0
- package/components/data/table/components/RowCells.js +4 -1
- package/components/data/table/hooks/useDynamicColumns.js +3 -1
- package/components/data/table/hooks/useResponsiveColumns.d.ts +2 -0
- package/components/data/table/index.d.ts +8 -0
- package/components/data/table/index.js +15 -0
- package/components/data/table/live-table/index.d.ts +2 -0
- package/components/data/table/props.d.ts +10 -0
- package/components/data/table/table-action/index.d.ts +2 -0
- package/components/data/table/table-column/index.d.ts +2 -0
- package/components/data/table/table-row/index.d.ts +2 -0
- package/components/data/table/table-row-action/index.d.ts +2 -0
- package/components/data/table/utils/index.d.ts +2 -0
- package/components/data/table/utils/index.js +17 -3
- package/components/dialogs/alert-dialog/index.d.ts +4 -0
- package/components/dialogs/confirm-dialog/index.d.ts +4 -0
- package/components/dialogs/dialog/index.d.ts +4 -0
- package/components/dialogs/dialog-actions/index.d.ts +2 -0
- package/components/dialogs/dialog-body/index.d.ts +2 -0
- package/components/dialogs/dialog-content/index.d.ts +2 -0
- package/components/dialogs/dialog-header/index.d.ts +2 -0
- package/components/dialogs/iframe-dialog/index.d.ts +4 -0
- package/components/dialogs/login-dialog/index.d.ts +4 -0
- package/components/dialogs/page-dialog/index.d.ts +4 -0
- package/components/form/button/index.d.ts +2 -0
- package/components/form/button/index.js +10 -1
- package/components/form/button-group/index.d.ts +2 -0
- package/components/input/calendar/index.d.ts +4 -0
- package/components/input/calendar/index.js +2 -1
- package/components/input/chips/index.d.ts +4 -0
- package/components/input/color-picker/index.d.ts +4 -0
- package/components/input/color-picker/index.js +18 -7
- package/components/input/composite/index.d.ts +2 -0
- package/components/input/currency/index.d.ts +4 -0
- package/components/input/default/checkbox/index.d.ts +4 -0
- package/components/input/default/checkboxset/index.d.ts +4 -0
- package/components/input/default/checkboxset/index.js +7 -5
- package/components/input/default/radioset/index.d.ts +4 -0
- package/components/input/default/radioset/index.js +2 -1
- package/components/input/default/switch/index.d.ts +4 -0
- package/components/input/default/switch/index.js +17 -13
- package/components/input/epoch/date/index.d.ts +2 -0
- package/components/input/epoch/date/index.js +30 -14
- package/components/input/epoch/datetime/index.d.ts +2 -0
- package/components/input/epoch/datetime/index.js +12 -8
- package/components/input/epoch/time/index.d.ts +2 -0
- package/components/input/epoch/time/index.js +21 -15
- package/components/input/fileupload/index.d.ts +2 -0
- package/components/input/number/index.d.ts +4 -0
- package/components/input/number/index.js +4 -3
- package/components/input/rating/index.d.ts +4 -0
- package/components/input/select/index.d.ts +4 -0
- package/components/input/slider/index.d.ts +4 -0
- package/components/input/slider/index.js +4 -2
- package/components/input/text/index.d.ts +4 -0
- package/components/input/text/index.js +16 -8
- package/components/input/textarea/index.d.ts +4 -0
- package/components/input/upload/index.d.ts +4 -0
- package/components/input/upload/index.js +6 -4
- package/components/navbar/index.d.ts +2 -0
- package/components/navbar/nav/index.d.ts +2 -0
- package/components/navbar/nav-item/index.d.ts +2 -0
- package/components/navigation/breadcrumb/index.d.ts +2 -0
- package/components/navigation/menu/index.d.ts +2 -0
- package/components/navigation/menu/index.js +2 -2
- package/components/navigation/popover/index.d.ts +2 -0
- package/components/page/partial/index.d.ts +2 -0
- package/context/AppContext.d.ts +2 -0
- package/context/AppContext.js +20 -1
- package/context/WidgetProvider.js +0 -3
- package/core/proxy-service.d.ts +2 -0
- package/core/proxy-service.js +25 -0
- package/higherOrder/BaseApp.js +1 -3
- package/higherOrder/BaseAppProps.d.ts +1 -1
- package/higherOrder/BasePage.js +4 -2
- package/higherOrder/props.d.ts +10 -0
- package/higherOrder/withBaseWrapper.js +3 -0
- package/hooks/useAuth.js +3 -0
- package/hooks/useLayoutSize.d.ts +6 -0
- package/hooks/useLayoutSize.js +12 -0
- package/package-lock.json +225 -199
- package/package.json +3 -3
- package/runtime-dynamic/components/use-dynamic-component.js +6 -11
- package/runtime-dynamic/main.js +1 -3
- package/runtime-dynamic/services/component-ref-provider.d.ts +1 -1
- package/runtime-dynamic/services/component-ref-provider.js +14 -11
- package/runtime-dynamic/services/resource-manager.js +10 -4
- package/runtime-dynamic/services/script-executor.js +4 -1
- package/runtime-dynamic/services/variable-registry.js +3 -0
- package/utils/attr.js +0 -1
- package/utils/format-util.js +2 -3
- package/utils/form-state.util.d.ts +0 -62
- package/utils/form-state.util.js +0 -109
|
@@ -51,9 +51,14 @@ import { getFormData } from "../../../utils/form-utils";
|
|
|
51
51
|
import { useParentFormData } from "../../data/form/form-context";
|
|
52
52
|
import isEqual from "lodash-es/isEqual";
|
|
53
53
|
import withStandalone from "../../../higherOrder/withStandalone";
|
|
54
|
+
import {
|
|
55
|
+
WmSkeleton,
|
|
56
|
+
SKELETON_REGISTRY,
|
|
57
|
+
shouldShowSkeleton
|
|
58
|
+
} from "../../common/wm-skeleton";
|
|
54
59
|
const DEFAULT_CLS = "app-wizard panel clearfix";
|
|
55
60
|
const BODY_CLASS = "app-wizard-body panel-body";
|
|
56
|
-
const
|
|
61
|
+
const WmWizardComponent = memo(
|
|
57
62
|
(props) => {
|
|
58
63
|
const {
|
|
59
64
|
listener,
|
|
@@ -818,7 +823,11 @@ const WmWizard = memo(
|
|
|
818
823
|
"donebtnlabel",
|
|
819
824
|
"cancelbtnlabel",
|
|
820
825
|
"children",
|
|
821
|
-
"hidden"
|
|
826
|
+
"hidden",
|
|
827
|
+
"loading",
|
|
828
|
+
"showSkeleton",
|
|
829
|
+
"skeletonRows",
|
|
830
|
+
"skeletonColumns"
|
|
822
831
|
];
|
|
823
832
|
return keys.every((key) => {
|
|
824
833
|
if (key === "children") {
|
|
@@ -828,8 +837,23 @@ const WmWizard = memo(
|
|
|
828
837
|
});
|
|
829
838
|
}
|
|
830
839
|
);
|
|
831
|
-
const
|
|
840
|
+
const WmWizard = (props) => {
|
|
841
|
+
if (shouldShowSkeleton(props.loading, props.showSkeleton)) {
|
|
842
|
+
return /* @__PURE__ */ jsx(
|
|
843
|
+
WmSkeleton,
|
|
844
|
+
__spreadProps(__spreadValues({}, SKELETON_REGISTRY["WmWizard"]), {
|
|
845
|
+
rows: props.skeletonRows,
|
|
846
|
+
columns: props.skeletonColumns,
|
|
847
|
+
className: clsx(DEFAULT_CLS, props.className),
|
|
848
|
+
styles: props.styles
|
|
849
|
+
})
|
|
850
|
+
);
|
|
851
|
+
}
|
|
852
|
+
return /* @__PURE__ */ jsx(WmWizardComponent, __spreadValues({}, props));
|
|
853
|
+
};
|
|
832
854
|
WmWizard.displayName = "WmWizard";
|
|
855
|
+
const WmWizardStandalone = withStandalone(WmWizard);
|
|
856
|
+
WmWizardComponent.displayName = "WmWizardComponent";
|
|
833
857
|
var wizard_default = withBaseWrapper(WmWizard);
|
|
834
858
|
export {
|
|
835
859
|
WmWizardStandalone as WmWizard,
|
|
@@ -212,6 +212,16 @@ export interface WizardPropsBase {
|
|
|
212
212
|
* @default false
|
|
213
213
|
*/
|
|
214
214
|
standalone?: boolean;
|
|
215
|
+
/**
|
|
216
|
+
* Number of skeleton step indicators shown while loading.
|
|
217
|
+
* @default 4
|
|
218
|
+
*/
|
|
219
|
+
skeletonRows?: number;
|
|
220
|
+
/**
|
|
221
|
+
* Number of skeleton content fields shown in the step body while loading.
|
|
222
|
+
* @default 3
|
|
223
|
+
*/
|
|
224
|
+
skeletonColumns?: number;
|
|
215
225
|
}
|
|
216
226
|
/**
|
|
217
227
|
* Combined props for the WmWizard component, including base WaveMaker props.
|
|
@@ -73,37 +73,43 @@ const WmCard = (props) => {
|
|
|
73
73
|
}, []);
|
|
74
74
|
const handleClick = useCallback(
|
|
75
75
|
(event) => {
|
|
76
|
-
|
|
76
|
+
var _a;
|
|
77
|
+
onClick == null ? void 0 : onClick(event, (_a = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _a[name], cardItem, listener);
|
|
77
78
|
},
|
|
78
79
|
[onClick, listener, name]
|
|
79
80
|
);
|
|
80
81
|
const handleDoubleClick = useCallback(
|
|
81
82
|
(event) => {
|
|
82
|
-
|
|
83
|
+
var _a;
|
|
84
|
+
onDblclick == null ? void 0 : onDblclick(event, (_a = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _a[name], cardItem, listener);
|
|
83
85
|
},
|
|
84
86
|
[onDblclick, props]
|
|
85
87
|
);
|
|
86
88
|
const handleMouseOver = useCallback(
|
|
87
89
|
(event) => {
|
|
88
|
-
|
|
90
|
+
var _a;
|
|
91
|
+
onMouseover == null ? void 0 : onMouseover(event, (_a = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _a[name], cardItem, listener);
|
|
89
92
|
},
|
|
90
93
|
[onMouseover, props]
|
|
91
94
|
);
|
|
92
95
|
const handleMouseOut = useCallback(
|
|
93
96
|
(event) => {
|
|
94
|
-
|
|
97
|
+
var _a;
|
|
98
|
+
onMouseout == null ? void 0 : onMouseout(event, (_a = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _a[name], cardItem, listener);
|
|
95
99
|
},
|
|
96
100
|
[onMouseout, props]
|
|
97
101
|
);
|
|
98
102
|
const handleMouseEnter = useCallback(
|
|
99
103
|
(event) => {
|
|
100
|
-
|
|
104
|
+
var _a;
|
|
105
|
+
onMouseenter == null ? void 0 : onMouseenter(event, (_a = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _a[name], cardItem, listener);
|
|
101
106
|
},
|
|
102
107
|
[onMouseenter, props]
|
|
103
108
|
);
|
|
104
109
|
const handleMouseLeave = useCallback(
|
|
105
110
|
(event) => {
|
|
106
|
-
|
|
111
|
+
var _a;
|
|
112
|
+
onMouseleave == null ? void 0 : onMouseleave(event, (_a = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _a[name], cardItem, listener);
|
|
107
113
|
},
|
|
108
114
|
[onMouseleave, props]
|
|
109
115
|
);
|
|
@@ -10,4 +10,4 @@ import { UseFormOperationsOptions, UseFormOperationsReturn } from "../props";
|
|
|
10
10
|
* - Save and new / Save and view actions
|
|
11
11
|
* - View mode state management
|
|
12
12
|
*/
|
|
13
|
-
export declare function useFormOperations({ formName, formfields, formRef, formReff, formType, fullDataPath, parentFormDataContext, clearFormData, resetFormData, trigger, submit,
|
|
13
|
+
export declare function useFormOperations({ formName, formfields, formRef, formReff, formType, fullDataPath, parentFormDataContext, clearFormData, resetFormData, trigger, submit, formProxy, widgetFormType, debouncedFilter, }: UseFormOperationsOptions): UseFormOperationsReturn;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState, useCallback } from "react";
|
|
2
|
-
import { cleanNullValues
|
|
2
|
+
import { cleanNullValues } from "../utils";
|
|
3
3
|
import { usesPrefixedFields } from "../props";
|
|
4
4
|
function useFormOperations({
|
|
5
5
|
formName,
|
|
@@ -13,7 +13,7 @@ function useFormOperations({
|
|
|
13
13
|
resetFormData,
|
|
14
14
|
trigger,
|
|
15
15
|
submit,
|
|
16
|
-
|
|
16
|
+
formProxy,
|
|
17
17
|
widgetFormType,
|
|
18
18
|
debouncedFilter
|
|
19
19
|
}) {
|
|
@@ -92,7 +92,7 @@ function useFormOperations({
|
|
|
92
92
|
}
|
|
93
93
|
const cleanedData = cleanNullValues(data);
|
|
94
94
|
resetFormData(cleanedData);
|
|
95
|
-
|
|
95
|
+
formProxy.formdata = cleanedData;
|
|
96
96
|
if (widgetFormType === "live-filter" && debouncedFilter) {
|
|
97
97
|
debouncedFilter();
|
|
98
98
|
}
|
|
@@ -22,7 +22,7 @@ import { useMemo, useState, useRef, useEffect, useCallback } from "react";
|
|
|
22
22
|
import clsx from "clsx";
|
|
23
23
|
import { useForm } from "react-hook-form";
|
|
24
24
|
import get from "lodash-es/get";
|
|
25
|
-
import
|
|
25
|
+
import debounce from "lodash-es/debounce";
|
|
26
26
|
import { defaultProps } from "./props";
|
|
27
27
|
import {
|
|
28
28
|
FormProvider,
|
|
@@ -36,8 +36,6 @@ import {
|
|
|
36
36
|
isElementInViewport,
|
|
37
37
|
scrollToElement,
|
|
38
38
|
transformRangeFilterData,
|
|
39
|
-
getWidgetFormData,
|
|
40
|
-
setWidgetFormData,
|
|
41
39
|
getWidgetFormFields,
|
|
42
40
|
registerChildFieldInWidget
|
|
43
41
|
} from "./utils";
|
|
@@ -51,11 +49,19 @@ import {
|
|
|
51
49
|
isChildFormType,
|
|
52
50
|
usesPrefixedFields
|
|
53
51
|
} from "./hooks";
|
|
52
|
+
import { useWidgetProxy } from "../../../../context/WidgetProvider";
|
|
53
|
+
import {
|
|
54
|
+
useAppNotificationAction,
|
|
55
|
+
useNotifyApp
|
|
56
|
+
} from "../../../../context/AppContext";
|
|
54
57
|
const DEFAULT_CLASS = "panel app-panel app-form";
|
|
55
58
|
const BaseForm = (WrappedComponent) => {
|
|
56
59
|
const ControlledForm = (FormProps) => {
|
|
57
|
-
var _a
|
|
60
|
+
var _a;
|
|
58
61
|
const props = __spreadValues(__spreadValues({}, defaultProps), FormProps);
|
|
62
|
+
const formProxy = useWidgetProxy(props.name);
|
|
63
|
+
const notificationAction = useAppNotificationAction();
|
|
64
|
+
const notifyApp = useNotifyApp();
|
|
59
65
|
const {
|
|
60
66
|
name: formName,
|
|
61
67
|
expanded: initialExpanded,
|
|
@@ -144,11 +150,10 @@ const BaseForm = (WrappedComponent) => {
|
|
|
144
150
|
}
|
|
145
151
|
return getItemsPerRowClass(String(itemsperrow));
|
|
146
152
|
}, [itemsperrow]);
|
|
147
|
-
const listenerWidgetFormdata =
|
|
153
|
+
const listenerWidgetFormdata = (_a = formProxy == null ? void 0 : formProxy.formdata) != null ? _a : void 0;
|
|
148
154
|
const widgetFormData = useMemo(() => {
|
|
149
155
|
if (!formName) return formdata;
|
|
150
|
-
const
|
|
151
|
-
const proxyFormdata = widgetData == null ? void 0 : widgetData.formdata;
|
|
156
|
+
const proxyFormdata = formProxy == null ? void 0 : formProxy.formdata;
|
|
152
157
|
return proxyFormdata && Object.keys(proxyFormdata).length > 0 ? proxyFormdata : formdata;
|
|
153
158
|
}, [formName, formdata, listenerWidgetFormdata]);
|
|
154
159
|
const formClassName = useMemo(() => {
|
|
@@ -157,7 +162,7 @@ const BaseForm = (WrappedComponent) => {
|
|
|
157
162
|
const fields = useMemo(() => {
|
|
158
163
|
const newFields = [];
|
|
159
164
|
if (!formName) return newFields;
|
|
160
|
-
const Widgets =
|
|
165
|
+
const Widgets = (formProxy == null ? void 0 : formProxy.formfields) || {};
|
|
161
166
|
Object.keys(Widgets).forEach((key) => {
|
|
162
167
|
if (!key.includes("formWidget") && Widgets[key]) {
|
|
163
168
|
newFields.push(Widgets[key]);
|
|
@@ -182,7 +187,6 @@ const BaseForm = (WrappedComponent) => {
|
|
|
182
187
|
}, []);
|
|
183
188
|
const checkAppServiceErrorMsg = useCallback((type) => {
|
|
184
189
|
var _a2;
|
|
185
|
-
const notificationAction = get(listener, "Actions.appNotification");
|
|
186
190
|
if (notificationAction && type === "error") {
|
|
187
191
|
return (_a2 = notificationAction == null ? void 0 : notificationAction.getMessage) == null ? void 0 : _a2.call(notificationAction);
|
|
188
192
|
}
|
|
@@ -194,7 +198,7 @@ const BaseForm = (WrappedComponent) => {
|
|
|
194
198
|
}, []);
|
|
195
199
|
const toggleMessage = useCallback(
|
|
196
200
|
(state, msg, type) => {
|
|
197
|
-
var _a2
|
|
201
|
+
var _a2;
|
|
198
202
|
let template = msg;
|
|
199
203
|
if (state && msg) {
|
|
200
204
|
if (type === "error" && errormessage && errormessage.length > 0) {
|
|
@@ -212,7 +216,7 @@ const BaseForm = (WrappedComponent) => {
|
|
|
212
216
|
scrollToElement(formEl);
|
|
213
217
|
}
|
|
214
218
|
} else {
|
|
215
|
-
|
|
219
|
+
notifyApp == null ? void 0 : notifyApp(template || "", type || "", true);
|
|
216
220
|
}
|
|
217
221
|
} else {
|
|
218
222
|
setStatusMessage({ caption: "", type: "" });
|
|
@@ -255,7 +259,7 @@ const BaseForm = (WrappedComponent) => {
|
|
|
255
259
|
const currentData = getValues();
|
|
256
260
|
markCurrentData(currentData);
|
|
257
261
|
lastUpdateOriginRef.current = "child";
|
|
258
|
-
|
|
262
|
+
formProxy.formdata = currentData;
|
|
259
263
|
},
|
|
260
264
|
[setValue, getValues, markCurrentData, formName]
|
|
261
265
|
);
|
|
@@ -333,16 +337,6 @@ const BaseForm = (WrappedComponent) => {
|
|
|
333
337
|
}),
|
|
334
338
|
[handleSubmit, livefilterFn]
|
|
335
339
|
);
|
|
336
|
-
const clearFilter = useMemo(
|
|
337
|
-
() => handleSubmit((data, e) => {
|
|
338
|
-
e == null ? void 0 : e.preventDefault();
|
|
339
|
-
e == null ? void 0 : e.stopPropagation();
|
|
340
|
-
formresetFn();
|
|
341
|
-
const transformedData = transformRangeFilterData(data);
|
|
342
|
-
livefilterFn(transformedData, true, formfieldsRef.current);
|
|
343
|
-
}),
|
|
344
|
-
[handleSubmit, livefilterFn]
|
|
345
|
-
);
|
|
346
340
|
const debouncedFilter = useCallback(() => {
|
|
347
341
|
const debouncedFn = debounce(filter, 250);
|
|
348
342
|
debouncedFn();
|
|
@@ -358,7 +352,7 @@ const BaseForm = (WrappedComponent) => {
|
|
|
358
352
|
setShowViewMode
|
|
359
353
|
} = useFormOperations({
|
|
360
354
|
formName: formName || "",
|
|
361
|
-
formfields,
|
|
355
|
+
formfields: (formProxy == null ? void 0 : formProxy.formfields) || {},
|
|
362
356
|
formRef,
|
|
363
357
|
formReff,
|
|
364
358
|
formType,
|
|
@@ -368,10 +362,20 @@ const BaseForm = (WrappedComponent) => {
|
|
|
368
362
|
resetFormData,
|
|
369
363
|
trigger,
|
|
370
364
|
submit,
|
|
371
|
-
|
|
365
|
+
formProxy: formProxy || {},
|
|
372
366
|
widgetFormType: props["form-type"],
|
|
373
367
|
debouncedFilter
|
|
374
368
|
});
|
|
369
|
+
const clearFilter = useMemo(
|
|
370
|
+
() => handleSubmit((data, e) => {
|
|
371
|
+
e == null ? void 0 : e.preventDefault();
|
|
372
|
+
e == null ? void 0 : e.stopPropagation();
|
|
373
|
+
formresetFn();
|
|
374
|
+
const transformedData = transformRangeFilterData(data);
|
|
375
|
+
livefilterFn(transformedData, true, formfieldsRef.current);
|
|
376
|
+
}),
|
|
377
|
+
[handleSubmit, livefilterFn]
|
|
378
|
+
);
|
|
375
379
|
const expandCollapsePanel = useCallback(() => {
|
|
376
380
|
if (collapsible) {
|
|
377
381
|
setExpanded(!expanded);
|
|
@@ -383,7 +387,8 @@ const BaseForm = (WrappedComponent) => {
|
|
|
383
387
|
return;
|
|
384
388
|
}
|
|
385
389
|
setShowViewMode(true);
|
|
386
|
-
|
|
390
|
+
formresetFn();
|
|
391
|
+
}, [setShowViewMode, props.cancel, formresetFn]);
|
|
387
392
|
const getFieldValue = useCallback((fieldName) => watch(fieldName), [watch]);
|
|
388
393
|
const highlightInvalidFields = useCallback(async () => {
|
|
389
394
|
await validateFieldsOnSubmit();
|
|
@@ -245,7 +245,7 @@ export interface UseFormOperationsOptions {
|
|
|
245
245
|
resetFormData: (data: any) => void;
|
|
246
246
|
trigger: () => Promise<boolean>;
|
|
247
247
|
submit: () => Promise<boolean | undefined>;
|
|
248
|
-
|
|
248
|
+
formProxy: any;
|
|
249
249
|
/** Widget form type (e.g., 'live-filter') */
|
|
250
250
|
widgetFormType?: string;
|
|
251
251
|
autoupdate?: string;
|
|
@@ -98,6 +98,9 @@ function DynamicForm(props) {
|
|
|
98
98
|
WmFormField,
|
|
99
99
|
__spreadProps(__spreadValues({}, field), {
|
|
100
100
|
name: field.name,
|
|
101
|
+
formName: formContext == null ? void 0 : formContext.name,
|
|
102
|
+
formKey: field.name,
|
|
103
|
+
fieldName: field.name,
|
|
101
104
|
field: "true",
|
|
102
105
|
listener,
|
|
103
106
|
className: clsx(
|
|
@@ -60,6 +60,8 @@ declare const WmFormActionsStandalone: import("react").ComponentType<{
|
|
|
60
60
|
updateon?: string;
|
|
61
61
|
dataset?: any;
|
|
62
62
|
prefabName?: string;
|
|
63
|
+
loading?: boolean;
|
|
64
|
+
showSkeleton?: boolean;
|
|
63
65
|
} & import("@wavemaker-ai/react-runtime/higherOrder/withStandalone").WithStandaloneProps>;
|
|
64
66
|
export { WmFormActionsStandalone as WmFormAction };
|
|
65
67
|
/**
|
|
@@ -133,5 +135,7 @@ declare const _default: import("react").ComponentType<{
|
|
|
133
135
|
updateon?: string;
|
|
134
136
|
dataset?: any;
|
|
135
137
|
prefabName?: string;
|
|
138
|
+
loading?: boolean;
|
|
139
|
+
showSkeleton?: boolean;
|
|
136
140
|
}>;
|
|
137
141
|
export default _default;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useRef, useEffect, useMemo } from "react";
|
|
2
2
|
import { createValidationRules } from "../validation-contrustor";
|
|
3
|
+
import isEqual from "lodash/isEqual";
|
|
3
4
|
const useFormRegistration = (name, fieldProxy, contextFormRef) => {
|
|
4
5
|
const hasRegisteredRef = useRef(false);
|
|
5
6
|
useEffect(() => {
|
|
@@ -13,7 +14,7 @@ const useExternalDataSync = (datavalue, fieldRef) => {
|
|
|
13
14
|
useEffect(() => {
|
|
14
15
|
if (fieldRef.current && datavalue !== void 0) {
|
|
15
16
|
const currentValue = fieldRef.current.value;
|
|
16
|
-
if (currentValue
|
|
17
|
+
if (!isEqual(currentValue, datavalue)) {
|
|
17
18
|
fieldRef.current.onChange(datavalue);
|
|
18
19
|
}
|
|
19
20
|
}
|
|
@@ -45,7 +45,8 @@ import {
|
|
|
45
45
|
useFormRegistration,
|
|
46
46
|
useDefaultValueSync,
|
|
47
47
|
useValidationRules,
|
|
48
|
-
useHTMLValidationProps
|
|
48
|
+
useHTMLValidationProps,
|
|
49
|
+
useExternalDataSync
|
|
49
50
|
} from "./hooks";
|
|
50
51
|
const withFormController = (WrappedComponent) => {
|
|
51
52
|
const WithFormControllerComponent = memo((props) => {
|
|
@@ -114,6 +115,7 @@ const withFormController = (WrappedComponent) => {
|
|
|
114
115
|
const trigger = formRef == null ? void 0 : formRef.trigger;
|
|
115
116
|
const validationType = (form == null ? void 0 : form.validationtype) || (formRef == null ? void 0 : formRef.validationtype) || "default";
|
|
116
117
|
useFormRegistration(name, fieldProxy, contextFormRef);
|
|
118
|
+
useExternalDataSync(effectiveDataValue, fieldRef);
|
|
117
119
|
useDefaultValueSync(defaultvalue, datavalue, fieldRef);
|
|
118
120
|
const widget = WrappedComponent == null ? void 0 : WrappedComponent.displayName;
|
|
119
121
|
const ignoreRange = ["WmRadioset", "WmCheckboxset"].includes(widget != null ? widget : "");
|
|
@@ -148,18 +150,6 @@ const withFormController = (WrappedComponent) => {
|
|
|
148
150
|
useEffect(() => {
|
|
149
151
|
observeRef.current = observe;
|
|
150
152
|
}, [observe]);
|
|
151
|
-
useEffect(() => {
|
|
152
|
-
return () => {
|
|
153
|
-
if (props.destroy) {
|
|
154
|
-
props.destroy([
|
|
155
|
-
props.name,
|
|
156
|
-
effectiveFormKey,
|
|
157
|
-
`${effectiveFormKey}_formWidget`,
|
|
158
|
-
`${effectiveFormKey}_formLabel`
|
|
159
|
-
]);
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
}, [effectiveFormKey]);
|
|
163
153
|
useEffect(() => {
|
|
164
154
|
if (isInitialMountRef.current) {
|
|
165
155
|
isInitialMountRef.current = false;
|
|
@@ -237,7 +227,7 @@ const withFormController = (WrappedComponent) => {
|
|
|
237
227
|
rules: validationRules,
|
|
238
228
|
defaultValue: effectiveDataValue !== void 0 ? effectiveDataValue : defaultvalue,
|
|
239
229
|
render: ({ field, fieldState }) => {
|
|
240
|
-
var _a2;
|
|
230
|
+
var _a2, _b;
|
|
241
231
|
fieldRef.current = field;
|
|
242
232
|
const processedValue = processFieldValue(field.value, type, props.datafield);
|
|
243
233
|
const errorState = getErrorState(fieldState, validationType, touched);
|
|
@@ -267,7 +257,7 @@ const withFormController = (WrappedComponent) => {
|
|
|
267
257
|
maxvalue: props.maxvalue !== void 0 ? props.maxvalue : void 0
|
|
268
258
|
// Keep original, don't update
|
|
269
259
|
};
|
|
270
|
-
const controlledProps = __spreadProps(__spreadValues(__spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, props), extractedValidatorProps), validationType === "html" ? htmlValidationProps : {}), maxWidgetProps), {
|
|
260
|
+
const controlledProps = __spreadValues(__spreadProps(__spreadValues(__spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, props), extractedValidatorProps), validationType === "html" ? htmlValidationProps : {}), maxWidgetProps), {
|
|
271
261
|
isMaxWidget,
|
|
272
262
|
// Ensure isMaxWidget is passed through
|
|
273
263
|
onChange: createOnChangeHandler(field),
|
|
@@ -283,6 +273,11 @@ const withFormController = (WrappedComponent) => {
|
|
|
283
273
|
className: clsx(wrappedComponentProps.className, {
|
|
284
274
|
hidden: contextFormRef == null ? void 0 : contextFormRef.isViewMode
|
|
285
275
|
})
|
|
276
|
+
}), {
|
|
277
|
+
listener: {
|
|
278
|
+
onChange: props.onChangeHandler,
|
|
279
|
+
Widgets: ((_a2 = props.listener) == null ? void 0 : _a2.Widgets) || {}
|
|
280
|
+
}
|
|
286
281
|
});
|
|
287
282
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
288
283
|
/* @__PURE__ */ jsx(
|
|
@@ -338,7 +333,7 @@ const withFormController = (WrappedComponent) => {
|
|
|
338
333
|
textAlign: "start",
|
|
339
334
|
width: "100%"
|
|
340
335
|
},
|
|
341
|
-
children: (
|
|
336
|
+
children: (_b = fieldState.error) == null ? void 0 : _b.message
|
|
342
337
|
}
|
|
343
338
|
)
|
|
344
339
|
] });
|
|
@@ -95,10 +95,6 @@ const BaseField = (WrappedComponent) => {
|
|
|
95
95
|
}
|
|
96
96
|
return props.formKey;
|
|
97
97
|
}, [props.formKey, props.searchkey, props.formName, props.name, props.parentForm]);
|
|
98
|
-
function resetField() {
|
|
99
|
-
const fieldName = props.formKey || props.name;
|
|
100
|
-
(formContext == null ? void 0 : formContext.resetField) && (formContext == null ? void 0 : formContext.resetField(fieldName));
|
|
101
|
-
}
|
|
102
98
|
const modifiedProps = useMemo(() => {
|
|
103
99
|
var _a;
|
|
104
100
|
return __spreadValues(__spreadProps(__spreadValues({}, props), {
|
|
@@ -113,7 +109,6 @@ const BaseField = (WrappedComponent) => {
|
|
|
113
109
|
widgetCls,
|
|
114
110
|
captionCls,
|
|
115
111
|
fieldRef,
|
|
116
|
-
reset: resetField,
|
|
117
112
|
setValidationMessage,
|
|
118
113
|
customValidationMsg,
|
|
119
114
|
fieldName: props.name,
|
|
@@ -18,42 +18,129 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
21
|
-
import { memo, useEffect } from "react";
|
|
21
|
+
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
22
22
|
import clsx from "clsx";
|
|
23
23
|
import isEqual from "lodash-es/isEqual";
|
|
24
24
|
import get from "lodash-es/get";
|
|
25
|
-
import withBaseWrapper from "../../../../higherOrder/withBaseWrapper";
|
|
26
25
|
import BaseField from "./base-field";
|
|
27
26
|
import { WmComposite } from "../../../input/composite";
|
|
27
|
+
import { useWidgetProxy } from "../../../../context/WidgetProvider";
|
|
28
|
+
import { createFormFieldProxy } from "../../../../core/proxy-service";
|
|
28
29
|
const DEFAULT_CLASS = "ng-pristine ng-invalid ng-touched";
|
|
29
30
|
const DEFAULT_COMPOSITE_CLASS = "app-composite-widget caption-left clearfix form-group live-field";
|
|
31
|
+
const DATASET_SYNC_KEYS = [
|
|
32
|
+
"dataset",
|
|
33
|
+
"datafield",
|
|
34
|
+
"displayfield",
|
|
35
|
+
"displaylabel",
|
|
36
|
+
"searchkey"
|
|
37
|
+
];
|
|
30
38
|
const WmFormField = memo(
|
|
31
39
|
(props) => {
|
|
32
|
-
var _a;
|
|
40
|
+
var _a, _b;
|
|
41
|
+
const { show = true, deferload } = props;
|
|
42
|
+
const [proxyProps, setProxyProps] = useState(__spreadProps(__spreadValues({}, props), {
|
|
43
|
+
show: show == null ? void 0 : show.toString(),
|
|
44
|
+
deferload: deferload == null ? void 0 : deferload.toString(),
|
|
45
|
+
datavalue: props.defaultvalue
|
|
46
|
+
}));
|
|
47
|
+
const fieldProxyRef = useRef(null);
|
|
48
|
+
const formProxy = useWidgetProxy(`${props.formName}`);
|
|
49
|
+
const overriddenItemsRef = useRef({});
|
|
50
|
+
const fieldKey = props.formKey || props.name;
|
|
51
|
+
const defaultValueRegisteredRef = useRef(false);
|
|
52
|
+
const formReady = (formProxy == null ? void 0 : formProxy.listener) !== void 0;
|
|
53
|
+
const reset = useCallback(
|
|
54
|
+
(value) => {
|
|
55
|
+
const field = fieldProxyRef.current;
|
|
56
|
+
if (field.readonly || field.disabled) return;
|
|
57
|
+
fieldProxyRef.current.datavalue = value != null ? value : "";
|
|
58
|
+
fieldProxyRef.current.value = value != null ? value : "";
|
|
59
|
+
},
|
|
60
|
+
[fieldKey]
|
|
61
|
+
);
|
|
62
|
+
const isNumber = useMemo(
|
|
63
|
+
() => props.type === "integer" || props.type === "number",
|
|
64
|
+
[props.type]
|
|
65
|
+
);
|
|
66
|
+
const onChangeHandler = useCallback(
|
|
67
|
+
(name, data) => {
|
|
68
|
+
Object.keys(data).forEach((key) => {
|
|
69
|
+
fieldProxyRef.current[key] = key === "datavalue" && isNumber ? Number(data[key]) : data[key];
|
|
70
|
+
});
|
|
71
|
+
setProxyProps((prev) => {
|
|
72
|
+
return __spreadValues(__spreadValues({}, prev), isNumber ? __spreadProps(__spreadValues({}, data), { datavalue: Number(data.datavalue) }) : data);
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
[isNumber]
|
|
76
|
+
);
|
|
33
77
|
useEffect(() => {
|
|
34
|
-
if (
|
|
35
|
-
|
|
78
|
+
if (!fieldKey || !formReady) return;
|
|
79
|
+
if (!formProxy.formWidgets) {
|
|
80
|
+
formProxy.formWidgets = {};
|
|
81
|
+
formProxy.formfields = {};
|
|
36
82
|
}
|
|
37
|
-
|
|
83
|
+
const mutableTarget = __spreadProps(__spreadValues({}, props), { reset, show, deferload });
|
|
84
|
+
const fieldProxy = createFormFieldProxy(
|
|
85
|
+
mutableTarget,
|
|
86
|
+
setProxyProps,
|
|
87
|
+
overriddenItemsRef,
|
|
88
|
+
formProxy
|
|
89
|
+
);
|
|
90
|
+
fieldProxyRef.current = fieldProxy;
|
|
91
|
+
}, [formReady]);
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (!formReady || !fieldProxyRef.current) return;
|
|
94
|
+
if (defaultValueRegisteredRef.current) return;
|
|
95
|
+
defaultValueRegisteredRef.current = true;
|
|
96
|
+
fieldProxyRef.current.datavalue = props.defaultvalue;
|
|
97
|
+
fieldProxyRef.current.value = props.defaultvalue;
|
|
98
|
+
fieldProxyRef.current.defaultvalue = props.defaultvalue;
|
|
99
|
+
}, [props.defaultvalue]);
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
var _a2;
|
|
102
|
+
const fieldProxy = fieldProxyRef.current;
|
|
103
|
+
if (!fieldProxy || !((_a2 = props.dataset) == null ? void 0 : _a2.length)) return;
|
|
104
|
+
DATASET_SYNC_KEYS.forEach((key) => {
|
|
105
|
+
const value = props[key];
|
|
106
|
+
if (value != null && fieldProxy[key] !== value) {
|
|
107
|
+
fieldProxy[key] = value;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}, [props.dataset, props.datafield, props.displayfield, props.displaylabel, props.searchkey]);
|
|
38
111
|
function renderFormFields() {
|
|
39
|
-
var _a2,
|
|
112
|
+
var _a2, _b2, _c;
|
|
40
113
|
if (props.formRef) {
|
|
41
114
|
const errors = (_a2 = props.formRef) == null ? void 0 : _a2.errors;
|
|
42
|
-
const formKey = (
|
|
115
|
+
const formKey = (_b2 = props.formKey) != null ? _b2 : props.name;
|
|
43
116
|
const fieldError = formKey && errors ? get(errors, formKey) : void 0;
|
|
44
117
|
const invalid = Boolean(fieldError);
|
|
45
118
|
const invalidCls = invalid ? " text-danger " : "";
|
|
46
|
-
return /* @__PURE__ */ jsx(Fragment, { children: (_c = props == null ? void 0 : props.renderFormFields) == null ? void 0 : _c.call(props, __spreadProps(__spreadValues({},
|
|
119
|
+
return /* @__PURE__ */ jsx(Fragment, { children: (_c = props == null ? void 0 : props.renderFormFields) == null ? void 0 : _c.call(props, __spreadProps(__spreadValues(__spreadValues({}, proxyProps), overriddenItemsRef.current), {
|
|
47
120
|
fieldError,
|
|
121
|
+
validators: props.validators,
|
|
122
|
+
asyncValidators: props.asyncValidators,
|
|
123
|
+
observe: props.observe,
|
|
48
124
|
invalid,
|
|
49
|
-
invalidCls
|
|
125
|
+
invalidCls,
|
|
126
|
+
iswidget: "false",
|
|
127
|
+
onChangeHandler
|
|
50
128
|
})) });
|
|
51
129
|
} else {
|
|
52
130
|
return null;
|
|
53
131
|
}
|
|
54
132
|
}
|
|
55
133
|
const itemsPerRow = ((_a = props == null ? void 0 : props.formRef) == null ? void 0 : _a.itemsPerRow) || "";
|
|
56
|
-
if (
|
|
134
|
+
if (!fieldProxyRef.current) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
const isDeferLoad = deferload === true;
|
|
138
|
+
const showValue = ((_b = proxyProps == null ? void 0 : proxyProps.show) == null ? void 0 : _b.toString()) !== "false";
|
|
139
|
+
if (!showValue && isDeferLoad) {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
const shouldHide = !showValue && !isDeferLoad;
|
|
143
|
+
if (shouldHide) {
|
|
57
144
|
return null;
|
|
58
145
|
}
|
|
59
146
|
return /* @__PURE__ */ jsx(
|
|
@@ -68,7 +155,6 @@ const WmFormField = memo(
|
|
|
68
155
|
name: props.name,
|
|
69
156
|
displayname: props.displayname,
|
|
70
157
|
placeholder: props.placeholder,
|
|
71
|
-
hidden: props.hidden,
|
|
72
158
|
"data-role": props.role || "form-field",
|
|
73
159
|
children: /* @__PURE__ */ jsx(
|
|
74
160
|
WmComposite,
|
|
@@ -89,7 +175,7 @@ const WmFormField = memo(
|
|
|
89
175
|
);
|
|
90
176
|
WmFormField.displayName = "WmFormField";
|
|
91
177
|
const WmFormFieldStandalone = BaseField(WmFormField);
|
|
92
|
-
var form_field_default = BaseField(
|
|
178
|
+
var form_field_default = BaseField(WmFormField);
|
|
93
179
|
export {
|
|
94
180
|
WmFormFieldStandalone as WmFormField,
|
|
95
181
|
form_field_default as default
|