@wavemaker-ai/react-runtime 1.0.0-rc.647499 → 1.0.0-rc.647565
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/.npmignore +4 -0
- package/actions/base-action.js +12 -29
- package/actions/login-action.js +35 -52
- package/actions/logout-action.js +21 -38
- package/actions/navigation-action.js +251 -346
- package/actions/notification-action.js +121 -149
- package/actions/timer-action.js +95 -151
- package/actions/toast-provider.js +62 -76
- package/actions/toast.js +95 -91
- package/actions/toast.service.js +59 -79
- package/actions/types/index.js +6 -9
- package/components/advanced/carousel/index.js +358 -366
- package/components/advanced/carousel/props.js +0 -5
- package/components/advanced/carousel/template.js +102 -80
- package/components/advanced/login/index.js +227 -285
- package/components/advanced/login/props.js +0 -5
- package/components/advanced/marquee/index.js +169 -163
- package/components/advanced/marquee/props.js +0 -5
- package/components/basic/anchor/index.js +207 -187
- package/components/basic/anchor/props.js +0 -5
- package/components/basic/audio/index.js +110 -72
- package/components/basic/audio/props.js +0 -5
- package/components/basic/html/index.js +163 -203
- package/components/basic/html/props.js +0 -5
- package/components/basic/html/utils.js +30 -28
- package/components/basic/icon/index.js +98 -84
- package/components/basic/icon/props.js +0 -5
- package/components/basic/iframe/iframe.utils.js +7 -16
- package/components/basic/iframe/index.js +97 -103
- package/components/basic/iframe/props.js +0 -5
- package/components/basic/label/index.js +156 -134
- package/components/basic/label/props.js +0 -5
- package/components/basic/message/index.js +129 -113
- package/components/basic/message/props.js +0 -5
- package/components/basic/picture/index.js +156 -127
- package/components/basic/picture/props.js +0 -5
- package/components/basic/progress-bar/index.js +240 -176
- package/components/basic/progress-bar/props.js +5 -31
- package/components/basic/progress-circle/index.js +166 -183
- package/components/basic/progress-circle/props.js +14 -34
- package/components/basic/richtexteditor/index.js +430 -396
- package/components/basic/richtexteditor/props.js +0 -5
- package/components/basic/search/index.js +812 -931
- package/components/basic/search/props.js +0 -5
- package/components/basic/search/providers.js +233 -380
- package/components/basic/spinner/index.js +210 -200
- package/components/basic/spinner/props.js +4 -22
- package/components/basic/tile/index.js +73 -81
- package/components/basic/tile/props.js +0 -5
- package/components/basic/tree/Components/TreeNodeComponent.js +238 -170
- package/components/basic/tree/hooks/useTreePartialNodeApi.js +143 -135
- package/components/basic/tree/index.js +378 -454
- package/components/basic/tree/props.js +0 -5
- package/components/basic/tree/utils.js +129 -185
- package/components/basic/video/index.js +161 -107
- package/components/basic/video/props.js +0 -5
- package/components/chart/index.js +42 -50
- package/components/chart/props.js +31 -37
- package/components/chart/src/ChartRenderer.js +172 -154
- package/components/chart/src/chart.js +391 -213
- package/components/chart/src/chartStyles.generated.js +6 -14
- package/components/chart/src/chartUtils.js +228 -272
- package/components/chart/src/constants.d.ts +13 -0
- package/components/chart/src/constants.js +316 -90
- package/components/chart/src/d3Setup.js +11 -30
- package/components/chart/src/dataUtils.js +362 -446
- package/components/chart/src/formatUtils.js +47 -38
- package/components/chart/src/index.js +11 -19
- package/components/chart/src/nvd3Source.generated.js +5 -13
- package/components/chart/src/pieDonutResponsiveLayout.d.ts +5 -0
- package/components/chart/src/pieDonutResponsiveLayout.js +76 -96
- package/components/chart/src/types.js +0 -5
- package/components/common/AppSpinner.js +17 -33
- package/components/common/app-spinner.js +11 -22
- package/components/common/customTemplate/index.d.ts +3 -0
- package/components/common/customTemplate/index.js +6 -0
- package/components/common/customTemplate/props.d.ts +20 -0
- package/components/common/customTemplate/props.js +0 -0
- package/components/common/customTemplate/template.d.ts +3 -0
- package/components/common/customTemplate/template.js +27 -0
- package/components/common/customTemplate/useCustomTemplate.d.ts +8 -0
- package/components/common/customTemplate/useCustomTemplate.js +17 -0
- package/components/common/customTemplate/utils.d.ts +6 -0
- package/components/common/customTemplate/utils.js +12 -0
- package/components/common/index.js +4 -12
- package/components/constants.js +81 -77
- package/components/container/accordion/accordion-pane/index.js +105 -118
- package/components/container/accordion/accordion-pane/props.js +5 -21
- package/components/container/accordion/index.js +225 -243
- package/components/container/accordion/props.js +5 -16
- package/components/container/index.js +214 -150
- package/components/container/layout-grid/grid-column/index.js +68 -43
- package/components/container/layout-grid/grid-column/props.js +0 -5
- package/components/container/layout-grid/grid-row/index.js +12 -29
- package/components/container/layout-grid/grid-row/props.js +0 -5
- package/components/container/layout-grid/index.js +53 -38
- package/components/container/layout-grid/props.js +0 -5
- package/components/container/linear-layout/index.js +56 -60
- package/components/container/linear-layout/linear-layout-item/index.js +43 -47
- package/components/container/linear-layout/linear-layout-item/props.js +0 -5
- package/components/container/linear-layout/props.js +0 -5
- package/components/container/panel/components/panel-content/index.js +7 -16
- package/components/container/panel/components/panel-header/index.js +166 -146
- package/components/container/panel/components/panel-header/props.js +0 -5
- package/components/container/panel/hooks.js +76 -102
- package/components/container/panel/index.js +289 -252
- package/components/container/panel/props.js +0 -5
- package/components/container/props.js +0 -5
- package/components/container/repeat-template/index.js +65 -44
- package/components/container/repeat-template/props.js +0 -5
- package/components/container/tabs/index.js +517 -526
- package/components/container/tabs/props.js +5 -28
- package/components/container/tabs/tab-pane/index.js +105 -100
- package/components/container/tabs/tab-pane/props.js +0 -5
- package/components/container/tabs/utils.js +30 -35
- package/components/container/wizard/WizardContext.js +9 -11
- package/components/container/wizard/components/StepComponents.js +76 -99
- package/components/container/wizard/components/WizardStep.js +107 -85
- package/components/container/wizard/index.js +791 -921
- package/components/container/wizard/props.js +0 -5
- package/components/container/wizard/utils.js +97 -131
- package/components/container/wizard/wizard-action/index.js +41 -81
- package/components/container/wizard/wizard-step/index.js +140 -120
- package/components/data/card/card-actions/index.js +13 -31
- package/components/data/card/card-content/index.js +27 -36
- package/components/data/card/card-footer/index.js +13 -31
- package/components/data/card/index.js +192 -199
- package/components/data/card/props.js +0 -5
- package/components/data/form/base-form/constant.js +5 -8
- package/components/data/form/base-form/hooks/index.js +26 -77
- package/components/data/form/base-form/hooks/useFormDataSync.js +106 -212
- package/components/data/form/base-form/hooks/useFormOperations.js +109 -161
- package/components/data/form/base-form/hooks/useFormSubmission.js +220 -280
- package/components/data/form/base-form/hooks/useFormValidation.js +119 -168
- package/components/data/form/base-form/hooks/useParentFormRelationship.js +67 -103
- package/components/data/form/base-form/index.js +531 -646
- package/components/data/form/base-form/props.js +74 -151
- package/components/data/form/base-form/utils.js +210 -323
- package/components/data/form/dynamic-fields/constant.js +43 -53
- package/components/data/form/dynamic-fields/index.js +135 -144
- package/components/data/form/dynamic-fields/props.js +0 -5
- package/components/data/form/dynamic-fields/utils.js +99 -158
- package/components/data/form/form-action/index.js +107 -85
- package/components/data/form/form-body/index.js +52 -26
- package/components/data/form/form-context.js +43 -59
- package/components/data/form/form-controller/hooks/index.js +43 -57
- package/components/data/form/form-controller/props.js +5 -8
- package/components/data/form/form-controller/utils.js +54 -49
- package/components/data/form/form-controller/validation-contrustor.js +203 -426
- package/components/data/form/form-controller/withFormController.js +319 -269
- package/components/data/form/form-dynamic-section/index.js +47 -41
- package/components/data/form/form-dynamic-section/props.js +0 -5
- package/components/data/form/form-field/base-field.js +97 -109
- package/components/data/form/form-field/index.js +91 -82
- package/components/data/form/form-field/props.js +0 -5
- package/components/data/form/form-footer/index.js +52 -25
- package/components/data/form/form-header/index.js +61 -58
- package/components/data/form/index.js +95 -74
- package/components/data/form/props.js +0 -5
- package/components/data/list/components/GroupHeader.js +34 -33
- package/components/data/list/components/GroupedListItems.js +108 -104
- package/components/data/list/components/ListContainer.js +22 -27
- package/components/data/list/components/ListDND.js +193 -185
- package/components/data/list/components/ListHeader.js +32 -49
- package/components/data/list/components/ListItem.js +153 -146
- package/components/data/list/components/ListItemWithTemplate.js +87 -105
- package/components/data/list/components/ListItems.js +180 -194
- package/components/data/list/components/ListPagination.js +127 -153
- package/components/data/list/components/LoadMoreButton.js +25 -33
- package/components/data/list/components/NoDataMessage.js +9 -22
- package/components/data/list/components/StandardListItems.js +79 -85
- package/components/data/list/components/index.js +31 -119
- package/components/data/list/components/props.js +0 -5
- package/components/data/list/hooks/index.js +22 -75
- package/components/data/list/hooks/props.js +0 -5
- package/components/data/list/hooks/useCurrentPageItems.js +20 -38
- package/components/data/list/hooks/useGroupedData.js +19 -33
- package/components/data/list/hooks/useListData.js +17 -47
- package/components/data/list/hooks/useListEffects.js +168 -237
- package/components/data/list/hooks/useListEventHandlers.js +301 -285
- package/components/data/list/hooks/useListPagination.js +90 -136
- package/components/data/list/hooks/useListState.js +49 -91
- package/components/data/list/hooks/useListStateManager.js +104 -159
- package/components/data/list/hooks/usePaginatedGroupedData.js +74 -110
- package/components/data/list/index.d.ts +1 -0
- package/components/data/list/index.js +579 -621
- package/components/data/list/props.d.ts +4 -0
- package/components/data/list/props.js +0 -5
- package/components/data/list/templates/media-template.js +29 -50
- package/components/data/list/utils/constants.js +20 -32
- package/components/data/list/utils/list-helpers.d.ts +2 -1
- package/components/data/list/utils/list-helpers.js +71 -115
- package/components/data/list/utils/list-widget-methods.js +56 -76
- package/components/data/list/utils/widget-instance-utils.js +20 -57
- package/components/data/live-filter/index.js +219 -271
- package/components/data/live-filter/props.js +5 -12
- package/components/data/live-form/index.js +68 -91
- package/components/data/live-form/props.js +5 -12
- package/components/data/pagination/components/BasicPagination.js +124 -104
- package/components/data/pagination/components/ClassicPagination.js +167 -190
- package/components/data/pagination/components/InlinePagination.js +97 -98
- package/components/data/pagination/components/LoadingComponent.js +17 -30
- package/components/data/pagination/components/PageSizeSelector.js +176 -169
- package/components/data/pagination/components/PagerNavigation.js +84 -105
- package/components/data/pagination/components/TotalRecords.js +48 -47
- package/components/data/pagination/components/index.js +14 -47
- package/components/data/pagination/components/props.js +0 -5
- package/components/data/pagination/hooks/index.js +6 -19
- package/components/data/pagination/hooks/props.js +0 -5
- package/components/data/pagination/hooks/useNavigationSize.js +12 -21
- package/components/data/pagination/hooks/usePagination.js +702 -905
- package/components/data/pagination/index.js +336 -389
- package/components/data/table/components/AddNewRow.js +122 -154
- package/components/data/table/components/EditableCell.js +68 -75
- package/components/data/table/components/FieldValidationError.js +19 -20
- package/components/data/table/components/RowCells.js +97 -80
- package/components/data/table/components/RowExpansionButton.js +43 -39
- package/components/data/table/components/SummaryCell.js +54 -88
- package/components/data/table/components/SummaryRow.js +45 -52
- package/components/data/table/components/SummaryRowFooter.js +35 -42
- package/components/data/table/components/TableBody.js +222 -218
- package/components/data/table/components/TableDataRow.js +113 -106
- package/components/data/table/components/TableFilters.js +391 -390
- package/components/data/table/components/TableFooterActions.js +25 -32
- package/components/data/table/components/TableHeader.js +460 -435
- package/components/data/table/components/TablePanelHeading.js +157 -181
- package/components/data/table/components/index.js +27 -95
- package/components/data/table/hooks/index.js +21 -230
- package/components/data/table/hooks/use-edited-rows.js +59 -94
- package/components/data/table/hooks/useCellState.js +58 -83
- package/components/data/table/hooks/useCustomExpressionColumns.js +65 -86
- package/components/data/table/hooks/useDynamicColumns.js +59 -92
- package/components/data/table/hooks/useEditingState.js +30 -41
- package/components/data/table/hooks/useFormWidget.js +163 -172
- package/components/data/table/hooks/usePaginationState.js +67 -77
- package/components/data/table/hooks/usePanelStructure.js +47 -41
- package/components/data/table/hooks/useResponsiveColumns.js +14 -20
- package/components/data/table/hooks/useRowExpansion.js +131 -127
- package/components/data/table/hooks/useRowHandlers.js +56 -69
- package/components/data/table/hooks/useRowSelection.js +249 -329
- package/components/data/table/hooks/useServerSideSorting.js +109 -175
- package/components/data/table/hooks/useTableColumns.js +322 -331
- package/components/data/table/hooks/useTableData.js +111 -166
- package/components/data/table/hooks/useTableEdit.js +526 -564
- package/components/data/table/hooks/useTableEffects.js +60 -107
- package/components/data/table/hooks/useTableFilter.js +244 -237
- package/components/data/table/hooks/useTableInitialization.js +44 -76
- package/components/data/table/hooks/useTableState.js +39 -61
- package/components/data/table/hooks/useTableStateManager.js +295 -468
- package/components/data/table/index.js +1553 -1713
- package/components/data/table/live-table/index.js +157 -219
- package/components/data/table/props.js +0 -5
- package/components/data/table/table-action/index.js +97 -75
- package/components/data/table/table-column/index.js +48 -42
- package/components/data/table/table-group/index.js +7 -25
- package/components/data/table/table-row/index.js +63 -55
- package/components/data/table/table-row-action/index.js +102 -77
- package/components/data/table/utils/buildSelectionColumns.js +86 -137
- package/components/data/table/utils/columnBuilder.js +116 -158
- package/components/data/table/utils/columnProxy.js +48 -66
- package/components/data/table/utils/columnWidthDistribution.js +40 -64
- package/components/data/table/utils/constants.js +92 -40
- package/components/data/table/utils/crud-handlers.js +292 -473
- package/components/data/table/utils/dynamic-columns.js +99 -144
- package/components/data/table/utils/groupHeaderUtils.js +36 -61
- package/components/data/table/utils/index.d.ts +8 -5
- package/components/data/table/utils/index.js +419 -639
- package/components/data/table/utils/renderDisplayCell.js +127 -169
- package/components/data/table/utils/script-page-size-broadcast.js +17 -29
- package/components/data/table/utils/selectionUtils.js +59 -113
- package/components/data/table/utils/table-helpers.js +38 -74
- package/components/data/table/utils/validation.js +35 -78
- package/components/data/table/utils/widgetMapping.d.ts +5 -0
- package/components/data/table/utils/widgetMapping.js +41 -0
- package/components/data/types.js +112 -112
- package/components/data/utils/field-data-utils.js +38 -42
- package/components/data/utils/filter-field-util.js +42 -44
- package/components/data/utils/index.js +112 -111
- package/components/dialogs/alert-dialog/index.js +83 -78
- package/components/dialogs/alert-dialog/props.js +0 -5
- package/components/dialogs/confirm-dialog/index.js +102 -92
- package/components/dialogs/confirm-dialog/props.js +0 -5
- package/components/dialogs/dialog/index.js +93 -69
- package/components/dialogs/dialog/props.js +0 -5
- package/components/dialogs/dialog-actions/index.js +12 -26
- package/components/dialogs/dialog-actions/props.js +0 -5
- package/components/dialogs/dialog-body/index.js +13 -30
- package/components/dialogs/dialog-body/props.js +0 -5
- package/components/dialogs/dialog-content/index.js +48 -41
- package/components/dialogs/dialog-content/props.js +0 -5
- package/components/dialogs/dialog-header/index.js +88 -101
- package/components/dialogs/dialog-header/props.js +0 -5
- package/components/dialogs/iframe-dialog/index.js +136 -128
- package/components/dialogs/iframe-dialog/props.js +0 -5
- package/components/dialogs/index.js +104 -101
- package/components/dialogs/login-dialog/index.js +285 -347
- package/components/dialogs/login-dialog/props.js +0 -5
- package/components/dialogs/page-dialog/index.js +95 -86
- package/components/dialogs/page-dialog/props.js +0 -5
- package/components/dialogs/props.js +0 -5
- package/components/dialogs/withDialogWrapper.js +110 -83
- package/components/form/button/index.js +296 -245
- package/components/form/button/props.js +0 -5
- package/components/form/button-group/index.js +80 -69
- package/components/form/button-group/props.js +0 -5
- package/components/input/calendar/index.js +409 -362
- package/components/input/calendar/props.js +0 -5
- package/components/input/calendar/utils.js +164 -172
- package/components/input/chips/SortableChip/index.js +109 -100
- package/components/input/chips/SortableChip/props.js +0 -5
- package/components/input/chips/index.js +663 -570
- package/components/input/chips/props.js +0 -5
- package/components/input/chips/utils.js +131 -122
- package/components/input/color-picker/index.js +536 -594
- package/components/input/color-picker/props.js +0 -5
- package/components/input/composite/index.js +71 -110
- package/components/input/composite/props.js +0 -5
- package/components/input/currency/index.js +277 -224
- package/components/input/currency/props.js +0 -5
- package/components/input/default/checkbox/index.js +329 -250
- package/components/input/default/checkbox/props.js +0 -5
- package/components/input/default/checkboxset/index.d.ts +2 -0
- package/components/input/default/checkboxset/index.js +529 -446
- package/components/input/default/checkboxset/props.d.ts +4 -0
- package/components/input/default/checkboxset/props.js +0 -5
- package/components/input/default/checkboxset/utils.js +15 -25
- package/components/input/default/radioset/index.d.ts +2 -0
- package/components/input/default/radioset/index.js +409 -350
- package/components/input/default/radioset/props.d.ts +6 -0
- package/components/input/default/radioset/props.js +0 -5
- package/components/input/default/switch/index.js +494 -458
- package/components/input/default/switch/prop.js +0 -5
- package/components/input/epoch/date/components/DatePickerPopover.js +242 -193
- package/components/input/epoch/date/index.js +638 -518
- package/components/input/epoch/date/props.js +0 -5
- package/components/input/epoch/date/styled.js +61 -70
- package/components/input/epoch/date/utils.js +67 -115
- package/components/input/epoch/datetime/index.js +758 -695
- package/components/input/epoch/datetime/props.js +0 -5
- package/components/input/epoch/datetime/utils.js +121 -186
- package/components/input/epoch/time/index.js +441 -415
- package/components/input/epoch/time/props.js +0 -5
- package/components/input/epoch/time/utils.js +101 -112
- package/components/input/fileupload/Utils.js +70 -97
- package/components/input/fileupload/components/ListItems.js +132 -130
- package/components/input/fileupload/components/MultiUpload.js +80 -77
- package/components/input/fileupload/components/SingleUpload.js +57 -57
- package/components/input/fileupload/index.js +253 -178
- package/components/input/fileupload/props.js +0 -5
- package/components/input/fileupload/useFileUpload.js +209 -258
- package/components/input/number/index.js +434 -393
- package/components/input/number/props.js +0 -5
- package/components/input/rating/index.js +401 -394
- package/components/input/rating/props.js +0 -5
- package/components/input/select/index.js +408 -463
- package/components/input/select/props.js +0 -5
- package/components/input/slider/index.js +339 -332
- package/components/input/slider/props.js +0 -5
- package/components/input/text/index.d.ts +3 -3
- package/components/input/text/index.js +438 -475
- package/components/input/text/props.d.ts +1 -1
- package/components/input/text/props.js +0 -5
- package/components/input/text/util.js +82 -222
- package/components/input/textarea/index.js +322 -358
- package/components/input/textarea/props.js +0 -5
- package/components/input/upload/index.js +135 -131
- package/components/input/upload/props.js +0 -5
- package/components/input/util/index.js +9 -11
- package/components/layout/footer/index.js +12 -35
- package/components/layout/footer/props.js +0 -5
- package/components/layout/header/index.js +12 -38
- package/components/layout/header/props.js +0 -5
- package/components/layout/leftnav/index.js +38 -44
- package/components/layout/leftnav/props.js +0 -5
- package/components/layout/rightnav/index.js +12 -36
- package/components/layout/rightnav/props.js +0 -5
- package/components/layout/topnav/index.js +24 -38
- package/components/layout/topnav/props.js +0 -5
- package/components/navbar/index.js +119 -98
- package/components/navbar/nav/index.js +236 -232
- package/components/navbar/nav/props.js +0 -5
- package/components/navbar/nav-item/index.js +74 -65
- package/components/navbar/nav-item/props.js +0 -5
- package/components/navigation/breadcrumb/index.js +38 -61
- package/components/navigation/breadcrumb/props.js +0 -5
- package/components/navigation/menu/components/ListItems.js +76 -67
- package/components/navigation/menu/constants.js +27 -42
- package/components/navigation/menu/hooks/useHoverState.hook.js +20 -47
- package/components/navigation/menu/hooks/useKeyboardMovements.hook.js +34 -28
- package/components/navigation/menu/hooks/useTransformedDataset.hook.js +21 -14
- package/components/navigation/menu/index.js +911 -846
- package/components/navigation/menu/props.js +0 -5
- package/components/navigation/menu/utils/action-task.js +6 -9
- package/components/navigation/menu/utils/role-filter.js +41 -56
- package/components/navigation/popover/index.js +191 -205
- package/components/navigation/popover/props.js +5 -8
- package/components/page/content/index.js +9 -31
- package/components/page/content/props.js +0 -5
- package/components/page/error-boundary/index.js +115 -105
- package/components/page/error-boundary/props.js +0 -5
- package/components/page/index.js +84 -102
- package/components/page/page-content/index.js +21 -30
- package/components/page/page-content/props.js +0 -5
- package/components/page/partial/index.js +50 -45
- package/components/page/partial/props.js +0 -5
- package/components/page/partial-container/index.js +81 -107
- package/components/page/partial-container/props.d.ts +1 -1
- package/components/page/partial-container/props.js +0 -5
- package/components/page/props.js +0 -5
- package/components/page/toast-container/index.js +20 -41
- package/components/page/toast-container/props.js +0 -5
- package/components/prefab/container/index.js +60 -53
- package/components/prefab/container/props.js +0 -5
- package/components/prefab/index.js +76 -61
- package/components/prefab/props.js +0 -5
- package/context/AppContext.d.ts +1 -1
- package/context/AppContext.js +17 -18
- package/context/AppSpinnerProvider.js +19 -34
- package/context/LayoutProvider.js +54 -57
- package/context/LocalizationProvider.js +34 -49
- package/context/PrefabContext.js +68 -119
- package/context/WidgetProvider.js +160 -166
- package/core/app-config.js +0 -1
- package/core/app.service.js +200 -327
- package/core/appVariablesStore.js +10 -15
- package/core/appstore.js +37 -53
- package/core/constants/currency-constant.js +81 -83
- package/core/constants/events.js +34 -44
- package/core/constants/index.js +21 -31
- package/core/dialog.service.js +52 -72
- package/core/event-notifier.js +94 -131
- package/core/formatter/array-formatters.js +18 -32
- package/core/formatter/date-formatters.js +140 -204
- package/core/formatter/index.js +64 -117
- package/core/formatter/number-formatters.js +115 -159
- package/core/formatter/security-formatters.js +233 -283
- package/core/formatter/string-formatters.js +23 -45
- package/core/formatter/types.js +12 -18
- package/core/formatters.js +6 -24
- package/core/proxy-service.js +242 -306
- package/core/script-registry.js +87 -134
- package/core/security.service.js +8 -11
- package/core/util/compare.js +13 -25
- package/core/util/dom.js +32 -63
- package/core/util/index.d.ts +5 -0
- package/core/util/index.js +95 -95
- package/core/util/safe-is-equal.js +42 -94
- package/core/util/security.js +114 -153
- package/core/util/utils.d.ts +8 -1
- package/core/util/utils.js +124 -132
- package/core/widget-observer.js +34 -61
- package/higherOrder/BaseApp.js +327 -500
- package/higherOrder/BaseAppProps.js +0 -5
- package/higherOrder/BaseDateTime.js +277 -231
- package/higherOrder/BasePage.js +479 -735
- package/higherOrder/BasePartial.js +87 -114
- package/higherOrder/BasePrefab.js +190 -206
- package/higherOrder/DataNav.js +287 -302
- package/higherOrder/helper.js +62 -48
- package/higherOrder/props.js +0 -5
- package/higherOrder/withBaseWrapper.js +123 -168
- package/higherOrder/withStandalone.js +28 -26
- package/hooks/useAccess.js +113 -289
- package/hooks/useAppConfig.js +15 -40
- package/hooks/useAuth.js +256 -495
- package/hooks/useDataSourceSubscription.d.ts +3 -3
- package/hooks/useDataSourceSubscription.js +99 -109
- package/hooks/useDebounce.js +28 -56
- package/hooks/useDeviceVisibility.js +14 -23
- package/hooks/useHttp.d.ts +1 -0
- package/hooks/useHttp.js +318 -493
- package/libs/index.js +4 -13
- package/libs/prefab/index.js +6 -20
- package/mui-config/theme-provider.js +9 -17
- package/mui-config/theme.js +6 -9
- package/package-lock.json +808 -3177
- package/package.json +3 -19
- package/providers/AppProviders.js +21 -24
- package/runtime-dynamic/App.js +65 -93
- package/runtime-dynamic/app-initializer.js +207 -400
- package/runtime-dynamic/components/ErrorBoundary.js +59 -76
- package/runtime-dynamic/components/PageWrapper.js +23 -35
- package/runtime-dynamic/components/PrefabPreview.js +40 -69
- package/runtime-dynamic/components/partial-content.d.ts +2 -3
- package/runtime-dynamic/components/partial-content.js +66 -48
- package/runtime-dynamic/components/prefab-content.js +37 -30
- package/runtime-dynamic/components/use-dynamic-component.js +62 -150
- package/runtime-dynamic/factories/build-base-page-like-component.js +44 -58
- package/runtime-dynamic/factories/dynamic-component.d.ts +9 -0
- package/runtime-dynamic/factories/dynamic-component.js +83 -0
- package/runtime-dynamic/factories/prefab-factory.js +60 -81
- package/runtime-dynamic/factories/startup-info.js +12 -25
- package/runtime-dynamic/factories/utils.d.ts +1 -9
- package/runtime-dynamic/factories/utils.js +47 -130
- package/runtime-dynamic/index.js +56 -191
- package/runtime-dynamic/main.js +42 -70
- package/runtime-dynamic/preview-mode.js +14 -29
- package/runtime-dynamic/preview-navigation.js +21 -30
- package/runtime-dynamic/preview-path.d.ts +5 -0
- package/runtime-dynamic/preview-path.js +13 -0
- package/runtime-dynamic/preview-resource-base.js +15 -31
- package/runtime-dynamic/registry/component-registry.js +269 -334
- package/runtime-dynamic/registry/custom-widget-registry.js +11 -15
- package/runtime-dynamic/registry/index.js +24 -63
- package/runtime-dynamic/registry/store.d.ts +1 -0
- package/runtime-dynamic/registry/store.js +18 -23
- package/runtime-dynamic/routes.js +53 -81
- package/runtime-dynamic/services/app-extension-provider.js +17 -44
- package/runtime-dynamic/services/autolayout-inject.d.ts +4 -0
- package/runtime-dynamic/services/autolayout-inject.js +27 -0
- package/runtime-dynamic/services/cache.js +27 -33
- package/runtime-dynamic/services/compile-render.d.ts +9 -0
- package/runtime-dynamic/services/compile-render.js +142 -0
- package/runtime-dynamic/services/component-ref-provider.js +70 -124
- package/runtime-dynamic/services/css-scoping.js +27 -28
- package/runtime-dynamic/services/fragment-url.js +37 -50
- package/runtime-dynamic/services/index.js +48 -152
- package/runtime-dynamic/services/markup-transpiler.d.ts +2 -2
- package/runtime-dynamic/services/markup-transpiler.js +39 -231
- package/runtime-dynamic/services/prefab-resources.js +42 -130
- package/runtime-dynamic/services/resource-manager.d.ts +2 -1
- package/runtime-dynamic/services/resource-manager.js +32 -63
- package/runtime-dynamic/services/script-executor.js +50 -61
- package/runtime-dynamic/services/variable-factory.js +141 -184
- package/runtime-dynamic/services/variable-registry.js +69 -115
- package/runtime-dynamic/services/variable-transpiler.js +73 -103
- package/runtime-dynamic/shims/next-image.js +79 -50
- package/runtime-dynamic/shims/next-link.js +58 -32
- package/runtime-dynamic/shims/next-navigation.js +17 -34
- package/runtime-dynamic/utils/index.d.ts +2 -0
- package/runtime-dynamic/utils/index.js +22 -24
- package/store/bindActions/i18nActions.js +16 -18
- package/store/index.js +29 -35
- package/store/middleware/navigationMiddleware.js +25 -45
- package/store/middleware/pendingTabNavigationIntentMiddleware.js +20 -25
- package/store/slices/appConfigSlice.js +65 -94
- package/store/slices/authSlice.js +317 -471
- package/store/slices/i18nSlice.js +169 -168
- package/store/slices/navigationSlice.js +22 -20
- package/store/util/resolve-path.d.ts +1 -0
- package/store/util/resolve-path.js +7 -0
- package/store/viewport.service.js +150 -194
- package/types/index.js +10 -15
- package/utils/attr.js +198 -41
- package/utils/custom-expression/index.js +55 -151
- package/utils/custom-expression/parser.js +106 -182
- package/utils/dataset-util.js +113 -154
- package/utils/eval-expression.js +10 -19
- package/utils/form-state.util.js +60 -118
- package/utils/form-utils.js +49 -190
- package/utils/format-util.js +113 -184
- package/utils/layoutsize-util.js +11 -17
- package/utils/lib-error-skipper.js +54 -52
- package/utils/page-params-util.js +50 -40
- package/utils/pending-tab-navigation-intent.js +7 -17
- package/utils/resource-url.js +8 -19
- package/utils/state-persistance.js +136 -253
- package/utils/style-utils.d.ts +2 -0
- package/utils/style-utils.js +25 -74
- package/utils/transformedDataset-utils.js +353 -381
- package/utils/widget-cleanup-util.js +42 -74
- package/utils/widgets.js +19 -31
- package/variables/base-variable.js +117 -166
- package/variables/constants.js +5 -8
- package/variables/crud-variable.js +150 -181
- package/variables/live-variable.d.ts +1 -1
- package/variables/live-variable.js +140 -174
- package/variables/metadata.service.js +74 -116
- package/variables/model-variable.js +68 -78
- package/variables/service-variable.js +171 -285
- package/wm-namespace.js +11 -14
- package/components/chart/src/css.d.js +0 -1
- package/tsconfig.declaration.tsbuildinfo +0 -1
- package/types/global.d.js +0 -3
|
@@ -1,304 +1,238 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
+
import React, {
|
|
22
|
+
memo,
|
|
23
|
+
useState,
|
|
24
|
+
useEffect,
|
|
25
|
+
useCallback,
|
|
26
|
+
useMemo,
|
|
27
|
+
isValidElement,
|
|
28
|
+
cloneElement,
|
|
29
|
+
useRef,
|
|
30
|
+
Children
|
|
31
|
+
} from "react";
|
|
32
|
+
import { Box, Typography, Stepper } from "@mui/material";
|
|
33
|
+
import clsx from "clsx";
|
|
34
|
+
import { withBaseWrapper } from "../../../higherOrder/withBaseWrapper";
|
|
35
|
+
import {
|
|
36
|
+
getNextValidStep,
|
|
37
|
+
getStepByName,
|
|
38
|
+
getStepByIndex,
|
|
39
|
+
handleNavigation,
|
|
40
|
+
extendNextFn,
|
|
41
|
+
extendPrevFn,
|
|
42
|
+
getPrevValidStep,
|
|
43
|
+
appendDatasetSteps,
|
|
44
|
+
trimStepsToLength
|
|
45
|
+
} from "./utils";
|
|
46
|
+
import WizardContext from "./WizardContext";
|
|
47
|
+
import { WmWizardstep } from "./wizard-step";
|
|
48
|
+
import { WizardStep } from "./components/WizardStep";
|
|
49
|
+
import WmForm from "../../data/form";
|
|
50
|
+
import { getFormData } from "../../../utils/form-utils";
|
|
51
|
+
import { useParentFormData } from "../../data/form/form-context";
|
|
52
|
+
import isEqual from "lodash-es/isEqual";
|
|
53
|
+
import withStandalone from "../../../higherOrder/withStandalone";
|
|
54
|
+
const DEFAULT_CLS = "app-wizard panel clearfix";
|
|
55
|
+
const BODY_CLASS = "app-wizard-body panel-body";
|
|
56
|
+
const WmWizard = memo(
|
|
57
|
+
(props) => {
|
|
58
|
+
const {
|
|
59
|
+
listener,
|
|
60
|
+
stepstyle = "auto",
|
|
61
|
+
actionsalignment = "right",
|
|
62
|
+
defaultstep = "none",
|
|
63
|
+
defaultstepindex = 0,
|
|
64
|
+
cancelable = true,
|
|
65
|
+
enablenext = false,
|
|
66
|
+
nextbtnlabel = "Next",
|
|
67
|
+
previousbtnlabel = "Previous",
|
|
68
|
+
donebtnlabel = "Done",
|
|
69
|
+
cancelbtnlabel = "Cancel",
|
|
70
|
+
type = "static",
|
|
71
|
+
dataset = [],
|
|
72
|
+
nodatamessage = "No Data Found",
|
|
73
|
+
children,
|
|
74
|
+
className = "classic",
|
|
75
|
+
styles,
|
|
76
|
+
name = "",
|
|
77
|
+
onCancel,
|
|
78
|
+
onDone,
|
|
79
|
+
message,
|
|
80
|
+
orientation = "horizontal",
|
|
81
|
+
alternativeLabel = false,
|
|
82
|
+
nonLinear = true,
|
|
83
|
+
connector,
|
|
84
|
+
width,
|
|
85
|
+
height,
|
|
86
|
+
render,
|
|
87
|
+
standalone = false
|
|
88
|
+
} = props;
|
|
89
|
+
const [steps, setSteps] = useState([]);
|
|
90
|
+
const [wizardMessage, setWizardMessage] = useState(message || { caption: "", type: "" });
|
|
91
|
+
const [isInitialized, setIsInitialized] = useState(false);
|
|
92
|
+
const formRefs = useRef({});
|
|
93
|
+
const stepContainerRefs = useRef({});
|
|
94
|
+
const navIndexRef = useRef(-1);
|
|
95
|
+
const [formReady, setFormReady] = useState(false);
|
|
96
|
+
const parentFormContext = useParentFormData();
|
|
97
|
+
const isInsideOuterForm = !!parentFormContext && Object.keys(parentFormContext).length > 0;
|
|
98
|
+
const createDynamicSteps = useCallback(
|
|
99
|
+
(datasetItems, startIndex) => {
|
|
100
|
+
return datasetItems.map((item, index) => {
|
|
101
|
+
var _a, _b;
|
|
102
|
+
index = startIndex || index;
|
|
103
|
+
const stepData = render ? render(item, index, datasetItems) : item;
|
|
104
|
+
let stepProps = (stepData == null ? void 0 : stepData.props) || {};
|
|
105
|
+
if (isValidElement(stepData)) {
|
|
106
|
+
if (stepData.type === WmWizardstep) {
|
|
107
|
+
stepProps = stepData.props || {};
|
|
108
|
+
} else if ((_a = stepData.props) == null ? void 0 : _a.children) {
|
|
109
|
+
const childrenArray = Children.toArray(
|
|
110
|
+
(_b = stepData.props) == null ? void 0 : _b.children
|
|
111
|
+
);
|
|
112
|
+
const firstWizardStep = childrenArray.find(
|
|
113
|
+
(child) => isValidElement(child) && child.type === WmWizardstep
|
|
114
|
+
);
|
|
115
|
+
if (isValidElement(firstWizardStep)) {
|
|
116
|
+
stepProps = firstWizardStep.props || {};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return __spreadProps(__spreadValues({}, stepProps), {
|
|
121
|
+
name: `step_${index}`,
|
|
122
|
+
title: stepProps.title || `Step ${index + 1}`,
|
|
123
|
+
show: stepProps.show !== false,
|
|
124
|
+
enableskip: stepData.enableskip || false,
|
|
125
|
+
enableNext: stepData.enableNext !== false,
|
|
126
|
+
enablePrev: stepData.enablePrev !== false,
|
|
127
|
+
enableDone: stepData.enableDone !== false,
|
|
128
|
+
isDone: false,
|
|
129
|
+
done: false,
|
|
130
|
+
active: index === defaultstepindex,
|
|
131
|
+
disabled: false,
|
|
132
|
+
isValid: true,
|
|
133
|
+
isInitialized: false,
|
|
134
|
+
isdynamic: true,
|
|
135
|
+
dynamicStepIndex: index,
|
|
136
|
+
render: stepProps.render
|
|
124
137
|
});
|
|
125
|
-
|
|
126
|
-
|
|
138
|
+
});
|
|
139
|
+
},
|
|
140
|
+
[defaultstepindex]
|
|
141
|
+
);
|
|
142
|
+
const currentStep = useMemo(() => steps.find((step) => step.active) || null, [steps]);
|
|
143
|
+
const visibleSteps = useMemo(() => steps.filter((step) => step.show), [steps]);
|
|
144
|
+
const currentStepIndex = useMemo(() => {
|
|
145
|
+
if (!currentStep) return -1;
|
|
146
|
+
return visibleSteps.findIndex((step) => step.name === currentStep.name);
|
|
147
|
+
}, [currentStep, visibleSteps]);
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
navIndexRef.current = currentStepIndex;
|
|
150
|
+
}, [currentStepIndex]);
|
|
151
|
+
const hasNextStep = useMemo(
|
|
152
|
+
() => currentStepIndex < visibleSteps.length - 1,
|
|
153
|
+
[currentStepIndex, visibleSteps]
|
|
154
|
+
);
|
|
155
|
+
const hasPrevStep = useMemo(() => currentStepIndex > 0, [currentStepIndex]);
|
|
156
|
+
const showDoneBtn = useMemo(
|
|
157
|
+
() => !hasNextStep && (currentStep == null ? void 0 : currentStep.enableDone) !== false,
|
|
158
|
+
[hasNextStep, currentStep]
|
|
159
|
+
);
|
|
160
|
+
const [isStepValid, setIsStepValid] = useState(true);
|
|
161
|
+
const [formValiditySignature, setFormValiditySignature] = useState("");
|
|
162
|
+
const formValidityMapRef = useRef(/* @__PURE__ */ new Map());
|
|
163
|
+
const getStepForms = useCallback((stepName) => {
|
|
164
|
+
var _a, _b;
|
|
165
|
+
const formElOrList = (_a = formRefs.current) == null ? void 0 : _a[stepName];
|
|
166
|
+
if (formElOrList) {
|
|
167
|
+
const cachedForms = Array.isArray(formElOrList) ? formElOrList : [formElOrList];
|
|
168
|
+
const stepContainer = (_b = cachedForms[0]) == null ? void 0 : _b.closest(".app-wizard-step-container");
|
|
169
|
+
if (stepContainer) {
|
|
170
|
+
const allForms = Array.from(stepContainer.querySelectorAll("form"));
|
|
171
|
+
if (allForms.length > 0) {
|
|
172
|
+
formRefs.current[stepName] = allForms.length === 1 ? allForms[0] : allForms;
|
|
173
|
+
return allForms;
|
|
127
174
|
}
|
|
128
175
|
}
|
|
176
|
+
return cachedForms;
|
|
129
177
|
}
|
|
130
|
-
return
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}, [currentStepIndex]);
|
|
173
|
-
var _hasNextStep = (0, _react.useMemo)(function () {
|
|
174
|
-
return currentStepIndex < visibleSteps.length - 1;
|
|
175
|
-
}, [currentStepIndex, visibleSteps]);
|
|
176
|
-
var hasPrevStep = (0, _react.useMemo)(function () {
|
|
177
|
-
return currentStepIndex > 0;
|
|
178
|
-
}, [currentStepIndex]);
|
|
179
|
-
var showDoneBtn = (0, _react.useMemo)(function () {
|
|
180
|
-
return !_hasNextStep && (currentStep === null || currentStep === void 0 ? void 0 : currentStep.enableDone) !== false;
|
|
181
|
-
}, [_hasNextStep, currentStep]);
|
|
182
|
-
var _useState5 = (0, _react.useState)(true),
|
|
183
|
-
isStepValid = _useState5[0],
|
|
184
|
-
setIsStepValid = _useState5[1];
|
|
185
|
-
var _useState6 = (0, _react.useState)(""),
|
|
186
|
-
formValiditySignature = _useState6[0],
|
|
187
|
-
setFormValiditySignature = _useState6[1];
|
|
188
|
-
var formValidityMapRef = (0, _react.useRef)(new Map());
|
|
189
|
-
|
|
190
|
-
// Helper to get all forms in the current step container
|
|
191
|
-
var getStepForms = (0, _react.useCallback)(function (stepName) {
|
|
192
|
-
var _formRefs$current;
|
|
193
|
-
// First try cached formRefs
|
|
194
|
-
var formElOrList = (_formRefs$current = formRefs.current) === null || _formRefs$current === void 0 ? void 0 : _formRefs$current[stepName];
|
|
195
|
-
if (formElOrList) {
|
|
196
|
-
var _cachedForms$;
|
|
197
|
-
var cachedForms = Array.isArray(formElOrList) ? formElOrList : [formElOrList];
|
|
198
|
-
// Re-query the DOM to get ALL forms (list items may have rendered after initial cache)
|
|
199
|
-
var stepContainer = (_cachedForms$ = cachedForms[0]) === null || _cachedForms$ === void 0 ? void 0 : _cachedForms$.closest(".app-wizard-step-container");
|
|
200
|
-
if (stepContainer) {
|
|
201
|
-
var allForms = Array.from(stepContainer.querySelectorAll("form"));
|
|
202
|
-
if (allForms.length > 0) {
|
|
203
|
-
// Update cache with all forms
|
|
204
|
-
formRefs.current[stepName] = allForms.length === 1 ? allForms[0] : allForms;
|
|
205
|
-
return allForms;
|
|
178
|
+
return [];
|
|
179
|
+
}, []);
|
|
180
|
+
useEffect(() => {
|
|
181
|
+
const stepName = currentStep == null ? void 0 : currentStep.name;
|
|
182
|
+
if (!stepName) return;
|
|
183
|
+
const stepContainer = stepContainerRefs.current[stepName];
|
|
184
|
+
if (!stepContainer) return;
|
|
185
|
+
formValidityMapRef.current.clear();
|
|
186
|
+
setFormValiditySignature("");
|
|
187
|
+
const initialForms = getStepForms(stepName);
|
|
188
|
+
if (initialForms.length === 0) return;
|
|
189
|
+
const onValidity = (e) => {
|
|
190
|
+
const form = e.target.closest("form");
|
|
191
|
+
if (!form) return;
|
|
192
|
+
const detail = e.detail;
|
|
193
|
+
const isValid = (detail == null ? void 0 : detail.isValid) !== false;
|
|
194
|
+
const currentForms = getStepForms(stepName);
|
|
195
|
+
formValidityMapRef.current.set(form, isValid);
|
|
196
|
+
const allFormsValid = currentForms.every((f) => {
|
|
197
|
+
const validity = formValidityMapRef.current.get(f);
|
|
198
|
+
return validity === void 0 || validity === true;
|
|
199
|
+
});
|
|
200
|
+
setFormValiditySignature(allFormsValid ? "1" : "0");
|
|
201
|
+
};
|
|
202
|
+
stepContainer.addEventListener("wm:form-validity", onValidity);
|
|
203
|
+
return () => {
|
|
204
|
+
stepContainer.removeEventListener("wm:form-validity", onValidity);
|
|
205
|
+
};
|
|
206
|
+
}, [currentStep, formReady, getStepForms]);
|
|
207
|
+
const parentFormIsValid = parentFormContext == null ? void 0 : parentFormContext.isValid;
|
|
208
|
+
useEffect(() => {
|
|
209
|
+
const validateStep = () => {
|
|
210
|
+
var _a;
|
|
211
|
+
if (!currentStep) return;
|
|
212
|
+
const forms = getStepForms(currentStep.name);
|
|
213
|
+
if (forms.length === 0) {
|
|
214
|
+
if (isInsideOuterForm && parentFormContext) {
|
|
215
|
+
setIsStepValid(parentFormContext.isValid === true);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
setIsStepValid(true);
|
|
219
|
+
return;
|
|
206
220
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
var stepName = currentStep === null || currentStep === void 0 ? void 0 : currentStep.name;
|
|
214
|
-
if (!stepName) return;
|
|
215
|
-
|
|
216
|
-
// Get step container for event delegation
|
|
217
|
-
var stepContainer = stepContainerRefs.current[stepName];
|
|
218
|
-
if (!stepContainer) return;
|
|
219
|
-
|
|
220
|
-
// Reset validity state for new step
|
|
221
|
-
formValidityMapRef.current.clear();
|
|
222
|
-
setFormValiditySignature("");
|
|
223
|
-
|
|
224
|
-
// Only set up form validity tracking if forms are present inside the step
|
|
225
|
-
var initialForms = getStepForms(stepName);
|
|
226
|
-
|
|
227
|
-
// When inside outer form with no embedded forms, validity comes from context
|
|
228
|
-
// No DOM event listener needed - parentFormContext.isValid is reactive
|
|
229
|
-
if (initialForms.length === 0) return;
|
|
230
|
-
|
|
231
|
-
// Use event delegation - listen on container, forms bubble their events up
|
|
232
|
-
var onValidity = function onValidity(e) {
|
|
233
|
-
// Find the form that emitted this event (could be e.target or closest form)
|
|
234
|
-
var form = e.target.closest("form");
|
|
235
|
-
if (!form) return;
|
|
236
|
-
var detail = e.detail;
|
|
237
|
-
var isValid = (detail === null || detail === void 0 ? void 0 : detail.isValid) !== false;
|
|
238
|
-
|
|
239
|
-
// Re-query forms to get current list (handles dynamically added forms from lists)
|
|
240
|
-
var currentForms = getStepForms(stepName);
|
|
241
|
-
|
|
242
|
-
// Track validity per form element
|
|
243
|
-
formValidityMapRef.current.set(form, isValid);
|
|
244
|
-
|
|
245
|
-
// Check if ALL current forms are valid
|
|
246
|
-
var allFormsValid = currentForms.every(function (f) {
|
|
247
|
-
var validity = formValidityMapRef.current.get(f);
|
|
248
|
-
// If we haven't received an event for this form yet, assume valid
|
|
249
|
-
return validity === undefined || validity === true;
|
|
250
|
-
});
|
|
251
|
-
setFormValiditySignature(allFormsValid ? "1" : "0");
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
// Listen on container - captures events from all forms, including dynamically added ones
|
|
255
|
-
stepContainer.addEventListener("wm:form-validity", onValidity);
|
|
256
|
-
return function () {
|
|
257
|
-
stepContainer.removeEventListener("wm:form-validity", onValidity);
|
|
258
|
-
};
|
|
259
|
-
}, [currentStep, formReady, getStepForms]);
|
|
260
|
-
var parentFormIsValid = parentFormContext === null || parentFormContext === void 0 ? void 0 : parentFormContext.isValid;
|
|
261
|
-
(0, _react.useEffect)(function () {
|
|
262
|
-
var validateStep = function validateStep() {
|
|
263
|
-
if (!currentStep) return;
|
|
264
|
-
|
|
265
|
-
// Dynamically query for all forms (handles list items that render after initial mount)
|
|
266
|
-
var forms = getStepForms(currentStep.name);
|
|
267
|
-
if (forms.length === 0) {
|
|
268
|
-
// When inside outer form with no embedded forms, use context-based validity
|
|
269
|
-
if (isInsideOuterForm && parentFormContext) {
|
|
270
|
-
setIsStepValid(parentFormContext.isValid === true);
|
|
221
|
+
const allFormsHidden = forms.every((form) => {
|
|
222
|
+
var _a2;
|
|
223
|
+
return form.hidden || ((_a2 = form.parentElement) == null ? void 0 : _a2.hidden);
|
|
224
|
+
});
|
|
225
|
+
if (allFormsHidden) {
|
|
226
|
+
setIsStepValid(true);
|
|
271
227
|
return;
|
|
272
228
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
var allFormsHidden = forms.every(function (form) {
|
|
279
|
-
var _form$parentElement;
|
|
280
|
-
return form.hidden || ((_form$parentElement = form.parentElement) === null || _form$parentElement === void 0 ? void 0 : _form$parentElement.hidden);
|
|
281
|
-
});
|
|
282
|
-
if (allFormsHidden) {
|
|
283
|
-
setIsStepValid(true);
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
// Check if any form has fields and collect validity
|
|
288
|
-
var hasAnyFields = false;
|
|
289
|
-
var allFormsValid = true;
|
|
290
|
-
var _iterator = _createForOfIteratorHelper(forms),
|
|
291
|
-
_step;
|
|
292
|
-
try {
|
|
293
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
294
|
-
var _form$parentElement2;
|
|
295
|
-
var form = _step.value;
|
|
296
|
-
if (form.hidden || (_form$parentElement2 = form.parentElement) !== null && _form$parentElement2 !== void 0 && _form$parentElement2.hidden) continue;
|
|
297
|
-
var formdata = (0, _formUtils.getFormData)({
|
|
298
|
-
current: form
|
|
299
|
-
});
|
|
229
|
+
let hasAnyFields = false;
|
|
230
|
+
let allFormsValid = true;
|
|
231
|
+
for (const form of forms) {
|
|
232
|
+
if (form.hidden || ((_a = form.parentElement) == null ? void 0 : _a.hidden)) continue;
|
|
233
|
+
const formdata = getFormData({ current: form });
|
|
300
234
|
if (!formdata) continue;
|
|
301
|
-
|
|
235
|
+
const hasFields = Object.keys(formdata.values || {}).length > 0;
|
|
302
236
|
if (hasFields) {
|
|
303
237
|
hasAnyFields = true;
|
|
304
238
|
if (formdata.isValid === false) {
|
|
@@ -306,662 +240,598 @@ var WmWizard = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
306
240
|
}
|
|
307
241
|
}
|
|
308
242
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
}, [nonLinear, type]);
|
|
376
|
-
var handleStepClick = (0, _react.useCallback)(function (index) {
|
|
377
|
-
var step = visibleSteps[index];
|
|
378
|
-
if (step && step.show && !step.disabled) {
|
|
379
|
-
if (step.done || step.isDone) {
|
|
380
|
-
onStepHeaderClick({}, step);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
}, [visibleSteps, nonLinear, onStepHeaderClick, type]);
|
|
384
|
-
|
|
385
|
-
// Step management functions
|
|
386
|
-
var updateStep = (0, _react.useCallback)(function (stepName, updates) {
|
|
387
|
-
setSteps(function (prevSteps) {
|
|
388
|
-
var stepIndex = prevSteps.findIndex(function (step) {
|
|
389
|
-
return step.name === stepName;
|
|
390
|
-
});
|
|
391
|
-
if (stepIndex === -1) return prevSteps;
|
|
392
|
-
var existing = prevSteps[stepIndex];
|
|
393
|
-
var hasChanges = Object.keys(updates).some(function (key) {
|
|
394
|
-
return existing[key] !== updates[key];
|
|
395
|
-
});
|
|
396
|
-
if (!hasChanges) return prevSteps;
|
|
397
|
-
var newSteps = (0, _toConsumableArray2["default"])(prevSteps);
|
|
398
|
-
newSteps[stepIndex] = _objectSpread(_objectSpread({}, existing), updates);
|
|
399
|
-
return newSteps;
|
|
400
|
-
});
|
|
401
|
-
}, []);
|
|
402
|
-
|
|
403
|
-
// Navigation functions
|
|
404
|
-
var _next = (0, _react.useCallback)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
405
|
-
var eventName,
|
|
406
|
-
fromIndex,
|
|
407
|
-
fromStep,
|
|
408
|
-
nextStep,
|
|
409
|
-
nextIndex,
|
|
410
|
-
_fromStep$onSkip,
|
|
411
|
-
response,
|
|
412
|
-
_fromStep$onNext,
|
|
413
|
-
_response,
|
|
414
|
-
_args = arguments;
|
|
415
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
416
|
-
while (1) switch (_context.prev = _context.next) {
|
|
417
|
-
case 0:
|
|
418
|
-
eventName = _args.length > 0 && _args[0] !== undefined ? _args[0] : "next";
|
|
419
|
-
fromIndex = navIndexRef.current >= 0 ? navIndexRef.current : currentStepIndex;
|
|
420
|
-
fromStep = (0, _utils.getStepByIndex)(fromIndex, visibleSteps);
|
|
421
|
-
if (fromStep) {
|
|
422
|
-
_context.next = 5;
|
|
423
|
-
break;
|
|
424
|
-
}
|
|
425
|
-
return _context.abrupt("return");
|
|
426
|
-
case 5:
|
|
427
|
-
nextStep = (0, _utils.getNextValidStep)(fromIndex + 1, visibleSteps);
|
|
428
|
-
if (nextStep) {
|
|
429
|
-
_context.next = 8;
|
|
430
|
-
break;
|
|
431
|
-
}
|
|
432
|
-
return _context.abrupt("return");
|
|
433
|
-
case 8:
|
|
434
|
-
nextIndex = visibleSteps.findIndex(function (s) {
|
|
435
|
-
return s.name === nextStep.name;
|
|
436
|
-
});
|
|
437
|
-
if (!(eventName === "skip")) {
|
|
438
|
-
_context.next = 19;
|
|
439
|
-
break;
|
|
440
|
-
}
|
|
441
|
-
response = (_fromStep$onSkip = fromStep.onSkip) === null || _fromStep$onSkip === void 0 ? void 0 : _fromStep$onSkip.call(fromStep, fromStep, fromStep, fromIndex);
|
|
442
|
-
if (!(response !== undefined)) {
|
|
443
|
-
_context.next = 16;
|
|
444
|
-
break;
|
|
445
|
-
}
|
|
446
|
-
_context.next = 14;
|
|
447
|
-
return (0, _utils.handleNavigation)(response, function () {
|
|
448
|
-
return (0, _utils.extendNextFn)(fromStep, fromIndex, visibleSteps, setSteps);
|
|
449
|
-
});
|
|
450
|
-
case 14:
|
|
451
|
-
_context.next = 17;
|
|
452
|
-
break;
|
|
453
|
-
case 16:
|
|
454
|
-
(0, _utils.extendNextFn)(fromStep, fromIndex, visibleSteps, setSteps);
|
|
455
|
-
case 17:
|
|
456
|
-
_context.next = 30;
|
|
457
|
-
break;
|
|
458
|
-
case 19:
|
|
459
|
-
if (!(fromStep.isValid && eventName === "next")) {
|
|
460
|
-
_context.next = 29;
|
|
461
|
-
break;
|
|
243
|
+
if (!hasAnyFields) {
|
|
244
|
+
setIsStepValid(true);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (formValiditySignature === "") {
|
|
248
|
+
setIsStepValid(allFormsValid);
|
|
249
|
+
} else {
|
|
250
|
+
setIsStepValid(formValiditySignature === "1");
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
validateStep();
|
|
254
|
+
}, [
|
|
255
|
+
currentStep,
|
|
256
|
+
formValiditySignature,
|
|
257
|
+
formReady,
|
|
258
|
+
getStepForms,
|
|
259
|
+
isInsideOuterForm,
|
|
260
|
+
parentFormContext,
|
|
261
|
+
parentFormIsValid
|
|
262
|
+
]);
|
|
263
|
+
const enableNext = useMemo(() => {
|
|
264
|
+
const enablenextBool = typeof enablenext === "string" ? enablenext.toLowerCase() === "true" || enablenext === "1" : Boolean(enablenext);
|
|
265
|
+
return enablenextBool || (currentStep == null ? void 0 : currentStep.enableNext) !== false && (currentStep == null ? void 0 : currentStep.isValid) !== false && isStepValid;
|
|
266
|
+
}, [enablenext, currentStep, isStepValid]);
|
|
267
|
+
const enablePrev = useMemo(() => (currentStep == null ? void 0 : currentStep.enablePrev) !== false, [currentStep]);
|
|
268
|
+
const enableDone = useMemo(
|
|
269
|
+
() => (currentStep == null ? void 0 : currentStep.enableDone) !== false && (currentStep == null ? void 0 : currentStep.isValid) !== false && isStepValid,
|
|
270
|
+
[currentStep, isStepValid]
|
|
271
|
+
);
|
|
272
|
+
const isFirstStep = useMemo(() => currentStepIndex === 0, [currentStepIndex]);
|
|
273
|
+
const isLastStep = useMemo(
|
|
274
|
+
() => currentStepIndex === visibleSteps.length - 1,
|
|
275
|
+
[currentStepIndex, visibleSteps]
|
|
276
|
+
);
|
|
277
|
+
const computedStepClass = useMemo(
|
|
278
|
+
() => stepstyle === "justified" ? "justified" : "auto",
|
|
279
|
+
[stepstyle]
|
|
280
|
+
);
|
|
281
|
+
const onStepHeaderClick = useCallback(
|
|
282
|
+
(event, step) => {
|
|
283
|
+
if ((step.done || step.isDone || nonLinear && type === "dynamic") && step.show && !step.disabled) {
|
|
284
|
+
setSteps(
|
|
285
|
+
(prevSteps) => prevSteps.map((s) => {
|
|
286
|
+
const stepIndex = prevSteps.findIndex((ps) => ps.name === s.name);
|
|
287
|
+
const targetIndex = prevSteps.findIndex((ps) => ps.name === step.name);
|
|
288
|
+
return __spreadProps(__spreadValues({}, s), {
|
|
289
|
+
active: s.name === step.name,
|
|
290
|
+
isDone: type === "dynamic" ? stepIndex < targetIndex : stepIndex < targetIndex,
|
|
291
|
+
done: type === "dynamic" ? stepIndex < targetIndex : stepIndex < targetIndex || s.name === step.name && targetIndex > 0,
|
|
292
|
+
disabled: false,
|
|
293
|
+
// Ensure enableNext and isValid are preserved when activating a step
|
|
294
|
+
enableNext: s.name === step.name ? true : s.enableNext,
|
|
295
|
+
isValid: s.name === step.name ? true : s.isValid
|
|
296
|
+
});
|
|
297
|
+
})
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
[nonLinear, type]
|
|
302
|
+
);
|
|
303
|
+
const handleStepClick = useCallback(
|
|
304
|
+
(index) => {
|
|
305
|
+
const step = visibleSteps[index];
|
|
306
|
+
if (step && step.show && !step.disabled) {
|
|
307
|
+
if (step.done || step.isDone) {
|
|
308
|
+
onStepHeaderClick({}, step);
|
|
462
309
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
[visibleSteps, nonLinear, onStepHeaderClick, type]
|
|
313
|
+
);
|
|
314
|
+
const updateStep = useCallback((stepName, updates) => {
|
|
315
|
+
setSteps((prevSteps) => {
|
|
316
|
+
const stepIndex = prevSteps.findIndex((step) => step.name === stepName);
|
|
317
|
+
if (stepIndex === -1) return prevSteps;
|
|
318
|
+
const existing = prevSteps[stepIndex];
|
|
319
|
+
const hasChanges = Object.keys(updates).some(
|
|
320
|
+
(key) => existing[key] !== updates[key]
|
|
321
|
+
);
|
|
322
|
+
if (!hasChanges) return prevSteps;
|
|
323
|
+
const newSteps = [...prevSteps];
|
|
324
|
+
newSteps[stepIndex] = __spreadValues(__spreadValues({}, existing), updates);
|
|
325
|
+
return newSteps;
|
|
326
|
+
});
|
|
327
|
+
}, []);
|
|
328
|
+
const next = useCallback(
|
|
329
|
+
async (eventName = "next") => {
|
|
330
|
+
var _a, _b;
|
|
331
|
+
const fromIndex = navIndexRef.current >= 0 ? navIndexRef.current : currentStepIndex;
|
|
332
|
+
const fromStep = getStepByIndex(fromIndex, visibleSteps);
|
|
333
|
+
if (!fromStep) return;
|
|
334
|
+
const nextStep = getNextValidStep(fromIndex + 1, visibleSteps);
|
|
335
|
+
if (!nextStep) return;
|
|
336
|
+
const nextIndex = visibleSteps.findIndex((s) => s.name === nextStep.name);
|
|
337
|
+
if (eventName === "skip") {
|
|
338
|
+
const response = (_a = fromStep.onSkip) == null ? void 0 : _a.call(fromStep, fromStep, fromStep, fromIndex);
|
|
339
|
+
if (response !== void 0) {
|
|
340
|
+
await handleNavigation(
|
|
341
|
+
response,
|
|
342
|
+
() => extendNextFn(fromStep, fromIndex, visibleSteps, setSteps)
|
|
343
|
+
);
|
|
344
|
+
} else {
|
|
345
|
+
extendNextFn(fromStep, fromIndex, visibleSteps, setSteps);
|
|
467
346
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
case 26:
|
|
476
|
-
(0, _utils.extendNextFn)(fromStep, fromIndex, visibleSteps, setSteps);
|
|
477
|
-
case 27:
|
|
478
|
-
_context.next = 30;
|
|
479
|
-
break;
|
|
480
|
-
case 29:
|
|
481
|
-
if (enablenext && !fromStep.isValid) {
|
|
482
|
-
console.warn("Cannot proceed: current step is invalid");
|
|
347
|
+
} else if (fromStep.isValid && eventName === "next") {
|
|
348
|
+
const response = (_b = fromStep.onNext) == null ? void 0 : _b.call(fromStep, fromStep, fromStep, fromIndex);
|
|
349
|
+
if (response !== void 0) {
|
|
350
|
+
await handleNavigation(
|
|
351
|
+
response,
|
|
352
|
+
() => extendNextFn(fromStep, fromIndex, visibleSteps, setSteps)
|
|
353
|
+
);
|
|
483
354
|
} else {
|
|
484
|
-
|
|
355
|
+
extendNextFn(fromStep, fromIndex, visibleSteps, setSteps);
|
|
485
356
|
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
357
|
+
} else if (enablenext && !fromStep.isValid) {
|
|
358
|
+
console.warn("Cannot proceed: current step is invalid");
|
|
359
|
+
} else {
|
|
360
|
+
extendNextFn(fromStep, fromIndex, visibleSteps, setSteps);
|
|
361
|
+
}
|
|
362
|
+
navIndexRef.current = nextIndex;
|
|
363
|
+
setFormReady(false);
|
|
364
|
+
},
|
|
365
|
+
[currentStepIndex, visibleSteps, enablenext]
|
|
366
|
+
);
|
|
367
|
+
const prev = useCallback(async () => {
|
|
368
|
+
var _a;
|
|
369
|
+
const fromIndex = navIndexRef.current >= 0 ? navIndexRef.current : currentStepIndex;
|
|
370
|
+
const fromStep = getStepByIndex(fromIndex, visibleSteps);
|
|
371
|
+
if (!fromStep) return;
|
|
372
|
+
const targetStep = getPrevValidStep(fromIndex - 1, visibleSteps);
|
|
373
|
+
if (!targetStep) return;
|
|
374
|
+
const prevIndex = visibleSteps.findIndex((s) => s.name === targetStep.name);
|
|
375
|
+
const response = (_a = fromStep.onPrev) == null ? void 0 : _a.call(fromStep, fromStep, fromStep, fromIndex);
|
|
376
|
+
if (response !== void 0) {
|
|
377
|
+
await handleNavigation(
|
|
378
|
+
response,
|
|
379
|
+
() => extendPrevFn(fromStep, fromIndex, visibleSteps, setSteps)
|
|
380
|
+
);
|
|
381
|
+
} else {
|
|
382
|
+
extendPrevFn(fromStep, fromIndex, visibleSteps, setSteps);
|
|
493
383
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
case 4:
|
|
510
|
-
targetStep = (0, _utils.getPrevValidStep)(fromIndex - 1, visibleSteps);
|
|
511
|
-
if (targetStep) {
|
|
512
|
-
_context2.next = 7;
|
|
513
|
-
break;
|
|
514
|
-
}
|
|
515
|
-
return _context2.abrupt("return");
|
|
516
|
-
case 7:
|
|
517
|
-
prevIndex = visibleSteps.findIndex(function (s) {
|
|
518
|
-
return s.name === targetStep.name;
|
|
519
|
-
});
|
|
520
|
-
response = (_fromStep$onPrev = fromStep.onPrev) === null || _fromStep$onPrev === void 0 ? void 0 : _fromStep$onPrev.call(fromStep, fromStep, fromStep, fromIndex);
|
|
521
|
-
if (!(response !== undefined)) {
|
|
522
|
-
_context2.next = 14;
|
|
523
|
-
break;
|
|
384
|
+
navIndexRef.current = prevIndex;
|
|
385
|
+
setFormReady(false);
|
|
386
|
+
}, [currentStepIndex, visibleSteps]);
|
|
387
|
+
const registerStep = useCallback((stepData) => {
|
|
388
|
+
setSteps((prevSteps) => {
|
|
389
|
+
const existingIndex = prevSteps.findIndex((step) => step.name === stepData.name);
|
|
390
|
+
if (existingIndex >= 0) {
|
|
391
|
+
const existing = prevSteps[existingIndex];
|
|
392
|
+
const hasChanges = Object.keys(stepData).some(
|
|
393
|
+
(key) => existing[key] !== stepData[key]
|
|
394
|
+
);
|
|
395
|
+
if (hasChanges) {
|
|
396
|
+
const newSteps = [...prevSteps];
|
|
397
|
+
newSteps[existingIndex] = __spreadValues(__spreadValues({}, existing), stepData);
|
|
398
|
+
return newSteps;
|
|
524
399
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
});
|
|
529
|
-
case 12:
|
|
530
|
-
_context2.next = 15;
|
|
531
|
-
break;
|
|
532
|
-
case 14:
|
|
533
|
-
(0, _utils.extendPrevFn)(fromStep, fromIndex, visibleSteps, setSteps);
|
|
534
|
-
case 15:
|
|
535
|
-
navIndexRef.current = prevIndex;
|
|
536
|
-
setFormReady(false);
|
|
537
|
-
case 17:
|
|
538
|
-
case "end":
|
|
539
|
-
return _context2.stop();
|
|
540
|
-
}
|
|
541
|
-
}, _callee2);
|
|
542
|
-
})), [currentStepIndex, visibleSteps]);
|
|
543
|
-
var registerStep = (0, _react.useCallback)(function (stepData) {
|
|
544
|
-
setSteps(function (prevSteps) {
|
|
545
|
-
var existingIndex = prevSteps.findIndex(function (step) {
|
|
546
|
-
return step.name === stepData.name;
|
|
400
|
+
return prevSteps;
|
|
401
|
+
}
|
|
402
|
+
return [...prevSteps, stepData];
|
|
547
403
|
});
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
404
|
+
}, []);
|
|
405
|
+
const skip = useCallback(() => {
|
|
406
|
+
next("skip");
|
|
407
|
+
}, [next]);
|
|
408
|
+
const done = useCallback(() => {
|
|
409
|
+
if (currentStep) {
|
|
410
|
+
updateStep(currentStep.name, { isDone: true, done: true });
|
|
411
|
+
if (onDone) {
|
|
412
|
+
onDone(currentStep, steps);
|
|
557
413
|
}
|
|
558
|
-
return prevSteps;
|
|
559
414
|
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
_next("skip");
|
|
565
|
-
}, [_next]);
|
|
566
|
-
var _done = (0, _react.useCallback)(function () {
|
|
567
|
-
if (currentStep) {
|
|
568
|
-
updateStep(currentStep.name, {
|
|
569
|
-
isDone: true,
|
|
570
|
-
done: true
|
|
571
|
-
});
|
|
572
|
-
if (onDone) {
|
|
573
|
-
onDone(currentStep, steps);
|
|
415
|
+
}, [currentStep, updateStep, onDone, steps]);
|
|
416
|
+
const cancel = useCallback(() => {
|
|
417
|
+
if (onCancel) {
|
|
418
|
+
onCancel(currentStep, steps);
|
|
574
419
|
}
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
420
|
+
}, [onCancel, steps]);
|
|
421
|
+
const gotoStep = useCallback(
|
|
422
|
+
(step) => {
|
|
423
|
+
let gotoStepIndex;
|
|
424
|
+
let targetStep = null;
|
|
425
|
+
if (typeof step === "string") {
|
|
426
|
+
gotoStepIndex = steps.map((s) => s.name).indexOf(step);
|
|
427
|
+
if (gotoStepIndex === -1) {
|
|
428
|
+
console.error(`Could not find step '${step}'`);
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
targetStep = steps[gotoStepIndex];
|
|
432
|
+
} else if (typeof step === "number" && step >= 0) {
|
|
433
|
+
gotoStepIndex = step;
|
|
434
|
+
targetStep = getStepByIndex(step, visibleSteps);
|
|
435
|
+
} else {
|
|
436
|
+
console.error("Invalid step name or index provided");
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
if (targetStep == null ? void 0 : targetStep.show) {
|
|
440
|
+
const visIndex = visibleSteps.findIndex((s) => s.name === (targetStep == null ? void 0 : targetStep.name));
|
|
441
|
+
if (visIndex >= 0) navIndexRef.current = visIndex;
|
|
442
|
+
onStepHeaderClick({}, targetStep);
|
|
443
|
+
} else {
|
|
444
|
+
console.error("The gotoStep function cannot navigate to hidden steps");
|
|
445
|
+
}
|
|
446
|
+
},
|
|
447
|
+
[steps, visibleSteps, onStepHeaderClick]
|
|
448
|
+
);
|
|
449
|
+
const setDefaultStep = useCallback(
|
|
450
|
+
(step) => {
|
|
451
|
+
if (step && step.show) {
|
|
452
|
+
setSteps(
|
|
453
|
+
(prevSteps) => prevSteps.map((s, index) => {
|
|
454
|
+
const stepIndex = prevSteps.findIndex((ps) => ps.name === s.name);
|
|
455
|
+
const defaultIndex = prevSteps.findIndex((ps) => ps.name === step.name);
|
|
456
|
+
return __spreadProps(__spreadValues({}, s), {
|
|
457
|
+
active: s.name === step.name,
|
|
458
|
+
isDone: false,
|
|
459
|
+
done: stepIndex < defaultIndex,
|
|
460
|
+
isInitialized: s.name === step.name ? true : s.isInitialized,
|
|
461
|
+
// Ensure enableNext and isValid are preserved for the active step
|
|
462
|
+
enableNext: s.name === step.name ? true : s.enableNext,
|
|
463
|
+
isValid: s.name === step.name ? true : s.isValid
|
|
464
|
+
});
|
|
465
|
+
})
|
|
466
|
+
);
|
|
467
|
+
setTimeout(() => {
|
|
468
|
+
if (step.onLoad) {
|
|
469
|
+
const stepIndex = visibleSteps.findIndex((s) => s.name === step.name);
|
|
470
|
+
step.onLoad(step, stepIndex);
|
|
471
|
+
}
|
|
472
|
+
}, 100);
|
|
473
|
+
} else {
|
|
474
|
+
const nextValidStep = getNextValidStep(0, visibleSteps);
|
|
475
|
+
if (nextValidStep) {
|
|
476
|
+
setDefaultStep(nextValidStep);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
},
|
|
480
|
+
[visibleSteps]
|
|
481
|
+
);
|
|
482
|
+
const showSignature = steps.map(
|
|
483
|
+
(s) => {
|
|
484
|
+
var _a, _b, _c, _d;
|
|
485
|
+
return ((_b = (_a = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _a[s.name]) == null ? void 0 : _b.show) === false || ((_d = (_c = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _c[s.name]) == null ? void 0 : _d.show) === "false" ? "0" : "1";
|
|
593
486
|
}
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
487
|
+
).join("|");
|
|
488
|
+
useEffect(() => {
|
|
489
|
+
if (!(listener == null ? void 0 : listener.Widgets)) return;
|
|
490
|
+
steps.forEach((step, index) => {
|
|
491
|
+
var _a;
|
|
492
|
+
const widgetShow = (_a = listener.Widgets[step.name]) == null ? void 0 : _a.show;
|
|
493
|
+
if ((widgetShow === false || widgetShow === "false") && step.show !== false) {
|
|
494
|
+
updateStep(step.name, { show: false, enableskip: false });
|
|
495
|
+
const prevStep = steps[index - 1];
|
|
496
|
+
if (prevStep && step.active) {
|
|
497
|
+
updateStep(prevStep.name, { active: true });
|
|
498
|
+
navIndexRef.current = index - 1;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
606
501
|
});
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
502
|
+
}, [showSignature]);
|
|
503
|
+
const updateListener = React.useCallback(() => {
|
|
504
|
+
if (listener && typeof listener.onChange === "function") {
|
|
505
|
+
listener.onChange(name, {
|
|
506
|
+
hasNextStep: () => hasNextStep,
|
|
507
|
+
hasPreviousStep: () => hasPrevStep,
|
|
508
|
+
hasNoNextStep: () => showDoneBtn,
|
|
509
|
+
next: () => next("next"),
|
|
510
|
+
previous: () => prev(),
|
|
511
|
+
done: () => done(),
|
|
512
|
+
cancel: () => cancel(),
|
|
513
|
+
skip: () => skip(),
|
|
514
|
+
disableNext: () => !enableNext,
|
|
515
|
+
disablePrevious: () => !enablePrev,
|
|
516
|
+
disableDone: () => !enableDone,
|
|
517
|
+
prev,
|
|
518
|
+
cancelable,
|
|
519
|
+
nextbtnlabel,
|
|
520
|
+
previousbtnlabel,
|
|
521
|
+
donebtnlabel,
|
|
522
|
+
cancelbtnlabel,
|
|
523
|
+
actionsalignment,
|
|
524
|
+
skippable: currentStep == null ? void 0 : currentStep.enableskip,
|
|
525
|
+
getCurrentStepIndex: () => currentStepIndex,
|
|
526
|
+
gotoStep: (step) => gotoStep(step),
|
|
527
|
+
isFirstStep,
|
|
528
|
+
isLastStep,
|
|
529
|
+
currentStepIndex,
|
|
530
|
+
currentStep
|
|
634
531
|
});
|
|
635
|
-
});
|
|
636
|
-
setTimeout(function () {
|
|
637
|
-
if (step.onLoad) {
|
|
638
|
-
var stepIndex = visibleSteps.findIndex(function (s) {
|
|
639
|
-
return s.name === step.name;
|
|
640
|
-
});
|
|
641
|
-
step.onLoad(step, stepIndex);
|
|
642
|
-
}
|
|
643
|
-
}, 100);
|
|
644
|
-
} else {
|
|
645
|
-
var nextValidStep = (0, _utils.getNextValidStep)(0, visibleSteps);
|
|
646
|
-
if (nextValidStep) {
|
|
647
|
-
setDefaultStep(nextValidStep);
|
|
648
532
|
}
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
533
|
+
}, [
|
|
534
|
+
hasNextStep,
|
|
535
|
+
hasPrevStep,
|
|
536
|
+
showDoneBtn,
|
|
537
|
+
enableNext,
|
|
538
|
+
enablePrev,
|
|
539
|
+
enableDone,
|
|
540
|
+
cancelable,
|
|
541
|
+
currentStep == null ? void 0 : currentStep.enableskip,
|
|
542
|
+
nextbtnlabel,
|
|
543
|
+
previousbtnlabel,
|
|
544
|
+
donebtnlabel,
|
|
545
|
+
cancelbtnlabel,
|
|
546
|
+
actionsalignment,
|
|
547
|
+
currentStepIndex,
|
|
548
|
+
isFirstStep,
|
|
549
|
+
isLastStep,
|
|
550
|
+
visibleSteps
|
|
551
|
+
]);
|
|
552
|
+
useEffect(() => {
|
|
553
|
+
updateListener();
|
|
554
|
+
}, [updateListener]);
|
|
555
|
+
useEffect(() => {
|
|
556
|
+
if (steps.length > 0 && !isInitialized && visibleSteps.length > 0 && type !== "dynamic") {
|
|
557
|
+
let defaultStepRef = null;
|
|
558
|
+
if (defaultstep !== "none") {
|
|
559
|
+
defaultStepRef = getStepByName(defaultstep, steps);
|
|
560
|
+
} else if (defaultstepindex >= 0 && defaultstepindex < visibleSteps.length) {
|
|
561
|
+
defaultStepRef = getStepByIndex(defaultstepindex, visibleSteps);
|
|
562
|
+
} else {
|
|
563
|
+
defaultStepRef = getNextValidStep(0, visibleSteps);
|
|
564
|
+
}
|
|
565
|
+
if (defaultStepRef) {
|
|
566
|
+
setDefaultStep(defaultStepRef);
|
|
567
|
+
setIsInitialized(true);
|
|
671
568
|
}
|
|
672
569
|
}
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
},
|
|
687
|
-
next: function next() {
|
|
688
|
-
return _next("next");
|
|
689
|
-
},
|
|
690
|
-
previous: function previous() {
|
|
691
|
-
return prev();
|
|
692
|
-
},
|
|
693
|
-
done: function done() {
|
|
694
|
-
return _done();
|
|
695
|
-
},
|
|
696
|
-
cancel: function cancel() {
|
|
697
|
-
return _cancel();
|
|
698
|
-
},
|
|
699
|
-
skip: function skip() {
|
|
700
|
-
return _skip();
|
|
701
|
-
},
|
|
702
|
-
disableNext: function disableNext() {
|
|
703
|
-
return !enableNext;
|
|
704
|
-
},
|
|
705
|
-
disablePrevious: function disablePrevious() {
|
|
706
|
-
return !enablePrev;
|
|
707
|
-
},
|
|
708
|
-
disableDone: function disableDone() {
|
|
709
|
-
return !enableDone;
|
|
710
|
-
},
|
|
711
|
-
prev: prev,
|
|
712
|
-
cancelable: cancelable,
|
|
713
|
-
nextbtnlabel: nextbtnlabel,
|
|
714
|
-
previousbtnlabel: previousbtnlabel,
|
|
715
|
-
donebtnlabel: donebtnlabel,
|
|
716
|
-
cancelbtnlabel: cancelbtnlabel,
|
|
717
|
-
actionsalignment: actionsalignment,
|
|
718
|
-
skippable: currentStep === null || currentStep === void 0 ? void 0 : currentStep.enableskip,
|
|
719
|
-
getCurrentStepIndex: function getCurrentStepIndex() {
|
|
720
|
-
return currentStepIndex;
|
|
721
|
-
},
|
|
722
|
-
gotoStep: function gotoStep(step) {
|
|
723
|
-
return _gotoStep(step);
|
|
724
|
-
},
|
|
725
|
-
isFirstStep: isFirstStep,
|
|
726
|
-
isLastStep: isLastStep,
|
|
727
|
-
currentStepIndex: currentStepIndex,
|
|
728
|
-
currentStep: currentStep
|
|
729
|
-
});
|
|
730
|
-
}
|
|
731
|
-
}, [_hasNextStep, hasPrevStep, showDoneBtn, enableNext, enablePrev, enableDone, cancelable, currentStep === null || currentStep === void 0 ? void 0 : currentStep.enableskip, nextbtnlabel, previousbtnlabel, donebtnlabel, cancelbtnlabel, actionsalignment, currentStepIndex, isFirstStep, isLastStep, visibleSteps]);
|
|
732
|
-
(0, _react.useEffect)(function () {
|
|
733
|
-
updateListener();
|
|
734
|
-
}, [updateListener]);
|
|
735
|
-
|
|
736
|
-
// Initialize default step for STATIC wizards only
|
|
737
|
-
(0, _react.useEffect)(function () {
|
|
738
|
-
if (steps.length > 0 && !isInitialized && visibleSteps.length > 0 && type !== "dynamic") {
|
|
739
|
-
var defaultStepRef = null;
|
|
740
|
-
if (defaultstep !== "none") {
|
|
741
|
-
defaultStepRef = (0, _utils.getStepByName)(defaultstep, steps);
|
|
742
|
-
} else if (defaultstepindex >= 0 && defaultstepindex < visibleSteps.length) {
|
|
743
|
-
// CHANGED: Removed type === "dynamic" check and added bounds checking
|
|
744
|
-
// REASON: This effect only runs for static wizards, and bounds checking prevents runtime errors
|
|
745
|
-
defaultStepRef = (0, _utils.getStepByIndex)(defaultstepindex, visibleSteps);
|
|
746
|
-
} else {
|
|
747
|
-
defaultStepRef = (0, _utils.getNextValidStep)(0, visibleSteps);
|
|
748
|
-
}
|
|
749
|
-
if (defaultStepRef) {
|
|
750
|
-
setDefaultStep(defaultStepRef);
|
|
751
|
-
setIsInitialized(true);
|
|
570
|
+
}, [
|
|
571
|
+
steps.length,
|
|
572
|
+
visibleSteps.length,
|
|
573
|
+
defaultstep,
|
|
574
|
+
defaultstepindex,
|
|
575
|
+
type,
|
|
576
|
+
isInitialized,
|
|
577
|
+
setDefaultStep,
|
|
578
|
+
visibleSteps
|
|
579
|
+
]);
|
|
580
|
+
useEffect(() => {
|
|
581
|
+
if (currentStep == null ? void 0 : currentStep.onLoad) {
|
|
582
|
+
currentStep == null ? void 0 : currentStep.onLoad(currentStep, currentStepIndex);
|
|
752
583
|
}
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
// Handle dataset changes for dynamic wizard
|
|
762
|
-
(0, _react.useEffect)(function () {
|
|
763
|
-
if (type === "dynamic" && dataset.length > 0 && steps.length === 0) {
|
|
764
|
-
var dynamicSteps = createDynamicSteps(dataset);
|
|
765
|
-
if (defaultstepindex >= 0 && defaultstepindex < dynamicSteps.length) {
|
|
766
|
-
var defaultStep = dynamicSteps[defaultstepindex];
|
|
767
|
-
if (defaultStep && defaultStep.show) {
|
|
768
|
-
var stepsWithDefault = dynamicSteps.map(function (step) {
|
|
769
|
-
return _objectSpread(_objectSpread({}, step), {}, {
|
|
584
|
+
}, [currentStep == null ? void 0 : currentStep.onLoad]);
|
|
585
|
+
useEffect(() => {
|
|
586
|
+
if (type === "dynamic" && dataset.length > 0 && steps.length === 0) {
|
|
587
|
+
const dynamicSteps = createDynamicSteps(dataset);
|
|
588
|
+
if (defaultstepindex >= 0 && defaultstepindex < dynamicSteps.length) {
|
|
589
|
+
const defaultStep = dynamicSteps[defaultstepindex];
|
|
590
|
+
if (defaultStep && defaultStep.show) {
|
|
591
|
+
const stepsWithDefault = dynamicSteps.map((step) => __spreadProps(__spreadValues({}, step), {
|
|
770
592
|
active: step.name === defaultStep.name,
|
|
771
593
|
isDone: false,
|
|
772
|
-
done: step.dynamicStepIndex !==
|
|
773
|
-
});
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
594
|
+
done: step.dynamicStepIndex !== void 0 ? step.dynamicStepIndex < defaultstepindex : false
|
|
595
|
+
}));
|
|
596
|
+
setSteps(stepsWithDefault);
|
|
597
|
+
setIsInitialized(true);
|
|
598
|
+
} else {
|
|
599
|
+
setSteps(dynamicSteps);
|
|
600
|
+
}
|
|
777
601
|
} else {
|
|
778
602
|
setSteps(dynamicSteps);
|
|
779
603
|
}
|
|
780
|
-
} else {
|
|
781
|
-
setSteps(dynamicSteps);
|
|
782
|
-
}
|
|
783
|
-
return;
|
|
784
|
-
}
|
|
785
|
-
if (type === "dynamic" && dataset.length > 0) {
|
|
786
|
-
// Append new steps if dataset grew
|
|
787
|
-
if (steps.length > 0 && dataset.length > steps.length) {
|
|
788
|
-
var newItems = dataset.slice(steps.length);
|
|
789
|
-
var newSteps = createDynamicSteps(newItems, steps.length);
|
|
790
|
-
if (newSteps.length) {
|
|
791
|
-
setSteps(function (prev) {
|
|
792
|
-
return (0, _utils.appendDatasetSteps)(prev, newSteps);
|
|
793
|
-
});
|
|
794
|
-
}
|
|
795
604
|
return;
|
|
796
605
|
}
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
606
|
+
if (type === "dynamic" && dataset.length > 0) {
|
|
607
|
+
if (steps.length > 0 && dataset.length > steps.length) {
|
|
608
|
+
const newItems = dataset.slice(steps.length);
|
|
609
|
+
const newSteps = createDynamicSteps(newItems, steps.length);
|
|
610
|
+
if (newSteps.length) {
|
|
611
|
+
setSteps((prev2) => appendDatasetSteps(prev2, newSteps));
|
|
612
|
+
}
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
if (steps.length > 0 && dataset.length < steps.length) {
|
|
616
|
+
setSteps((prev2) => trimStepsToLength(prev2, dataset.length));
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
803
619
|
}
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
620
|
+
}, [type, dataset, createDynamicSteps, defaultstepindex, dataset.length]);
|
|
621
|
+
const contextValue = useMemo(
|
|
622
|
+
() => ({
|
|
623
|
+
steps,
|
|
624
|
+
currentStep,
|
|
625
|
+
currentStepIndex,
|
|
626
|
+
hasNextStep,
|
|
627
|
+
hasPrevStep,
|
|
628
|
+
showDoneBtn: showDoneBtn || false,
|
|
629
|
+
enableNext: enableNext || false,
|
|
630
|
+
enablePrev: enablePrev || false,
|
|
631
|
+
enableDone: enableDone || false,
|
|
632
|
+
isFirstStep,
|
|
633
|
+
isLastStep,
|
|
634
|
+
registerStep,
|
|
635
|
+
updateStep,
|
|
636
|
+
next,
|
|
637
|
+
prev,
|
|
638
|
+
skip,
|
|
639
|
+
done,
|
|
640
|
+
cancel,
|
|
641
|
+
gotoStep,
|
|
642
|
+
onStepHeaderClick,
|
|
643
|
+
addStep: () => []
|
|
644
|
+
}),
|
|
645
|
+
[
|
|
646
|
+
steps,
|
|
647
|
+
currentStep,
|
|
648
|
+
currentStepIndex,
|
|
649
|
+
hasNextStep,
|
|
650
|
+
hasPrevStep,
|
|
651
|
+
showDoneBtn,
|
|
652
|
+
enableNext,
|
|
653
|
+
enablePrev,
|
|
654
|
+
enableDone,
|
|
655
|
+
isFirstStep,
|
|
656
|
+
isLastStep,
|
|
657
|
+
registerStep,
|
|
658
|
+
updateStep,
|
|
659
|
+
next,
|
|
660
|
+
prev,
|
|
661
|
+
skip,
|
|
662
|
+
done,
|
|
663
|
+
cancel,
|
|
664
|
+
gotoStep,
|
|
665
|
+
onStepHeaderClick
|
|
666
|
+
]
|
|
667
|
+
);
|
|
668
|
+
const wizardSteps = [];
|
|
669
|
+
React.Children.forEach(children, (child) => {
|
|
670
|
+
if (isValidElement(child) && child.type === WmWizardstep) {
|
|
671
|
+
wizardSteps.push(child);
|
|
832
672
|
}
|
|
833
|
-
};
|
|
834
|
-
}, [steps, currentStep, currentStepIndex, _hasNextStep, hasPrevStep, showDoneBtn, enableNext, enablePrev, enableDone, isFirstStep, isLastStep, registerStep, updateStep, _next, prev, _skip, _done, _cancel, _gotoStep, onStepHeaderClick]);
|
|
835
|
-
|
|
836
|
-
// Extract wizard steps from children
|
|
837
|
-
var wizardSteps = [];
|
|
838
|
-
_react["default"].Children.forEach(children, function (child) {
|
|
839
|
-
if (/*#__PURE__*/(0, _react.isValidElement)(child) && child.type === _wizardStep.WmWizardstep) {
|
|
840
|
-
wizardSteps.push(child);
|
|
841
|
-
}
|
|
842
|
-
});
|
|
843
|
-
|
|
844
|
-
// If no data in dynamic mode, show no data message
|
|
845
|
-
if (type === "dynamic" && (!dataset || dataset.length === 0)) {
|
|
846
|
-
return __jsx("div", null, nodatamessage);
|
|
847
|
-
}
|
|
848
|
-
var classValue = className && className.trim() !== "" ? className : "classic";
|
|
849
|
-
return __jsx(_WizardContext["default"].Provider, {
|
|
850
|
-
value: contextValue
|
|
851
|
-
}, __jsx(_material.Box, {
|
|
852
|
-
className: (0, _clsx["default"])(DEFAULT_CLS, classValue, computedStepClass, {
|
|
853
|
-
classic: classValue === null || classValue === void 0 ? void 0 : classValue.includes("classic"),
|
|
854
|
-
number: classValue === null || classValue === void 0 ? void 0 : classValue.includes("number"),
|
|
855
|
-
dottedstepper: classValue === null || classValue === void 0 ? void 0 : classValue.includes("dottedstepper"),
|
|
856
|
-
"text-inline": classValue === null || classValue === void 0 ? void 0 : classValue.includes("text-inline"),
|
|
857
|
-
iconstepper: classValue === null || classValue === void 0 ? void 0 : classValue.includes("iconstepper")
|
|
858
|
-
}),
|
|
859
|
-
style: _objectSpread(_objectSpread({}, styles), {}, {
|
|
860
|
-
width: width,
|
|
861
|
-
height: height
|
|
862
|
-
}),
|
|
863
|
-
hidden: props.hidden,
|
|
864
|
-
name: name
|
|
865
|
-
}, __jsx(_material.Box, {
|
|
866
|
-
className: "app-wizard-heading"
|
|
867
|
-
}, __jsx(_material.Stepper, {
|
|
868
|
-
activeStep: currentStepIndex,
|
|
869
|
-
orientation: orientation,
|
|
870
|
-
alternativeLabel: alternativeLabel,
|
|
871
|
-
nonLinear: nonLinear,
|
|
872
|
-
connector: connector,
|
|
873
|
-
className: (0, _clsx["default"])("app-wizard-steps", computedStepClass, stepstyle === "justified" ? "nav-justified" : "")
|
|
874
|
-
}, steps.map(function (step, index) {
|
|
875
|
-
// Calculate the visible index by counting only visible steps before this one
|
|
876
|
-
var visibleIndex = steps.slice(0, index).filter(function (s) {
|
|
877
|
-
return s.show !== false && s.show !== "false";
|
|
878
|
-
}).length;
|
|
879
|
-
var isCurrentStep = currentStepIndex === visibleIndex && step.show !== false && step.show !== "false";
|
|
880
|
-
return __jsx(_WizardStep.WizardStep, {
|
|
881
|
-
key: step.name,
|
|
882
|
-
step: step,
|
|
883
|
-
index: index,
|
|
884
|
-
className: classValue,
|
|
885
|
-
nonLinear: nonLinear,
|
|
886
|
-
orientation: orientation,
|
|
887
|
-
onStepClick: handleStepClick,
|
|
888
|
-
current: isCurrentStep
|
|
889
673
|
});
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
674
|
+
if (type === "dynamic" && (!dataset || dataset.length === 0)) {
|
|
675
|
+
return /* @__PURE__ */ jsx("div", { children: nodatamessage });
|
|
676
|
+
}
|
|
677
|
+
const classValue = className && className.trim() !== "" ? className : "classic";
|
|
678
|
+
return /* @__PURE__ */ jsx(WizardContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs(
|
|
679
|
+
Box,
|
|
680
|
+
__spreadProps(__spreadValues({
|
|
681
|
+
className: clsx(DEFAULT_CLS, classValue, computedStepClass, {
|
|
682
|
+
classic: classValue == null ? void 0 : classValue.includes("classic"),
|
|
683
|
+
number: classValue == null ? void 0 : classValue.includes("number"),
|
|
684
|
+
dottedstepper: classValue == null ? void 0 : classValue.includes("dottedstepper"),
|
|
685
|
+
"text-inline": classValue == null ? void 0 : classValue.includes("text-inline"),
|
|
686
|
+
iconstepper: classValue == null ? void 0 : classValue.includes("iconstepper")
|
|
687
|
+
}),
|
|
688
|
+
style: __spreadProps(__spreadValues({}, styles), { width, height }),
|
|
689
|
+
hidden: props.hidden
|
|
690
|
+
}, { name }), {
|
|
691
|
+
children: [
|
|
692
|
+
/* @__PURE__ */ jsx(Box, { className: "app-wizard-heading", children: /* @__PURE__ */ jsx(
|
|
693
|
+
Stepper,
|
|
694
|
+
{
|
|
695
|
+
activeStep: currentStepIndex,
|
|
696
|
+
orientation,
|
|
697
|
+
alternativeLabel,
|
|
698
|
+
nonLinear,
|
|
699
|
+
connector,
|
|
700
|
+
className: clsx(
|
|
701
|
+
"app-wizard-steps",
|
|
702
|
+
computedStepClass,
|
|
703
|
+
stepstyle === "justified" ? "nav-justified" : ""
|
|
704
|
+
),
|
|
705
|
+
children: steps.map((step, index) => {
|
|
706
|
+
const visibleIndex = steps.slice(0, index).filter((s) => s.show !== false && s.show !== "false").length;
|
|
707
|
+
const isCurrentStep = currentStepIndex === visibleIndex && step.show !== false && step.show !== "false";
|
|
708
|
+
return /* @__PURE__ */ jsx(
|
|
709
|
+
WizardStep,
|
|
710
|
+
{
|
|
711
|
+
step,
|
|
712
|
+
index,
|
|
713
|
+
className: classValue,
|
|
714
|
+
nonLinear,
|
|
715
|
+
orientation,
|
|
716
|
+
onStepClick: handleStepClick,
|
|
717
|
+
current: isCurrentStep
|
|
718
|
+
},
|
|
719
|
+
step.name
|
|
720
|
+
);
|
|
721
|
+
})
|
|
911
722
|
}
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
723
|
+
) }),
|
|
724
|
+
(orientation === "horizontal" || type === "dynamic") && /* @__PURE__ */ jsxs(Box, { className: BODY_CLASS, children: [
|
|
725
|
+
wizardMessage.caption && /* @__PURE__ */ jsx(Box, { component: "p", children: /* @__PURE__ */ jsx(
|
|
726
|
+
Typography,
|
|
727
|
+
{
|
|
728
|
+
variant: "body2",
|
|
729
|
+
color: wizardMessage.type === "error" ? "error" : "textSecondary",
|
|
730
|
+
children: wizardMessage.caption
|
|
731
|
+
}
|
|
732
|
+
) }),
|
|
733
|
+
steps.map((step, index) => /* @__PURE__ */ jsx(
|
|
734
|
+
"div",
|
|
735
|
+
{
|
|
736
|
+
ref: (el) => {
|
|
737
|
+
if (el) {
|
|
738
|
+
stepContainerRefs.current[step.name] = el;
|
|
739
|
+
const formElements = el.querySelectorAll("form");
|
|
740
|
+
if (formElements.length > 0) {
|
|
741
|
+
formRefs.current[step.name] = formElements.length === 1 ? formElements[0] : Array.from(formElements);
|
|
742
|
+
if (formElements[0].classList.contains("app-form")) {
|
|
743
|
+
setFormReady(true);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
},
|
|
748
|
+
className: clsx("app-wizard-step-container", {
|
|
749
|
+
active: step.active
|
|
750
|
+
}),
|
|
751
|
+
hidden: !step.active,
|
|
752
|
+
name: step.name,
|
|
753
|
+
children: isInsideOuterForm ? (
|
|
754
|
+
// Inside outer form - use div, fields/forms pass through to outer form context
|
|
755
|
+
/* @__PURE__ */ jsx(
|
|
756
|
+
"div",
|
|
757
|
+
{
|
|
758
|
+
className: clsx("app-wizard-step-content", {
|
|
759
|
+
active: step.active
|
|
760
|
+
}),
|
|
761
|
+
children: (currentStep == null ? void 0 : currentStep.name) && step.active && currentStep.render ? currentStep.render(step, index) : step.children
|
|
762
|
+
}
|
|
763
|
+
)
|
|
764
|
+
) : (
|
|
765
|
+
// @ts-ignore Standalone wizard without inner form - wizard provides form context
|
|
766
|
+
/* @__PURE__ */ jsx(
|
|
767
|
+
WmForm,
|
|
768
|
+
{
|
|
769
|
+
standalone,
|
|
770
|
+
show: step.active,
|
|
771
|
+
name: step.name + `_form`,
|
|
772
|
+
className: clsx("app-wizard-step-content", {
|
|
773
|
+
active: step.active
|
|
774
|
+
}),
|
|
775
|
+
listener,
|
|
776
|
+
isInsideWizard: true,
|
|
777
|
+
children: (currentStep == null ? void 0 : currentStep.name) && step.active && currentStep.render ? currentStep.render(step, index) : step.children
|
|
778
|
+
}
|
|
779
|
+
)
|
|
780
|
+
)
|
|
781
|
+
},
|
|
782
|
+
step.name
|
|
783
|
+
))
|
|
784
|
+
] }),
|
|
785
|
+
children,
|
|
786
|
+
type === "static" && wizardSteps.map(
|
|
787
|
+
(step, index) => {
|
|
788
|
+
var _a;
|
|
789
|
+
return cloneElement(step, {
|
|
790
|
+
key: ((_a = step.props) == null ? void 0 : _a.name) || index
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
)
|
|
794
|
+
]
|
|
925
795
|
})
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
className
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
796
|
+
) });
|
|
797
|
+
},
|
|
798
|
+
(prev, next) => {
|
|
799
|
+
const keys = [
|
|
800
|
+
"render",
|
|
801
|
+
"dataset",
|
|
802
|
+
"className",
|
|
803
|
+
"styles",
|
|
804
|
+
"width",
|
|
805
|
+
"height",
|
|
806
|
+
"type",
|
|
807
|
+
"stepstyle",
|
|
808
|
+
"orientation",
|
|
809
|
+
"alternativeLabel",
|
|
810
|
+
"nonLinear",
|
|
811
|
+
"defaultstep",
|
|
812
|
+
"defaultstepindex",
|
|
813
|
+
"message",
|
|
814
|
+
"cancelable",
|
|
815
|
+
"enablenext",
|
|
816
|
+
"nextbtnlabel",
|
|
817
|
+
"previousbtnlabel",
|
|
818
|
+
"donebtnlabel",
|
|
819
|
+
"cancelbtnlabel",
|
|
820
|
+
"children",
|
|
821
|
+
"hidden"
|
|
822
|
+
];
|
|
823
|
+
return keys.every((key) => {
|
|
824
|
+
if (key === "children") {
|
|
825
|
+
return prev[key] === next[key];
|
|
826
|
+
}
|
|
827
|
+
return isEqual(prev[key], next[key]);
|
|
942
828
|
});
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
return keys.every(function (key) {
|
|
947
|
-
// Never deep-compare children; treat as referential
|
|
948
|
-
if (key === "children") {
|
|
949
|
-
return prev[key] === next[key];
|
|
950
|
-
}
|
|
951
|
-
return (0, _isEqual["default"])(prev[key], next[key]);
|
|
952
|
-
});
|
|
953
|
-
});
|
|
954
|
-
var WmWizardStandalone = exports.WmWizard = (0, _withStandalone["default"])(WmWizard);
|
|
829
|
+
}
|
|
830
|
+
);
|
|
831
|
+
const WmWizardStandalone = withStandalone(WmWizard);
|
|
955
832
|
WmWizard.displayName = "WmWizard";
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
* - [Playground](https://react-components.wavemaker.ai/?path=/story/containers-wizard--showcase)
|
|
962
|
-
*
|
|
963
|
-
* - [Docs](https://react-components.wavemaker.ai/?path=/story/containers-wizard--docs)
|
|
964
|
-
*
|
|
965
|
-
* @param props - {@link WmWizardProps}
|
|
966
|
-
*/
|
|
967
|
-
var _default = exports["default"] = (0, _withBaseWrapper.withBaseWrapper)(WmWizard);
|
|
833
|
+
var wizard_default = withBaseWrapper(WmWizard);
|
|
834
|
+
export {
|
|
835
|
+
WmWizardStandalone as WmWizard,
|
|
836
|
+
wizard_default as default
|
|
837
|
+
};
|