@wavemaker-ai/react-runtime 1.0.0-rc.314 → 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/actions/navigation-action.d.ts +1 -0
- package/actions/navigation-action.js +34 -9
- 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.d.ts +6 -0
- package/components/auth/RoleAuthGuard.js +66 -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/search/index.js +2 -1
- package/components/basic/search/providers.js +2 -2
- package/components/basic/spinner/index.d.ts +2 -0
- package/components/basic/tile/index.d.ts +2 -0
- package/components/basic/tree/Components/TreeNodeComponent.d.ts +1 -1
- package/components/basic/tree/Components/TreeNodeComponent.js +14 -8
- package/components/basic/tree/hooks/useTreePersistedState.d.ts +3 -0
- package/components/basic/tree/hooks/useTreePersistedState.js +38 -0
- package/components/basic/tree/index.d.ts +3 -0
- package/components/basic/tree/index.js +105 -30
- package/components/basic/tree/props.d.ts +18 -1
- package/components/basic/tree/utils.d.ts +16 -1
- package/components/basic/tree/utils.js +111 -0
- package/components/basic/video/index.d.ts +2 -0
- package/components/chart/index.d.ts +2 -0
- package/components/chart/src/dataUtils.js +1 -1
- package/components/common/customTemplate/useCustomTemplate.js +1 -1
- 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-column/index.js +2 -1
- 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 +33 -26
- 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 +14 -23
- 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/pagination/hooks/usePagination.js +0 -1
- 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 +20 -2
- 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/columnBuilder.d.ts +1 -1
- package/components/data/table/utils/columnBuilder.js +7 -4
- package/components/data/table/utils/crud-handlers.js +10 -10
- package/components/data/table/utils/index.d.ts +11 -8
- package/components/data/table/utils/index.js +90 -12
- 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/layout/leftnav/index.js +21 -2
- package/components/layout/leftnav/props.d.ts +9 -0
- package/components/layout/leftnav/utils/page-class-util.d.ts +9 -0
- package/components/layout/leftnav/utils/page-class-util.js +28 -0
- 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/navigation/popover/index.js +1 -0
- package/components/page/index.js +22 -6
- package/components/page/page-context.d.ts +4 -0
- package/components/page/page-context.js +5 -0
- package/components/page/partial/index.d.ts +2 -0
- package/components/page/partial-container/index.js +1 -4
- 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 +5 -6
- package/higherOrder/BaseAppProps.d.ts +1 -0
- package/higherOrder/BasePage.js +4 -12
- package/higherOrder/props.d.ts +10 -0
- package/higherOrder/withBaseWrapper.js +3 -0
- package/hooks/useAuth.js +3 -0
- package/hooks/useDataSourceSubscription.js +1 -1
- package/hooks/useHttp.js +0 -4
- package/hooks/useLayoutSize.d.ts +6 -0
- package/hooks/useLayoutSize.js +12 -0
- package/package-lock.json +229 -203
- package/package.json +3 -3
- package/runtime-dynamic/app-initializer.js +1 -1
- package/runtime-dynamic/components/use-dynamic-component.js +12 -31
- package/runtime-dynamic/factories/build-base-page-like-component.d.ts +1 -1
- package/runtime-dynamic/factories/dynamic-component.js +9 -1
- package/runtime-dynamic/factories/prefab-factory.d.ts +1 -1
- package/runtime-dynamic/factories/utils.d.ts +1 -1
- package/runtime-dynamic/main.js +1 -3
- package/runtime-dynamic/services/component-ref-provider.d.ts +19 -4
- package/runtime-dynamic/services/component-ref-provider.js +18 -38
- package/runtime-dynamic/services/index.d.ts +2 -3
- package/runtime-dynamic/services/index.js +1 -18
- package/runtime-dynamic/services/resource-manager.d.ts +2 -3
- package/runtime-dynamic/services/resource-manager.js +13 -17
- package/runtime-dynamic/services/script-executor.js +5 -8
- package/runtime-dynamic/services/variable-registry.js +3 -4
- package/utils/attr.js +1 -9
- package/utils/custom-expression/index.js +4 -1
- package/utils/custom-expression/parser.js +4 -2
- package/utils/format-util.js +2 -3
- package/utils/state-persistance.d.ts +1 -1
- package/runtime-dynamic/services/cache.d.ts +0 -29
- package/runtime-dynamic/services/cache.js +0 -51
- package/utils/form-state.util.d.ts +0 -62
- package/utils/form-state.util.js +0 -109
|
@@ -36,6 +36,11 @@ import Typography from "@mui/material/Typography";
|
|
|
36
36
|
import withBaseWrapper from "../../../higherOrder/withBaseWrapper";
|
|
37
37
|
import WmTabPane from "./tab-pane";
|
|
38
38
|
import { DEFAULT_PROPS } from "./props";
|
|
39
|
+
import {
|
|
40
|
+
WmSkeleton,
|
|
41
|
+
SKELETON_REGISTRY,
|
|
42
|
+
shouldShowSkeleton
|
|
43
|
+
} from "../../common/wm-skeleton";
|
|
39
44
|
import {
|
|
40
45
|
getWidgetState,
|
|
41
46
|
setWidgetState
|
|
@@ -90,6 +95,17 @@ const useTabsContext = () => {
|
|
|
90
95
|
const WmTabs = memo(
|
|
91
96
|
(Props) => {
|
|
92
97
|
const props = __spreadValues(__spreadValues({}, DEFAULT_PROPS), Props);
|
|
98
|
+
if (shouldShowSkeleton(props.loading, props.showSkeleton)) {
|
|
99
|
+
return /* @__PURE__ */ jsx(
|
|
100
|
+
WmSkeleton,
|
|
101
|
+
__spreadProps(__spreadValues({}, SKELETON_REGISTRY["WmTabs"]), {
|
|
102
|
+
rows: props.skeletonRows,
|
|
103
|
+
columns: props.skeletonColumns,
|
|
104
|
+
className: clsx("app-tabs clearfix", props.className),
|
|
105
|
+
styles: props.styles
|
|
106
|
+
})
|
|
107
|
+
);
|
|
108
|
+
}
|
|
93
109
|
const {
|
|
94
110
|
defaultpaneindex,
|
|
95
111
|
statehandler,
|
|
@@ -528,7 +544,13 @@ const WmTabs = memo(
|
|
|
528
544
|
"iconposition",
|
|
529
545
|
"render",
|
|
530
546
|
"selectedindex",
|
|
531
|
-
"children"
|
|
547
|
+
"children",
|
|
548
|
+
"loading",
|
|
549
|
+
"showSkeleton",
|
|
550
|
+
"skeletonRows",
|
|
551
|
+
"skeletonColumns",
|
|
552
|
+
"className",
|
|
553
|
+
"styles"
|
|
532
554
|
];
|
|
533
555
|
return keys.every((key) => {
|
|
534
556
|
if (key === "children") {
|
|
@@ -96,6 +96,16 @@ export interface TabsPropsBase {
|
|
|
96
96
|
* Called when the active tab changes.
|
|
97
97
|
*/
|
|
98
98
|
onChange?: (event: React.SyntheticEvent | null, props: WmTabsProps, newPaneIndex: number, oldPaneIndex: number) => void;
|
|
99
|
+
/**
|
|
100
|
+
* Number of skeleton tab headers shown while loading.
|
|
101
|
+
* @default 4
|
|
102
|
+
*/
|
|
103
|
+
skeletonRows?: number;
|
|
104
|
+
/**
|
|
105
|
+
* Number of skeleton content lines shown in the active tab panel while loading.
|
|
106
|
+
* @default 3
|
|
107
|
+
*/
|
|
108
|
+
skeletonColumns?: number;
|
|
99
109
|
}
|
|
100
110
|
/**
|
|
101
111
|
* Combined props for the WmTabs component, including base WaveMaker props.
|
|
@@ -30,6 +30,8 @@ declare const WmWizardStandalone: React.ComponentType<{
|
|
|
30
30
|
onCancel?: (currentStep: WizardStepData | null, steps: WizardStepData[]) => void;
|
|
31
31
|
onDone?: (currentStep: WizardStepData, steps: WizardStepData[]) => void;
|
|
32
32
|
standalone?: boolean;
|
|
33
|
+
skeletonRows?: number;
|
|
34
|
+
skeletonColumns?: number;
|
|
33
35
|
ref?: React.RefObject<HTMLElement> | React.RefObject<null>;
|
|
34
36
|
animation?: string;
|
|
35
37
|
show?: boolean | string;
|
|
@@ -75,6 +77,8 @@ declare const WmWizardStandalone: React.ComponentType<{
|
|
|
75
77
|
formfield?: boolean;
|
|
76
78
|
updateon?: string;
|
|
77
79
|
prefabName?: string;
|
|
80
|
+
loading?: boolean;
|
|
81
|
+
showSkeleton?: boolean;
|
|
78
82
|
} & import("@wavemaker-ai/react-runtime/higherOrder/withStandalone").WithStandaloneProps>;
|
|
79
83
|
export { WmWizardStandalone as WmWizard };
|
|
80
84
|
/**
|
|
@@ -117,6 +121,8 @@ declare const _default: React.ComponentType<{
|
|
|
117
121
|
onCancel?: (currentStep: WizardStepData | null, steps: WizardStepData[]) => void;
|
|
118
122
|
onDone?: (currentStep: WizardStepData, steps: WizardStepData[]) => void;
|
|
119
123
|
standalone?: boolean;
|
|
124
|
+
skeletonRows?: number;
|
|
125
|
+
skeletonColumns?: number;
|
|
120
126
|
ref?: React.RefObject<HTMLElement> | React.RefObject<null>;
|
|
121
127
|
animation?: string;
|
|
122
128
|
show?: boolean | string;
|
|
@@ -162,5 +168,7 @@ declare const _default: React.ComponentType<{
|
|
|
162
168
|
formfield?: boolean;
|
|
163
169
|
updateon?: string;
|
|
164
170
|
prefabName?: string;
|
|
171
|
+
loading?: boolean;
|
|
172
|
+
showSkeleton?: boolean;
|
|
165
173
|
}>;
|
|
166
174
|
export default _default;
|
|
@@ -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();
|
|
@@ -449,7 +454,7 @@ const BaseForm = (WrappedComponent) => {
|
|
|
449
454
|
useEffect(() => {
|
|
450
455
|
return () => {
|
|
451
456
|
var _a2;
|
|
452
|
-
if (!formName) return;
|
|
457
|
+
if (!formName || !formRef.current) return;
|
|
453
458
|
(_a2 = props == null ? void 0 : props.destroy) == null ? void 0 : _a2.call(props, formName);
|
|
454
459
|
formresetFn();
|
|
455
460
|
};
|
|
@@ -583,6 +588,7 @@ const BaseForm = (WrappedComponent) => {
|
|
|
583
588
|
widgetCls,
|
|
584
589
|
itemsPerRow,
|
|
585
590
|
validationtype: props.validationtype,
|
|
591
|
+
submitCount,
|
|
586
592
|
showViewMode,
|
|
587
593
|
formdata: computedFormdata,
|
|
588
594
|
submit,
|
|
@@ -602,6 +608,7 @@ const BaseForm = (WrappedComponent) => {
|
|
|
602
608
|
widgetCls,
|
|
603
609
|
itemsPerRow,
|
|
604
610
|
props.validationtype,
|
|
611
|
+
submitCount,
|
|
605
612
|
showViewMode,
|
|
606
613
|
computedFormdata,
|
|
607
614
|
submit,
|
|
@@ -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,29 +150,12 @@ 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
|
-
useEffect(() => {
|
|
164
|
-
if (touched && !hasEverBeenTouchedRef.current) {
|
|
165
|
-
hasEverBeenTouchedRef.current = true;
|
|
166
|
-
}
|
|
167
|
-
}, [touched]);
|
|
168
153
|
useEffect(() => {
|
|
169
154
|
if (isInitialMountRef.current) {
|
|
170
155
|
isInitialMountRef.current = false;
|
|
171
156
|
return;
|
|
172
157
|
}
|
|
173
|
-
const hasBeenTouchedOrSubmitted = hasEverBeenTouchedRef.current || (formRef == null ? void 0 : formRef.submitCount) && formRef.submitCount > 0;
|
|
158
|
+
const hasBeenTouchedOrSubmitted = hasEverBeenTouchedRef.current || (formRef == null ? void 0 : formRef.submitCount) && formRef.submitCount > 0 || false;
|
|
174
159
|
if (trigger && effectiveFormKey && hasBeenTouchedOrSubmitted) {
|
|
175
160
|
trigger(effectiveFormKey);
|
|
176
161
|
}
|
|
@@ -181,7 +166,7 @@ const withFormController = (WrappedComponent) => {
|
|
|
181
166
|
customMsgInitialRef.current = false;
|
|
182
167
|
return;
|
|
183
168
|
}
|
|
184
|
-
if (trigger && effectiveFormKey) {
|
|
169
|
+
if (trigger && effectiveFormKey && hasEverBeenTouchedRef.current) {
|
|
185
170
|
trigger(effectiveFormKey);
|
|
186
171
|
}
|
|
187
172
|
}, [customValidationMsg]);
|
|
@@ -218,6 +203,7 @@ const withFormController = (WrappedComponent) => {
|
|
|
218
203
|
return (e) => {
|
|
219
204
|
var _a2;
|
|
220
205
|
setTouched(true);
|
|
206
|
+
hasEverBeenTouchedRef.current = true;
|
|
221
207
|
field.onBlur();
|
|
222
208
|
const shouldTriggerValidation = validationType === "html" && trigger && !!fieldState.error || validationType !== "none" && ((_a2 = observeRef.current) == null ? void 0 : _a2.length) && trigger;
|
|
223
209
|
if (shouldTriggerValidation) {
|
|
@@ -241,7 +227,7 @@ const withFormController = (WrappedComponent) => {
|
|
|
241
227
|
rules: validationRules,
|
|
242
228
|
defaultValue: effectiveDataValue !== void 0 ? effectiveDataValue : defaultvalue,
|
|
243
229
|
render: ({ field, fieldState }) => {
|
|
244
|
-
var _a2;
|
|
230
|
+
var _a2, _b;
|
|
245
231
|
fieldRef.current = field;
|
|
246
232
|
const processedValue = processFieldValue(field.value, type, props.datafield);
|
|
247
233
|
const errorState = getErrorState(fieldState, validationType, touched);
|
|
@@ -271,7 +257,7 @@ const withFormController = (WrappedComponent) => {
|
|
|
271
257
|
maxvalue: props.maxvalue !== void 0 ? props.maxvalue : void 0
|
|
272
258
|
// Keep original, don't update
|
|
273
259
|
};
|
|
274
|
-
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), {
|
|
275
261
|
isMaxWidget,
|
|
276
262
|
// Ensure isMaxWidget is passed through
|
|
277
263
|
onChange: createOnChangeHandler(field),
|
|
@@ -287,6 +273,11 @@ const withFormController = (WrappedComponent) => {
|
|
|
287
273
|
className: clsx(wrappedComponentProps.className, {
|
|
288
274
|
hidden: contextFormRef == null ? void 0 : contextFormRef.isViewMode
|
|
289
275
|
})
|
|
276
|
+
}), {
|
|
277
|
+
listener: {
|
|
278
|
+
onChange: props.onChangeHandler,
|
|
279
|
+
Widgets: ((_a2 = props.listener) == null ? void 0 : _a2.Widgets) || {}
|
|
280
|
+
}
|
|
290
281
|
});
|
|
291
282
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
292
283
|
/* @__PURE__ */ jsx(
|
|
@@ -342,7 +333,7 @@ const withFormController = (WrappedComponent) => {
|
|
|
342
333
|
textAlign: "start",
|
|
343
334
|
width: "100%"
|
|
344
335
|
},
|
|
345
|
-
children: (
|
|
336
|
+
children: (_b = fieldState.error) == null ? void 0 : _b.message
|
|
346
337
|
}
|
|
347
338
|
)
|
|
348
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,
|