@wavemaker-ai/react-runtime 1.0.0-rc.324 → 1.0.0-rc.328

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/components/basic/anchor/index.js +3 -0
  2. package/components/basic/icon/index.js +36 -5
  3. package/components/basic/iframe/index.js +18 -8
  4. package/components/basic/label/index.js +4 -3
  5. package/components/basic/search/index.d.ts +72 -3
  6. package/components/basic/search/index.js +75 -21
  7. package/components/basic/search/props.d.ts +4 -0
  8. package/components/common/WmAppIcon/index.js +11 -8
  9. package/components/common/WmAppIcon/props.d.ts +2 -0
  10. package/components/container/accordion/accordion-pane/index.d.ts +1 -0
  11. package/components/container/accordion/accordion-pane/index.js +7 -3
  12. package/components/container/accordion/accordion-pane/props.d.ts +1 -0
  13. package/components/container/index.js +18 -5
  14. package/components/container/layout-grid/grid-row/index.js +1 -1
  15. package/components/container/panel/components/panel-header/index.js +1 -3
  16. package/components/container/tabs/tab-pane/index.d.ts +1 -0
  17. package/components/container/tabs/tab-pane/index.js +2 -2
  18. package/components/container/tabs/tab-pane/props.d.ts +1 -0
  19. package/components/container/wizard/index.js +11 -10
  20. package/components/container/wizard/utils.js +1 -0
  21. package/components/data/form/base-form/hooks/useFormSubmission.d.ts +1 -1
  22. package/components/data/form/base-form/hooks/useFormSubmission.js +3 -1
  23. package/components/data/form/base-form/index.js +11 -14
  24. package/components/data/form/base-form/props.d.ts +3 -0
  25. package/components/data/form/dynamic-fields/WmxDynamicFormField.d.ts +11 -0
  26. package/components/data/form/dynamic-fields/WmxDynamicFormField.js +77 -0
  27. package/components/data/form/dynamic-fields/index.js +12 -1
  28. package/components/data/form/form-controller/withFormController.js +19 -16
  29. package/components/data/form/form-field/base-field.js +8 -5
  30. package/components/data/form/form-field/index.js +15 -8
  31. package/components/data/form/form-field/props.d.ts +1 -0
  32. package/components/data/list/components/ListItemWithTemplate.js +5 -2
  33. package/components/data/list/hooks/useListEffects.js +1 -1
  34. package/components/data/list/index.js +14 -5
  35. package/components/data/list/utils/constants.d.ts +0 -1
  36. package/components/data/list/utils/constants.js +0 -2
  37. package/components/data/table/components/RowCells.js +20 -4
  38. package/components/data/table/components/TableBody.js +5 -3
  39. package/components/data/table/components/TableHeader.js +14 -8
  40. package/components/data/table/components/TablePanelHeading.js +1 -1
  41. package/components/data/table/hooks/useDynamicColumns.js +1 -1
  42. package/components/data/table/hooks/useRowExpansion.js +41 -31
  43. package/components/data/table/hooks/useRowHandlers.d.ts +4 -2
  44. package/components/data/table/hooks/useRowHandlers.js +23 -12
  45. package/components/data/table/hooks/useRowSelection.d.ts +1 -1
  46. package/components/data/table/hooks/useRowSelection.js +80 -66
  47. package/components/data/table/hooks/useServerSideSorting.js +0 -1
  48. package/components/data/table/hooks/useTableColumns.js +16 -8
  49. package/components/data/table/hooks/useTableData.js +0 -1
  50. package/components/data/table/hooks/useTableEdit.js +0 -1
  51. package/components/data/table/hooks/useTableState.js +14 -2
  52. package/components/data/table/index.js +94 -61
  53. package/components/data/table/live-table/index.js +0 -1
  54. package/components/data/table/props.d.ts +8 -0
  55. package/components/data/table/utils/buildSelectionColumns.js +2 -4
  56. package/components/data/table/utils/columnBuilder.d.ts +16 -2
  57. package/components/data/table/utils/columnBuilder.js +14 -9
  58. package/components/data/table/utils/columnWidthDistribution.js +10 -0
  59. package/components/data/table/utils/constants.d.ts +0 -4
  60. package/components/data/table/utils/constants.js +0 -7
  61. package/components/data/table/utils/dynamic-columns.d.ts +1 -1
  62. package/components/data/table/utils/dynamic-columns.js +3 -8
  63. package/components/data/table/utils/expansionColumn.d.ts +23 -0
  64. package/components/data/table/utils/expansionColumn.js +56 -0
  65. package/components/data/table/utils/index.d.ts +23 -3
  66. package/components/data/table/utils/index.js +60 -20
  67. package/components/data/table/utils/selectionUtils.d.ts +5 -0
  68. package/components/data/table/utils/selectionUtils.js +5 -0
  69. package/components/dialogs/dialog/index.js +3 -2
  70. package/components/dialogs/dialog-header/index.js +1 -1
  71. package/components/dialogs/index.js +14 -2
  72. package/components/input/chips/index.js +29 -5
  73. package/components/input/color-picker/index.js +4 -6
  74. package/components/input/default/radioset/index.js +2 -1
  75. package/components/input/epoch/date/index.js +1 -1
  76. package/components/input/select/index.js +3 -5
  77. package/components/input/text/index.js +2 -2
  78. package/components/input/textarea/index.js +42 -17
  79. package/components/navbar/nav/index.js +10 -5
  80. package/components/navigation/breadcrumb/index.js +2 -1
  81. package/components/navigation/popover/index.js +24 -8
  82. package/components/page/index.js +1 -1
  83. package/components/page/page-content/index.js +30 -6
  84. package/components/page/page-content/props.d.ts +1 -0
  85. package/components/page/partial-container/index.js +2 -1
  86. package/components/prefab/index.js +3 -2
  87. package/components/prefab/props.d.ts +1 -0
  88. package/components/wmx/WmxRenderer.d.ts +8 -0
  89. package/components/wmx/WmxRenderer.js +57 -0
  90. package/context/WidgetProvider.js +2 -1
  91. package/core/appstore.js +1 -1
  92. package/core/proxy-service.d.ts +1 -0
  93. package/core/proxy-service.js +53 -2
  94. package/core/util/index.d.ts +0 -2
  95. package/core/util/index.js +3 -30
  96. package/higherOrder/BasePage.js +36 -54
  97. package/higherOrder/DataNav.js +4 -1
  98. package/higherOrder/withBaseWrapper.js +9 -7
  99. package/hooks/useHttp.js +4 -2
  100. package/hooks/useLayoutSize.js +1 -1
  101. package/package-lock.json +240 -607
  102. package/package.json +3 -3
  103. package/runtime-dynamic/app-initializer.js +2 -1
  104. package/runtime-dynamic/components/partial-content.js +4 -1
  105. package/runtime-dynamic/components/wmx-placeholder.d.ts +18 -0
  106. package/runtime-dynamic/components/wmx-placeholder.js +48 -0
  107. package/runtime-dynamic/factories/dynamic-component.js +26 -3
  108. package/runtime-dynamic/main.js +6 -0
  109. package/runtime-dynamic/services/compile-render.js +75 -12
  110. package/runtime-dynamic/services/css-scoping.d.ts +2 -0
  111. package/runtime-dynamic/services/css-scoping.js +39 -20
  112. package/store/slices/i18nSlice.d.ts +0 -1
  113. package/store/slices/i18nSlice.js +0 -2
  114. package/utils/custom-expression/parser.js +11 -8
  115. package/utils/layoutsize-util.js +12 -7
  116. package/utils/style-utils.d.ts +6 -0
  117. package/utils/style-utils.js +10 -0
  118. package/utils/transformedDataset-utils.d.ts +3 -3
  119. package/utils/transformedDataset-utils.js +1 -2
  120. package/utils/wmx.utils.d.ts +6 -0
  121. package/utils/wmx.utils.js +41 -0
  122. package/variables/crud-variable.js +1 -1
  123. package/variables/live-variable.js +1 -1
  124. package/variables/service-variable.js +6 -3
