@wavemaker-ai/react-runtime 1.0.0-rc.312 → 1.0.0-rc.317
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.d.ts +1 -0
- package/actions/navigation-action.js +275 -345
- 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/auth/RoleAuthGuard.d.ts +6 -0
- package/components/auth/RoleAuthGuard.js +65 -0
- 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 +813 -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.d.ts +1 -1
- package/components/basic/tree/Components/TreeNodeComponent.js +244 -170
- package/components/basic/tree/hooks/useTreePartialNodeApi.js +143 -135
- package/components/basic/tree/hooks/useTreePersistedState.d.ts +3 -0
- package/components/basic/tree/hooks/useTreePersistedState.js +38 -0
- package/components/basic/tree/index.d.ts +1 -0
- package/components/basic/tree/index.js +453 -454
- package/components/basic/tree/props.d.ts +18 -1
- package/components/basic/tree/props.js +0 -5
- package/components/basic/tree/utils.d.ts +16 -1
- package/components/basic/tree/utils.js +240 -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 +363 -447
- 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 +210 -155
- package/components/container/layout-grid/grid-column/index.js +69 -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 +534 -647
- 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 +320 -274
- 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 +701 -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 +1556 -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.d.ts +1 -1
- package/components/data/table/utils/columnBuilder.js +121 -160
- 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 +17 -13
- package/components/data/table/utils/index.js +483 -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 +57 -44
- package/components/layout/leftnav/props.d.ts +9 -0
- package/components/layout/leftnav/props.js +0 -5
- package/components/layout/leftnav/utils/page-class-util.d.ts +9 -0
- package/components/layout/leftnav/utils/page-class-util.js +28 -0
- package/components/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 +192 -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 +100 -102
- package/components/page/page-content/index.js +21 -30
- package/components/page/page-content/props.js +0 -5
- package/components/page/page-context.d.ts +4 -0
- package/components/page/page-context.js +5 -0
- package/components/page/partial/index.js +50 -45
- package/components/page/partial/props.js +0 -5
- package/components/page/partial-container/index.js +78 -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.js +92 -98
- package/core/util/safe-is-equal.js +42 -94
- package/core/util/security.js +114 -153
- package/core/util/utils.d.ts +4 -1
- package/core/util/utils.js +88 -159
- package/core/widget-observer.js +34 -61
- package/higherOrder/BaseApp.js +328 -502
- package/higherOrder/BaseAppProps.d.ts +1 -0
- package/higherOrder/BaseAppProps.js +0 -5
- package/higherOrder/BaseDateTime.js +277 -231
- package/higherOrder/BasePage.js +474 -740
- 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 +314 -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 +816 -3207
- package/package.json +3 -19
- package/providers/AppProviders.js +21 -24
- package/runtime-dynamic/App.js +65 -93
- package/runtime-dynamic/app-initializer.js +193 -411
- 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 -45
- package/runtime-dynamic/components/prefab-content.js +37 -30
- package/runtime-dynamic/components/use-dynamic-component.js +55 -157
- package/runtime-dynamic/factories/build-base-page-like-component.d.ts +1 -1
- 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 +91 -0
- package/runtime-dynamic/factories/prefab-factory.d.ts +1 -1
- 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 +2 -10
- package/runtime-dynamic/factories/utils.js +47 -129
- 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/compile-render.d.ts +9 -0
- package/runtime-dynamic/services/compile-render.js +142 -0
- package/runtime-dynamic/services/component-ref-provider.d.ts +18 -3
- package/runtime-dynamic/services/component-ref-provider.js +52 -129
- package/runtime-dynamic/services/css-scoping.js +23 -28
- package/runtime-dynamic/services/fragment-url.js +37 -50
- package/runtime-dynamic/services/index.d.ts +2 -3
- package/runtime-dynamic/services/index.js +31 -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 +40 -118
- package/runtime-dynamic/services/resource-manager.d.ts +2 -2
- package/runtime-dynamic/services/resource-manager.js +24 -65
- package/runtime-dynamic/services/script-executor.js +46 -63
- package/runtime-dynamic/services/variable-factory.js +141 -184
- package/runtime-dynamic/services/variable-registry.js +65 -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.js +15 -30
- 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 +191 -41
- package/utils/custom-expression/index.js +58 -151
- package/utils/custom-expression/parser.js +108 -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.d.ts +1 -1
- package/utils/state-persistance.js +136 -253
- package/utils/style-utils.js +24 -78
- 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/runtime-dynamic/services/cache.d.ts +0 -29
- package/runtime-dynamic/services/cache.js +0 -57
- package/tsconfig.declaration.tsbuildinfo +0 -1
- package/types/global.d.js +0 -3
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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 { useState, useCallback, useEffect, useRef, useMemo } from "react";
|
|
21
|
+
import { isArray, isEmpty, isNull } from "lodash-es";
|
|
22
|
+
import { addUniqueRowIds, extractDataArray } from "../../table/utils";
|
|
23
|
+
const isDataSourceHasPaging = (datasource) => {
|
|
17
24
|
return datasource && typeof datasource.execute === "function" && datasource.execute("IS_PAGEABLE");
|
|
18
25
|
};
|
|
19
|
-
|
|
20
|
-
// Utility function to calculate paging values
|
|
21
|
-
var calculatePagingValues = function calculatePagingValues(dataSize, maxResults) {
|
|
26
|
+
const calculatePagingValues = (dataSize, maxResults) => {
|
|
22
27
|
return dataSize > maxResults ? Math.ceil(dataSize / maxResults) : dataSize < 0 ? 0 : 1;
|
|
23
28
|
};
|
|
24
|
-
|
|
25
|
-
// Utility function to create a dummy synthetic event when no event is available
|
|
26
|
-
var createDummyEvent = function createDummyEvent() {
|
|
27
|
-
var eventName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "synthetic";
|
|
29
|
+
const createDummyEvent = (eventName = "synthetic") => {
|
|
28
30
|
return {
|
|
29
31
|
bubbles: false,
|
|
30
32
|
cancelable: false,
|
|
@@ -37,451 +39,360 @@ var createDummyEvent = function createDummyEvent() {
|
|
|
37
39
|
timeStamp: Date.now(),
|
|
38
40
|
type: eventName,
|
|
39
41
|
// Dynamic type based on the event being triggered
|
|
40
|
-
isDefaultPrevented:
|
|
41
|
-
|
|
42
|
+
isDefaultPrevented: () => false,
|
|
43
|
+
isPropagationStopped: () => false,
|
|
44
|
+
persist: () => {
|
|
42
45
|
},
|
|
43
|
-
|
|
44
|
-
return false;
|
|
46
|
+
preventDefault: () => {
|
|
45
47
|
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
stopPropagation: function stopPropagation() {}
|
|
48
|
+
stopPropagation: () => {
|
|
49
|
+
}
|
|
49
50
|
};
|
|
50
51
|
};
|
|
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
|
-
var _useState4 = (0, _react.useState)({
|
|
108
|
-
isDisableNext: true,
|
|
109
|
-
isDisablePrevious: true,
|
|
110
|
-
isDisableFirst: true,
|
|
111
|
-
isDisableLast: true,
|
|
112
|
-
isDisableCurrent: false,
|
|
113
|
-
isDisableCount: false
|
|
114
|
-
}),
|
|
115
|
-
disableStates = _useState4[0],
|
|
116
|
-
setDisableStates = _useState4[1];
|
|
117
|
-
var isFetchingRef = (0, _react.useRef)(false);
|
|
118
|
-
var isResettingRef = (0, _react.useRef)(false); // Track if we're currently resetting accumulated data
|
|
119
|
-
|
|
120
|
-
// Refs for accumulated data (Scroll and On-Demand)
|
|
121
|
-
var observerRef = (0, _react.useRef)(null);
|
|
122
|
-
var internalSentinelRef = (0, _react.useRef)(null);
|
|
123
|
-
var sentinelRef = sentinelRefProp !== undefined ? sentinelRefProp : internalSentinelRef;
|
|
124
|
-
var accumulatingStateRef = (0, _react.useRef)(accumulatingState);
|
|
125
|
-
var sentinelHasLeftViewportRef = (0, _react.useRef)(true); // Track if sentinel has left viewport after View Less
|
|
126
|
-
|
|
127
|
-
// Keep ref in sync with state
|
|
128
|
-
(0, _react.useEffect)(function () {
|
|
52
|
+
const usePagination = ({
|
|
53
|
+
dataset,
|
|
54
|
+
maxResults = 10,
|
|
55
|
+
currentPage: initialPage,
|
|
56
|
+
navigation,
|
|
57
|
+
name,
|
|
58
|
+
listener,
|
|
59
|
+
onPaginationChange,
|
|
60
|
+
onSetRecord,
|
|
61
|
+
onPageSizeChange,
|
|
62
|
+
paginationMeta,
|
|
63
|
+
totalItems,
|
|
64
|
+
datasource,
|
|
65
|
+
setIsLoadingMore,
|
|
66
|
+
isServerSidePagination = false,
|
|
67
|
+
listDirection,
|
|
68
|
+
scrollContainerRef,
|
|
69
|
+
sentinelRef: sentinelRefProp,
|
|
70
|
+
datasourceInvokeOptions
|
|
71
|
+
}) => {
|
|
72
|
+
var _a;
|
|
73
|
+
const pageSizeChangeHandler = onPageSizeChange || (listener == null ? void 0 : listener.onPageSizeChange);
|
|
74
|
+
const widgetInstance = (_a = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _a[name];
|
|
75
|
+
const [paginationState, setPaginationState] = useState({
|
|
76
|
+
currentPage: initialPage || 1,
|
|
77
|
+
pageCount: 0,
|
|
78
|
+
dataSize: 0,
|
|
79
|
+
currentMaxResults: (paginationMeta == null ? void 0 : paginationMeta.size) || maxResults,
|
|
80
|
+
error: null
|
|
81
|
+
});
|
|
82
|
+
const [dataState, setDataState] = useState({
|
|
83
|
+
fullData: [],
|
|
84
|
+
result: []
|
|
85
|
+
});
|
|
86
|
+
const [accumulatingState, setAccumulatingState] = useState({
|
|
87
|
+
accumulatedData: [],
|
|
88
|
+
lastLoadedPage: 0,
|
|
89
|
+
isAccumulating: navigation === "Scroll" || navigation === "On-Demand",
|
|
90
|
+
isInitialized: false
|
|
91
|
+
});
|
|
92
|
+
const [disableStates, setDisableStates] = useState({
|
|
93
|
+
isDisableNext: true,
|
|
94
|
+
isDisablePrevious: true,
|
|
95
|
+
isDisableFirst: true,
|
|
96
|
+
isDisableLast: true,
|
|
97
|
+
isDisableCurrent: false,
|
|
98
|
+
isDisableCount: false
|
|
99
|
+
});
|
|
100
|
+
const isFetchingRef = useRef(false);
|
|
101
|
+
const isResettingRef = useRef(false);
|
|
102
|
+
const observerRef = useRef(null);
|
|
103
|
+
const internalSentinelRef = useRef(null);
|
|
104
|
+
const sentinelRef = sentinelRefProp !== void 0 ? sentinelRefProp : internalSentinelRef;
|
|
105
|
+
const accumulatingStateRef = useRef(accumulatingState);
|
|
106
|
+
const sentinelHasLeftViewportRef = useRef(true);
|
|
107
|
+
useEffect(() => {
|
|
129
108
|
accumulatingStateRef.current = accumulatingState;
|
|
130
109
|
}, [accumulatingState]);
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
var isFirstPage = (0, _react.useMemo)(function () {
|
|
134
|
-
// First check pagination metadata if available
|
|
135
|
-
if (paginationMeta && paginationMeta.first !== undefined) {
|
|
110
|
+
const isFirstPage = useMemo(() => {
|
|
111
|
+
if (paginationMeta && paginationMeta.first !== void 0) {
|
|
136
112
|
return paginationMeta.first;
|
|
137
113
|
}
|
|
138
|
-
// Fall back to calculation
|
|
139
114
|
return paginationState.currentPage === 1 || !paginationState.currentPage;
|
|
140
115
|
}, [paginationState.currentPage, paginationMeta]);
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (paginationMeta && paginationMeta.last !== undefined) {
|
|
116
|
+
const isLastPage = useMemo(() => {
|
|
117
|
+
if (paginationMeta && paginationMeta.last !== void 0) {
|
|
144
118
|
return paginationMeta.last;
|
|
145
119
|
}
|
|
146
|
-
// Fall back to calculation
|
|
147
120
|
return paginationState.currentPage === paginationState.pageCount;
|
|
148
121
|
}, [paginationState.currentPage, paginationState.pageCount, paginationMeta]);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
var allowedNavControls = ["Basic", "Classic", "Pager", "Scroll", "On-Demand"];
|
|
152
|
-
var getValidNavControl = function getValidNavControl(nav) {
|
|
122
|
+
const allowedNavControls = ["Basic", "Classic", "Pager", "Scroll", "On-Demand"];
|
|
123
|
+
const getValidNavControl = (nav) => {
|
|
153
124
|
return allowedNavControls.includes(nav) ? nav : "Basic";
|
|
154
125
|
};
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
return Promise.resolve();
|
|
167
|
-
}
|
|
168
|
-
isFetchingRef.current = true;
|
|
169
|
-
setPaginationState(function (prev) {
|
|
170
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
171
|
-
error: null
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
try {
|
|
175
|
-
// Prepare invoke options with page and optionally size
|
|
176
|
-
var invokeOptions = {
|
|
177
|
-
page: page
|
|
178
|
-
};
|
|
179
|
-
if (size !== undefined) {
|
|
180
|
-
invokeOptions.size = size;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// Include additional invoke options if provided (for table sorting/filtering)
|
|
184
|
-
if (datasourceInvokeOptions) {
|
|
185
|
-
// Merge the additional options with page/size
|
|
186
|
-
Object.assign(invokeOptions, datasourceInvokeOptions);
|
|
126
|
+
const [navcontrols, setNavcontrols] = useState(getValidNavControl(navigation));
|
|
127
|
+
const getPaginationStartIndex = () => {
|
|
128
|
+
var _a2, _b;
|
|
129
|
+
const startIndex = (_a2 = datasource == null ? void 0 : datasource._paginationConfig) == null ? void 0 : _a2.paginationStartIndex;
|
|
130
|
+
return startIndex !== void 0 && ((_b = datasource._paginationConfig) == null ? void 0 : _b.type) === "page" ? Number(startIndex) : 1;
|
|
131
|
+
};
|
|
132
|
+
const datasourceInvoke = useCallback(
|
|
133
|
+
(page, size, isScrollMode = false) => {
|
|
134
|
+
if (isServerSidePagination && datasource && typeof datasource.invoke === "function") {
|
|
135
|
+
if (isFetchingRef.current) {
|
|
136
|
+
return Promise.resolve();
|
|
187
137
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
if (
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
138
|
+
isFetchingRef.current = true;
|
|
139
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { error: null }));
|
|
140
|
+
try {
|
|
141
|
+
const invokeOptions = { page };
|
|
142
|
+
if (size !== void 0) {
|
|
143
|
+
invokeOptions.size = size;
|
|
144
|
+
}
|
|
145
|
+
if (datasourceInvokeOptions) {
|
|
146
|
+
Object.assign(invokeOptions, datasourceInvokeOptions);
|
|
147
|
+
}
|
|
148
|
+
invokeOptions.page = page - 1 + getPaginationStartIndex();
|
|
149
|
+
const result = datasource.invoke(invokeOptions);
|
|
150
|
+
return Promise.resolve(result).then((response) => {
|
|
151
|
+
isFetchingRef.current = false;
|
|
152
|
+
if (isScrollMode && response && response.data) {
|
|
153
|
+
const currentAccumulatedData = accumulatingStateRef.current.accumulatedData;
|
|
154
|
+
const newDataWithIds = addUniqueRowIds(response.data);
|
|
155
|
+
const newAccumulatedData = [...currentAccumulatedData, ...newDataWithIds];
|
|
156
|
+
setAccumulatingState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
204
157
|
accumulatedData: newAccumulatedData,
|
|
205
158
|
lastLoadedPage: page
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
// Immediately update the data state with accumulated data
|
|
210
|
-
setDataState(function (prev) {
|
|
211
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
159
|
+
}));
|
|
160
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
212
161
|
fullData: newAccumulatedData,
|
|
213
162
|
result: newAccumulatedData
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
console.error("Error fetching page data:", error);
|
|
221
|
-
setPaginationState(function (prev) {
|
|
222
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
return response;
|
|
166
|
+
}).catch((error) => {
|
|
167
|
+
isFetchingRef.current = false;
|
|
168
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
223
169
|
error: error.message || "Failed to fetch page data"
|
|
224
|
-
});
|
|
170
|
+
}));
|
|
171
|
+
return Promise.reject(error);
|
|
225
172
|
});
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
console.error("Error invoking datasource:", error);
|
|
231
|
-
setPaginationState(function (prev) {
|
|
232
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
173
|
+
} catch (error) {
|
|
174
|
+
isFetchingRef.current = false;
|
|
175
|
+
console.error("Error invoking datasource:", error);
|
|
176
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
233
177
|
error: error.message || "Failed to invoke datasource"
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
|
|
178
|
+
}));
|
|
179
|
+
return Promise.reject(error);
|
|
180
|
+
}
|
|
237
181
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
// Get next batch of data
|
|
258
|
-
var nextBatch = dataState.fullData.slice(currentVisible, newVisibleCount);
|
|
259
|
-
var newAccumulatedData = [].concat((0, _toConsumableArray2["default"])(accumulatingStateRef.current.accumulatedData), (0, _toConsumableArray2["default"])(nextBatch));
|
|
260
|
-
setAccumulatingState(function (prev) {
|
|
261
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
182
|
+
return Promise.resolve();
|
|
183
|
+
},
|
|
184
|
+
[datasource, isServerSidePagination, datasourceInvokeOptions]
|
|
185
|
+
);
|
|
186
|
+
const loadMoreData = useCallback(
|
|
187
|
+
(event) => {
|
|
188
|
+
const isAccumulatingMode = navigation === "Scroll" || navigation === "On-Demand";
|
|
189
|
+
if (!isAccumulatingMode || isLastPage || isFetchingRef.current) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
if (!isServerSidePagination) {
|
|
193
|
+
const currentVisible = accumulatingStateRef.current.accumulatedData.length;
|
|
194
|
+
const totalAvailable = dataState.fullData.length;
|
|
195
|
+
const nextBatchSize = paginationState.currentMaxResults;
|
|
196
|
+
const newVisibleCount = Math.min(currentVisible + nextBatchSize, totalAvailable);
|
|
197
|
+
const nextBatch = dataState.fullData.slice(currentVisible, newVisibleCount);
|
|
198
|
+
const newAccumulatedData = [...accumulatingStateRef.current.accumulatedData, ...nextBatch];
|
|
199
|
+
setAccumulatingState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
262
200
|
accumulatedData: newAccumulatedData,
|
|
263
201
|
lastLoadedPage: prev.lastLoadedPage + 1
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
// Update the result to show accumulated data
|
|
268
|
-
setDataState(function (prev) {
|
|
269
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
202
|
+
}));
|
|
203
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
270
204
|
result: newAccumulatedData
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
onPaginationChange(event || createDummyEvent("paginationchange"), widgetInstance, _nextPage);
|
|
283
|
-
}
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
// Server-side pagination
|
|
288
|
-
var nextPage = accumulatingStateRef.current.lastLoadedPage + 1;
|
|
289
|
-
if (setIsLoadingMore) {
|
|
290
|
-
setIsLoadingMore(true);
|
|
291
|
-
}
|
|
292
|
-
datasourceInvoke(nextPage, paginationState.currentMaxResults, true).then(function () {
|
|
293
|
-
setPaginationState(function (prev) {
|
|
294
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
295
|
-
currentPage: nextPage
|
|
296
|
-
});
|
|
297
|
-
});
|
|
298
|
-
if (onPaginationChange) {
|
|
299
|
-
onPaginationChange(event || createDummyEvent("paginationchange"), widgetInstance, nextPage);
|
|
300
|
-
}
|
|
301
|
-
if (setIsLoadingMore) {
|
|
302
|
-
setIsLoadingMore(false);
|
|
303
|
-
}
|
|
304
|
-
})["catch"](function () {
|
|
305
|
-
if (setIsLoadingMore) {
|
|
306
|
-
setIsLoadingMore(false);
|
|
205
|
+
}));
|
|
206
|
+
const nextPage2 = accumulatingStateRef.current.lastLoadedPage + 1;
|
|
207
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { currentPage: nextPage2 }));
|
|
208
|
+
if (onPaginationChange) {
|
|
209
|
+
onPaginationChange(
|
|
210
|
+
event || createDummyEvent("paginationchange"),
|
|
211
|
+
widgetInstance,
|
|
212
|
+
nextPage2
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
return;
|
|
307
216
|
}
|
|
308
|
-
|
|
309
|
-
}, [navigation, isServerSidePagination, isLastPage, setIsLoadingMore, datasourceInvoke, paginationState.currentMaxResults, onPaginationChange, widgetInstance, dataState.fullData]);
|
|
310
|
-
|
|
311
|
-
// Function to reset accumulated data (for View Less button in On-Demand navigation)
|
|
312
|
-
var resetAccumulatedData = (0, _react.useCallback)(function (event) {
|
|
313
|
-
if (navigation === "Scroll") {
|
|
314
|
-
sentinelHasLeftViewportRef.current = false;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
// Set resetting flag to prevent dataset prop from overwriting our reset
|
|
318
|
-
isResettingRef.current = true;
|
|
319
|
-
|
|
320
|
-
// Reset to initial state
|
|
321
|
-
setAccumulatingState({
|
|
322
|
-
accumulatedData: [],
|
|
323
|
-
lastLoadedPage: 0,
|
|
324
|
-
isAccumulating: navigation === "Scroll" || navigation === "On-Demand",
|
|
325
|
-
isInitialized: false
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
// Immediately clear the result data to trigger UI update
|
|
329
|
-
setDataState(function (prev) {
|
|
330
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
331
|
-
result: []
|
|
332
|
-
});
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
// Reset current page to 1
|
|
336
|
-
setPaginationState(function (prev) {
|
|
337
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
338
|
-
currentPage: 1
|
|
339
|
-
});
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
// Immediately trigger pagination change callback to reset table's page index
|
|
343
|
-
if (onPaginationChange) {
|
|
344
|
-
onPaginationChange(event || createDummyEvent(), widgetInstance, 1);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// For client-side, reset result to first page
|
|
348
|
-
if (!isServerSidePagination && dataState.fullData.length > 0) {
|
|
349
|
-
var firstPageData = dataState.fullData.slice(0, paginationState.currentMaxResults);
|
|
350
|
-
setDataState(function (prev) {
|
|
351
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
352
|
-
result: firstPageData
|
|
353
|
-
});
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
// Re-initialize with first page data
|
|
357
|
-
setTimeout(function () {
|
|
358
|
-
setAccumulatingState({
|
|
359
|
-
accumulatedData: firstPageData,
|
|
360
|
-
lastLoadedPage: 1,
|
|
361
|
-
isAccumulating: true,
|
|
362
|
-
isInitialized: true
|
|
363
|
-
});
|
|
364
|
-
}, 0);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
// For server-side, refetch first page
|
|
368
|
-
if (isServerSidePagination && datasource && typeof datasource.invoke === "function") {
|
|
217
|
+
const nextPage = accumulatingStateRef.current.lastLoadedPage + 1;
|
|
369
218
|
if (setIsLoadingMore) {
|
|
370
219
|
setIsLoadingMore(true);
|
|
371
220
|
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
var result = datasource.invoke(invokeOptions);
|
|
381
|
-
Promise.resolve(result).then(function (response) {
|
|
382
|
-
if (response && response.data) {
|
|
383
|
-
var newDataWithIds = (0, _utils.addUniqueRowIds)(response.data);
|
|
384
|
-
setAccumulatingState({
|
|
385
|
-
accumulatedData: newDataWithIds,
|
|
386
|
-
lastLoadedPage: 1,
|
|
387
|
-
isAccumulating: true,
|
|
388
|
-
isInitialized: true
|
|
389
|
-
});
|
|
390
|
-
setDataState(function (prev) {
|
|
391
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
392
|
-
fullData: newDataWithIds,
|
|
393
|
-
result: newDataWithIds
|
|
394
|
-
});
|
|
395
|
-
});
|
|
396
|
-
// Clear resetting flag after successfully setting new data
|
|
397
|
-
isResettingRef.current = false;
|
|
221
|
+
datasourceInvoke(nextPage, paginationState.currentMaxResults, true).then(() => {
|
|
222
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { currentPage: nextPage }));
|
|
223
|
+
if (onPaginationChange) {
|
|
224
|
+
onPaginationChange(
|
|
225
|
+
event || createDummyEvent("paginationchange"),
|
|
226
|
+
widgetInstance,
|
|
227
|
+
nextPage
|
|
228
|
+
);
|
|
398
229
|
}
|
|
399
230
|
if (setIsLoadingMore) {
|
|
400
231
|
setIsLoadingMore(false);
|
|
401
232
|
}
|
|
402
|
-
})
|
|
403
|
-
// Clear resetting flag on error
|
|
404
|
-
isResettingRef.current = false;
|
|
233
|
+
}).catch(() => {
|
|
405
234
|
if (setIsLoadingMore) {
|
|
406
235
|
setIsLoadingMore(false);
|
|
407
236
|
}
|
|
408
237
|
});
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
observerRef.current.disconnect();
|
|
426
|
-
observerRef.current = null;
|
|
427
|
-
}
|
|
428
|
-
if (!sentinel || navigation !== "Scroll" || !accumulatingStateRef.current.isInitialized) {
|
|
429
|
-
return;
|
|
430
|
-
}
|
|
431
|
-
if (isRowScroll && !scrollRoot) {
|
|
432
|
-
return; // Row needs list container as root; sentinel is inside list
|
|
433
|
-
}
|
|
434
|
-
observerRef.current = new IntersectionObserver(function (entries) {
|
|
435
|
-
var entry = entries[0];
|
|
436
|
-
if (!entry.isIntersecting && sentinelHasLeftViewportRef.current === false) {
|
|
437
|
-
sentinelHasLeftViewportRef.current = true;
|
|
438
|
-
}
|
|
439
|
-
if (entry.isIntersecting && accumulatingStateRef.current.isInitialized && !isLastPage && !isFetchingRef.current && sentinelHasLeftViewportRef.current) {
|
|
440
|
-
loadMoreData();
|
|
238
|
+
},
|
|
239
|
+
[
|
|
240
|
+
navigation,
|
|
241
|
+
isServerSidePagination,
|
|
242
|
+
isLastPage,
|
|
243
|
+
setIsLoadingMore,
|
|
244
|
+
datasourceInvoke,
|
|
245
|
+
paginationState.currentMaxResults,
|
|
246
|
+
onPaginationChange,
|
|
247
|
+
widgetInstance,
|
|
248
|
+
dataState.fullData
|
|
249
|
+
]
|
|
250
|
+
);
|
|
251
|
+
const resetAccumulatedData = useCallback(
|
|
252
|
+
(event) => {
|
|
253
|
+
if (navigation === "Scroll") {
|
|
441
254
|
sentinelHasLeftViewportRef.current = false;
|
|
442
255
|
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
256
|
+
isResettingRef.current = true;
|
|
257
|
+
setAccumulatingState({
|
|
258
|
+
accumulatedData: [],
|
|
259
|
+
lastLoadedPage: 0,
|
|
260
|
+
isAccumulating: navigation === "Scroll" || navigation === "On-Demand",
|
|
261
|
+
isInitialized: false
|
|
262
|
+
});
|
|
263
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
264
|
+
result: []
|
|
265
|
+
}));
|
|
266
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { currentPage: 1 }));
|
|
267
|
+
if (onPaginationChange) {
|
|
268
|
+
onPaginationChange(event || createDummyEvent(), widgetInstance, 1);
|
|
269
|
+
}
|
|
270
|
+
if (!isServerSidePagination && dataState.fullData.length > 0) {
|
|
271
|
+
const firstPageData = dataState.fullData.slice(0, paginationState.currentMaxResults);
|
|
272
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
273
|
+
result: firstPageData
|
|
274
|
+
}));
|
|
275
|
+
setTimeout(() => {
|
|
276
|
+
setAccumulatingState({
|
|
277
|
+
accumulatedData: firstPageData,
|
|
278
|
+
lastLoadedPage: 1,
|
|
279
|
+
isAccumulating: true,
|
|
280
|
+
isInitialized: true
|
|
281
|
+
});
|
|
282
|
+
}, 0);
|
|
283
|
+
}
|
|
284
|
+
if (isServerSidePagination && datasource && typeof datasource.invoke === "function") {
|
|
285
|
+
if (setIsLoadingMore) {
|
|
286
|
+
setIsLoadingMore(true);
|
|
287
|
+
}
|
|
288
|
+
const invokeOptions = {
|
|
289
|
+
page: 1
|
|
290
|
+
};
|
|
291
|
+
if (datasourceInvokeOptions) {
|
|
292
|
+
Object.assign(invokeOptions, datasourceInvokeOptions);
|
|
293
|
+
}
|
|
294
|
+
const result = datasource.invoke(invokeOptions);
|
|
295
|
+
Promise.resolve(result).then((response) => {
|
|
296
|
+
if (response && response.data) {
|
|
297
|
+
const newDataWithIds = addUniqueRowIds(response.data);
|
|
298
|
+
setAccumulatingState({
|
|
299
|
+
accumulatedData: newDataWithIds,
|
|
300
|
+
lastLoadedPage: 1,
|
|
301
|
+
isAccumulating: true,
|
|
302
|
+
isInitialized: true
|
|
303
|
+
});
|
|
304
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
305
|
+
fullData: newDataWithIds,
|
|
306
|
+
result: newDataWithIds
|
|
307
|
+
}));
|
|
308
|
+
isResettingRef.current = false;
|
|
309
|
+
}
|
|
310
|
+
if (setIsLoadingMore) {
|
|
311
|
+
setIsLoadingMore(false);
|
|
312
|
+
}
|
|
313
|
+
}).catch(() => {
|
|
314
|
+
isResettingRef.current = false;
|
|
315
|
+
if (setIsLoadingMore) {
|
|
316
|
+
setIsLoadingMore(false);
|
|
317
|
+
}
|
|
464
318
|
});
|
|
465
319
|
} else {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
var updatedCurrentPage = currentPage !== undefined ? currentPage : prev.currentPage;
|
|
470
|
-
|
|
471
|
-
// Calculate page count based on updated values
|
|
472
|
-
// Use paginationMeta.totalPages if available
|
|
473
|
-
var newPageCount = (paginationMeta === null || paginationMeta === void 0 ? void 0 : paginationMeta.totalPages) !== undefined && (paginationMeta === null || paginationMeta === void 0 ? void 0 : paginationMeta.totalPages) > 1 ? paginationMeta.totalPages : updatedDataSize > updatedMaxResults ? Math.ceil(updatedDataSize / updatedMaxResults) : updatedDataSize < 0 ? 0 : 1;
|
|
474
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
475
|
-
currentPage: updatedCurrentPage,
|
|
476
|
-
dataSize: updatedDataSize,
|
|
477
|
-
pageCount: newPageCount
|
|
478
|
-
});
|
|
320
|
+
setTimeout(() => {
|
|
321
|
+
isResettingRef.current = false;
|
|
322
|
+
}, 0);
|
|
479
323
|
}
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
324
|
+
},
|
|
325
|
+
[
|
|
326
|
+
navigation,
|
|
327
|
+
isServerSidePagination,
|
|
328
|
+
datasource,
|
|
329
|
+
datasourceInvokeOptions,
|
|
330
|
+
dataState.fullData,
|
|
331
|
+
paginationState.currentMaxResults,
|
|
332
|
+
setIsLoadingMore,
|
|
333
|
+
onPaginationChange,
|
|
334
|
+
widgetInstance
|
|
335
|
+
]
|
|
336
|
+
);
|
|
337
|
+
const isRowScroll = navigation === "Scroll" && (listDirection === "row" || listDirection === "horizontal");
|
|
338
|
+
const setupInfiniteScrollObserver = useCallback(
|
|
339
|
+
(sentinel, scrollRoot) => {
|
|
340
|
+
if (observerRef.current) {
|
|
341
|
+
observerRef.current.disconnect();
|
|
342
|
+
observerRef.current = null;
|
|
343
|
+
}
|
|
344
|
+
if (!sentinel || navigation !== "Scroll" || !accumulatingStateRef.current.isInitialized) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
if (isRowScroll && !scrollRoot) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
observerRef.current = new IntersectionObserver(
|
|
351
|
+
(entries) => {
|
|
352
|
+
const entry = entries[0];
|
|
353
|
+
if (!entry.isIntersecting && sentinelHasLeftViewportRef.current === false) {
|
|
354
|
+
sentinelHasLeftViewportRef.current = true;
|
|
355
|
+
}
|
|
356
|
+
if (entry.isIntersecting && accumulatingStateRef.current.isInitialized && !isLastPage && !isFetchingRef.current && sentinelHasLeftViewportRef.current) {
|
|
357
|
+
loadMoreData();
|
|
358
|
+
sentinelHasLeftViewportRef.current = false;
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
root: scrollRoot != null ? scrollRoot : null,
|
|
363
|
+
rootMargin: isRowScroll ? "0px" : "100px",
|
|
364
|
+
threshold: 0.1
|
|
365
|
+
}
|
|
366
|
+
);
|
|
367
|
+
observerRef.current.observe(sentinel);
|
|
368
|
+
},
|
|
369
|
+
[navigation, isLastPage, loadMoreData, listDirection, isRowScroll]
|
|
370
|
+
);
|
|
371
|
+
const setDefaultPagingValues = useCallback(
|
|
372
|
+
(newDataSize, newMaxResults, currentPage) => {
|
|
373
|
+
setPaginationState((prev) => {
|
|
374
|
+
if (!newDataSize && !newMaxResults) {
|
|
375
|
+
return __spreadProps(__spreadValues({}, prev), {
|
|
376
|
+
pageCount: 1,
|
|
377
|
+
dataSize: newDataSize,
|
|
378
|
+
currentPage: currentPage !== void 0 ? currentPage : prev.currentPage
|
|
379
|
+
});
|
|
380
|
+
} else {
|
|
381
|
+
const updatedMaxResults = newMaxResults || prev.currentMaxResults;
|
|
382
|
+
const updatedDataSize = newDataSize !== void 0 ? newDataSize : prev.dataSize;
|
|
383
|
+
const updatedCurrentPage = currentPage !== void 0 ? currentPage : prev.currentPage;
|
|
384
|
+
const newPageCount = (paginationMeta == null ? void 0 : paginationMeta.totalPages) !== void 0 && (paginationMeta == null ? void 0 : paginationMeta.totalPages) > 1 ? paginationMeta.totalPages : updatedDataSize > updatedMaxResults ? Math.ceil(updatedDataSize / updatedMaxResults) : updatedDataSize < 0 ? 0 : 1;
|
|
385
|
+
return __spreadProps(__spreadValues({}, prev), {
|
|
386
|
+
currentPage: updatedCurrentPage,
|
|
387
|
+
dataSize: updatedDataSize,
|
|
388
|
+
pageCount: newPageCount
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
},
|
|
393
|
+
[paginationMeta]
|
|
394
|
+
);
|
|
395
|
+
const disableNavigation = useCallback(() => {
|
|
485
396
|
setDisableStates({
|
|
486
397
|
isDisableFirst: isFirstPage,
|
|
487
398
|
isDisablePrevious: isFirstPage,
|
|
@@ -491,363 +402,298 @@ var usePagination = exports.usePagination = function usePagination(_ref) {
|
|
|
491
402
|
isDisableCount: false
|
|
492
403
|
});
|
|
493
404
|
}, [isFirstPage, isLastPage]);
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
if (currentAccumulatedData.length === 0 && (0, _lodash.isArray)(newVal)) {
|
|
531
|
-
// Ensure initial data has unique IDs using the existing utility
|
|
532
|
-
var initialDataWithIds = (0, _utils.addUniqueRowIds)(newVal);
|
|
533
|
-
setAccumulatingState(function (prev) {
|
|
534
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
405
|
+
const setNonPageableData = useCallback(
|
|
406
|
+
(newVal) => {
|
|
407
|
+
let newDataSize, newMaxResults, currentPage, startIndex;
|
|
408
|
+
if (isServerSidePagination) {
|
|
409
|
+
const serverTotalCount = totalItems != null ? totalItems : paginationMeta == null ? void 0 : paginationMeta.totalElements;
|
|
410
|
+
newDataSize = serverTotalCount !== void 0 && serverTotalCount >= 0 ? serverTotalCount : isArray(newVal) ? newVal.length : isEmpty(newVal) ? 0 : 1;
|
|
411
|
+
} else {
|
|
412
|
+
newDataSize = isArray(newVal) ? newVal.length : isEmpty(newVal) ? 0 : 1;
|
|
413
|
+
}
|
|
414
|
+
newMaxResults = paginationState.currentMaxResults || newDataSize;
|
|
415
|
+
currentPage = paginationState.currentPage;
|
|
416
|
+
setDefaultPagingValues(newDataSize, newMaxResults, currentPage);
|
|
417
|
+
disableNavigation();
|
|
418
|
+
startIndex = (currentPage - 1) * newMaxResults;
|
|
419
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
420
|
+
result: isArray(newVal) ? newVal.slice(startIndex, startIndex + newMaxResults) : newVal
|
|
421
|
+
}));
|
|
422
|
+
},
|
|
423
|
+
[
|
|
424
|
+
paginationState.currentPage,
|
|
425
|
+
paginationState.currentMaxResults,
|
|
426
|
+
disableNavigation,
|
|
427
|
+
setDefaultPagingValues,
|
|
428
|
+
isServerSidePagination,
|
|
429
|
+
totalItems,
|
|
430
|
+
paginationMeta
|
|
431
|
+
]
|
|
432
|
+
);
|
|
433
|
+
const setPagingValues = useCallback(
|
|
434
|
+
(newVal) => {
|
|
435
|
+
const isAccumulatingMode = (navigation === "Scroll" || navigation === "On-Demand") && isServerSidePagination;
|
|
436
|
+
if (isAccumulatingMode) {
|
|
437
|
+
const currentAccumulatedData = accumulatingStateRef.current.accumulatedData;
|
|
438
|
+
if (currentAccumulatedData.length === 0 && isArray(newVal)) {
|
|
439
|
+
const initialDataWithIds = addUniqueRowIds(newVal);
|
|
440
|
+
setAccumulatingState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
535
441
|
accumulatedData: initialDataWithIds,
|
|
536
442
|
lastLoadedPage: 1,
|
|
537
443
|
isInitialized: true
|
|
538
|
-
});
|
|
539
|
-
|
|
540
|
-
setDataState(function (prev) {
|
|
541
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
444
|
+
}));
|
|
445
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
542
446
|
fullData: initialDataWithIds,
|
|
543
447
|
result: initialDataWithIds
|
|
544
|
-
});
|
|
545
|
-
})
|
|
546
|
-
|
|
547
|
-
// For subsequent updates in accumulating mode, always use accumulated data
|
|
548
|
-
setDataState(function (prev) {
|
|
549
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
448
|
+
}));
|
|
449
|
+
} else if (currentAccumulatedData.length > 0) {
|
|
450
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
550
451
|
fullData: currentAccumulatedData,
|
|
551
452
|
result: currentAccumulatedData
|
|
552
|
-
});
|
|
553
|
-
}
|
|
453
|
+
}));
|
|
454
|
+
}
|
|
455
|
+
return;
|
|
554
456
|
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
564
|
-
fullData: (0, _lodash.isArray)(newVal) ? newVal : []
|
|
565
|
-
});
|
|
566
|
-
});
|
|
567
|
-
var _currentAccumulatedData = accumulatingStateRef.current.accumulatedData;
|
|
568
|
-
|
|
569
|
-
// Initialize accumulated data with first page if empty
|
|
570
|
-
if (_currentAccumulatedData.length === 0 && (0, _lodash.isArray)(newVal) && newVal.length > 0) {
|
|
571
|
-
var firstPageData = newVal.slice(0, paginationState.currentMaxResults);
|
|
572
|
-
setAccumulatingState(function (prev) {
|
|
573
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
457
|
+
if (navigation === "On-Demand" && !isServerSidePagination) {
|
|
458
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
459
|
+
fullData: isArray(newVal) ? newVal : []
|
|
460
|
+
}));
|
|
461
|
+
const currentAccumulatedData = accumulatingStateRef.current.accumulatedData;
|
|
462
|
+
if (currentAccumulatedData.length === 0 && isArray(newVal) && newVal.length > 0) {
|
|
463
|
+
const firstPageData = newVal.slice(0, paginationState.currentMaxResults);
|
|
464
|
+
setAccumulatingState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
574
465
|
accumulatedData: firstPageData,
|
|
575
466
|
lastLoadedPage: 1,
|
|
576
467
|
isInitialized: true
|
|
577
|
-
});
|
|
578
|
-
|
|
579
|
-
setDataState(function (prev) {
|
|
580
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
468
|
+
}));
|
|
469
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
581
470
|
result: firstPageData
|
|
582
|
-
});
|
|
583
|
-
})
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
}
|
|
471
|
+
}));
|
|
472
|
+
} else if (currentAccumulatedData.length > 0) {
|
|
473
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
474
|
+
result: currentAccumulatedData
|
|
475
|
+
}));
|
|
476
|
+
}
|
|
477
|
+
if (isArray(newVal)) {
|
|
478
|
+
setDefaultPagingValues(newVal.length, paginationState.currentMaxResults, 1);
|
|
479
|
+
}
|
|
480
|
+
return;
|
|
591
481
|
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
482
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
483
|
+
fullData: isArray(newVal) ? newVal : []
|
|
484
|
+
}));
|
|
485
|
+
if (newVal && !isArray(newVal)) {
|
|
486
|
+
setNonPageableData(newVal);
|
|
487
|
+
} else if (newVal) {
|
|
488
|
+
setNonPageableData(newVal);
|
|
489
|
+
} else {
|
|
490
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), { result: newVal }));
|
|
491
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { pageCount: 0, dataSize: 0 }));
|
|
596
492
|
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
});
|
|
617
|
-
// Don't reset page navigation when dataset is empty - just update counts
|
|
618
|
-
setPaginationState(function (prev) {
|
|
619
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
620
|
-
pageCount: 0,
|
|
621
|
-
dataSize: 0
|
|
622
|
-
});
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
}, [setNonPageableData, navigation, isServerSidePagination, paginationState.currentMaxResults, setDefaultPagingValues]);
|
|
626
|
-
|
|
627
|
-
// Validate current page
|
|
628
|
-
var validateCurrentPage = (0, _react.useCallback)(function (event) {
|
|
629
|
-
var currentPage = paginationState.currentPage,
|
|
630
|
-
pageCount = paginationState.pageCount;
|
|
631
|
-
// If the value entered is greater than the last page number or invalid value, then update the page
|
|
632
|
-
if (event && (isNaN(currentPage) || currentPage <= 0 || pageCount && (currentPage > pageCount || (0, _lodash.isNull)(currentPage)))) {
|
|
633
|
-
if (currentPage <= 0) {
|
|
634
|
-
setPaginationState(function (prev) {
|
|
635
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
636
|
-
currentPage: 1
|
|
637
|
-
});
|
|
638
|
-
});
|
|
639
|
-
} else if (currentPage > pageCount) {
|
|
640
|
-
setPaginationState(function (prev) {
|
|
641
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
642
|
-
currentPage: pageCount
|
|
643
|
-
});
|
|
644
|
-
});
|
|
493
|
+
},
|
|
494
|
+
[
|
|
495
|
+
setNonPageableData,
|
|
496
|
+
navigation,
|
|
497
|
+
isServerSidePagination,
|
|
498
|
+
paginationState.currentMaxResults,
|
|
499
|
+
setDefaultPagingValues
|
|
500
|
+
]
|
|
501
|
+
);
|
|
502
|
+
const validateCurrentPage = useCallback(
|
|
503
|
+
(event) => {
|
|
504
|
+
const { currentPage, pageCount } = paginationState;
|
|
505
|
+
if (event && (isNaN(currentPage) || currentPage <= 0 || pageCount && (currentPage > pageCount || isNull(currentPage)))) {
|
|
506
|
+
if (currentPage <= 0) {
|
|
507
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { currentPage: 1 }));
|
|
508
|
+
} else if (currentPage > pageCount) {
|
|
509
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { currentPage: pageCount }));
|
|
510
|
+
}
|
|
511
|
+
return false;
|
|
645
512
|
}
|
|
646
|
-
return
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
var startIndex = firstRow;
|
|
658
|
-
var data = (0, _lodash.isArray)(fullData) ? fullData.slice(startIndex, startIndex + currentMaxResults) : fullData;
|
|
659
|
-
setDataState(function (prev) {
|
|
660
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
661
|
-
result: data
|
|
662
|
-
});
|
|
663
|
-
});
|
|
513
|
+
return true;
|
|
514
|
+
},
|
|
515
|
+
[paginationState]
|
|
516
|
+
);
|
|
517
|
+
const goToPage = useCallback(() => {
|
|
518
|
+
const { currentPage, currentMaxResults } = paginationState;
|
|
519
|
+
const { fullData } = dataState;
|
|
520
|
+
const firstRow = (currentPage - 1) * currentMaxResults;
|
|
521
|
+
const startIndex = firstRow;
|
|
522
|
+
const data = isArray(fullData) ? fullData.slice(startIndex, startIndex + currentMaxResults) : fullData;
|
|
523
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), { result: data }));
|
|
664
524
|
disableNavigation();
|
|
665
525
|
}, [paginationState, dataState.fullData, disableNavigation]);
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
526
|
+
const performPageNavigation = useCallback(
|
|
527
|
+
(newPage, previousPage, event) => {
|
|
528
|
+
if (setIsLoadingMore) {
|
|
529
|
+
setIsLoadingMore(true);
|
|
530
|
+
}
|
|
531
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { currentPage: newPage }));
|
|
532
|
+
if (isServerSidePagination) {
|
|
533
|
+
datasourceInvoke(newPage).then(() => {
|
|
534
|
+
if (onPaginationChange) {
|
|
535
|
+
onPaginationChange(
|
|
536
|
+
event || createDummyEvent("paginationchange"),
|
|
537
|
+
widgetInstance,
|
|
538
|
+
newPage
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
if (onSetRecord) {
|
|
542
|
+
const firstRow = (newPage - 1) * paginationState.currentMaxResults;
|
|
543
|
+
const startIndex = firstRow;
|
|
544
|
+
const data = isArray(dataState.fullData) ? dataState.fullData.slice(
|
|
545
|
+
startIndex,
|
|
546
|
+
startIndex + paginationState.currentMaxResults
|
|
547
|
+
) : dataState.fullData;
|
|
548
|
+
const pageInfo = {
|
|
549
|
+
currentPage: newPage,
|
|
550
|
+
size: paginationState.currentMaxResults,
|
|
551
|
+
totalElements: (paginationMeta == null ? void 0 : paginationMeta.totalElements) || dataState.fullData.length,
|
|
552
|
+
totalPages: paginationState.pageCount
|
|
553
|
+
};
|
|
554
|
+
onSetRecord(event || createDummyEvent("setrecord"), widgetInstance, data, pageInfo);
|
|
555
|
+
}
|
|
556
|
+
if (setIsLoadingMore) {
|
|
557
|
+
setIsLoadingMore(false);
|
|
558
|
+
}
|
|
559
|
+
}).catch(() => {
|
|
560
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
561
|
+
currentPage: previousPage || paginationState.currentPage
|
|
562
|
+
}));
|
|
563
|
+
if (setIsLoadingMore) {
|
|
564
|
+
setIsLoadingMore(false);
|
|
565
|
+
}
|
|
566
|
+
});
|
|
567
|
+
} else {
|
|
685
568
|
if (onPaginationChange) {
|
|
686
|
-
onPaginationChange(
|
|
569
|
+
onPaginationChange(
|
|
570
|
+
event || createDummyEvent("paginationchange"),
|
|
571
|
+
widgetInstance,
|
|
572
|
+
newPage
|
|
573
|
+
);
|
|
687
574
|
}
|
|
688
|
-
|
|
689
|
-
// Call onSetRecord with the new page data
|
|
690
575
|
if (onSetRecord) {
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
576
|
+
const firstRow = (newPage - 1) * paginationState.currentMaxResults;
|
|
577
|
+
const startIndex = firstRow;
|
|
578
|
+
const data = isArray(dataState.fullData) ? dataState.fullData.slice(startIndex, startIndex + paginationState.currentMaxResults) : dataState.fullData;
|
|
579
|
+
const pageInfo = {
|
|
695
580
|
currentPage: newPage,
|
|
696
581
|
size: paginationState.currentMaxResults,
|
|
697
|
-
totalElements: (paginationMeta
|
|
582
|
+
totalElements: (paginationMeta == null ? void 0 : paginationMeta.totalElements) || dataState.fullData.length,
|
|
698
583
|
totalPages: paginationState.pageCount
|
|
699
584
|
};
|
|
700
585
|
onSetRecord(event || createDummyEvent("setrecord"), widgetInstance, data, pageInfo);
|
|
701
586
|
}
|
|
702
|
-
|
|
703
|
-
// Clear loading state immediately for better UX
|
|
704
|
-
if (setIsLoadingMore) {
|
|
705
|
-
setIsLoadingMore(false);
|
|
706
|
-
}
|
|
707
|
-
})["catch"](function () {
|
|
708
|
-
// If the data fetch fails, revert to the previous page
|
|
709
|
-
setPaginationState(function (prev) {
|
|
710
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
711
|
-
currentPage: previousPage || paginationState.currentPage
|
|
712
|
-
});
|
|
713
|
-
});
|
|
714
|
-
|
|
715
|
-
// Clear loading state
|
|
716
587
|
if (setIsLoadingMore) {
|
|
717
588
|
setIsLoadingMore(false);
|
|
718
589
|
}
|
|
719
|
-
});
|
|
720
|
-
} else {
|
|
721
|
-
// Client-side pagination - no API call needed
|
|
722
|
-
// Just trigger the callbacks directly
|
|
723
|
-
if (onPaginationChange) {
|
|
724
|
-
onPaginationChange(event || createDummyEvent("paginationchange"), widgetInstance, newPage);
|
|
725
590
|
}
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
591
|
+
},
|
|
592
|
+
[
|
|
593
|
+
isServerSidePagination,
|
|
594
|
+
datasourceInvoke,
|
|
595
|
+
onPaginationChange,
|
|
596
|
+
onSetRecord,
|
|
597
|
+
widgetInstance,
|
|
598
|
+
paginationState,
|
|
599
|
+
dataState.fullData,
|
|
600
|
+
setIsLoadingMore,
|
|
601
|
+
paginationMeta
|
|
602
|
+
]
|
|
603
|
+
);
|
|
604
|
+
const navigatePage = useCallback(
|
|
605
|
+
(index, event, isRefresh = false) => {
|
|
606
|
+
const currentPage = +paginationState.currentPage;
|
|
607
|
+
let newPage = currentPage;
|
|
608
|
+
switch (index) {
|
|
609
|
+
case "first":
|
|
610
|
+
if (!isFirstPage) {
|
|
611
|
+
newPage = 1;
|
|
612
|
+
} else if (isRefresh) {
|
|
613
|
+
goToPage();
|
|
614
|
+
return;
|
|
615
|
+
} else {
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
break;
|
|
619
|
+
case "prev":
|
|
620
|
+
if (isFirstPage || !validateCurrentPage(event)) {
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
newPage = currentPage - 1;
|
|
624
|
+
break;
|
|
625
|
+
case "next":
|
|
626
|
+
if (isLastPage || !validateCurrentPage(event)) {
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
newPage = currentPage + 1;
|
|
630
|
+
break;
|
|
631
|
+
case "last":
|
|
632
|
+
if (!isLastPage) {
|
|
633
|
+
newPage = paginationState.pageCount;
|
|
634
|
+
} else if (isRefresh) {
|
|
635
|
+
goToPage();
|
|
636
|
+
return;
|
|
637
|
+
} else {
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
break;
|
|
641
|
+
default:
|
|
642
|
+
return;
|
|
739
643
|
}
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
if (setIsLoadingMore) {
|
|
743
|
-
setIsLoadingMore(false);
|
|
644
|
+
if (newPage !== currentPage) {
|
|
645
|
+
performPageNavigation(newPage, currentPage, event);
|
|
744
646
|
}
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
goToPage();
|
|
760
|
-
return;
|
|
761
|
-
} else {
|
|
762
|
-
return;
|
|
763
|
-
}
|
|
764
|
-
break;
|
|
765
|
-
case "prev":
|
|
766
|
-
// Return if already on the first page or invalid page
|
|
767
|
-
if (isFirstPage || !validateCurrentPage(event)) {
|
|
768
|
-
return;
|
|
769
|
-
}
|
|
770
|
-
// Decrement the current page by 1
|
|
771
|
-
newPage = currentPage - 1;
|
|
772
|
-
break;
|
|
773
|
-
case "next":
|
|
774
|
-
// Return if already on the last page or invalid page
|
|
775
|
-
if (isLastPage || !validateCurrentPage(event)) {
|
|
776
|
-
return;
|
|
777
|
-
}
|
|
778
|
-
// Increment the current page by 1
|
|
779
|
-
newPage = currentPage + 1;
|
|
780
|
-
break;
|
|
781
|
-
case "last":
|
|
782
|
-
if (!isLastPage) {
|
|
783
|
-
newPage = paginationState.pageCount;
|
|
784
|
-
} else if (isRefresh) {
|
|
785
|
-
goToPage();
|
|
786
|
-
return;
|
|
787
|
-
} else {
|
|
788
|
-
return;
|
|
789
|
-
}
|
|
790
|
-
break;
|
|
791
|
-
default:
|
|
792
|
-
return;
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
// Call handlers only when page actually changes
|
|
796
|
-
if (newPage !== currentPage) {
|
|
797
|
-
performPageNavigation(newPage, currentPage, event);
|
|
798
|
-
}
|
|
799
|
-
}, [paginationState, isFirstPage, isLastPage, validateCurrentPage, goToPage, performPageNavigation]);
|
|
800
|
-
|
|
801
|
-
// Handle page change for basic pagination
|
|
802
|
-
var handlePageChange = (0, _react.useCallback)(function (event, page) {
|
|
803
|
-
// Do not call goToPage if page has not changed
|
|
804
|
-
if (page !== paginationState.currentPage) {
|
|
805
|
-
// Save current page to restore in case of error
|
|
806
|
-
var previousPage = paginationState.currentPage;
|
|
807
|
-
performPageNavigation(page, previousPage, event);
|
|
808
|
-
}
|
|
809
|
-
}, [paginationState.currentPage, performPageNavigation]);
|
|
810
|
-
|
|
811
|
-
// Handle input change for classic pagination
|
|
812
|
-
var handleInputChange = (0, _react.useCallback)(function (event) {
|
|
813
|
-
var value = parseInt(event.target.value, 10);
|
|
647
|
+
},
|
|
648
|
+
[paginationState, isFirstPage, isLastPage, validateCurrentPage, goToPage, performPageNavigation]
|
|
649
|
+
);
|
|
650
|
+
const handlePageChange = useCallback(
|
|
651
|
+
(event, page) => {
|
|
652
|
+
if (page !== paginationState.currentPage) {
|
|
653
|
+
const previousPage = paginationState.currentPage;
|
|
654
|
+
performPageNavigation(page, previousPage, event);
|
|
655
|
+
}
|
|
656
|
+
},
|
|
657
|
+
[paginationState.currentPage, performPageNavigation]
|
|
658
|
+
);
|
|
659
|
+
const handleInputChange = useCallback((event) => {
|
|
660
|
+
const value = parseInt(event.target.value, 10);
|
|
814
661
|
if (!isNaN(value)) {
|
|
815
|
-
setPaginationState(
|
|
816
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
817
|
-
currentPage: value
|
|
818
|
-
});
|
|
819
|
-
});
|
|
662
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { currentPage: value }));
|
|
820
663
|
}
|
|
821
664
|
}, []);
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
665
|
+
const onModelChange = useCallback(
|
|
666
|
+
(event) => {
|
|
667
|
+
if (!validateCurrentPage(event)) {
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
if (onSetRecord) {
|
|
671
|
+
const { currentPage, currentMaxResults, pageCount } = paginationState;
|
|
672
|
+
const { fullData } = dataState;
|
|
673
|
+
const firstRow = (currentPage - 1) * currentMaxResults;
|
|
674
|
+
const startIndex = firstRow;
|
|
675
|
+
const data = isArray(fullData) ? fullData.slice(startIndex, startIndex + currentMaxResults) : fullData;
|
|
676
|
+
const pageInfo = {
|
|
677
|
+
currentPage,
|
|
678
|
+
size: currentMaxResults,
|
|
679
|
+
totalElements: (paginationMeta == null ? void 0 : paginationMeta.totalElements) || fullData.length,
|
|
680
|
+
totalPages: pageCount
|
|
681
|
+
};
|
|
682
|
+
onSetRecord(event, widgetInstance, data, pageInfo);
|
|
683
|
+
}
|
|
684
|
+
goToPage();
|
|
685
|
+
},
|
|
686
|
+
[
|
|
687
|
+
goToPage,
|
|
688
|
+
validateCurrentPage,
|
|
689
|
+
onSetRecord,
|
|
690
|
+
paginationState,
|
|
691
|
+
dataState.fullData,
|
|
692
|
+
widgetInstance,
|
|
693
|
+
paginationMeta
|
|
694
|
+
]
|
|
695
|
+
);
|
|
696
|
+
const onKeyDown = useCallback((event) => {
|
|
851
697
|
if (event.code === "KeyE") {
|
|
852
698
|
event.currentTarget.classList.add("ng-invalid");
|
|
853
699
|
return false;
|
|
@@ -855,92 +701,78 @@ var usePagination = exports.usePagination = function usePagination(_ref) {
|
|
|
855
701
|
event.currentTarget.classList.remove("ng-invalid");
|
|
856
702
|
return true;
|
|
857
703
|
}, []);
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
// Update page size and reset to first page (similar to Angular behavior)
|
|
874
|
-
setPaginationState(function (prev) {
|
|
875
|
-
// Calculate new page count
|
|
876
|
-
var newPageCount = calculatePagingValues(dataSize, pageSize);
|
|
877
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
878
|
-
currentMaxResults: pageSize,
|
|
879
|
-
currentPage: 1,
|
|
880
|
-
// Always go to first page like Angular
|
|
881
|
-
pageCount: newPageCount
|
|
704
|
+
const handlePageSizeChange = useCallback(
|
|
705
|
+
(event, pageSize) => {
|
|
706
|
+
const { currentMaxResults: oldPageSize, currentPage: oldPage, dataSize } = paginationState;
|
|
707
|
+
const actualPageSize = oldPageSize;
|
|
708
|
+
if (isDataSourceHasPaging(datasource) && datasource) {
|
|
709
|
+
datasource.maxResults = pageSize;
|
|
710
|
+
}
|
|
711
|
+
setPaginationState((prev) => {
|
|
712
|
+
const newPageCount = calculatePagingValues(dataSize, pageSize);
|
|
713
|
+
return __spreadProps(__spreadValues({}, prev), {
|
|
714
|
+
currentMaxResults: pageSize,
|
|
715
|
+
currentPage: 1,
|
|
716
|
+
// Always go to first page like Angular
|
|
717
|
+
pageCount: newPageCount
|
|
718
|
+
});
|
|
882
719
|
});
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
if (setIsLoadingMore) {
|
|
918
|
-
setIsLoadingMore(false);
|
|
919
|
-
}
|
|
920
|
-
})["catch"](function () {
|
|
921
|
-
// Clear loading state on error
|
|
720
|
+
if (setIsLoadingMore) {
|
|
721
|
+
setIsLoadingMore(true);
|
|
722
|
+
}
|
|
723
|
+
if (pageSizeChangeHandler) {
|
|
724
|
+
pageSizeChangeHandler(pageSize);
|
|
725
|
+
}
|
|
726
|
+
if (isServerSidePagination) {
|
|
727
|
+
datasourceInvoke(1, pageSize).then(() => {
|
|
728
|
+
if (onPaginationChange) {
|
|
729
|
+
onPaginationChange(event || createDummyEvent("paginationchange"), widgetInstance, 1);
|
|
730
|
+
}
|
|
731
|
+
if (onSetRecord) {
|
|
732
|
+
const data = isArray(dataState.fullData) ? dataState.fullData.slice(0, pageSize) : dataState.fullData;
|
|
733
|
+
const newPageCount = calculatePagingValues(dataState.fullData.length, pageSize);
|
|
734
|
+
const pageInfo = {
|
|
735
|
+
currentPage: 1,
|
|
736
|
+
size: pageSize,
|
|
737
|
+
totalElements: (paginationMeta == null ? void 0 : paginationMeta.totalElements) || dataState.fullData.length,
|
|
738
|
+
totalPages: newPageCount
|
|
739
|
+
};
|
|
740
|
+
onSetRecord(event || createDummyEvent("setrecord"), widgetInstance, data, pageInfo);
|
|
741
|
+
}
|
|
742
|
+
if (setIsLoadingMore) {
|
|
743
|
+
setIsLoadingMore(false);
|
|
744
|
+
}
|
|
745
|
+
}).catch(() => {
|
|
746
|
+
if (setIsLoadingMore) {
|
|
747
|
+
setIsLoadingMore(false);
|
|
748
|
+
}
|
|
749
|
+
});
|
|
750
|
+
} else {
|
|
751
|
+
setTimeout(() => {
|
|
752
|
+
navigatePage("first", event, true);
|
|
753
|
+
}, 0);
|
|
922
754
|
if (setIsLoadingMore) {
|
|
923
755
|
setIsLoadingMore(false);
|
|
924
756
|
}
|
|
925
|
-
});
|
|
926
|
-
} else {
|
|
927
|
-
// For client-side pagination, navigate to first page
|
|
928
|
-
setTimeout(function () {
|
|
929
|
-
navigatePage("first", event, true);
|
|
930
|
-
}, 0);
|
|
931
|
-
|
|
932
|
-
// Clear loading state immediately for client-side pagination
|
|
933
|
-
if (setIsLoadingMore) {
|
|
934
|
-
setIsLoadingMore(false);
|
|
935
757
|
}
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
758
|
+
},
|
|
759
|
+
[
|
|
760
|
+
pageSizeChangeHandler,
|
|
761
|
+
navigatePage,
|
|
762
|
+
datasource,
|
|
763
|
+
paginationState,
|
|
764
|
+
isServerSidePagination,
|
|
765
|
+
datasourceInvoke,
|
|
766
|
+
onPaginationChange,
|
|
767
|
+
onSetRecord,
|
|
768
|
+
widgetInstance,
|
|
769
|
+
dataState.fullData,
|
|
770
|
+
setIsLoadingMore,
|
|
771
|
+
paginationMeta
|
|
772
|
+
]
|
|
773
|
+
);
|
|
774
|
+
useEffect(() => {
|
|
941
775
|
setNavcontrols(getValidNavControl(navigation));
|
|
942
|
-
|
|
943
|
-
// Reset accumulated data state when navigation changes to Scroll or On-Demand
|
|
944
776
|
if (navigation === "Scroll" || navigation === "On-Demand") {
|
|
945
777
|
setAccumulatingState({
|
|
946
778
|
accumulatedData: [],
|
|
@@ -950,100 +782,65 @@ var usePagination = exports.usePagination = function usePagination(_ref) {
|
|
|
950
782
|
});
|
|
951
783
|
}
|
|
952
784
|
}, [navigation]);
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
// Check if we're in accumulating mode (Scroll or On-Demand with server-side pagination)
|
|
958
|
-
var isAccumulatingMode = (navigation === "Scroll" || navigation === "On-Demand") && isServerSidePagination;
|
|
959
|
-
|
|
960
|
-
// For accumulating mode, only process dataset updates if accumulated data is empty
|
|
961
|
-
// This prevents overwriting accumulated data when datasource updates with new page data
|
|
962
|
-
// Also skip if we're currently resetting (to prevent old dataset from overwriting reset)
|
|
785
|
+
useEffect(() => {
|
|
786
|
+
if (dataset !== void 0) {
|
|
787
|
+
const processedDataset = extractDataArray(dataset);
|
|
788
|
+
const isAccumulatingMode = (navigation === "Scroll" || navigation === "On-Demand") && isServerSidePagination;
|
|
963
789
|
if (isAccumulatingMode) {
|
|
964
|
-
|
|
965
|
-
// Only process dataset if accumulated data is empty (initial load or after reset)
|
|
966
|
-
// AND we're not currently in the middle of a reset operation
|
|
790
|
+
const currentAccumulatedData = accumulatingStateRef.current.accumulatedData;
|
|
967
791
|
if (currentAccumulatedData.length === 0 && !isResettingRef.current) {
|
|
968
|
-
setPagingValues(
|
|
792
|
+
setPagingValues(processedDataset);
|
|
969
793
|
}
|
|
970
794
|
} else {
|
|
971
|
-
|
|
972
|
-
setPagingValues(dataset);
|
|
795
|
+
setPagingValues(processedDataset);
|
|
973
796
|
}
|
|
974
797
|
}
|
|
975
798
|
}, [dataset, setPagingValues, navigation, isServerSidePagination]);
|
|
976
|
-
|
|
977
|
-
// For server-side pagination, update dataSize and pageCount based on metadata
|
|
978
|
-
(0, _react.useEffect)(function () {
|
|
799
|
+
useEffect(() => {
|
|
979
800
|
if (isServerSidePagination) {
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
var updates = {
|
|
801
|
+
const totalCount = totalItems != null ? totalItems : paginationMeta == null ? void 0 : paginationMeta.totalElements;
|
|
802
|
+
if (totalCount !== void 0 && totalCount >= 0) {
|
|
803
|
+
setPaginationState((prev) => {
|
|
804
|
+
let updates = {
|
|
985
805
|
dataSize: totalCount
|
|
986
806
|
};
|
|
987
|
-
|
|
988
|
-
// If totalPages not provided, calculate it
|
|
989
|
-
if ((paginationMeta === null || paginationMeta === void 0 ? void 0 : paginationMeta.totalPages) !== undefined) {
|
|
807
|
+
if ((paginationMeta == null ? void 0 : paginationMeta.totalPages) !== void 0) {
|
|
990
808
|
updates.pageCount = paginationMeta.totalPages;
|
|
991
809
|
} else if (prev.currentMaxResults > 0) {
|
|
992
810
|
updates.pageCount = Math.ceil(totalCount / prev.currentMaxResults) || 1;
|
|
993
811
|
}
|
|
994
|
-
|
|
995
|
-
// Handle edge case: current page is out of range
|
|
996
|
-
if (paginationMeta !== null && paginationMeta !== void 0 && paginationMeta.totalPages && prev.currentPage > paginationMeta.totalPages) {
|
|
812
|
+
if ((paginationMeta == null ? void 0 : paginationMeta.totalPages) && prev.currentPage > paginationMeta.totalPages) {
|
|
997
813
|
updates.currentPage = Math.max(1, paginationMeta.totalPages);
|
|
998
814
|
}
|
|
999
|
-
|
|
1000
|
-
// Handle empty results
|
|
1001
815
|
if (totalCount === 0) {
|
|
1002
|
-
updates.pageCount = 1;
|
|
816
|
+
updates.pageCount = 1;
|
|
1003
817
|
updates.currentPage = 1;
|
|
1004
818
|
}
|
|
1005
|
-
return
|
|
819
|
+
return __spreadValues(__spreadValues({}, prev), updates);
|
|
1006
820
|
});
|
|
1007
821
|
}
|
|
1008
822
|
}
|
|
1009
823
|
}, [isServerSidePagination, totalItems, paginationMeta]);
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
if (initialPage !== undefined && initialPage !== paginationState.currentPage) {
|
|
1014
|
-
setPaginationState(function (prev) {
|
|
1015
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
1016
|
-
currentPage: initialPage
|
|
1017
|
-
});
|
|
1018
|
-
});
|
|
1019
|
-
// Update navigation buttons when page changes
|
|
824
|
+
useEffect(() => {
|
|
825
|
+
if (initialPage !== void 0 && initialPage !== paginationState.currentPage) {
|
|
826
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { currentPage: initialPage }));
|
|
1020
827
|
disableNavigation();
|
|
1021
828
|
}
|
|
1022
829
|
}, [initialPage, paginationState.currentPage, disableNavigation]);
|
|
1023
|
-
|
|
1024
|
-
// Sync currentMaxResults when maxResults prop changes (e.g. when table passes updated page size from script/broadcast)
|
|
1025
|
-
(0, _react.useEffect)(function () {
|
|
830
|
+
useEffect(() => {
|
|
1026
831
|
if (maxResults !== paginationState.currentMaxResults) {
|
|
1027
|
-
setPaginationState(
|
|
1028
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
1029
|
-
currentMaxResults: maxResults
|
|
1030
|
-
});
|
|
1031
|
-
});
|
|
832
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { currentMaxResults: maxResults }));
|
|
1032
833
|
}
|
|
1033
834
|
}, [maxResults, paginationState.currentMaxResults]);
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
(0, _react.useEffect)(function () {
|
|
1037
|
-
var _scrollContainerRef$c;
|
|
835
|
+
useEffect(() => {
|
|
836
|
+
var _a2;
|
|
1038
837
|
if (!accumulatingState.isInitialized || !sentinelRef.current || navigation !== "Scroll") return;
|
|
1039
|
-
|
|
838
|
+
const scrollRoot = isRowScroll ? (_a2 = scrollContainerRef == null ? void 0 : scrollContainerRef.current) != null ? _a2 : null : null;
|
|
1040
839
|
if (isRowScroll && !scrollRoot) return;
|
|
1041
840
|
setupInfiniteScrollObserver(sentinelRef.current, scrollRoot);
|
|
1042
841
|
}, [accumulatingState.isInitialized, navigation, setupInfiniteScrollObserver, isRowScroll]);
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
(0, _react.useEffect)(function () {
|
|
1046
|
-
return function () {
|
|
842
|
+
useEffect(() => {
|
|
843
|
+
return () => {
|
|
1047
844
|
if (observerRef.current) {
|
|
1048
845
|
observerRef.current.disconnect();
|
|
1049
846
|
observerRef.current = null;
|
|
@@ -1056,7 +853,7 @@ var usePagination = exports.usePagination = function usePagination(_ref) {
|
|
|
1056
853
|
pageCount: paginationState.pageCount,
|
|
1057
854
|
dataSize: paginationState.dataSize,
|
|
1058
855
|
result: dataState.result,
|
|
1059
|
-
navcontrols
|
|
856
|
+
navcontrols,
|
|
1060
857
|
currentMaxResults: paginationState.currentMaxResults,
|
|
1061
858
|
error: paginationState.error,
|
|
1062
859
|
// Disable states
|
|
@@ -1067,29 +864,28 @@ var usePagination = exports.usePagination = function usePagination(_ref) {
|
|
|
1067
864
|
isDisableCurrent: disableStates.isDisableCurrent,
|
|
1068
865
|
isDisableCount: disableStates.isDisableCount,
|
|
1069
866
|
// Actions
|
|
1070
|
-
navigatePage
|
|
1071
|
-
handlePageChange
|
|
1072
|
-
handleInputChange
|
|
1073
|
-
onModelChange
|
|
1074
|
-
onKeyDown
|
|
1075
|
-
setDn:
|
|
1076
|
-
|
|
1077
|
-
return _objectSpread(_objectSpread({}, prev), value);
|
|
1078
|
-
});
|
|
1079
|
-
},
|
|
1080
|
-
handlePageSizeChange: handlePageSizeChange,
|
|
867
|
+
navigatePage,
|
|
868
|
+
handlePageChange,
|
|
869
|
+
handleInputChange,
|
|
870
|
+
onModelChange,
|
|
871
|
+
onKeyDown,
|
|
872
|
+
setDn: (value) => setPaginationState((prev) => __spreadValues(__spreadValues({}, prev), value)),
|
|
873
|
+
handlePageSizeChange,
|
|
1081
874
|
// Utilities
|
|
1082
|
-
isFirstPage
|
|
1083
|
-
isLastPage
|
|
875
|
+
isFirstPage,
|
|
876
|
+
isLastPage,
|
|
1084
877
|
isFetching: isFetchingRef.current,
|
|
1085
878
|
// Infinite scroll specific
|
|
1086
|
-
setupInfiniteScrollObserver
|
|
1087
|
-
sentinelRef
|
|
879
|
+
setupInfiniteScrollObserver,
|
|
880
|
+
sentinelRef,
|
|
1088
881
|
isLoadingMore: isFetchingRef.current && (navigation === "Scroll" || navigation === "On-Demand") && accumulatingStateRef.current.lastLoadedPage > 0,
|
|
1089
882
|
hasMoreData: !isLastPage && (navigation === "Scroll" || navigation === "On-Demand"),
|
|
1090
883
|
// On-Demand specific
|
|
1091
|
-
loadMoreData
|
|
1092
|
-
resetAccumulatedData
|
|
884
|
+
loadMoreData,
|
|
885
|
+
resetAccumulatedData,
|
|
1093
886
|
accumulatedDataCount: accumulatingStateRef.current.accumulatedData.length
|
|
1094
887
|
};
|
|
1095
|
-
};
|
|
888
|
+
};
|
|
889
|
+
export {
|
|
890
|
+
usePagination
|
|
891
|
+
};
|