@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,1830 +1,1670 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
"use client";
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
Object.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var _reactTable = require("@tanstack/react-table");
|
|
19
|
-
var _material = require("@mui/material");
|
|
20
|
-
var _lodashEs = require("lodash-es");
|
|
21
|
-
var _withBaseWrapper = _interopRequireDefault(require("@wavemaker-ai/react-runtime/higherOrder/withBaseWrapper"));
|
|
22
|
-
var _pagination = _interopRequireDefault(require("@wavemaker-ai/react-runtime/components/data/pagination"));
|
|
23
|
-
var _hooks = require("./hooks");
|
|
24
|
-
var _utils = require("./utils");
|
|
25
|
-
var _groupHeaderUtils = require("./utils/groupHeaderUtils");
|
|
26
|
-
var _components = require("./components");
|
|
27
|
-
var _buildSelectionColumns = require("./utils/buildSelectionColumns");
|
|
28
|
-
var _LoadingComponent = _interopRequireDefault(require("@wavemaker-ai/react-runtime/components/data/pagination/components/LoadingComponent"));
|
|
29
|
-
var _columnProxy = require("./utils/columnProxy");
|
|
30
|
-
var _useDataSourceSubscription = require("@wavemaker-ai/react-runtime/hooks/useDataSourceSubscription");
|
|
31
|
-
var _crudHandlers = require("./utils/crud-handlers");
|
|
32
|
-
var _types = require("@wavemaker-ai/react-runtime/components/data/types");
|
|
33
|
-
var _useEditedRows = require("./hooks/use-edited-rows");
|
|
34
|
-
var _scriptPageSizeBroadcast = require("./utils/script-page-size-broadcast");
|
|
35
|
-
var _withStandalone = _interopRequireDefault(require("@wavemaker-ai/react-runtime/higherOrder/withStandalone"));
|
|
36
|
-
var _excluded = ["name", "dataset", "navigation", "children", "listener", "pagesize", "navigationalign", "showrecordcount", "maxsize", "boundarylinks", "allowpagesizechange", "pagesizeoptions", "formposition", "editmode", "spacing", "title", "subheading", "iconclass", "exportOptions", "shownavigation", "onDemandLoad", "showrowindex", "showheader", "enablesort", "enablecolumnselection", "onColumnselect", "onColumndeselect", "radioselect", "radioselecttitle", "radioselectarialabel", "multiselect", "multiselecttitle", "multiselectarialabel", "gridfirstrowselect", "isrowselectable", "rowClass", "deleteoktext", "deletecanceltext", "confirmdelete", "errormessage", "nodatamessage", "loadingdatamsg", "insertmessage", "updatemessage", "deletemessage", "ondemandmessage", "viewlessmessage", "showviewlessbutton", "onRowDelete", "onRowUpdate", "datasource", "binddataset", "onSuccess", "onError", "onRowinsert", "onRowupdate", "onRowdelete", "onRowclick", "onSort", "onBeforerowdelete", "onBeforefilter", "onHeaderclick", "onRowselect", "onRowdeselect", "onSetrecord", "statehandler", "formName", "parentForm", "filtermode", "filteronkeypress", "searchlabel", "onBeforedatarender", "onDatarender", "className", "exportformat", "exportdatasize", "onBeforeexport", "onAfterexport", "styles"];
|
|
37
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
|
|
38
|
-
var __jsx = _react["default"].createElement;
|
|
39
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
40
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
41
|
-
var WmTableComponent = exports.WmTableComponent = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
42
|
-
var _listener$App, _listener$Widgets2, _datasource$paginatio2, _table$getState$pagin, _datasource$paginatio4;
|
|
43
|
-
var name = props.name,
|
|
44
|
-
_props$dataset = props.dataset,
|
|
45
|
-
dataset = _props$dataset === void 0 ? [] : _props$dataset,
|
|
46
|
-
_props$navigation = props.navigation,
|
|
47
|
-
navigation = _props$navigation === void 0 ? "Basic" : _props$navigation,
|
|
48
|
-
children = props.children,
|
|
49
|
-
listener = props.listener,
|
|
50
|
-
_props$pagesize = props.pagesize,
|
|
51
|
-
pagesize = _props$pagesize === void 0 ? 5 : _props$pagesize,
|
|
52
|
-
_props$navigationalig = props.navigationalign,
|
|
53
|
-
navigationalign = _props$navigationalig === void 0 ? "left" : _props$navigationalig,
|
|
54
|
-
_props$showrecordcoun = props.showrecordcount,
|
|
55
|
-
showrecordcount = _props$showrecordcoun === void 0 ? false : _props$showrecordcoun,
|
|
56
|
-
_props$maxsize = props.maxsize,
|
|
57
|
-
maxsize = _props$maxsize === void 0 ? 5 : _props$maxsize,
|
|
58
|
-
_props$boundarylinks = props.boundarylinks,
|
|
59
|
-
boundarylinks = _props$boundarylinks === void 0 ? false : _props$boundarylinks,
|
|
60
|
-
_props$allowpagesizec = props.allowpagesizechange,
|
|
61
|
-
allowpagesizechange = _props$allowpagesizec === void 0 ? false : _props$allowpagesizec,
|
|
62
|
-
_props$pagesizeoption = props.pagesizeoptions,
|
|
63
|
-
pagesizeoptions = _props$pagesizeoption === void 0 ? "5,10,20,50,100" : _props$pagesizeoption,
|
|
64
|
-
_props$formposition = props.formposition,
|
|
65
|
-
formposition = _props$formposition === void 0 ? "bottom" : _props$formposition,
|
|
66
|
-
_props$editmode = props.editmode,
|
|
67
|
-
editmode = _props$editmode === void 0 ? "none" : _props$editmode,
|
|
68
|
-
_props$spacing = props.spacing,
|
|
69
|
-
spacing = _props$spacing === void 0 ? "normal" : _props$spacing,
|
|
70
|
-
title = props.title,
|
|
71
|
-
subheading = props.subheading,
|
|
72
|
-
iconclass = props.iconclass,
|
|
73
|
-
_props$exportOptions = props.exportOptions,
|
|
74
|
-
exportOptions = _props$exportOptions === void 0 ? [] : _props$exportOptions,
|
|
75
|
-
_props$shownavigation = props.shownavigation,
|
|
76
|
-
shownavigation = _props$shownavigation === void 0 ? true : _props$shownavigation,
|
|
77
|
-
_props$onDemandLoad = props.onDemandLoad,
|
|
78
|
-
onDemandLoad = _props$onDemandLoad === void 0 ? false : _props$onDemandLoad,
|
|
79
|
-
_props$showrowindex = props.showrowindex,
|
|
80
|
-
showrowindex = _props$showrowindex === void 0 ? false : _props$showrowindex,
|
|
81
|
-
_props$showheader = props.showheader,
|
|
82
|
-
showheader = _props$showheader === void 0 ? true : _props$showheader,
|
|
83
|
-
_props$enablesort = props.enablesort,
|
|
84
|
-
enablesort = _props$enablesort === void 0 ? true : _props$enablesort,
|
|
85
|
-
_props$enablecolumnse = props.enablecolumnselection,
|
|
86
|
-
enablecolumnselection = _props$enablecolumnse === void 0 ? false : _props$enablecolumnse,
|
|
87
|
-
onColumnselect = props.onColumnselect,
|
|
88
|
-
onColumndeselect = props.onColumndeselect,
|
|
89
|
-
_props$radioselect = props.radioselect,
|
|
90
|
-
radioselect = _props$radioselect === void 0 ? false : _props$radioselect,
|
|
91
|
-
_props$radioselecttit = props.radioselecttitle,
|
|
92
|
-
radioselecttitle = _props$radioselecttit === void 0 ? "" : _props$radioselecttit,
|
|
93
|
-
_props$radioselectari = props.radioselectarialabel,
|
|
94
|
-
radioselectarialabel = _props$radioselectari === void 0 ? _utils.TABLE_MESSAGES.radioSelectAriaLabel : _props$radioselectari,
|
|
95
|
-
_props$multiselect = props.multiselect,
|
|
96
|
-
multiselect = _props$multiselect === void 0 ? false : _props$multiselect,
|
|
97
|
-
_props$multiselecttit = props.multiselecttitle,
|
|
98
|
-
multiselecttitle = _props$multiselecttit === void 0 ? "" : _props$multiselecttit,
|
|
99
|
-
_props$multiselectari = props.multiselectarialabel,
|
|
100
|
-
multiselectarialabel = _props$multiselectari === void 0 ? _utils.TABLE_MESSAGES.multiSelectAriaLabel : _props$multiselectari,
|
|
101
|
-
_props$gridfirstrowse = props.gridfirstrowselect,
|
|
102
|
-
gridfirstrowselect = _props$gridfirstrowse === void 0 ? false : _props$gridfirstrowse,
|
|
103
|
-
_props$isrowselectabl = props.isrowselectable,
|
|
104
|
-
isrowselectable = _props$isrowselectabl === void 0 ? false : _props$isrowselectabl,
|
|
105
|
-
_props$rowClass = props.rowClass,
|
|
106
|
-
rowClass = _props$rowClass === void 0 ? "" : _props$rowClass,
|
|
107
|
-
_props$deleteoktext = props.deleteoktext,
|
|
108
|
-
deleteoktext = _props$deleteoktext === void 0 ? _utils.TABLE_MESSAGES.deleteOkText : _props$deleteoktext,
|
|
109
|
-
_props$deletecancelte = props.deletecanceltext,
|
|
110
|
-
deletecanceltext = _props$deletecancelte === void 0 ? _utils.TABLE_MESSAGES.deleteCancelText : _props$deletecancelte,
|
|
111
|
-
_props$confirmdelete = props.confirmdelete,
|
|
112
|
-
confirmdelete = _props$confirmdelete === void 0 ? _utils.TABLE_MESSAGES.deleteConfirmMessage : _props$confirmdelete,
|
|
113
|
-
_props$errormessage = props.errormessage,
|
|
114
|
-
errormessage = _props$errormessage === void 0 ? _utils.TABLE_MESSAGES.operationError : _props$errormessage,
|
|
115
|
-
_props$nodatamessage = props.nodatamessage,
|
|
116
|
-
nodatamessage = _props$nodatamessage === void 0 ? _utils.TABLE_MESSAGES.noDataMessage : _props$nodatamessage,
|
|
117
|
-
_props$loadingdatamsg = props.loadingdatamsg,
|
|
118
|
-
loadingdatamsg = _props$loadingdatamsg === void 0 ? _utils.TABLE_MESSAGES.loadingMessage : _props$loadingdatamsg,
|
|
119
|
-
_props$insertmessage = props.insertmessage,
|
|
120
|
-
insertmessage = _props$insertmessage === void 0 ? _utils.TABLE_MESSAGES.insertSuccess : _props$insertmessage,
|
|
121
|
-
_props$updatemessage = props.updatemessage,
|
|
122
|
-
updatemessage = _props$updatemessage === void 0 ? _utils.TABLE_MESSAGES.updateSuccess : _props$updatemessage,
|
|
123
|
-
_props$deletemessage = props.deletemessage,
|
|
124
|
-
deletemessage = _props$deletemessage === void 0 ? _utils.TABLE_MESSAGES.deleteSuccess : _props$deletemessage,
|
|
125
|
-
_props$ondemandmessag = props.ondemandmessage,
|
|
126
|
-
ondemandmessage = _props$ondemandmessag === void 0 ? "Load More" : _props$ondemandmessag,
|
|
127
|
-
_props$viewlessmessag = props.viewlessmessage,
|
|
128
|
-
viewlessmessage = _props$viewlessmessag === void 0 ? "View Less" : _props$viewlessmessag,
|
|
129
|
-
_props$showviewlessbu = props.showviewlessbutton,
|
|
130
|
-
showviewlessbutton = _props$showviewlessbu === void 0 ? false : _props$showviewlessbu,
|
|
131
|
-
onRowDelete = props.onRowDelete,
|
|
132
|
-
onRowUpdate = props.onRowUpdate,
|
|
133
|
-
datasource = props.datasource,
|
|
134
|
-
binddataset = props.binddataset,
|
|
135
|
-
onSuccess = props.onSuccess,
|
|
136
|
-
onError = props.onError,
|
|
137
|
-
onRowinsert = props.onRowinsert,
|
|
138
|
-
onRowupdate = props.onRowupdate,
|
|
139
|
-
onRowdelete = props.onRowdelete,
|
|
140
|
-
onRowclick = props.onRowclick,
|
|
141
|
-
onSort = props.onSort,
|
|
142
|
-
onBeforerowdelete = props.onBeforerowdelete,
|
|
143
|
-
onBeforefilter = props.onBeforefilter,
|
|
144
|
-
onHeaderclick = props.onHeaderclick,
|
|
145
|
-
onRowselect = props.onRowselect,
|
|
146
|
-
onRowdeselect = props.onRowdeselect,
|
|
147
|
-
onSetrecord = props.onSetrecord,
|
|
148
|
-
statehandler = props.statehandler,
|
|
149
|
-
formName = props.formName,
|
|
150
|
-
parentForm = props.parentForm,
|
|
151
|
-
filtermode = props.filtermode,
|
|
152
|
-
_props$filteronkeypre = props.filteronkeypress,
|
|
153
|
-
filteronkeypress = _props$filteronkeypre === void 0 ? false : _props$filteronkeypre,
|
|
154
|
-
_props$searchlabel = props.searchlabel,
|
|
155
|
-
searchlabel = _props$searchlabel === void 0 ? "Search" : _props$searchlabel,
|
|
156
|
-
onBeforedatarender = props.onBeforedatarender,
|
|
157
|
-
onDatarender = props.onDatarender,
|
|
158
|
-
className = props.className,
|
|
159
|
-
exportformat = props.exportformat,
|
|
160
|
-
exportdatasize = props.exportdatasize,
|
|
161
|
-
onBeforeexport = props.onBeforeexport,
|
|
162
|
-
onAfterexport = props.onAfterexport,
|
|
163
|
-
styles = props.styles,
|
|
164
|
-
rest = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
|
165
|
-
// When same partial is used multiple times (e.g. in tabs), use unique storage key to prevent state collision
|
|
166
|
-
var effectiveStorageKey = (0, _react.useMemo)(function () {
|
|
167
|
-
return name + (listener !== null && listener !== void 0 && listener.partialName ? "__".concat(listener === null || listener === void 0 ? void 0 : listener.partialName) : "");
|
|
168
|
-
}, [name, listener === null || listener === void 0 ? void 0 : listener.partialName]);
|
|
169
|
-
var widgetRegistrationKey = props["item-id"] || name;
|
|
170
|
-
var listenerRef = (0, _react.useRef)(listener);
|
|
171
|
-
listenerRef.current = listener;
|
|
172
|
-
var loading = (datasource === null || datasource === void 0 ? void 0 : datasource.loading) || false;
|
|
173
|
-
var prevDatasetRef = (0, _react.useRef)(dataset);
|
|
174
|
-
var prevSelectedRow = (0, _react.useRef)(null);
|
|
175
|
-
var tableApisRegistered = (0, _react.useRef)(false);
|
|
176
|
-
|
|
177
|
-
// State for accumulated data in Scroll and On-Demand navigation modes
|
|
178
|
-
var _useState = (0, _react.useState)([]),
|
|
179
|
-
accumulatedData = _useState[0],
|
|
180
|
-
setAccumulatedData = _useState[1];
|
|
181
|
-
|
|
182
|
-
// Callback to receive accumulated data from pagination (for Scroll and On-Demand)
|
|
183
|
-
var handleAccumulatedDataUpdate = (0, _react.useCallback)(function (data) {
|
|
184
|
-
// Only update if data has actually changed to prevent unnecessary re-renders
|
|
185
|
-
setAccumulatedData(function (prevData) {
|
|
186
|
-
// If lengths are different, it's definitely new data
|
|
187
|
-
if (prevData.length !== data.length) {
|
|
188
|
-
return data;
|
|
189
|
-
}
|
|
190
|
-
// Otherwise keep the previous reference to avoid re-render
|
|
191
|
-
return prevData;
|
|
192
|
-
});
|
|
193
|
-
}, []);
|
|
194
|
-
|
|
195
|
-
// Reset accumulated data when navigation changes
|
|
196
|
-
(0, _react.useEffect)(function () {
|
|
197
|
-
if (navigation !== "Scroll" && navigation !== "On-Demand") {
|
|
198
|
-
setAccumulatedData([]);
|
|
199
|
-
}
|
|
200
|
-
}, [navigation]);
|
|
201
|
-
var notifyApp = listener === null || listener === void 0 || (_listener$App = listener.App) === null || _listener$App === void 0 ? void 0 : _listener$App.notifyApp;
|
|
202
|
-
|
|
203
|
-
// Create a centralized toast notification function
|
|
204
|
-
var showToast = (0, _react.useCallback)(function (message, type) {
|
|
205
|
-
if (notifyApp) {
|
|
206
|
-
notifyApp(message, type);
|
|
207
|
-
}
|
|
208
|
-
}, [notifyApp]);
|
|
209
|
-
|
|
210
|
-
// Determine if we're using server-side pagination
|
|
211
|
-
// Check if datasource is API-aware (server-side) rather than checking runtime pagination data
|
|
212
|
-
var isServerSidePagination = (0, _react.useCallback)(function () {
|
|
213
|
-
if (navigation === "None") {
|
|
214
|
-
return false;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
215
17
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
var
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
(
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
widgetType: "table",
|
|
229
|
-
onPageRestored: function onPageRestored() {
|
|
230
|
-
// This will be called when datasource loads with restored page
|
|
231
|
-
// The page is already set in datasource options, so we don't need to do anything here
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
232
30
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
33
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
34
|
+
import React, {
|
|
35
|
+
memo,
|
|
36
|
+
useCallback,
|
|
37
|
+
useEffect,
|
|
38
|
+
useMemo,
|
|
39
|
+
useState,
|
|
40
|
+
useRef
|
|
41
|
+
} from "react";
|
|
42
|
+
import {
|
|
43
|
+
useReactTable,
|
|
44
|
+
getCoreRowModel,
|
|
45
|
+
getPaginationRowModel,
|
|
46
|
+
getSortedRowModel
|
|
47
|
+
} from "@tanstack/react-table";
|
|
48
|
+
import { Box, Table } from "@mui/material";
|
|
49
|
+
import { uniqueId, find, isEqual } from "lodash-es";
|
|
50
|
+
import withBaseWrapper from "../../../higherOrder/withBaseWrapper";
|
|
51
|
+
import WmPagination from "../pagination";
|
|
52
|
+
import {
|
|
53
|
+
useTableData,
|
|
54
|
+
useFormWidget,
|
|
55
|
+
usePanelStructure,
|
|
56
|
+
useTableEdit,
|
|
57
|
+
useTableColumns,
|
|
58
|
+
useRowSelection,
|
|
59
|
+
useTableState,
|
|
60
|
+
useCellState,
|
|
61
|
+
useRowHandlers,
|
|
62
|
+
usePaginationState,
|
|
63
|
+
useTableInitialization,
|
|
64
|
+
useRowExpansion,
|
|
65
|
+
useServerSideSorting,
|
|
66
|
+
useTableEffects,
|
|
67
|
+
useTableStateManager,
|
|
68
|
+
useTableFilter,
|
|
69
|
+
useDynamicColumns,
|
|
70
|
+
useCustomExpressionColumns
|
|
71
|
+
} from "./hooks";
|
|
72
|
+
import {
|
|
73
|
+
parseTableColumns,
|
|
74
|
+
parseTableStructureWithGroups,
|
|
75
|
+
flattenTableStructure,
|
|
76
|
+
parseTableRowActions,
|
|
77
|
+
parseTableActions,
|
|
78
|
+
parseTableRowExpansion,
|
|
79
|
+
getSpacingClasses,
|
|
80
|
+
TABLE_CSS_CLASSES,
|
|
81
|
+
TABLE_MESSAGES,
|
|
82
|
+
getTableState,
|
|
83
|
+
saveTableState,
|
|
84
|
+
clearTableState,
|
|
85
|
+
addUniqueRowIds,
|
|
86
|
+
cleanRowData
|
|
87
|
+
} from "./utils";
|
|
88
|
+
import { hasTableGroups } from "./utils/groupHeaderUtils";
|
|
89
|
+
import { handleNewRowNavigation } from "./utils";
|
|
90
|
+
import {
|
|
91
|
+
TablePanelHeading,
|
|
92
|
+
TableFooterActions,
|
|
93
|
+
TableBodyComponent,
|
|
94
|
+
TableHeaderComponent,
|
|
95
|
+
GlobalSearchFilter,
|
|
96
|
+
SummaryRowFooter
|
|
97
|
+
} from "./components";
|
|
98
|
+
import { buildSelectionColumns } from "./utils/buildSelectionColumns";
|
|
99
|
+
import LoadingComponent from "../pagination/components/LoadingComponent";
|
|
100
|
+
import { createColumnsProxy } from "./utils/columnProxy";
|
|
101
|
+
import { useDataSourceSubscription } from "../../../hooks/useDataSourceSubscription";
|
|
102
|
+
import { refreshDataSource } from "./utils/crud-handlers";
|
|
103
|
+
import { DataSource } from "../types";
|
|
104
|
+
import { EditedRowsProvider } from "./hooks/use-edited-rows";
|
|
105
|
+
import {
|
|
106
|
+
subscribeToScriptPageSizeBroadcast,
|
|
107
|
+
broadcastScriptPageSize
|
|
108
|
+
} from "./utils/script-page-size-broadcast";
|
|
109
|
+
import withStandalone from "../../../higherOrder/withStandalone";
|
|
110
|
+
const WmTableComponent = memo(
|
|
111
|
+
(props) => {
|
|
112
|
+
var _a, _b, _d, _e, _f, _g, _h, _i;
|
|
113
|
+
const _c = props, {
|
|
114
|
+
name,
|
|
115
|
+
dataset = [],
|
|
116
|
+
navigation = "Basic",
|
|
117
|
+
children,
|
|
118
|
+
listener,
|
|
119
|
+
pagesize = 5,
|
|
120
|
+
navigationalign = "left",
|
|
121
|
+
showrecordcount = false,
|
|
122
|
+
maxsize = 5,
|
|
123
|
+
boundarylinks = false,
|
|
124
|
+
allowpagesizechange = false,
|
|
125
|
+
pagesizeoptions = "5,10,20,50,100",
|
|
126
|
+
formposition = "bottom",
|
|
127
|
+
editmode = "none",
|
|
128
|
+
spacing = "normal",
|
|
129
|
+
title,
|
|
130
|
+
subheading,
|
|
131
|
+
iconclass,
|
|
132
|
+
exportOptions = [],
|
|
133
|
+
shownavigation = true,
|
|
134
|
+
onDemandLoad = false,
|
|
135
|
+
showrowindex = false,
|
|
136
|
+
showheader = true,
|
|
137
|
+
enablesort = true,
|
|
138
|
+
enablecolumnselection = false,
|
|
139
|
+
onColumnselect,
|
|
140
|
+
onColumndeselect,
|
|
141
|
+
radioselect = false,
|
|
142
|
+
radioselecttitle = "",
|
|
143
|
+
radioselectarialabel = (_a = TABLE_MESSAGES) == null ? void 0 : _a.radioSelectAriaLabel,
|
|
144
|
+
multiselect = false,
|
|
145
|
+
multiselecttitle = "",
|
|
146
|
+
multiselectarialabel = (_b = TABLE_MESSAGES) == null ? void 0 : _b.multiSelectAriaLabel,
|
|
147
|
+
gridfirstrowselect = false,
|
|
148
|
+
isrowselectable = false,
|
|
149
|
+
rowClass = "",
|
|
150
|
+
deleteoktext = TABLE_MESSAGES.deleteOkText,
|
|
151
|
+
deletecanceltext = TABLE_MESSAGES.deleteCancelText,
|
|
152
|
+
confirmdelete = TABLE_MESSAGES.deleteConfirmMessage,
|
|
153
|
+
errormessage = TABLE_MESSAGES.operationError,
|
|
154
|
+
nodatamessage = TABLE_MESSAGES.noDataMessage,
|
|
155
|
+
loadingdatamsg = TABLE_MESSAGES.loadingMessage,
|
|
156
|
+
insertmessage = TABLE_MESSAGES.insertSuccess,
|
|
157
|
+
updatemessage = TABLE_MESSAGES.updateSuccess,
|
|
158
|
+
deletemessage = TABLE_MESSAGES.deleteSuccess,
|
|
159
|
+
ondemandmessage = "Load More",
|
|
160
|
+
viewlessmessage = "View Less",
|
|
161
|
+
showviewlessbutton = false,
|
|
162
|
+
onRowDelete,
|
|
163
|
+
onRowUpdate,
|
|
164
|
+
datasource,
|
|
165
|
+
binddataset,
|
|
166
|
+
onSuccess,
|
|
167
|
+
onError,
|
|
168
|
+
onRowinsert,
|
|
169
|
+
onRowupdate,
|
|
170
|
+
onRowdelete,
|
|
171
|
+
onRowclick,
|
|
172
|
+
onSort,
|
|
173
|
+
onBeforerowdelete,
|
|
174
|
+
onBeforefilter,
|
|
175
|
+
onHeaderclick,
|
|
176
|
+
onRowselect,
|
|
177
|
+
onRowdeselect,
|
|
178
|
+
onSetrecord,
|
|
179
|
+
statehandler,
|
|
180
|
+
formName,
|
|
181
|
+
parentForm,
|
|
182
|
+
filtermode,
|
|
183
|
+
filteronkeypress = false,
|
|
184
|
+
searchlabel = "Search",
|
|
185
|
+
onBeforedatarender,
|
|
186
|
+
onDatarender,
|
|
187
|
+
className,
|
|
188
|
+
exportformat,
|
|
189
|
+
exportdatasize,
|
|
190
|
+
onBeforeexport,
|
|
191
|
+
onAfterexport,
|
|
192
|
+
styles
|
|
193
|
+
} = _c, rest = __objRest(_c, [
|
|
194
|
+
"name",
|
|
195
|
+
"dataset",
|
|
196
|
+
"navigation",
|
|
197
|
+
"children",
|
|
198
|
+
"listener",
|
|
199
|
+
"pagesize",
|
|
200
|
+
"navigationalign",
|
|
201
|
+
"showrecordcount",
|
|
202
|
+
"maxsize",
|
|
203
|
+
"boundarylinks",
|
|
204
|
+
"allowpagesizechange",
|
|
205
|
+
"pagesizeoptions",
|
|
206
|
+
"formposition",
|
|
207
|
+
"editmode",
|
|
208
|
+
"spacing",
|
|
209
|
+
"title",
|
|
210
|
+
"subheading",
|
|
211
|
+
"iconclass",
|
|
212
|
+
"exportOptions",
|
|
213
|
+
"shownavigation",
|
|
214
|
+
"onDemandLoad",
|
|
215
|
+
"showrowindex",
|
|
216
|
+
"showheader",
|
|
217
|
+
"enablesort",
|
|
218
|
+
"enablecolumnselection",
|
|
219
|
+
"onColumnselect",
|
|
220
|
+
"onColumndeselect",
|
|
221
|
+
"radioselect",
|
|
222
|
+
"radioselecttitle",
|
|
223
|
+
"radioselectarialabel",
|
|
224
|
+
"multiselect",
|
|
225
|
+
"multiselecttitle",
|
|
226
|
+
"multiselectarialabel",
|
|
227
|
+
"gridfirstrowselect",
|
|
228
|
+
"isrowselectable",
|
|
229
|
+
"rowClass",
|
|
230
|
+
"deleteoktext",
|
|
231
|
+
"deletecanceltext",
|
|
232
|
+
"confirmdelete",
|
|
233
|
+
"errormessage",
|
|
234
|
+
"nodatamessage",
|
|
235
|
+
"loadingdatamsg",
|
|
236
|
+
"insertmessage",
|
|
237
|
+
"updatemessage",
|
|
238
|
+
"deletemessage",
|
|
239
|
+
"ondemandmessage",
|
|
240
|
+
"viewlessmessage",
|
|
241
|
+
"showviewlessbutton",
|
|
242
|
+
"onRowDelete",
|
|
243
|
+
"onRowUpdate",
|
|
244
|
+
"datasource",
|
|
245
|
+
"binddataset",
|
|
246
|
+
"onSuccess",
|
|
247
|
+
"onError",
|
|
248
|
+
"onRowinsert",
|
|
249
|
+
"onRowupdate",
|
|
250
|
+
"onRowdelete",
|
|
251
|
+
"onRowclick",
|
|
252
|
+
"onSort",
|
|
253
|
+
"onBeforerowdelete",
|
|
254
|
+
"onBeforefilter",
|
|
255
|
+
"onHeaderclick",
|
|
256
|
+
"onRowselect",
|
|
257
|
+
"onRowdeselect",
|
|
258
|
+
"onSetrecord",
|
|
259
|
+
"statehandler",
|
|
260
|
+
"formName",
|
|
261
|
+
"parentForm",
|
|
262
|
+
"filtermode",
|
|
263
|
+
"filteronkeypress",
|
|
264
|
+
"searchlabel",
|
|
265
|
+
"onBeforedatarender",
|
|
266
|
+
"onDatarender",
|
|
267
|
+
"className",
|
|
268
|
+
"exportformat",
|
|
269
|
+
"exportdatasize",
|
|
270
|
+
"onBeforeexport",
|
|
271
|
+
"onAfterexport",
|
|
272
|
+
"styles"
|
|
273
|
+
]);
|
|
274
|
+
const effectiveStorageKey = useMemo(
|
|
275
|
+
() => name + ((listener == null ? void 0 : listener.partialName) ? `__${listener == null ? void 0 : listener.partialName}` : ""),
|
|
276
|
+
[name, listener == null ? void 0 : listener.partialName]
|
|
277
|
+
);
|
|
278
|
+
const widgetRegistrationKey = props["item-id"] || name;
|
|
279
|
+
const listenerRef = useRef(listener);
|
|
280
|
+
listenerRef.current = listener;
|
|
281
|
+
const loading = (datasource == null ? void 0 : datasource.loading) || false;
|
|
282
|
+
const prevDatasetRef = useRef(dataset);
|
|
283
|
+
const prevSelectedRow = useRef(null);
|
|
284
|
+
const tableApisRegistered = useRef(false);
|
|
285
|
+
const [accumulatedData, setAccumulatedData] = useState([]);
|
|
286
|
+
const handleAccumulatedDataUpdate = useCallback((data) => {
|
|
287
|
+
setAccumulatedData((prevData) => {
|
|
288
|
+
if (prevData.length !== data.length) {
|
|
289
|
+
return data;
|
|
290
|
+
}
|
|
291
|
+
return prevData;
|
|
292
|
+
});
|
|
293
|
+
}, []);
|
|
294
|
+
useEffect(() => {
|
|
295
|
+
if (navigation !== "Scroll" && navigation !== "On-Demand") {
|
|
296
|
+
setAccumulatedData([]);
|
|
297
|
+
}
|
|
298
|
+
}, [navigation]);
|
|
299
|
+
const notifyApp = (_d = listener == null ? void 0 : listener.App) == null ? void 0 : _d.notifyApp;
|
|
300
|
+
const showToast = useCallback(
|
|
301
|
+
(message, type) => {
|
|
302
|
+
if (notifyApp) {
|
|
303
|
+
notifyApp(message, type);
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
[notifyApp]
|
|
307
|
+
);
|
|
308
|
+
const isServerSidePagination = useCallback(() => {
|
|
309
|
+
if (navigation === "None") {
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
return !!(datasource && datasource.execute && datasource.execute(DataSource.Operation.IS_PAGEABLE));
|
|
313
|
+
}, [datasource, navigation]);
|
|
314
|
+
const effectiveStateHandler = navigation === "Scroll" ? "none" : statehandler;
|
|
315
|
+
useDataSourceSubscription({
|
|
316
|
+
datasource,
|
|
317
|
+
statehandler: effectiveStateHandler,
|
|
318
|
+
name,
|
|
319
|
+
widgetType: "table",
|
|
320
|
+
onPageRestored: () => {
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
const { internalDataset, setInternalDataset, deleteRecord, renderConfirmDialog } = useTableData(
|
|
324
|
+
{
|
|
325
|
+
dataset,
|
|
326
|
+
onRowDelete,
|
|
327
|
+
deleteoktext,
|
|
328
|
+
deletecanceltext,
|
|
329
|
+
confirmdelete,
|
|
330
|
+
deletemessage,
|
|
331
|
+
errormessage,
|
|
332
|
+
showToast,
|
|
333
|
+
datasource,
|
|
334
|
+
binddataset,
|
|
335
|
+
onSuccess,
|
|
336
|
+
onError,
|
|
337
|
+
onRowdelete,
|
|
338
|
+
isServerSidePagination: isServerSidePagination(),
|
|
339
|
+
listener,
|
|
340
|
+
widgetName: name
|
|
341
|
+
}
|
|
342
|
+
);
|
|
343
|
+
const { renderFormWidget } = useFormWidget({
|
|
344
|
+
listener
|
|
345
|
+
});
|
|
346
|
+
const cellState = useCellState(name);
|
|
347
|
+
const syncSelectedItemsImplRef = useRef(null);
|
|
348
|
+
const onSyncSelectedItems = useCallback(
|
|
349
|
+
(ids) => {
|
|
350
|
+
var _a2;
|
|
351
|
+
return (_a2 = syncSelectedItemsImplRef.current) == null ? void 0 : _a2.call(syncSelectedItemsImplRef, ids);
|
|
352
|
+
},
|
|
353
|
+
[]
|
|
354
|
+
);
|
|
355
|
+
const {
|
|
356
|
+
initialPage,
|
|
357
|
+
initialPageSize,
|
|
358
|
+
initialActualPageSize,
|
|
359
|
+
initialSearchState,
|
|
360
|
+
initialSortState
|
|
361
|
+
} = useMemo(() => {
|
|
362
|
+
var _a2;
|
|
281
363
|
if (navigation === "Scroll") {
|
|
282
364
|
return {
|
|
283
365
|
initialPage: 1,
|
|
284
366
|
initialPageSize: pagesize,
|
|
285
|
-
initialActualPageSize:
|
|
286
|
-
initialSearchState:
|
|
287
|
-
initialSortState:
|
|
367
|
+
initialActualPageSize: void 0,
|
|
368
|
+
initialSearchState: void 0,
|
|
369
|
+
initialSortState: void 0
|
|
288
370
|
};
|
|
289
371
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
return a - b;
|
|
297
|
-
});
|
|
298
|
-
var hasExplicitPersistedPageSize = persisted != null && persisted.pagesize !== undefined && persisted.pagesize !== null;
|
|
299
|
-
|
|
300
|
-
// Align with Angular TableComponent.setDefaultPageSize: when allowpagesizechange is on
|
|
301
|
-
// and there is no persisted pagesize, use the smallest pagesize option (not design-time pagesize).
|
|
302
|
-
var defaultPageSizeFromOptions = allowpagesizechange && sortedPageSizeOptions.length > 0 && !hasExplicitPersistedPageSize ? sortedPageSizeOptions[0] : 20;
|
|
303
|
-
|
|
304
|
-
// Determine the actual page size (original datasource page size)
|
|
305
|
-
var actualPageSize;
|
|
306
|
-
if ((persisted === null || persisted === void 0 ? void 0 : persisted.actualpagesize) !== undefined) {
|
|
307
|
-
// If we have a persisted actualPageSize, use it (it should never change)
|
|
372
|
+
const persisted = getTableState(name, effectiveStateHandler);
|
|
373
|
+
const sortedPageSizeOptions = (pagesizeoptions || "").split(",").map((v) => Number(v.trim())).filter((n) => !Number.isNaN(n)).sort((a, b) => a - b);
|
|
374
|
+
const hasExplicitPersistedPageSize = persisted != null && persisted.pagesize !== void 0 && persisted.pagesize !== null;
|
|
375
|
+
const defaultPageSizeFromOptions = allowpagesizechange && sortedPageSizeOptions.length > 0 && !hasExplicitPersistedPageSize ? sortedPageSizeOptions[0] : 20;
|
|
376
|
+
let actualPageSize;
|
|
377
|
+
if ((persisted == null ? void 0 : persisted.actualpagesize) !== void 0) {
|
|
308
378
|
actualPageSize = persisted.actualpagesize;
|
|
309
|
-
} else if (datasource
|
|
310
|
-
// Otherwise, if this is the first load, capture it from datasource
|
|
379
|
+
} else if ((_a2 = datasource == null ? void 0 : datasource.pagination) == null ? void 0 : _a2.size) {
|
|
311
380
|
actualPageSize = datasource.pagination.size;
|
|
312
|
-
} else if (datasource
|
|
313
|
-
// Fallback to maxResults if available
|
|
381
|
+
} else if (datasource == null ? void 0 : datasource.maxResults) {
|
|
314
382
|
actualPageSize = datasource.maxResults;
|
|
315
383
|
}
|
|
316
384
|
if (persisted) {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
// The server will return new filtered data, so old pagination is invalid
|
|
322
|
-
var restoredPage = hasActiveFilter ? 1 : persisted.pagination || 1;
|
|
323
|
-
var persistedPageSize = hasExplicitPersistedPageSize ? persisted.pagesize : defaultPageSizeFromOptions !== null && defaultPageSizeFromOptions !== void 0 ? defaultPageSizeFromOptions : pagesize;
|
|
324
|
-
|
|
325
|
-
// Set datasource maxResults if we have a persisted pageSize and datasource
|
|
326
|
-
if (isServerSidePagination() && datasource && datasource.maxResults !== undefined && hasExplicitPersistedPageSize) {
|
|
385
|
+
const hasActiveFilter = persisted.search && persisted.search.length > 0;
|
|
386
|
+
const restoredPage = hasActiveFilter ? 1 : persisted.pagination || 1;
|
|
387
|
+
const persistedPageSize = hasExplicitPersistedPageSize ? persisted.pagesize : defaultPageSizeFromOptions != null ? defaultPageSizeFromOptions : pagesize;
|
|
388
|
+
if (isServerSidePagination() && datasource && datasource.maxResults !== void 0 && hasExplicitPersistedPageSize) {
|
|
327
389
|
datasource.maxResults = persistedPageSize;
|
|
328
390
|
}
|
|
329
391
|
return {
|
|
330
392
|
initialPage: restoredPage,
|
|
331
393
|
initialPageSize: persistedPageSize,
|
|
332
394
|
initialActualPageSize: actualPageSize,
|
|
333
|
-
initialSearchState: persisted.search ||
|
|
334
|
-
initialSortState: persisted.sort ||
|
|
395
|
+
initialSearchState: persisted.search || void 0,
|
|
396
|
+
initialSortState: persisted.sort || void 0
|
|
335
397
|
};
|
|
336
398
|
}
|
|
337
|
-
|
|
399
|
+
const initialPageSize2 = defaultPageSizeFromOptions !== void 0 ? defaultPageSizeFromOptions : actualPageSize || pagesize;
|
|
338
400
|
return {
|
|
339
401
|
initialPage: 1,
|
|
340
|
-
initialPageSize:
|
|
402
|
+
initialPageSize: initialPageSize2,
|
|
341
403
|
initialActualPageSize: pagesize,
|
|
342
|
-
initialSearchState:
|
|
343
|
-
initialSortState:
|
|
404
|
+
initialSearchState: void 0,
|
|
405
|
+
initialSortState: void 0
|
|
344
406
|
};
|
|
345
|
-
}, [name, effectiveStateHandler, pagesize, isServerSidePagination(), datasource, navigation])
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
// Use pagination state hook - manages controlled pagination state
|
|
362
|
-
var _usePaginationState = (0, _hooks.usePaginationState)({
|
|
363
|
-
initialPage: initialPage,
|
|
364
|
-
initialPageSize: initialPageSize,
|
|
365
|
-
editmode: editmode,
|
|
366
|
-
internalDataset: internalDataset,
|
|
367
|
-
datasource: datasource,
|
|
407
|
+
}, [name, effectiveStateHandler, pagesize, isServerSidePagination(), datasource, navigation]);
|
|
408
|
+
const tableRef = React.useRef(null);
|
|
409
|
+
const tableContainerRef = React.useRef(null);
|
|
410
|
+
const prevPageIndexRef = useRef(-1);
|
|
411
|
+
const {
|
|
412
|
+
paginationState,
|
|
413
|
+
setPaginationState,
|
|
414
|
+
handlePaginationChange,
|
|
415
|
+
handlePageSizeChange: handlePageSizeChangeBase
|
|
416
|
+
} = usePaginationState({
|
|
417
|
+
initialPage,
|
|
418
|
+
initialPageSize,
|
|
419
|
+
editmode,
|
|
420
|
+
internalDataset,
|
|
421
|
+
datasource,
|
|
368
422
|
isServerSidePagination: isServerSidePagination()
|
|
369
|
-
})
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
423
|
+
});
|
|
424
|
+
const effectiveMultiselect = multiselect;
|
|
425
|
+
const {
|
|
426
|
+
selectedRowIds,
|
|
427
|
+
useMultiSelect,
|
|
428
|
+
useRadioSelect,
|
|
429
|
+
handleRadioSelection,
|
|
430
|
+
handleMultiSelection,
|
|
431
|
+
handleSelectAll,
|
|
432
|
+
handleRowSelectionClick,
|
|
433
|
+
isRowSelected
|
|
434
|
+
} = useRowSelection({
|
|
435
|
+
radioselect,
|
|
381
436
|
multiselect: effectiveMultiselect,
|
|
382
|
-
gridfirstrowselect
|
|
383
|
-
internalDataset
|
|
384
|
-
cellState
|
|
385
|
-
name
|
|
437
|
+
gridfirstrowselect,
|
|
438
|
+
internalDataset,
|
|
439
|
+
cellState,
|
|
440
|
+
name,
|
|
386
441
|
statehandler: effectiveStateHandler,
|
|
387
|
-
initialActualPageSize
|
|
388
|
-
getTableState:
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
listener: listener,
|
|
400
|
-
navigation: navigation,
|
|
401
|
-
onSyncSelectedItems: onSyncSelectedItems
|
|
402
|
-
}),
|
|
403
|
-
selectedRowIds = _useRowSelection.selectedRowIds,
|
|
404
|
-
useMultiSelect = _useRowSelection.useMultiSelect,
|
|
405
|
-
useRadioSelect = _useRowSelection.useRadioSelect,
|
|
406
|
-
handleRadioSelection = _useRowSelection.handleRadioSelection,
|
|
407
|
-
handleMultiSelection = _useRowSelection.handleMultiSelection,
|
|
408
|
-
handleSelectAll = _useRowSelection.handleSelectAll,
|
|
409
|
-
handleRowSelectionClick = _useRowSelection.handleRowSelectionClick,
|
|
410
|
-
isRowSelected = _useRowSelection.isRowSelected;
|
|
411
|
-
|
|
412
|
-
// Use table state hook
|
|
413
|
-
var _useTableState = (0, _hooks.useTableState)({
|
|
442
|
+
initialActualPageSize,
|
|
443
|
+
getTableState: () => tableRef.current ? {
|
|
444
|
+
currentPage: tableRef.current.getState().pagination.pageIndex + 1,
|
|
445
|
+
currentPageSize: tableRef.current.getState().pagination.pageSize
|
|
446
|
+
} : { currentPage: 1, currentPageSize: initialPageSize },
|
|
447
|
+
onRowselect,
|
|
448
|
+
onRowdeselect,
|
|
449
|
+
listener,
|
|
450
|
+
navigation,
|
|
451
|
+
onSyncSelectedItems
|
|
452
|
+
});
|
|
453
|
+
const { activeRowIds, setActiveRow, handleRowActiveClick, isRowActive } = useTableState({
|
|
414
454
|
editMode: editmode,
|
|
415
|
-
radioselect
|
|
455
|
+
radioselect,
|
|
416
456
|
multiselect: effectiveMultiselect
|
|
417
|
-
})
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
// This ensures that when rows are selected/deselected, the active state follows
|
|
425
|
-
(0, _react.useEffect)(function () {
|
|
426
|
-
if (useRadioSelect || useMultiSelect) {
|
|
427
|
-
setActiveRow(selectedRowIds);
|
|
428
|
-
}
|
|
429
|
-
}, [selectedRowIds, useRadioSelect, useMultiSelect, setActiveRow]);
|
|
430
|
-
|
|
431
|
-
// Use dynamic columns hook to generate columns from data when no children are provided.
|
|
432
|
-
// Use the raw dataset prop (not internalDataset) so column structure (keys/schema) is
|
|
433
|
-
// derived from the actual API response — even when all values are empty strings,
|
|
434
|
-
// removeEmptyRecords would otherwise wipe out internalDataset and leave dynamicColumns empty.
|
|
435
|
-
var _useDynamicColumns = (0, _hooks.useDynamicColumns)({
|
|
457
|
+
});
|
|
458
|
+
useEffect(() => {
|
|
459
|
+
if (useRadioSelect || useMultiSelect) {
|
|
460
|
+
setActiveRow(selectedRowIds);
|
|
461
|
+
}
|
|
462
|
+
}, [selectedRowIds, useRadioSelect, useMultiSelect, setActiveRow]);
|
|
463
|
+
const { dynamicColumns, isDynamicTable } = useDynamicColumns({
|
|
436
464
|
dataset: dataset || [],
|
|
437
|
-
children
|
|
438
|
-
listener
|
|
439
|
-
})
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
465
|
+
children,
|
|
466
|
+
listener
|
|
467
|
+
});
|
|
468
|
+
const {
|
|
469
|
+
wmTableColumns,
|
|
470
|
+
tableStructure,
|
|
471
|
+
rowActions,
|
|
472
|
+
headerActions,
|
|
473
|
+
footerActions,
|
|
474
|
+
rowExpansionConfig
|
|
475
|
+
} = useMemo(() => {
|
|
476
|
+
const allTableActions = parseTableActions(children);
|
|
477
|
+
const headerActions2 = allTableActions.filter((action) => {
|
|
478
|
+
const position = action.position || "footer";
|
|
448
479
|
return position === "header" || position.includes("header");
|
|
449
480
|
});
|
|
450
|
-
|
|
451
|
-
|
|
481
|
+
const footerActions2 = allTableActions.filter((action) => {
|
|
482
|
+
const position = action.position || "footer";
|
|
452
483
|
return position === "footer" || position.includes("footer") || !action.position;
|
|
453
484
|
});
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
// Get static columns from children
|
|
460
|
-
var staticColumns = (0, _utils.parseTableColumns)(children, internalDataset);
|
|
461
|
-
|
|
462
|
-
// Check if we have groups in the structure
|
|
463
|
-
var hasGroups = structure.some(function (item) {
|
|
464
|
-
return "isGroup" in item && item.isGroup;
|
|
465
|
-
});
|
|
466
|
-
|
|
467
|
-
// Determine final columns:
|
|
468
|
-
// - If groups exist, use flatColumns (from structure) to preserve group structure
|
|
469
|
-
// - Otherwise, prefer static columns, then dynamic columns, then flat columns from structure
|
|
470
|
-
var finalColumns = hasGroups && flatColumns.length > 0 ? flatColumns : staticColumns.length > 0 ? staticColumns : isDynamicTable && dynamicColumns.length > 0 ? dynamicColumns : flatColumns;
|
|
485
|
+
const structure = parseTableStructureWithGroups(children);
|
|
486
|
+
const flatColumns = flattenTableStructure(structure);
|
|
487
|
+
const staticColumns = parseTableColumns(children, internalDataset);
|
|
488
|
+
const hasGroups = structure.some((item) => "isGroup" in item && item.isGroup);
|
|
489
|
+
const finalColumns = hasGroups && flatColumns.length > 0 ? flatColumns : staticColumns.length > 0 ? staticColumns : isDynamicTable && dynamicColumns.length > 0 ? dynamicColumns : flatColumns;
|
|
471
490
|
return {
|
|
472
491
|
wmTableColumns: finalColumns,
|
|
473
492
|
tableStructure: structure,
|
|
474
|
-
rowActions:
|
|
493
|
+
rowActions: parseTableRowActions(children),
|
|
475
494
|
tableActions: allTableActions,
|
|
476
|
-
headerActions:
|
|
477
|
-
footerActions:
|
|
478
|
-
rowExpansionConfig:
|
|
495
|
+
headerActions: headerActions2,
|
|
496
|
+
footerActions: footerActions2,
|
|
497
|
+
rowExpansionConfig: parseTableRowExpansion(children)
|
|
479
498
|
};
|
|
480
|
-
}, [children, internalDataset, isDynamicTable, dynamicColumns])
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
499
|
+
}, [children, internalDataset, isDynamicTable, dynamicColumns]);
|
|
500
|
+
const [columnsVersion, setColumnsVersion] = useState(0);
|
|
501
|
+
const [columnOverrides, setColumnOverrides] = useState(
|
|
502
|
+
{}
|
|
503
|
+
);
|
|
504
|
+
const applyOverride = useCallback((field, key, value) => {
|
|
505
|
+
setColumnOverrides((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
506
|
+
[field]: __spreadProps(__spreadValues({}, prev[field] || {}), { [key]: value })
|
|
507
|
+
}));
|
|
508
|
+
}, []);
|
|
509
|
+
const wmTableColumnsWithOverrides = useMemo(
|
|
510
|
+
() => wmTableColumns.map((col) => {
|
|
511
|
+
const f = col == null ? void 0 : col.field;
|
|
512
|
+
if (!f) return col;
|
|
513
|
+
const o = columnOverrides[f];
|
|
514
|
+
if (!o || Object.keys(o).length === 0) return col;
|
|
515
|
+
return __spreadValues(__spreadValues({}, col), o);
|
|
516
|
+
}),
|
|
517
|
+
[wmTableColumns, columnOverrides]
|
|
518
|
+
);
|
|
519
|
+
const {
|
|
520
|
+
editingRowId,
|
|
521
|
+
isRowEditing,
|
|
522
|
+
startEditing,
|
|
523
|
+
cancelEditing,
|
|
524
|
+
saveEditing,
|
|
525
|
+
renderEditableCell,
|
|
526
|
+
isAddingNewRow,
|
|
527
|
+
handleAddNewRowClick,
|
|
528
|
+
renderAddNewRow,
|
|
529
|
+
handleRowClick: handleTableEditRowClick,
|
|
530
|
+
handleKeyDown: handleTableEditKeyDown
|
|
531
|
+
} = useTableEdit({
|
|
513
532
|
editMode: editmode,
|
|
514
|
-
internalDataset
|
|
515
|
-
setInternalDataset
|
|
533
|
+
internalDataset,
|
|
534
|
+
setInternalDataset,
|
|
516
535
|
wmTableColumns: wmTableColumnsWithOverrides,
|
|
517
|
-
cellState
|
|
518
|
-
renderFormWidget
|
|
519
|
-
listener
|
|
520
|
-
onRowUpdate
|
|
521
|
-
onRowDelete
|
|
522
|
-
onNewRowAdded:
|
|
523
|
-
|
|
524
|
-
(0, _utils.handleNewRowNavigation)(tableRef, newRecord, internalDataset);
|
|
536
|
+
cellState,
|
|
537
|
+
renderFormWidget,
|
|
538
|
+
listener,
|
|
539
|
+
onRowUpdate,
|
|
540
|
+
onRowDelete,
|
|
541
|
+
onNewRowAdded: (newRecord) => {
|
|
542
|
+
handleNewRowNavigation(tableRef, newRecord, internalDataset);
|
|
525
543
|
},
|
|
526
|
-
showrowindex
|
|
527
|
-
radioselect
|
|
544
|
+
showrowindex,
|
|
545
|
+
radioselect,
|
|
528
546
|
multiselect: effectiveMultiselect,
|
|
529
|
-
rowActions
|
|
530
|
-
formposition
|
|
531
|
-
insertmessage
|
|
532
|
-
updatemessage
|
|
533
|
-
errormessage
|
|
534
|
-
showToast
|
|
547
|
+
rowActions,
|
|
548
|
+
formposition,
|
|
549
|
+
insertmessage,
|
|
550
|
+
updatemessage,
|
|
551
|
+
errormessage,
|
|
552
|
+
showToast,
|
|
535
553
|
hasRowExpansion: rowExpansionConfig ? rowExpansionConfig.show : false,
|
|
536
554
|
expansionPosition: rowExpansionConfig ? parseInt(String(rowExpansionConfig.position || "0"), 10) : 0,
|
|
537
|
-
datasource
|
|
538
|
-
binddataset
|
|
539
|
-
onSuccess
|
|
540
|
-
onError
|
|
541
|
-
onRowinsert
|
|
542
|
-
onRowupdate
|
|
543
|
-
onRowdelete
|
|
544
|
-
tableRef
|
|
555
|
+
datasource,
|
|
556
|
+
binddataset,
|
|
557
|
+
onSuccess,
|
|
558
|
+
onError,
|
|
559
|
+
onRowinsert,
|
|
560
|
+
onRowupdate,
|
|
561
|
+
onRowdelete,
|
|
562
|
+
tableRef,
|
|
545
563
|
isServerSidePagination: isServerSidePagination(),
|
|
546
564
|
tableName: name
|
|
547
|
-
})
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
isAddingNewRow
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
useRadioSelect: useRadioSelect,
|
|
569
|
-
useMultiSelect: useMultiSelect,
|
|
570
|
-
isrowselectable: isrowselectable,
|
|
571
|
-
listener: listener,
|
|
572
|
-
name: name
|
|
573
|
-
}),
|
|
574
|
-
handleRowClick = _useRowHandlers.handleRowClick;
|
|
575
|
-
|
|
576
|
-
// Effect to cancel editing when page changes
|
|
577
|
-
(0, _react.useEffect)(function () {
|
|
578
|
-
var currentPage = paginationState.pageIndex;
|
|
579
|
-
// Skip on initial render (when prevPageIndexRef is still -1)
|
|
580
|
-
// The ref is initialized to -1 and only updated after first data render
|
|
581
|
-
if (prevPageIndexRef.current !== -1 && currentPage !== prevPageIndexRef.current && isAddingNewRow) {
|
|
582
|
-
cancelEditing();
|
|
583
|
-
}
|
|
584
|
-
// Don't update the ref here - it's updated in the data render effect
|
|
585
|
-
}, [paginationState.pageIndex, isAddingNewRow, cancelEditing]);
|
|
586
|
-
|
|
587
|
-
// Track sorting and column sizing states
|
|
588
|
-
var _useState4 = (0, _react.useState)(function () {
|
|
589
|
-
// Convert initialSortState to TanStack Table sorting format
|
|
565
|
+
});
|
|
566
|
+
const { handleRowClick } = useRowHandlers({
|
|
567
|
+
editingRowId,
|
|
568
|
+
isAddingNewRow,
|
|
569
|
+
handleRowSelectionClick,
|
|
570
|
+
handleTableEditRowClick,
|
|
571
|
+
handleRowActiveClick,
|
|
572
|
+
onRowclick,
|
|
573
|
+
useRadioSelect,
|
|
574
|
+
useMultiSelect,
|
|
575
|
+
isrowselectable,
|
|
576
|
+
listener,
|
|
577
|
+
name
|
|
578
|
+
});
|
|
579
|
+
useEffect(() => {
|
|
580
|
+
const currentPage = paginationState.pageIndex;
|
|
581
|
+
if (prevPageIndexRef.current !== -1 && currentPage !== prevPageIndexRef.current && isAddingNewRow) {
|
|
582
|
+
cancelEditing();
|
|
583
|
+
}
|
|
584
|
+
}, [paginationState.pageIndex, isAddingNewRow, cancelEditing]);
|
|
585
|
+
const [sorting, setSorting] = useState(() => {
|
|
590
586
|
if (initialSortState) {
|
|
591
|
-
return [
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
587
|
+
return [
|
|
588
|
+
{
|
|
589
|
+
id: initialSortState.field,
|
|
590
|
+
desc: initialSortState.direction === "desc"
|
|
591
|
+
}
|
|
592
|
+
];
|
|
595
593
|
}
|
|
596
594
|
return [];
|
|
597
|
-
}),
|
|
598
|
-
sorting = _useState4[0],
|
|
599
|
-
setSorting = _useState4[1];
|
|
600
|
-
var _useState5 = (0, _react.useState)({}),
|
|
601
|
-
columnSizing = _useState5[0],
|
|
602
|
-
setColumnSizing = _useState5[1];
|
|
603
|
-
var _useState6 = (0, _react.useState)(false),
|
|
604
|
-
isResizing = _useState6[0],
|
|
605
|
-
setIsResizing = _useState6[1];
|
|
606
|
-
|
|
607
|
-
// Column selection handlers - just call the external callbacks
|
|
608
|
-
// The class toggling is handled directly in TableHeaderComponent
|
|
609
|
-
var handleColumnSelect = (0, _react.useCallback)(function (event, columnId, colDef, columnData) {
|
|
610
|
-
if (onColumnselect) {
|
|
611
|
-
onColumnselect(event, {
|
|
612
|
-
field: columnId,
|
|
613
|
-
colDef: colDef,
|
|
614
|
-
data: columnData
|
|
615
|
-
});
|
|
616
|
-
}
|
|
617
|
-
}, [onColumnselect]);
|
|
618
|
-
var handleColumnDeselect = (0, _react.useCallback)(function (event, columnId, colDef, columnData) {
|
|
619
|
-
if (onColumndeselect) {
|
|
620
|
-
onColumndeselect(event, {
|
|
621
|
-
field: columnId,
|
|
622
|
-
colDef: colDef,
|
|
623
|
-
data: columnData
|
|
624
|
-
});
|
|
625
|
-
}
|
|
626
|
-
}, [onColumndeselect]);
|
|
627
|
-
|
|
628
|
-
// Custom sorting change handler that resets page to 1 when sorting changes
|
|
629
|
-
var handleSortingChange = (0, _react.useCallback)(function (updaterOrValue) {
|
|
630
|
-
var newSorting = typeof updaterOrValue === "function" ? updaterOrValue(sorting) : updaterOrValue;
|
|
631
|
-
setSorting(updaterOrValue);
|
|
632
|
-
// Reset to first page when sorting changes
|
|
633
|
-
setPaginationState(function (prev) {
|
|
634
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
635
|
-
pageIndex: 0
|
|
636
|
-
});
|
|
637
595
|
});
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
};
|
|
646
|
-
onSort(null, listener === null || listener === void 0 || (_listener$Widgets = listener.Widgets) === null || _listener$Widgets === void 0 ? void 0 : _listener$Widgets[name], sortData);
|
|
647
|
-
}
|
|
648
|
-
}, [sorting, name]);
|
|
649
|
-
|
|
650
|
-
// Use row expansion hook
|
|
651
|
-
var _useRowExpansion = (0, _hooks.useRowExpansion)({
|
|
652
|
-
rowExpansionConfig: rowExpansionConfig,
|
|
653
|
-
internalDataset: internalDataset
|
|
654
|
-
}),
|
|
655
|
-
expandedRows = _useRowExpansion.expandedRows,
|
|
656
|
-
toggleRowExpansion = _useRowExpansion.toggleRowExpansion,
|
|
657
|
-
isRowExpanded = _useRowExpansion.isRowExpanded,
|
|
658
|
-
registerRowDefInstance = _useRowExpansion.registerRowDefInstance,
|
|
659
|
-
rowDefInstances = _useRowExpansion.rowDefInstances;
|
|
660
|
-
var handleToggleRowExpansion = (0, _react.useCallback)(function (rowId, rowData) {
|
|
661
|
-
if (listener !== null && listener !== void 0 && listener.onChange) {
|
|
662
|
-
var selecteditem = (0, _utils.cleanRowData)(rowData);
|
|
663
|
-
if (!(0, _lodashEs.isEqual)(prevSelectedRow.current, selecteditem)) {
|
|
664
|
-
prevSelectedRow.current = selecteditem;
|
|
665
|
-
listener.onChange(widgetRegistrationKey, {
|
|
666
|
-
selecteditem: selecteditem
|
|
667
|
-
});
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
setTimeout(function () {
|
|
671
|
-
return toggleRowExpansion(rowId, rowData);
|
|
672
|
-
}, 0);
|
|
673
|
-
}, [name]);
|
|
674
|
-
|
|
675
|
-
// Use table columns hook to get column definitions
|
|
676
|
-
var _useTableColumns = (0, _hooks.useTableColumns)({
|
|
677
|
-
wmTableColumns: wmTableColumnsWithOverrides,
|
|
678
|
-
columnsVersion: columnsVersion,
|
|
679
|
-
rowActions: rowActions,
|
|
680
|
-
listener: listener,
|
|
681
|
-
deleteRecord: function deleteRecord(rowData) {
|
|
682
|
-
return _deleteRecord(rowData, tableRef.current);
|
|
596
|
+
const [columnSizing, setColumnSizing] = useState({});
|
|
597
|
+
const [isResizing, setIsResizing] = useState(false);
|
|
598
|
+
const handleColumnSelect = useCallback(
|
|
599
|
+
(event, columnId, colDef, columnData) => {
|
|
600
|
+
if (onColumnselect) {
|
|
601
|
+
onColumnselect(event, { field: columnId, colDef, data: columnData });
|
|
602
|
+
}
|
|
683
603
|
},
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
});
|
|
720
|
-
if (selectionColumn) {
|
|
721
|
-
return [selectionColumn].concat((0, _toConsumableArray2["default"])(baseColumns));
|
|
722
|
-
}
|
|
723
|
-
return baseColumns;
|
|
724
|
-
}, [baseColumns, useRadioSelect, useMultiSelect, selectedRowIds, internalDataset, handleRadioSelection, handleMultiSelection, handleSelectAll, radioselecttitle, radioselectarialabel, multiselecttitle, multiselectarialabel, name]);
|
|
725
|
-
|
|
726
|
-
//column proxy changes
|
|
727
|
-
var columnsStateRef = (0, _react.useRef)(columns);
|
|
728
|
-
var parentFormColumns = (listener === null || listener === void 0 || (_listener$Widgets2 = listener.Widgets) === null || _listener$Widgets2 === void 0 || (_listener$Widgets2 = _listener$Widgets2[parentForm]) === null || _listener$Widgets2 === void 0 ? void 0 : _listener$Widgets2.dataoutput) || {};
|
|
729
|
-
var _useState7 = (0, _react.useState)([]),
|
|
730
|
-
summaryRowDefs = _useState7[0],
|
|
731
|
-
setSummaryRowDefs = _useState7[1];
|
|
732
|
-
var _useState8 = (0, _react.useState)(false),
|
|
733
|
-
summaryRowEnabled = _useState8[0],
|
|
734
|
-
setSummaryRowEnabled = _useState8[1];
|
|
735
|
-
var _useState9 = (0, _react.useState)([]),
|
|
736
|
-
summaryRowDefObjects = _useState9[0],
|
|
737
|
-
setSummaryRowDefObjects = _useState9[1];
|
|
738
|
-
// Store column show property for summary rows: [rowIndex][columnKey] => show boolean
|
|
739
|
-
var _useState0 = (0, _react.useState)({}),
|
|
740
|
-
summaryRowColumnShow = _useState0[0],
|
|
741
|
-
setSummaryRowColumnShow = _useState0[1];
|
|
742
|
-
var setSummaryRowDef = (0, _react.useCallback)(function (columnKey, data, rowIndex, refresh, show) {
|
|
743
|
-
setSummaryRowDefs(function (prev) {
|
|
744
|
-
var newDefs = (0, _toConsumableArray2["default"])(prev);
|
|
745
|
-
newDefs[rowIndex] = _objectSpread(_objectSpread({}, newDefs[rowIndex]), {}, (0, _defineProperty2["default"])({}, columnKey, data));
|
|
746
|
-
return newDefs;
|
|
747
|
-
});
|
|
748
|
-
setSummaryRowDefObjects(function (prev) {
|
|
749
|
-
var newObjs = (0, _toConsumableArray2["default"])(prev);
|
|
750
|
-
newObjs[rowIndex] = _objectSpread(_objectSpread({}, newObjs[rowIndex]), {}, (0, _defineProperty2["default"])({}, columnKey, data));
|
|
751
|
-
return newObjs;
|
|
604
|
+
[onColumnselect]
|
|
605
|
+
);
|
|
606
|
+
const handleColumnDeselect = useCallback(
|
|
607
|
+
(event, columnId, colDef, columnData) => {
|
|
608
|
+
if (onColumndeselect) {
|
|
609
|
+
onColumndeselect(event, { field: columnId, colDef, data: columnData });
|
|
610
|
+
}
|
|
611
|
+
},
|
|
612
|
+
[onColumndeselect]
|
|
613
|
+
);
|
|
614
|
+
const handleSortingChange = useCallback(
|
|
615
|
+
(updaterOrValue) => {
|
|
616
|
+
var _a2;
|
|
617
|
+
const newSorting = typeof updaterOrValue === "function" ? updaterOrValue(sorting) : updaterOrValue;
|
|
618
|
+
setSorting(updaterOrValue);
|
|
619
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { pageIndex: 0 }));
|
|
620
|
+
if (onSort && newSorting.length > 0) {
|
|
621
|
+
const sortData = {
|
|
622
|
+
field: newSorting[0].id,
|
|
623
|
+
direction: newSorting[0].desc ? "desc" : "asc"
|
|
624
|
+
};
|
|
625
|
+
onSort(null, (_a2 = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _a2[name], sortData);
|
|
626
|
+
}
|
|
627
|
+
},
|
|
628
|
+
[sorting, name]
|
|
629
|
+
);
|
|
630
|
+
const {
|
|
631
|
+
expandedRows,
|
|
632
|
+
toggleRowExpansion,
|
|
633
|
+
isRowExpanded,
|
|
634
|
+
registerRowDefInstance,
|
|
635
|
+
rowDefInstances
|
|
636
|
+
} = useRowExpansion({
|
|
637
|
+
rowExpansionConfig,
|
|
638
|
+
internalDataset
|
|
752
639
|
});
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
640
|
+
const handleToggleRowExpansion = useCallback(
|
|
641
|
+
(rowId, rowData) => {
|
|
642
|
+
if (listener == null ? void 0 : listener.onChange) {
|
|
643
|
+
const selecteditem = cleanRowData(rowData);
|
|
644
|
+
if (!isEqual(prevSelectedRow.current, selecteditem)) {
|
|
645
|
+
prevSelectedRow.current = selecteditem;
|
|
646
|
+
listener.onChange(widgetRegistrationKey, { selecteditem });
|
|
647
|
+
}
|
|
759
648
|
}
|
|
760
|
-
|
|
761
|
-
|
|
649
|
+
setTimeout(() => toggleRowExpansion(rowId, rowData), 0);
|
|
650
|
+
},
|
|
651
|
+
[name]
|
|
652
|
+
);
|
|
653
|
+
const { columns: baseColumns } = useTableColumns({
|
|
654
|
+
wmTableColumns: wmTableColumnsWithOverrides,
|
|
655
|
+
columnsVersion,
|
|
656
|
+
rowActions,
|
|
657
|
+
listener,
|
|
658
|
+
deleteRecord: (rowData) => deleteRecord(rowData, tableRef.current),
|
|
659
|
+
showrowindex,
|
|
660
|
+
editmode,
|
|
661
|
+
isDynamicTable,
|
|
662
|
+
renderEditableCell,
|
|
663
|
+
isRowEditing,
|
|
664
|
+
startEditing,
|
|
665
|
+
cancelEditing,
|
|
666
|
+
saveEditing,
|
|
667
|
+
editingRowId,
|
|
668
|
+
cellState,
|
|
669
|
+
isResizing,
|
|
670
|
+
handleRowClick,
|
|
671
|
+
handleRadioSelection,
|
|
672
|
+
handleMultiSelection,
|
|
673
|
+
useRadioSelect,
|
|
674
|
+
useMultiSelect,
|
|
675
|
+
isRowSelected
|
|
676
|
+
});
|
|
677
|
+
const columns = useMemo(() => {
|
|
678
|
+
const selectionColumn = buildSelectionColumns({
|
|
679
|
+
useRadioSelect,
|
|
680
|
+
useMultiSelect,
|
|
681
|
+
selectedRowIds,
|
|
682
|
+
handleRadioSelection,
|
|
683
|
+
handleMultiSelection,
|
|
684
|
+
handleSelectAll,
|
|
685
|
+
internalDataset,
|
|
686
|
+
radioselecttitle,
|
|
687
|
+
radioselectarialabel,
|
|
688
|
+
multiselecttitle,
|
|
689
|
+
multiselectarialabel,
|
|
690
|
+
tableName: name
|
|
762
691
|
});
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
692
|
+
if (selectionColumn) {
|
|
693
|
+
return [selectionColumn, ...baseColumns];
|
|
694
|
+
}
|
|
695
|
+
return baseColumns;
|
|
696
|
+
}, [
|
|
697
|
+
baseColumns,
|
|
698
|
+
useRadioSelect,
|
|
699
|
+
useMultiSelect,
|
|
700
|
+
selectedRowIds,
|
|
701
|
+
internalDataset,
|
|
702
|
+
handleRadioSelection,
|
|
703
|
+
handleMultiSelection,
|
|
704
|
+
handleSelectAll,
|
|
705
|
+
radioselecttitle,
|
|
706
|
+
radioselectarialabel,
|
|
707
|
+
multiselecttitle,
|
|
708
|
+
multiselectarialabel,
|
|
709
|
+
name
|
|
710
|
+
]);
|
|
711
|
+
const columnsStateRef = useRef(columns);
|
|
712
|
+
const parentFormColumns = ((_f = (_e = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _e[parentForm]) == null ? void 0 : _f.dataoutput) || {};
|
|
713
|
+
const [summaryRowDefs, setSummaryRowDefs] = useState([]);
|
|
714
|
+
const [summaryRowEnabled, setSummaryRowEnabled] = useState(false);
|
|
715
|
+
const [summaryRowDefObjects, setSummaryRowDefObjects] = useState([]);
|
|
716
|
+
const [summaryRowColumnShow, setSummaryRowColumnShow] = useState({});
|
|
717
|
+
const setSummaryRowDef = useCallback(
|
|
718
|
+
(columnKey, data, rowIndex, refresh2, show) => {
|
|
719
|
+
setSummaryRowDefs((prev) => {
|
|
720
|
+
const newDefs = [...prev];
|
|
721
|
+
newDefs[rowIndex] = __spreadProps(__spreadValues({}, newDefs[rowIndex]), { [columnKey]: data });
|
|
722
|
+
return newDefs;
|
|
723
|
+
});
|
|
724
|
+
setSummaryRowDefObjects((prev) => {
|
|
725
|
+
const newObjs = [...prev];
|
|
726
|
+
newObjs[rowIndex] = __spreadProps(__spreadValues({}, newObjs[rowIndex]), { [columnKey]: data });
|
|
727
|
+
return newObjs;
|
|
728
|
+
});
|
|
729
|
+
if (show !== void 0) {
|
|
730
|
+
setSummaryRowColumnShow((prev) => {
|
|
731
|
+
const newShow = __spreadValues({}, prev);
|
|
732
|
+
if (!newShow[rowIndex]) {
|
|
733
|
+
newShow[rowIndex] = {};
|
|
734
|
+
}
|
|
735
|
+
newShow[rowIndex] = __spreadProps(__spreadValues({}, newShow[rowIndex]), { [columnKey]: show });
|
|
736
|
+
return newShow;
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
setSummaryRowEnabled(true);
|
|
740
|
+
},
|
|
741
|
+
[]
|
|
742
|
+
);
|
|
743
|
+
const columnsProxy = useMemo(
|
|
744
|
+
() => createColumnsProxy(wmTableColumns, applyOverride, setColumnsVersion, setSummaryRowDef),
|
|
745
|
+
[wmTableColumns, applyOverride, setColumnsVersion, setSummaryRowDef]
|
|
746
|
+
);
|
|
747
|
+
const {
|
|
748
|
+
customColumns,
|
|
749
|
+
customColumnsRevision,
|
|
750
|
+
customExpressionSignature,
|
|
751
|
+
mergeParsedCustomColumns
|
|
752
|
+
} = useCustomExpressionColumns({
|
|
770
753
|
columnSource: columnsProxy,
|
|
771
|
-
listenerRef
|
|
772
|
-
}),
|
|
773
|
-
customColumns = _useCustomExpressionC.customColumns,
|
|
774
|
-
customColumnsRevision = _useCustomExpressionC.customColumnsRevision,
|
|
775
|
-
customExpressionSignature = _useCustomExpressionC.customExpressionSignature,
|
|
776
|
-
mergeParsedCustomColumns = _useCustomExpressionC.mergeParsedCustomColumns;
|
|
777
|
-
columnsStateRef.current = columns;
|
|
778
|
-
var columnsForTable = (0, _react.useMemo)(function () {
|
|
779
|
-
var base = columnsStateRef.current || [];
|
|
780
|
-
return base.map(function (col) {
|
|
781
|
-
var field = col.accessorKey || col.id;
|
|
782
|
-
var override = field ? columnOverrides[field] || {} : {};
|
|
783
|
-
return _objectSpread(_objectSpread(_objectSpread({}, col), override), Object.keys(override).length > 0 ? {
|
|
784
|
-
meta: _objectSpread(_objectSpread({}, col.meta), override)
|
|
785
|
-
} : {});
|
|
754
|
+
listenerRef
|
|
786
755
|
});
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
756
|
+
columnsStateRef.current = columns;
|
|
757
|
+
const columnsForTable = useMemo(() => {
|
|
758
|
+
const base = columnsStateRef.current || [];
|
|
759
|
+
return base.map((col) => {
|
|
760
|
+
const field = col.accessorKey || col.id;
|
|
761
|
+
const override = field ? columnOverrides[field] || {} : {};
|
|
762
|
+
return __spreadValues(__spreadValues(__spreadValues({}, col), override), Object.keys(override).length > 0 ? { meta: __spreadValues(__spreadValues({}, col.meta), override) } : {});
|
|
763
|
+
});
|
|
764
|
+
}, [columns, columnOverrides, columnsVersion, editingRowId]);
|
|
765
|
+
const ColClassSignature = useMemo(() => {
|
|
766
|
+
try {
|
|
767
|
+
return (columnsForTable || []).map((col) => {
|
|
768
|
+
const m = col == null ? void 0 : col.meta;
|
|
769
|
+
return [m == null ? void 0 : m.className, m == null ? void 0 : m.colClass].map((v) => String(v != null ? v : "")).join(":");
|
|
770
|
+
}).join("|");
|
|
771
|
+
} catch (e) {
|
|
772
|
+
return "";
|
|
773
|
+
}
|
|
774
|
+
}, [columnsForTable]);
|
|
775
|
+
const {
|
|
776
|
+
globalFilter,
|
|
777
|
+
setGlobalFilter: setGlobalFilterOriginal,
|
|
778
|
+
globalSearchColumn,
|
|
779
|
+
setGlobalSearchColumn,
|
|
780
|
+
columnFilters,
|
|
781
|
+
setColumnFilter: setColumnFilterOriginal,
|
|
782
|
+
filteredData,
|
|
783
|
+
getFilterFields,
|
|
784
|
+
transformFilterFields
|
|
785
|
+
} = useTableFilter({
|
|
805
786
|
filterMode: filtermode,
|
|
806
787
|
columns: columnsForTable,
|
|
807
788
|
dataset: (navigation === "Scroll" || navigation === "On-Demand") && accumulatedData.length > 0 ? accumulatedData : internalDataset,
|
|
808
|
-
initialSearchState
|
|
809
|
-
}),
|
|
810
|
-
globalFilter = _useTableFilter.globalFilter,
|
|
811
|
-
setGlobalFilterOriginal = _useTableFilter.setGlobalFilter,
|
|
812
|
-
globalSearchColumn = _useTableFilter.globalSearchColumn,
|
|
813
|
-
setGlobalSearchColumn = _useTableFilter.setGlobalSearchColumn,
|
|
814
|
-
columnFilters = _useTableFilter.columnFilters,
|
|
815
|
-
setColumnFilterOriginal = _useTableFilter.setColumnFilter,
|
|
816
|
-
filteredData = _useTableFilter.filteredData,
|
|
817
|
-
getFilterFields = _useTableFilter.getFilterFields,
|
|
818
|
-
transformFilterFields = _useTableFilter.transformFilterFields;
|
|
819
|
-
|
|
820
|
-
// Wrap filter setters to reset page when filters change
|
|
821
|
-
var setGlobalFilter = (0, _react.useCallback)(function (value) {
|
|
822
|
-
setGlobalFilterOriginal(value);
|
|
823
|
-
// Reset to first page when filter changes
|
|
824
|
-
setPaginationState(function (prev) {
|
|
825
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
826
|
-
pageIndex: 0
|
|
827
|
-
});
|
|
789
|
+
initialSearchState
|
|
828
790
|
});
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
791
|
+
const setGlobalFilter = useCallback(
|
|
792
|
+
(value) => {
|
|
793
|
+
setGlobalFilterOriginal(value);
|
|
794
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { pageIndex: 0 }));
|
|
795
|
+
},
|
|
796
|
+
[setGlobalFilterOriginal]
|
|
797
|
+
);
|
|
798
|
+
const setColumnFilter = useCallback(
|
|
799
|
+
(columnId, value, matchMode) => {
|
|
800
|
+
setColumnFilterOriginal(columnId, value, matchMode);
|
|
801
|
+
setPaginationState((prev) => __spreadProps(__spreadValues({}, prev), { pageIndex: 0 }));
|
|
802
|
+
},
|
|
803
|
+
[setColumnFilterOriginal]
|
|
804
|
+
);
|
|
805
|
+
const resizeTimeoutRef = useRef(null);
|
|
806
|
+
const handleColumnSizingChange = useCallback(
|
|
807
|
+
(updaterOrValue) => {
|
|
808
|
+
setIsResizing((prev) => {
|
|
809
|
+
if (!prev) return true;
|
|
810
|
+
return prev;
|
|
811
|
+
});
|
|
812
|
+
setColumnSizing(updaterOrValue);
|
|
813
|
+
if (resizeTimeoutRef.current) {
|
|
814
|
+
clearTimeout(resizeTimeoutRef.current);
|
|
815
|
+
}
|
|
816
|
+
resizeTimeoutRef.current = setTimeout(() => {
|
|
817
|
+
setIsResizing(false);
|
|
818
|
+
}, 150);
|
|
819
|
+
},
|
|
820
|
+
[]
|
|
821
|
+
);
|
|
822
|
+
const rowSelection = useMemo(() => {
|
|
823
|
+
const selection = {};
|
|
824
|
+
selectedRowIds.forEach((id) => {
|
|
825
|
+
selection[id] = true;
|
|
836
826
|
});
|
|
827
|
+
return selection;
|
|
828
|
+
}, [selectedRowIds]);
|
|
829
|
+
const isServerSideSorting = isServerSidePagination();
|
|
830
|
+
const tableData = useMemo(() => {
|
|
831
|
+
if ((navigation === "Scroll" || navigation === "On-Demand") && accumulatedData.length > 0) {
|
|
832
|
+
return filtermode && !isServerSidePagination() ? filteredData : accumulatedData;
|
|
833
|
+
}
|
|
834
|
+
return filtermode && !isServerSidePagination() ? filteredData : internalDataset;
|
|
835
|
+
}, [
|
|
836
|
+
navigation,
|
|
837
|
+
accumulatedData,
|
|
838
|
+
filteredData,
|
|
839
|
+
internalDataset,
|
|
840
|
+
filtermode,
|
|
841
|
+
isServerSidePagination
|
|
842
|
+
]);
|
|
843
|
+
const memoizedPagination = useMemo(
|
|
844
|
+
() => ({
|
|
845
|
+
pageSize: navigation === "None" ? (tableData == null ? void 0 : tableData.length) || 0 : paginationState.pageSize,
|
|
846
|
+
pageIndex: paginationState.pageIndex
|
|
847
|
+
}),
|
|
848
|
+
[navigation, tableData == null ? void 0 : tableData.length, paginationState.pageSize, paginationState.pageIndex]
|
|
849
|
+
);
|
|
850
|
+
const table = useReactTable({
|
|
851
|
+
data: tableData,
|
|
852
|
+
columns: columnsForTable,
|
|
853
|
+
state: {
|
|
854
|
+
sorting,
|
|
855
|
+
columnSizing,
|
|
856
|
+
rowSelection,
|
|
857
|
+
// Add row selection state
|
|
858
|
+
pagination: memoizedPagination
|
|
859
|
+
},
|
|
860
|
+
onSortingChange: handleSortingChange,
|
|
861
|
+
onColumnSizingChange: handleColumnSizingChange,
|
|
862
|
+
onPaginationChange: setPaginationState,
|
|
863
|
+
getCoreRowModel: getCoreRowModel(),
|
|
864
|
+
// Only use pagination model for client-side pagination
|
|
865
|
+
getPaginationRowModel: isServerSidePagination() ? void 0 : getPaginationRowModel(),
|
|
866
|
+
// Use sorted row model only for client-side sorting
|
|
867
|
+
getSortedRowModel: isServerSideSorting ? void 0 : getSortedRowModel(),
|
|
868
|
+
enableSorting: enablesort,
|
|
869
|
+
enableSortingRemoval: false,
|
|
870
|
+
autoResetPageIndex: false,
|
|
871
|
+
enableColumnResizing: true,
|
|
872
|
+
columnResizeMode: "onChange",
|
|
873
|
+
// Keep onChange for real-time visual feedback
|
|
874
|
+
enableRowSelection: true,
|
|
875
|
+
// Enable row selection
|
|
876
|
+
// Use manual pagination and sorting for server-side operations
|
|
877
|
+
manualPagination: isServerSidePagination(),
|
|
878
|
+
manualSorting: isServerSideSorting,
|
|
879
|
+
pageCount: isServerSidePagination() && ((_g = datasource == null ? void 0 : datasource.pagination) == null ? void 0 : _g.totalPages) ? datasource.pagination.totalPages : void 0,
|
|
880
|
+
getRowId: (row) => row._wmTableRowId || String(row.id) || uniqueId("row_")
|
|
837
881
|
});
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
var handleColumnSizingChange = (0, _react.useCallback)(function (updaterOrValue) {
|
|
845
|
-
// Only update resizing state if it's not already true
|
|
846
|
-
setIsResizing(function (prev) {
|
|
847
|
-
if (!prev) return true;
|
|
848
|
-
return prev;
|
|
849
|
-
});
|
|
850
|
-
setColumnSizing(updaterOrValue);
|
|
851
|
-
|
|
852
|
-
// Clear any existing timeout
|
|
853
|
-
if (resizeTimeoutRef.current) {
|
|
854
|
-
clearTimeout(resizeTimeoutRef.current);
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
// Set a debounced timeout to detect when resizing has stopped
|
|
858
|
-
resizeTimeoutRef.current = setTimeout(function () {
|
|
859
|
-
setIsResizing(false);
|
|
860
|
-
}, 150); // 150ms delay to detect when user stops resizing
|
|
861
|
-
}, []);
|
|
862
|
-
|
|
863
|
-
// Create custom row selection state for TanStack Table
|
|
864
|
-
// Uses unified selectedRowIds array - works for both radio select (1 item) and multiselect (multiple items)
|
|
865
|
-
var rowSelection = (0, _react.useMemo)(function () {
|
|
866
|
-
var selection = {};
|
|
867
|
-
selectedRowIds.forEach(function (id) {
|
|
868
|
-
selection[id] = true;
|
|
869
|
-
});
|
|
870
|
-
return selection;
|
|
871
|
-
}, [selectedRowIds]);
|
|
872
|
-
|
|
873
|
-
// Determine if we're using server-side sorting (same as server-side pagination)
|
|
874
|
-
var isServerSideSorting = isServerSidePagination();
|
|
875
|
-
|
|
876
|
-
// Use accumulated data for Scroll and On-Demand navigation, otherwise use normal dataset
|
|
877
|
-
var tableData = (0, _react.useMemo)(function () {
|
|
878
|
-
// For Scroll and On-Demand, use accumulated data from pagination
|
|
879
|
-
if ((navigation === "Scroll" || navigation === "On-Demand") && accumulatedData.length > 0) {
|
|
880
|
-
// For server-side pagination, don't apply client-side filtering as server already filters
|
|
881
|
-
return filtermode && !isServerSidePagination() ? filteredData : accumulatedData;
|
|
882
|
-
}
|
|
883
|
-
// For server-side pagination, use internalDataset directly (already filtered by server)
|
|
884
|
-
// Client-side filtering should only be applied for client-side pagination
|
|
885
|
-
return filtermode && !isServerSidePagination() ? filteredData : internalDataset;
|
|
886
|
-
}, [navigation, accumulatedData, filteredData, internalDataset, filtermode, isServerSidePagination]);
|
|
887
|
-
|
|
888
|
-
// Memoize pagination options to prevent unnecessary re-renders
|
|
889
|
-
var memoizedPagination = (0, _react.useMemo)(function () {
|
|
890
|
-
return {
|
|
891
|
-
pageSize: navigation === "None" ? (tableData === null || tableData === void 0 ? void 0 : tableData.length) || 0 : paginationState.pageSize,
|
|
892
|
-
pageIndex: paginationState.pageIndex
|
|
893
|
-
};
|
|
894
|
-
}, [navigation, tableData === null || tableData === void 0 ? void 0 : tableData.length, paginationState.pageSize, paginationState.pageIndex]);
|
|
895
|
-
var table = (0, _reactTable.useReactTable)({
|
|
896
|
-
data: tableData,
|
|
897
|
-
columns: columnsForTable,
|
|
898
|
-
state: {
|
|
899
|
-
sorting: sorting,
|
|
900
|
-
columnSizing: columnSizing,
|
|
901
|
-
rowSelection: rowSelection,
|
|
902
|
-
// Add row selection state
|
|
903
|
-
pagination: memoizedPagination
|
|
904
|
-
},
|
|
905
|
-
onSortingChange: handleSortingChange,
|
|
906
|
-
onColumnSizingChange: handleColumnSizingChange,
|
|
907
|
-
onPaginationChange: setPaginationState,
|
|
908
|
-
getCoreRowModel: (0, _reactTable.getCoreRowModel)(),
|
|
909
|
-
// Only use pagination model for client-side pagination
|
|
910
|
-
getPaginationRowModel: isServerSidePagination() ? undefined : (0, _reactTable.getPaginationRowModel)(),
|
|
911
|
-
// Use sorted row model only for client-side sorting
|
|
912
|
-
getSortedRowModel: isServerSideSorting ? undefined : (0, _reactTable.getSortedRowModel)(),
|
|
913
|
-
enableSorting: enablesort,
|
|
914
|
-
enableSortingRemoval: false,
|
|
915
|
-
autoResetPageIndex: false,
|
|
916
|
-
enableColumnResizing: true,
|
|
917
|
-
columnResizeMode: "onChange",
|
|
918
|
-
// Keep onChange for real-time visual feedback
|
|
919
|
-
enableRowSelection: true,
|
|
920
|
-
// Enable row selection
|
|
921
|
-
// Use manual pagination and sorting for server-side operations
|
|
922
|
-
manualPagination: isServerSidePagination(),
|
|
923
|
-
manualSorting: isServerSideSorting,
|
|
924
|
-
pageCount: isServerSidePagination() && datasource !== null && datasource !== void 0 && (_datasource$paginatio2 = datasource.pagination) !== null && _datasource$paginatio2 !== void 0 && _datasource$paginatio2.totalPages ? datasource.pagination.totalPages : undefined,
|
|
925
|
-
getRowId: function getRowId(row) {
|
|
926
|
-
return row._wmTableRowId || String(row.id) || (0, _lodashEs.uniqueId)("row_");
|
|
927
|
-
}
|
|
928
|
-
});
|
|
929
|
-
|
|
930
|
-
// Update the table ref
|
|
931
|
-
tableRef.current = table;
|
|
932
|
-
|
|
933
|
-
// Memoize filter fields to prevent unnecessary re-renders in useServerSideSorting
|
|
934
|
-
var memoizedFilterFields = (0, _react.useMemo)(function () {
|
|
935
|
-
if (!filtermode) return {};
|
|
936
|
-
var searchObj = filtermode === "search" ? [{
|
|
937
|
-
field: globalSearchColumn,
|
|
938
|
-
value: globalFilter,
|
|
939
|
-
matchMode: "anywhereignorecase",
|
|
940
|
-
type: "string"
|
|
941
|
-
}] : transformFilterFields(columnFilters);
|
|
942
|
-
return getFilterFields(searchObj);
|
|
943
|
-
}, [filtermode, globalSearchColumn, globalFilter, columnFilters, getFilterFields, transformFilterFields]);
|
|
944
|
-
|
|
945
|
-
// Memoize logical operator
|
|
946
|
-
var memoizedLogicalOp = (0, _react.useMemo)(function () {
|
|
947
|
-
return filtermode === "search" && !globalSearchColumn ? "OR" : "AND";
|
|
948
|
-
}, [filtermode, globalSearchColumn]);
|
|
949
|
-
|
|
950
|
-
// Use server-side sorting hook to handle data fetching
|
|
951
|
-
(0, _hooks.useServerSideSorting)({
|
|
952
|
-
datasource: datasource,
|
|
953
|
-
sorting: sorting,
|
|
954
|
-
setInternalDataset: setInternalDataset,
|
|
955
|
-
showToast: showToast,
|
|
956
|
-
isServerSidePagination: isServerSidePagination(),
|
|
957
|
-
pageIndex: table.getState().pagination.pageIndex,
|
|
958
|
-
onError: onError,
|
|
959
|
-
onBeforefilter: onBeforefilter,
|
|
960
|
-
filterFields: memoizedFilterFields,
|
|
961
|
-
logicalOp: memoizedLogicalOp,
|
|
962
|
-
listener: listener,
|
|
963
|
-
name: name
|
|
964
|
-
});
|
|
965
|
-
|
|
966
|
-
// Panel structure management
|
|
967
|
-
var _usePanelStructure = (0, _hooks.usePanelStructure)({
|
|
968
|
-
title: title,
|
|
969
|
-
subheading: subheading,
|
|
970
|
-
iconclass: iconclass,
|
|
971
|
-
exportformat: exportformat,
|
|
972
|
-
headerActions: headerActions,
|
|
973
|
-
footerActions: footerActions,
|
|
974
|
-
shownavigation: shownavigation,
|
|
975
|
-
onDemandLoad: onDemandLoad,
|
|
976
|
-
internalDataset: internalDataset,
|
|
977
|
-
pagesize: pagesize,
|
|
978
|
-
allowpagesizechange: allowpagesizechange,
|
|
979
|
-
datasource: datasource,
|
|
980
|
-
showrecordcount: showrecordcount
|
|
981
|
-
}),
|
|
982
|
-
showPanelHeading = _usePanelStructure.showPanelHeading,
|
|
983
|
-
showPagination = _usePanelStructure.showPagination;
|
|
984
|
-
|
|
985
|
-
// Callback: when pagination widget is ready, set table.dataNavigator = pagination widget proxy
|
|
986
|
-
var handlePaginationWidgetReady = (0, _react.useCallback)(function (paginationWidget) {
|
|
987
|
-
var _listener$Widgets3;
|
|
988
|
-
if (name && listener !== null && listener !== void 0 && (_listener$Widgets3 = listener.Widgets) !== null && _listener$Widgets3 !== void 0 && _listener$Widgets3[name]) {
|
|
989
|
-
listener.Widgets[name].dataNavigator = paginationWidget;
|
|
990
|
-
}
|
|
991
|
-
}, [name, listener]);
|
|
992
|
-
|
|
993
|
-
// Memoize sortInfo for export to prevent unnecessary re-renders
|
|
994
|
-
var sortInfoForExport = (0, _react.useMemo)(function () {
|
|
995
|
-
if (sorting.length > 0) {
|
|
996
|
-
return {
|
|
997
|
-
field: sorting[0].id,
|
|
998
|
-
direction: sorting[0].desc ? "desc" : "asc"
|
|
999
|
-
};
|
|
1000
|
-
}
|
|
1001
|
-
return undefined;
|
|
1002
|
-
}, [sorting]);
|
|
1003
|
-
|
|
1004
|
-
// Update grid edit mode (includes inline editing and add new row)
|
|
1005
|
-
var isGridEditModeComplete = isAddingNewRow || editingRowId !== null;
|
|
1006
|
-
|
|
1007
|
-
// Generate spacing-related classes based on spacing prop
|
|
1008
|
-
var spacingClasses = (0, _utils.getSpacingClasses)(spacing);
|
|
1009
|
-
|
|
1010
|
-
// ==================== STATE MANAGEMENT ====================
|
|
1011
|
-
// Prepare filter data based on filter mode - always in array format
|
|
1012
|
-
var filterDataForState = (0, _react.useMemo)(function () {
|
|
1013
|
-
if (!filtermode) return undefined;
|
|
1014
|
-
if (filtermode === "search") {
|
|
1015
|
-
if (globalFilter || globalSearchColumn) {
|
|
1016
|
-
// Find column type for the selected search column
|
|
1017
|
-
var columnType = globalSearchColumn ? function (_col$meta, _col$meta2) {
|
|
1018
|
-
var col = (0, _lodashEs.find)(columnsForTable, function (c) {
|
|
1019
|
-
var column = c;
|
|
1020
|
-
return column.accessorKey === globalSearchColumn || column.id === globalSearchColumn;
|
|
1021
|
-
});
|
|
1022
|
-
return (col === null || col === void 0 || (_col$meta = col.meta) === null || _col$meta === void 0 ? void 0 : _col$meta.type) || (col === null || col === void 0 || (_col$meta2 = col.meta) === null || _col$meta2 === void 0 ? void 0 : _col$meta2.editinputtype) || "string";
|
|
1023
|
-
}() : "string";
|
|
1024
|
-
return [{
|
|
1025
|
-
field: globalSearchColumn || "",
|
|
882
|
+
tableRef.current = table;
|
|
883
|
+
const memoizedFilterFields = useMemo(() => {
|
|
884
|
+
if (!filtermode) return {};
|
|
885
|
+
const searchObj = filtermode === "search" ? [
|
|
886
|
+
{
|
|
887
|
+
field: globalSearchColumn,
|
|
1026
888
|
value: globalFilter,
|
|
1027
889
|
matchMode: "anywhereignorecase",
|
|
1028
|
-
type:
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
890
|
+
type: "string"
|
|
891
|
+
}
|
|
892
|
+
] : transformFilterFields(columnFilters);
|
|
893
|
+
return getFilterFields(searchObj);
|
|
894
|
+
}, [
|
|
895
|
+
filtermode,
|
|
896
|
+
globalSearchColumn,
|
|
897
|
+
globalFilter,
|
|
898
|
+
columnFilters,
|
|
899
|
+
getFilterFields,
|
|
900
|
+
transformFilterFields
|
|
901
|
+
]);
|
|
902
|
+
const memoizedLogicalOp = useMemo(() => {
|
|
903
|
+
return filtermode === "search" && !globalSearchColumn ? "OR" : "AND";
|
|
904
|
+
}, [filtermode, globalSearchColumn]);
|
|
905
|
+
useServerSideSorting({
|
|
906
|
+
datasource,
|
|
907
|
+
sorting,
|
|
908
|
+
setInternalDataset,
|
|
909
|
+
showToast,
|
|
910
|
+
isServerSidePagination: isServerSidePagination(),
|
|
911
|
+
pageIndex: table.getState().pagination.pageIndex,
|
|
912
|
+
onError,
|
|
913
|
+
onBeforefilter,
|
|
914
|
+
filterFields: memoizedFilterFields,
|
|
915
|
+
logicalOp: memoizedLogicalOp,
|
|
916
|
+
listener,
|
|
917
|
+
name
|
|
918
|
+
});
|
|
919
|
+
const { showPanelHeading, showPagination } = usePanelStructure({
|
|
920
|
+
title,
|
|
921
|
+
subheading,
|
|
922
|
+
iconclass,
|
|
923
|
+
exportformat,
|
|
924
|
+
headerActions,
|
|
925
|
+
footerActions,
|
|
926
|
+
shownavigation,
|
|
927
|
+
onDemandLoad,
|
|
928
|
+
internalDataset,
|
|
929
|
+
pagesize,
|
|
930
|
+
allowpagesizechange,
|
|
931
|
+
datasource,
|
|
932
|
+
showrecordcount
|
|
933
|
+
});
|
|
934
|
+
const handlePaginationWidgetReady = useCallback(
|
|
935
|
+
(paginationWidget) => {
|
|
936
|
+
var _a2;
|
|
937
|
+
if (name && ((_a2 = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _a2[name])) {
|
|
938
|
+
listener.Widgets[name].dataNavigator = paginationWidget;
|
|
939
|
+
}
|
|
940
|
+
},
|
|
941
|
+
[name, listener]
|
|
942
|
+
);
|
|
943
|
+
const sortInfoForExport = useMemo(() => {
|
|
944
|
+
if (sorting.length > 0) {
|
|
1049
945
|
return {
|
|
1050
|
-
field:
|
|
1051
|
-
|
|
1052
|
-
matchMode: filter.matchMode,
|
|
1053
|
-
type: columnType
|
|
946
|
+
field: sorting[0].id,
|
|
947
|
+
direction: sorting[0].desc ? "desc" : "asc"
|
|
1054
948
|
};
|
|
1055
|
-
}
|
|
1056
|
-
return
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
datasource: datasource,
|
|
1081
|
-
multiselect: effectiveMultiselect,
|
|
1082
|
-
filterData: filterDataForState,
|
|
1083
|
-
sortData: sortDataForState,
|
|
1084
|
-
navigation: navigation,
|
|
1085
|
-
isStateConfigured: effectiveStateHandler !== undefined && effectiveStateHandler !== "none",
|
|
1086
|
-
defaultPageSize: initialPageSize,
|
|
1087
|
-
initialSortState: initialSortState,
|
|
1088
|
-
initialFilterState: initialSearchState
|
|
1089
|
-
});
|
|
1090
|
-
|
|
1091
|
-
// Enhanced page size change handler with state persistence
|
|
1092
|
-
var handlePageSizeChange = (0, _react.useCallback)(function (newPageSize) {
|
|
1093
|
-
// Get old page size before updating for state persistence
|
|
1094
|
-
var oldPageSize = paginationState.pageSize;
|
|
1095
|
-
|
|
1096
|
-
// Call base handler from hook
|
|
1097
|
-
handlePageSizeChangeBase(newPageSize);
|
|
1098
|
-
|
|
1099
|
-
// Skip state persistence for Scroll navigation
|
|
1100
|
-
if (navigation !== "Scroll") {
|
|
1101
|
-
// Get current persisted state to access all selected items across pages
|
|
1102
|
-
var currentPersistedState = (0, _utils.getTableState)(name, effectiveStateHandler);
|
|
1103
|
-
|
|
1104
|
-
// Build the state for page size change
|
|
1105
|
-
var newState = stateManager.getStateForPageSizeChange(newPageSize, currentPersistedState === null || currentPersistedState === void 0 ? void 0 : currentPersistedState.selectedItem, oldPageSize // Pass the old page size
|
|
1106
|
-
);
|
|
1107
|
-
|
|
1108
|
-
// Clear the existing state first to avoid merge issues with setWidgetState
|
|
1109
|
-
(0, _utils.clearTableState)(name, effectiveStateHandler);
|
|
1110
|
-
|
|
1111
|
-
// Only save if there's something to save (not in default state)
|
|
1112
|
-
if (Object.keys(newState).length > 0) {
|
|
1113
|
-
// If pagesize equals default, remove it from the state
|
|
1114
|
-
if (newPageSize === initialPageSize) {
|
|
1115
|
-
delete newState.pagesize;
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
// Only save if there are still properties after removing default pagesize
|
|
1119
|
-
if (Object.keys(newState).length > 0) {
|
|
1120
|
-
(0, _utils.saveTableState)(name, effectiveStateHandler, newState);
|
|
949
|
+
}
|
|
950
|
+
return void 0;
|
|
951
|
+
}, [sorting]);
|
|
952
|
+
const isGridEditModeComplete = isAddingNewRow || editingRowId !== null;
|
|
953
|
+
const spacingClasses = getSpacingClasses(spacing);
|
|
954
|
+
const filterDataForState = useMemo(() => {
|
|
955
|
+
if (!filtermode) return void 0;
|
|
956
|
+
if (filtermode === "search") {
|
|
957
|
+
if (globalFilter || globalSearchColumn) {
|
|
958
|
+
const columnType = globalSearchColumn ? (() => {
|
|
959
|
+
var _a2, _b2;
|
|
960
|
+
const col = find(columnsForTable, (c) => {
|
|
961
|
+
const column = c;
|
|
962
|
+
return column.accessorKey === globalSearchColumn || column.id === globalSearchColumn;
|
|
963
|
+
});
|
|
964
|
+
return ((_a2 = col == null ? void 0 : col.meta) == null ? void 0 : _a2.type) || ((_b2 = col == null ? void 0 : col.meta) == null ? void 0 : _b2.editinputtype) || "string";
|
|
965
|
+
})() : "string";
|
|
966
|
+
return [
|
|
967
|
+
{
|
|
968
|
+
field: globalSearchColumn || "",
|
|
969
|
+
value: globalFilter,
|
|
970
|
+
matchMode: "anywhereignorecase",
|
|
971
|
+
type: columnType
|
|
972
|
+
}
|
|
973
|
+
];
|
|
1121
974
|
}
|
|
975
|
+
} else if (filtermode === "multicolumn") {
|
|
976
|
+
const activeFilters = Object.entries(columnFilters).filter(([_, filter]) => filter.value).map(([field, filter]) => {
|
|
977
|
+
const columnType = (() => {
|
|
978
|
+
var _a2, _b2;
|
|
979
|
+
const col = find(columnsForTable, (c) => {
|
|
980
|
+
const column = c;
|
|
981
|
+
return column.accessorKey === field || column.id === field;
|
|
982
|
+
});
|
|
983
|
+
return ((_a2 = col == null ? void 0 : col.meta) == null ? void 0 : _a2.type) || ((_b2 = col == null ? void 0 : col.meta) == null ? void 0 : _b2.editinputtype) || "string";
|
|
984
|
+
})();
|
|
985
|
+
return {
|
|
986
|
+
field,
|
|
987
|
+
value: filter.value,
|
|
988
|
+
matchMode: filter.matchMode,
|
|
989
|
+
type: columnType
|
|
990
|
+
};
|
|
991
|
+
});
|
|
992
|
+
return activeFilters.length > 0 ? activeFilters : void 0;
|
|
1122
993
|
}
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
handlePageSizeChange(value);
|
|
994
|
+
return void 0;
|
|
995
|
+
}, [filtermode, globalFilter, globalSearchColumn, columnFilters, columnsForTable]);
|
|
996
|
+
const sortDataForState = useMemo(() => {
|
|
997
|
+
if (sorting.length > 0) {
|
|
998
|
+
const firstSort = sorting[0];
|
|
999
|
+
return {
|
|
1000
|
+
field: firstSort.id,
|
|
1001
|
+
direction: firstSort.desc ? "desc" : "asc"
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
return void 0;
|
|
1005
|
+
}, [sorting]);
|
|
1006
|
+
const stateManager = useTableStateManager({
|
|
1007
|
+
name,
|
|
1008
|
+
storage: effectiveStateHandler,
|
|
1009
|
+
currentPage: table.getState().pagination.pageIndex + 1,
|
|
1010
|
+
currentPageSize: table.getState().pagination.pageSize,
|
|
1011
|
+
selectedRowIds,
|
|
1012
|
+
internalDataset,
|
|
1013
|
+
initialActualPageSize,
|
|
1014
|
+
datasource,
|
|
1015
|
+
multiselect: effectiveMultiselect,
|
|
1016
|
+
filterData: filterDataForState,
|
|
1017
|
+
sortData: sortDataForState,
|
|
1018
|
+
navigation,
|
|
1019
|
+
isStateConfigured: effectiveStateHandler !== void 0 && effectiveStateHandler !== "none",
|
|
1020
|
+
defaultPageSize: initialPageSize,
|
|
1021
|
+
initialSortState,
|
|
1022
|
+
initialFilterState: initialSearchState
|
|
1153
1023
|
});
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
prevPageIndexRef.current = currentPageIndex;
|
|
1166
|
-
|
|
1167
|
-
// Only call callbacks if data has actually changed
|
|
1168
|
-
if (!(0, _lodashEs.isEqual)(prevDatasetRef.current, internalDataset)) {
|
|
1169
|
-
prevDatasetRef.current = internalDataset;
|
|
1170
|
-
|
|
1171
|
-
// Call onBeforedatarender callback
|
|
1172
|
-
if (onBeforedatarender) {
|
|
1173
|
-
var _listener$Widgets4;
|
|
1174
|
-
onBeforedatarender(listener === null || listener === void 0 || (_listener$Widgets4 = listener.Widgets) === null || _listener$Widgets4 === void 0 ? void 0 : _listener$Widgets4[name],
|
|
1175
|
-
// widget reference
|
|
1176
|
-
internalDataset,
|
|
1177
|
-
// data
|
|
1178
|
-
columnsProxy // columns (including dynamic ones)
|
|
1024
|
+
const handlePageSizeChange = useCallback(
|
|
1025
|
+
(newPageSize) => {
|
|
1026
|
+
const oldPageSize = paginationState.pageSize;
|
|
1027
|
+
handlePageSizeChangeBase(newPageSize);
|
|
1028
|
+
if (navigation !== "Scroll") {
|
|
1029
|
+
const currentPersistedState = getTableState(name, effectiveStateHandler);
|
|
1030
|
+
const newState = stateManager.getStateForPageSizeChange(
|
|
1031
|
+
newPageSize,
|
|
1032
|
+
currentPersistedState == null ? void 0 : currentPersistedState.selectedItem,
|
|
1033
|
+
oldPageSize
|
|
1034
|
+
// Pass the old page size
|
|
1179
1035
|
);
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1036
|
+
clearTableState(name, effectiveStateHandler);
|
|
1037
|
+
if (Object.keys(newState).length > 0) {
|
|
1038
|
+
if (newPageSize === initialPageSize) {
|
|
1039
|
+
delete newState.pagesize;
|
|
1040
|
+
}
|
|
1041
|
+
if (Object.keys(newState).length > 0) {
|
|
1042
|
+
saveTableState(name, effectiveStateHandler, newState);
|
|
1043
|
+
}
|
|
1185
1044
|
}
|
|
1186
|
-
var nextRows = internalDataset.map(function (r) {
|
|
1187
|
-
return (0, _typeof2["default"])(r) === "object" && r !== null ? _objectSpread({}, r) : r;
|
|
1188
|
-
});
|
|
1189
|
-
setInternalDataset(nextRows);
|
|
1190
1045
|
}
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1046
|
+
},
|
|
1047
|
+
[
|
|
1048
|
+
handlePageSizeChangeBase,
|
|
1049
|
+
name,
|
|
1050
|
+
effectiveStateHandler,
|
|
1051
|
+
stateManager,
|
|
1052
|
+
initialPageSize,
|
|
1053
|
+
navigation
|
|
1054
|
+
]
|
|
1055
|
+
);
|
|
1056
|
+
const selectPageSize = useCallback(
|
|
1057
|
+
(pagesize2) => {
|
|
1058
|
+
if (!allowpagesizechange && !pagesize2) return;
|
|
1059
|
+
const pageSizeOptions = (pagesizeoptions || "5,10,20,50,100").split(",").map((v) => Number(v.trim())).filter((n) => !Number.isNaN(n)).sort((a, b) => a - b);
|
|
1060
|
+
if (pageSizeOptions.length === 0) return;
|
|
1061
|
+
const nv = Number(pagesize2);
|
|
1062
|
+
const clamped = nv < pageSizeOptions[0] || nv > pageSizeOptions[pageSizeOptions.length - 1] || !pageSizeOptions.includes(nv) ? pageSizeOptions[0] : nv;
|
|
1063
|
+
handlePageSizeChange(clamped);
|
|
1064
|
+
if (effectiveStorageKey !== name) {
|
|
1065
|
+
broadcastScriptPageSize(name, effectiveStorageKey, clamped);
|
|
1066
|
+
}
|
|
1067
|
+
},
|
|
1068
|
+
[allowpagesizechange, pagesizeoptions, handlePageSizeChange, effectiveStorageKey, name]
|
|
1069
|
+
);
|
|
1070
|
+
useEffect(() => {
|
|
1071
|
+
if (effectiveStorageKey === name) return;
|
|
1072
|
+
return subscribeToScriptPageSizeBroadcast(name, effectiveStorageKey, (value) => {
|
|
1073
|
+
handlePageSizeChange(value);
|
|
1074
|
+
});
|
|
1075
|
+
}, [name, effectiveStorageKey, handlePageSizeChange]);
|
|
1076
|
+
useEffect(() => {
|
|
1077
|
+
var _a2;
|
|
1078
|
+
const shouldCallCallbacks = isDynamicTable ? internalDataset.length > 0 : internalDataset.length > 0 && wmTableColumns.length > 0;
|
|
1079
|
+
if (shouldCallCallbacks) {
|
|
1080
|
+
const currentPageIndex = table.getState().pagination.pageIndex;
|
|
1081
|
+
prevPageIndexRef.current = currentPageIndex;
|
|
1082
|
+
if (!isEqual(prevDatasetRef.current, internalDataset)) {
|
|
1083
|
+
prevDatasetRef.current = internalDataset;
|
|
1084
|
+
if (onBeforedatarender) {
|
|
1085
|
+
onBeforedatarender(
|
|
1086
|
+
(_a2 = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _a2[name],
|
|
1087
|
+
// widget reference
|
|
1088
|
+
internalDataset,
|
|
1089
|
+
// data
|
|
1090
|
+
columnsProxy
|
|
1091
|
+
// columns (including dynamic ones)
|
|
1092
|
+
);
|
|
1093
|
+
const customExprKeys = Object.keys(columnsProxy).filter(
|
|
1094
|
+
(key) => columnsProxy[key].customExpression
|
|
1095
|
+
);
|
|
1096
|
+
if (customExprKeys.length > 0) {
|
|
1097
|
+
void mergeParsedCustomColumns().finally(() => {
|
|
1098
|
+
});
|
|
1199
1099
|
}
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
{
|
|
1203
|
-
$data: internalDataset,
|
|
1204
|
-
data: internalDataset
|
|
1205
|
-
} // match Angular's format with both $data and data
|
|
1100
|
+
const nextRows = internalDataset.map(
|
|
1101
|
+
(r) => typeof r === "object" && r !== null ? __spreadValues({}, r) : r
|
|
1206
1102
|
);
|
|
1103
|
+
setInternalDataset(nextRows);
|
|
1207
1104
|
}
|
|
1208
|
-
|
|
1105
|
+
requestAnimationFrame(() => {
|
|
1106
|
+
var _a3;
|
|
1107
|
+
if (onDatarender) {
|
|
1108
|
+
if (name && (listener == null ? void 0 : listener.Widgets[name]) && tableContainerRef.current) {
|
|
1109
|
+
listener.Widgets[name].nativeElement = tableContainerRef.current;
|
|
1110
|
+
}
|
|
1111
|
+
onDatarender(
|
|
1112
|
+
(_a3 = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _a3[name],
|
|
1113
|
+
// widget reference to match Angular format
|
|
1114
|
+
{ $data: internalDataset, data: internalDataset }
|
|
1115
|
+
// match Angular's format with both $data and data
|
|
1116
|
+
);
|
|
1117
|
+
}
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1209
1120
|
}
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1121
|
+
}, [
|
|
1122
|
+
internalDataset,
|
|
1123
|
+
wmTableColumns,
|
|
1124
|
+
onBeforedatarender,
|
|
1125
|
+
onDatarender,
|
|
1126
|
+
name,
|
|
1127
|
+
isDynamicTable,
|
|
1128
|
+
table.getState().pagination.pageIndex,
|
|
1129
|
+
setInternalDataset,
|
|
1130
|
+
columnsProxy,
|
|
1131
|
+
mergeParsedCustomColumns
|
|
1132
|
+
]);
|
|
1133
|
+
useEffect(() => {
|
|
1134
|
+
if (!onBeforedatarender) return;
|
|
1135
|
+
if (internalDataset.length === 0) return;
|
|
1136
|
+
void mergeParsedCustomColumns();
|
|
1137
|
+
}, [
|
|
1138
|
+
customExpressionSignature,
|
|
1139
|
+
mergeParsedCustomColumns,
|
|
1140
|
+
onBeforedatarender,
|
|
1141
|
+
internalDataset.length
|
|
1142
|
+
]);
|
|
1143
|
+
useTableInitialization({
|
|
1144
|
+
internalDataset,
|
|
1145
|
+
wmTableColumns: wmTableColumnsWithOverrides,
|
|
1146
|
+
cellState,
|
|
1147
|
+
gridfirstrowselect,
|
|
1148
|
+
useRadioSelect,
|
|
1149
|
+
useMultiSelect,
|
|
1150
|
+
setActiveRow,
|
|
1151
|
+
selectedRowIds,
|
|
1152
|
+
formName,
|
|
1153
|
+
editmode,
|
|
1154
|
+
activeRowIds,
|
|
1155
|
+
listener
|
|
1156
|
+
});
|
|
1157
|
+
const { restoredPageNumber, restoredSelectedIndices, setIsRestoringSelection } = useTableEffects({
|
|
1158
|
+
name,
|
|
1159
|
+
navigation,
|
|
1160
|
+
datasource,
|
|
1161
|
+
internalDataset,
|
|
1241
1162
|
statehandler: effectiveStateHandler,
|
|
1242
|
-
selectedRowIds
|
|
1163
|
+
selectedRowIds,
|
|
1243
1164
|
currentPage: table.getState().pagination.pageIndex + 1,
|
|
1244
1165
|
// Convert to 1-based
|
|
1245
1166
|
currentPageSize: table.getState().pagination.pageSize,
|
|
1246
|
-
sorting
|
|
1167
|
+
sorting,
|
|
1247
1168
|
isGridEditMode: isGridEditModeComplete,
|
|
1248
|
-
stateManager
|
|
1249
|
-
initialActualPageSize
|
|
1250
|
-
})
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
// Set flag to prevent saving while restoring
|
|
1271
|
-
setIsRestoringSelection(true);
|
|
1272
|
-
|
|
1273
|
-
// Apply restored selections by converting indices to row IDs
|
|
1274
|
-
if (useMultiSelect) {
|
|
1275
|
-
// For multiselect, set all restored items by index
|
|
1276
|
-
var _selectedRowIds = [];
|
|
1277
|
-
restoredSelectedIndices.forEach(function (index) {
|
|
1278
|
-
if (index >= 0 && index < internalDataset.length) {
|
|
1279
|
-
var row = internalDataset[index];
|
|
1280
|
-
if (row && row._wmTableRowId) {
|
|
1281
|
-
handleMultiSelection(row._wmTableRowId, row, true);
|
|
1282
|
-
// Collect all selected row IDs
|
|
1283
|
-
_selectedRowIds.push(row._wmTableRowId);
|
|
1169
|
+
stateManager,
|
|
1170
|
+
initialActualPageSize
|
|
1171
|
+
});
|
|
1172
|
+
useEffect(() => {
|
|
1173
|
+
if (restoredPageNumber !== null && restoredPageNumber > 1) {
|
|
1174
|
+
table.setPageIndex(restoredPageNumber - 1);
|
|
1175
|
+
}
|
|
1176
|
+
}, [restoredPageNumber, table]);
|
|
1177
|
+
const hasRestoredSelectionRef = useRef(false);
|
|
1178
|
+
useEffect(() => {
|
|
1179
|
+
if (restoredSelectedIndices.length > 0 && internalDataset.length > 0 && !hasRestoredSelectionRef.current) {
|
|
1180
|
+
hasRestoredSelectionRef.current = true;
|
|
1181
|
+
setIsRestoringSelection(true);
|
|
1182
|
+
if (useMultiSelect) {
|
|
1183
|
+
const selectedRowIds2 = [];
|
|
1184
|
+
restoredSelectedIndices.forEach((index) => {
|
|
1185
|
+
if (index >= 0 && index < internalDataset.length) {
|
|
1186
|
+
const row = internalDataset[index];
|
|
1187
|
+
if (row && row._wmTableRowId) {
|
|
1188
|
+
handleMultiSelection(row._wmTableRowId, row, true);
|
|
1189
|
+
selectedRowIds2.push(row._wmTableRowId);
|
|
1190
|
+
}
|
|
1284
1191
|
}
|
|
1192
|
+
});
|
|
1193
|
+
if (selectedRowIds2.length > 0) {
|
|
1194
|
+
setActiveRow(selectedRowIds2);
|
|
1285
1195
|
}
|
|
1286
|
-
}
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
if (firstIndex >= 0 && firstIndex < internalDataset.length) {
|
|
1295
|
-
var row = internalDataset[firstIndex];
|
|
1296
|
-
if (row && row._wmTableRowId) {
|
|
1297
|
-
handleRadioSelection(row._wmTableRowId, row);
|
|
1298
|
-
// Also set as active row for single selection
|
|
1299
|
-
setActiveRow(row._wmTableRowId);
|
|
1196
|
+
} else {
|
|
1197
|
+
const firstIndex = restoredSelectedIndices[0];
|
|
1198
|
+
if (firstIndex >= 0 && firstIndex < internalDataset.length) {
|
|
1199
|
+
const row = internalDataset[firstIndex];
|
|
1200
|
+
if (row && row._wmTableRowId) {
|
|
1201
|
+
handleRadioSelection(row._wmTableRowId, row);
|
|
1202
|
+
setActiveRow(row._wmTableRowId);
|
|
1203
|
+
}
|
|
1300
1204
|
}
|
|
1301
1205
|
}
|
|
1206
|
+
setTimeout(() => {
|
|
1207
|
+
setIsRestoringSelection(false);
|
|
1208
|
+
}, 0);
|
|
1302
1209
|
}
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
clearTimeout(currentTimeout);
|
|
1317
|
-
}
|
|
1318
|
-
};
|
|
1319
|
-
}, []);
|
|
1320
|
-
|
|
1321
|
-
// Create wrapper functions for external API
|
|
1322
|
-
var editRow = (0, _react.useCallback)(function (event, widget, row) {
|
|
1323
|
-
if (!row || !row._wmTableRowId) {
|
|
1324
|
-
console.warn("Invalid row data provided to editRow");
|
|
1325
|
-
return;
|
|
1326
|
-
}
|
|
1327
|
-
startEditing(row, row._wmTableRowId);
|
|
1328
|
-
}, [startEditing]);
|
|
1329
|
-
var deleteRow = (0, _react.useCallback)(/*#__PURE__*/function () {
|
|
1330
|
-
var _ref5 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(event, widget, row) {
|
|
1331
|
-
var _listener$Widgets6, cleanedRow, rowIndex, result;
|
|
1332
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
1333
|
-
while (1) switch (_context.prev = _context.next) {
|
|
1334
|
-
case 0:
|
|
1335
|
-
if (row) {
|
|
1336
|
-
_context.next = 3;
|
|
1337
|
-
break;
|
|
1338
|
-
}
|
|
1339
|
-
console.warn("Invalid row data provided to deleteRow");
|
|
1340
|
-
return _context.abrupt("return");
|
|
1341
|
-
case 3:
|
|
1342
|
-
if (!onBeforerowdelete) {
|
|
1343
|
-
_context.next = 11;
|
|
1344
|
-
break;
|
|
1345
|
-
}
|
|
1346
|
-
cleanedRow = (0, _utils.cleanRowData)([row])[0];
|
|
1347
|
-
rowIndex = internalDataset.findIndex(function (r) {
|
|
1348
|
-
return r._wmTableRowId === row._wmTableRowId || r.id !== undefined && r.id === row.id;
|
|
1349
|
-
});
|
|
1350
|
-
_context.next = 8;
|
|
1351
|
-
return onBeforerowdelete(event, listener === null || listener === void 0 || (_listener$Widgets6 = listener.Widgets) === null || _listener$Widgets6 === void 0 ? void 0 : _listener$Widgets6[name], cleanedRow, {
|
|
1352
|
-
rowIndex: rowIndex,
|
|
1353
|
-
data: cleanedRow
|
|
1354
|
-
});
|
|
1355
|
-
case 8:
|
|
1356
|
-
result = _context.sent;
|
|
1357
|
-
if (!(result === false)) {
|
|
1358
|
-
_context.next = 11;
|
|
1359
|
-
break;
|
|
1360
|
-
}
|
|
1361
|
-
return _context.abrupt("return");
|
|
1362
|
-
case 11:
|
|
1363
|
-
_deleteRecord(row, tableRef.current);
|
|
1364
|
-
case 12:
|
|
1365
|
-
case "end":
|
|
1366
|
-
return _context.stop();
|
|
1210
|
+
}, [
|
|
1211
|
+
restoredSelectedIndices,
|
|
1212
|
+
internalDataset,
|
|
1213
|
+
useMultiSelect,
|
|
1214
|
+
handleMultiSelection,
|
|
1215
|
+
handleRadioSelection,
|
|
1216
|
+
setIsRestoringSelection
|
|
1217
|
+
]);
|
|
1218
|
+
useEffect(() => {
|
|
1219
|
+
const currentTimeout = resizeTimeoutRef.current;
|
|
1220
|
+
return () => {
|
|
1221
|
+
if (currentTimeout) {
|
|
1222
|
+
clearTimeout(currentTimeout);
|
|
1367
1223
|
}
|
|
1368
|
-
}
|
|
1369
|
-
})
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1224
|
+
};
|
|
1225
|
+
}, []);
|
|
1226
|
+
const editRow = useCallback(
|
|
1227
|
+
(event, widget, row) => {
|
|
1228
|
+
if (!row || !row._wmTableRowId) {
|
|
1229
|
+
console.warn("Invalid row data provided to editRow");
|
|
1230
|
+
return;
|
|
1231
|
+
}
|
|
1232
|
+
startEditing(row, row._wmTableRowId);
|
|
1233
|
+
},
|
|
1234
|
+
[startEditing]
|
|
1235
|
+
);
|
|
1236
|
+
const deleteRow = useCallback(
|
|
1237
|
+
async (event, widget, row) => {
|
|
1238
|
+
var _a2;
|
|
1239
|
+
if (!row) {
|
|
1240
|
+
console.warn("Invalid row data provided to deleteRow");
|
|
1241
|
+
return;
|
|
1242
|
+
}
|
|
1243
|
+
if (onBeforerowdelete) {
|
|
1244
|
+
const cleanedRow = cleanRowData([row])[0];
|
|
1245
|
+
const rowIndex = internalDataset.findIndex(
|
|
1246
|
+
(r) => r._wmTableRowId === row._wmTableRowId || r.id !== void 0 && r.id === row.id
|
|
1247
|
+
);
|
|
1248
|
+
const result = await onBeforerowdelete(event, (_a2 = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _a2[name], cleanedRow, {
|
|
1249
|
+
rowIndex,
|
|
1250
|
+
data: cleanedRow
|
|
1251
|
+
});
|
|
1252
|
+
if (result === false) {
|
|
1253
|
+
return;
|
|
1397
1254
|
}
|
|
1255
|
+
}
|
|
1256
|
+
deleteRecord(row, tableRef.current);
|
|
1257
|
+
},
|
|
1258
|
+
[deleteRecord, onBeforerowdelete, listener, name, internalDataset]
|
|
1259
|
+
);
|
|
1260
|
+
const refresh = useCallback(
|
|
1261
|
+
async (newData = false) => {
|
|
1262
|
+
var _a2, _b2;
|
|
1263
|
+
if (!datasource) {
|
|
1398
1264
|
console.warn("No datasource available for refresh");
|
|
1399
|
-
return
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
currentTable
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
break;
|
|
1265
|
+
return;
|
|
1266
|
+
}
|
|
1267
|
+
try {
|
|
1268
|
+
const currentTable = tableRef.current;
|
|
1269
|
+
if (!currentTable) {
|
|
1270
|
+
console.warn("Table instance not available");
|
|
1271
|
+
return;
|
|
1407
1272
|
}
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
targetPage = currentTable.getState().pagination.pageIndex + 1;
|
|
1412
|
-
currentPageSize = ((_datasource$paginatio3 = datasource.pagination) === null || _datasource$paginatio3 === void 0 ? void 0 : _datasource$paginatio3.size) || currentTable.getState().pagination.pageSize;
|
|
1413
|
-
shouldNavigateToLastPage = false; // If newData is true and we have pagination metadata, calculate the last page
|
|
1273
|
+
let targetPage = currentTable.getState().pagination.pageIndex + 1;
|
|
1274
|
+
const currentPageSize = ((_a2 = datasource.pagination) == null ? void 0 : _a2.size) || currentTable.getState().pagination.pageSize;
|
|
1275
|
+
let shouldNavigateToLastPage = false;
|
|
1414
1276
|
if (newData && datasource.pagination) {
|
|
1415
|
-
totalElements = datasource.pagination
|
|
1416
|
-
if (totalElements !==
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
// Adding 1 element makes it 16 elements = 4 pages (since page 3 is full)
|
|
1420
|
-
totalAfterAdd = totalElements + 1;
|
|
1421
|
-
lastPage = Math.ceil(totalAfterAdd / currentPageSize);
|
|
1277
|
+
const { totalElements } = datasource.pagination;
|
|
1278
|
+
if (totalElements !== void 0 && currentPageSize > 0) {
|
|
1279
|
+
const totalAfterAdd = totalElements + 1;
|
|
1280
|
+
const lastPage = Math.ceil(totalAfterAdd / currentPageSize);
|
|
1422
1281
|
targetPage = lastPage;
|
|
1423
1282
|
shouldNavigateToLastPage = true;
|
|
1424
1283
|
}
|
|
1425
1284
|
}
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
if (response && response.data) {
|
|
1444
|
-
dataWithIds = (0, _utils.addUniqueRowIds)(response.data);
|
|
1445
|
-
setInternalDataset(dataWithIds);
|
|
1446
|
-
|
|
1447
|
-
// Set the table to the last page AFTER data is loaded
|
|
1285
|
+
if (isServerSidePagination()) {
|
|
1286
|
+
const response = await refreshDataSource(datasource, {
|
|
1287
|
+
page: targetPage,
|
|
1288
|
+
pagesize: currentPageSize,
|
|
1289
|
+
filterFields: memoizedFilterFields || {},
|
|
1290
|
+
condition: memoizedLogicalOp
|
|
1291
|
+
});
|
|
1292
|
+
if (response && response.data) {
|
|
1293
|
+
const dataWithIds = addUniqueRowIds(response.data);
|
|
1294
|
+
setInternalDataset(dataWithIds);
|
|
1295
|
+
if (shouldNavigateToLastPage) {
|
|
1296
|
+
requestAnimationFrame(() => {
|
|
1297
|
+
currentTable.setPageIndex(targetPage);
|
|
1298
|
+
});
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
} else {
|
|
1448
1302
|
if (shouldNavigateToLastPage) {
|
|
1449
|
-
|
|
1450
|
-
requestAnimationFrame(function () {
|
|
1451
|
-
currentTable.setPageIndex(targetPage);
|
|
1452
|
-
});
|
|
1303
|
+
currentTable.setPageIndex(targetPage);
|
|
1453
1304
|
}
|
|
1454
1305
|
}
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
case 20:
|
|
1458
|
-
// For client-side pagination, just set the page index
|
|
1459
|
-
if (shouldNavigateToLastPage) {
|
|
1460
|
-
currentTable.setPageIndex(targetPage);
|
|
1461
|
-
}
|
|
1462
|
-
case 21:
|
|
1463
|
-
_context2.next = 28;
|
|
1464
|
-
break;
|
|
1465
|
-
case 23:
|
|
1466
|
-
_context2.prev = 23;
|
|
1467
|
-
_context2.t0 = _context2["catch"](4);
|
|
1468
|
-
console.error("Error refreshing table data:", _context2.t0);
|
|
1306
|
+
} catch (error) {
|
|
1307
|
+
console.error("Error refreshing table data:", error);
|
|
1469
1308
|
if (showToast) {
|
|
1470
1309
|
showToast("Failed to refresh table data", "Error");
|
|
1471
1310
|
}
|
|
1472
1311
|
if (onError) {
|
|
1473
|
-
onError(null, listener
|
|
1312
|
+
onError(null, (_b2 = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _b2[name], error, "refresh");
|
|
1474
1313
|
}
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1314
|
+
}
|
|
1315
|
+
},
|
|
1316
|
+
[datasource, isServerSidePagination(), setInternalDataset, showToast, onError, name]
|
|
1317
|
+
);
|
|
1318
|
+
const tableApis = {
|
|
1319
|
+
columns: columnsProxy,
|
|
1320
|
+
addNewRow: handleAddNewRowClick,
|
|
1321
|
+
editRow,
|
|
1322
|
+
deleteRow,
|
|
1323
|
+
refresh,
|
|
1324
|
+
datasource,
|
|
1325
|
+
dataset,
|
|
1326
|
+
selectPageSize,
|
|
1327
|
+
rowDefInstances
|
|
1328
|
+
};
|
|
1329
|
+
syncSelectedItemsImplRef.current = (newSelectedIds) => {
|
|
1330
|
+
if (!(listener == null ? void 0 : listener.onChange)) return;
|
|
1331
|
+
const getRowId = (row) => row._wmTableRowId || String(row.id);
|
|
1332
|
+
const selectedRows = internalDataset.filter(
|
|
1333
|
+
(row) => newSelectedIds.includes(getRowId(row))
|
|
1334
|
+
);
|
|
1335
|
+
const selectedItems = cleanRowData(selectedRows);
|
|
1336
|
+
if (!isEqual(prevSelectedRow.current, selectedItems)) {
|
|
1337
|
+
prevSelectedRow.current = selectedItems;
|
|
1338
|
+
if (tableApisRegistered.current) {
|
|
1339
|
+
listener.onChange(widgetRegistrationKey, { selectedItems });
|
|
1340
|
+
} else {
|
|
1341
|
+
tableApisRegistered.current = true;
|
|
1342
|
+
listener.onChange(widgetRegistrationKey, __spreadProps(__spreadValues({}, tableApis), { selectedItems }));
|
|
1343
|
+
}
|
|
1478
1344
|
}
|
|
1479
|
-
}, _callee2, null, [[4, 23]]);
|
|
1480
|
-
})), [datasource, isServerSidePagination(), setInternalDataset, showToast, onError, name]); // Removed 'table' from dependencies to prevent recreation
|
|
1481
|
-
|
|
1482
|
-
var tableApis = {
|
|
1483
|
-
columns: columnsProxy,
|
|
1484
|
-
addNewRow: handleAddNewRowClick,
|
|
1485
|
-
editRow: editRow,
|
|
1486
|
-
deleteRow: deleteRow,
|
|
1487
|
-
refresh: refresh,
|
|
1488
|
-
datasource: datasource,
|
|
1489
|
-
dataset: dataset,
|
|
1490
|
-
selectPageSize: selectPageSize,
|
|
1491
|
-
rowDefInstances: rowDefInstances
|
|
1492
|
-
};
|
|
1493
|
-
|
|
1494
|
-
// Keep the sync-selected-items implementation up-to-date every render so that
|
|
1495
|
-
// the stable onSyncSelectedItems callback (passed to useRowSelection) always has
|
|
1496
|
-
// access to the latest tableApis / internalDataset / listener values.
|
|
1497
|
-
syncSelectedItemsImplRef.current = function (newSelectedIds) {
|
|
1498
|
-
if (!(listener !== null && listener !== void 0 && listener.onChange)) return;
|
|
1499
|
-
var getRowId = function getRowId(row) {
|
|
1500
|
-
return row._wmTableRowId || String(row.id);
|
|
1501
1345
|
};
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1346
|
+
useEffect(() => {
|
|
1347
|
+
var _a2, _b2, _c2;
|
|
1348
|
+
if (parentForm && name && ((_a2 = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _a2[parentForm])) {
|
|
1349
|
+
const columns2 = (_c2 = (_b2 = listener == null ? void 0 : listener.Widgets) == null ? void 0 : _b2[name]) == null ? void 0 : _c2.columns;
|
|
1350
|
+
const defaultValues = Object.entries(columns2 || {}).reduce(
|
|
1351
|
+
(acc, [key, value]) => {
|
|
1352
|
+
if ((value == null ? void 0 : value.defaultValue) !== void 0) {
|
|
1353
|
+
acc[key] = value;
|
|
1354
|
+
}
|
|
1355
|
+
return acc;
|
|
1356
|
+
},
|
|
1357
|
+
{}
|
|
1358
|
+
);
|
|
1359
|
+
const valuesToPass = Object.keys(defaultValues).length === 0 ? [] : defaultValues;
|
|
1360
|
+
if (parentFormColumns) {
|
|
1361
|
+
listener == null ? void 0 : listener.onChange(parentForm, {
|
|
1362
|
+
dataoutput: __spreadProps(__spreadValues({}, parentFormColumns), {
|
|
1363
|
+
[name]: valuesToPass
|
|
1364
|
+
})
|
|
1365
|
+
});
|
|
1366
|
+
}
|
|
1517
1367
|
}
|
|
1518
|
-
}
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1368
|
+
}, [parentForm, parentFormColumns]);
|
|
1369
|
+
const updateSelectedItem = () => {
|
|
1370
|
+
if (!(listener == null ? void 0 : listener.onChange)) return;
|
|
1371
|
+
const getRowId = (row) => row._wmTableRowId || String(row.id);
|
|
1372
|
+
let selectedRows = [];
|
|
1373
|
+
if ((useRadioSelect || useMultiSelect) && selectedRowIds.length > 0) {
|
|
1374
|
+
selectedRows = internalDataset.filter((row) => selectedRowIds.includes(getRowId(row)));
|
|
1375
|
+
} else if (activeRowIds.length > 0) {
|
|
1376
|
+
selectedRows = internalDataset.filter(
|
|
1377
|
+
(row) => activeRowIds.includes(getRowId(row))
|
|
1378
|
+
);
|
|
1379
|
+
}
|
|
1380
|
+
const cleanedRows = cleanRowData(selectedRows);
|
|
1381
|
+
const selectedItems = cleanedRows.length > 0 ? cleanedRows : [];
|
|
1382
|
+
if (!isEqual(prevSelectedRow.current, selectedItems)) {
|
|
1383
|
+
prevSelectedRow.current = selectedItems;
|
|
1384
|
+
if (tableApisRegistered.current) {
|
|
1385
|
+
listener.onChange(widgetRegistrationKey, { selectedItems });
|
|
1386
|
+
return;
|
|
1533
1387
|
}
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
// If all values are undefined, pass empty array, else pass object of default values
|
|
1538
|
-
var valuesToPass = Object.keys(defaultValues).length === 0 ? [] : defaultValues;
|
|
1539
|
-
if (parentFormColumns) {
|
|
1540
|
-
listener === null || listener === void 0 || listener.onChange(parentForm, {
|
|
1541
|
-
dataoutput: _objectSpread(_objectSpread({}, parentFormColumns), {}, (0, _defineProperty2["default"])({}, name, valuesToPass))
|
|
1542
|
-
});
|
|
1388
|
+
tableApisRegistered.current = true;
|
|
1389
|
+
listener.onChange(widgetRegistrationKey, __spreadProps(__spreadValues({}, tableApis), { selectedItems }));
|
|
1543
1390
|
}
|
|
1544
|
-
}
|
|
1545
|
-
}, [parentForm, parentFormColumns]);
|
|
1546
|
-
var updateSelectedItem = function updateSelectedItem() {
|
|
1547
|
-
if (!(listener !== null && listener !== void 0 && listener.onChange)) return;
|
|
1548
|
-
|
|
1549
|
-
// Helper to get row ID
|
|
1550
|
-
var getRowId = function getRowId(row) {
|
|
1551
|
-
return row._wmTableRowId || String(row.id);
|
|
1552
1391
|
};
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
selectedRows = internalDataset.filter(function (row) {
|
|
1562
|
-
return activeRowIds.includes(getRowId(row));
|
|
1563
|
-
});
|
|
1564
|
-
}
|
|
1565
|
-
|
|
1566
|
-
// Clean and format selecteditem - always return as array
|
|
1567
|
-
var cleanedRows = (0, _utils.cleanRowData)(selectedRows);
|
|
1568
|
-
|
|
1569
|
-
// Always return selectedItems as an array (empty array if nothing selected)
|
|
1570
|
-
var selectedItems = cleanedRows.length > 0 ? cleanedRows : [];
|
|
1571
|
-
|
|
1572
|
-
// Update only if changed
|
|
1573
|
-
if (!(0, _lodashEs.isEqual)(prevSelectedRow.current, selectedItems)) {
|
|
1574
|
-
prevSelectedRow.current = selectedItems;
|
|
1575
|
-
if (tableApisRegistered.current) {
|
|
1576
|
-
listener.onChange(widgetRegistrationKey, {
|
|
1577
|
-
selectedItems: selectedItems
|
|
1578
|
-
});
|
|
1579
|
-
return;
|
|
1580
|
-
}
|
|
1581
|
-
tableApisRegistered.current = true;
|
|
1582
|
-
listener.onChange(widgetRegistrationKey, _objectSpread(_objectSpread({}, tableApis), {}, {
|
|
1583
|
-
selectedItems: selectedItems
|
|
1584
|
-
}));
|
|
1585
|
-
}
|
|
1586
|
-
};
|
|
1587
|
-
|
|
1588
|
-
// Expose active/selected row data through listener
|
|
1589
|
-
// This updates whenever the active/selected row changes (when user clicks on a row)
|
|
1590
|
-
(0, _react.useEffect)(function () {
|
|
1591
|
-
updateSelectedItem();
|
|
1592
|
-
}, [activeRowIds, selectedRowIds, useRadioSelect, useMultiSelect, internalDataset, name]);
|
|
1593
|
-
|
|
1594
|
-
// `table` reference is stable; header groups can change as state changes (pagination/columns/etc).
|
|
1595
|
-
// So include state-based deps to avoid stale/empty colgroup.
|
|
1596
|
-
var colGroupSpec = (0, _react.useMemo)(function () {
|
|
1597
|
-
var headerGroups = table.getHeaderGroups();
|
|
1598
|
-
var leafHeaderGroup = headerGroups.length ? headerGroups[headerGroups.length - 1] : undefined;
|
|
1599
|
-
var leafHeaders = ((leafHeaderGroup === null || leafHeaderGroup === void 0 ? void 0 : leafHeaderGroup.headers) || []).filter(function (h) {
|
|
1600
|
-
return !h.isPlaceholder;
|
|
1601
|
-
});
|
|
1602
|
-
|
|
1603
|
-
// Build base spec from TanStack columns
|
|
1604
|
-
var base = leafHeaders.map(function (h) {
|
|
1605
|
-
return {
|
|
1392
|
+
useEffect(() => {
|
|
1393
|
+
updateSelectedItem();
|
|
1394
|
+
}, [activeRowIds, selectedRowIds, useRadioSelect, useMultiSelect, internalDataset, name]);
|
|
1395
|
+
const colGroupSpec = useMemo(() => {
|
|
1396
|
+
const headerGroups = table.getHeaderGroups();
|
|
1397
|
+
const leafHeaderGroup = headerGroups.length ? headerGroups[headerGroups.length - 1] : void 0;
|
|
1398
|
+
const leafHeaders = ((leafHeaderGroup == null ? void 0 : leafHeaderGroup.headers) || []).filter((h) => !h.isPlaceholder);
|
|
1399
|
+
const base = leafHeaders.map((h) => ({
|
|
1606
1400
|
key: h.column.id,
|
|
1607
|
-
width:
|
|
1608
|
-
};
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1401
|
+
width: `${h.column.getSize()}px`
|
|
1402
|
+
}));
|
|
1403
|
+
return base;
|
|
1404
|
+
}, [table, columnSizing, columnsVersion, showheader, ColClassSignature]);
|
|
1405
|
+
return /* @__PURE__ */ jsxs(
|
|
1406
|
+
Box,
|
|
1407
|
+
__spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
1408
|
+
ref: tableContainerRef,
|
|
1409
|
+
hidden: props.hidden,
|
|
1410
|
+
className: `app-grid app-panel panel app-datagrid ${className}`.trim()
|
|
1411
|
+
}, { name }), { editmode }), { navigation }), { title }), {
|
|
1412
|
+
currentpage: table.getState().pagination.pageIndex + 1
|
|
1413
|
+
}), {
|
|
1414
|
+
children: [
|
|
1415
|
+
renderConfirmDialog(),
|
|
1416
|
+
showPanelHeading && /* @__PURE__ */ jsx(
|
|
1417
|
+
TablePanelHeading,
|
|
1418
|
+
{
|
|
1419
|
+
title,
|
|
1420
|
+
subheading,
|
|
1421
|
+
iconclass,
|
|
1422
|
+
exportformat,
|
|
1423
|
+
headerActions,
|
|
1424
|
+
spacing,
|
|
1425
|
+
isGridEditMode: isGridEditModeComplete,
|
|
1426
|
+
isLoading: datasource == null ? void 0 : datasource.loading,
|
|
1427
|
+
listener,
|
|
1428
|
+
datasource,
|
|
1429
|
+
columns: wmTableColumnsWithOverrides,
|
|
1430
|
+
sortInfo: sortInfoForExport,
|
|
1431
|
+
filterInfo: filterDataForState,
|
|
1432
|
+
exportdatasize,
|
|
1433
|
+
onBeforeExport: onBeforeexport
|
|
1434
|
+
}
|
|
1435
|
+
),
|
|
1436
|
+
/* @__PURE__ */ jsxs(Box, { className: "app-datagrid", onKeyDown: (e) => handleTableEditKeyDown(e), children: [
|
|
1437
|
+
filtermode === "search" && /* @__PURE__ */ jsx(
|
|
1438
|
+
GlobalSearchFilter,
|
|
1439
|
+
{
|
|
1440
|
+
filteronkeypress,
|
|
1441
|
+
value: globalFilter,
|
|
1442
|
+
onChange: setGlobalFilter,
|
|
1443
|
+
selectedColumn: globalSearchColumn,
|
|
1444
|
+
onColumnChange: setGlobalSearchColumn,
|
|
1445
|
+
columns: columnsForTable,
|
|
1446
|
+
searchLabel: searchlabel,
|
|
1447
|
+
name,
|
|
1448
|
+
listener
|
|
1449
|
+
}
|
|
1450
|
+
),
|
|
1451
|
+
/* @__PURE__ */ jsx(Box, { className: "table-container table-responsive", children: /* @__PURE__ */ jsx(Box, { className: "app-grid-header", children: /* @__PURE__ */ jsxs(
|
|
1452
|
+
Box,
|
|
1453
|
+
{
|
|
1454
|
+
className: "app-grid-header-inner",
|
|
1455
|
+
style: __spreadValues({ height: "100%", overflow: "auto", position: "relative" }, styles),
|
|
1456
|
+
children: [
|
|
1457
|
+
loading && navigation !== "On-Demand" && /* @__PURE__ */ jsx(LoadingComponent, { message: loadingdatamsg }),
|
|
1458
|
+
/* @__PURE__ */ jsxs(
|
|
1459
|
+
Table,
|
|
1460
|
+
__spreadProps(__spreadValues({
|
|
1461
|
+
className: `${TABLE_CSS_CLASSES.gridDefault} table-striped table-hover ${spacingClasses}`.trim(),
|
|
1462
|
+
sx: __spreadValues({
|
|
1463
|
+
width: props.width || "100%"
|
|
1464
|
+
}, tableStructure && hasTableGroups(tableStructure) ? {
|
|
1465
|
+
tableLayout: "fixed",
|
|
1466
|
+
minWidth: table.getTotalSize()
|
|
1467
|
+
} : {})
|
|
1468
|
+
}, { name }), {
|
|
1469
|
+
children: [
|
|
1470
|
+
showheader && wmTableColumns.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1471
|
+
/* @__PURE__ */ jsx(
|
|
1472
|
+
TableHeaderComponent,
|
|
1473
|
+
{
|
|
1474
|
+
table,
|
|
1475
|
+
enablesort,
|
|
1476
|
+
enablecolumnselection,
|
|
1477
|
+
rowClass,
|
|
1478
|
+
ColClassSignature,
|
|
1479
|
+
sorting,
|
|
1480
|
+
columnSizing,
|
|
1481
|
+
rowSelection,
|
|
1482
|
+
rowExpansionConfig,
|
|
1483
|
+
columnsVersion,
|
|
1484
|
+
filterMode: filtermode,
|
|
1485
|
+
columnFilters,
|
|
1486
|
+
onColumnFilterChange: setColumnFilter,
|
|
1487
|
+
renderFormWidget,
|
|
1488
|
+
listener,
|
|
1489
|
+
tableStructure,
|
|
1490
|
+
onColumnSelect: handleColumnSelect,
|
|
1491
|
+
onColumnDeselect: handleColumnDeselect,
|
|
1492
|
+
onHeaderclick,
|
|
1493
|
+
tableName: name
|
|
1494
|
+
}
|
|
1495
|
+
),
|
|
1496
|
+
/* @__PURE__ */ jsx("colgroup", { children: colGroupSpec.map((c) => /* @__PURE__ */ jsx("col", { style: { width: c.width }, width: c.width }, c.key)) })
|
|
1497
|
+
] }),
|
|
1498
|
+
internalDataset.length > 0 && /* @__PURE__ */ jsx(
|
|
1499
|
+
TableBodyComponent,
|
|
1500
|
+
{
|
|
1501
|
+
table,
|
|
1502
|
+
columns,
|
|
1503
|
+
rowClass,
|
|
1504
|
+
formposition,
|
|
1505
|
+
renderAddNewRow,
|
|
1506
|
+
onRowClick: handleRowClick,
|
|
1507
|
+
isRowActive,
|
|
1508
|
+
isRowSelected,
|
|
1509
|
+
nodatamessage,
|
|
1510
|
+
loadingdatamsg,
|
|
1511
|
+
isLoading: datasource == null ? void 0 : datasource.loading,
|
|
1512
|
+
rowExpansionConfig,
|
|
1513
|
+
expandedRows,
|
|
1514
|
+
toggleRowExpansion: handleToggleRowExpansion,
|
|
1515
|
+
isRowExpanded,
|
|
1516
|
+
rowsVersion: tableData.length,
|
|
1517
|
+
ColClassSignature,
|
|
1518
|
+
tableData,
|
|
1519
|
+
editingRowId,
|
|
1520
|
+
activeRowIds,
|
|
1521
|
+
selectedRowIds,
|
|
1522
|
+
isAddingNewRow,
|
|
1523
|
+
customExpressionColumns: customColumns,
|
|
1524
|
+
customColumnsRevision,
|
|
1525
|
+
columnsVersion
|
|
1526
|
+
}
|
|
1527
|
+
),
|
|
1528
|
+
summaryRowEnabled && summaryRowDefs.length > 0 && /* @__PURE__ */ jsx(
|
|
1529
|
+
SummaryRowFooter,
|
|
1530
|
+
{
|
|
1531
|
+
summaryRowDefs,
|
|
1532
|
+
summaryRowDefObjects,
|
|
1533
|
+
columns: wmTableColumnsWithOverrides,
|
|
1534
|
+
tableName: name,
|
|
1535
|
+
summaryRowColumnShow
|
|
1536
|
+
}
|
|
1537
|
+
)
|
|
1538
|
+
]
|
|
1539
|
+
}),
|
|
1540
|
+
`table-${isDynamicTable ? "dynamic" : "static"}-${wmTableColumns.length}-page-${table.getState().pagination.pageIndex}`
|
|
1541
|
+
)
|
|
1542
|
+
]
|
|
1543
|
+
}
|
|
1544
|
+
) }) })
|
|
1545
|
+
] }),
|
|
1546
|
+
/* @__PURE__ */ jsxs(Box, { className: "panel-footer clearfix", children: [
|
|
1547
|
+
showPagination && /* @__PURE__ */ jsx(Box, { className: "app-datagrid-paginator", children: /* @__PURE__ */ jsx(
|
|
1548
|
+
WmPagination,
|
|
1549
|
+
{
|
|
1550
|
+
name,
|
|
1551
|
+
dataset: filtermode ? filteredData : internalDataset,
|
|
1552
|
+
maxResults: (_h = table.getState().pagination.pageSize) != null ? _h : initialPageSize,
|
|
1553
|
+
currentPage: table.getState().pagination.pageIndex + 1,
|
|
1554
|
+
navigation,
|
|
1555
|
+
navigationalign,
|
|
1556
|
+
showrecordcount,
|
|
1557
|
+
maxsize,
|
|
1558
|
+
boundarylinks,
|
|
1559
|
+
directionlinks: true,
|
|
1560
|
+
allowpagesizechange,
|
|
1561
|
+
pagesizeoptions,
|
|
1562
|
+
listener,
|
|
1563
|
+
onPaginationChange: handlePaginationChange,
|
|
1564
|
+
onSetRecord: onSetrecord,
|
|
1565
|
+
onPageSizeChange: handlePageSizeChange,
|
|
1566
|
+
onDataUpdate: handleAccumulatedDataUpdate,
|
|
1567
|
+
onPaginationWidgetReady: handlePaginationWidgetReady,
|
|
1568
|
+
paginationMeta: datasource == null ? void 0 : datasource.pagination,
|
|
1569
|
+
totalItems: (_i = datasource == null ? void 0 : datasource.pagination) == null ? void 0 : _i.totalElements,
|
|
1570
|
+
datasource,
|
|
1571
|
+
isServerSidePagination: isServerSidePagination(),
|
|
1572
|
+
datasourceInvokeOptions: isServerSidePagination() ? {
|
|
1573
|
+
orderBy: sorting.length > 0 ? sorting.map((s) => `${s.id} ${s.desc ? "desc" : "asc"}`).join(", ") : void 0,
|
|
1574
|
+
filterFields: memoizedFilterFields,
|
|
1575
|
+
condition: memoizedLogicalOp
|
|
1576
|
+
} : void 0,
|
|
1577
|
+
ondemandmessage,
|
|
1578
|
+
viewlessmessage,
|
|
1579
|
+
showviewlessbutton
|
|
1580
|
+
}
|
|
1581
|
+
) }),
|
|
1582
|
+
/* @__PURE__ */ jsx(
|
|
1583
|
+
TableFooterActions,
|
|
1584
|
+
{
|
|
1585
|
+
footerActions,
|
|
1586
|
+
spacing,
|
|
1587
|
+
isGridEditMode: isGridEditModeComplete,
|
|
1588
|
+
isLoading: datasource == null ? void 0 : datasource.loading,
|
|
1589
|
+
listener
|
|
1590
|
+
}
|
|
1591
|
+
)
|
|
1592
|
+
] })
|
|
1593
|
+
]
|
|
1594
|
+
})
|
|
1595
|
+
);
|
|
1596
|
+
},
|
|
1597
|
+
(prev, current) => {
|
|
1598
|
+
const keys = [
|
|
1599
|
+
"dataset",
|
|
1600
|
+
"editmode",
|
|
1601
|
+
"navigation",
|
|
1602
|
+
"pagesize",
|
|
1603
|
+
"showrowindex",
|
|
1604
|
+
"showheader",
|
|
1605
|
+
"enablesort",
|
|
1606
|
+
"radioselect",
|
|
1607
|
+
"radioselecttitle",
|
|
1608
|
+
"radioselectarialabel",
|
|
1609
|
+
"multiselect",
|
|
1610
|
+
"multiselecttitle",
|
|
1611
|
+
"multiselectarialabel",
|
|
1612
|
+
"gridfirstrowselect",
|
|
1613
|
+
"rowClass",
|
|
1614
|
+
"deleteoktext",
|
|
1615
|
+
"deletecanceltext",
|
|
1616
|
+
"confirmdelete",
|
|
1617
|
+
"errormessage",
|
|
1618
|
+
"nodatamessage",
|
|
1619
|
+
"loadingdatamsg",
|
|
1620
|
+
"insertmessage",
|
|
1621
|
+
"updatemessage",
|
|
1622
|
+
"deletemessage",
|
|
1623
|
+
"spacing",
|
|
1624
|
+
"title",
|
|
1625
|
+
"subheading",
|
|
1626
|
+
"iconclass",
|
|
1627
|
+
"allowpagesizechange",
|
|
1628
|
+
"pagesizeoptions",
|
|
1629
|
+
"showrecordcount",
|
|
1630
|
+
"shownavigation",
|
|
1631
|
+
"datasource",
|
|
1632
|
+
"binddataset",
|
|
1633
|
+
"onSuccess",
|
|
1634
|
+
"onError",
|
|
1635
|
+
"onRowinsert",
|
|
1636
|
+
"onRowupdate",
|
|
1637
|
+
"onRowdelete",
|
|
1638
|
+
"onSort",
|
|
1639
|
+
"onBeforerowdelete",
|
|
1640
|
+
"onHeaderclick",
|
|
1641
|
+
"onRowselect",
|
|
1642
|
+
"onRowdeselect",
|
|
1643
|
+
"statehandler",
|
|
1644
|
+
"filtermode",
|
|
1645
|
+
"children",
|
|
1646
|
+
"listener",
|
|
1647
|
+
"hidden"
|
|
1648
|
+
];
|
|
1649
|
+
const simplePropsEqual = keys.every((key) => prev[key] === current[key]);
|
|
1650
|
+
if (!simplePropsEqual) return false;
|
|
1651
|
+
const prevChildrenCount = React.Children.count(prev.children);
|
|
1652
|
+
const currentChildrenCount = React.Children.count(current.children);
|
|
1653
|
+
if (prevChildrenCount !== currentChildrenCount) return false;
|
|
1654
|
+
return true;
|
|
1655
|
+
}
|
|
1656
|
+
);
|
|
1809
1657
|
WmTableComponent.displayName = "WmTableComponent";
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
var WmTableWithProvider = function WmTableWithProvider(props) {
|
|
1813
|
-
return __jsx(_useEditedRows.EditedRowsProvider, null, __jsx(WmTableComponent, props));
|
|
1658
|
+
const WmTableWithProvider = (props) => {
|
|
1659
|
+
return /* @__PURE__ */ jsx(EditedRowsProvider, { children: /* @__PURE__ */ jsx(WmTableComponent, __spreadValues({}, props)) });
|
|
1814
1660
|
};
|
|
1815
1661
|
WmTableWithProvider.displayName = "WmTable";
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
var WmTable = (0, _withBaseWrapper["default"])(WmTableWithProvider);
|
|
1662
|
+
const WmTableStandalone = withStandalone(WmTableWithProvider);
|
|
1663
|
+
const WmTable = withBaseWrapper(WmTableWithProvider);
|
|
1819
1664
|
WmTable.displayName = "WmTable";
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
* - [Docs](https://react-components.wavemaker.ai/?path=/story/data-data-table--docs)
|
|
1827
|
-
*
|
|
1828
|
-
* @param props - {@link WmTableProps}
|
|
1829
|
-
*/
|
|
1830
|
-
var _default = exports["default"] = WmTable;
|
|
1665
|
+
var table_default = WmTable;
|
|
1666
|
+
export {
|
|
1667
|
+
WmTableStandalone as WmTable,
|
|
1668
|
+
WmTableComponent,
|
|
1669
|
+
table_default as default
|
|
1670
|
+
};
|