@@ -30,7 +30,13 @@ var __objRest = (source, exclude) => {
30
30
  return target;
31
31
  };
32
32
  import { jsx } from "react/jsx-runtime";
33
- import { useEffect, useRef, useMemo, useCallback } from "react";
33
+ import {
34
+ useEffect,
35
+ useRef,
36
+ useMemo,
37
+ useCallback,
38
+ useState
39
+ } from "react";
34
40
  import { clsx } from "clsx";
35
41
  import { withBaseWrapper } from "../../higherOrder/withBaseWrapper";
36
42
  import { useLayoutSize } from "../../hooks/useLayoutSize";
@@ -38,7 +44,7 @@ import { removeInvalidAttributes } from "../../utils/attr";
38
44
  import { normalizeBackgroundImage } from "../../utils/style-utils";
39
45
  const DEFAULT_CLASS = "app-container";
40
46
  const WmContainer = (props) => {
41
- var _c;
47
+ var _c, _d, _e;
42
48
  const _a = props, { listener } = _a, restPartialProps = __objRest(_a, ["listener"]);
43
49
  const _b = restPartialProps, {
44
50
  className,
@@ -148,6 +154,9 @@ const WmContainer = (props) => {
148
154
  const isLoaded = useRef(false);
149
155
  const widget_instance = (_c = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _c[name];
150
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";
151
160
  const containerStyles = useMemo(() => {
152
161
  if (!(styles == null ? void 0 : styles.backgroundImage)) {
153
162
  return styles;
@@ -200,6 +209,9 @@ const WmContainer = (props) => {
200
209
  viewParent.Widgets[props.name || partialName] = widget || props;
201
210
  isLoaded.current = true;
202
211
  onLoad == null ? void 0 : onLoad(widget || props);
212
+ if (!props.name && partialName) {
213
+ setPartialHostKey(partialName);
214
+ }
203
215
  }
204
216
  },
205
217
  [onLoad, props.name]
@@ -212,7 +224,7 @@ const WmContainer = (props) => {
212
224
  const classNames = (className == null ? void 0 : className.split(" ")) || [];
213
225
  return /* @__PURE__ */ jsx(
214
226
  "div",
215
- __spreadProps(__spreadValues(__spreadValues(__spreadValues({
227
+ __spreadProps(__spreadValues(__spreadProps(__spreadValues(__spreadValues(__spreadValues({
216
228
  className: clsx(
217
229
  {
218
230
  [className || ""]: Boolean(className),
@@ -224,10 +236,11 @@ const WmContainer = (props) => {
224
236
  ),
225
237
  "data-widget-id": props["data-widget-id"],
226
238
  id,
227
- hidden: props.hidden
239
+ hidden: props.hidden || hostShouldHide
228
240
  }, removeInvalidAttributes(rest)), domEvents), { name }), {
229
241
  style: __spreadValues(__spreadValues({}, containerStyles), conditionalstyle),
230
- ref: containerRef,
242
+ ref: containerRef
243
+ }), direction ? { direction } : {}), {
231
244
  children: renderPartial ? renderPartial(restPartialProps, handleOnLoad) : children
232
245
  })
233
246
  );
@@ -4,7 +4,7 @@ import { Container } from "@mui/material";
4
4
  import { withBaseWrapper } from "../../../../higherOrder/withBaseWrapper";
5
5
  const DEFAULT_CLASS = "app-grid-row clearfix";
6
6
  const WmGridrow = (props) => {
7
- return /* @__PURE__ */ jsx(Container, { style: props.styles, className: clsx(DEFAULT_CLASS, props.className), children: props.children });
7
+ return /* @__PURE__ */ jsx(Container, { style: props.styles, className: clsx(DEFAULT_CLASS, props.className), hidden: props.hidden, children: props.children });
8
8
  };
9
9
  WmGridrow.displayName = "WmGridrow";
10
10
  var grid_row_default = withBaseWrapper(WmGridrow);
@@ -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: isExpanded ? /* @__PURE__ */ jsx(ExpandLessIcon, { className: "wi-minus" }) : /* @__PURE__ */ jsx(ExpandMoreIcon, { className: "wi-plus" })
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
- currentStep == null ? void 0 : currentStep.onLoad(currentStep, currentStepIndex);
588
- }
589
- }, [currentStep == null ? void 0 : currentStep.onLoad]);
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
  );
@@ -8,4 +8,4 @@ import { UseFormSubmissionOptions, UseFormSubmissionReturn } from "../props";
8
8
  * - Success/error callbacks
9
9
  * - Data output notification
10
10
  */
11
- export declare function useFormSubmission({ formName, formfields, formDataref: externalFormDataref, getValues, formType, validateFieldsOnSubmit, resetFormData, toggleMessage, setShowViewMode, listener, datasource, formSubmit, widgettype, onBeforeSubmit, onSubmit, onResult, onSuccess, onError, insertmessage, updatemessage, deletemessage, postmessage, errormessage, messagelayout, standalone, }: UseFormSubmissionOptions): UseFormSubmissionReturn;
11
+ export declare function useFormSubmission({ formName, formfields, formDataref: externalFormDataref, getValues, formType, validateFieldsOnSubmit, resetFormData, toggleMessage, setShowViewMode, listener, datasource, formSubmit, widgettype, onBeforeSubmit, onSubmit, onResult, onSuccess, formSuccess, onError, insertmessage, updatemessage, deletemessage, postmessage, errormessage, messagelayout, standalone, }: UseFormSubmissionOptions): UseFormSubmissionReturn;
@@ -43,6 +43,7 @@ function useFormSubmission({
43
43
  onSubmit,
44
44
  onResult,
45
45
  onSuccess,
46
+ formSuccess,
46
47
  onError,
47
48
  insertmessage,
48
49
  updatemessage,
@@ -102,6 +103,7 @@ function useFormSubmission({
102
103
  }
103
104
  if (status) {
104
105
  onSuccess == null ? void 0 : onSuccess(event, {}, data);
106
+ formSuccess == null ? void 0 : formSuccess(event, {}, data);
105
107
  if (messagelayout === "Inline") {
106
108
  toggleMessage(true, "Data saved successfully", "success");
107
109
  }
@@ -113,7 +115,7 @@ function useFormSubmission({
113
115
  }
114
116
  }
115
117
  },
116
- [onResult, onSuccess, onError, messagelayout, errormessage, toggleMessage]
118
+ [onResult, onSuccess, formSuccess, onError, messagelayout, errormessage, toggleMessage]
117
119
  );
118
120
  const handleSubmitSuccess = useCallback(
119
121
  (data, resolve) => {
@@ -159,17 +159,7 @@ const BaseForm = (WrappedComponent) => {
159
159
  const formClassName = useMemo(() => {
160
160
  return isInsideWizard ? clsx(className) : clsx(DEFAULT_CLASS, className);
161
161
  }, [isInsideWizard, className]);
162
- const fields = useMemo(() => {
163
- const newFields = [];
164
- if (!formName) return newFields;
165
- const Widgets = (formProxy == null ? void 0 : formProxy.formfields) || {};
166
- Object.keys(Widgets).forEach((key) => {
167
- if (!key.includes("formWidget") && Widgets[key]) {
168
- newFields.push(Widgets[key]);
169
- }
170
- });
171
- return newFields;
172
- }, [formName]);
162
+ const onDataSourceChangeFiredRef = useRef(false);
173
163
  const registerHeaderAction = useCallback((actionName, action) => {
174
164
  if (!action || !actionName) return;
175
165
  setHeaderActions((prev) => {
@@ -317,6 +307,7 @@ const BaseForm = (WrappedComponent) => {
317
307
  onSubmit: props.onSubmit,
318
308
  onResult: props.onResult,
319
309
  onSuccess: props.onSuccess,
310
+ formSuccess: props.formSuccess,
320
311
  onError: props.onError,
321
312
  insertmessage: props.insertmessage,
322
313
  updatemessage: props.updatemessage,
@@ -539,10 +530,15 @@ const BaseForm = (WrappedComponent) => {
539
530
  debouncedFilter
540
531
  ]);
541
532
  useEffect(() => {
542
- if (props.onDataSourceChange && fields.length > 0) {
543
- props.onDataSourceChange(fields);
533
+ if (!props.onDataSourceChange || !formName) return;
534
+ if (onDataSourceChangeFiredRef.current) return;
535
+ const Widgets = (formProxy == null ? void 0 : formProxy.formfields) || {};
536
+ const currentFields = Object.keys(Widgets).filter((key) => !key.includes("formWidget") && Widgets[key]).map((key) => Widgets[key]);
537
+ if (currentFields.length > 0) {
538
+ onDataSourceChangeFiredRef.current = true;
539
+ props.onDataSourceChange(currentFields);
544
540
  }
545
- }, [fields, props.onDataSourceChange]);
541
+ }, [props.onDataSourceChange, formName]);
546
542
  useEffect(() => {
547
543
  if (formRef.current) {
548
544
  const formEl = formRef.current;
@@ -661,6 +657,7 @@ const BaseForm = (WrappedComponent) => {
661
657
  return {
662
658
  formdata: (_a2 = currentFormData != null ? currentFormData : widgetFormData) != null ? _a2 : formdata,
663
659
  formName: formName || "",
660
+ isValid,
664
661
  rootParentForm: isChildForm ? rootParentForm || "" : formName || "",
665
662
  parentDataPath: isChildForm ? fullDataPath : void 0,
666
663
  lastUpdateOrigin: isChildForm ? parentFormDataContext == null ? void 0 : parentFormDataContext.lastUpdateOrigin : lastUpdateOriginRef.current,
@@ -97,6 +97,8 @@ interface BaseFormProps extends BaseProps {
97
97
  onSubmit: (event: React.FormEvent<HTMLFormElement>, widget: any, data: any) => void;
98
98
  onError: (event: React.FormEvent<HTMLFormElement>, widget: any, error: any) => void;
99
99
  onSuccess: (event: React.FormEvent<HTMLFormElement>, widget?: any, data?: any) => void;
100
+ /** @deprecated Use onSuccess instead. Fired with the same args as onSuccess for backward compatibility. */
101
+ formSuccess?: (event: React.FormEvent<HTMLFormElement>, widget?: any, data?: any) => void;
100
102
  formSubmit: (event: React.FormEvent<HTMLFormElement>, widget: any, data: any, operation?: any) => void;
101
103
  onChange: (event: React.FormEvent<HTMLFormElement>, widget: any, data: any) => void;
102
104
  onBeforeSubmit: (event: React.FormEvent<HTMLFormElement>, widget: any, data: any) => boolean | string | object | Promise<boolean | string | object>;
@@ -280,6 +282,7 @@ export interface UseFormSubmissionOptions {
280
282
  onSubmit?: Function;
281
283
  onResult?: Function;
282
284
  onSuccess?: Function;
285
+ formSuccess?: Function;
283
286
  onError?: Function;
284
287
  insertmessage?: string;
285
288
  updatemessage?: string;
@@ -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(
@@ -73,6 +73,7 @@ const withFormController = (WrappedComponent) => {
73
73
  observe,
74
74
  onBlur,
75
75
  fieldName,
76
+ updateon,
76
77
  standalone = false
77
78
  } = _a, wrappedComponentProps = __objRest(_a, [
78
79
  "formRef",
@@ -97,6 +98,7 @@ const withFormController = (WrappedComponent) => {
97
98
  "observe",
98
99
  "onBlur",
99
100
  "fieldName",
101
+ "updateon",
100
102
  "standalone"
101
103
  ]);
102
104
  const [touched, setTouched] = useState(false);
@@ -193,10 +195,14 @@ const withFormController = (WrappedComponent) => {
193
195
  if (isValid === false) {
194
196
  return;
195
197
  }
198
+ if (updateon === "keypress" && effectiveFormKey) {
199
+ setTouched(true);
200
+ trigger(effectiveFormKey);
201
+ }
196
202
  (_a2 = props.onChange) == null ? void 0 : _a2.call(props, e, componentProps, newValue, oldValue);
197
203
  };
198
204
  },
199
- [type, props.datafield]
205
+ [type, props.datafield, updateon, effectiveFormKey]
200
206
  );
201
207
  const createOnBlurHandler = useCallback(
202
208
  (field, fieldState) => {
@@ -275,7 +281,18 @@ const withFormController = (WrappedComponent) => {
275
281
  })
276
282
  }), {
277
283
  listener: {
278
- onChange: props.onChangeHandler,
284
+ onChange: isMaxWidget && props.onChangeHandler ? (name2, data) => {
285
+ const remapped = __spreadValues({}, data);
286
+ if ("datavalue" in remapped) {
287
+ remapped.maxDataValue = remapped.datavalue;
288
+ delete remapped.datavalue;
289
+ }
290
+ if ("displayValue" in remapped) {
291
+ remapped.maxDisplayValue = remapped.displayValue;
292
+ delete remapped.displayValue;
293
+ }
294
+ props.onChangeHandler(name2, remapped);
295
+ } : props.onChangeHandler,
279
296
  Widgets: ((_a2 = props.listener) == null ? void 0 : _a2.Widgets) || {}
280
297
  }
281
298
  });
@@ -308,20 +325,6 @@ const withFormController = (WrappedComponent) => {
308
325
  })()
309
326
  }
310
327
  ),
311
- hint && !shouldShowErrorMessage(validationType, fieldState, touched) && /* @__PURE__ */ jsx(
312
- "p",
313
- {
314
- className: "help-block",
315
- "aria-hidden": "true",
316
- role: "alert",
317
- "aria-live": "polite",
318
- style: {
319
- textAlign: "start",
320
- width: "100%"
321
- },
322
- children: hint
323
- }
324
- ),
325
328
  shouldShowErrorMessage(validationType, fieldState, touched) && /* @__PURE__ */ jsx(
326
329
  "p",
327
330
  {
@@ -57,13 +57,15 @@ const BaseField = (WrappedComponent) => {
57
57
  }
58
58
  }
59
59
  function setFieldDataSet(dataset, options) {
60
- setRelatedData({
61
- displaylabel: props.displayfield = options.aliasColumn || LIVE_CONSTANTS.LABEL_VALUE,
62
- displayfield: props.displayfield = options.aliasColumn || LIVE_CONSTANTS.LABEL_VALUE,
60
+ const aliasDisplayField = options.aliasColumn || LIVE_CONSTANTS.LABEL_VALUE;
61
+ const newRelatedData = {
62
+ displaylabel: aliasDisplayField,
63
+ displayfield: aliasDisplayField,
63
64
  datafield: options.aliasColumn || LIVE_CONSTANTS.LABEL_KEY,
64
65
  searchkey: options.distinctField || LIVE_CONSTANTS.LABEL_KEY,
65
66
  dataset
66
- });
67
+ };
68
+ setRelatedData(newRelatedData);
67
69
  }
68
70
  const hasRequiredValidator = () => {
69
71
  const checkRequiredValidator = (validator) => {
@@ -134,7 +136,8 @@ const BaseField = (WrappedComponent) => {
134
136
  relatedData,
135
137
  isRequired,
136
138
  transformedFormKey,
137
- customValidationMsg
139
+ customValidationMsg,
140
+ formContext
138
141
  ]);
139
142
  return /* @__PURE__ */ createElement(
140
143
  WrappedComponent,
@@ -37,7 +37,7 @@ const DATASET_SYNC_KEYS = [
37
37
  ];
38
38
  const WmFormField = memo(
39
39
  (props) => {
40
- var _a, _b;
40
+ var _a, _b, _c, _d, _e;
41
41
  const { show = true, deferload } = props;
42
42
  const [proxyProps, setProxyProps] = useState(__spreadProps(__spreadValues({}, props), {
43
43
  show: show == null ? void 0 : show.toString(),
@@ -49,7 +49,8 @@ const WmFormField = memo(
49
49
  const overriddenItemsRef = useRef({});
50
50
  const fieldKey = props.formKey || props.name;
51
51
  const defaultValueRegisteredRef = useRef(false);
52
- const formReady = (formProxy == null ? void 0 : formProxy.listener) !== void 0;
52
+ const showfield = (_b = (_a = overriddenItemsRef == null ? void 0 : overriddenItemsRef.current) == null ? void 0 : _a.show) != null ? _b : show;
53
+ const formReady = (formProxy == null ? void 0 : formProxy.listener) !== void 0 || ((_c = props.formRef) == null ? void 0 : _c.name) === props.formName;
53
54
  const reset = useCallback(
54
55
  (value) => {
55
56
  const field = fieldProxyRef.current;
@@ -69,7 +70,7 @@ const WmFormField = memo(
69
70
  fieldProxyRef.current[key] = key === "datavalue" && isNumber && !Array.isArray(data[key]) ? Number(data[key]) : data[key];
70
71
  });
71
72
  setProxyProps((prev) => {
72
- return __spreadValues(__spreadValues({}, prev), isNumber && !Array.isArray(data.datavalue) ? __spreadProps(__spreadValues({}, data), { datavalue: Number(data.datavalue) }) : data);
73
+ return __spreadValues(__spreadValues({}, prev), isNumber && data.datavalue !== void 0 && !Array.isArray(data.datavalue) ? __spreadProps(__spreadValues({}, data), { datavalue: Number(data.datavalue) }) : data);
73
74
  });
74
75
  },
75
76
  [isNumber]
@@ -109,14 +110,20 @@ const WmFormField = memo(
109
110
  });
110
111
  }, [props.dataset, props.datafield, props.displayfield, props.displaylabel, props.searchkey]);
111
112
  function renderFormFields() {
112
- var _a2, _b2, _c;
113
+ var _a2, _b2, _c2, _d2, _e2, _f, _g, _h;
113
114
  if (props.formRef) {
114
115
  const errors = (_a2 = props.formRef) == null ? void 0 : _a2.errors;
115
116
  const formKey = (_b2 = props.formKey) != null ? _b2 : props.name;
116
117
  const fieldError = formKey && errors ? get(errors, formKey) : void 0;
117
118
  const invalid = Boolean(fieldError);
118
119
  const invalidCls = invalid ? " text-danger " : "";
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), {
120
+ return /* @__PURE__ */ jsx(Fragment, { children: (_h = props == null ? void 0 : props.renderFormFields) == null ? void 0 : _h.call(props, __spreadProps(__spreadValues(__spreadValues({}, proxyProps), overriddenItemsRef.current), {
121
+ show: showfield,
122
+ disabled: (_d2 = (_c2 = overriddenItemsRef == null ? void 0 : overriddenItemsRef.current) == null ? void 0 : _c2.disabled) != null ? _d2 : props == null ? void 0 : props.disabled,
123
+ readonly: (_f = (_e2 = overriddenItemsRef == null ? void 0 : overriddenItemsRef.current) == null ? void 0 : _e2.readonly) != null ? _f : props == null ? void 0 : props.readonly,
124
+ // BaseField derives this from live validators. A direct field-proxy write wins,
125
+ // but never fall back to the initial proxyProps.required snapshot.
126
+ required: (_g = overriddenItemsRef.current.required) != null ? _g : props.required,
120
127
  fieldError,
121
128
  validators: props.validators,
122
129
  asyncValidators: props.asyncValidators,
@@ -131,13 +138,13 @@ const WmFormField = memo(
131
138
  }
132
139
  }
133
140
  const isDynamicFormField = typeof props.className === "string" && props.className.includes("app-dynamic-form-field");
134
- const itemsPerRowClass = !isDynamicFormField && ((_a = props.formRef) == null ? void 0 : _a.itemsPerRow) || "";
141
+ const itemsPerRowClass = !isDynamicFormField && ((_d = props.formRef) == null ? void 0 : _d.itemsPerRow) || "";
135
142
  if (!fieldProxyRef.current) {
136
143
  return null;
137
144
  }
138
145
  const isDeferLoad = deferload === true;
139
- const showValue = ((_b = proxyProps == null ? void 0 : proxyProps.show) == null ? void 0 : _b.toString()) !== "false";
140
- if (!showValue && isDeferLoad) {
146
+ const showValue = ((_e = proxyProps == null ? void 0 : proxyProps.show) == null ? void 0 : _e.toString()) !== "false";
147
+ if ((!showValue || showfield) && isDeferLoad) {
141
148
  return null;
142
149
  }
143
150
  const shouldHide = !showValue && !isDeferLoad;
@@ -205,6 +205,7 @@ export interface FormFieldProps {
205
205
  observeOn?: any[];
206
206
  reset?: () => void;
207
207
  setValidationMessage?: (message: string) => void;
208
+ disabled?: boolean;
208
209
  }
209
210
  /**
210
211
  * Combined props for the WmFormField component, including base WaveMaker props.
@@ -6,6 +6,7 @@ import { MediaWmListtemplate } from "../templates/media-template";
6
6
  import { resolveDisableItem } from "../utils/list-helpers";
7
7
  import { useWidgetProxy } from "../../../../context/WidgetProvider";
8
8
  import isPlainObject from "lodash-es/isPlainObject";
9
+ import isEmpty from "lodash-es/isEmpty";
9
10
  const ListItemWithTemplate = ({
10
11
  item,
11
12
  index,
@@ -38,7 +39,7 @@ const ListItemWithTemplate = ({
38
39
  const getCurrentItemWidgets = useCallback(
39
40
  ($index) => {
40
41
  const cached = widgetCacheRef.current.get($index);
41
- if (cached) {
42
+ if (cached && !isEmpty(cached)) {
42
43
  return cached;
43
44
  }
44
45
  const items = {};
@@ -52,7 +53,9 @@ const ListItemWithTemplate = ({
52
53
  }
53
54
  }
54
55
  }
55
- widgetCacheRef.current.set($index, items);
56
+ if (!isEmpty(items)) {
57
+ widgetCacheRef.current.set($index, items);
58
+ }
56
59
  return items;
57
60
  },
58
61
  [WidgetProxy, name]
@@ -112,7 +112,7 @@ const useListEffects = (props) => {
112
112
  selectPageSize: (size) => widgetMethodsRef.current.selectPageSize(size)
113
113
  });
114
114
  }
115
- }, [name, showNavigation, items]);
115
+ }, [name, showNavigation, items == null ? void 0 : items.length]);
116
116
  useEffect(() => {
117
117
  if ((listener == null ? void 0 : listener.onChange) && props.navigation !== LIST_NAVIGATION_TYPES.NONE) {
118
118
  listener.onChange(name, {