@wavemaker/react-runtime 11.14.1-15.6409
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/actions/base-action.js +32 -0
- package/actions/login-action.js +53 -0
- package/actions/logout-action.js +41 -0
- package/actions/navigation-action.js +145 -0
- package/actions/notification-action.js +147 -0
- package/actions/timer-action.js +164 -0
- package/actions/toast-provider.js +111 -0
- package/actions/toast.js +115 -0
- package/actions/toast.service.js +94 -0
- package/actions/types/index.js +11 -0
- package/components/advanced/carousel/index.js +456 -0
- package/components/advanced/carousel/props.js +5 -0
- package/components/advanced/carousel/template.js +72 -0
- package/components/advanced/login/index.js +307 -0
- package/components/advanced/login/props.js +5 -0
- package/components/advanced/marquee/index.js +158 -0
- package/components/advanced/marquee/props.js +5 -0
- package/components/basic/anchor/index.js +239 -0
- package/components/basic/anchor/props.js +5 -0
- package/components/basic/audio/index.js +61 -0
- package/components/basic/html/index.js +158 -0
- package/components/basic/icon/index.js +85 -0
- package/components/basic/iframe/iframe.utils.js +10 -0
- package/components/basic/iframe/index.js +95 -0
- package/components/basic/label/index.js +139 -0
- package/components/basic/message/index.js +120 -0
- package/components/basic/message/props.js +5 -0
- package/components/basic/picture/index.js +117 -0
- package/components/basic/picture/props.js +5 -0
- package/components/basic/progress-bar/index.js +168 -0
- package/components/basic/progress-bar/props.js +18 -0
- package/components/basic/progress-circle/index.js +196 -0
- package/components/basic/progress-circle/props.js +16 -0
- package/components/basic/richtexteditor/index.js +533 -0
- package/components/basic/richtexteditor/props.js +5 -0
- package/components/basic/search/index.js +1023 -0
- package/components/basic/search/props.js +5 -0
- package/components/basic/search/providers.js +350 -0
- package/components/basic/spinner/index.js +202 -0
- package/components/basic/spinner/props.js +12 -0
- package/components/basic/tile/index.js +91 -0
- package/components/basic/tree/Components/TreeNodeComponent.js +142 -0
- package/components/basic/tree/index.js +503 -0
- package/components/basic/tree/props.js +5 -0
- package/components/basic/tree/utils.js +154 -0
- package/components/basic/video/index.js +85 -0
- package/components/basic/video/props.js +5 -0
- package/components/chart/components/barColumnChart/index.js +132 -0
- package/components/chart/components/barColumnChart/props.js +5 -0
- package/components/chart/components/bubbleChart/index.js +176 -0
- package/components/chart/components/bubbleChart/props.js +5 -0
- package/components/chart/components/chartLegend/components/ClassicLegendItem.js +39 -0
- package/components/chart/components/chartLegend/components/FuriousLegendItem.js +81 -0
- package/components/chart/components/chartLegend/index.js +69 -0
- package/components/chart/components/chartLegend/props.js +5 -0
- package/components/chart/components/chartLegend/utils.js +31 -0
- package/components/chart/components/chartTooltip/index.js +53 -0
- package/components/chart/components/chartTooltip/styles.js +37 -0
- package/components/chart/components/chartTooltip/utils.js +23 -0
- package/components/chart/components/cumulativeLineChart/index.js +113 -0
- package/components/chart/components/cumulativeLineChart/props.js +5 -0
- package/components/chart/components/cumulativeLineChart/utils.js +34 -0
- package/components/chart/components/index.js +40 -0
- package/components/chart/components/lineAreaChart/index.js +140 -0
- package/components/chart/components/lineAreaChart/props.js +5 -0
- package/components/chart/components/noDataMessage/index.js +27 -0
- package/components/chart/components/pieDonutChart/index.js +171 -0
- package/components/chart/components/pieDonutChart/props.js +5 -0
- package/components/chart/constant.js +72 -0
- package/components/chart/index.js +930 -0
- package/components/chart/props.js +5 -0
- package/components/chart/utils.js +691 -0
- package/components/common/AppSpinner.js +36 -0
- package/components/common/app-spinner.js +26 -0
- package/components/common/index.js +12 -0
- package/components/constants.js +1208 -0
- package/components/container/accordion/accordion-pane/index.js +108 -0
- package/components/container/accordion/accordion-pane/props.js +11 -0
- package/components/container/accordion/index.js +232 -0
- package/components/container/accordion/props.js +13 -0
- package/components/container/alignment-utils.js +183 -0
- package/components/container/index.js +188 -0
- package/components/container/layout-grid/grid-column/index.js +34 -0
- package/components/container/layout-grid/grid-row/index.js +24 -0
- package/components/container/layout-grid/index.js +33 -0
- package/components/container/linear-layout/index.js +72 -0
- package/components/container/linear-layout/linear-layout-item/index.js +43 -0
- package/components/container/panel/components/panel-header/index.js +144 -0
- package/components/container/panel/components/panel-header/props.js +5 -0
- package/components/container/panel/hooks.js +144 -0
- package/components/container/panel/index.js +286 -0
- package/components/container/panel/props.js +5 -0
- package/components/container/props.js +5 -0
- package/components/container/tabs/index.js +379 -0
- package/components/container/tabs/props.js +20 -0
- package/components/container/tabs/tab-pane/index.js +42 -0
- package/components/container/tabs/tab-pane/props.js +5 -0
- package/components/container/wizard/WizardContext.js +16 -0
- package/components/container/wizard/components/StepComponents.js +100 -0
- package/components/container/wizard/components/WizardStep.js +89 -0
- package/components/container/wizard/index.js +710 -0
- package/components/container/wizard/props.js +5 -0
- package/components/container/wizard/utils.js +133 -0
- package/components/container/wizard/wizard-action/index.js +22 -0
- package/components/container/wizard/wizard-step/index.js +94 -0
- package/components/data/card/card-actions/index.js +24 -0
- package/components/data/card/card-content/index.js +38 -0
- package/components/data/card/card-footer/index.js +24 -0
- package/components/data/card/index.js +246 -0
- package/components/data/card/props.js +5 -0
- package/components/data/form/base-form/constant.js +39 -0
- package/components/data/form/base-form/index.js +460 -0
- package/components/data/form/base-form/props.js +29 -0
- package/components/data/form/base-form/utils.js +42 -0
- package/components/data/form/dynamic-fields/index.js +196 -0
- package/components/data/form/dynamic-fields/props.js +5 -0
- package/components/data/form/dynamic-fields/utils.js +237 -0
- package/components/data/form/form-action/index.js +71 -0
- package/components/data/form/form-body/index.js +26 -0
- package/components/data/form/form-context.js +34 -0
- package/components/data/form/form-controller/props.js +19 -0
- package/components/data/form/form-controller/validation-contrustor.js +313 -0
- package/components/data/form/form-controller/withFormController.js +320 -0
- package/components/data/form/form-field/base-field.js +138 -0
- package/components/data/form/form-field/index.js +36 -0
- package/components/data/form/form-field/props.js +5 -0
- package/components/data/form/form-footer/index.js +26 -0
- package/components/data/form/form-header/index.js +56 -0
- package/components/data/form/index.js +39 -0
- package/components/data/form/props.js +5 -0
- package/components/data/list/components/GroupHeader.js +35 -0
- package/components/data/list/components/GroupedListItems.js +98 -0
- package/components/data/list/components/ListContainer.js +27 -0
- package/components/data/list/components/ListDND.js +241 -0
- package/components/data/list/components/ListHeader.js +59 -0
- package/components/data/list/components/ListItem.js +148 -0
- package/components/data/list/components/ListItemWithTemplate.js +59 -0
- package/components/data/list/components/ListItems.js +231 -0
- package/components/data/list/components/ListPagination.js +165 -0
- package/components/data/list/components/LoadMoreButton.js +39 -0
- package/components/data/list/components/NoDataMessage.js +22 -0
- package/components/data/list/components/StandardListItems.js +84 -0
- package/components/data/list/components/index.js +119 -0
- package/components/data/list/components/props.js +5 -0
- package/components/data/list/hooks/index.js +75 -0
- package/components/data/list/hooks/props.js +5 -0
- package/components/data/list/hooks/useCurrentPageItems.js +48 -0
- package/components/data/list/hooks/useGroupedData.js +37 -0
- package/components/data/list/hooks/useListData.js +60 -0
- package/components/data/list/hooks/useListEffects.js +285 -0
- package/components/data/list/hooks/useListEventHandlers.js +291 -0
- package/components/data/list/hooks/useListPagination.js +168 -0
- package/components/data/list/hooks/useListState.js +98 -0
- package/components/data/list/hooks/useListStateManager.js +195 -0
- package/components/data/list/hooks/usePaginatedGroupedData.js +121 -0
- package/components/data/list/index.js +611 -0
- package/components/data/list/props.js +5 -0
- package/components/data/list/templates/media-template.js +53 -0
- package/components/data/list/utils/constants.js +81 -0
- package/components/data/list/utils/list-helpers.js +173 -0
- package/components/data/list/utils/list-widget-methods.js +114 -0
- package/components/data/live-filter/index.js +279 -0
- package/components/data/live-filter/props.js +12 -0
- package/components/data/live-form/index.js +93 -0
- package/components/data/live-form/props.js +16 -0
- package/components/data/pagination/components/BasicPagination.js +77 -0
- package/components/data/pagination/components/ClassicPagination.js +191 -0
- package/components/data/pagination/components/InlinePagination.js +99 -0
- package/components/data/pagination/components/LoadingComponent.js +31 -0
- package/components/data/pagination/components/PageSizeSelector.js +175 -0
- package/components/data/pagination/components/PagerNavigation.js +105 -0
- package/components/data/pagination/components/TotalRecords.js +52 -0
- package/components/data/pagination/components/index.js +47 -0
- package/components/data/pagination/components/props.js +5 -0
- package/components/data/pagination/hooks/index.js +19 -0
- package/components/data/pagination/hooks/props.js +5 -0
- package/components/data/pagination/hooks/useNavigationSize.js +44 -0
- package/components/data/pagination/hooks/usePagination.js +796 -0
- package/components/data/pagination/index.js +322 -0
- package/components/data/table/components/AddNewRow.js +190 -0
- package/components/data/table/components/EditableCell.js +91 -0
- package/components/data/table/components/FieldValidationError.js +24 -0
- package/components/data/table/components/RowExpansionButton.js +74 -0
- package/components/data/table/components/TableBody.js +279 -0
- package/components/data/table/components/TableFilters.js +325 -0
- package/components/data/table/components/TableFooterActions.js +48 -0
- package/components/data/table/components/TableHeader.js +174 -0
- package/components/data/table/components/TablePanelHeading.js +68 -0
- package/components/data/table/components/index.js +74 -0
- package/components/data/table/hooks/index.js +219 -0
- package/components/data/table/hooks/useCellState.js +117 -0
- package/components/data/table/hooks/useDynamicColumns.js +85 -0
- package/components/data/table/hooks/useEditingState.js +47 -0
- package/components/data/table/hooks/useFormWidget.js +184 -0
- package/components/data/table/hooks/usePaginationState.js +60 -0
- package/components/data/table/hooks/usePanelStructure.js +40 -0
- package/components/data/table/hooks/useResponsiveColumns.js +34 -0
- package/components/data/table/hooks/useRowExpansion.js +110 -0
- package/components/data/table/hooks/useRowHandlers.js +38 -0
- package/components/data/table/hooks/useRowSelection.js +213 -0
- package/components/data/table/hooks/useServerSideSorting.js +165 -0
- package/components/data/table/hooks/useTableColumns.js +263 -0
- package/components/data/table/hooks/useTableData.js +154 -0
- package/components/data/table/hooks/useTableEdit.js +467 -0
- package/components/data/table/hooks/useTableEffects.js +139 -0
- package/components/data/table/hooks/useTableFilter.js +389 -0
- package/components/data/table/hooks/useTableInitialization.js +103 -0
- package/components/data/table/hooks/useTableState.js +69 -0
- package/components/data/table/hooks/useTableStateManager.js +558 -0
- package/components/data/table/index.js +1295 -0
- package/components/data/table/live-table/index.js +232 -0
- package/components/data/table/props.js +5 -0
- package/components/data/table/table-action/index.js +78 -0
- package/components/data/table/table-column/index.js +35 -0
- package/components/data/table/table-row/index.js +49 -0
- package/components/data/table/table-row-action/index.js +74 -0
- package/components/data/table/utils/buildSelectionColumns.js +173 -0
- package/components/data/table/utils/columnBuilder.js +209 -0
- package/components/data/table/utils/columnProxy.js +48 -0
- package/components/data/table/utils/columnWidthDistribution.js +98 -0
- package/components/data/table/utils/constants.js +80 -0
- package/components/data/table/utils/crud-handlers.js +518 -0
- package/components/data/table/utils/dynamic-columns.js +118 -0
- package/components/data/table/utils/index.js +607 -0
- package/components/data/table/utils/renderDisplayCell.js +183 -0
- package/components/data/table/utils/selectionUtils.js +166 -0
- package/components/data/table/utils/table-helpers.js +100 -0
- package/components/data/table/utils/validation.js +124 -0
- package/components/data/types.js +113 -0
- package/components/data/utils/field-data-utils.js +66 -0
- package/components/data/utils/filter-field-util.js +81 -0
- package/components/data/utils/index.js +216 -0
- package/components/dialogs/alert-dialog/index.js +80 -0
- package/components/dialogs/confirm-dialog/index.js +105 -0
- package/components/dialogs/dialog/index.js +56 -0
- package/components/dialogs/dialog-actions/index.js +18 -0
- package/components/dialogs/dialog-body/index.js +21 -0
- package/components/dialogs/dialog-content/index.js +30 -0
- package/components/dialogs/dialog-header/index.js +93 -0
- package/components/dialogs/iframe-dialog/index.js +114 -0
- package/components/dialogs/index.js +129 -0
- package/components/dialogs/login-dialog/index.js +369 -0
- package/components/dialogs/login-dialog/props.js +5 -0
- package/components/dialogs/page-dialog/index.js +96 -0
- package/components/dialogs/withDialogWrapper.js +108 -0
- package/components/form/button/index.js +216 -0
- package/components/form/button-group/index.js +60 -0
- package/components/input/calendar/index.js +546 -0
- package/components/input/calendar/props.js +5 -0
- package/components/input/calendar/utils.js +340 -0
- package/components/input/chips/SortableChip/index.js +115 -0
- package/components/input/chips/SortableChip/props.js +5 -0
- package/components/input/chips/index.js +488 -0
- package/components/input/chips/props.js +5 -0
- package/components/input/chips/utils.js +259 -0
- package/components/input/color-picker/index.js +678 -0
- package/components/input/color-picker/props.js +5 -0
- package/components/input/composite/index.js +137 -0
- package/components/input/currency/index.js +263 -0
- package/components/input/currency/props.js +5 -0
- package/components/input/default/checkbox/index.js +230 -0
- package/components/input/default/checkbox/props.js +5 -0
- package/components/input/default/checkboxset/index.js +476 -0
- package/components/input/default/checkboxset/props.js +5 -0
- package/components/input/default/radioset/index.js +379 -0
- package/components/input/default/radioset/props.js +5 -0
- package/components/input/default/switch/index.js +490 -0
- package/components/input/default/switch/prop.js +5 -0
- package/components/input/epoch/date/components/DatePickerPopover.js +220 -0
- package/components/input/epoch/date/index.js +520 -0
- package/components/input/epoch/date/props.js +5 -0
- package/components/input/epoch/date/styled.js +70 -0
- package/components/input/epoch/date/utils.js +108 -0
- package/components/input/epoch/datetime/index.js +656 -0
- package/components/input/epoch/datetime/props.js +5 -0
- package/components/input/epoch/datetime/styled.js +90 -0
- package/components/input/epoch/datetime/utils.js +244 -0
- package/components/input/epoch/time/index.js +412 -0
- package/components/input/epoch/time/props.js +5 -0
- package/components/input/epoch/time/utils.js +209 -0
- package/components/input/fileupload/Utils.js +134 -0
- package/components/input/fileupload/components/ListItems.js +140 -0
- package/components/input/fileupload/components/MultiUpload.js +85 -0
- package/components/input/fileupload/components/SingleUpload.js +65 -0
- package/components/input/fileupload/index.js +170 -0
- package/components/input/fileupload/props.js +5 -0
- package/components/input/fileupload/useFileUpload.js +400 -0
- package/components/input/number/index.js +295 -0
- package/components/input/number/props.js +5 -0
- package/components/input/rating/index.js +368 -0
- package/components/input/rating/props.js +5 -0
- package/components/input/select/index.js +344 -0
- package/components/input/select/props.js +5 -0
- package/components/input/slider/index.js +167 -0
- package/components/input/slider/props.js +5 -0
- package/components/input/text/index.js +434 -0
- package/components/input/text/props.js +5 -0
- package/components/input/text/util.js +179 -0
- package/components/input/textarea/index.js +347 -0
- package/components/input/textarea/props.js +5 -0
- package/components/layout/footer/index.js +30 -0
- package/components/layout/header/index.js +30 -0
- package/components/layout/leftnav/index.js +44 -0
- package/components/layout/rightnav/index.js +32 -0
- package/components/layout/topnav/index.js +34 -0
- package/components/navbar/index.js +41 -0
- package/components/navbar/nav/index.js +102 -0
- package/components/navbar/nav/props.js +5 -0
- package/components/navbar/nav-item/index.js +44 -0
- package/components/navigation/breadcrumb/index.js +56 -0
- package/components/navigation/breadcrumb/props.js +5 -0
- package/components/navigation/menu/components/ListItems.js +66 -0
- package/components/navigation/menu/constants.js +101 -0
- package/components/navigation/menu/index.js +807 -0
- package/components/navigation/menu/props.js +5 -0
- package/components/navigation/popover/index.js +209 -0
- package/components/navigation/popover/props.js +15 -0
- package/components/page/content/index.js +28 -0
- package/components/page/error-boundary/index.js +108 -0
- package/components/page/index.js +137 -0
- package/components/page/page-content/index.js +23 -0
- package/components/page/partial/index.js +36 -0
- package/components/page/partial-container/index.js +48 -0
- package/components/page/props.js +5 -0
- package/components/page/toast-container/index.js +33 -0
- package/components/prefab/container/index.js +46 -0
- package/components/prefab/index.js +67 -0
- package/context/AppContext.js +25 -0
- package/context/AppSpinnerProvider.js +43 -0
- package/context/LocalizationProvider.js +79 -0
- package/context/PrefabContext.js +66 -0
- package/context/WidgetProvider.js +187 -0
- package/core/app-config.js +1 -0
- package/core/app.service.js +357 -0
- package/core/appVariablesStore.js +20 -0
- package/core/appstore.js +88 -0
- package/core/constants/currency-constant.js +1071 -0
- package/core/constants/events.js +34 -0
- package/core/constants/index.js +27 -0
- package/core/dialog.service.js +76 -0
- package/core/event-notifier.js +151 -0
- package/core/formatter/date-formatters.js +222 -0
- package/core/formatter/index.js +131 -0
- package/core/formatter/number-formatters.js +142 -0
- package/core/formatter/security-formatters.js +323 -0
- package/core/formatter/string-formatters.js +52 -0
- package/core/formatter/types.js +18 -0
- package/core/formatters.js +24 -0
- package/core/proxy-service.js +412 -0
- package/core/script-registry.js +63 -0
- package/core/security.service.js +11 -0
- package/core/util/common.js +33 -0
- package/core/util/dom.js +107 -0
- package/core/util/index.js +136 -0
- package/core/util/security.js +184 -0
- package/core/util/utils.js +189 -0
- package/core/widget-observer.js +98 -0
- package/higherOrder/BaseApp.js +430 -0
- package/higherOrder/BaseAppProps.js +5 -0
- package/higherOrder/BaseDateTime.js +251 -0
- package/higherOrder/BasePage.js +715 -0
- package/higherOrder/BasePartial.js +124 -0
- package/higherOrder/BasePrefab.js +145 -0
- package/higherOrder/DataNav.js +377 -0
- package/higherOrder/helper.js +43 -0
- package/higherOrder/props.js +5 -0
- package/higherOrder/withBaseWrapper.js +183 -0
- package/hooks/useAccess.js +308 -0
- package/hooks/useAppConfig.js +42 -0
- package/hooks/useAuth.js +562 -0
- package/hooks/useDataSourceSubscription.js +125 -0
- package/hooks/useDebounce.js +76 -0
- package/hooks/useDeviceVisibility.js +49 -0
- package/hooks/useHttp.js +338 -0
- package/libs/index.js +20 -0
- package/mui-config/theme-provider.js +17 -0
- package/mui-config/theme.js +371 -0
- package/package-lock.json +10177 -0
- package/package.json +95 -0
- package/store/index.js +33 -0
- package/store/middleware/navigationMiddleware.js +48 -0
- package/store/slices/appConfigSlice.js +103 -0
- package/store/slices/authSlice.js +508 -0
- package/store/slices/i18nSlice.js +206 -0
- package/types/index.js +15 -0
- package/utils/dataset-util.js +174 -0
- package/utils/eval-expression.js +32 -0
- package/utils/form-state.util.js +140 -0
- package/utils/form-utils.js +187 -0
- package/utils/format-util.js +260 -0
- package/utils/page-params-util.js +24 -0
- package/utils/resource-url.js +27 -0
- package/utils/state-persistance.js +343 -0
- package/utils/style-utils.js +73 -0
- package/utils/transformedDataset-utils.js +633 -0
- package/utils/widget-cleanup-util.js +84 -0
- package/utils/widgets.js +99 -0
- package/variables/base-variable.js +173 -0
- package/variables/constants.js +27 -0
- package/variables/live-variable.js +166 -0
- package/variables/model-variable.js +77 -0
- package/variables/service-variable.js +307 -0
|
@@ -0,0 +1,1295 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = exports.WmTableComponent = void 0;
|
|
9
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
14
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
16
|
+
var _reactTable = require("@tanstack/react-table");
|
|
17
|
+
var _material = require("@mui/material");
|
|
18
|
+
var _lodashEs = require("lodash-es");
|
|
19
|
+
var _withBaseWrapper = _interopRequireDefault(require("../../../higherOrder/withBaseWrapper"));
|
|
20
|
+
var _pagination = _interopRequireDefault(require("../pagination"));
|
|
21
|
+
var _hooks = require("./hooks");
|
|
22
|
+
var _utils = require("./utils");
|
|
23
|
+
var _components = require("./components");
|
|
24
|
+
var _buildSelectionColumns = require("./utils/buildSelectionColumns");
|
|
25
|
+
var _LoadingComponent = _interopRequireDefault(require("../pagination/components/LoadingComponent"));
|
|
26
|
+
var _columnProxy = require("./utils/columnProxy");
|
|
27
|
+
var _useDataSourceSubscription = require("../../../hooks/useDataSourceSubscription");
|
|
28
|
+
var _crudHandlers = require("./utils/crud-handlers");
|
|
29
|
+
var _types = require("../types");
|
|
30
|
+
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", "radioselect", "radioselecttitle", "radioselectarialabel", "multiselect", "multiselecttitle", "multiselectarialabel", "gridfirstrowselect", "rowClass", "deleteoktext", "deletecanceltext", "confirmdelete", "errormessage", "nodatamessage", "loadingdatamsg", "insertmessage", "updatemessage", "deletemessage", "onRowDelete", "onRowUpdate", "datasource", "binddataset", "onSuccess", "onError", "onRowinsert", "onRowupdate", "onRowdelete", "onRowclick", "statehandler", "formName", "filtermode", "searchlabel", "onBeforedatarender", "onDatarender", "className"]; // Import custom hooks and utilities
|
|
31
|
+
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" != _typeof(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); }
|
|
32
|
+
var __jsx = _react["default"].createElement;
|
|
33
|
+
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; }
|
|
34
|
+
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; }
|
|
35
|
+
var WmTableComponent = exports.WmTableComponent = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
36
|
+
var _datasource$paginatio2, _datasource$paginatio4;
|
|
37
|
+
var name = _ref.name,
|
|
38
|
+
_ref$dataset = _ref.dataset,
|
|
39
|
+
dataset = _ref$dataset === void 0 ? [] : _ref$dataset,
|
|
40
|
+
_ref$navigation = _ref.navigation,
|
|
41
|
+
navigation = _ref$navigation === void 0 ? "Pager" : _ref$navigation,
|
|
42
|
+
children = _ref.children,
|
|
43
|
+
listener = _ref.listener,
|
|
44
|
+
_ref$pagesize = _ref.pagesize,
|
|
45
|
+
pagesize = _ref$pagesize === void 0 ? 5 : _ref$pagesize,
|
|
46
|
+
_ref$navigationalign = _ref.navigationalign,
|
|
47
|
+
navigationalign = _ref$navigationalign === void 0 ? "left" : _ref$navigationalign,
|
|
48
|
+
_ref$showrecordcount = _ref.showrecordcount,
|
|
49
|
+
showrecordcount = _ref$showrecordcount === void 0 ? false : _ref$showrecordcount,
|
|
50
|
+
_ref$maxsize = _ref.maxsize,
|
|
51
|
+
maxsize = _ref$maxsize === void 0 ? 5 : _ref$maxsize,
|
|
52
|
+
_ref$boundarylinks = _ref.boundarylinks,
|
|
53
|
+
boundarylinks = _ref$boundarylinks === void 0 ? false : _ref$boundarylinks,
|
|
54
|
+
_ref$allowpagesizecha = _ref.allowpagesizechange,
|
|
55
|
+
allowpagesizechange = _ref$allowpagesizecha === void 0 ? false : _ref$allowpagesizecha,
|
|
56
|
+
_ref$pagesizeoptions = _ref.pagesizeoptions,
|
|
57
|
+
pagesizeoptions = _ref$pagesizeoptions === void 0 ? "5,10,20,50,100" : _ref$pagesizeoptions,
|
|
58
|
+
_ref$formposition = _ref.formposition,
|
|
59
|
+
formposition = _ref$formposition === void 0 ? "bottom" : _ref$formposition,
|
|
60
|
+
_ref$editmode = _ref.editmode,
|
|
61
|
+
editmode = _ref$editmode === void 0 ? "none" : _ref$editmode,
|
|
62
|
+
_ref$spacing = _ref.spacing,
|
|
63
|
+
spacing = _ref$spacing === void 0 ? "normal" : _ref$spacing,
|
|
64
|
+
title = _ref.title,
|
|
65
|
+
subheading = _ref.subheading,
|
|
66
|
+
iconclass = _ref.iconclass,
|
|
67
|
+
_ref$exportOptions = _ref.exportOptions,
|
|
68
|
+
exportOptions = _ref$exportOptions === void 0 ? [] : _ref$exportOptions,
|
|
69
|
+
_ref$shownavigation = _ref.shownavigation,
|
|
70
|
+
shownavigation = _ref$shownavigation === void 0 ? true : _ref$shownavigation,
|
|
71
|
+
_ref$onDemandLoad = _ref.onDemandLoad,
|
|
72
|
+
onDemandLoad = _ref$onDemandLoad === void 0 ? false : _ref$onDemandLoad,
|
|
73
|
+
_ref$showrowindex = _ref.showrowindex,
|
|
74
|
+
showrowindex = _ref$showrowindex === void 0 ? false : _ref$showrowindex,
|
|
75
|
+
_ref$showheader = _ref.showheader,
|
|
76
|
+
showheader = _ref$showheader === void 0 ? true : _ref$showheader,
|
|
77
|
+
_ref$enablesort = _ref.enablesort,
|
|
78
|
+
enablesort = _ref$enablesort === void 0 ? true : _ref$enablesort,
|
|
79
|
+
_ref$radioselect = _ref.radioselect,
|
|
80
|
+
radioselect = _ref$radioselect === void 0 ? false : _ref$radioselect,
|
|
81
|
+
_ref$radioselecttitle = _ref.radioselecttitle,
|
|
82
|
+
radioselecttitle = _ref$radioselecttitle === void 0 ? "" : _ref$radioselecttitle,
|
|
83
|
+
_ref$radioselectarial = _ref.radioselectarialabel,
|
|
84
|
+
radioselectarialabel = _ref$radioselectarial === void 0 ? _utils.TABLE_MESSAGES.radioSelectAriaLabel : _ref$radioselectarial,
|
|
85
|
+
_ref$multiselect = _ref.multiselect,
|
|
86
|
+
multiselect = _ref$multiselect === void 0 ? false : _ref$multiselect,
|
|
87
|
+
_ref$multiselecttitle = _ref.multiselecttitle,
|
|
88
|
+
multiselecttitle = _ref$multiselecttitle === void 0 ? "" : _ref$multiselecttitle,
|
|
89
|
+
_ref$multiselectarial = _ref.multiselectarialabel,
|
|
90
|
+
multiselectarialabel = _ref$multiselectarial === void 0 ? _utils.TABLE_MESSAGES.multiSelectAriaLabel : _ref$multiselectarial,
|
|
91
|
+
_ref$gridfirstrowsele = _ref.gridfirstrowselect,
|
|
92
|
+
gridfirstrowselect = _ref$gridfirstrowsele === void 0 ? false : _ref$gridfirstrowsele,
|
|
93
|
+
_ref$rowClass = _ref.rowClass,
|
|
94
|
+
rowClass = _ref$rowClass === void 0 ? "" : _ref$rowClass,
|
|
95
|
+
_ref$deleteoktext = _ref.deleteoktext,
|
|
96
|
+
deleteoktext = _ref$deleteoktext === void 0 ? _utils.TABLE_MESSAGES.deleteOkText : _ref$deleteoktext,
|
|
97
|
+
_ref$deletecanceltext = _ref.deletecanceltext,
|
|
98
|
+
deletecanceltext = _ref$deletecanceltext === void 0 ? _utils.TABLE_MESSAGES.deleteCancelText : _ref$deletecanceltext,
|
|
99
|
+
_ref$confirmdelete = _ref.confirmdelete,
|
|
100
|
+
confirmdelete = _ref$confirmdelete === void 0 ? _utils.TABLE_MESSAGES.deleteConfirmMessage : _ref$confirmdelete,
|
|
101
|
+
_ref$errormessage = _ref.errormessage,
|
|
102
|
+
errormessage = _ref$errormessage === void 0 ? _utils.TABLE_MESSAGES.operationError : _ref$errormessage,
|
|
103
|
+
_ref$nodatamessage = _ref.nodatamessage,
|
|
104
|
+
nodatamessage = _ref$nodatamessage === void 0 ? _utils.TABLE_MESSAGES.noDataMessage : _ref$nodatamessage,
|
|
105
|
+
_ref$loadingdatamsg = _ref.loadingdatamsg,
|
|
106
|
+
loadingdatamsg = _ref$loadingdatamsg === void 0 ? _utils.TABLE_MESSAGES.loadingMessage : _ref$loadingdatamsg,
|
|
107
|
+
_ref$insertmessage = _ref.insertmessage,
|
|
108
|
+
insertmessage = _ref$insertmessage === void 0 ? _utils.TABLE_MESSAGES.insertSuccess : _ref$insertmessage,
|
|
109
|
+
_ref$updatemessage = _ref.updatemessage,
|
|
110
|
+
updatemessage = _ref$updatemessage === void 0 ? _utils.TABLE_MESSAGES.updateSuccess : _ref$updatemessage,
|
|
111
|
+
_ref$deletemessage = _ref.deletemessage,
|
|
112
|
+
deletemessage = _ref$deletemessage === void 0 ? _utils.TABLE_MESSAGES.deleteSuccess : _ref$deletemessage,
|
|
113
|
+
onRowDelete = _ref.onRowDelete,
|
|
114
|
+
onRowUpdate = _ref.onRowUpdate,
|
|
115
|
+
datasource = _ref.datasource,
|
|
116
|
+
binddataset = _ref.binddataset,
|
|
117
|
+
onSuccess = _ref.onSuccess,
|
|
118
|
+
onError = _ref.onError,
|
|
119
|
+
onRowinsert = _ref.onRowinsert,
|
|
120
|
+
onRowupdate = _ref.onRowupdate,
|
|
121
|
+
onRowdelete = _ref.onRowdelete,
|
|
122
|
+
onRowclick = _ref.onRowclick,
|
|
123
|
+
statehandler = _ref.statehandler,
|
|
124
|
+
formName = _ref.formName,
|
|
125
|
+
filtermode = _ref.filtermode,
|
|
126
|
+
_ref$searchlabel = _ref.searchlabel,
|
|
127
|
+
searchlabel = _ref$searchlabel === void 0 ? "Search" : _ref$searchlabel,
|
|
128
|
+
onBeforedatarender = _ref.onBeforedatarender,
|
|
129
|
+
onDatarender = _ref.onDatarender,
|
|
130
|
+
className = _ref.className,
|
|
131
|
+
props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
132
|
+
var _useState = (0, _react.useState)((datasource === null || datasource === void 0 ? void 0 : datasource.loading) || false),
|
|
133
|
+
loading = _useState[0],
|
|
134
|
+
setLoading = _useState[1];
|
|
135
|
+
(0, _react.useEffect)(function () {
|
|
136
|
+
// Sync local loading state with datasource loading
|
|
137
|
+
if ((datasource === null || datasource === void 0 ? void 0 : datasource.loading) !== undefined) {
|
|
138
|
+
setLoading(datasource.loading);
|
|
139
|
+
}
|
|
140
|
+
}, [datasource === null || datasource === void 0 ? void 0 : datasource.loading]);
|
|
141
|
+
|
|
142
|
+
// State for accumulated data in Scroll navigation mode
|
|
143
|
+
var _useState2 = (0, _react.useState)([]),
|
|
144
|
+
scrollAccumulatedData = _useState2[0],
|
|
145
|
+
setScrollAccumulatedData = _useState2[1];
|
|
146
|
+
|
|
147
|
+
// Callback to receive accumulated data from pagination
|
|
148
|
+
var handleScrollDataUpdate = (0, _react.useCallback)(function (data) {
|
|
149
|
+
// Only update if data has actually changed to prevent unnecessary re-renders
|
|
150
|
+
setScrollAccumulatedData(function (prevData) {
|
|
151
|
+
// If lengths are different, it's definitely new data
|
|
152
|
+
if (prevData.length !== data.length) {
|
|
153
|
+
return data;
|
|
154
|
+
}
|
|
155
|
+
// Otherwise keep the previous reference to avoid re-render
|
|
156
|
+
return prevData;
|
|
157
|
+
});
|
|
158
|
+
}, []);
|
|
159
|
+
|
|
160
|
+
// Reset accumulated data when navigation changes or dataset changes
|
|
161
|
+
(0, _react.useEffect)(function () {
|
|
162
|
+
if (navigation !== "Scroll") {
|
|
163
|
+
setScrollAccumulatedData([]);
|
|
164
|
+
}
|
|
165
|
+
}, [navigation]);
|
|
166
|
+
|
|
167
|
+
// Create a centralized toast notification function
|
|
168
|
+
var showToast = (0, _react.useCallback)(function (message, type) {
|
|
169
|
+
if (listener && listener.App && typeof listener.App.notifyApp === "function") {
|
|
170
|
+
listener.App.notifyApp(message, type);
|
|
171
|
+
}
|
|
172
|
+
}, [listener]);
|
|
173
|
+
|
|
174
|
+
// Determine if we're using server-side pagination
|
|
175
|
+
// Check if datasource is API-aware (server-side) rather than checking runtime pagination data
|
|
176
|
+
var isServerSidePagination = (0, _react.useMemo)(function () {
|
|
177
|
+
return !!(datasource && datasource.execute && datasource.execute(_types.DataSource.Operation.IS_PAGEABLE));
|
|
178
|
+
}, [datasource]);
|
|
179
|
+
|
|
180
|
+
// Disable state management for Scroll navigation
|
|
181
|
+
var effectiveStateHandler = navigation === "Scroll" ? "none" : statehandler;
|
|
182
|
+
|
|
183
|
+
// Use datasource subscription for SSP state restoration - RUN FIRST
|
|
184
|
+
// This hook must run before other hooks to ensure datasource state is properly initialized
|
|
185
|
+
(0, _useDataSourceSubscription.useDataSourceSubscription)({
|
|
186
|
+
datasource: datasource,
|
|
187
|
+
statehandler: effectiveStateHandler,
|
|
188
|
+
name: name,
|
|
189
|
+
widgetType: "table",
|
|
190
|
+
onPageRestored: function onPageRestored() {
|
|
191
|
+
// This will be called when datasource loads with restored page
|
|
192
|
+
// The page is already set in datasource options, so we don't need to do anything here
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// Use custom hooks for organized functionality
|
|
197
|
+
var _useTableData = (0, _hooks.useTableData)({
|
|
198
|
+
dataset: dataset,
|
|
199
|
+
onRowDelete: onRowDelete,
|
|
200
|
+
deleteoktext: deleteoktext,
|
|
201
|
+
deletecanceltext: deletecanceltext,
|
|
202
|
+
confirmdelete: confirmdelete,
|
|
203
|
+
deletemessage: deletemessage,
|
|
204
|
+
errormessage: errormessage,
|
|
205
|
+
showToast: showToast,
|
|
206
|
+
datasource: datasource,
|
|
207
|
+
binddataset: binddataset,
|
|
208
|
+
onSuccess: onSuccess,
|
|
209
|
+
onError: onError,
|
|
210
|
+
onRowdelete: onRowdelete,
|
|
211
|
+
isServerSidePagination: isServerSidePagination
|
|
212
|
+
}),
|
|
213
|
+
internalDataset = _useTableData.internalDataset,
|
|
214
|
+
setInternalDataset = _useTableData.setInternalDataset,
|
|
215
|
+
_deleteRecord = _useTableData.deleteRecord,
|
|
216
|
+
renderConfirmDialog = _useTableData.renderConfirmDialog;
|
|
217
|
+
var _useFormWidget = (0, _hooks.useFormWidget)({
|
|
218
|
+
listener: listener
|
|
219
|
+
}),
|
|
220
|
+
renderFormWidget = _useFormWidget.renderFormWidget;
|
|
221
|
+
|
|
222
|
+
// Use generic cell state hook for managing cell values and selections
|
|
223
|
+
// Use the table name as unique ID to prevent collisions between multiple tables
|
|
224
|
+
var cellState = (0, _hooks.useCellState)(name);
|
|
225
|
+
|
|
226
|
+
// ==================== STATE PERSISTENCE ====================
|
|
227
|
+
// Restore persisted state before initializing table
|
|
228
|
+
var _useMemo = (0, _react.useMemo)(function () {
|
|
229
|
+
var _datasource$paginatio;
|
|
230
|
+
// Skip state restoration for Scroll navigation
|
|
231
|
+
if (navigation === "Scroll") {
|
|
232
|
+
return {
|
|
233
|
+
initialPage: 1,
|
|
234
|
+
initialPageSize: pagesize,
|
|
235
|
+
initialActualPageSize: undefined,
|
|
236
|
+
initialSearchState: undefined,
|
|
237
|
+
initialSortState: undefined
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
var persisted = (0, _utils.getTableState)(name, effectiveStateHandler);
|
|
241
|
+
|
|
242
|
+
// Determine the actual page size (original datasource page size)
|
|
243
|
+
var actualPageSize;
|
|
244
|
+
if ((persisted === null || persisted === void 0 ? void 0 : persisted.actualpagesize) !== undefined) {
|
|
245
|
+
// If we have a persisted actualPageSize, use it (it should never change)
|
|
246
|
+
actualPageSize = persisted.actualpagesize;
|
|
247
|
+
} else if (datasource !== null && datasource !== void 0 && (_datasource$paginatio = datasource.pagination) !== null && _datasource$paginatio !== void 0 && _datasource$paginatio.size) {
|
|
248
|
+
// Otherwise, if this is the first load, capture it from datasource
|
|
249
|
+
actualPageSize = datasource.pagination.size;
|
|
250
|
+
} else if (datasource !== null && datasource !== void 0 && datasource.maxResults) {
|
|
251
|
+
// Fallback to maxResults if available
|
|
252
|
+
actualPageSize = datasource.maxResults;
|
|
253
|
+
}
|
|
254
|
+
if (persisted) {
|
|
255
|
+
// Check if there's an active filter/search state
|
|
256
|
+
var hasActiveFilter = persisted.search && persisted.search.length > 0;
|
|
257
|
+
|
|
258
|
+
// If there's an active filter, don't restore pagination - start from page 1
|
|
259
|
+
// The server will return new filtered data, so old pagination is invalid
|
|
260
|
+
var restoredPage = hasActiveFilter ? 1 : persisted.pagination || 1;
|
|
261
|
+
|
|
262
|
+
// Get persisted page size
|
|
263
|
+
var persistedPageSize = persisted.pagesize || pagesize;
|
|
264
|
+
|
|
265
|
+
// Set datasource maxResults if we have a persisted pageSize and datasource
|
|
266
|
+
if (persisted.pagesize && isServerSidePagination && datasource && datasource.maxResults !== undefined) {
|
|
267
|
+
datasource.maxResults = persistedPageSize;
|
|
268
|
+
}
|
|
269
|
+
return {
|
|
270
|
+
initialPage: restoredPage,
|
|
271
|
+
initialPageSize: persistedPageSize,
|
|
272
|
+
initialActualPageSize: actualPageSize,
|
|
273
|
+
initialSearchState: persisted.search || undefined,
|
|
274
|
+
initialSortState: persisted.sort || undefined
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
return {
|
|
278
|
+
initialPage: 1,
|
|
279
|
+
initialPageSize: pagesize,
|
|
280
|
+
initialActualPageSize: actualPageSize,
|
|
281
|
+
initialSearchState: undefined,
|
|
282
|
+
initialSortState: undefined
|
|
283
|
+
};
|
|
284
|
+
}, [name, effectiveStateHandler, pagesize, isServerSidePagination, datasource, navigation]),
|
|
285
|
+
initialPage = _useMemo.initialPage,
|
|
286
|
+
initialPageSize = _useMemo.initialPageSize,
|
|
287
|
+
initialActualPageSize = _useMemo.initialActualPageSize,
|
|
288
|
+
initialSearchState = _useMemo.initialSearchState,
|
|
289
|
+
initialSortState = _useMemo.initialSortState;
|
|
290
|
+
|
|
291
|
+
// Create a ref to hold the table instance
|
|
292
|
+
var tableRef = _react["default"].useRef(null);
|
|
293
|
+
|
|
294
|
+
// Track previous page index to detect actual page changes
|
|
295
|
+
var prevPageIndexRef = (0, _react.useRef)(-1);
|
|
296
|
+
|
|
297
|
+
// Use row selection hook
|
|
298
|
+
var _useRowSelection = (0, _hooks.useRowSelection)({
|
|
299
|
+
radioselect: radioselect,
|
|
300
|
+
multiselect: multiselect,
|
|
301
|
+
gridfirstrowselect: gridfirstrowselect,
|
|
302
|
+
internalDataset: internalDataset,
|
|
303
|
+
cellState: cellState,
|
|
304
|
+
name: name,
|
|
305
|
+
statehandler: effectiveStateHandler,
|
|
306
|
+
initialActualPageSize: initialActualPageSize,
|
|
307
|
+
getTableState: function getTableState() {
|
|
308
|
+
return tableRef.current ? {
|
|
309
|
+
currentPage: tableRef.current.getState().pagination.pageIndex + 1,
|
|
310
|
+
currentPageSize: tableRef.current.getState().pagination.pageSize
|
|
311
|
+
} : {
|
|
312
|
+
currentPage: 1,
|
|
313
|
+
currentPageSize: pagesize
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
}),
|
|
317
|
+
selectedRowId = _useRowSelection.selectedRowId,
|
|
318
|
+
selectedRowIds = _useRowSelection.selectedRowIds,
|
|
319
|
+
useMultiSelect = _useRowSelection.useMultiSelect,
|
|
320
|
+
useRadioSelect = _useRowSelection.useRadioSelect,
|
|
321
|
+
handleRadioSelection = _useRowSelection.handleRadioSelection,
|
|
322
|
+
handleMultiSelection = _useRowSelection.handleMultiSelection,
|
|
323
|
+
handleSelectAll = _useRowSelection.handleSelectAll,
|
|
324
|
+
handleRowSelectionClick = _useRowSelection.handleRowSelectionClick,
|
|
325
|
+
isRowSelected = _useRowSelection.isRowSelected;
|
|
326
|
+
|
|
327
|
+
// Use table state hook
|
|
328
|
+
var _useTableState = (0, _hooks.useTableState)({
|
|
329
|
+
editMode: editmode,
|
|
330
|
+
radioselect: radioselect,
|
|
331
|
+
multiselect: multiselect
|
|
332
|
+
}),
|
|
333
|
+
activeRowIds = _useTableState.activeRowIds,
|
|
334
|
+
setActiveRow = _useTableState.setActiveRow,
|
|
335
|
+
handleRowActiveClick = _useTableState.handleRowActiveClick,
|
|
336
|
+
isRowActive = _useTableState.isRowActive;
|
|
337
|
+
|
|
338
|
+
// Use dynamic columns hook to generate columns from data when no children are provided
|
|
339
|
+
var _useDynamicColumns = (0, _hooks.useDynamicColumns)({
|
|
340
|
+
dataset: internalDataset,
|
|
341
|
+
children: children,
|
|
342
|
+
listener: listener
|
|
343
|
+
}),
|
|
344
|
+
dynamicColumns = _useDynamicColumns.dynamicColumns,
|
|
345
|
+
isDynamicTable = _useDynamicColumns.isDynamicTable;
|
|
346
|
+
|
|
347
|
+
// Parse table structure from children using utilities
|
|
348
|
+
var _useMemo2 = (0, _react.useMemo)(function () {
|
|
349
|
+
var allTableActions = (0, _utils.parseTableActions)(children);
|
|
350
|
+
|
|
351
|
+
// Filter out addNewRow action when editmode is 'none' or 'quickedit'
|
|
352
|
+
var filteredActions = editmode === "none" || editmode === "quickedit" ? allTableActions.filter(function (action) {
|
|
353
|
+
return action.key !== "addNewRow";
|
|
354
|
+
}) : allTableActions;
|
|
355
|
+
|
|
356
|
+
// Split actions based on position - handle comma-separated positions
|
|
357
|
+
var headerActions = filteredActions.filter(function (action) {
|
|
358
|
+
var position = action.position || "footer";
|
|
359
|
+
return position === "header" || position.includes("header");
|
|
360
|
+
});
|
|
361
|
+
var footerActions = filteredActions.filter(function (action) {
|
|
362
|
+
var position = action.position || "footer";
|
|
363
|
+
return position === "footer" || position.includes("footer") || !action.position;
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
// Get static columns from children
|
|
367
|
+
var staticColumns = (0, _utils.parseTableColumns)(children);
|
|
368
|
+
|
|
369
|
+
// Use dynamic columns if no static columns are provided
|
|
370
|
+
// For dynamic tables, prefer dynamic columns even if they're empty initially (data loading)
|
|
371
|
+
var finalColumns = staticColumns.length > 0 ? staticColumns : isDynamicTable ? dynamicColumns : staticColumns;
|
|
372
|
+
return {
|
|
373
|
+
wmTableColumns: finalColumns,
|
|
374
|
+
rowActions: (0, _utils.parseTableRowActions)(children),
|
|
375
|
+
tableActions: filteredActions,
|
|
376
|
+
headerActions: headerActions,
|
|
377
|
+
footerActions: footerActions,
|
|
378
|
+
rowExpansionConfig: (0, _utils.parseTableRowExpansion)(children)
|
|
379
|
+
};
|
|
380
|
+
}, [children, editmode, dynamicColumns]),
|
|
381
|
+
wmTableColumns = _useMemo2.wmTableColumns,
|
|
382
|
+
rowActions = _useMemo2.rowActions,
|
|
383
|
+
headerActions = _useMemo2.headerActions,
|
|
384
|
+
footerActions = _useMemo2.footerActions,
|
|
385
|
+
rowExpansionConfig = _useMemo2.rowExpansionConfig;
|
|
386
|
+
|
|
387
|
+
// Use unified table edit functionality
|
|
388
|
+
var _useTableEdit = (0, _hooks.useTableEdit)({
|
|
389
|
+
editMode: editmode,
|
|
390
|
+
internalDataset: internalDataset,
|
|
391
|
+
setInternalDataset: setInternalDataset,
|
|
392
|
+
wmTableColumns: wmTableColumns,
|
|
393
|
+
cellState: cellState,
|
|
394
|
+
renderFormWidget: renderFormWidget,
|
|
395
|
+
listener: listener,
|
|
396
|
+
onRowUpdate: onRowUpdate,
|
|
397
|
+
onRowDelete: onRowDelete,
|
|
398
|
+
onNewRowAdded: function onNewRowAdded(newRecord) {
|
|
399
|
+
// Use shared navigation utility function
|
|
400
|
+
(0, _utils.handleNewRowNavigation)(tableRef, newRecord, internalDataset);
|
|
401
|
+
},
|
|
402
|
+
showrowindex: showrowindex,
|
|
403
|
+
radioselect: radioselect,
|
|
404
|
+
multiselect: multiselect,
|
|
405
|
+
rowActions: rowActions,
|
|
406
|
+
formposition: formposition,
|
|
407
|
+
insertmessage: insertmessage,
|
|
408
|
+
updatemessage: updatemessage,
|
|
409
|
+
errormessage: errormessage,
|
|
410
|
+
showToast: showToast,
|
|
411
|
+
hasRowExpansion: rowExpansionConfig ? rowExpansionConfig.show : false,
|
|
412
|
+
expansionPosition: rowExpansionConfig ? parseInt(String(rowExpansionConfig.position || "0"), 10) : 0,
|
|
413
|
+
datasource: datasource,
|
|
414
|
+
binddataset: binddataset,
|
|
415
|
+
onSuccess: onSuccess,
|
|
416
|
+
onError: onError,
|
|
417
|
+
onRowinsert: onRowinsert,
|
|
418
|
+
onRowupdate: onRowupdate,
|
|
419
|
+
onRowdelete: onRowdelete,
|
|
420
|
+
tableRef: tableRef,
|
|
421
|
+
isServerSidePagination: isServerSidePagination
|
|
422
|
+
}),
|
|
423
|
+
editingRowId = _useTableEdit.editingRowId,
|
|
424
|
+
isRowEditing = _useTableEdit.isRowEditing,
|
|
425
|
+
startEditing = _useTableEdit.startEditing,
|
|
426
|
+
cancelEditing = _useTableEdit.cancelEditing,
|
|
427
|
+
saveEditing = _useTableEdit.saveEditing,
|
|
428
|
+
renderEditableCell = _useTableEdit.renderEditableCell,
|
|
429
|
+
isAddingNewRow = _useTableEdit.isAddingNewRow,
|
|
430
|
+
handleAddNewRowClick = _useTableEdit.handleAddNewRowClick,
|
|
431
|
+
renderAddNewRow = _useTableEdit.renderAddNewRow,
|
|
432
|
+
handleTableEditRowClick = _useTableEdit.handleRowClick,
|
|
433
|
+
handleTableEditKeyDown = _useTableEdit.handleKeyDown;
|
|
434
|
+
|
|
435
|
+
// Use the row handlers hook
|
|
436
|
+
var _useRowHandlers = (0, _hooks.useRowHandlers)({
|
|
437
|
+
editingRowId: editingRowId,
|
|
438
|
+
isAddingNewRow: isAddingNewRow,
|
|
439
|
+
handleRowSelectionClick: handleRowSelectionClick,
|
|
440
|
+
handleTableEditRowClick: handleTableEditRowClick,
|
|
441
|
+
handleRowActiveClick: handleRowActiveClick,
|
|
442
|
+
onRowclick: onRowclick
|
|
443
|
+
}),
|
|
444
|
+
handleRowClick = _useRowHandlers.handleRowClick;
|
|
445
|
+
|
|
446
|
+
// Track sorting and column sizing states
|
|
447
|
+
var _useState3 = (0, _react.useState)(function () {
|
|
448
|
+
// Convert initialSortState to TanStack Table sorting format
|
|
449
|
+
if (initialSortState) {
|
|
450
|
+
return [{
|
|
451
|
+
id: initialSortState.field,
|
|
452
|
+
desc: initialSortState.direction === "desc"
|
|
453
|
+
}];
|
|
454
|
+
}
|
|
455
|
+
return [];
|
|
456
|
+
}),
|
|
457
|
+
sorting = _useState3[0],
|
|
458
|
+
setSorting = _useState3[1];
|
|
459
|
+
var _useState4 = (0, _react.useState)({}),
|
|
460
|
+
columnSizing = _useState4[0],
|
|
461
|
+
setColumnSizing = _useState4[1];
|
|
462
|
+
var _useState5 = (0, _react.useState)(false),
|
|
463
|
+
isResizing = _useState5[0],
|
|
464
|
+
setIsResizing = _useState5[1];
|
|
465
|
+
|
|
466
|
+
// Custom sorting change handler that resets page to 1 when sorting changes
|
|
467
|
+
var handleSortingChange = (0, _react.useCallback)(function (updaterOrValue) {
|
|
468
|
+
setSorting(updaterOrValue);
|
|
469
|
+
// Reset to first page when sorting changes
|
|
470
|
+
if (tableRef.current) {
|
|
471
|
+
tableRef.current.setPageIndex(0);
|
|
472
|
+
}
|
|
473
|
+
}, []);
|
|
474
|
+
|
|
475
|
+
// Use row expansion hook
|
|
476
|
+
var _useRowExpansion = (0, _hooks.useRowExpansion)({
|
|
477
|
+
rowExpansionConfig: rowExpansionConfig,
|
|
478
|
+
internalDataset: internalDataset
|
|
479
|
+
}),
|
|
480
|
+
expandedRows = _useRowExpansion.expandedRows,
|
|
481
|
+
toggleRowExpansion = _useRowExpansion.toggleRowExpansion,
|
|
482
|
+
isRowExpanded = _useRowExpansion.isRowExpanded;
|
|
483
|
+
|
|
484
|
+
// Use table columns hook to get column definitions
|
|
485
|
+
var _useTableColumns = (0, _hooks.useTableColumns)({
|
|
486
|
+
wmTableColumns: wmTableColumns,
|
|
487
|
+
rowActions: rowActions,
|
|
488
|
+
listener: listener,
|
|
489
|
+
deleteRecord: function deleteRecord(rowData) {
|
|
490
|
+
return _deleteRecord(rowData, tableRef.current);
|
|
491
|
+
},
|
|
492
|
+
showrowindex: showrowindex,
|
|
493
|
+
editmode: editmode,
|
|
494
|
+
renderEditableCell: renderEditableCell,
|
|
495
|
+
isRowEditing: isRowEditing,
|
|
496
|
+
startEditing: startEditing,
|
|
497
|
+
cancelEditing: cancelEditing,
|
|
498
|
+
saveEditing: saveEditing,
|
|
499
|
+
editingRowId: editingRowId,
|
|
500
|
+
cellState: cellState,
|
|
501
|
+
isResizing: isResizing
|
|
502
|
+
}),
|
|
503
|
+
baseColumns = _useTableColumns.columns;
|
|
504
|
+
|
|
505
|
+
// Add radio select or multiselect column if enabled and memoize with stable references
|
|
506
|
+
var columns = (0, _react.useMemo)(function () {
|
|
507
|
+
var selectionColumn = (0, _buildSelectionColumns.buildSelectionColumns)({
|
|
508
|
+
useRadioSelect: useRadioSelect,
|
|
509
|
+
useMultiSelect: useMultiSelect,
|
|
510
|
+
selectedRowId: selectedRowId,
|
|
511
|
+
// Keep these for interface compatibility but they're not used in column structure
|
|
512
|
+
selectedRowIds: selectedRowIds,
|
|
513
|
+
handleRadioSelection: handleRadioSelection,
|
|
514
|
+
handleMultiSelection: handleMultiSelection,
|
|
515
|
+
handleSelectAll: handleSelectAll,
|
|
516
|
+
internalDataset: internalDataset,
|
|
517
|
+
radioselecttitle: radioselecttitle,
|
|
518
|
+
radioselectarialabel: radioselectarialabel,
|
|
519
|
+
multiselecttitle: multiselecttitle,
|
|
520
|
+
multiselectarialabel: multiselectarialabel,
|
|
521
|
+
tableName: name
|
|
522
|
+
});
|
|
523
|
+
if (selectionColumn) {
|
|
524
|
+
return [selectionColumn].concat((0, _toConsumableArray2["default"])(baseColumns));
|
|
525
|
+
}
|
|
526
|
+
return baseColumns;
|
|
527
|
+
}, [baseColumns, useRadioSelect, useMultiSelect, handleRadioSelection, handleMultiSelection, handleSelectAll, radioselecttitle, radioselectarialabel, multiselecttitle, multiselectarialabel, name]);
|
|
528
|
+
|
|
529
|
+
//column proxy changes
|
|
530
|
+
var columnsStateRef = (0, _react.useRef)(columns);
|
|
531
|
+
var _useState6 = (0, _react.useState)(0),
|
|
532
|
+
columnsVersion = _useState6[0],
|
|
533
|
+
setColumnsVersion = _useState6[1];
|
|
534
|
+
var _useState7 = (0, _react.useState)({}),
|
|
535
|
+
columnOverrides = _useState7[0],
|
|
536
|
+
setColumnOverrides = _useState7[1];
|
|
537
|
+
var applyOverride = (0, _react.useCallback)(function (index, key, value) {
|
|
538
|
+
setColumnOverrides(function (prev) {
|
|
539
|
+
return _objectSpread(_objectSpread({}, prev), {}, (0, _defineProperty2["default"])({}, index, _objectSpread(_objectSpread({}, prev[index] || {}), {}, (0, _defineProperty2["default"])({}, key, value))));
|
|
540
|
+
});
|
|
541
|
+
}, []);
|
|
542
|
+
var columnsProxy = (0, _react.useMemo)(function () {
|
|
543
|
+
return (0, _columnProxy.createColumnsProxy)(wmTableColumns, applyOverride, setColumnsVersion);
|
|
544
|
+
}, [wmTableColumns, applyOverride, setColumnsVersion]);
|
|
545
|
+
columnsStateRef.current = columns;
|
|
546
|
+
var columnsForTable = (0, _react.useMemo)(function () {
|
|
547
|
+
var base = columnsStateRef.current || [];
|
|
548
|
+
return base.map(function (col, idx) {
|
|
549
|
+
return _objectSpread(_objectSpread({}, col), columnOverrides[idx] || {});
|
|
550
|
+
});
|
|
551
|
+
}, [columns, columnOverrides, columnsVersion, editingRowId]);
|
|
552
|
+
|
|
553
|
+
// Use filter hook for filtering functionality
|
|
554
|
+
var _useTableFilter = (0, _hooks.useTableFilter)({
|
|
555
|
+
filterMode: filtermode,
|
|
556
|
+
columns: columnsForTable,
|
|
557
|
+
dataset: navigation === "Scroll" && scrollAccumulatedData.length > 0 ? scrollAccumulatedData : internalDataset,
|
|
558
|
+
initialSearchState: initialSearchState
|
|
559
|
+
}),
|
|
560
|
+
globalFilter = _useTableFilter.globalFilter,
|
|
561
|
+
setGlobalFilterOriginal = _useTableFilter.setGlobalFilter,
|
|
562
|
+
globalSearchColumn = _useTableFilter.globalSearchColumn,
|
|
563
|
+
setGlobalSearchColumn = _useTableFilter.setGlobalSearchColumn,
|
|
564
|
+
columnFilters = _useTableFilter.columnFilters,
|
|
565
|
+
setColumnFilterOriginal = _useTableFilter.setColumnFilter,
|
|
566
|
+
filteredData = _useTableFilter.filteredData,
|
|
567
|
+
getFilterFields = _useTableFilter.getFilterFields,
|
|
568
|
+
transformFilterFields = _useTableFilter.transformFilterFields;
|
|
569
|
+
|
|
570
|
+
// Wrap filter setters to reset page when filters change
|
|
571
|
+
var setGlobalFilter = (0, _react.useCallback)(function (value) {
|
|
572
|
+
setGlobalFilterOriginal(value);
|
|
573
|
+
// Reset to first page when filter changes
|
|
574
|
+
if (tableRef.current) {
|
|
575
|
+
tableRef.current.setPageIndex(0);
|
|
576
|
+
}
|
|
577
|
+
}, [setGlobalFilterOriginal]);
|
|
578
|
+
var setColumnFilter = (0, _react.useCallback)(function (columnId, value, matchMode) {
|
|
579
|
+
setColumnFilterOriginal(columnId, value, matchMode);
|
|
580
|
+
// Reset to first page when filter changes
|
|
581
|
+
if (tableRef.current) {
|
|
582
|
+
tableRef.current.setPageIndex(0);
|
|
583
|
+
}
|
|
584
|
+
}, [setColumnFilterOriginal]);
|
|
585
|
+
|
|
586
|
+
// Use refs to track resizing state and debounce timer
|
|
587
|
+
var resizeTimeoutRef = (0, _react.useRef)(null);
|
|
588
|
+
|
|
589
|
+
// Memoize the column sizing change handler with smart resizing detection
|
|
590
|
+
var handleColumnSizingChange = (0, _react.useCallback)(function (updaterOrValue) {
|
|
591
|
+
// Only update resizing state if it's not already true
|
|
592
|
+
setIsResizing(function (prev) {
|
|
593
|
+
if (!prev) return true;
|
|
594
|
+
return prev;
|
|
595
|
+
});
|
|
596
|
+
setColumnSizing(updaterOrValue);
|
|
597
|
+
|
|
598
|
+
// Clear any existing timeout
|
|
599
|
+
if (resizeTimeoutRef.current) {
|
|
600
|
+
clearTimeout(resizeTimeoutRef.current);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
// Set a debounced timeout to detect when resizing has stopped
|
|
604
|
+
resizeTimeoutRef.current = setTimeout(function () {
|
|
605
|
+
setIsResizing(false);
|
|
606
|
+
}, 150); // 150ms delay to detect when user stops resizing
|
|
607
|
+
}, []);
|
|
608
|
+
|
|
609
|
+
// Create custom row selection state for TanStack Table
|
|
610
|
+
var rowSelection = (0, _react.useMemo)(function () {
|
|
611
|
+
var selection = {};
|
|
612
|
+
if (useMultiSelect) {
|
|
613
|
+
selectedRowIds.forEach(function (id) {
|
|
614
|
+
selection[id] = true;
|
|
615
|
+
});
|
|
616
|
+
} else if (useRadioSelect && selectedRowId) {
|
|
617
|
+
selection[selectedRowId] = true;
|
|
618
|
+
}
|
|
619
|
+
return selection;
|
|
620
|
+
}, [useMultiSelect, useRadioSelect, selectedRowIds, selectedRowId]);
|
|
621
|
+
|
|
622
|
+
// Determine if we're using server-side sorting (same as server-side pagination)
|
|
623
|
+
var isServerSideSorting = isServerSidePagination;
|
|
624
|
+
|
|
625
|
+
// Use accumulated data for Scroll navigation, otherwise use normal dataset
|
|
626
|
+
var tableData = (0, _react.useMemo)(function () {
|
|
627
|
+
if (navigation === "Scroll" && scrollAccumulatedData.length > 0) {
|
|
628
|
+
return filtermode ? filteredData : scrollAccumulatedData;
|
|
629
|
+
}
|
|
630
|
+
return filtermode ? filteredData : internalDataset;
|
|
631
|
+
}, [navigation, scrollAccumulatedData, filteredData, internalDataset, filtermode]);
|
|
632
|
+
|
|
633
|
+
// Create the table with columns
|
|
634
|
+
var table = (0, _reactTable.useReactTable)({
|
|
635
|
+
data: tableData,
|
|
636
|
+
columns: columnsForTable,
|
|
637
|
+
state: {
|
|
638
|
+
sorting: sorting,
|
|
639
|
+
columnSizing: columnSizing,
|
|
640
|
+
rowSelection: rowSelection // Add row selection state
|
|
641
|
+
},
|
|
642
|
+
onSortingChange: handleSortingChange,
|
|
643
|
+
onColumnSizingChange: handleColumnSizingChange,
|
|
644
|
+
getCoreRowModel: (0, _reactTable.getCoreRowModel)(),
|
|
645
|
+
// Only use pagination model for client-side pagination
|
|
646
|
+
getPaginationRowModel: isServerSidePagination ? undefined : (0, _reactTable.getPaginationRowModel)(),
|
|
647
|
+
// Use sorted row model only for client-side sorting
|
|
648
|
+
getSortedRowModel: isServerSideSorting ? undefined : (0, _reactTable.getSortedRowModel)(),
|
|
649
|
+
enableSorting: enablesort,
|
|
650
|
+
enableSortingRemoval: false,
|
|
651
|
+
autoResetPageIndex: false,
|
|
652
|
+
enableColumnResizing: true,
|
|
653
|
+
columnResizeMode: "onChange",
|
|
654
|
+
// Keep onChange for real-time visual feedback
|
|
655
|
+
enableRowSelection: true,
|
|
656
|
+
// Enable row selection
|
|
657
|
+
// Use manual pagination and sorting for server-side operations
|
|
658
|
+
manualPagination: isServerSidePagination,
|
|
659
|
+
manualSorting: isServerSideSorting,
|
|
660
|
+
pageCount: isServerSidePagination && datasource !== null && datasource !== void 0 && (_datasource$paginatio2 = datasource.pagination) !== null && _datasource$paginatio2 !== void 0 && _datasource$paginatio2.totalPages ? datasource.pagination.totalPages : undefined,
|
|
661
|
+
initialState: {
|
|
662
|
+
pagination: {
|
|
663
|
+
pageSize: initialPageSize,
|
|
664
|
+
pageIndex: initialPage - 1 // Convert to 0-based index
|
|
665
|
+
}
|
|
666
|
+
},
|
|
667
|
+
getRowId: function getRowId(row) {
|
|
668
|
+
return row._wmTableRowId || String(row.id) || (0, _lodashEs.uniqueId)("row_");
|
|
669
|
+
}
|
|
670
|
+
});
|
|
671
|
+
|
|
672
|
+
// Update the table ref
|
|
673
|
+
tableRef.current = table;
|
|
674
|
+
|
|
675
|
+
// Memoize filter fields to prevent unnecessary re-renders in useServerSideSorting
|
|
676
|
+
var memoizedFilterFields = (0, _react.useMemo)(function () {
|
|
677
|
+
if (!filtermode) return {};
|
|
678
|
+
var searchObj = filtermode === "search" ? [{
|
|
679
|
+
field: globalSearchColumn,
|
|
680
|
+
value: globalFilter,
|
|
681
|
+
matchMode: "anywhereignorecase",
|
|
682
|
+
type: "string"
|
|
683
|
+
}] : transformFilterFields(columnFilters);
|
|
684
|
+
return getFilterFields(searchObj);
|
|
685
|
+
}, [filtermode, globalSearchColumn, globalFilter, columnFilters, getFilterFields, transformFilterFields]);
|
|
686
|
+
|
|
687
|
+
// Memoize logical operator
|
|
688
|
+
var memoizedLogicalOp = (0, _react.useMemo)(function () {
|
|
689
|
+
return filtermode === "search" && !globalSearchColumn ? "OR" : "AND";
|
|
690
|
+
}, [filtermode, globalSearchColumn]);
|
|
691
|
+
|
|
692
|
+
// Use server-side sorting hook to handle data fetching
|
|
693
|
+
(0, _hooks.useServerSideSorting)({
|
|
694
|
+
datasource: datasource,
|
|
695
|
+
sorting: sorting,
|
|
696
|
+
setInternalDataset: setInternalDataset,
|
|
697
|
+
showToast: showToast,
|
|
698
|
+
isServerSidePagination: isServerSidePagination,
|
|
699
|
+
pageIndex: table.getState().pagination.pageIndex,
|
|
700
|
+
onError: onError,
|
|
701
|
+
setLoading: setLoading,
|
|
702
|
+
filterFields: memoizedFilterFields,
|
|
703
|
+
logicalOp: memoizedLogicalOp
|
|
704
|
+
});
|
|
705
|
+
|
|
706
|
+
// Panel structure management
|
|
707
|
+
var _usePanelStructure = (0, _hooks.usePanelStructure)({
|
|
708
|
+
title: title,
|
|
709
|
+
subheading: subheading,
|
|
710
|
+
iconclass: iconclass,
|
|
711
|
+
exportOptions: exportOptions,
|
|
712
|
+
headerActions: headerActions,
|
|
713
|
+
footerActions: footerActions,
|
|
714
|
+
shownavigation: shownavigation,
|
|
715
|
+
onDemandLoad: onDemandLoad,
|
|
716
|
+
internalDataset: internalDataset,
|
|
717
|
+
pagesize: pagesize,
|
|
718
|
+
allowpagesizechange: allowpagesizechange,
|
|
719
|
+
datasource: datasource
|
|
720
|
+
}),
|
|
721
|
+
showPanelHeading = _usePanelStructure.showPanelHeading,
|
|
722
|
+
showPagination = _usePanelStructure.showPagination;
|
|
723
|
+
|
|
724
|
+
// Update grid edit mode (includes inline editing and add new row)
|
|
725
|
+
var isGridEditModeComplete = isAddingNewRow || editingRowId !== null;
|
|
726
|
+
|
|
727
|
+
// Generate spacing-related classes based on spacing prop
|
|
728
|
+
var spacingClasses = (0, _utils.getSpacingClasses)(spacing);
|
|
729
|
+
|
|
730
|
+
// ==================== STATE MANAGEMENT ====================
|
|
731
|
+
// Prepare filter data based on filter mode - always in array format
|
|
732
|
+
var filterDataForState = (0, _react.useMemo)(function () {
|
|
733
|
+
if (!filtermode) return undefined;
|
|
734
|
+
if (filtermode === "search") {
|
|
735
|
+
if (globalFilter || globalSearchColumn) {
|
|
736
|
+
// Find column type for the selected search column
|
|
737
|
+
var columnType = globalSearchColumn ? function (_col$meta, _col$meta2) {
|
|
738
|
+
var col = (0, _lodashEs.find)(columnsForTable, function (c) {
|
|
739
|
+
var column = c;
|
|
740
|
+
return column.accessorKey === globalSearchColumn || column.id === globalSearchColumn;
|
|
741
|
+
});
|
|
742
|
+
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";
|
|
743
|
+
}() : "string";
|
|
744
|
+
return [{
|
|
745
|
+
field: globalSearchColumn || "",
|
|
746
|
+
value: globalFilter,
|
|
747
|
+
matchMode: "anywhereignorecase",
|
|
748
|
+
type: columnType
|
|
749
|
+
}];
|
|
750
|
+
}
|
|
751
|
+
} else if (filtermode === "multicolumn") {
|
|
752
|
+
var activeFilters = Object.entries(columnFilters).filter(function (_ref2) {
|
|
753
|
+
var _ref3 = (0, _slicedToArray2["default"])(_ref2, 2),
|
|
754
|
+
_ = _ref3[0],
|
|
755
|
+
filter = _ref3[1];
|
|
756
|
+
return filter.value;
|
|
757
|
+
}).map(function (_ref4) {
|
|
758
|
+
var _ref5 = (0, _slicedToArray2["default"])(_ref4, 2),
|
|
759
|
+
field = _ref5[0],
|
|
760
|
+
filter = _ref5[1];
|
|
761
|
+
// Find column type for each field
|
|
762
|
+
var columnType = function (_col$meta3, _col$meta4) {
|
|
763
|
+
var col = (0, _lodashEs.find)(columnsForTable, function (c) {
|
|
764
|
+
var column = c;
|
|
765
|
+
return column.accessorKey === field || column.id === field;
|
|
766
|
+
});
|
|
767
|
+
return (col === null || col === void 0 || (_col$meta3 = col.meta) === null || _col$meta3 === void 0 ? void 0 : _col$meta3.type) || (col === null || col === void 0 || (_col$meta4 = col.meta) === null || _col$meta4 === void 0 ? void 0 : _col$meta4.editinputtype) || "string";
|
|
768
|
+
}();
|
|
769
|
+
return {
|
|
770
|
+
field: field,
|
|
771
|
+
value: filter.value,
|
|
772
|
+
matchMode: filter.matchMode,
|
|
773
|
+
type: columnType
|
|
774
|
+
};
|
|
775
|
+
});
|
|
776
|
+
return activeFilters.length > 0 ? activeFilters : undefined;
|
|
777
|
+
}
|
|
778
|
+
return undefined;
|
|
779
|
+
}, [filtermode, globalFilter, globalSearchColumn, columnFilters, columnsForTable]);
|
|
780
|
+
|
|
781
|
+
// Convert TanStack Table sorting state to our format
|
|
782
|
+
var sortDataForState = (0, _react.useMemo)(function () {
|
|
783
|
+
if (sorting.length > 0) {
|
|
784
|
+
var firstSort = sorting[0]; // We only support single column sorting for state persistence
|
|
785
|
+
return {
|
|
786
|
+
field: firstSort.id,
|
|
787
|
+
direction: firstSort.desc ? "desc" : "asc"
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
return undefined;
|
|
791
|
+
}, [sorting]);
|
|
792
|
+
var stateManager = (0, _hooks.useTableStateManager)({
|
|
793
|
+
name: name,
|
|
794
|
+
storage: effectiveStateHandler,
|
|
795
|
+
currentPage: table.getState().pagination.pageIndex + 1,
|
|
796
|
+
currentPageSize: table.getState().pagination.pageSize,
|
|
797
|
+
selectedRowId: selectedRowId,
|
|
798
|
+
selectedRowIds: selectedRowIds,
|
|
799
|
+
internalDataset: internalDataset,
|
|
800
|
+
initialActualPageSize: initialActualPageSize,
|
|
801
|
+
datasource: datasource,
|
|
802
|
+
multiselect: multiselect,
|
|
803
|
+
filterData: filterDataForState,
|
|
804
|
+
sortData: sortDataForState,
|
|
805
|
+
navigation: navigation,
|
|
806
|
+
isStateConfigured: effectiveStateHandler !== undefined && effectiveStateHandler !== "none",
|
|
807
|
+
defaultPageSize: pagesize,
|
|
808
|
+
// Original page size from props
|
|
809
|
+
initialSortState: initialSortState,
|
|
810
|
+
initialFilterState: initialSearchState
|
|
811
|
+
});
|
|
812
|
+
|
|
813
|
+
// Use pagination state hook
|
|
814
|
+
var _usePaginationState = (0, _hooks.usePaginationState)({
|
|
815
|
+
table: table,
|
|
816
|
+
editmode: editmode,
|
|
817
|
+
internalDataset: internalDataset,
|
|
818
|
+
isAddingNewRow: isAddingNewRow,
|
|
819
|
+
cancelEditing: cancelEditing,
|
|
820
|
+
datasource: datasource,
|
|
821
|
+
isServerSidePagination: isServerSidePagination
|
|
822
|
+
}),
|
|
823
|
+
handlePaginationChange = _usePaginationState.handlePaginationChange,
|
|
824
|
+
handlePageSizeChangeBase = _usePaginationState.handlePageSizeChange;
|
|
825
|
+
|
|
826
|
+
// Enhanced page size change handler with state persistence
|
|
827
|
+
var handlePageSizeChange = (0, _react.useCallback)(function (newPageSize) {
|
|
828
|
+
// Call base handler
|
|
829
|
+
handlePageSizeChangeBase(newPageSize);
|
|
830
|
+
|
|
831
|
+
// Skip state persistence for Scroll navigation
|
|
832
|
+
if (navigation !== "Scroll") {
|
|
833
|
+
// Get current persisted state to access all selected items across pages
|
|
834
|
+
var currentPersistedState = (0, _utils.getTableState)(name, effectiveStateHandler);
|
|
835
|
+
|
|
836
|
+
// Build the state for page size change
|
|
837
|
+
var newState = stateManager.getStateForPageSizeChange(newPageSize, currentPersistedState === null || currentPersistedState === void 0 ? void 0 : currentPersistedState.selectedItem, table.getState().pagination.pageSize // Pass the old page size
|
|
838
|
+
);
|
|
839
|
+
|
|
840
|
+
// Clear the existing state first to avoid merge issues with setWidgetState
|
|
841
|
+
(0, _utils.clearTableState)(name, effectiveStateHandler);
|
|
842
|
+
|
|
843
|
+
// Only save if there's something to save (not in default state)
|
|
844
|
+
if (Object.keys(newState).length > 0) {
|
|
845
|
+
// If pagesize equals default, remove it from the state
|
|
846
|
+
if (newPageSize === pagesize) {
|
|
847
|
+
delete newState.pagesize;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
// Only save if there are still properties after removing default pagesize
|
|
851
|
+
if (Object.keys(newState).length > 0) {
|
|
852
|
+
(0, _utils.saveTableState)(name, effectiveStateHandler, newState);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
}, [handlePageSizeChangeBase, name, effectiveStateHandler, stateManager, pagesize, table, navigation]);
|
|
857
|
+
|
|
858
|
+
// Call data render callbacks for dynamic tables or when data changes
|
|
859
|
+
(0, _react.useEffect)(function () {
|
|
860
|
+
// For dynamic tables, call callbacks when we have data
|
|
861
|
+
// For static tables, call callbacks when we have both data and columns
|
|
862
|
+
var shouldCallCallbacks = isDynamicTable ? internalDataset.length > 0 : internalDataset.length > 0 && wmTableColumns.length > 0;
|
|
863
|
+
if (shouldCallCallbacks) {
|
|
864
|
+
var currentPageIndex = table.getState().pagination.pageIndex;
|
|
865
|
+
|
|
866
|
+
// Only call callbacks if it's initial render or page actually changed
|
|
867
|
+
var isInitialRender = prevPageIndexRef.current === -1;
|
|
868
|
+
var hasPageChanged = prevPageIndexRef.current !== currentPageIndex;
|
|
869
|
+
if (isInitialRender || hasPageChanged) {
|
|
870
|
+
// Update the tracked page index
|
|
871
|
+
prevPageIndexRef.current = currentPageIndex;
|
|
872
|
+
|
|
873
|
+
// Call onBeforedatarender callback
|
|
874
|
+
if (onBeforedatarender) {
|
|
875
|
+
onBeforedatarender(listener === null || listener === void 0 ? void 0 : listener.Widgets[name],
|
|
876
|
+
// widget reference
|
|
877
|
+
internalDataset,
|
|
878
|
+
// data
|
|
879
|
+
wmTableColumns // columns (including dynamic ones)
|
|
880
|
+
);
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
// Schedule onDatarender callback after rendering is complete
|
|
884
|
+
// Use requestAnimationFrame to ensure DOM is fully painted
|
|
885
|
+
requestAnimationFrame(function () {
|
|
886
|
+
if (onDatarender) {
|
|
887
|
+
onDatarender(listener === null || listener === void 0 ? void 0 : listener.Widgets[name],
|
|
888
|
+
// widget reference to match Angular format
|
|
889
|
+
{
|
|
890
|
+
$data: internalDataset,
|
|
891
|
+
data: internalDataset
|
|
892
|
+
} // match Angular's format with both $data and data
|
|
893
|
+
);
|
|
894
|
+
}
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
}, [internalDataset, wmTableColumns, onBeforedatarender, onDatarender, name, isDynamicTable, table.getState().pagination.pageIndex]);
|
|
899
|
+
|
|
900
|
+
// Use table initialization hook
|
|
901
|
+
(0, _hooks.useTableInitialization)({
|
|
902
|
+
internalDataset: internalDataset,
|
|
903
|
+
wmTableColumns: wmTableColumns,
|
|
904
|
+
cellState: cellState,
|
|
905
|
+
gridfirstrowselect: gridfirstrowselect,
|
|
906
|
+
useRadioSelect: useRadioSelect,
|
|
907
|
+
useMultiSelect: useMultiSelect,
|
|
908
|
+
setActiveRow: setActiveRow,
|
|
909
|
+
selectedRowId: selectedRowId,
|
|
910
|
+
selectedRowIds: selectedRowIds,
|
|
911
|
+
formName: formName,
|
|
912
|
+
editmode: editmode,
|
|
913
|
+
activeRowIds: activeRowIds,
|
|
914
|
+
listener: listener
|
|
915
|
+
});
|
|
916
|
+
|
|
917
|
+
// Use table effects hook for state persistence
|
|
918
|
+
var _useTableEffects = (0, _hooks.useTableEffects)({
|
|
919
|
+
name: name,
|
|
920
|
+
navigation: navigation,
|
|
921
|
+
datasource: datasource,
|
|
922
|
+
internalDataset: internalDataset,
|
|
923
|
+
statehandler: effectiveStateHandler,
|
|
924
|
+
selectedRowId: selectedRowId,
|
|
925
|
+
selectedRowIds: selectedRowIds,
|
|
926
|
+
currentPage: table.getState().pagination.pageIndex + 1,
|
|
927
|
+
// Convert to 1-based
|
|
928
|
+
currentPageSize: table.getState().pagination.pageSize,
|
|
929
|
+
sorting: sorting,
|
|
930
|
+
isGridEditMode: isGridEditModeComplete,
|
|
931
|
+
stateManager: stateManager,
|
|
932
|
+
initialActualPageSize: initialActualPageSize
|
|
933
|
+
}),
|
|
934
|
+
restoredPageNumber = _useTableEffects.restoredPageNumber,
|
|
935
|
+
restoredSelectedIndices = _useTableEffects.restoredSelectedIndices,
|
|
936
|
+
setIsRestoringSelection = _useTableEffects.setIsRestoringSelection;
|
|
937
|
+
|
|
938
|
+
// Apply restored state
|
|
939
|
+
(0, _react.useEffect)(function () {
|
|
940
|
+
if (restoredPageNumber !== null && restoredPageNumber > 1) {
|
|
941
|
+
// Set the restored page (convert to 0-based index)
|
|
942
|
+
table.setPageIndex(restoredPageNumber - 1);
|
|
943
|
+
}
|
|
944
|
+
}, [restoredPageNumber, table]);
|
|
945
|
+
|
|
946
|
+
// Track if we've already restored selection to avoid loops
|
|
947
|
+
var hasRestoredSelectionRef = (0, _react.useRef)(false);
|
|
948
|
+
(0, _react.useEffect)(function () {
|
|
949
|
+
if (restoredSelectedIndices.length > 0 && internalDataset.length > 0 && !hasRestoredSelectionRef.current) {
|
|
950
|
+
// Mark as restored to prevent running again
|
|
951
|
+
hasRestoredSelectionRef.current = true;
|
|
952
|
+
|
|
953
|
+
// Set flag to prevent saving while restoring
|
|
954
|
+
setIsRestoringSelection(true);
|
|
955
|
+
|
|
956
|
+
// Apply restored selections by converting indices to row IDs
|
|
957
|
+
if (useMultiSelect) {
|
|
958
|
+
// For multiselect, set all restored items by index
|
|
959
|
+
var _selectedRowIds = [];
|
|
960
|
+
restoredSelectedIndices.forEach(function (index) {
|
|
961
|
+
if (index >= 0 && index < internalDataset.length) {
|
|
962
|
+
var row = internalDataset[index];
|
|
963
|
+
if (row && row._wmTableRowId) {
|
|
964
|
+
handleMultiSelection(row._wmTableRowId, row, true);
|
|
965
|
+
// Collect all selected row IDs
|
|
966
|
+
_selectedRowIds.push(row._wmTableRowId);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
});
|
|
970
|
+
// Set all selected rows as active
|
|
971
|
+
if (_selectedRowIds.length > 0) {
|
|
972
|
+
setActiveRow(_selectedRowIds);
|
|
973
|
+
}
|
|
974
|
+
} else {
|
|
975
|
+
// For radio select or default mode (single selection), only restore the first selection
|
|
976
|
+
var firstIndex = restoredSelectedIndices[0];
|
|
977
|
+
if (firstIndex >= 0 && firstIndex < internalDataset.length) {
|
|
978
|
+
var row = internalDataset[firstIndex];
|
|
979
|
+
if (row && row._wmTableRowId) {
|
|
980
|
+
handleRadioSelection(row._wmTableRowId, row);
|
|
981
|
+
// Also set as active row for single selection
|
|
982
|
+
setActiveRow(row._wmTableRowId);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
// Reset flag after restoration is complete
|
|
988
|
+
setTimeout(function () {
|
|
989
|
+
setIsRestoringSelection(false);
|
|
990
|
+
}, 0);
|
|
991
|
+
}
|
|
992
|
+
}, [restoredSelectedIndices, internalDataset, useMultiSelect, handleMultiSelection, handleRadioSelection, setIsRestoringSelection]);
|
|
993
|
+
|
|
994
|
+
// Cleanup resize timeout on unmount and when component updates
|
|
995
|
+
(0, _react.useEffect)(function () {
|
|
996
|
+
var currentTimeout = resizeTimeoutRef.current;
|
|
997
|
+
return function () {
|
|
998
|
+
if (currentTimeout) {
|
|
999
|
+
clearTimeout(currentTimeout);
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
}, []);
|
|
1003
|
+
|
|
1004
|
+
// Create wrapper functions for external API
|
|
1005
|
+
var editRow = (0, _react.useCallback)(function (event, widget, row) {
|
|
1006
|
+
if (!row || !row._wmTableRowId) {
|
|
1007
|
+
console.warn("Invalid row data provided to editRow");
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
1010
|
+
startEditing(row, row._wmTableRowId);
|
|
1011
|
+
}, [startEditing]);
|
|
1012
|
+
var deleteRow = (0, _react.useCallback)(function (event, widget, row) {
|
|
1013
|
+
if (!row) {
|
|
1014
|
+
console.warn("Invalid row data provided to deleteRow");
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
_deleteRecord(row, tableRef.current);
|
|
1018
|
+
}, [_deleteRecord]);
|
|
1019
|
+
|
|
1020
|
+
// Refresh table data
|
|
1021
|
+
var refresh = (0, _react.useCallback)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
1022
|
+
var newData,
|
|
1023
|
+
_datasource$paginatio3,
|
|
1024
|
+
currentTable,
|
|
1025
|
+
targetPage,
|
|
1026
|
+
currentPageSize,
|
|
1027
|
+
shouldNavigateToLastPage,
|
|
1028
|
+
totalElements,
|
|
1029
|
+
totalAfterAdd,
|
|
1030
|
+
lastPage,
|
|
1031
|
+
response,
|
|
1032
|
+
dataWithIds,
|
|
1033
|
+
_args = arguments;
|
|
1034
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
1035
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1036
|
+
case 0:
|
|
1037
|
+
newData = _args.length > 0 && _args[0] !== undefined ? _args[0] : false;
|
|
1038
|
+
if (datasource) {
|
|
1039
|
+
_context.next = 4;
|
|
1040
|
+
break;
|
|
1041
|
+
}
|
|
1042
|
+
console.warn("No datasource available for refresh");
|
|
1043
|
+
return _context.abrupt("return");
|
|
1044
|
+
case 4:
|
|
1045
|
+
_context.prev = 4;
|
|
1046
|
+
// Use tableRef.current to access the latest table instance
|
|
1047
|
+
currentTable = tableRef.current;
|
|
1048
|
+
if (currentTable) {
|
|
1049
|
+
_context.next = 9;
|
|
1050
|
+
break;
|
|
1051
|
+
}
|
|
1052
|
+
console.warn("Table instance not available");
|
|
1053
|
+
return _context.abrupt("return");
|
|
1054
|
+
case 9:
|
|
1055
|
+
targetPage = currentTable.getState().pagination.pageIndex + 1;
|
|
1056
|
+
currentPageSize = ((_datasource$paginatio3 = datasource.pagination) === null || _datasource$paginatio3 === void 0 ? void 0 : _datasource$paginatio3.size) || currentTable.getState().pagination.pageSize;
|
|
1057
|
+
shouldNavigateToLastPage = false; // If newData is true and we have pagination metadata, calculate the last page
|
|
1058
|
+
if (newData && datasource.pagination) {
|
|
1059
|
+
totalElements = datasource.pagination.totalElements;
|
|
1060
|
+
if (totalElements !== undefined && currentPageSize > 0) {
|
|
1061
|
+
// Calculate the last page
|
|
1062
|
+
// For example: 15 elements with page size 5 = 3 pages
|
|
1063
|
+
// Adding 1 element makes it 16 elements = 4 pages (since page 3 is full)
|
|
1064
|
+
totalAfterAdd = totalElements + 1;
|
|
1065
|
+
lastPage = Math.ceil(totalAfterAdd / currentPageSize);
|
|
1066
|
+
targetPage = lastPage;
|
|
1067
|
+
shouldNavigateToLastPage = true;
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
// For server-side pagination, use datasource invoke
|
|
1072
|
+
if (!isServerSidePagination) {
|
|
1073
|
+
_context.next = 20;
|
|
1074
|
+
break;
|
|
1075
|
+
}
|
|
1076
|
+
_context.next = 16;
|
|
1077
|
+
return (0, _crudHandlers.refreshDataSource)(datasource, {
|
|
1078
|
+
page: targetPage,
|
|
1079
|
+
pagesize: currentPageSize,
|
|
1080
|
+
filterFields: memoizedFilterFields || {},
|
|
1081
|
+
condition: memoizedLogicalOp
|
|
1082
|
+
});
|
|
1083
|
+
case 16:
|
|
1084
|
+
response = _context.sent;
|
|
1085
|
+
// The datasource should update its data property automatically
|
|
1086
|
+
// which will trigger a re-render through the dataset prop
|
|
1087
|
+
if (response && response.data) {
|
|
1088
|
+
dataWithIds = (0, _utils.addUniqueRowIds)(response.data);
|
|
1089
|
+
setInternalDataset(dataWithIds);
|
|
1090
|
+
|
|
1091
|
+
// Set the table to the last page AFTER data is loaded
|
|
1092
|
+
if (shouldNavigateToLastPage) {
|
|
1093
|
+
// Use requestAnimationFrame for better performance than setTimeout
|
|
1094
|
+
requestAnimationFrame(function () {
|
|
1095
|
+
currentTable.setPageIndex(targetPage);
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
_context.next = 21;
|
|
1100
|
+
break;
|
|
1101
|
+
case 20:
|
|
1102
|
+
// For client-side pagination, just set the page index
|
|
1103
|
+
if (shouldNavigateToLastPage) {
|
|
1104
|
+
currentTable.setPageIndex(targetPage);
|
|
1105
|
+
}
|
|
1106
|
+
case 21:
|
|
1107
|
+
// Show success notification
|
|
1108
|
+
if (showToast) {
|
|
1109
|
+
showToast("Table refreshed successfully", "Success");
|
|
1110
|
+
}
|
|
1111
|
+
_context.next = 29;
|
|
1112
|
+
break;
|
|
1113
|
+
case 24:
|
|
1114
|
+
_context.prev = 24;
|
|
1115
|
+
_context.t0 = _context["catch"](4);
|
|
1116
|
+
console.error("Error refreshing table data:", _context.t0);
|
|
1117
|
+
if (showToast) {
|
|
1118
|
+
showToast("Failed to refresh table data", "Error");
|
|
1119
|
+
}
|
|
1120
|
+
if (onError) {
|
|
1121
|
+
onError("refresh", _context.t0);
|
|
1122
|
+
}
|
|
1123
|
+
case 29:
|
|
1124
|
+
case "end":
|
|
1125
|
+
return _context.stop();
|
|
1126
|
+
}
|
|
1127
|
+
}, _callee, null, [[4, 24]]);
|
|
1128
|
+
})), [datasource, isServerSidePagination, setInternalDataset, showToast, onError]); // Removed 'table' from dependencies to prevent recreation
|
|
1129
|
+
|
|
1130
|
+
// Expose table API through listener
|
|
1131
|
+
(0, _react.useEffect)(function () {
|
|
1132
|
+
if (listener && listener.onChange) {
|
|
1133
|
+
listener.onChange(name, {
|
|
1134
|
+
columns: columnsProxy,
|
|
1135
|
+
addNewRow: handleAddNewRowClick,
|
|
1136
|
+
editRow: editRow,
|
|
1137
|
+
deleteRow: deleteRow,
|
|
1138
|
+
refresh: refresh,
|
|
1139
|
+
datasource: datasource
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1142
|
+
}, []);
|
|
1143
|
+
return __jsx(_material.Box, {
|
|
1144
|
+
className: "app-livegrid",
|
|
1145
|
+
name: name
|
|
1146
|
+
}, __jsx(_material.Box, {
|
|
1147
|
+
className: "app-grid app-panel panel app-datagrid ".concat(className).trim(),
|
|
1148
|
+
name: name,
|
|
1149
|
+
editmode: editmode,
|
|
1150
|
+
navigation: navigation,
|
|
1151
|
+
title: title,
|
|
1152
|
+
currentpage: table.getState().pagination.pageIndex + 1
|
|
1153
|
+
}, renderConfirmDialog(), showPanelHeading && __jsx(_components.TablePanelHeading, {
|
|
1154
|
+
title: title,
|
|
1155
|
+
subheading: subheading,
|
|
1156
|
+
iconclass: iconclass,
|
|
1157
|
+
exportOptions: exportOptions,
|
|
1158
|
+
headerActions: headerActions,
|
|
1159
|
+
spacing: spacing,
|
|
1160
|
+
isGridEditMode: isGridEditModeComplete,
|
|
1161
|
+
isLoading: datasource === null || datasource === void 0 ? void 0 : datasource.loading,
|
|
1162
|
+
listener: listener
|
|
1163
|
+
}), __jsx(_material.Box, {
|
|
1164
|
+
className: "app-datagrid",
|
|
1165
|
+
onKeyDown: function onKeyDown(e) {
|
|
1166
|
+
return handleTableEditKeyDown(e);
|
|
1167
|
+
}
|
|
1168
|
+
}, filtermode === "search" && __jsx(_components.GlobalSearchFilter, {
|
|
1169
|
+
value: globalFilter,
|
|
1170
|
+
onChange: setGlobalFilter,
|
|
1171
|
+
selectedColumn: globalSearchColumn,
|
|
1172
|
+
onColumnChange: setGlobalSearchColumn,
|
|
1173
|
+
columns: columnsForTable,
|
|
1174
|
+
searchLabel: searchlabel
|
|
1175
|
+
}), __jsx(_material.Box, {
|
|
1176
|
+
className: "table-container table-responsive"
|
|
1177
|
+
}, __jsx(_material.Box, {
|
|
1178
|
+
className: "app-grid-header"
|
|
1179
|
+
}, __jsx(_material.Box, {
|
|
1180
|
+
className: "app-grid-header-inner",
|
|
1181
|
+
style: {
|
|
1182
|
+
height: "100%",
|
|
1183
|
+
overflow: "auto",
|
|
1184
|
+
position: "relative"
|
|
1185
|
+
}
|
|
1186
|
+
}, loading && __jsx(_LoadingComponent["default"], {
|
|
1187
|
+
message: loadingdatamsg
|
|
1188
|
+
}), __jsx(_material.Table, {
|
|
1189
|
+
key: "table-".concat(isDynamicTable ? "dynamic" : "static", "-").concat(wmTableColumns.length, "-page-").concat(table.getState().pagination.pageIndex) // Force complete rebuild on pagination
|
|
1190
|
+
,
|
|
1191
|
+
className: "".concat(_utils.TABLE_CSS_CLASSES.gridDefault, " table-striped table-hover ").concat(spacingClasses).trim(),
|
|
1192
|
+
sx: {
|
|
1193
|
+
width: props.width || "100%"
|
|
1194
|
+
},
|
|
1195
|
+
name: name
|
|
1196
|
+
}, showheader && wmTableColumns.length > 0 && __jsx(_components.TableHeaderComponent, {
|
|
1197
|
+
table: table,
|
|
1198
|
+
enablesort: enablesort,
|
|
1199
|
+
rowClass: rowClass,
|
|
1200
|
+
sorting: sorting,
|
|
1201
|
+
columnSizing: columnSizing,
|
|
1202
|
+
rowSelection: rowSelection,
|
|
1203
|
+
rowExpansionConfig: rowExpansionConfig,
|
|
1204
|
+
columnsVersion: columnsVersion,
|
|
1205
|
+
filterMode: filtermode,
|
|
1206
|
+
columnFilters: columnFilters,
|
|
1207
|
+
onColumnFilterChange: setColumnFilter,
|
|
1208
|
+
renderFormWidget: renderFormWidget,
|
|
1209
|
+
listener: listener
|
|
1210
|
+
}), __jsx(_components.TableBodyComponent, {
|
|
1211
|
+
table: table,
|
|
1212
|
+
columns: columns,
|
|
1213
|
+
rowClass: rowClass,
|
|
1214
|
+
formposition: formposition,
|
|
1215
|
+
renderAddNewRow: renderAddNewRow,
|
|
1216
|
+
onRowClick: handleRowClick,
|
|
1217
|
+
isRowActive: isRowActive,
|
|
1218
|
+
isRowSelected: isRowSelected,
|
|
1219
|
+
nodatamessage: nodatamessage,
|
|
1220
|
+
loadingdatamsg: loadingdatamsg,
|
|
1221
|
+
isLoading: datasource === null || datasource === void 0 ? void 0 : datasource.loading,
|
|
1222
|
+
rowExpansionConfig: rowExpansionConfig,
|
|
1223
|
+
expandedRows: expandedRows,
|
|
1224
|
+
toggleRowExpansion: toggleRowExpansion,
|
|
1225
|
+
isRowExpanded: isRowExpanded
|
|
1226
|
+
})))))), __jsx(_material.Box, {
|
|
1227
|
+
className: "panel-footer clearfix"
|
|
1228
|
+
}, showPagination && __jsx(_material.Box, {
|
|
1229
|
+
className: "app-datagrid-paginator"
|
|
1230
|
+
}, __jsx(_pagination["default"], {
|
|
1231
|
+
name: "".concat(name || "table", "_pagination"),
|
|
1232
|
+
dataset: filtermode ? filteredData : internalDataset,
|
|
1233
|
+
maxResults: pagesize,
|
|
1234
|
+
currentPage: table.getState().pagination.pageIndex + 1,
|
|
1235
|
+
navigation: navigation,
|
|
1236
|
+
navigationalign: navigationalign,
|
|
1237
|
+
showrecordcount: showrecordcount,
|
|
1238
|
+
maxsize: maxsize,
|
|
1239
|
+
boundarylinks: boundarylinks,
|
|
1240
|
+
directionlinks: true,
|
|
1241
|
+
allowpagesizechange: allowpagesizechange,
|
|
1242
|
+
pagesizeoptions: pagesizeoptions,
|
|
1243
|
+
listener: listener,
|
|
1244
|
+
onPaginationChange: handlePaginationChange,
|
|
1245
|
+
onPageSizeChange: handlePageSizeChange,
|
|
1246
|
+
onDataUpdate: handleScrollDataUpdate
|
|
1247
|
+
// Pass pagination metadata from datasource if available
|
|
1248
|
+
,
|
|
1249
|
+
paginationMeta: datasource === null || datasource === void 0 ? void 0 : datasource.pagination,
|
|
1250
|
+
totalItems: datasource === null || datasource === void 0 || (_datasource$paginatio4 = datasource.pagination) === null || _datasource$paginatio4 === void 0 ? void 0 : _datasource$paginatio4.totalElements
|
|
1251
|
+
// Pass datasource for API-based pagination
|
|
1252
|
+
,
|
|
1253
|
+
datasource: datasource
|
|
1254
|
+
// Pass server-side pagination flag
|
|
1255
|
+
,
|
|
1256
|
+
isServerSidePagination: isServerSidePagination
|
|
1257
|
+
// Pass additional invoke options for server-side operations
|
|
1258
|
+
,
|
|
1259
|
+
datasourceInvokeOptions: isServerSidePagination ? {
|
|
1260
|
+
orderBy: sorting.length > 0 ? sorting.map(function (s) {
|
|
1261
|
+
return "".concat(s.id, " ").concat(s.desc ? "desc" : "asc");
|
|
1262
|
+
}).join(", ") : undefined,
|
|
1263
|
+
filterFields: memoizedFilterFields,
|
|
1264
|
+
condition: memoizedLogicalOp
|
|
1265
|
+
} : undefined
|
|
1266
|
+
})), __jsx(_components.TableFooterActions, {
|
|
1267
|
+
footerActions: footerActions,
|
|
1268
|
+
spacing: spacing,
|
|
1269
|
+
isGridEditMode: isGridEditModeComplete,
|
|
1270
|
+
isLoading: datasource === null || datasource === void 0 ? void 0 : datasource.loading,
|
|
1271
|
+
listener: listener
|
|
1272
|
+
}))));
|
|
1273
|
+
}, function (prev, current) {
|
|
1274
|
+
// Check if core data and configuration props are the same
|
|
1275
|
+
var keys = ["dataset", "editmode", "navigation", "pagesize", "showrowindex", "showheader", "enablesort", "radioselect", "radioselecttitle", "radioselectarialabel", "multiselect", "multiselecttitle", "multiselectarialabel", "gridfirstrowselect", "rowClass", "deleteoktext", "deletecanceltext", "confirmdelete", "errormessage", "nodatamessage", "loadingdatamsg", "insertmessage", "updatemessage", "deletemessage", "spacing", "title", "subheading", "iconclass", "allowpagesizechange", "pagesizeoptions", "datasource", "binddataset", "onSuccess", "onError", "onRowinsert", "onRowupdate", "onRowdelete", "statehandler", "filtermode", "children", "listener"];
|
|
1276
|
+
|
|
1277
|
+
// First check the simple props
|
|
1278
|
+
var simplePropsEqual = keys.every(function (key) {
|
|
1279
|
+
return prev[key] === current[key];
|
|
1280
|
+
});
|
|
1281
|
+
if (!simplePropsEqual) return false;
|
|
1282
|
+
|
|
1283
|
+
// Check if children structure has changed (column/action definitions)
|
|
1284
|
+
var prevChildrenCount = _react["default"].Children.count(prev.children);
|
|
1285
|
+
var currentChildrenCount = _react["default"].Children.count(current.children);
|
|
1286
|
+
if (prevChildrenCount !== currentChildrenCount) return false;
|
|
1287
|
+
|
|
1288
|
+
// If all checks pass, consider components equal (skip re-render)
|
|
1289
|
+
return true;
|
|
1290
|
+
});
|
|
1291
|
+
WmTableComponent.displayName = "WmTableComponent";
|
|
1292
|
+
var WmTable = (0, _withBaseWrapper["default"])(WmTableComponent);
|
|
1293
|
+
// Override the displayName set by withBaseWrapper
|
|
1294
|
+
WmTable.displayName = "WmTable";
|
|
1295
|
+
var _default = exports["default"] = WmTable;
|