@wavemaker-ai/react-runtime 1.0.0-rc.330 → 1.0.0-rc.334

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 (171) hide show
  1. package/actions/notification-action.js +3 -3
  2. package/actions/toast.js +2 -1
  3. package/components/advanced/carousel/index.d.ts +1 -0
  4. package/components/advanced/carousel/template.d.ts +1 -0
  5. package/components/advanced/login/index.d.ts +1 -0
  6. package/components/advanced/marquee/index.d.ts +1 -0
  7. package/components/basic/anchor/index.d.ts +1 -0
  8. package/components/basic/anchor/index.js +3 -5
  9. package/components/basic/audio/index.d.ts +1 -0
  10. package/components/basic/html/index.d.ts +1 -0
  11. package/components/basic/icon/index.d.ts +1 -0
  12. package/components/basic/iframe/index.d.ts +1 -0
  13. package/components/basic/label/index.d.ts +1 -0
  14. package/components/basic/message/index.js +1 -0
  15. package/components/basic/picture/index.d.ts +1 -0
  16. package/components/basic/progress-bar/index.d.ts +1 -0
  17. package/components/basic/progress-circle/index.d.ts +1 -0
  18. package/components/basic/richtexteditor/index.d.ts +2 -0
  19. package/components/basic/search/index.js +9 -11
  20. package/components/basic/search/providers.d.ts +1 -1
  21. package/components/basic/search/providers.js +6 -3
  22. package/components/basic/spinner/index.d.ts +1 -0
  23. package/components/basic/tile/index.d.ts +1 -0
  24. package/components/basic/tree/index.d.ts +1 -0
  25. package/components/basic/video/index.d.ts +1 -0
  26. package/components/chart/index.d.ts +1 -0
  27. package/components/container/accordion/accordion-pane/index.d.ts +1 -0
  28. package/components/container/accordion/index.d.ts +1 -0
  29. package/components/container/index.d.ts +4 -0
  30. package/components/container/index.js +33 -9
  31. package/components/container/layout-grid/grid-column/index.d.ts +1 -0
  32. package/components/container/layout-grid/grid-row/index.d.ts +1 -0
  33. package/components/container/layout-grid/index.d.ts +1 -0
  34. package/components/container/layout-grid/index.js +2 -1
  35. package/components/container/linear-layout/index.d.ts +1 -0
  36. package/components/container/linear-layout/index.js +0 -1
  37. package/components/container/linear-layout/linear-layout-item/index.d.ts +1 -0
  38. package/components/container/panel/index.d.ts +1 -0
  39. package/components/container/props.d.ts +1 -0
  40. package/components/container/repeat-template/index.d.ts +1 -0
  41. package/components/container/repeat-template/index.js +1 -1
  42. package/components/container/tabs/index.d.ts +1 -0
  43. package/components/container/tabs/index.js +8 -6
  44. package/components/container/tabs/tab-pane/index.d.ts +1 -0
  45. package/components/container/tabs/tab-pane/index.js +2 -2
  46. package/components/container/wizard/index.d.ts +2 -0
  47. package/components/container/wizard/index.js +56 -40
  48. package/components/container/wizard/wizard-step/index.d.ts +1 -0
  49. package/components/data/card/card-actions/index.d.ts +1 -0
  50. package/components/data/card/card-content/index.d.ts +1 -0
  51. package/components/data/card/card-footer/index.d.ts +1 -0
  52. package/components/data/card/index.d.ts +1 -0
  53. package/components/data/form/base-form/hooks/useFormOperations.d.ts +1 -1
  54. package/components/data/form/base-form/hooks/useFormOperations.js +14 -17
  55. package/components/data/form/base-form/index.js +22 -23
  56. package/components/data/form/base-form/props.d.ts +1 -0
  57. package/components/data/form/base-form/utils.js +5 -4
  58. package/components/data/form/form-action/index.d.ts +4 -2
  59. package/components/data/form/form-action/index.js +2 -2
  60. package/components/data/form/form-context.d.ts +12 -13
  61. package/components/data/form/form-context.js +4 -6
  62. package/components/data/form/form-controller/withFormController.js +20 -7
  63. package/components/data/form/form-field/index.js +40 -15
  64. package/components/data/form/form-field/props.d.ts +7 -2
  65. package/components/data/list/components/ListItems.js +1 -3
  66. package/components/data/list/index.d.ts +2 -0
  67. package/components/data/list/index.js +6 -11
  68. package/components/data/pagination/hooks/usePagination.js +8 -8
  69. package/components/data/table/components/RowExpansionButton.js +5 -1
  70. package/components/data/table/components/TableBody.js +4 -1
  71. package/components/data/table/components/TableDataRow.js +1 -1
  72. package/components/data/table/components/TableHeader.js +3 -1
  73. package/components/data/table/hooks/useFormWidget.js +2 -2
  74. package/components/data/table/hooks/usePanelStructure.js +6 -1
  75. package/components/data/table/hooks/useResponsiveColumns.d.ts +1 -0
  76. package/components/data/table/hooks/useRowHandlers.js +3 -3
  77. package/components/data/table/hooks/useRowSelection.js +22 -13
  78. package/components/data/table/hooks/useTableColumns.js +5 -5
  79. package/components/data/table/hooks/useTableData.js +10 -2
  80. package/components/data/table/index.d.ts +2 -0
  81. package/components/data/table/index.js +15 -14
  82. package/components/data/table/live-table/index.d.ts +1 -0
  83. package/components/data/table/props.d.ts +9 -8
  84. package/components/data/table/table-action/index.d.ts +1 -0
  85. package/components/data/table/table-column/index.d.ts +1 -0
  86. package/components/data/table/table-row/index.d.ts +1 -0
  87. package/components/data/table/table-row-action/index.d.ts +1 -0
  88. package/components/data/table/utils/buildSelectionColumns.js +45 -50
  89. package/components/data/table/utils/crud-handlers.js +3 -1
  90. package/components/data/table/utils/expansionColumn.js +1 -1
  91. package/components/data/table/utils/index.d.ts +10 -3
  92. package/components/data/table/utils/index.js +20 -9
  93. package/components/data/table/utils/selectionUtils.d.ts +14 -0
  94. package/components/data/table/utils/selectionUtils.js +33 -1
  95. package/components/dialogs/alert-dialog/index.d.ts +2 -0
  96. package/components/dialogs/confirm-dialog/index.d.ts +2 -0
  97. package/components/dialogs/dialog/index.d.ts +2 -0
  98. package/components/dialogs/dialog-actions/index.d.ts +1 -0
  99. package/components/dialogs/dialog-actions/index.js +11 -2
  100. package/components/dialogs/dialog-body/index.d.ts +1 -0
  101. package/components/dialogs/dialog-content/index.d.ts +1 -0
  102. package/components/dialogs/dialog-header/index.d.ts +1 -0
  103. package/components/dialogs/iframe-dialog/index.d.ts +2 -0
  104. package/components/dialogs/login-dialog/index.d.ts +2 -0
  105. package/components/dialogs/page-dialog/index.d.ts +2 -0
  106. package/components/dialogs/withDialogWrapper.js +12 -2
  107. package/components/form/button/index.d.ts +1 -0
  108. package/components/form/button-group/index.d.ts +1 -0
  109. package/components/input/calendar/index.d.ts +2 -0
  110. package/components/input/chips/index.d.ts +2 -0
  111. package/components/input/color-picker/index.d.ts +2 -0
  112. package/components/input/composite/index.d.ts +1 -0
  113. package/components/input/composite/index.js +32 -6
  114. package/components/input/default/checkbox/index.d.ts +2 -0
  115. package/components/input/default/checkboxset/index.d.ts +2 -0
  116. package/components/input/default/radioset/index.d.ts +2 -0
  117. package/components/input/default/switch/index.d.ts +2 -0
  118. package/components/input/epoch/date/index.d.ts +1 -0
  119. package/components/input/epoch/date/index.js +2 -1
  120. package/components/input/epoch/date/utils.js +4 -2
  121. package/components/input/epoch/datetime/index.d.ts +1 -0
  122. package/components/input/epoch/datetime/index.js +5 -3
  123. package/components/input/epoch/datetime/props.d.ts +2 -2
  124. package/components/input/epoch/time/index.d.ts +1 -0
  125. package/components/input/epoch/time/utils.d.ts +1 -1
  126. package/components/input/epoch/time/utils.js +2 -2
  127. package/components/input/fileupload/index.d.ts +1 -0
  128. package/components/input/fileupload/index.js +2 -1
  129. package/components/input/fileupload/useFileUpload.js +19 -24
  130. package/components/input/number/index.d.ts +2 -0
  131. package/components/input/rating/index.d.ts +2 -0
  132. package/components/input/select/index.js +6 -3
  133. package/components/input/slider/index.d.ts +2 -0
  134. package/components/input/text/index.d.ts +2 -0
  135. package/components/input/text/index.js +9 -2
  136. package/components/input/textarea/index.d.ts +2 -0
  137. package/components/input/upload/index.d.ts +2 -0
  138. package/components/navbar/index.d.ts +1 -0
  139. package/components/navbar/nav-item/index.d.ts +1 -0
  140. package/components/navigation/breadcrumb/index.d.ts +1 -0
  141. package/components/navigation/menu/index.d.ts +1 -0
  142. package/components/navigation/menu/index.js +13 -9
  143. package/components/navigation/menu/props.d.ts +1 -0
  144. package/components/navigation/popover/index.d.ts +2 -1
  145. package/components/navigation/popover/index.js +16 -4
  146. package/components/navigation/popover/props.d.ts +1 -1
  147. package/components/page/partial/index.d.ts +1 -0
  148. package/context/PopoverContext.d.ts +5 -0
  149. package/context/PopoverContext.js +5 -0
  150. package/context/WidgetProvider.js +9 -2
  151. package/core/proxy-service.d.ts +18 -1
  152. package/core/proxy-service.js +84 -14
  153. package/higherOrder/BaseApp.js +2 -1
  154. package/higherOrder/BaseDateTime.js +8 -1
  155. package/higherOrder/BasePage.js +9 -11
  156. package/higherOrder/props.d.ts +1 -0
  157. package/higherOrder/useActivePageReactivity.js +1 -4
  158. package/higherOrder/withBaseWrapper.js +6 -6
  159. package/package-lock.json +203 -185
  160. package/package.json +3 -3
  161. package/runtime-dynamic/components/PageWrapper.js +1 -1
  162. package/runtime-dynamic/components/PrefabPreview.js +1 -1
  163. package/runtime-dynamic/components/partial-content.js +17 -1
  164. package/runtime-dynamic/factories/build-base-page-like-component.js +11 -7
  165. package/runtime-dynamic/factories/dynamic-component.js +1 -7
  166. package/runtime-dynamic/routes.js +17 -8
  167. package/utils/page-params-util.js +22 -1
  168. package/utils/partial-host-util.d.ts +40 -0
  169. package/utils/partial-host-util.js +41 -0
  170. package/variables/model-variable.d.ts +2 -0
  171. package/variables/model-variable.js +14 -0
