@wavemaker-ai/react-runtime 1.0.0-rc.332 → 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.
- package/components/advanced/carousel/index.d.ts +1 -0
- package/components/advanced/carousel/template.d.ts +1 -0
- package/components/advanced/login/index.d.ts +1 -0
- package/components/advanced/marquee/index.d.ts +1 -0
- package/components/basic/anchor/index.d.ts +1 -0
- package/components/basic/anchor/index.js +3 -5
- package/components/basic/audio/index.d.ts +1 -0
- package/components/basic/html/index.d.ts +1 -0
- package/components/basic/icon/index.d.ts +1 -0
- package/components/basic/iframe/index.d.ts +1 -0
- package/components/basic/label/index.d.ts +1 -0
- package/components/basic/picture/index.d.ts +1 -0
- package/components/basic/progress-bar/index.d.ts +1 -0
- package/components/basic/progress-circle/index.d.ts +1 -0
- package/components/basic/richtexteditor/index.d.ts +2 -0
- package/components/basic/spinner/index.d.ts +1 -0
- package/components/basic/tile/index.d.ts +1 -0
- package/components/basic/tree/index.d.ts +1 -0
- package/components/basic/video/index.d.ts +1 -0
- package/components/chart/index.d.ts +1 -0
- package/components/container/accordion/accordion-pane/index.d.ts +1 -0
- package/components/container/accordion/index.d.ts +1 -0
- package/components/container/index.d.ts +4 -0
- package/components/container/index.js +33 -9
- package/components/container/layout-grid/grid-column/index.d.ts +1 -0
- package/components/container/layout-grid/grid-row/index.d.ts +1 -0
- package/components/container/layout-grid/index.d.ts +1 -0
- package/components/container/layout-grid/index.js +1 -1
- package/components/container/linear-layout/index.d.ts +1 -0
- package/components/container/linear-layout/linear-layout-item/index.d.ts +1 -0
- package/components/container/panel/index.d.ts +1 -0
- package/components/container/props.d.ts +1 -0
- package/components/container/repeat-template/index.d.ts +1 -0
- package/components/container/repeat-template/index.js +1 -1
- package/components/container/tabs/index.d.ts +1 -0
- package/components/container/tabs/index.js +8 -6
- package/components/container/tabs/tab-pane/index.d.ts +1 -0
- package/components/container/tabs/tab-pane/index.js +2 -2
- package/components/container/wizard/index.d.ts +2 -0
- package/components/container/wizard/index.js +56 -40
- package/components/container/wizard/wizard-step/index.d.ts +1 -0
- package/components/data/card/card-actions/index.d.ts +1 -0
- package/components/data/card/card-content/index.d.ts +1 -0
- package/components/data/card/card-footer/index.d.ts +1 -0
- package/components/data/card/index.d.ts +1 -0
- package/components/data/form/base-form/hooks/useFormOperations.d.ts +1 -1
- package/components/data/form/base-form/hooks/useFormOperations.js +5 -2
- package/components/data/form/base-form/index.js +10 -14
- package/components/data/form/base-form/props.d.ts +1 -0
- package/components/data/form/form-action/index.d.ts +2 -0
- package/components/data/form/form-controller/withFormController.js +16 -3
- package/components/data/form/form-field/index.js +35 -11
- package/components/data/form/form-field/props.d.ts +7 -2
- package/components/data/list/index.d.ts +2 -0
- package/components/data/list/index.js +4 -9
- package/components/data/pagination/hooks/usePagination.js +6 -6
- package/components/data/table/components/RowExpansionButton.js +5 -1
- package/components/data/table/components/TableBody.js +2 -0
- package/components/data/table/components/TableHeader.js +3 -1
- package/components/data/table/hooks/useFormWidget.js +2 -2
- package/components/data/table/hooks/usePanelStructure.js +6 -1
- package/components/data/table/hooks/useResponsiveColumns.d.ts +1 -0
- package/components/data/table/hooks/useRowHandlers.js +1 -1
- package/components/data/table/hooks/useRowSelection.js +7 -3
- package/components/data/table/hooks/useTableData.js +10 -2
- package/components/data/table/index.d.ts +2 -0
- package/components/data/table/index.js +14 -13
- package/components/data/table/live-table/index.d.ts +1 -0
- package/components/data/table/props.d.ts +1 -0
- package/components/data/table/table-action/index.d.ts +1 -0
- package/components/data/table/table-column/index.d.ts +1 -0
- package/components/data/table/table-row/index.d.ts +1 -0
- package/components/data/table/table-row-action/index.d.ts +1 -0
- package/components/data/table/utils/buildSelectionColumns.js +17 -22
- package/components/data/table/utils/crud-handlers.js +3 -1
- package/components/data/table/utils/expansionColumn.js +1 -1
- package/components/data/table/utils/index.d.ts +10 -3
- package/components/data/table/utils/index.js +5 -8
- package/components/data/table/utils/selectionUtils.d.ts +12 -0
- package/components/data/table/utils/selectionUtils.js +10 -0
- package/components/dialogs/alert-dialog/index.d.ts +2 -0
- package/components/dialogs/confirm-dialog/index.d.ts +2 -0
- package/components/dialogs/dialog/index.d.ts +2 -0
- package/components/dialogs/dialog-actions/index.d.ts +1 -0
- package/components/dialogs/dialog-body/index.d.ts +1 -0
- package/components/dialogs/dialog-content/index.d.ts +1 -0
- package/components/dialogs/dialog-header/index.d.ts +1 -0
- package/components/dialogs/iframe-dialog/index.d.ts +2 -0
- package/components/dialogs/login-dialog/index.d.ts +2 -0
- package/components/dialogs/page-dialog/index.d.ts +2 -0
- package/components/dialogs/withDialogWrapper.js +12 -2
- package/components/form/button/index.d.ts +1 -0
- package/components/form/button-group/index.d.ts +1 -0
- package/components/input/calendar/index.d.ts +2 -0
- package/components/input/chips/index.d.ts +2 -0
- package/components/input/color-picker/index.d.ts +2 -0
- package/components/input/composite/index.d.ts +1 -0
- package/components/input/composite/index.js +32 -6
- package/components/input/default/checkbox/index.d.ts +2 -0
- package/components/input/default/checkboxset/index.d.ts +2 -0
- package/components/input/default/radioset/index.d.ts +2 -0
- package/components/input/default/switch/index.d.ts +2 -0
- package/components/input/epoch/date/index.d.ts +1 -0
- package/components/input/epoch/datetime/index.d.ts +1 -0
- package/components/input/epoch/datetime/index.js +3 -1
- package/components/input/epoch/time/index.d.ts +1 -0
- package/components/input/fileupload/index.d.ts +1 -0
- package/components/input/fileupload/index.js +2 -1
- package/components/input/number/index.d.ts +2 -0
- package/components/input/rating/index.d.ts +2 -0
- package/components/input/slider/index.d.ts +2 -0
- package/components/input/text/index.d.ts +2 -0
- package/components/input/text/index.js +9 -2
- package/components/input/textarea/index.d.ts +2 -0
- package/components/input/upload/index.d.ts +2 -0
- package/components/navbar/index.d.ts +1 -0
- package/components/navbar/nav-item/index.d.ts +1 -0
- package/components/navigation/breadcrumb/index.d.ts +1 -0
- package/components/navigation/menu/index.d.ts +1 -0
- package/components/navigation/menu/index.js +13 -9
- package/components/navigation/menu/props.d.ts +1 -0
- package/components/navigation/popover/index.d.ts +1 -0
- package/components/navigation/popover/index.js +15 -3
- package/components/page/partial/index.d.ts +1 -0
- package/context/PopoverContext.d.ts +5 -0
- package/context/PopoverContext.js +5 -0
- package/context/WidgetProvider.js +9 -2
- package/core/proxy-service.d.ts +2 -0
- package/core/proxy-service.js +46 -3
- package/higherOrder/BaseApp.js +2 -1
- package/higherOrder/BasePage.js +2 -9
- package/higherOrder/props.d.ts +1 -0
- package/higherOrder/useActivePageReactivity.js +1 -4
- package/higherOrder/withBaseWrapper.js +3 -2
- package/package-lock.json +168 -167
- package/package.json +3 -3
- package/runtime-dynamic/components/PageWrapper.js +1 -1
- package/runtime-dynamic/components/PrefabPreview.js +1 -1
- package/runtime-dynamic/components/partial-content.js +17 -1
- package/runtime-dynamic/factories/build-base-page-like-component.js +11 -7
- package/runtime-dynamic/factories/dynamic-component.js +1 -7
- package/runtime-dynamic/routes.js +17 -8
- package/utils/page-params-util.js +22 -1
- package/utils/partial-host-util.d.ts +40 -0
- package/utils/partial-host-util.js +41 -0
- package/variables/model-variable.d.ts +2 -0
- package/variables/model-variable.js +14 -0
|
@@ -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 (
|
|
290
|
-
|
|
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,
|
|
350
|
+
const fromStep = getStepByIndex(fromIndex, currentVisibleSteps);
|
|
339
351
|
if (!fromStep) return;
|
|
340
|
-
const nextStep = getNextValidStep(fromIndex + 1,
|
|
352
|
+
const nextStep = getNextValidStep(fromIndex + 1, currentVisibleSteps);
|
|
341
353
|
if (!nextStep) return;
|
|
342
|
-
const nextIndex =
|
|
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,
|
|
360
|
+
() => extendNextFn(fromStep, fromIndex, currentVisibleSteps, setSteps)
|
|
349
361
|
);
|
|
350
362
|
} else {
|
|
351
|
-
extendNextFn(fromStep, fromIndex,
|
|
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,
|
|
370
|
+
() => extendNextFn(fromStep, fromIndex, currentVisibleSteps, setSteps)
|
|
359
371
|
);
|
|
360
372
|
} else {
|
|
361
|
-
extendNextFn(fromStep, fromIndex,
|
|
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,
|
|
378
|
+
extendNextFn(fromStep, fromIndex, currentVisibleSteps, setSteps);
|
|
367
379
|
}
|
|
368
380
|
navIndexRef.current = nextIndex;
|
|
369
381
|
setFormReady(false);
|
|
370
382
|
},
|
|
371
|
-
[currentStepIndex,
|
|
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,
|
|
389
|
+
const fromStep = getStepByIndex(fromIndex, currentVisibleSteps);
|
|
377
390
|
if (!fromStep) return;
|
|
378
|
-
const targetStep = getPrevValidStep(fromIndex - 1,
|
|
391
|
+
const targetStep = getPrevValidStep(fromIndex - 1, currentVisibleSteps);
|
|
379
392
|
if (!targetStep) return;
|
|
380
|
-
const prevIndex =
|
|
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,
|
|
398
|
+
() => extendPrevFn(fromStep, fromIndex, currentVisibleSteps, setSteps)
|
|
386
399
|
);
|
|
387
400
|
} else {
|
|
388
|
-
extendPrevFn(fromStep, fromIndex,
|
|
401
|
+
extendPrevFn(fromStep, fromIndex, currentVisibleSteps, setSteps);
|
|
389
402
|
}
|
|
390
403
|
navIndexRef.current = prevIndex;
|
|
391
404
|
setFormReady(false);
|
|
392
|
-
}, [currentStepIndex
|
|
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 =
|
|
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 =
|
|
452
|
+
targetStep = currentSteps[gotoStepIndex];
|
|
438
453
|
} else if (typeof step === "number" && step >= 0) {
|
|
439
454
|
gotoStepIndex = step;
|
|
440
|
-
targetStep = getStepByIndex(step,
|
|
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 =
|
|
461
|
+
const visIndex = currentVisibleSteps.findIndex((s) => s.name === (targetStep == null ? void 0 : targetStep.name));
|
|
447
462
|
if (visIndex >= 0) navIndexRef.current = visIndex;
|
|
448
|
-
|
|
463
|
+
activateStep(targetStep);
|
|
449
464
|
} else {
|
|
450
465
|
console.error("The gotoStep function cannot navigate to hidden steps");
|
|
451
466
|
}
|
|
452
467
|
},
|
|
453
|
-
[
|
|
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;
|
|
@@ -16,7 +16,8 @@ function useFormOperations({
|
|
|
16
16
|
submit,
|
|
17
17
|
formProxy,
|
|
18
18
|
widgetFormType,
|
|
19
|
-
debouncedFilter
|
|
19
|
+
debouncedFilter,
|
|
20
|
+
onReset
|
|
20
21
|
}) {
|
|
21
22
|
const hasPrefixedFields = usesPrefixedFields(formType);
|
|
22
23
|
const [showViewMode, setShowViewMode] = useState(false);
|
|
@@ -53,6 +54,7 @@ function useFormOperations({
|
|
|
53
54
|
return (_a = childForm == null ? void 0 : childForm.formreset) == null ? void 0 : _a.call(childForm);
|
|
54
55
|
});
|
|
55
56
|
}
|
|
57
|
+
onReset == null ? void 0 : onReset();
|
|
56
58
|
}, [
|
|
57
59
|
formName,
|
|
58
60
|
formfields,
|
|
@@ -62,7 +64,8 @@ function useFormOperations({
|
|
|
62
64
|
fullDataPath,
|
|
63
65
|
parentFormDataContext,
|
|
64
66
|
formRef,
|
|
65
|
-
formReff
|
|
67
|
+
formReff,
|
|
68
|
+
onReset
|
|
66
69
|
]);
|
|
67
70
|
const create = useCallback(() => {
|
|
68
71
|
formreset();
|
|
@@ -325,7 +325,7 @@ const BaseForm = (WrappedComponent) => {
|
|
|
325
325
|
e == null ? void 0 : e.preventDefault();
|
|
326
326
|
e == null ? void 0 : e.stopPropagation();
|
|
327
327
|
const transformedData = transformRangeFilterData(data);
|
|
328
|
-
return livefilterFn(transformedData, false,
|
|
328
|
+
return livefilterFn(transformedData, false, formProxy == null ? void 0 : formProxy.formfields);
|
|
329
329
|
}),
|
|
330
330
|
[handleSubmit, livefilterFn]
|
|
331
331
|
);
|
|
@@ -334,7 +334,7 @@ const BaseForm = (WrappedComponent) => {
|
|
|
334
334
|
debouncedFn();
|
|
335
335
|
}, [filter]);
|
|
336
336
|
const {
|
|
337
|
-
formreset
|
|
337
|
+
formreset,
|
|
338
338
|
create,
|
|
339
339
|
edit,
|
|
340
340
|
setFormData,
|
|
@@ -356,18 +356,14 @@ const BaseForm = (WrappedComponent) => {
|
|
|
356
356
|
submit,
|
|
357
357
|
formProxy: formProxy || {},
|
|
358
358
|
widgetFormType: props["form-type"],
|
|
359
|
-
debouncedFilter
|
|
359
|
+
debouncedFilter,
|
|
360
|
+
onReset: props.onReset
|
|
360
361
|
});
|
|
361
|
-
const formreset = useCallback(async () => {
|
|
362
|
-
var _a2;
|
|
363
|
-
await formresetFn();
|
|
364
|
-
(_a2 = props.onReset) == null ? void 0 : _a2.call(props);
|
|
365
|
-
}, [formresetFn, props.onReset]);
|
|
366
362
|
const clearFilter = useMemo(
|
|
367
363
|
() => handleSubmit((data, e) => {
|
|
368
364
|
e == null ? void 0 : e.preventDefault();
|
|
369
365
|
e == null ? void 0 : e.stopPropagation();
|
|
370
|
-
|
|
366
|
+
formreset();
|
|
371
367
|
const transformedData = transformRangeFilterData(data);
|
|
372
368
|
livefilterFn(transformedData, true, formfieldsRef.current);
|
|
373
369
|
}),
|
|
@@ -384,8 +380,8 @@ const BaseForm = (WrappedComponent) => {
|
|
|
384
380
|
return;
|
|
385
381
|
}
|
|
386
382
|
setShowViewMode(true);
|
|
387
|
-
|
|
388
|
-
}, [setShowViewMode, props.cancel,
|
|
383
|
+
formreset();
|
|
384
|
+
}, [setShowViewMode, props.cancel, formreset]);
|
|
389
385
|
const highlightInvalidFields = useCallback(async () => {
|
|
390
386
|
await validateFieldsOnSubmit();
|
|
391
387
|
}, [validateFieldsOnSubmit]);
|
|
@@ -452,7 +448,7 @@ const BaseForm = (WrappedComponent) => {
|
|
|
452
448
|
var _a2;
|
|
453
449
|
if (!formName || !formRef.current) return;
|
|
454
450
|
(_a2 = props == null ? void 0 : props.destroy) == null ? void 0 : _a2.call(props, formName);
|
|
455
|
-
|
|
451
|
+
formreset();
|
|
456
452
|
};
|
|
457
453
|
}, []);
|
|
458
454
|
useEffect(() => {
|
|
@@ -559,7 +555,7 @@ const BaseForm = (WrappedComponent) => {
|
|
|
559
555
|
}
|
|
560
556
|
const formId = formIdRef.current;
|
|
561
557
|
parentFormRef.current[formId] = {
|
|
562
|
-
formreset
|
|
558
|
+
formreset,
|
|
563
559
|
validateFieldsOnSubmit
|
|
564
560
|
};
|
|
565
561
|
return () => {
|
|
@@ -567,7 +563,7 @@ const BaseForm = (WrappedComponent) => {
|
|
|
567
563
|
delete parentFormRef.current[formId];
|
|
568
564
|
}
|
|
569
565
|
};
|
|
570
|
-
}, [parentFormRef,
|
|
566
|
+
}, [parentFormRef, formreset, validateFieldsOnSubmit]);
|
|
571
567
|
const computedFormdata = widgetFormData || childFormData || formdata;
|
|
572
568
|
const ref = useMemo(
|
|
573
569
|
() => ({
|
|
@@ -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")[];
|
|
@@ -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")[];
|
|
@@ -48,6 +48,8 @@ import {
|
|
|
48
48
|
useHTMLValidationProps,
|
|
49
49
|
useExternalDataSync
|
|
50
50
|
} from "./hooks";
|
|
51
|
+
const ALWAYS_MULTI_VALUE_WIDGETS = ["WmChips", "WmCheckboxset"];
|
|
52
|
+
const MULTI_SELECT_WIDGET = "WmSelect";
|
|
51
53
|
const withFormController = (WrappedComponent) => {
|
|
52
54
|
const WithFormControllerComponent = memo((props) => {
|
|
53
55
|
const _a = props, {
|
|
@@ -121,6 +123,9 @@ const withFormController = (WrappedComponent) => {
|
|
|
121
123
|
useDefaultValueSync(defaultvalue, datavalue, fieldRef);
|
|
122
124
|
const widget = WrappedComponent == null ? void 0 : WrappedComponent.displayName;
|
|
123
125
|
const ignoreRange = ["WmRadioset", "WmCheckboxset"].includes(widget != null ? widget : "");
|
|
126
|
+
const isMultipleSelect = widget === MULTI_SELECT_WIDGET && props.multiple == true;
|
|
127
|
+
const isMultiValueWidget = ALWAYS_MULTI_VALUE_WIDGETS.includes(widget != null ? widget : "") || isMultipleSelect;
|
|
128
|
+
const fallbackDefaultValue = isMultiValueWidget && defaultvalue === void 0 ? [] : defaultvalue;
|
|
124
129
|
const validationRules = useValidationRules(
|
|
125
130
|
validationType,
|
|
126
131
|
validators,
|
|
@@ -172,6 +177,10 @@ const withFormController = (WrappedComponent) => {
|
|
|
172
177
|
trigger(effectiveFormKey);
|
|
173
178
|
}
|
|
174
179
|
}, [customValidationMsg]);
|
|
180
|
+
const onChangeRef = useRef(props.onChange);
|
|
181
|
+
useEffect(() => {
|
|
182
|
+
onChangeRef.current = props.onChange;
|
|
183
|
+
}, [props.onChange]);
|
|
175
184
|
const createOnChangeHandler = useCallback(
|
|
176
185
|
(field) => {
|
|
177
186
|
return (e, componentProps, newValue, oldValue, isValid) => {
|
|
@@ -199,7 +208,7 @@ const withFormController = (WrappedComponent) => {
|
|
|
199
208
|
setTouched(true);
|
|
200
209
|
trigger(effectiveFormKey);
|
|
201
210
|
}
|
|
202
|
-
(_a2 =
|
|
211
|
+
(_a2 = onChangeRef.current) == null ? void 0 : _a2.call(onChangeRef, e, componentProps, newValue, oldValue);
|
|
203
212
|
};
|
|
204
213
|
},
|
|
205
214
|
[type, props.datafield, updateon, effectiveFormKey]
|
|
@@ -231,12 +240,13 @@ const withFormController = (WrappedComponent) => {
|
|
|
231
240
|
control: formRef.control,
|
|
232
241
|
name: effectiveFormKey,
|
|
233
242
|
rules: validationRules,
|
|
234
|
-
defaultValue: effectiveDataValue !== void 0 ? effectiveDataValue :
|
|
243
|
+
defaultValue: effectiveDataValue !== void 0 ? effectiveDataValue : fallbackDefaultValue,
|
|
235
244
|
render: ({ field, fieldState }) => {
|
|
236
245
|
var _a2, _b, _c;
|
|
237
246
|
fieldRef.current = field;
|
|
238
247
|
const processedValue = processFieldValue(field.value, type, props.datafield);
|
|
239
248
|
const errorState = getErrorState(fieldState, validationType, touched);
|
|
249
|
+
const isExplicitFormField = props.formfield === true || props.formfield === "true";
|
|
240
250
|
let valueToUse;
|
|
241
251
|
if (processedValue !== void 0) {
|
|
242
252
|
valueToUse = processedValue;
|
|
@@ -321,11 +331,14 @@ const withFormController = (WrappedComponent) => {
|
|
|
321
331
|
value = JSON.stringify(value);
|
|
322
332
|
}
|
|
323
333
|
}
|
|
334
|
+
if (value && typeof value === "object") {
|
|
335
|
+
value = JSON.stringify(value);
|
|
336
|
+
}
|
|
324
337
|
return value;
|
|
325
338
|
})()
|
|
326
339
|
}
|
|
327
340
|
),
|
|
328
|
-
shouldShowErrorMessage(validationType, fieldState, touched) && /* @__PURE__ */ jsx(
|
|
341
|
+
isExplicitFormField && shouldShowErrorMessage(validationType, fieldState, touched) && /* @__PURE__ */ jsx(
|
|
329
342
|
"p",
|
|
330
343
|
{
|
|
331
344
|
className: "help-block text-danger",
|
|
@@ -48,7 +48,7 @@ const WmFormField = memo(
|
|
|
48
48
|
const formProxy = useWidgetProxy(`${props.formName}`);
|
|
49
49
|
const overriddenItemsRef = useRef({});
|
|
50
50
|
const fieldKey = props.formKey || props.name;
|
|
51
|
-
const
|
|
51
|
+
const prevDefaultValueRef = useRef(props.defaultvalue);
|
|
52
52
|
const showfield = (_b = (_a = overriddenItemsRef == null ? void 0 : overriddenItemsRef.current) == null ? void 0 : _a.show) != null ? _b : show;
|
|
53
53
|
const formReady = (formProxy == null ? void 0 : formProxy.listener) !== void 0 || ((_c = props.formRef) == null ? void 0 : _c.name) === props.formName;
|
|
54
54
|
const reset = useCallback(
|
|
@@ -81,7 +81,19 @@ const WmFormField = memo(
|
|
|
81
81
|
formProxy.formWidgets = {};
|
|
82
82
|
formProxy.formfields = {};
|
|
83
83
|
}
|
|
84
|
-
const mutableTarget = __spreadProps(__spreadValues({}, props), {
|
|
84
|
+
const mutableTarget = __spreadProps(__spreadValues({}, props), {
|
|
85
|
+
reset,
|
|
86
|
+
show,
|
|
87
|
+
deferload,
|
|
88
|
+
fieldValidations: {
|
|
89
|
+
validate: () => {
|
|
90
|
+
var _a2;
|
|
91
|
+
if (fieldKey && typeof ((_a2 = props.formRef) == null ? void 0 : _a2.trigger) === "function") {
|
|
92
|
+
props.formRef.trigger(fieldKey);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
85
97
|
const fieldProxy = createFormFieldProxy(
|
|
86
98
|
mutableTarget,
|
|
87
99
|
setProxyProps,
|
|
@@ -93,16 +105,19 @@ const WmFormField = memo(
|
|
|
93
105
|
}, [formReady]);
|
|
94
106
|
useEffect(() => {
|
|
95
107
|
if (!formReady || !fieldProxyRef.current) return;
|
|
96
|
-
if (
|
|
97
|
-
|
|
108
|
+
if (prevDefaultValueRef.current === props.defaultvalue) return;
|
|
109
|
+
const valueUnset = fieldProxyRef.current.datavalue === void 0 || fieldProxyRef.current.datavalue === prevDefaultValueRef.current;
|
|
110
|
+
prevDefaultValueRef.current = props.defaultvalue;
|
|
111
|
+
if (!valueUnset) return;
|
|
98
112
|
fieldProxyRef.current.datavalue = props.defaultvalue;
|
|
99
113
|
fieldProxyRef.current.value = props.defaultvalue;
|
|
100
114
|
fieldProxyRef.current.defaultvalue = props.defaultvalue;
|
|
101
|
-
}, [props.defaultvalue]);
|
|
115
|
+
}, [props.defaultvalue, formReady]);
|
|
102
116
|
useEffect(() => {
|
|
103
|
-
var _a2;
|
|
104
117
|
const fieldProxy = fieldProxyRef.current;
|
|
105
|
-
if (!fieldProxy
|
|
118
|
+
if (!fieldProxy) return;
|
|
119
|
+
const hasDataset = typeof props.dataset === "function" || props.dataset && props.dataset.length > 0;
|
|
120
|
+
if (!hasDataset) return;
|
|
106
121
|
DATASET_SYNC_KEYS.forEach((key) => {
|
|
107
122
|
const value = props[key];
|
|
108
123
|
if (value != null && fieldProxy[key] !== value) {
|
|
@@ -111,20 +126,25 @@ const WmFormField = memo(
|
|
|
111
126
|
});
|
|
112
127
|
}, [props.dataset, props.datafield, props.displayfield, props.displaylabel, props.searchkey]);
|
|
113
128
|
function renderFormFields() {
|
|
114
|
-
var _a2, _b2, _c2, _d2, _e, _f, _g, _h;
|
|
129
|
+
var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
115
130
|
if (props.formRef) {
|
|
116
131
|
const errors = (_a2 = props.formRef) == null ? void 0 : _a2.errors;
|
|
117
132
|
const formKey = (_b2 = props.formKey) != null ? _b2 : props.name;
|
|
118
133
|
const fieldError = formKey && errors ? get(errors, formKey) : void 0;
|
|
119
134
|
const invalid = Boolean(fieldError);
|
|
120
135
|
const invalidCls = invalid ? " text-danger " : "";
|
|
121
|
-
return /* @__PURE__ */ jsx(Fragment, { children: (
|
|
136
|
+
return /* @__PURE__ */ jsx(Fragment, { children: (_m = props == null ? void 0 : props.renderFormFields) == null ? void 0 : _m.call(props, __spreadProps(__spreadValues(__spreadValues({}, proxyProps), overriddenItemsRef.current), {
|
|
137
|
+
// proxyProps snapshots onChange once at mount; nothing resyncs it, so a
|
|
138
|
+
// handler assigned after mount (e.g. from a page's onReady) is never seen
|
|
139
|
+
// unless we read the live prop here, same as onTrailingiconclick below.
|
|
140
|
+
onChange: props.onChange,
|
|
122
141
|
show: showfield,
|
|
123
142
|
disabled: (_d2 = (_c2 = overriddenItemsRef == null ? void 0 : overriddenItemsRef.current) == null ? void 0 : _c2.disabled) != null ? _d2 : props == null ? void 0 : props.disabled,
|
|
124
143
|
readonly: (_f = (_e = overriddenItemsRef == null ? void 0 : overriddenItemsRef.current) == null ? void 0 : _e.readonly) != null ? _f : props == null ? void 0 : props.readonly,
|
|
125
144
|
// BaseField derives this from live validators. A direct field-proxy write wins,
|
|
126
145
|
// but never fall back to the initial proxyProps.required snapshot.
|
|
127
146
|
required: (_g = overriddenItemsRef.current.required) != null ? _g : props.required,
|
|
147
|
+
displayname: (_h = overriddenItemsRef.current.displayname) != null ? _h : props.displayname,
|
|
128
148
|
fieldError,
|
|
129
149
|
validators: props.validators,
|
|
130
150
|
asyncValidators: props.asyncValidators,
|
|
@@ -132,7 +152,11 @@ const WmFormField = memo(
|
|
|
132
152
|
invalid,
|
|
133
153
|
invalidCls,
|
|
134
154
|
iswidget: "false",
|
|
135
|
-
onChangeHandler
|
|
155
|
+
onChangeHandler,
|
|
156
|
+
onTrailingiconclick: (_i = overriddenItemsRef.current.onTrailingiconclick) != null ? _i : props.onTrailingiconclick,
|
|
157
|
+
trailingiconurl: (_j = overriddenItemsRef.current.trailingiconurl) != null ? _j : props.trailingiconurl,
|
|
158
|
+
onLeadingiconclick: (_k = overriddenItemsRef.current.onLeadingiconclick) != null ? _k : props.onLeadingiconclick,
|
|
159
|
+
leadingiconurl: (_l = overriddenItemsRef.current.leadingiconurl) != null ? _l : props.leadingiconurl
|
|
136
160
|
})) });
|
|
137
161
|
} else {
|
|
138
162
|
return null;
|
|
@@ -145,7 +169,7 @@ const WmFormField = memo(
|
|
|
145
169
|
}
|
|
146
170
|
const isDeferLoad = deferload === true;
|
|
147
171
|
const showValue = (showfield == null ? void 0 : showfield.toString()) !== "false";
|
|
148
|
-
if (
|
|
172
|
+
if (!showValue && isDeferLoad) {
|
|
149
173
|
return null;
|
|
150
174
|
}
|
|
151
175
|
const shouldHide = !showValue && !isDeferLoad;
|
|
@@ -146,9 +146,9 @@ export interface FormFieldProps {
|
|
|
146
146
|
*/
|
|
147
147
|
displaylabel?: string;
|
|
148
148
|
/**
|
|
149
|
-
* The collection of data items for the field.
|
|
149
|
+
* The collection of data items for the field, or a thunk returning them.
|
|
150
150
|
*/
|
|
151
|
-
dataset?: any[];
|
|
151
|
+
dataset?: any[] | (() => any[]);
|
|
152
152
|
/**
|
|
153
153
|
* Key to use for searching.
|
|
154
154
|
*/
|
|
@@ -206,6 +206,11 @@ export interface FormFieldProps {
|
|
|
206
206
|
reset?: () => void;
|
|
207
207
|
setValidationMessage?: (message: string) => void;
|
|
208
208
|
disabled?: boolean;
|
|
209
|
+
trailingiconurl?: string;
|
|
210
|
+
onTrailingiconclick?: (...args: any[]) => void;
|
|
211
|
+
leadingiconurl?: string;
|
|
212
|
+
onLeadingiconclick?: (...args: any[]) => void;
|
|
213
|
+
onChange?: (...args: any[]) => void;
|
|
209
214
|
}
|
|
210
215
|
/**
|
|
211
216
|
* Combined props for the WmFormField component, including base WaveMaker props.
|
|
@@ -84,6 +84,7 @@ declare const WmListStandalone: React.ComponentType<{
|
|
|
84
84
|
datavalue?: any;
|
|
85
85
|
width?: number | string;
|
|
86
86
|
height?: number | string;
|
|
87
|
+
class?: string;
|
|
87
88
|
animation?: string;
|
|
88
89
|
show?: boolean | string;
|
|
89
90
|
padding?: string;
|
|
@@ -139,6 +140,7 @@ declare const _default: React.ComponentType<{
|
|
|
139
140
|
width?: number | string;
|
|
140
141
|
height?: number | string;
|
|
141
142
|
className?: string;
|
|
143
|
+
class?: string;
|
|
142
144
|
conditionalstyle?: React.CSSProperties;
|
|
143
145
|
conditionalclass?: string;
|
|
144
146
|
showindevice?: ("xs" | "sm" | "md" | "lg" | "all")[];
|
|
@@ -182,7 +182,7 @@ const WmList = (props) => {
|
|
|
182
182
|
}
|
|
183
183
|
const safeDataset = useMemo(() => {
|
|
184
184
|
return addUniqueRowIds(resolvedDataset, { type: "list" });
|
|
185
|
-
}, [currentDataset]);
|
|
185
|
+
}, [currentDataset, dataset]);
|
|
186
186
|
const [initialRender, setinitialRender] = useState(true);
|
|
187
187
|
const userInitiatedSelectionRef = React.useRef(false);
|
|
188
188
|
const listScrollContainerRef = useRef(null);
|
|
@@ -512,18 +512,13 @@ const WmList = (props) => {
|
|
|
512
512
|
return /* @__PURE__ */ jsxs(
|
|
513
513
|
Box,
|
|
514
514
|
__spreadProps(__spreadValues(__spreadProps(__spreadValues({
|
|
515
|
-
className: clsx(
|
|
516
|
-
DEFAULT_CLS,
|
|
517
|
-
"wm-position-relative",
|
|
518
|
-
className,
|
|
519
|
-
hidden && "wm-hidden",
|
|
520
|
-
wrapper_autoLayout_Classes
|
|
521
|
-
),
|
|
515
|
+
className: clsx(DEFAULT_CLS, "wm-position-relative", className, wrapper_autoLayout_Classes),
|
|
522
516
|
component: "div",
|
|
523
517
|
"data-name": name
|
|
524
518
|
}, { name }), {
|
|
525
519
|
"data-navigation": navigation,
|
|
526
|
-
ref: ListWrapperRef
|
|
520
|
+
ref: ListWrapperRef,
|
|
521
|
+
hidden
|
|
527
522
|
}), direction ? { direction } : {}), {
|
|
528
523
|
children: [
|
|
529
524
|
/* @__PURE__ */ jsx(
|