@wavemaker-ai/react-runtime 1.0.0-rc.647502 → 1.0.0-rc.647565
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.npmignore +4 -0
- package/actions/base-action.js +12 -29
- package/actions/login-action.js +35 -52
- package/actions/logout-action.js +21 -38
- package/actions/navigation-action.js +251 -346
- package/actions/notification-action.js +121 -149
- package/actions/timer-action.js +95 -151
- package/actions/toast-provider.js +62 -76
- package/actions/toast.js +95 -91
- package/actions/toast.service.js +59 -79
- package/actions/types/index.js +6 -9
- package/components/advanced/carousel/index.js +358 -366
- package/components/advanced/carousel/props.js +0 -5
- package/components/advanced/carousel/template.js +102 -80
- package/components/advanced/login/index.js +227 -285
- package/components/advanced/login/props.js +0 -5
- package/components/advanced/marquee/index.js +169 -163
- package/components/advanced/marquee/props.js +0 -5
- package/components/basic/anchor/index.js +207 -187
- package/components/basic/anchor/props.js +0 -5
- package/components/basic/audio/index.js +110 -72
- package/components/basic/audio/props.js +0 -5
- package/components/basic/html/index.js +163 -203
- package/components/basic/html/props.js +0 -5
- package/components/basic/html/utils.js +30 -28
- package/components/basic/icon/index.js +98 -84
- package/components/basic/icon/props.js +0 -5
- package/components/basic/iframe/iframe.utils.js +7 -16
- package/components/basic/iframe/index.js +97 -103
- package/components/basic/iframe/props.js +0 -5
- package/components/basic/label/index.js +156 -134
- package/components/basic/label/props.js +0 -5
- package/components/basic/message/index.js +129 -113
- package/components/basic/message/props.js +0 -5
- package/components/basic/picture/index.js +156 -127
- package/components/basic/picture/props.js +0 -5
- package/components/basic/progress-bar/index.js +240 -176
- package/components/basic/progress-bar/props.js +5 -31
- package/components/basic/progress-circle/index.js +166 -183
- package/components/basic/progress-circle/props.js +14 -34
- package/components/basic/richtexteditor/index.js +430 -396
- package/components/basic/richtexteditor/props.js +0 -5
- package/components/basic/search/index.js +812 -931
- package/components/basic/search/props.js +0 -5
- package/components/basic/search/providers.js +233 -380
- package/components/basic/spinner/index.js +210 -200
- package/components/basic/spinner/props.js +4 -22
- package/components/basic/tile/index.js +73 -81
- package/components/basic/tile/props.js +0 -5
- package/components/basic/tree/Components/TreeNodeComponent.js +238 -170
- package/components/basic/tree/hooks/useTreePartialNodeApi.js +143 -135
- package/components/basic/tree/index.js +378 -454
- package/components/basic/tree/props.js +0 -5
- package/components/basic/tree/utils.js +129 -185
- package/components/basic/video/index.js +161 -107
- package/components/basic/video/props.js +0 -5
- package/components/chart/index.js +42 -50
- package/components/chart/props.js +31 -37
- package/components/chart/src/ChartRenderer.js +172 -154
- package/components/chart/src/chart.js +391 -213
- package/components/chart/src/chartStyles.generated.js +6 -14
- package/components/chart/src/chartUtils.js +228 -272
- package/components/chart/src/constants.d.ts +13 -0
- package/components/chart/src/constants.js +316 -90
- package/components/chart/src/d3Setup.js +11 -30
- package/components/chart/src/dataUtils.js +362 -446
- package/components/chart/src/formatUtils.js +47 -38
- package/components/chart/src/index.js +11 -19
- package/components/chart/src/nvd3Source.generated.js +5 -13
- package/components/chart/src/pieDonutResponsiveLayout.d.ts +5 -0
- package/components/chart/src/pieDonutResponsiveLayout.js +76 -96
- package/components/chart/src/types.js +0 -5
- package/components/common/AppSpinner.js +17 -33
- package/components/common/app-spinner.js +11 -22
- package/components/common/customTemplate/index.d.ts +3 -0
- package/components/common/customTemplate/index.js +6 -0
- package/components/common/customTemplate/props.d.ts +20 -0
- package/components/common/customTemplate/props.js +0 -0
- package/components/common/customTemplate/template.d.ts +3 -0
- package/components/common/customTemplate/template.js +27 -0
- package/components/common/customTemplate/useCustomTemplate.d.ts +8 -0
- package/components/common/customTemplate/useCustomTemplate.js +17 -0
- package/components/common/customTemplate/utils.d.ts +6 -0
- package/components/common/customTemplate/utils.js +12 -0
- package/components/common/index.js +4 -12
- package/components/constants.js +81 -77
- package/components/container/accordion/accordion-pane/index.js +105 -118
- package/components/container/accordion/accordion-pane/props.js +5 -21
- package/components/container/accordion/index.js +225 -243
- package/components/container/accordion/props.js +5 -16
- package/components/container/index.js +214 -150
- package/components/container/layout-grid/grid-column/index.js +68 -43
- package/components/container/layout-grid/grid-column/props.js +0 -5
- package/components/container/layout-grid/grid-row/index.js +12 -29
- package/components/container/layout-grid/grid-row/props.js +0 -5
- package/components/container/layout-grid/index.js +53 -38
- package/components/container/layout-grid/props.js +0 -5
- package/components/container/linear-layout/index.js +56 -60
- package/components/container/linear-layout/linear-layout-item/index.js +43 -47
- package/components/container/linear-layout/linear-layout-item/props.js +0 -5
- package/components/container/linear-layout/props.js +0 -5
- package/components/container/panel/components/panel-content/index.js +7 -16
- package/components/container/panel/components/panel-header/index.js +166 -146
- package/components/container/panel/components/panel-header/props.js +0 -5
- package/components/container/panel/hooks.js +76 -102
- package/components/container/panel/index.js +289 -252
- package/components/container/panel/props.js +0 -5
- package/components/container/props.js +0 -5
- package/components/container/repeat-template/index.js +65 -44
- package/components/container/repeat-template/props.js +0 -5
- package/components/container/tabs/index.js +517 -526
- package/components/container/tabs/props.js +5 -28
- package/components/container/tabs/tab-pane/index.js +105 -100
- package/components/container/tabs/tab-pane/props.js +0 -5
- package/components/container/tabs/utils.js +30 -35
- package/components/container/wizard/WizardContext.js +9 -11
- package/components/container/wizard/components/StepComponents.js +76 -99
- package/components/container/wizard/components/WizardStep.js +107 -85
- package/components/container/wizard/index.js +791 -921
- package/components/container/wizard/props.js +0 -5
- package/components/container/wizard/utils.js +97 -131
- package/components/container/wizard/wizard-action/index.js +41 -81
- package/components/container/wizard/wizard-step/index.js +140 -120
- package/components/data/card/card-actions/index.js +13 -31
- package/components/data/card/card-content/index.js +27 -36
- package/components/data/card/card-footer/index.js +13 -31
- package/components/data/card/index.js +192 -199
- package/components/data/card/props.js +0 -5
- package/components/data/form/base-form/constant.js +5 -8
- package/components/data/form/base-form/hooks/index.js +26 -77
- package/components/data/form/base-form/hooks/useFormDataSync.js +106 -212
- package/components/data/form/base-form/hooks/useFormOperations.js +109 -161
- package/components/data/form/base-form/hooks/useFormSubmission.js +220 -280
- package/components/data/form/base-form/hooks/useFormValidation.js +119 -168
- package/components/data/form/base-form/hooks/useParentFormRelationship.js +67 -103
- package/components/data/form/base-form/index.js +531 -646
- package/components/data/form/base-form/props.js +74 -151
- package/components/data/form/base-form/utils.js +210 -323
- package/components/data/form/dynamic-fields/constant.js +43 -53
- package/components/data/form/dynamic-fields/index.js +135 -144
- package/components/data/form/dynamic-fields/props.js +0 -5
- package/components/data/form/dynamic-fields/utils.js +99 -158
- package/components/data/form/form-action/index.js +107 -85
- package/components/data/form/form-body/index.js +52 -26
- package/components/data/form/form-context.js +43 -59
- package/components/data/form/form-controller/hooks/index.js +43 -57
- package/components/data/form/form-controller/props.js +5 -8
- package/components/data/form/form-controller/utils.js +54 -49
- package/components/data/form/form-controller/validation-contrustor.js +203 -426
- package/components/data/form/form-controller/withFormController.js +319 -269
- package/components/data/form/form-dynamic-section/index.js +47 -41
- package/components/data/form/form-dynamic-section/props.js +0 -5
- package/components/data/form/form-field/base-field.js +97 -109
- package/components/data/form/form-field/index.js +91 -82
- package/components/data/form/form-field/props.js +0 -5
- package/components/data/form/form-footer/index.js +52 -25
- package/components/data/form/form-header/index.js +61 -58
- package/components/data/form/index.js +95 -74
- package/components/data/form/props.js +0 -5
- package/components/data/list/components/GroupHeader.js +34 -33
- package/components/data/list/components/GroupedListItems.js +108 -104
- package/components/data/list/components/ListContainer.js +22 -27
- package/components/data/list/components/ListDND.js +193 -185
- package/components/data/list/components/ListHeader.js +32 -49
- package/components/data/list/components/ListItem.js +153 -146
- package/components/data/list/components/ListItemWithTemplate.js +87 -105
- package/components/data/list/components/ListItems.js +180 -194
- package/components/data/list/components/ListPagination.js +127 -153
- package/components/data/list/components/LoadMoreButton.js +25 -33
- package/components/data/list/components/NoDataMessage.js +9 -22
- package/components/data/list/components/StandardListItems.js +79 -85
- package/components/data/list/components/index.js +31 -119
- package/components/data/list/components/props.js +0 -5
- package/components/data/list/hooks/index.js +22 -75
- package/components/data/list/hooks/props.js +0 -5
- package/components/data/list/hooks/useCurrentPageItems.js +20 -38
- package/components/data/list/hooks/useGroupedData.js +19 -33
- package/components/data/list/hooks/useListData.js +17 -47
- package/components/data/list/hooks/useListEffects.js +168 -237
- package/components/data/list/hooks/useListEventHandlers.js +301 -285
- package/components/data/list/hooks/useListPagination.js +90 -136
- package/components/data/list/hooks/useListState.js +49 -91
- package/components/data/list/hooks/useListStateManager.js +104 -159
- package/components/data/list/hooks/usePaginatedGroupedData.js +74 -110
- package/components/data/list/index.d.ts +1 -0
- package/components/data/list/index.js +579 -621
- package/components/data/list/props.d.ts +4 -0
- package/components/data/list/props.js +0 -5
- package/components/data/list/templates/media-template.js +29 -50
- package/components/data/list/utils/constants.js +20 -32
- package/components/data/list/utils/list-helpers.d.ts +2 -1
- package/components/data/list/utils/list-helpers.js +71 -115
- package/components/data/list/utils/list-widget-methods.js +56 -76
- package/components/data/list/utils/widget-instance-utils.js +20 -57
- package/components/data/live-filter/index.js +219 -271
- package/components/data/live-filter/props.js +5 -12
- package/components/data/live-form/index.js +68 -91
- package/components/data/live-form/props.js +5 -12
- package/components/data/pagination/components/BasicPagination.js +124 -104
- package/components/data/pagination/components/ClassicPagination.js +167 -190
- package/components/data/pagination/components/InlinePagination.js +97 -98
- package/components/data/pagination/components/LoadingComponent.js +17 -30
- package/components/data/pagination/components/PageSizeSelector.js +176 -169
- package/components/data/pagination/components/PagerNavigation.js +84 -105
- package/components/data/pagination/components/TotalRecords.js +48 -47
- package/components/data/pagination/components/index.js +14 -47
- package/components/data/pagination/components/props.js +0 -5
- package/components/data/pagination/hooks/index.js +6 -19
- package/components/data/pagination/hooks/props.js +0 -5
- package/components/data/pagination/hooks/useNavigationSize.js +12 -21
- package/components/data/pagination/hooks/usePagination.js +702 -905
- package/components/data/pagination/index.js +336 -389
- package/components/data/table/components/AddNewRow.js +122 -154
- package/components/data/table/components/EditableCell.js +68 -75
- package/components/data/table/components/FieldValidationError.js +19 -20
- package/components/data/table/components/RowCells.js +97 -80
- package/components/data/table/components/RowExpansionButton.js +43 -39
- package/components/data/table/components/SummaryCell.js +54 -88
- package/components/data/table/components/SummaryRow.js +45 -52
- package/components/data/table/components/SummaryRowFooter.js +35 -42
- package/components/data/table/components/TableBody.js +222 -218
- package/components/data/table/components/TableDataRow.js +113 -106
- package/components/data/table/components/TableFilters.js +391 -390
- package/components/data/table/components/TableFooterActions.js +25 -32
- package/components/data/table/components/TableHeader.js +460 -435
- package/components/data/table/components/TablePanelHeading.js +157 -181
- package/components/data/table/components/index.js +27 -95
- package/components/data/table/hooks/index.js +21 -230
- package/components/data/table/hooks/use-edited-rows.js +59 -94
- package/components/data/table/hooks/useCellState.js +58 -83
- package/components/data/table/hooks/useCustomExpressionColumns.js +65 -86
- package/components/data/table/hooks/useDynamicColumns.js +59 -92
- package/components/data/table/hooks/useEditingState.js +30 -41
- package/components/data/table/hooks/useFormWidget.js +163 -172
- package/components/data/table/hooks/usePaginationState.js +67 -77
- package/components/data/table/hooks/usePanelStructure.js +47 -41
- package/components/data/table/hooks/useResponsiveColumns.js +14 -20
- package/components/data/table/hooks/useRowExpansion.js +131 -127
- package/components/data/table/hooks/useRowHandlers.js +56 -69
- package/components/data/table/hooks/useRowSelection.js +249 -329
- package/components/data/table/hooks/useServerSideSorting.js +109 -175
- package/components/data/table/hooks/useTableColumns.js +322 -331
- package/components/data/table/hooks/useTableData.js +111 -166
- package/components/data/table/hooks/useTableEdit.js +526 -564
- package/components/data/table/hooks/useTableEffects.js +60 -107
- package/components/data/table/hooks/useTableFilter.js +244 -237
- package/components/data/table/hooks/useTableInitialization.js +44 -76
- package/components/data/table/hooks/useTableState.js +39 -61
- package/components/data/table/hooks/useTableStateManager.js +295 -468
- package/components/data/table/index.js +1553 -1713
- package/components/data/table/live-table/index.js +157 -219
- package/components/data/table/props.js +0 -5
- package/components/data/table/table-action/index.js +97 -75
- package/components/data/table/table-column/index.js +48 -42
- package/components/data/table/table-group/index.js +7 -25
- package/components/data/table/table-row/index.js +63 -55
- package/components/data/table/table-row-action/index.js +102 -77
- package/components/data/table/utils/buildSelectionColumns.js +86 -137
- package/components/data/table/utils/columnBuilder.js +116 -158
- package/components/data/table/utils/columnProxy.js +48 -66
- package/components/data/table/utils/columnWidthDistribution.js +40 -64
- package/components/data/table/utils/constants.js +92 -40
- package/components/data/table/utils/crud-handlers.js +292 -473
- package/components/data/table/utils/dynamic-columns.js +99 -144
- package/components/data/table/utils/groupHeaderUtils.js +36 -61
- package/components/data/table/utils/index.d.ts +8 -5
- package/components/data/table/utils/index.js +419 -639
- package/components/data/table/utils/renderDisplayCell.js +127 -169
- package/components/data/table/utils/script-page-size-broadcast.js +17 -29
- package/components/data/table/utils/selectionUtils.js +59 -113
- package/components/data/table/utils/table-helpers.js +38 -74
- package/components/data/table/utils/validation.js +35 -78
- package/components/data/table/utils/widgetMapping.d.ts +5 -0
- package/components/data/table/utils/widgetMapping.js +41 -0
- package/components/data/types.js +112 -112
- package/components/data/utils/field-data-utils.js +38 -42
- package/components/data/utils/filter-field-util.js +42 -44
- package/components/data/utils/index.js +112 -111
- package/components/dialogs/alert-dialog/index.js +83 -78
- package/components/dialogs/alert-dialog/props.js +0 -5
- package/components/dialogs/confirm-dialog/index.js +102 -92
- package/components/dialogs/confirm-dialog/props.js +0 -5
- package/components/dialogs/dialog/index.js +93 -69
- package/components/dialogs/dialog/props.js +0 -5
- package/components/dialogs/dialog-actions/index.js +12 -26
- package/components/dialogs/dialog-actions/props.js +0 -5
- package/components/dialogs/dialog-body/index.js +13 -30
- package/components/dialogs/dialog-body/props.js +0 -5
- package/components/dialogs/dialog-content/index.js +48 -41
- package/components/dialogs/dialog-content/props.js +0 -5
- package/components/dialogs/dialog-header/index.js +88 -101
- package/components/dialogs/dialog-header/props.js +0 -5
- package/components/dialogs/iframe-dialog/index.js +136 -128
- package/components/dialogs/iframe-dialog/props.js +0 -5
- package/components/dialogs/index.js +104 -101
- package/components/dialogs/login-dialog/index.js +285 -347
- package/components/dialogs/login-dialog/props.js +0 -5
- package/components/dialogs/page-dialog/index.js +95 -86
- package/components/dialogs/page-dialog/props.js +0 -5
- package/components/dialogs/props.js +0 -5
- package/components/dialogs/withDialogWrapper.js +110 -83
- package/components/form/button/index.js +296 -245
- package/components/form/button/props.js +0 -5
- package/components/form/button-group/index.js +80 -69
- package/components/form/button-group/props.js +0 -5
- package/components/input/calendar/index.js +409 -362
- package/components/input/calendar/props.js +0 -5
- package/components/input/calendar/utils.js +164 -172
- package/components/input/chips/SortableChip/index.js +109 -100
- package/components/input/chips/SortableChip/props.js +0 -5
- package/components/input/chips/index.js +663 -570
- package/components/input/chips/props.js +0 -5
- package/components/input/chips/utils.js +131 -122
- package/components/input/color-picker/index.js +536 -594
- package/components/input/color-picker/props.js +0 -5
- package/components/input/composite/index.js +71 -110
- package/components/input/composite/props.js +0 -5
- package/components/input/currency/index.js +277 -224
- package/components/input/currency/props.js +0 -5
- package/components/input/default/checkbox/index.js +329 -250
- package/components/input/default/checkbox/props.js +0 -5
- package/components/input/default/checkboxset/index.d.ts +2 -0
- package/components/input/default/checkboxset/index.js +529 -446
- package/components/input/default/checkboxset/props.d.ts +4 -0
- package/components/input/default/checkboxset/props.js +0 -5
- package/components/input/default/checkboxset/utils.js +15 -25
- package/components/input/default/radioset/index.d.ts +2 -0
- package/components/input/default/radioset/index.js +409 -350
- package/components/input/default/radioset/props.d.ts +6 -0
- package/components/input/default/radioset/props.js +0 -5
- package/components/input/default/switch/index.js +494 -458
- package/components/input/default/switch/prop.js +0 -5
- package/components/input/epoch/date/components/DatePickerPopover.js +242 -193
- package/components/input/epoch/date/index.js +638 -518
- package/components/input/epoch/date/props.js +0 -5
- package/components/input/epoch/date/styled.js +61 -70
- package/components/input/epoch/date/utils.js +67 -115
- package/components/input/epoch/datetime/index.js +758 -695
- package/components/input/epoch/datetime/props.js +0 -5
- package/components/input/epoch/datetime/utils.js +121 -186
- package/components/input/epoch/time/index.js +441 -415
- package/components/input/epoch/time/props.js +0 -5
- package/components/input/epoch/time/utils.js +101 -112
- package/components/input/fileupload/Utils.js +70 -97
- package/components/input/fileupload/components/ListItems.js +132 -130
- package/components/input/fileupload/components/MultiUpload.js +80 -77
- package/components/input/fileupload/components/SingleUpload.js +57 -57
- package/components/input/fileupload/index.js +253 -178
- package/components/input/fileupload/props.js +0 -5
- package/components/input/fileupload/useFileUpload.js +209 -258
- package/components/input/number/index.js +434 -393
- package/components/input/number/props.js +0 -5
- package/components/input/rating/index.js +401 -394
- package/components/input/rating/props.js +0 -5
- package/components/input/select/index.js +408 -463
- package/components/input/select/props.js +0 -5
- package/components/input/slider/index.js +339 -332
- package/components/input/slider/props.js +0 -5
- package/components/input/text/index.d.ts +3 -3
- package/components/input/text/index.js +438 -475
- package/components/input/text/props.d.ts +1 -1
- package/components/input/text/props.js +0 -5
- package/components/input/text/util.js +82 -222
- package/components/input/textarea/index.js +322 -358
- package/components/input/textarea/props.js +0 -5
- package/components/input/upload/index.js +135 -131
- package/components/input/upload/props.js +0 -5
- package/components/input/util/index.js +9 -11
- package/components/layout/footer/index.js +12 -35
- package/components/layout/footer/props.js +0 -5
- package/components/layout/header/index.js +12 -38
- package/components/layout/header/props.js +0 -5
- package/components/layout/leftnav/index.js +38 -44
- package/components/layout/leftnav/props.js +0 -5
- package/components/layout/rightnav/index.js +12 -36
- package/components/layout/rightnav/props.js +0 -5
- package/components/layout/topnav/index.js +24 -38
- package/components/layout/topnav/props.js +0 -5
- package/components/navbar/index.js +119 -98
- package/components/navbar/nav/index.js +236 -232
- package/components/navbar/nav/props.js +0 -5
- package/components/navbar/nav-item/index.js +74 -65
- package/components/navbar/nav-item/props.js +0 -5
- package/components/navigation/breadcrumb/index.js +38 -61
- package/components/navigation/breadcrumb/props.js +0 -5
- package/components/navigation/menu/components/ListItems.js +76 -67
- package/components/navigation/menu/constants.js +27 -42
- package/components/navigation/menu/hooks/useHoverState.hook.js +20 -47
- package/components/navigation/menu/hooks/useKeyboardMovements.hook.js +34 -28
- package/components/navigation/menu/hooks/useTransformedDataset.hook.js +21 -14
- package/components/navigation/menu/index.js +911 -846
- package/components/navigation/menu/props.js +0 -5
- package/components/navigation/menu/utils/action-task.js +6 -9
- package/components/navigation/menu/utils/role-filter.js +41 -56
- package/components/navigation/popover/index.js +191 -205
- package/components/navigation/popover/props.js +5 -8
- package/components/page/content/index.js +9 -31
- package/components/page/content/props.js +0 -5
- package/components/page/error-boundary/index.js +115 -105
- package/components/page/error-boundary/props.js +0 -5
- package/components/page/index.js +84 -102
- package/components/page/page-content/index.js +21 -30
- package/components/page/page-content/props.js +0 -5
- package/components/page/partial/index.js +50 -45
- package/components/page/partial/props.js +0 -5
- package/components/page/partial-container/index.js +81 -107
- package/components/page/partial-container/props.d.ts +1 -1
- package/components/page/partial-container/props.js +0 -5
- package/components/page/props.js +0 -5
- package/components/page/toast-container/index.js +20 -41
- package/components/page/toast-container/props.js +0 -5
- package/components/prefab/container/index.js +60 -53
- package/components/prefab/container/props.js +0 -5
- package/components/prefab/index.js +76 -61
- package/components/prefab/props.js +0 -5
- package/context/AppContext.d.ts +1 -1
- package/context/AppContext.js +17 -18
- package/context/AppSpinnerProvider.js +19 -34
- package/context/LayoutProvider.js +54 -57
- package/context/LocalizationProvider.js +34 -49
- package/context/PrefabContext.js +68 -119
- package/context/WidgetProvider.js +160 -166
- package/core/app-config.js +0 -1
- package/core/app.service.js +200 -327
- package/core/appVariablesStore.js +10 -15
- package/core/appstore.js +37 -53
- package/core/constants/currency-constant.js +81 -83
- package/core/constants/events.js +34 -44
- package/core/constants/index.js +21 -31
- package/core/dialog.service.js +52 -72
- package/core/event-notifier.js +94 -131
- package/core/formatter/array-formatters.js +18 -32
- package/core/formatter/date-formatters.js +140 -204
- package/core/formatter/index.js +64 -117
- package/core/formatter/number-formatters.js +115 -159
- package/core/formatter/security-formatters.js +233 -283
- package/core/formatter/string-formatters.js +23 -45
- package/core/formatter/types.js +12 -18
- package/core/formatters.js +6 -24
- package/core/proxy-service.js +242 -306
- package/core/script-registry.js +87 -134
- package/core/security.service.js +8 -11
- package/core/util/compare.js +13 -25
- package/core/util/dom.js +32 -63
- package/core/util/index.d.ts +5 -0
- package/core/util/index.js +95 -95
- package/core/util/safe-is-equal.js +42 -94
- package/core/util/security.js +114 -153
- package/core/util/utils.d.ts +8 -1
- package/core/util/utils.js +124 -132
- package/core/widget-observer.js +34 -61
- package/higherOrder/BaseApp.js +327 -500
- package/higherOrder/BaseAppProps.js +0 -5
- package/higherOrder/BaseDateTime.js +277 -231
- package/higherOrder/BasePage.js +479 -735
- package/higherOrder/BasePartial.js +87 -114
- package/higherOrder/BasePrefab.js +190 -206
- package/higherOrder/DataNav.js +287 -302
- package/higherOrder/helper.js +62 -48
- package/higherOrder/props.js +0 -5
- package/higherOrder/withBaseWrapper.js +123 -168
- package/higherOrder/withStandalone.js +28 -26
- package/hooks/useAccess.js +113 -289
- package/hooks/useAppConfig.js +15 -40
- package/hooks/useAuth.js +256 -495
- package/hooks/useDataSourceSubscription.d.ts +3 -3
- package/hooks/useDataSourceSubscription.js +99 -109
- package/hooks/useDebounce.js +28 -56
- package/hooks/useDeviceVisibility.js +14 -23
- package/hooks/useHttp.d.ts +1 -0
- package/hooks/useHttp.js +318 -493
- package/libs/index.js +4 -13
- package/libs/prefab/index.js +6 -20
- package/mui-config/theme-provider.js +9 -17
- package/mui-config/theme.js +6 -9
- package/package-lock.json +808 -3177
- package/package.json +3 -19
- package/providers/AppProviders.js +21 -24
- package/runtime-dynamic/App.js +65 -93
- package/runtime-dynamic/app-initializer.js +207 -400
- package/runtime-dynamic/components/ErrorBoundary.js +59 -76
- package/runtime-dynamic/components/PageWrapper.js +23 -35
- package/runtime-dynamic/components/PrefabPreview.js +40 -69
- package/runtime-dynamic/components/partial-content.d.ts +2 -3
- package/runtime-dynamic/components/partial-content.js +66 -48
- package/runtime-dynamic/components/prefab-content.js +37 -30
- package/runtime-dynamic/components/use-dynamic-component.js +62 -150
- package/runtime-dynamic/factories/build-base-page-like-component.js +44 -58
- package/runtime-dynamic/factories/dynamic-component.d.ts +9 -0
- package/runtime-dynamic/factories/dynamic-component.js +83 -0
- package/runtime-dynamic/factories/prefab-factory.js +60 -81
- package/runtime-dynamic/factories/startup-info.js +12 -25
- package/runtime-dynamic/factories/utils.d.ts +1 -9
- package/runtime-dynamic/factories/utils.js +47 -130
- package/runtime-dynamic/index.js +56 -191
- package/runtime-dynamic/main.js +42 -70
- package/runtime-dynamic/preview-mode.js +14 -29
- package/runtime-dynamic/preview-navigation.js +21 -30
- package/runtime-dynamic/preview-path.d.ts +5 -0
- package/runtime-dynamic/preview-path.js +13 -0
- package/runtime-dynamic/preview-resource-base.js +15 -31
- package/runtime-dynamic/registry/component-registry.js +269 -334
- package/runtime-dynamic/registry/custom-widget-registry.js +11 -15
- package/runtime-dynamic/registry/index.js +24 -63
- package/runtime-dynamic/registry/store.d.ts +1 -0
- package/runtime-dynamic/registry/store.js +18 -23
- package/runtime-dynamic/routes.js +53 -81
- package/runtime-dynamic/services/app-extension-provider.js +17 -44
- package/runtime-dynamic/services/autolayout-inject.d.ts +4 -0
- package/runtime-dynamic/services/autolayout-inject.js +27 -0
- package/runtime-dynamic/services/cache.js +27 -33
- package/runtime-dynamic/services/compile-render.d.ts +9 -0
- package/runtime-dynamic/services/compile-render.js +142 -0
- package/runtime-dynamic/services/component-ref-provider.js +70 -124
- package/runtime-dynamic/services/css-scoping.js +27 -28
- package/runtime-dynamic/services/fragment-url.js +37 -50
- package/runtime-dynamic/services/index.js +48 -152
- package/runtime-dynamic/services/markup-transpiler.d.ts +2 -2
- package/runtime-dynamic/services/markup-transpiler.js +39 -231
- package/runtime-dynamic/services/prefab-resources.js +42 -130
- package/runtime-dynamic/services/resource-manager.d.ts +2 -1
- package/runtime-dynamic/services/resource-manager.js +32 -63
- package/runtime-dynamic/services/script-executor.js +50 -61
- package/runtime-dynamic/services/variable-factory.js +141 -184
- package/runtime-dynamic/services/variable-registry.js +69 -115
- package/runtime-dynamic/services/variable-transpiler.js +73 -103
- package/runtime-dynamic/shims/next-image.js +79 -50
- package/runtime-dynamic/shims/next-link.js +58 -32
- package/runtime-dynamic/shims/next-navigation.js +17 -34
- package/runtime-dynamic/utils/index.d.ts +2 -0
- package/runtime-dynamic/utils/index.js +22 -24
- package/store/bindActions/i18nActions.js +16 -18
- package/store/index.js +29 -35
- package/store/middleware/navigationMiddleware.js +25 -45
- package/store/middleware/pendingTabNavigationIntentMiddleware.js +20 -25
- package/store/slices/appConfigSlice.js +65 -94
- package/store/slices/authSlice.js +317 -471
- package/store/slices/i18nSlice.js +169 -168
- package/store/slices/navigationSlice.js +22 -20
- package/store/util/resolve-path.d.ts +1 -0
- package/store/util/resolve-path.js +7 -0
- package/store/viewport.service.js +150 -194
- package/types/index.js +10 -15
- package/utils/attr.js +198 -41
- package/utils/custom-expression/index.js +55 -151
- package/utils/custom-expression/parser.js +106 -182
- package/utils/dataset-util.js +113 -154
- package/utils/eval-expression.js +10 -19
- package/utils/form-state.util.js +60 -118
- package/utils/form-utils.js +49 -190
- package/utils/format-util.js +113 -184
- package/utils/layoutsize-util.js +11 -17
- package/utils/lib-error-skipper.js +54 -52
- package/utils/page-params-util.js +50 -40
- package/utils/pending-tab-navigation-intent.js +7 -17
- package/utils/resource-url.js +8 -19
- package/utils/state-persistance.js +136 -253
- package/utils/style-utils.d.ts +2 -0
- package/utils/style-utils.js +25 -74
- package/utils/transformedDataset-utils.js +353 -381
- package/utils/widget-cleanup-util.js +42 -74
- package/utils/widgets.js +19 -31
- package/variables/base-variable.js +117 -166
- package/variables/constants.js +5 -8
- package/variables/crud-variable.js +150 -181
- package/variables/live-variable.d.ts +1 -1
- package/variables/live-variable.js +140 -174
- package/variables/metadata.service.js +74 -116
- package/variables/model-variable.js +68 -78
- package/variables/service-variable.js +171 -285
- package/wm-namespace.js +11 -14
- package/components/chart/src/css.d.js +0 -1
- package/tsconfig.declaration.tsbuildinfo +0 -1
- package/types/global.d.js +0 -3
|
@@ -1,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,361 @@ 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
|
-
|
|
221
|
-
setPaginationState(function (prev) {
|
|
222
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
return response;
|
|
166
|
+
}).catch((error) => {
|
|
167
|
+
isFetchingRef.current = false;
|
|
168
|
+
console.error("Error fetching page data:", error);
|
|
169
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
223
170
|
error: error.message || "Failed to fetch page data"
|
|
224
|
-
});
|
|
171
|
+
}));
|
|
172
|
+
return Promise.reject(error);
|
|
225
173
|
});
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
console.error("Error invoking datasource:", error);
|
|
231
|
-
setPaginationState(function (prev) {
|
|
232
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
174
|
+
} catch (error) {
|
|
175
|
+
isFetchingRef.current = false;
|
|
176
|
+
console.error("Error invoking datasource:", error);
|
|
177
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
233
178
|
error: error.message || "Failed to invoke datasource"
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
|
|
179
|
+
}));
|
|
180
|
+
return Promise.reject(error);
|
|
181
|
+
}
|
|
237
182
|
}
|
|
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), {}, {
|
|
183
|
+
return Promise.resolve();
|
|
184
|
+
},
|
|
185
|
+
[datasource, isServerSidePagination, datasourceInvokeOptions]
|
|
186
|
+
);
|
|
187
|
+
const loadMoreData = useCallback(
|
|
188
|
+
(event) => {
|
|
189
|
+
const isAccumulatingMode = navigation === "Scroll" || navigation === "On-Demand";
|
|
190
|
+
if (!isAccumulatingMode || isLastPage || isFetchingRef.current) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (!isServerSidePagination) {
|
|
194
|
+
const currentVisible = accumulatingStateRef.current.accumulatedData.length;
|
|
195
|
+
const totalAvailable = dataState.fullData.length;
|
|
196
|
+
const nextBatchSize = paginationState.currentMaxResults;
|
|
197
|
+
const newVisibleCount = Math.min(currentVisible + nextBatchSize, totalAvailable);
|
|
198
|
+
const nextBatch = dataState.fullData.slice(currentVisible, newVisibleCount);
|
|
199
|
+
const newAccumulatedData = [...accumulatingStateRef.current.accumulatedData, ...nextBatch];
|
|
200
|
+
setAccumulatingState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
262
201
|
accumulatedData: newAccumulatedData,
|
|
263
202
|
lastLoadedPage: prev.lastLoadedPage + 1
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
// Update the result to show accumulated data
|
|
268
|
-
setDataState(function (prev) {
|
|
269
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
203
|
+
}));
|
|
204
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
270
205
|
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);
|
|
206
|
+
}));
|
|
207
|
+
const nextPage2 = accumulatingStateRef.current.lastLoadedPage + 1;
|
|
208
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { currentPage: nextPage2 }));
|
|
209
|
+
if (onPaginationChange) {
|
|
210
|
+
onPaginationChange(
|
|
211
|
+
event || createDummyEvent("paginationchange"),
|
|
212
|
+
widgetInstance,
|
|
213
|
+
nextPage2
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
return;
|
|
307
217
|
}
|
|
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") {
|
|
218
|
+
const nextPage = accumulatingStateRef.current.lastLoadedPage + 1;
|
|
369
219
|
if (setIsLoadingMore) {
|
|
370
220
|
setIsLoadingMore(true);
|
|
371
221
|
}
|
|
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;
|
|
222
|
+
datasourceInvoke(nextPage, paginationState.currentMaxResults, true).then(() => {
|
|
223
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { currentPage: nextPage }));
|
|
224
|
+
if (onPaginationChange) {
|
|
225
|
+
onPaginationChange(
|
|
226
|
+
event || createDummyEvent("paginationchange"),
|
|
227
|
+
widgetInstance,
|
|
228
|
+
nextPage
|
|
229
|
+
);
|
|
398
230
|
}
|
|
399
231
|
if (setIsLoadingMore) {
|
|
400
232
|
setIsLoadingMore(false);
|
|
401
233
|
}
|
|
402
|
-
})
|
|
403
|
-
// Clear resetting flag on error
|
|
404
|
-
isResettingRef.current = false;
|
|
234
|
+
}).catch(() => {
|
|
405
235
|
if (setIsLoadingMore) {
|
|
406
236
|
setIsLoadingMore(false);
|
|
407
237
|
}
|
|
408
238
|
});
|
|
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();
|
|
239
|
+
},
|
|
240
|
+
[
|
|
241
|
+
navigation,
|
|
242
|
+
isServerSidePagination,
|
|
243
|
+
isLastPage,
|
|
244
|
+
setIsLoadingMore,
|
|
245
|
+
datasourceInvoke,
|
|
246
|
+
paginationState.currentMaxResults,
|
|
247
|
+
onPaginationChange,
|
|
248
|
+
widgetInstance,
|
|
249
|
+
dataState.fullData
|
|
250
|
+
]
|
|
251
|
+
);
|
|
252
|
+
const resetAccumulatedData = useCallback(
|
|
253
|
+
(event) => {
|
|
254
|
+
if (navigation === "Scroll") {
|
|
441
255
|
sentinelHasLeftViewportRef.current = false;
|
|
442
256
|
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
257
|
+
isResettingRef.current = true;
|
|
258
|
+
setAccumulatingState({
|
|
259
|
+
accumulatedData: [],
|
|
260
|
+
lastLoadedPage: 0,
|
|
261
|
+
isAccumulating: navigation === "Scroll" || navigation === "On-Demand",
|
|
262
|
+
isInitialized: false
|
|
263
|
+
});
|
|
264
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
265
|
+
result: []
|
|
266
|
+
}));
|
|
267
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { currentPage: 1 }));
|
|
268
|
+
if (onPaginationChange) {
|
|
269
|
+
onPaginationChange(event || createDummyEvent(), widgetInstance, 1);
|
|
270
|
+
}
|
|
271
|
+
if (!isServerSidePagination && dataState.fullData.length > 0) {
|
|
272
|
+
const firstPageData = dataState.fullData.slice(0, paginationState.currentMaxResults);
|
|
273
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
274
|
+
result: firstPageData
|
|
275
|
+
}));
|
|
276
|
+
setTimeout(() => {
|
|
277
|
+
setAccumulatingState({
|
|
278
|
+
accumulatedData: firstPageData,
|
|
279
|
+
lastLoadedPage: 1,
|
|
280
|
+
isAccumulating: true,
|
|
281
|
+
isInitialized: true
|
|
282
|
+
});
|
|
283
|
+
}, 0);
|
|
284
|
+
}
|
|
285
|
+
if (isServerSidePagination && datasource && typeof datasource.invoke === "function") {
|
|
286
|
+
if (setIsLoadingMore) {
|
|
287
|
+
setIsLoadingMore(true);
|
|
288
|
+
}
|
|
289
|
+
const invokeOptions = {
|
|
290
|
+
page: 1
|
|
291
|
+
};
|
|
292
|
+
if (datasourceInvokeOptions) {
|
|
293
|
+
Object.assign(invokeOptions, datasourceInvokeOptions);
|
|
294
|
+
}
|
|
295
|
+
const result = datasource.invoke(invokeOptions);
|
|
296
|
+
Promise.resolve(result).then((response) => {
|
|
297
|
+
if (response && response.data) {
|
|
298
|
+
const newDataWithIds = addUniqueRowIds(response.data);
|
|
299
|
+
setAccumulatingState({
|
|
300
|
+
accumulatedData: newDataWithIds,
|
|
301
|
+
lastLoadedPage: 1,
|
|
302
|
+
isAccumulating: true,
|
|
303
|
+
isInitialized: true
|
|
304
|
+
});
|
|
305
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
306
|
+
fullData: newDataWithIds,
|
|
307
|
+
result: newDataWithIds
|
|
308
|
+
}));
|
|
309
|
+
isResettingRef.current = false;
|
|
310
|
+
}
|
|
311
|
+
if (setIsLoadingMore) {
|
|
312
|
+
setIsLoadingMore(false);
|
|
313
|
+
}
|
|
314
|
+
}).catch(() => {
|
|
315
|
+
isResettingRef.current = false;
|
|
316
|
+
if (setIsLoadingMore) {
|
|
317
|
+
setIsLoadingMore(false);
|
|
318
|
+
}
|
|
464
319
|
});
|
|
465
320
|
} 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
|
-
});
|
|
321
|
+
setTimeout(() => {
|
|
322
|
+
isResettingRef.current = false;
|
|
323
|
+
}, 0);
|
|
479
324
|
}
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
325
|
+
},
|
|
326
|
+
[
|
|
327
|
+
navigation,
|
|
328
|
+
isServerSidePagination,
|
|
329
|
+
datasource,
|
|
330
|
+
datasourceInvokeOptions,
|
|
331
|
+
dataState.fullData,
|
|
332
|
+
paginationState.currentMaxResults,
|
|
333
|
+
setIsLoadingMore,
|
|
334
|
+
onPaginationChange,
|
|
335
|
+
widgetInstance
|
|
336
|
+
]
|
|
337
|
+
);
|
|
338
|
+
const isRowScroll = navigation === "Scroll" && (listDirection === "row" || listDirection === "horizontal");
|
|
339
|
+
const setupInfiniteScrollObserver = useCallback(
|
|
340
|
+
(sentinel, scrollRoot) => {
|
|
341
|
+
if (observerRef.current) {
|
|
342
|
+
observerRef.current.disconnect();
|
|
343
|
+
observerRef.current = null;
|
|
344
|
+
}
|
|
345
|
+
if (!sentinel || navigation !== "Scroll" || !accumulatingStateRef.current.isInitialized) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
if (isRowScroll && !scrollRoot) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
observerRef.current = new IntersectionObserver(
|
|
352
|
+
(entries) => {
|
|
353
|
+
const entry = entries[0];
|
|
354
|
+
if (!entry.isIntersecting && sentinelHasLeftViewportRef.current === false) {
|
|
355
|
+
sentinelHasLeftViewportRef.current = true;
|
|
356
|
+
}
|
|
357
|
+
if (entry.isIntersecting && accumulatingStateRef.current.isInitialized && !isLastPage && !isFetchingRef.current && sentinelHasLeftViewportRef.current) {
|
|
358
|
+
loadMoreData();
|
|
359
|
+
sentinelHasLeftViewportRef.current = false;
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
root: scrollRoot != null ? scrollRoot : null,
|
|
364
|
+
rootMargin: isRowScroll ? "0px" : "100px",
|
|
365
|
+
threshold: 0.1
|
|
366
|
+
}
|
|
367
|
+
);
|
|
368
|
+
observerRef.current.observe(sentinel);
|
|
369
|
+
},
|
|
370
|
+
[navigation, isLastPage, loadMoreData, listDirection, isRowScroll]
|
|
371
|
+
);
|
|
372
|
+
const setDefaultPagingValues = useCallback(
|
|
373
|
+
(newDataSize, newMaxResults, currentPage) => {
|
|
374
|
+
setPaginationState((prev) => {
|
|
375
|
+
if (!newDataSize && !newMaxResults) {
|
|
376
|
+
return __spreadProps(__spreadValues({}, prev), {
|
|
377
|
+
pageCount: 1,
|
|
378
|
+
dataSize: newDataSize,
|
|
379
|
+
currentPage: currentPage !== void 0 ? currentPage : prev.currentPage
|
|
380
|
+
});
|
|
381
|
+
} else {
|
|
382
|
+
const updatedMaxResults = newMaxResults || prev.currentMaxResults;
|
|
383
|
+
const updatedDataSize = newDataSize !== void 0 ? newDataSize : prev.dataSize;
|
|
384
|
+
const updatedCurrentPage = currentPage !== void 0 ? currentPage : prev.currentPage;
|
|
385
|
+
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;
|
|
386
|
+
return __spreadProps(__spreadValues({}, prev), {
|
|
387
|
+
currentPage: updatedCurrentPage,
|
|
388
|
+
dataSize: updatedDataSize,
|
|
389
|
+
pageCount: newPageCount
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
},
|
|
394
|
+
[paginationMeta]
|
|
395
|
+
);
|
|
396
|
+
const disableNavigation = useCallback(() => {
|
|
485
397
|
setDisableStates({
|
|
486
398
|
isDisableFirst: isFirstPage,
|
|
487
399
|
isDisablePrevious: isFirstPage,
|
|
@@ -491,363 +403,298 @@ var usePagination = exports.usePagination = function usePagination(_ref) {
|
|
|
491
403
|
isDisableCount: false
|
|
492
404
|
});
|
|
493
405
|
}, [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), {}, {
|
|
406
|
+
const setNonPageableData = useCallback(
|
|
407
|
+
(newVal) => {
|
|
408
|
+
let newDataSize, newMaxResults, currentPage, startIndex;
|
|
409
|
+
if (isServerSidePagination) {
|
|
410
|
+
const serverTotalCount = totalItems != null ? totalItems : paginationMeta == null ? void 0 : paginationMeta.totalElements;
|
|
411
|
+
newDataSize = serverTotalCount !== void 0 && serverTotalCount >= 0 ? serverTotalCount : isArray(newVal) ? newVal.length : isEmpty(newVal) ? 0 : 1;
|
|
412
|
+
} else {
|
|
413
|
+
newDataSize = isArray(newVal) ? newVal.length : isEmpty(newVal) ? 0 : 1;
|
|
414
|
+
}
|
|
415
|
+
newMaxResults = paginationState.currentMaxResults || newDataSize;
|
|
416
|
+
currentPage = paginationState.currentPage;
|
|
417
|
+
setDefaultPagingValues(newDataSize, newMaxResults, currentPage);
|
|
418
|
+
disableNavigation();
|
|
419
|
+
startIndex = (currentPage - 1) * newMaxResults;
|
|
420
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
421
|
+
result: isArray(newVal) ? newVal.slice(startIndex, startIndex + newMaxResults) : newVal
|
|
422
|
+
}));
|
|
423
|
+
},
|
|
424
|
+
[
|
|
425
|
+
paginationState.currentPage,
|
|
426
|
+
paginationState.currentMaxResults,
|
|
427
|
+
disableNavigation,
|
|
428
|
+
setDefaultPagingValues,
|
|
429
|
+
isServerSidePagination,
|
|
430
|
+
totalItems,
|
|
431
|
+
paginationMeta
|
|
432
|
+
]
|
|
433
|
+
);
|
|
434
|
+
const setPagingValues = useCallback(
|
|
435
|
+
(newVal) => {
|
|
436
|
+
const isAccumulatingMode = (navigation === "Scroll" || navigation === "On-Demand") && isServerSidePagination;
|
|
437
|
+
if (isAccumulatingMode) {
|
|
438
|
+
const currentAccumulatedData = accumulatingStateRef.current.accumulatedData;
|
|
439
|
+
if (currentAccumulatedData.length === 0 && isArray(newVal)) {
|
|
440
|
+
const initialDataWithIds = addUniqueRowIds(newVal);
|
|
441
|
+
setAccumulatingState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
535
442
|
accumulatedData: initialDataWithIds,
|
|
536
443
|
lastLoadedPage: 1,
|
|
537
444
|
isInitialized: true
|
|
538
|
-
});
|
|
539
|
-
|
|
540
|
-
setDataState(function (prev) {
|
|
541
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
445
|
+
}));
|
|
446
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
542
447
|
fullData: initialDataWithIds,
|
|
543
448
|
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), {}, {
|
|
449
|
+
}));
|
|
450
|
+
} else if (currentAccumulatedData.length > 0) {
|
|
451
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
550
452
|
fullData: currentAccumulatedData,
|
|
551
453
|
result: currentAccumulatedData
|
|
552
|
-
});
|
|
553
|
-
}
|
|
454
|
+
}));
|
|
455
|
+
}
|
|
456
|
+
return;
|
|
554
457
|
}
|
|
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), {}, {
|
|
458
|
+
if (navigation === "On-Demand" && !isServerSidePagination) {
|
|
459
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
460
|
+
fullData: isArray(newVal) ? newVal : []
|
|
461
|
+
}));
|
|
462
|
+
const currentAccumulatedData = accumulatingStateRef.current.accumulatedData;
|
|
463
|
+
if (currentAccumulatedData.length === 0 && isArray(newVal) && newVal.length > 0) {
|
|
464
|
+
const firstPageData = newVal.slice(0, paginationState.currentMaxResults);
|
|
465
|
+
setAccumulatingState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
574
466
|
accumulatedData: firstPageData,
|
|
575
467
|
lastLoadedPage: 1,
|
|
576
468
|
isInitialized: true
|
|
577
|
-
});
|
|
578
|
-
|
|
579
|
-
setDataState(function (prev) {
|
|
580
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
469
|
+
}));
|
|
470
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
581
471
|
result: firstPageData
|
|
582
|
-
});
|
|
583
|
-
})
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
}
|
|
472
|
+
}));
|
|
473
|
+
} else if (currentAccumulatedData.length > 0) {
|
|
474
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
475
|
+
result: currentAccumulatedData
|
|
476
|
+
}));
|
|
477
|
+
}
|
|
478
|
+
if (isArray(newVal)) {
|
|
479
|
+
setDefaultPagingValues(newVal.length, paginationState.currentMaxResults, 1);
|
|
480
|
+
}
|
|
481
|
+
return;
|
|
591
482
|
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
483
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
484
|
+
fullData: isArray(newVal) ? newVal : []
|
|
485
|
+
}));
|
|
486
|
+
if (newVal && !isArray(newVal)) {
|
|
487
|
+
setNonPageableData(newVal);
|
|
488
|
+
} else if (newVal) {
|
|
489
|
+
setNonPageableData(newVal);
|
|
490
|
+
} else {
|
|
491
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), { result: newVal }));
|
|
492
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { pageCount: 0, dataSize: 0 }));
|
|
596
493
|
}
|
|
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
|
-
});
|
|
494
|
+
},
|
|
495
|
+
[
|
|
496
|
+
setNonPageableData,
|
|
497
|
+
navigation,
|
|
498
|
+
isServerSidePagination,
|
|
499
|
+
paginationState.currentMaxResults,
|
|
500
|
+
setDefaultPagingValues
|
|
501
|
+
]
|
|
502
|
+
);
|
|
503
|
+
const validateCurrentPage = useCallback(
|
|
504
|
+
(event) => {
|
|
505
|
+
const { currentPage, pageCount } = paginationState;
|
|
506
|
+
if (event && (isNaN(currentPage) || currentPage <= 0 || pageCount && (currentPage > pageCount || isNull(currentPage)))) {
|
|
507
|
+
if (currentPage <= 0) {
|
|
508
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { currentPage: 1 }));
|
|
509
|
+
} else if (currentPage > pageCount) {
|
|
510
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { currentPage: pageCount }));
|
|
511
|
+
}
|
|
512
|
+
return false;
|
|
645
513
|
}
|
|
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
|
-
});
|
|
514
|
+
return true;
|
|
515
|
+
},
|
|
516
|
+
[paginationState]
|
|
517
|
+
);
|
|
518
|
+
const goToPage = useCallback(() => {
|
|
519
|
+
const { currentPage, currentMaxResults } = paginationState;
|
|
520
|
+
const { fullData } = dataState;
|
|
521
|
+
const firstRow = (currentPage - 1) * currentMaxResults;
|
|
522
|
+
const startIndex = firstRow;
|
|
523
|
+
const data = isArray(fullData) ? fullData.slice(startIndex, startIndex + currentMaxResults) : fullData;
|
|
524
|
+
setDataState((prev) => __spreadProps(__spreadValues({}, prev), { result: data }));
|
|
664
525
|
disableNavigation();
|
|
665
526
|
}, [paginationState, dataState.fullData, disableNavigation]);
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
527
|
+
const performPageNavigation = useCallback(
|
|
528
|
+
(newPage, previousPage, event) => {
|
|
529
|
+
if (setIsLoadingMore) {
|
|
530
|
+
setIsLoadingMore(true);
|
|
531
|
+
}
|
|
532
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { currentPage: newPage }));
|
|
533
|
+
if (isServerSidePagination) {
|
|
534
|
+
datasourceInvoke(newPage).then(() => {
|
|
535
|
+
if (onPaginationChange) {
|
|
536
|
+
onPaginationChange(
|
|
537
|
+
event || createDummyEvent("paginationchange"),
|
|
538
|
+
widgetInstance,
|
|
539
|
+
newPage
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
if (onSetRecord) {
|
|
543
|
+
const firstRow = (newPage - 1) * paginationState.currentMaxResults;
|
|
544
|
+
const startIndex = firstRow;
|
|
545
|
+
const data = isArray(dataState.fullData) ? dataState.fullData.slice(
|
|
546
|
+
startIndex,
|
|
547
|
+
startIndex + paginationState.currentMaxResults
|
|
548
|
+
) : dataState.fullData;
|
|
549
|
+
const pageInfo = {
|
|
550
|
+
currentPage: newPage,
|
|
551
|
+
size: paginationState.currentMaxResults,
|
|
552
|
+
totalElements: (paginationMeta == null ? void 0 : paginationMeta.totalElements) || dataState.fullData.length,
|
|
553
|
+
totalPages: paginationState.pageCount
|
|
554
|
+
};
|
|
555
|
+
onSetRecord(event || createDummyEvent("setrecord"), widgetInstance, data, pageInfo);
|
|
556
|
+
}
|
|
557
|
+
if (setIsLoadingMore) {
|
|
558
|
+
setIsLoadingMore(false);
|
|
559
|
+
}
|
|
560
|
+
}).catch(() => {
|
|
561
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
562
|
+
currentPage: previousPage || paginationState.currentPage
|
|
563
|
+
}));
|
|
564
|
+
if (setIsLoadingMore) {
|
|
565
|
+
setIsLoadingMore(false);
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
} else {
|
|
685
569
|
if (onPaginationChange) {
|
|
686
|
-
onPaginationChange(
|
|
570
|
+
onPaginationChange(
|
|
571
|
+
event || createDummyEvent("paginationchange"),
|
|
572
|
+
widgetInstance,
|
|
573
|
+
newPage
|
|
574
|
+
);
|
|
687
575
|
}
|
|
688
|
-
|
|
689
|
-
// Call onSetRecord with the new page data
|
|
690
576
|
if (onSetRecord) {
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
577
|
+
const firstRow = (newPage - 1) * paginationState.currentMaxResults;
|
|
578
|
+
const startIndex = firstRow;
|
|
579
|
+
const data = isArray(dataState.fullData) ? dataState.fullData.slice(startIndex, startIndex + paginationState.currentMaxResults) : dataState.fullData;
|
|
580
|
+
const pageInfo = {
|
|
695
581
|
currentPage: newPage,
|
|
696
582
|
size: paginationState.currentMaxResults,
|
|
697
|
-
totalElements: (paginationMeta
|
|
583
|
+
totalElements: (paginationMeta == null ? void 0 : paginationMeta.totalElements) || dataState.fullData.length,
|
|
698
584
|
totalPages: paginationState.pageCount
|
|
699
585
|
};
|
|
700
586
|
onSetRecord(event || createDummyEvent("setrecord"), widgetInstance, data, pageInfo);
|
|
701
587
|
}
|
|
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
588
|
if (setIsLoadingMore) {
|
|
717
589
|
setIsLoadingMore(false);
|
|
718
590
|
}
|
|
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
591
|
}
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
592
|
+
},
|
|
593
|
+
[
|
|
594
|
+
isServerSidePagination,
|
|
595
|
+
datasourceInvoke,
|
|
596
|
+
onPaginationChange,
|
|
597
|
+
onSetRecord,
|
|
598
|
+
widgetInstance,
|
|
599
|
+
paginationState,
|
|
600
|
+
dataState.fullData,
|
|
601
|
+
setIsLoadingMore,
|
|
602
|
+
paginationMeta
|
|
603
|
+
]
|
|
604
|
+
);
|
|
605
|
+
const navigatePage = useCallback(
|
|
606
|
+
(index, event, isRefresh = false) => {
|
|
607
|
+
const currentPage = +paginationState.currentPage;
|
|
608
|
+
let newPage = currentPage;
|
|
609
|
+
switch (index) {
|
|
610
|
+
case "first":
|
|
611
|
+
if (!isFirstPage) {
|
|
612
|
+
newPage = 1;
|
|
613
|
+
} else if (isRefresh) {
|
|
614
|
+
goToPage();
|
|
615
|
+
return;
|
|
616
|
+
} else {
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
break;
|
|
620
|
+
case "prev":
|
|
621
|
+
if (isFirstPage || !validateCurrentPage(event)) {
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
newPage = currentPage - 1;
|
|
625
|
+
break;
|
|
626
|
+
case "next":
|
|
627
|
+
if (isLastPage || !validateCurrentPage(event)) {
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
newPage = currentPage + 1;
|
|
631
|
+
break;
|
|
632
|
+
case "last":
|
|
633
|
+
if (!isLastPage) {
|
|
634
|
+
newPage = paginationState.pageCount;
|
|
635
|
+
} else if (isRefresh) {
|
|
636
|
+
goToPage();
|
|
637
|
+
return;
|
|
638
|
+
} else {
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
break;
|
|
642
|
+
default:
|
|
643
|
+
return;
|
|
739
644
|
}
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
if (setIsLoadingMore) {
|
|
743
|
-
setIsLoadingMore(false);
|
|
645
|
+
if (newPage !== currentPage) {
|
|
646
|
+
performPageNavigation(newPage, currentPage, event);
|
|
744
647
|
}
|
|
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);
|
|
648
|
+
},
|
|
649
|
+
[paginationState, isFirstPage, isLastPage, validateCurrentPage, goToPage, performPageNavigation]
|
|
650
|
+
);
|
|
651
|
+
const handlePageChange = useCallback(
|
|
652
|
+
(event, page) => {
|
|
653
|
+
if (page !== paginationState.currentPage) {
|
|
654
|
+
const previousPage = paginationState.currentPage;
|
|
655
|
+
performPageNavigation(page, previousPage, event);
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
[paginationState.currentPage, performPageNavigation]
|
|
659
|
+
);
|
|
660
|
+
const handleInputChange = useCallback((event) => {
|
|
661
|
+
const value = parseInt(event.target.value, 10);
|
|
814
662
|
if (!isNaN(value)) {
|
|
815
|
-
setPaginationState(
|
|
816
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
817
|
-
currentPage: value
|
|
818
|
-
});
|
|
819
|
-
});
|
|
663
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { currentPage: value }));
|
|
820
664
|
}
|
|
821
665
|
}, []);
|
|
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
|
-
|
|
666
|
+
const onModelChange = useCallback(
|
|
667
|
+
(event) => {
|
|
668
|
+
if (!validateCurrentPage(event)) {
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
if (onSetRecord) {
|
|
672
|
+
const { currentPage, currentMaxResults, pageCount } = paginationState;
|
|
673
|
+
const { fullData } = dataState;
|
|
674
|
+
const firstRow = (currentPage - 1) * currentMaxResults;
|
|
675
|
+
const startIndex = firstRow;
|
|
676
|
+
const data = isArray(fullData) ? fullData.slice(startIndex, startIndex + currentMaxResults) : fullData;
|
|
677
|
+
const pageInfo = {
|
|
678
|
+
currentPage,
|
|
679
|
+
size: currentMaxResults,
|
|
680
|
+
totalElements: (paginationMeta == null ? void 0 : paginationMeta.totalElements) || fullData.length,
|
|
681
|
+
totalPages: pageCount
|
|
682
|
+
};
|
|
683
|
+
onSetRecord(event, widgetInstance, data, pageInfo);
|
|
684
|
+
}
|
|
685
|
+
goToPage();
|
|
686
|
+
},
|
|
687
|
+
[
|
|
688
|
+
goToPage,
|
|
689
|
+
validateCurrentPage,
|
|
690
|
+
onSetRecord,
|
|
691
|
+
paginationState,
|
|
692
|
+
dataState.fullData,
|
|
693
|
+
widgetInstance,
|
|
694
|
+
paginationMeta
|
|
695
|
+
]
|
|
696
|
+
);
|
|
697
|
+
const onKeyDown = useCallback((event) => {
|
|
851
698
|
if (event.code === "KeyE") {
|
|
852
699
|
event.currentTarget.classList.add("ng-invalid");
|
|
853
700
|
return false;
|
|
@@ -855,92 +702,78 @@ var usePagination = exports.usePagination = function usePagination(_ref) {
|
|
|
855
702
|
event.currentTarget.classList.remove("ng-invalid");
|
|
856
703
|
return true;
|
|
857
704
|
}, []);
|
|
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
|
|
705
|
+
const handlePageSizeChange = useCallback(
|
|
706
|
+
(event, pageSize) => {
|
|
707
|
+
const { currentMaxResults: oldPageSize, currentPage: oldPage, dataSize } = paginationState;
|
|
708
|
+
const actualPageSize = oldPageSize;
|
|
709
|
+
if (isDataSourceHasPaging(datasource) && datasource) {
|
|
710
|
+
datasource.maxResults = pageSize;
|
|
711
|
+
}
|
|
712
|
+
setPaginationState((prev) => {
|
|
713
|
+
const newPageCount = calculatePagingValues(dataSize, pageSize);
|
|
714
|
+
return __spreadProps(__spreadValues({}, prev), {
|
|
715
|
+
currentMaxResults: pageSize,
|
|
716
|
+
currentPage: 1,
|
|
717
|
+
// Always go to first page like Angular
|
|
718
|
+
pageCount: newPageCount
|
|
719
|
+
});
|
|
882
720
|
});
|
|
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
|
|
721
|
+
if (setIsLoadingMore) {
|
|
722
|
+
setIsLoadingMore(true);
|
|
723
|
+
}
|
|
724
|
+
if (pageSizeChangeHandler) {
|
|
725
|
+
pageSizeChangeHandler(pageSize);
|
|
726
|
+
}
|
|
727
|
+
if (isServerSidePagination) {
|
|
728
|
+
datasourceInvoke(1, pageSize).then(() => {
|
|
729
|
+
if (onPaginationChange) {
|
|
730
|
+
onPaginationChange(event || createDummyEvent("paginationchange"), widgetInstance, 1);
|
|
731
|
+
}
|
|
732
|
+
if (onSetRecord) {
|
|
733
|
+
const data = isArray(dataState.fullData) ? dataState.fullData.slice(0, pageSize) : dataState.fullData;
|
|
734
|
+
const newPageCount = calculatePagingValues(dataState.fullData.length, pageSize);
|
|
735
|
+
const pageInfo = {
|
|
736
|
+
currentPage: 1,
|
|
737
|
+
size: pageSize,
|
|
738
|
+
totalElements: (paginationMeta == null ? void 0 : paginationMeta.totalElements) || dataState.fullData.length,
|
|
739
|
+
totalPages: newPageCount
|
|
740
|
+
};
|
|
741
|
+
onSetRecord(event || createDummyEvent("setrecord"), widgetInstance, data, pageInfo);
|
|
742
|
+
}
|
|
743
|
+
if (setIsLoadingMore) {
|
|
744
|
+
setIsLoadingMore(false);
|
|
745
|
+
}
|
|
746
|
+
}).catch(() => {
|
|
747
|
+
if (setIsLoadingMore) {
|
|
748
|
+
setIsLoadingMore(false);
|
|
749
|
+
}
|
|
750
|
+
});
|
|
751
|
+
} else {
|
|
752
|
+
setTimeout(() => {
|
|
753
|
+
navigatePage("first", event, true);
|
|
754
|
+
}, 0);
|
|
922
755
|
if (setIsLoadingMore) {
|
|
923
756
|
setIsLoadingMore(false);
|
|
924
757
|
}
|
|
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
758
|
}
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
759
|
+
},
|
|
760
|
+
[
|
|
761
|
+
pageSizeChangeHandler,
|
|
762
|
+
navigatePage,
|
|
763
|
+
datasource,
|
|
764
|
+
paginationState,
|
|
765
|
+
isServerSidePagination,
|
|
766
|
+
datasourceInvoke,
|
|
767
|
+
onPaginationChange,
|
|
768
|
+
onSetRecord,
|
|
769
|
+
widgetInstance,
|
|
770
|
+
dataState.fullData,
|
|
771
|
+
setIsLoadingMore,
|
|
772
|
+
paginationMeta
|
|
773
|
+
]
|
|
774
|
+
);
|
|
775
|
+
useEffect(() => {
|
|
941
776
|
setNavcontrols(getValidNavControl(navigation));
|
|
942
|
-
|
|
943
|
-
// Reset accumulated data state when navigation changes to Scroll or On-Demand
|
|
944
777
|
if (navigation === "Scroll" || navigation === "On-Demand") {
|
|
945
778
|
setAccumulatingState({
|
|
946
779
|
accumulatedData: [],
|
|
@@ -950,100 +783,65 @@ var usePagination = exports.usePagination = function usePagination(_ref) {
|
|
|
950
783
|
});
|
|
951
784
|
}
|
|
952
785
|
}, [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)
|
|
786
|
+
useEffect(() => {
|
|
787
|
+
if (dataset !== void 0) {
|
|
788
|
+
const processedDataset = extractDataArray(dataset);
|
|
789
|
+
const isAccumulatingMode = (navigation === "Scroll" || navigation === "On-Demand") && isServerSidePagination;
|
|
963
790
|
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
|
|
791
|
+
const currentAccumulatedData = accumulatingStateRef.current.accumulatedData;
|
|
967
792
|
if (currentAccumulatedData.length === 0 && !isResettingRef.current) {
|
|
968
|
-
setPagingValues(
|
|
793
|
+
setPagingValues(processedDataset);
|
|
969
794
|
}
|
|
970
795
|
} else {
|
|
971
|
-
|
|
972
|
-
setPagingValues(dataset);
|
|
796
|
+
setPagingValues(processedDataset);
|
|
973
797
|
}
|
|
974
798
|
}
|
|
975
799
|
}, [dataset, setPagingValues, navigation, isServerSidePagination]);
|
|
976
|
-
|
|
977
|
-
// For server-side pagination, update dataSize and pageCount based on metadata
|
|
978
|
-
(0, _react.useEffect)(function () {
|
|
800
|
+
useEffect(() => {
|
|
979
801
|
if (isServerSidePagination) {
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
var updates = {
|
|
802
|
+
const totalCount = totalItems != null ? totalItems : paginationMeta == null ? void 0 : paginationMeta.totalElements;
|
|
803
|
+
if (totalCount !== void 0 && totalCount >= 0) {
|
|
804
|
+
setPaginationState((prev) => {
|
|
805
|
+
let updates = {
|
|
985
806
|
dataSize: totalCount
|
|
986
807
|
};
|
|
987
|
-
|
|
988
|
-
// If totalPages not provided, calculate it
|
|
989
|
-
if ((paginationMeta === null || paginationMeta === void 0 ? void 0 : paginationMeta.totalPages) !== undefined) {
|
|
808
|
+
if ((paginationMeta == null ? void 0 : paginationMeta.totalPages) !== void 0) {
|
|
990
809
|
updates.pageCount = paginationMeta.totalPages;
|
|
991
810
|
} else if (prev.currentMaxResults > 0) {
|
|
992
811
|
updates.pageCount = Math.ceil(totalCount / prev.currentMaxResults) || 1;
|
|
993
812
|
}
|
|
994
|
-
|
|
995
|
-
// Handle edge case: current page is out of range
|
|
996
|
-
if (paginationMeta !== null && paginationMeta !== void 0 && paginationMeta.totalPages && prev.currentPage > paginationMeta.totalPages) {
|
|
813
|
+
if ((paginationMeta == null ? void 0 : paginationMeta.totalPages) && prev.currentPage > paginationMeta.totalPages) {
|
|
997
814
|
updates.currentPage = Math.max(1, paginationMeta.totalPages);
|
|
998
815
|
}
|
|
999
|
-
|
|
1000
|
-
// Handle empty results
|
|
1001
816
|
if (totalCount === 0) {
|
|
1002
|
-
updates.pageCount = 1;
|
|
817
|
+
updates.pageCount = 1;
|
|
1003
818
|
updates.currentPage = 1;
|
|
1004
819
|
}
|
|
1005
|
-
return
|
|
820
|
+
return __spreadValues(__spreadValues({}, prev), updates);
|
|
1006
821
|
});
|
|
1007
822
|
}
|
|
1008
823
|
}
|
|
1009
824
|
}, [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
|
|
825
|
+
useEffect(() => {
|
|
826
|
+
if (initialPage !== void 0 && initialPage !== paginationState.currentPage) {
|
|
827
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { currentPage: initialPage }));
|
|
1020
828
|
disableNavigation();
|
|
1021
829
|
}
|
|
1022
830
|
}, [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 () {
|
|
831
|
+
useEffect(() => {
|
|
1026
832
|
if (maxResults !== paginationState.currentMaxResults) {
|
|
1027
|
-
setPaginationState(
|
|
1028
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
1029
|
-
currentMaxResults: maxResults
|
|
1030
|
-
});
|
|
1031
|
-
});
|
|
833
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { currentMaxResults: maxResults }));
|
|
1032
834
|
}
|
|
1033
835
|
}, [maxResults, paginationState.currentMaxResults]);
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
(0, _react.useEffect)(function () {
|
|
1037
|
-
var _scrollContainerRef$c;
|
|
836
|
+
useEffect(() => {
|
|
837
|
+
var _a2;
|
|
1038
838
|
if (!accumulatingState.isInitialized || !sentinelRef.current || navigation !== "Scroll") return;
|
|
1039
|
-
|
|
839
|
+
const scrollRoot = isRowScroll ? (_a2 = scrollContainerRef == null ? void 0 : scrollContainerRef.current) != null ? _a2 : null : null;
|
|
1040
840
|
if (isRowScroll && !scrollRoot) return;
|
|
1041
841
|
setupInfiniteScrollObserver(sentinelRef.current, scrollRoot);
|
|
1042
842
|
}, [accumulatingState.isInitialized, navigation, setupInfiniteScrollObserver, isRowScroll]);
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
(0, _react.useEffect)(function () {
|
|
1046
|
-
return function () {
|
|
843
|
+
useEffect(() => {
|
|
844
|
+
return () => {
|
|
1047
845
|
if (observerRef.current) {
|
|
1048
846
|
observerRef.current.disconnect();
|
|
1049
847
|
observerRef.current = null;
|
|
@@ -1056,7 +854,7 @@ var usePagination = exports.usePagination = function usePagination(_ref) {
|
|
|
1056
854
|
pageCount: paginationState.pageCount,
|
|
1057
855
|
dataSize: paginationState.dataSize,
|
|
1058
856
|
result: dataState.result,
|
|
1059
|
-
navcontrols
|
|
857
|
+
navcontrols,
|
|
1060
858
|
currentMaxResults: paginationState.currentMaxResults,
|
|
1061
859
|
error: paginationState.error,
|
|
1062
860
|
// Disable states
|
|
@@ -1067,29 +865,28 @@ var usePagination = exports.usePagination = function usePagination(_ref) {
|
|
|
1067
865
|
isDisableCurrent: disableStates.isDisableCurrent,
|
|
1068
866
|
isDisableCount: disableStates.isDisableCount,
|
|
1069
867
|
// 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,
|
|
868
|
+
navigatePage,
|
|
869
|
+
handlePageChange,
|
|
870
|
+
handleInputChange,
|
|
871
|
+
onModelChange,
|
|
872
|
+
onKeyDown,
|
|
873
|
+
setDn: (value) => setPaginationState((prev) => __spreadValues(__spreadValues({}, prev), value)),
|
|
874
|
+
handlePageSizeChange,
|
|
1081
875
|
// Utilities
|
|
1082
|
-
isFirstPage
|
|
1083
|
-
isLastPage
|
|
876
|
+
isFirstPage,
|
|
877
|
+
isLastPage,
|
|
1084
878
|
isFetching: isFetchingRef.current,
|
|
1085
879
|
// Infinite scroll specific
|
|
1086
|
-
setupInfiniteScrollObserver
|
|
1087
|
-
sentinelRef
|
|
880
|
+
setupInfiniteScrollObserver,
|
|
881
|
+
sentinelRef,
|
|
1088
882
|
isLoadingMore: isFetchingRef.current && (navigation === "Scroll" || navigation === "On-Demand") && accumulatingStateRef.current.lastLoadedPage > 0,
|
|
1089
883
|
hasMoreData: !isLastPage && (navigation === "Scroll" || navigation === "On-Demand"),
|
|
1090
884
|
// On-Demand specific
|
|
1091
|
-
loadMoreData
|
|
1092
|
-
resetAccumulatedData
|
|
885
|
+
loadMoreData,
|
|
886
|
+
resetAccumulatedData,
|
|
1093
887
|
accumulatedDataCount: accumulatingStateRef.current.accumulatedData.length
|
|
1094
888
|
};
|
|
1095
|
-
};
|
|
889
|
+
};
|
|
890
|
+
export {
|
|
891
|
+
usePagination
|
|
892
|
+
};
|