@@ -47,7 +47,7 @@ const WmTabpane = (props) => {
47
47
  listener.onChange(tabsContainerName, { activeTab: widgetInstance });
48
48
  }
49
49
  if (isActive) {
50
- if (!loadedRef.current) {
50
+ if (!loadedRef.current && !renderPartial) {
51
51
  (_c = props == null ? void 0 : props.onLoad) == null ? void 0 : _c.call(props, null, widgetInstance);
52
52
  loadedRef.current = true;
53
53
  }
@@ -95,7 +95,7 @@ const WmTabpane = (props) => {
95
95
  return;
96
96
  }
97
97
  updatePaneHeader(name, headerProps);
98
- }, [name, headerProps, updatePaneHeader]);
98
+ }, [name, updatePaneHeader]);
99
99
  return /* @__PURE__ */ jsx(
100
100
  Tabs.Panel,
101
101
  __spreadProps(__spreadValues(__spreadValues({
@@ -38,6 +38,7 @@ declare const WmWizardStandalone: React.ComponentType<{
38
38
  padding?: string;
39
39
  margin?: string;
40
40
  className?: string;
41
+ class?: string;
41
42
  conditionalstyle?: React.CSSProperties;
42
43
  conditionalclass?: string;
43
44
  showindevice?: ("xs" | "sm" | "md" | "lg" | "all")[];
@@ -130,6 +131,7 @@ declare const _default: React.ComponentType<{
130
131
  padding?: string;
131
132
  margin?: string;
132
133
  className?: string;
134
+ class?: string;
133
135
  conditionalstyle?: React.CSSProperties;
134
136
  conditionalclass?: string;
135
137
  showindevice?: ("xs" | "sm" | "md" | "lg" | "all")[];
@@ -147,6 +147,10 @@ const WmWizardComponent = memo(
147
147
  );
148
148
  const currentStep = useMemo(() => steps.find((step) => step.active) || null, [steps]);
149
149
  const visibleSteps = useMemo(() => steps.filter((step) => step.show), [steps]);
150
+ const visibleStepsRef = useRef(visibleSteps);
151
+ visibleStepsRef.current = visibleSteps;
152
+ const stepsRef = useRef(steps);
153
+ stepsRef.current = steps;
150
154
  const currentStepIndex = useMemo(() => {
151
155
  if (!currentStep) return -1;
152
156
  return visibleSteps.findIndex((step) => step.name === currentStep.name);
@@ -284,27 +288,34 @@ const WmWizardComponent = memo(
284
288
  () => stepstyle === "justified" ? "justified" : "auto",
285
289
  [stepstyle]
286
290
  );
291
+ const activateStep = useCallback(
292
+ (step) => {
293
+ if (!step.show || step.disabled) return;
294
+ setSteps(
295
+ (prevSteps) => prevSteps.map((s) => {
296
+ const stepIndex = prevSteps.findIndex((ps) => ps.name === s.name);
297
+ const targetIndex = prevSteps.findIndex((ps) => ps.name === step.name);
298
+ return __spreadProps(__spreadValues({}, s), {
299
+ active: s.name === step.name,
300
+ isDone: type === "dynamic" ? stepIndex < targetIndex : stepIndex < targetIndex,
301
+ done: type === "dynamic" ? stepIndex < targetIndex : stepIndex < targetIndex || s.name === step.name && targetIndex > 0,
302
+ disabled: false,
303
+ // Ensure enableNext and isValid are preserved when activating a step
304
+ enableNext: s.name === step.name ? true : s.enableNext,
305
+ isValid: s.name === step.name ? true : s.isValid
306
+ });
307
+ })
308
+ );
309
+ },
310
+ [type]
311
+ );
287
312
  const onStepHeaderClick = useCallback(
288
313
  (event, step) => {
289
- if ((step.done || step.isDone || nonLinear && type === "dynamic") && step.show && !step.disabled) {
290
- setSteps(
291
- (prevSteps) => prevSteps.map((s) => {
292
- const stepIndex = prevSteps.findIndex((ps) => ps.name === s.name);
293
- const targetIndex = prevSteps.findIndex((ps) => ps.name === step.name);
294
- return __spreadProps(__spreadValues({}, s), {
295
- active: s.name === step.name,
296
- isDone: type === "dynamic" ? stepIndex < targetIndex : stepIndex < targetIndex,
297
- done: type === "dynamic" ? stepIndex < targetIndex : stepIndex < targetIndex || s.name === step.name && targetIndex > 0,
298
- disabled: false,
299
- // Ensure enableNext and isValid are preserved when activating a step
300
- enableNext: s.name === step.name ? true : s.enableNext,
301
- isValid: s.name === step.name ? true : s.isValid
302
- });
303
- })
304
- );
314
+ if (step.done || step.isDone || nonLinear && type === "dynamic") {
315
+ activateStep(step);
305
316
  }
306
317
  },
307
- [nonLinear, type]
318
+ [nonLinear, type, activateStep]
308
319
  );
309
320
  const handleStepClick = useCallback(
310
321
  (index) => {
@@ -334,62 +345,64 @@ const WmWizardComponent = memo(
334
345
  const next = useCallback(
335
346
  async (eventName = "next") => {
336
347
  var _a, _b;
348
+ const currentVisibleSteps = visibleStepsRef.current;
337
349
  const fromIndex = navIndexRef.current >= 0 ? navIndexRef.current : currentStepIndex;
338
- const fromStep = getStepByIndex(fromIndex, visibleSteps);
350
+ const fromStep = getStepByIndex(fromIndex, currentVisibleSteps);
339
351
  if (!fromStep) return;
340
- const nextStep = getNextValidStep(fromIndex + 1, visibleSteps);
352
+ const nextStep = getNextValidStep(fromIndex + 1, currentVisibleSteps);
341
353
  if (!nextStep) return;
342
- const nextIndex = visibleSteps.findIndex((s) => s.name === nextStep.name);
354
+ const nextIndex = currentVisibleSteps.findIndex((s) => s.name === nextStep.name);
343
355
  if (eventName === "skip") {
344
356
  const response = (_a = fromStep.onSkip) == null ? void 0 : _a.call(fromStep, fromStep, fromStep, fromIndex);
345
357
  if (response !== void 0) {
346
358
  await handleNavigation(
347
359
  response,
348
- () => extendNextFn(fromStep, fromIndex, visibleSteps, setSteps)
360
+ () => extendNextFn(fromStep, fromIndex, currentVisibleSteps, setSteps)
349
361
  );
350
362
  } else {
351
- extendNextFn(fromStep, fromIndex, visibleSteps, setSteps);
363
+ extendNextFn(fromStep, fromIndex, currentVisibleSteps, setSteps);
352
364
  }
353
365
  } else if (fromStep.isValid && eventName === "next") {
354
366
  const response = (_b = fromStep.onNext) == null ? void 0 : _b.call(fromStep, fromStep, fromStep, fromIndex);
355
367
  if (response !== void 0) {
356
368
  await handleNavigation(
357
369
  response,
358
- () => extendNextFn(fromStep, fromIndex, visibleSteps, setSteps)
370
+ () => extendNextFn(fromStep, fromIndex, currentVisibleSteps, setSteps)
359
371
  );
360
372
  } else {
361
- extendNextFn(fromStep, fromIndex, visibleSteps, setSteps);
373
+ extendNextFn(fromStep, fromIndex, currentVisibleSteps, setSteps);
362
374
  }
363
375
  } else if (enablenext && !fromStep.isValid) {
364
376
  console.warn("Cannot proceed: current step is invalid");
365
377
  } else {
366
- extendNextFn(fromStep, fromIndex, visibleSteps, setSteps);
378
+ extendNextFn(fromStep, fromIndex, currentVisibleSteps, setSteps);
367
379
  }
368
380
  navIndexRef.current = nextIndex;
369
381
  setFormReady(false);
370
382
  },
371
- [currentStepIndex, visibleSteps, enablenext]
383
+ [currentStepIndex, enablenext]
372
384
  );
373
385
  const prev = useCallback(async () => {
374
386
  var _a;
387
+ const currentVisibleSteps = visibleStepsRef.current;
375
388
  const fromIndex = navIndexRef.current >= 0 ? navIndexRef.current : currentStepIndex;
376
- const fromStep = getStepByIndex(fromIndex, visibleSteps);
389
+ const fromStep = getStepByIndex(fromIndex, currentVisibleSteps);
377
390
  if (!fromStep) return;
378
- const targetStep = getPrevValidStep(fromIndex - 1, visibleSteps);
391
+ const targetStep = getPrevValidStep(fromIndex - 1, currentVisibleSteps);
379
392
  if (!targetStep) return;
380
- const prevIndex = visibleSteps.findIndex((s) => s.name === targetStep.name);
393
+ const prevIndex = currentVisibleSteps.findIndex((s) => s.name === targetStep.name);
381
394
  const response = (_a = fromStep.onPrev) == null ? void 0 : _a.call(fromStep, fromStep, fromStep, fromIndex);
382
395
  if (response !== void 0) {
383
396
  await handleNavigation(
384
397
  response,
385
- () => extendPrevFn(fromStep, fromIndex, visibleSteps, setSteps)
398
+ () => extendPrevFn(fromStep, fromIndex, currentVisibleSteps, setSteps)
386
399
  );
387
400
  } else {
388
- extendPrevFn(fromStep, fromIndex, visibleSteps, setSteps);
401
+ extendPrevFn(fromStep, fromIndex, currentVisibleSteps, setSteps);
389
402
  }
390
403
  navIndexRef.current = prevIndex;
391
404
  setFormReady(false);
392
- }, [currentStepIndex, visibleSteps]);
405
+ }, [currentStepIndex]);
393
406
  const registerStep = useCallback((stepData) => {
394
407
  setSteps((prevSteps) => {
395
408
  const existingIndex = prevSteps.findIndex((step) => step.name === stepData.name);
@@ -426,31 +439,33 @@ const WmWizardComponent = memo(
426
439
  }, [onCancel, steps]);
427
440
  const gotoStep = useCallback(
428
441
  (step) => {
442
+ const currentSteps = stepsRef.current;
443
+ const currentVisibleSteps = visibleStepsRef.current;
429
444
  let gotoStepIndex;
430
445
  let targetStep = null;
431
446
  if (typeof step === "string") {
432
- gotoStepIndex = steps.map((s) => s.name).indexOf(step);
447
+ gotoStepIndex = currentSteps.map((s) => s.name).indexOf(step);
433
448
  if (gotoStepIndex === -1) {
434
449
  console.error(`Could not find step '${step}'`);
435
450
  return;
436
451
  }
437
- targetStep = steps[gotoStepIndex];
452
+ targetStep = currentSteps[gotoStepIndex];
438
453
  } else if (typeof step === "number" && step >= 0) {
439
454
  gotoStepIndex = step;
440
- targetStep = getStepByIndex(step, visibleSteps);
455
+ targetStep = getStepByIndex(step, currentVisibleSteps);
441
456
  } else {
442
457
  console.error("Invalid step name or index provided");
443
458
  return;
444
459
  }
445
460
  if (targetStep == null ? void 0 : targetStep.show) {
446
- const visIndex = visibleSteps.findIndex((s) => s.name === (targetStep == null ? void 0 : targetStep.name));
461
+ const visIndex = currentVisibleSteps.findIndex((s) => s.name === (targetStep == null ? void 0 : targetStep.name));
447
462
  if (visIndex >= 0) navIndexRef.current = visIndex;
448
- onStepHeaderClick({}, targetStep);
463
+ activateStep(targetStep);
449
464
  } else {
450
465
  console.error("The gotoStep function cannot navigate to hidden steps");
451
466
  }
452
467
  },
453
- [steps, visibleSteps, onStepHeaderClick]
468
+ [activateStep]
454
469
  );
455
470
  const setDefaultStep = useCallback(
456
471
  (step) => {
@@ -547,7 +562,8 @@ const WmWizardComponent = memo(
547
562
  currentStepIndex,
548
563
  isFirstStep,
549
564
  isLastStep,
550
- visibleSteps
565
+ visibleSteps,
566
+ gotoStep
551
567
  ]);
552
568
  useEffect(() => {
553
569
  updateListener();
@@ -754,7 +770,7 @@ const WmWizardComponent = memo(
754
770
  className: clsx("app-wizard-step-container", {
755
771
  active: step.active
756
772
  }),
757
- hidden: !step.active,
773
+ hidden: !step.active || step.show === false || step.show === "false",
758
774
  name: step.name,
759
775
  children: isInsideOuterForm ? (
760
776
  // Inside outer form - use div, fields/forms pass through to outer form context
@@ -19,6 +19,7 @@ declare const _default: import("react").ComponentType<{
19
19
  width?: number | string;
20
20
  height?: number | string;
21
21
  className?: string;
22
+ class?: string;
22
23
  conditionalstyle?: import("react").CSSProperties;
23
24
  conditionalclass?: string;
24
25
  showindevice?: ("xs" | "sm" | "md" | "lg" | "all")[];
@@ -23,6 +23,7 @@ declare const _default: React.ComponentType<{
23
23
  width?: number | string;
24
24
  height?: number | string;
25
25
  className?: string;
26
+ class?: string;
26
27
  conditionalstyle?: React.CSSProperties;
27
28
  conditionalclass?: string;
28
29
  showindevice?: ("xs" | "sm" | "md" | "lg" | "all")[];
@@ -23,6 +23,7 @@ declare const _default: React.ComponentType<{
23
23
  width?: number | string;
24
24
  height?: number | string;
25
25
  className?: string;
26
+ class?: string;
26
27
  conditionalstyle?: React.CSSProperties;
27
28
  conditionalclass?: string;
28
29
  showindevice?: ("xs" | "sm" | "md" | "lg" | "all")[];
@@ -23,6 +23,7 @@ declare const _default: React.ComponentType<{
23
23
  width?: number | string;
24
24
  height?: number | string;
25
25
  className?: string;
26
+ class?: string;
26
27
  conditionalstyle?: React.CSSProperties;
27
28
  conditionalclass?: string;
28
29
  showindevice?: ("xs" | "sm" | "md" | "lg" | "all")[];
@@ -46,6 +46,7 @@ declare const _default: React.ComponentType<{
46
46
  width?: number | string;
47
47
  height?: number | string;
48
48
  className?: string;
49
+ class?: string;
49
50
  conditionalstyle?: React.CSSProperties;
50
51
  conditionalclass?: string;
51
52
  showindevice?: ("xs" | "sm" | "md" | "lg" | "all")[];
@@ -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, formProxy, widgetFormType, debouncedFilter, }: UseFormOperationsOptions): UseFormOperationsReturn;
13
+ export declare function useFormOperations({ formName, formfields, formRef, formReff, formType, fullDataPath, parentFormDataContext, clearFormData, resetFormData, trigger, submit, formProxy, widgetFormType, debouncedFilter, onReset, }: UseFormOperationsOptions): UseFormOperationsReturn;
@@ -1,4 +1,5 @@
1
1
  import { useState, useCallback } from "react";
2
+ import { getFormFieldEntries } from "../../../../../core/proxy-service";
2
3
  import { cleanNullValues } from "../utils";
3
4
  import { usesPrefixedFields } from "../props";
4
5
  function useFormOperations({
@@ -15,32 +16,26 @@ function useFormOperations({
15
16
  submit,
16
17
  formProxy,
17
18
  widgetFormType,
18
- debouncedFilter
19
+ debouncedFilter,
20
+ onReset
19
21
  }) {
20
22
  const hasPrefixedFields = usesPrefixedFields(formType);
21
23
  const [showViewMode, setShowViewMode] = useState(false);
22
24
  const formreset = useCallback(async () => {
23
25
  const cleanedData = {};
24
26
  const formNamePrefix = `${formName}.`;
25
- Object.keys(formfields).forEach((key) => {
26
- var _a, _b;
27
- if (formfields[key].formName !== formName) return;
27
+ getFormFieldEntries(formfields).forEach(({ key, field }) => {
28
+ if (field.formName !== formName) return;
28
29
  if (key.endsWith("_formWidget")) return;
29
- let fieldKey = key;
30
- if (hasPrefixedFields) {
31
- if (key.startsWith(formNamePrefix)) {
32
- fieldKey = key.substring(formNamePrefix.length);
33
- } else {
34
- return;
35
- }
36
- }
37
- if (formfields[key].readonly || formfields[key].readOnly || formfields[key].disabled) {
38
- cleanedData[fieldKey] = formfields[key].defaultvalue || formfields[key].value;
30
+ if (hasPrefixedFields && !key.startsWith(formNamePrefix)) return;
31
+ const fieldKey = hasPrefixedFields ? key.slice(formNamePrefix.length) : key;
32
+ if (field.readonly || field.readOnly || field.disabled) {
33
+ cleanedData[fieldKey] = field.defaultvalue || field.value;
39
34
  } else {
40
35
  cleanedData[fieldKey] = "";
36
+ field.datavalue = "";
41
37
  }
42
- const isRange = ((_a = formfields[key]) == null ? void 0 : _a.isRange) === true || ((_b = formfields[key]) == null ? void 0 : _b.isRange) === "true";
43
- if (widgetFormType === "live-filter" && isRange) {
38
+ if (widgetFormType === "live-filter" && (field.isRange === true || field.isRange === "true")) {
44
39
  cleanedData[`${fieldKey}_maxWidget`] = "";
45
40
  }
46
41
  });
@@ -59,6 +54,7 @@ function useFormOperations({
59
54
  return (_a = childForm == null ? void 0 : childForm.formreset) == null ? void 0 : _a.call(childForm);
60
55
  });
61
56
  }
57
+ onReset == null ? void 0 : onReset();
62
58
  }, [
63
59
  formName,
64
60
  formfields,
@@ -68,7 +64,8 @@ function useFormOperations({
68
64
  fullDataPath,
69
65
  parentFormDataContext,
70
66
  formRef,
71
- formReff
67
+ formReff,
68
+ onReset
72
69
  ]);
73
70
  const create = useCallback(() => {
74
71
  formreset();
@@ -50,6 +50,7 @@ import {
50
50
  usesPrefixedFields
51
51
  } from "./hooks";
52
52
  import { useWidgetProxy } from "../../../../context/WidgetProvider";
53
+ import { getFormFieldList } from "../../../../core/proxy-service";
53
54
  import {
54
55
  useAppNotificationAction,
55
56
  useNotifyApp
@@ -324,7 +325,7 @@ const BaseForm = (WrappedComponent) => {
324
325
  e == null ? void 0 : e.preventDefault();
325
326
  e == null ? void 0 : e.stopPropagation();
326
327
  const transformedData = transformRangeFilterData(data);
327
- return livefilterFn(transformedData, false, formfieldsRef.current);
328
+ return livefilterFn(transformedData, false, formProxy == null ? void 0 : formProxy.formfields);
328
329
  }),
329
330
  [handleSubmit, livefilterFn]
330
331
  );
@@ -333,7 +334,7 @@ const BaseForm = (WrappedComponent) => {
333
334
  debouncedFn();
334
335
  }, [filter]);
335
336
  const {
336
- formreset: formresetFn,
337
+ formreset,
337
338
  create,
338
339
  edit,
339
340
  setFormData,
@@ -355,13 +356,14 @@ const BaseForm = (WrappedComponent) => {
355
356
  submit,
356
357
  formProxy: formProxy || {},
357
358
  widgetFormType: props["form-type"],
358
- debouncedFilter
359
+ debouncedFilter,
360
+ onReset: props.onReset
359
361
  });
360
362
  const clearFilter = useMemo(
361
363
  () => handleSubmit((data, e) => {
362
364
  e == null ? void 0 : e.preventDefault();
363
365
  e == null ? void 0 : e.stopPropagation();
364
- formresetFn();
366
+ formreset();
365
367
  const transformedData = transformRangeFilterData(data);
366
368
  livefilterFn(transformedData, true, formfieldsRef.current);
367
369
  }),
@@ -378,9 +380,8 @@ const BaseForm = (WrappedComponent) => {
378
380
  return;
379
381
  }
380
382
  setShowViewMode(true);
381
- formresetFn();
382
- }, [setShowViewMode, props.cancel, formresetFn]);
383
- const getFieldValue = useCallback((fieldName) => watch(fieldName), [watch]);
383
+ formreset();
384
+ }, [setShowViewMode, props.cancel, formreset]);
384
385
  const highlightInvalidFields = useCallback(async () => {
385
386
  await validateFieldsOnSubmit();
386
387
  }, [validateFieldsOnSubmit]);
@@ -447,23 +448,20 @@ const BaseForm = (WrappedComponent) => {
447
448
  var _a2;
448
449
  if (!formName || !formRef.current) return;
449
450
  (_a2 = props == null ? void 0 : props.destroy) == null ? void 0 : _a2.call(props, formName);
450
- formresetFn();
451
+ formreset();
451
452
  };
452
453
  }, []);
453
454
  useEffect(() => {
454
455
  const registerFn = parentFormDataContext == null ? void 0 : parentFormDataContext.registerChildField;
455
456
  if (!registerFn || !formName) return;
456
457
  const widgetFormFields = getWidgetFormFields(listener, formName);
457
- const formFieldsToRegister = widgetFormFields || formfields;
458
- Object.entries(formFieldsToRegister).forEach(([key, widget]) => {
459
- if (key.includes("formWidget")) return;
460
- const typedWidget = widget;
461
- const formKey = (typedWidget == null ? void 0 : typedWidget.formKey) || (typedWidget == null ? void 0 : typedWidget.fieldName) || key;
462
- const fieldName = (typedWidget == null ? void 0 : typedWidget.fieldName) || key;
458
+ getFormFieldList(widgetFormFields || formfields).forEach((field) => {
459
+ const fieldName = (field == null ? void 0 : field.fieldName) || (field == null ? void 0 : field.name);
460
+ if (!fieldName) return;
463
461
  registerFn({
464
462
  childFormName: formName,
465
- widget,
466
- formKey,
463
+ widget: field,
464
+ formKey: (field == null ? void 0 : field.formKey) || fieldName,
467
465
  fieldName
468
466
  });
469
467
  });
@@ -532,8 +530,7 @@ const BaseForm = (WrappedComponent) => {
532
530
  useEffect(() => {
533
531
  if (!props.onDataSourceChange || !formName) return;
534
532
  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]);
533
+ const currentFields = getFormFieldList(formProxy == null ? void 0 : formProxy.formfields);
537
534
  if (currentFields.length > 0) {
538
535
  onDataSourceChangeFiredRef.current = true;
539
536
  props.onDataSourceChange(currentFields);
@@ -558,7 +555,7 @@ const BaseForm = (WrappedComponent) => {
558
555
  }
559
556
  const formId = formIdRef.current;
560
557
  parentFormRef.current[formId] = {
561
- formreset: formresetFn,
558
+ formreset,
562
559
  validateFieldsOnSubmit
563
560
  };
564
561
  return () => {
@@ -566,7 +563,7 @@ const BaseForm = (WrappedComponent) => {
566
563
  delete parentFormRef.current[formId];
567
564
  }
568
565
  };
569
- }, [parentFormRef, formresetFn, validateFieldsOnSubmit]);
566
+ }, [parentFormRef, formreset, validateFieldsOnSubmit]);
570
567
  const computedFormdata = widgetFormData || childFormData || formdata;
571
568
  const ref = useMemo(
572
569
  () => ({
@@ -588,7 +585,8 @@ const BaseForm = (WrappedComponent) => {
588
585
  showViewMode,
589
586
  formdata: computedFormdata,
590
587
  submit,
591
- formreset: formresetFn
588
+ formreset,
589
+ setValue
592
590
  }),
593
591
  [
594
592
  updateFormData,
@@ -608,13 +606,14 @@ const BaseForm = (WrappedComponent) => {
608
606
  showViewMode,
609
607
  computedFormdata,
610
608
  submit,
611
- formresetFn
609
+ formreset,
610
+ setValue
612
611
  ]
613
612
  );
614
613
  const conditionalProps = __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, props.target && { target: props.target }), props.method && { method: props.method }), props.encType && { encType: props.encType }), props.action && { action: props.action });
615
614
  const formProps = __spreadProps(__spreadValues(__spreadValues({}, props), conditionalProps), {
616
615
  submit,
617
- formreset: formresetFn,
616
+ formreset,
618
617
  formfields,
619
618
  formWidgets: formfields,
620
619
  headerActions,
@@ -252,6 +252,7 @@ export interface UseFormOperationsOptions {
252
252
  widgetFormType?: string;
253
253
  autoupdate?: string;
254
254
  debouncedFilter?: () => void;
255
+ onReset?: () => void;
255
256
  }
256
257
  export interface UseFormOperationsReturn {
257
258
  formreset: () => Promise<void>;
@@ -29,6 +29,7 @@ import {
29
29
  some
30
30
  } from "lodash-es";
31
31
  import { REGEX } from "./constant";
32
+ import { defineFieldAlias } from "../../../../core/proxy-service";
32
33
  let userAgent = "";
33
34
  if (typeof window !== "undefined") {
34
35
  userAgent = window.navigator.userAgent;
@@ -272,10 +273,10 @@ const registerChildFieldInWidget = (listener, formName, data) => {
272
273
  const parentFormContext = listener.Widgets[formName];
273
274
  parentFormContext.formfields = parentFormContext.formfields || {};
274
275
  parentFormContext.formWidgets = parentFormContext.formWidgets || {};
275
- parentFormContext.formfields[formKey] = widget;
276
- parentFormContext.formWidgets[fieldName] = widget;
277
- parentFormContext.formfields[`${fieldName}_formWidget`] = widget;
278
- parentFormContext.formWidgets[`${fieldName}_formWidget`] = widget;
276
+ const { formfields, formWidgets } = parentFormContext;
277
+ formfields[formKey] = widget;
278
+ formWidgets[fieldName] = widget;
279
+ defineFieldAlias(`${fieldName}_formWidget`, widget, formfields, formWidgets);
279
280
  };
280
281
  export {
281
282
  cleanNullValues,
@@ -1,5 +1,5 @@
1
1
  declare const WmFormActionsStandalone: import("react").ComponentType<{
2
- onClick: ((event: any) => void) & ((event?: React.MouseEvent<HTMLElement>, widget?: Record<string, any>, newVal?: string | number | null, oldVal?: string | number | null) => void);
2
+ onClick: ((event: any, widget?: any) => void) & ((event?: React.MouseEvent<HTMLElement>, widget?: Record<string, any>, newVal?: string | number | null, oldVal?: string | number | null) => void);
3
3
  formKey: string;
4
4
  name: string;
5
5
  displayName: string;
@@ -22,6 +22,7 @@ declare const WmFormActionsStandalone: import("react").ComponentType<{
22
22
  margin?: string;
23
23
  width?: number | string;
24
24
  height?: number | string;
25
+ class?: string;
25
26
  conditionalstyle?: import("react").CSSProperties;
26
27
  conditionalclass?: string;
27
28
  showindevice?: ("xs" | "sm" | "md" | "lg" | "all")[];
@@ -75,7 +76,7 @@ export { WmFormActionsStandalone as WmFormAction };
75
76
  * @param props - {@link WmFormActionsProps}
76
77
  */
77
78
  declare const _default: import("react").ComponentType<{
78
- onClick: ((event: any) => void) & ((event?: React.MouseEvent<HTMLElement>, widget?: Record<string, any>, newVal?: string | number | null, oldVal?: string | number | null) => void);
79
+ onClick: ((event: any, widget?: any) => void) & ((event?: React.MouseEvent<HTMLElement>, widget?: Record<string, any>, newVal?: string | number | null, oldVal?: string | number | null) => void);
79
80
  formKey: string;
80
81
  name: string;
81
82
  displayName: string;
@@ -98,6 +99,7 @@ declare const _default: import("react").ComponentType<{
98
99
  margin?: string;
99
100
  width?: number | string;
100
101
  height?: number | string;
102
+ class?: string;
101
103
  conditionalstyle?: import("react").CSSProperties;
102
104
  conditionalclass?: string;
103
105
  showindevice?: ("xs" | "sm" | "md" | "lg" | "all")[];
@@ -59,7 +59,7 @@ const WmFormActions = memo((props) => {
59
59
  const isheaderaction = position === "header" && !headeraction;
60
60
  const formRef = useFormContext();
61
61
  const handleClick = useCallback(
62
- (event) => {
62
+ (event, widget) => {
63
63
  var _a2, _b2, _c;
64
64
  if (props.standalone) {
65
65
  if (type === "submit") {
@@ -68,7 +68,7 @@ const WmFormActions = memo((props) => {
68
68
  (_b2 = formRef == null ? void 0 : formRef.formreset) == null ? void 0 : _b2.call(formRef);
69
69
  }
70
70
  }
71
- (_c = props.onClick) == null ? void 0 : _c.call(props, event);
71
+ (_c = props.onClick) == null ? void 0 : _c.call(props, event, widget);
72
72
  },
73
73
  [formRef, props.onClick, type]
74
74
  );
@@ -1,27 +1,26 @@
1
1
  import React from "react";
2
+ import type { UseFormSetValue } from "react-hook-form";
2
3
  export interface FormContextValue {
3
- updateFormData?: (data: any) => void;
4
4
  control?: any;
5
5
  watch?: any;
6
- registerFormField?: (formKey: string, fieldName: string, fieldInstance: any) => void;
7
- registerFormWidget?: (widgetName: string, widgetInstance: any) => void;
8
- registerHeaderAction?: (actionName: string, action: any) => void;
9
- onChangeHandler?: (fieldName: string, value: any) => void;
10
- getFieldValue?: (fieldName: string) => any;
11
6
  trigger?: any;
12
7
  errors?: any;
13
- name?: string;
8
+ setValue?: UseFormSetValue<any>;
9
+ submitCount?: number;
10
+ submit?: (e?: any) => Promise<boolean | undefined>;
11
+ formreset?: () => Promise<void>;
12
+ updateFormData?: (data: any) => void;
13
+ onChangeHandler?: (fieldName: string, value: any) => void;
14
+ registerFormWidget?: (widgetName: string, widgetInstance: any) => void;
15
+ registerHeaderAction?: (actionName: string, action: any) => void;
14
16
  captionposition?: string;
15
17
  captionCls?: string;
16
18
  widgetCls?: string;
17
- validationtype?: string;
19
+ itemsPerRow?: string;
18
20
  isViewMode?: boolean;
19
- resetField?: (fieldName: string) => void;
20
- submitCount?: number;
21
+ name?: string;
22
+ validationtype?: string;
21
23
  ref?: any;
22
- itemsPerRow?: string;
23
- submit?: (e?: any) => Promise<boolean | undefined>;
24
- formreset?: () => Promise<void>;
25
24
  }
26
25
  declare const FormContext: React.Context<FormContextValue>;
27
26
  /**
@@ -18,17 +18,15 @@ var __spreadValues = (a, b) => {
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  import { jsx } from "react/jsx-runtime";
21
- import { createContext, useContext } from "react";
21
+ import { createContext, useContext, useMemo } from "react";
22
22
  const FormContext = createContext(null);
23
23
  const ParentFormDataContext = createContext(null);
24
24
  const useParentFormData = () => useContext(ParentFormDataContext);
25
25
  const FormProvider = ({ value, isViewMode, children }) => {
26
- return /* @__PURE__ */ jsx(FormContext.Provider, { value: __spreadProps(__spreadValues({}, value), { isViewMode }), children });
27
- };
28
- const useFormContext = () => {
29
- const context = useContext(FormContext);
30
- return context;
26
+ const contextValue = useMemo(() => __spreadProps(__spreadValues({}, value), { isViewMode }), [value, isViewMode]);
27
+ return /* @__PURE__ */ jsx(FormContext.Provider, { value: contextValue, children });
31
28
  };
29
+ const useFormContext = () => useContext(FormContext);
32
30
  const useIsViewMode = () => {
33
31
  const context = useFormContext();
34
32
  return context == null ? void 0 : context.isViewMode;