@wavemaker/react-runtime 11.14.1-16.6404
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,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useTableEffects = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _tableHelpers = require("../utils/table-helpers");
|
|
9
|
+
var useTableEffects = exports.useTableEffects = function useTableEffects(props) {
|
|
10
|
+
var name = props.name,
|
|
11
|
+
navigation = props.navigation,
|
|
12
|
+
datasource = props.datasource,
|
|
13
|
+
internalDataset = props.internalDataset,
|
|
14
|
+
statehandler = props.statehandler,
|
|
15
|
+
selectedRowId = props.selectedRowId,
|
|
16
|
+
selectedRowIds = props.selectedRowIds,
|
|
17
|
+
currentPage = props.currentPage,
|
|
18
|
+
currentPageSize = props.currentPageSize,
|
|
19
|
+
sorting = props.sorting,
|
|
20
|
+
isGridEditMode = props.isGridEditMode,
|
|
21
|
+
stateManager = props.stateManager,
|
|
22
|
+
initialActualPageSize = props.initialActualPageSize;
|
|
23
|
+
|
|
24
|
+
// State to track if we've restored state
|
|
25
|
+
var _useState = (0, _react.useState)(false),
|
|
26
|
+
hasRestoredState = _useState[0],
|
|
27
|
+
setHasRestoredState = _useState[1];
|
|
28
|
+
var _useState2 = (0, _react.useState)(null),
|
|
29
|
+
restoredPageNumber = _useState2[0],
|
|
30
|
+
setRestoredPageNumber = _useState2[1];
|
|
31
|
+
var _useState3 = (0, _react.useState)([]),
|
|
32
|
+
restoredSelectedRowIds = _useState3[0],
|
|
33
|
+
setRestoredSelectedRowIds = _useState3[1];
|
|
34
|
+
var _useState4 = (0, _react.useState)([]),
|
|
35
|
+
restoredSelectedIndices = _useState4[0],
|
|
36
|
+
setRestoredSelectedIndices = _useState4[1];
|
|
37
|
+
var _useState5 = (0, _react.useState)(false),
|
|
38
|
+
isRestoringSelection = _useState5[0],
|
|
39
|
+
setIsRestoringSelection = _useState5[1];
|
|
40
|
+
|
|
41
|
+
// Effect 1: Load persisted state when component mounts
|
|
42
|
+
(0, _react.useEffect)(function () {
|
|
43
|
+
if (!hasRestoredState && statehandler && internalDataset.length > 0) {
|
|
44
|
+
var savedState = (0, _tableHelpers.getTableState)(name, statehandler);
|
|
45
|
+
if (savedState) {
|
|
46
|
+
// Check if there's an active filter
|
|
47
|
+
var hasActiveFilter = savedState.search && savedState.search.length > 0;
|
|
48
|
+
|
|
49
|
+
// Extract page number (only if no active filter)
|
|
50
|
+
if (savedState.pagination && !hasActiveFilter) {
|
|
51
|
+
setRestoredPageNumber(savedState.pagination);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Extract selected indices for the current page (only if no active filter)
|
|
55
|
+
if (savedState.selectedItem && savedState.selectedItem.length > 0 && !hasActiveFilter) {
|
|
56
|
+
// Only restore selections for the current page
|
|
57
|
+
var currentPageSelections = savedState.selectedItem.filter(function (item) {
|
|
58
|
+
return item.page === savedState.pagination;
|
|
59
|
+
}).map(function (item) {
|
|
60
|
+
return item.index;
|
|
61
|
+
});
|
|
62
|
+
setRestoredSelectedIndices(currentPageSelections);
|
|
63
|
+
}
|
|
64
|
+
// If there's an active filter, don't restore selections as the data is completely different
|
|
65
|
+
}
|
|
66
|
+
setHasRestoredState(true);
|
|
67
|
+
}
|
|
68
|
+
}, [name, statehandler, hasRestoredState, internalDataset.length]);
|
|
69
|
+
|
|
70
|
+
// Effect 2: Persist state on changes
|
|
71
|
+
(0, _react.useEffect)(function () {
|
|
72
|
+
// Skip persistence if we haven't loaded initial data yet
|
|
73
|
+
if (internalDataset.length === 0 || !statehandler) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Skip persistence during edit mode or when restoring selection
|
|
78
|
+
if (isGridEditMode || isRestoringSelection) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Check if we're in default state
|
|
83
|
+
if (!stateManager.isDefaultState()) {
|
|
84
|
+
// Get existing persisted state
|
|
85
|
+
var existingState = (0, _tableHelpers.getTableState)(name, statehandler);
|
|
86
|
+
|
|
87
|
+
// Merge current state with existing state
|
|
88
|
+
var stateToSave = stateManager.mergeWithExisting(stateManager.currentState, existingState);
|
|
89
|
+
|
|
90
|
+
// Clean up the state to save - remove default values
|
|
91
|
+
var cleanedState = {};
|
|
92
|
+
|
|
93
|
+
// Only include non-default values
|
|
94
|
+
if (stateToSave.pagination && stateToSave.pagination !== 1) {
|
|
95
|
+
cleanedState.pagination = stateToSave.pagination;
|
|
96
|
+
}
|
|
97
|
+
if (stateToSave.pagesize) {
|
|
98
|
+
cleanedState.pagesize = stateToSave.pagesize;
|
|
99
|
+
}
|
|
100
|
+
if (stateToSave.selectedItem && stateToSave.selectedItem.length > 0) {
|
|
101
|
+
cleanedState.selectedItem = stateToSave.selectedItem;
|
|
102
|
+
}
|
|
103
|
+
if (stateToSave.search && stateToSave.search.length > 0) {
|
|
104
|
+
cleanedState.search = stateToSave.search;
|
|
105
|
+
}
|
|
106
|
+
if (stateToSave.sort) {
|
|
107
|
+
cleanedState.sort = stateToSave.sort;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Include actualpagesize if present
|
|
111
|
+
if (stateToSave.actualpagesize !== undefined) {
|
|
112
|
+
cleanedState.actualpagesize = stateToSave.actualpagesize;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Only save if there's something to save
|
|
116
|
+
if (Object.keys(cleanedState).length > 0) {
|
|
117
|
+
// If we have a filter active, use clear-then-save to avoid merge issues
|
|
118
|
+
var hasActiveFilter = cleanedState.search && cleanedState.search.length > 0;
|
|
119
|
+
if (hasActiveFilter) {
|
|
120
|
+
// Clear first to ensure no merge happens
|
|
121
|
+
(0, _tableHelpers.clearTableState)(name, statehandler);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Save the cleaned state
|
|
125
|
+
(0, _tableHelpers.saveTableState)(name, statehandler, cleanedState);
|
|
126
|
+
} else {
|
|
127
|
+
// If nothing to save, clear the state
|
|
128
|
+
(0, _tableHelpers.clearTableState)(name, statehandler);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}, [selectedRowId, selectedRowIds, currentPage, currentPageSize, internalDataset, name, statehandler, isGridEditMode, isRestoringSelection, stateManager]);
|
|
132
|
+
return {
|
|
133
|
+
restoredPageNumber: restoredPageNumber,
|
|
134
|
+
restoredSelectedRowIds: restoredSelectedRowIds,
|
|
135
|
+
restoredSelectedIndices: restoredSelectedIndices,
|
|
136
|
+
hasRestoredState: hasRestoredState,
|
|
137
|
+
setIsRestoringSelection: setIsRestoringSelection
|
|
138
|
+
};
|
|
139
|
+
};
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useTableFilter = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
var _lodashEs = require("lodash-es");
|
|
12
|
+
var _types = require("../../types");
|
|
13
|
+
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; }
|
|
14
|
+
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; }
|
|
15
|
+
// Constants
|
|
16
|
+
var NUMERIC_DATA_TYPES = [_types.DataType.INTEGER, _types.DataType.BIG_INTEGER, _types.DataType.SHORT, _types.DataType.FLOAT, _types.DataType.BIG_DECIMAL, _types.DataType.DOUBLE, _types.DataType.LONG, _types.DataType.BYTE, "number"];
|
|
17
|
+
var DATE_DATA_TYPES = [_types.DataType.DATE, _types.DataType.TIME, _types.DataType.TIMESTAMP, _types.DataType.DATETIME];
|
|
18
|
+
var MATCH_MODES = {
|
|
19
|
+
START: "start",
|
|
20
|
+
START_IGNORE_CASE: "startignorecase",
|
|
21
|
+
END: "end",
|
|
22
|
+
END_IGNORE_CASE: "endignorecase",
|
|
23
|
+
EXACT: "exact",
|
|
24
|
+
EXACT_IGNORE_CASE: "exactignorecase",
|
|
25
|
+
NOT_EQUALS: "notequals",
|
|
26
|
+
NOT_EQUALS_IGNORE_CASE: "notequalsignorecase",
|
|
27
|
+
NULL: "null",
|
|
28
|
+
IS_NOT_NULL: "isnotnull",
|
|
29
|
+
EMPTY: "empty",
|
|
30
|
+
IS_NOT_EMPTY: "isnotempty",
|
|
31
|
+
NULL_OR_EMPTY: "nullorempty",
|
|
32
|
+
LESS_THAN: "lessthan",
|
|
33
|
+
LESS_THAN_EQUAL: "lessthanequal",
|
|
34
|
+
GREATER_THAN: "greaterthan",
|
|
35
|
+
GREATER_THAN_EQUAL: "greaterthanequal",
|
|
36
|
+
ANYWHERE: "anywhere",
|
|
37
|
+
ANYWHERE_IGNORE_CASE: "anywhereignorecase"
|
|
38
|
+
};
|
|
39
|
+
var EMPTY_MATCH_MODES = [MATCH_MODES.NULL, MATCH_MODES.EMPTY, MATCH_MODES.NULL_OR_EMPTY, MATCH_MODES.IS_NOT_NULL, MATCH_MODES.IS_NOT_EMPTY];
|
|
40
|
+
|
|
41
|
+
// Helper function to check if type is numeric
|
|
42
|
+
var isNumberType = function isNumberType(type) {
|
|
43
|
+
return (0, _lodashEs.includes)(NUMERIC_DATA_TYPES, type === null || type === void 0 ? void 0 : type.toLowerCase());
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// Get search value based on the type
|
|
47
|
+
var getSearchValue = function getSearchValue(value, type) {
|
|
48
|
+
if (!value && value !== 0 && value !== "") {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
var dataType = type === null || type === void 0 ? void 0 : type.toLowerCase();
|
|
52
|
+
if (isNumberType(dataType !== null && dataType !== void 0 ? dataType : "")) {
|
|
53
|
+
return (0, _lodashEs.toNumber)(value);
|
|
54
|
+
}
|
|
55
|
+
if ((0, _lodashEs.includes)(DATE_DATA_TYPES, dataType)) {
|
|
56
|
+
// For now, return timestamp - can be enhanced with moment.js if needed
|
|
57
|
+
return new Date(value).valueOf();
|
|
58
|
+
}
|
|
59
|
+
return (0, _lodashEs.toLower)((0, _lodashEs.toString)(value));
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// Filter the data based on the search value and conditions - matches Angular implementation
|
|
63
|
+
var getFilteredData = function getFilteredData(data, searchObj) {
|
|
64
|
+
var _searchObj$matchMode, _searchObj$type;
|
|
65
|
+
var visibleCols = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
66
|
+
var searchVal = getSearchValue(searchObj.value, searchObj.type);
|
|
67
|
+
var currentVal;
|
|
68
|
+
|
|
69
|
+
// Return whole data if search value is undefined and matchmode is not an empty matchmode type
|
|
70
|
+
// or search value is null and datatype is number. Null can not be compared with numeric values
|
|
71
|
+
if (!searchVal && searchVal !== 0 && !(0, _lodashEs.includes)(EMPTY_MATCH_MODES, (_searchObj$matchMode = searchObj.matchMode) !== null && _searchObj$matchMode !== void 0 ? _searchObj$matchMode : "") || isNumberType((_searchObj$type = searchObj.type) !== null && _searchObj$type !== void 0 ? _searchObj$type : "") && (0, _lodashEs.isNull)(searchObj.value)) {
|
|
72
|
+
return data;
|
|
73
|
+
}
|
|
74
|
+
return (0, _lodashEs.filter)(data, function (obj) {
|
|
75
|
+
var _searchObj$type2;
|
|
76
|
+
var isExists;
|
|
77
|
+
if (searchObj.field) {
|
|
78
|
+
currentVal = getSearchValue((0, _lodashEs.get)(obj, searchObj.field), searchObj.type);
|
|
79
|
+
} else {
|
|
80
|
+
// If field is not there, search on all visible columns
|
|
81
|
+
var valuesArray = [];
|
|
82
|
+
|
|
83
|
+
// Use lodash's forEach and filter more efficiently
|
|
84
|
+
(0, _lodashEs.forEach)(obj, function (val, key) {
|
|
85
|
+
if ((0, _lodashEs.includes)(visibleCols, key)) {
|
|
86
|
+
valuesArray.push(val);
|
|
87
|
+
} else {
|
|
88
|
+
// Handle nested key format (dot notation)
|
|
89
|
+
var nestedColPaths = (0, _lodashEs.filter)(visibleCols, function (col) {
|
|
90
|
+
return (0, _lodashEs.startsWith)(col, "".concat(key, "."));
|
|
91
|
+
});
|
|
92
|
+
(0, _lodashEs.forEach)(nestedColPaths, function (colPath) {
|
|
93
|
+
var value = (0, _lodashEs.get)(obj, colPath);
|
|
94
|
+
if (!(0, _lodashEs.includes)(valuesArray, value)) {
|
|
95
|
+
valuesArray.push(value);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
currentVal = (0, _lodashEs.toLower)(valuesArray.join(" "));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Check if values are valid for comparison operations upfront
|
|
104
|
+
var hasValidValues = !(0, _lodashEs.isNil)(currentVal) && !(0, _lodashEs.isNil)(searchVal);
|
|
105
|
+
var isCurrentString = (0, _lodashEs.isString)(currentVal);
|
|
106
|
+
var isSearchString = (0, _lodashEs.isString)(searchVal);
|
|
107
|
+
var areBothStrings = isCurrentString && isSearchString;
|
|
108
|
+
switch (searchObj.matchMode) {
|
|
109
|
+
case MATCH_MODES.START:
|
|
110
|
+
case MATCH_MODES.START_IGNORE_CASE:
|
|
111
|
+
isExists = areBothStrings ? (0, _lodashEs.startsWith)(currentVal, searchVal) : false;
|
|
112
|
+
break;
|
|
113
|
+
case MATCH_MODES.END:
|
|
114
|
+
case MATCH_MODES.END_IGNORE_CASE:
|
|
115
|
+
isExists = areBothStrings ? (0, _lodashEs.endsWith)(currentVal, searchVal) : false;
|
|
116
|
+
break;
|
|
117
|
+
case MATCH_MODES.EXACT:
|
|
118
|
+
case MATCH_MODES.EXACT_IGNORE_CASE:
|
|
119
|
+
isExists = (0, _lodashEs.isEqual)(currentVal, searchVal);
|
|
120
|
+
break;
|
|
121
|
+
case MATCH_MODES.NOT_EQUALS:
|
|
122
|
+
case MATCH_MODES.NOT_EQUALS_IGNORE_CASE:
|
|
123
|
+
isExists = !(0, _lodashEs.isEqual)(currentVal, searchVal);
|
|
124
|
+
break;
|
|
125
|
+
case MATCH_MODES.NULL:
|
|
126
|
+
isExists = (0, _lodashEs.isNull)(currentVal);
|
|
127
|
+
break;
|
|
128
|
+
case MATCH_MODES.IS_NOT_NULL:
|
|
129
|
+
isExists = !(0, _lodashEs.isNull)(currentVal);
|
|
130
|
+
break;
|
|
131
|
+
case MATCH_MODES.EMPTY:
|
|
132
|
+
isExists = (0, _lodashEs.isEmpty)(currentVal);
|
|
133
|
+
break;
|
|
134
|
+
case MATCH_MODES.IS_NOT_EMPTY:
|
|
135
|
+
isExists = !(0, _lodashEs.isEmpty)(currentVal);
|
|
136
|
+
break;
|
|
137
|
+
case MATCH_MODES.NULL_OR_EMPTY:
|
|
138
|
+
isExists = (0, _lodashEs.isNull)(currentVal) || (0, _lodashEs.isEmpty)(currentVal);
|
|
139
|
+
break;
|
|
140
|
+
case MATCH_MODES.LESS_THAN:
|
|
141
|
+
isExists = hasValidValues && currentVal < searchVal;
|
|
142
|
+
break;
|
|
143
|
+
case MATCH_MODES.LESS_THAN_EQUAL:
|
|
144
|
+
isExists = hasValidValues && currentVal <= searchVal;
|
|
145
|
+
break;
|
|
146
|
+
case MATCH_MODES.GREATER_THAN:
|
|
147
|
+
isExists = hasValidValues && currentVal > searchVal;
|
|
148
|
+
break;
|
|
149
|
+
case MATCH_MODES.GREATER_THAN_EQUAL:
|
|
150
|
+
isExists = hasValidValues && currentVal >= searchVal;
|
|
151
|
+
break;
|
|
152
|
+
case MATCH_MODES.ANYWHERE:
|
|
153
|
+
case MATCH_MODES.ANYWHERE_IGNORE_CASE:
|
|
154
|
+
default:
|
|
155
|
+
isExists = isNumberType((_searchObj$type2 = searchObj.type) !== null && _searchObj$type2 !== void 0 ? _searchObj$type2 : "") ? (0, _lodashEs.isEqual)(currentVal, searchVal) : isCurrentString && !(0, _lodashEs.isNil)(searchVal) ? (0, _lodashEs.includes)(currentVal, (0, _lodashEs.toString)(searchVal)) : false;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
return isExists;
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
// Set the filter fields as required by datasource
|
|
163
|
+
var setFilterFields = function setFilterFields(filterFields, searchObj) {
|
|
164
|
+
var visibleCols = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
165
|
+
var columns = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
166
|
+
var field = searchObj && searchObj.field;
|
|
167
|
+
if (field) {
|
|
168
|
+
var _ref, _ref2, _searchObj$type3, _column$meta, _column$meta2, _searchObj$matchMode2;
|
|
169
|
+
// Set the filter options when a field/column has been selected
|
|
170
|
+
// Find the column to get its type
|
|
171
|
+
var column = (0, _lodashEs.find)(columns, function (col) {
|
|
172
|
+
var c = col;
|
|
173
|
+
return c.accessorKey === field || c.id === field;
|
|
174
|
+
});
|
|
175
|
+
var columnType = (_ref = (_ref2 = (_searchObj$type3 = searchObj.type) !== null && _searchObj$type3 !== void 0 ? _searchObj$type3 : column === null || column === void 0 || (_column$meta = column.meta) === null || _column$meta === void 0 ? void 0 : _column$meta.type) !== null && _ref2 !== void 0 ? _ref2 : column === null || column === void 0 || (_column$meta2 = column.meta) === null || _column$meta2 === void 0 ? void 0 : _column$meta2.editinputtype) !== null && _ref !== void 0 ? _ref : _types.DataType.STRING;
|
|
176
|
+
filterFields[field] = {
|
|
177
|
+
value: searchObj.value,
|
|
178
|
+
logicalOp: "AND",
|
|
179
|
+
matchMode: (_searchObj$matchMode2 = searchObj.matchMode) !== null && _searchObj$matchMode2 !== void 0 ? _searchObj$matchMode2 : MATCH_MODES.ANYWHERE_IGNORE_CASE,
|
|
180
|
+
type: columnType
|
|
181
|
+
};
|
|
182
|
+
} else {
|
|
183
|
+
// Set the filter options when a field/column hasn't been selected
|
|
184
|
+
(0, _lodashEs.forEach)(visibleCols, function (field) {
|
|
185
|
+
var _ref3, _column$meta$type, _column$meta3, _column$meta4, _searchObj$matchMode3;
|
|
186
|
+
// Find the column to get its type
|
|
187
|
+
var column = (0, _lodashEs.find)(columns, function (col) {
|
|
188
|
+
var c = col;
|
|
189
|
+
return c.accessorKey === field;
|
|
190
|
+
});
|
|
191
|
+
var columnType = (_ref3 = (_column$meta$type = column === null || column === void 0 || (_column$meta3 = column.meta) === null || _column$meta3 === void 0 ? void 0 : _column$meta3.type) !== null && _column$meta$type !== void 0 ? _column$meta$type : column === null || column === void 0 || (_column$meta4 = column.meta) === null || _column$meta4 === void 0 ? void 0 : _column$meta4.editinputtype) !== null && _ref3 !== void 0 ? _ref3 : _types.DataType.STRING;
|
|
192
|
+
filterFields[field] = {
|
|
193
|
+
value: searchObj.value,
|
|
194
|
+
type: columnType,
|
|
195
|
+
logicalOp: "OR",
|
|
196
|
+
matchMode: (_searchObj$matchMode3 = searchObj.matchMode) !== null && _searchObj$matchMode3 !== void 0 ? _searchObj$matchMode3 : MATCH_MODES.ANYWHERE_IGNORE_CASE
|
|
197
|
+
};
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
var useTableFilter = exports.useTableFilter = function useTableFilter(_ref4) {
|
|
202
|
+
var filterMode = _ref4.filterMode,
|
|
203
|
+
_ref4$columns = _ref4.columns,
|
|
204
|
+
columns = _ref4$columns === void 0 ? [] : _ref4$columns,
|
|
205
|
+
_ref4$dataset = _ref4.dataset,
|
|
206
|
+
dataset = _ref4$dataset === void 0 ? [] : _ref4$dataset,
|
|
207
|
+
initialSearchState = _ref4.initialSearchState;
|
|
208
|
+
// Initialize filter states based on persisted state
|
|
209
|
+
var getInitialGlobalFilter = function getInitialGlobalFilter() {
|
|
210
|
+
if (!initialSearchState || filterMode !== "search") return "";
|
|
211
|
+
// For search mode, we expect an array with one item
|
|
212
|
+
if ((0, _lodashEs.isArray)(initialSearchState) && initialSearchState.length > 0) {
|
|
213
|
+
var value = initialSearchState[0].value;
|
|
214
|
+
return !(0, _lodashEs.isNil)(value) ? String(value) : "";
|
|
215
|
+
}
|
|
216
|
+
return "";
|
|
217
|
+
};
|
|
218
|
+
var getInitialGlobalSearchColumn = function getInitialGlobalSearchColumn() {
|
|
219
|
+
if (!initialSearchState || filterMode !== "search") return "";
|
|
220
|
+
// For search mode, we expect an array with one item
|
|
221
|
+
if ((0, _lodashEs.isArray)(initialSearchState) && initialSearchState.length > 0) {
|
|
222
|
+
return initialSearchState[0].field || "";
|
|
223
|
+
}
|
|
224
|
+
return "";
|
|
225
|
+
};
|
|
226
|
+
var getInitialColumnFilters = function getInitialColumnFilters() {
|
|
227
|
+
if (!initialSearchState || filterMode !== "multicolumn") return {};
|
|
228
|
+
var filters = {};
|
|
229
|
+
if ((0, _lodashEs.isArray)(initialSearchState)) {
|
|
230
|
+
(0, _lodashEs.forEach)(initialSearchState, function (filter) {
|
|
231
|
+
if (filter.field) {
|
|
232
|
+
var _filter$value, _filter$matchMode;
|
|
233
|
+
filters[filter.field] = {
|
|
234
|
+
value: (_filter$value = filter.value) !== null && _filter$value !== void 0 ? _filter$value : "",
|
|
235
|
+
matchMode: (_filter$matchMode = filter.matchMode) !== null && _filter$matchMode !== void 0 ? _filter$matchMode : MATCH_MODES.ANYWHERE_IGNORE_CASE
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
return filters;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
// Global filter state for 'search' mode
|
|
244
|
+
var _useState = (0, _react.useState)(getInitialGlobalFilter()),
|
|
245
|
+
globalFilter = _useState[0],
|
|
246
|
+
setGlobalFilter = _useState[1];
|
|
247
|
+
|
|
248
|
+
// Selected column for global search
|
|
249
|
+
var _useState2 = (0, _react.useState)(getInitialGlobalSearchColumn()),
|
|
250
|
+
globalSearchColumn = _useState2[0],
|
|
251
|
+
setGlobalSearchColumn = _useState2[1];
|
|
252
|
+
|
|
253
|
+
// Column filters state for 'multicolumn' mode
|
|
254
|
+
var _useState3 = (0, _react.useState)(getInitialColumnFilters()),
|
|
255
|
+
columnFilters = _useState3[0],
|
|
256
|
+
setColumnFilters = _useState3[1];
|
|
257
|
+
|
|
258
|
+
// Set individual column filter
|
|
259
|
+
var setColumnFilter = (0, _react.useCallback)(function (columnId, value) {
|
|
260
|
+
var matchMode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : MATCH_MODES.ANYWHERE_IGNORE_CASE;
|
|
261
|
+
setColumnFilters(function (prev) {
|
|
262
|
+
return _objectSpread(_objectSpread({}, prev), {}, (0, _defineProperty2["default"])({}, columnId, {
|
|
263
|
+
value: value,
|
|
264
|
+
matchMode: matchMode
|
|
265
|
+
}));
|
|
266
|
+
});
|
|
267
|
+
}, []);
|
|
268
|
+
|
|
269
|
+
// Clear all filters
|
|
270
|
+
var clearAllFilters = (0, _react.useCallback)(function () {
|
|
271
|
+
setGlobalFilter("");
|
|
272
|
+
setGlobalSearchColumn("");
|
|
273
|
+
setColumnFilters({});
|
|
274
|
+
}, []);
|
|
275
|
+
|
|
276
|
+
// Get visible columns that can be searched
|
|
277
|
+
var getTableVisibleCols = (0, _react.useCallback)(function () {
|
|
278
|
+
var excludedColumnIds = ["actions", "row-operations", "multiSelect", "radioSelect", "row-index"];
|
|
279
|
+
return (0, _lodashEs.map)((0, _lodashEs.filter)(columns, function (col) {
|
|
280
|
+
var column = col;
|
|
281
|
+
return column.searchable !== false && !!column.accessorKey && !(0, _lodashEs.includes)(excludedColumnIds, column.id);
|
|
282
|
+
}), function (col) {
|
|
283
|
+
return col.accessorKey;
|
|
284
|
+
});
|
|
285
|
+
}, [columns]);
|
|
286
|
+
|
|
287
|
+
// Get filter fields as required by datasource
|
|
288
|
+
var getFilterFields = (0, _react.useCallback)(function (searchObj) {
|
|
289
|
+
var filterFields = {};
|
|
290
|
+
var visibleCols = getTableVisibleCols();
|
|
291
|
+
if (!searchObj) return filterFields;
|
|
292
|
+
if ((0, _lodashEs.isArray)(searchObj)) {
|
|
293
|
+
(0, _lodashEs.forEach)(searchObj, function (obj) {
|
|
294
|
+
setFilterFields(filterFields, obj, visibleCols, columns);
|
|
295
|
+
});
|
|
296
|
+
} else {
|
|
297
|
+
setFilterFields(filterFields, searchObj, visibleCols, columns);
|
|
298
|
+
}
|
|
299
|
+
return filterFields;
|
|
300
|
+
}, [getTableVisibleCols, columns]);
|
|
301
|
+
|
|
302
|
+
// Transform filter fields from object to array format
|
|
303
|
+
var transformFilterFields = (0, _react.useCallback)(function (filterFields) {
|
|
304
|
+
var result = [];
|
|
305
|
+
(0, _lodashEs.forEach)(filterFields, function (filter, field) {
|
|
306
|
+
var _filterObj$matchMode;
|
|
307
|
+
var filterObj = filter;
|
|
308
|
+
if (filterObj && (!(0, _lodashEs.isNil)(filterObj.value) || (0, _lodashEs.includes)(EMPTY_MATCH_MODES, (_filterObj$matchMode = filterObj.matchMode) !== null && _filterObj$matchMode !== void 0 ? _filterObj$matchMode : ""))) {
|
|
309
|
+
var _filterObj$matchMode2, _filterObj$type;
|
|
310
|
+
result.push({
|
|
311
|
+
field: field,
|
|
312
|
+
value: filterObj.value,
|
|
313
|
+
matchMode: (_filterObj$matchMode2 = filterObj.matchMode) !== null && _filterObj$matchMode2 !== void 0 ? _filterObj$matchMode2 : MATCH_MODES.ANYWHERE_IGNORE_CASE,
|
|
314
|
+
type: (_filterObj$type = filterObj.type) !== null && _filterObj$type !== void 0 ? _filterObj$type : _types.DataType.STRING
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
return result;
|
|
319
|
+
}, []);
|
|
320
|
+
|
|
321
|
+
// Apply filtering logic based on filter mode
|
|
322
|
+
var filteredData = (0, _react.useMemo)(function () {
|
|
323
|
+
if (!filterMode || !dataset) {
|
|
324
|
+
return dataset;
|
|
325
|
+
}
|
|
326
|
+
var data = (0, _toConsumableArray2["default"])(dataset);
|
|
327
|
+
var visibleCols = getTableVisibleCols();
|
|
328
|
+
if (filterMode === "search") {
|
|
329
|
+
// Handle search mode filtering
|
|
330
|
+
if (globalFilter || globalSearchColumn) {
|
|
331
|
+
var searchObj = {
|
|
332
|
+
field: globalSearchColumn || "",
|
|
333
|
+
value: globalFilter,
|
|
334
|
+
matchMode: MATCH_MODES.ANYWHERE_IGNORE_CASE,
|
|
335
|
+
type: globalSearchColumn ? function (_ref5, _col$meta$type, _col$meta, _col$meta2) {
|
|
336
|
+
var col = (0, _lodashEs.find)(columns, function (c) {
|
|
337
|
+
var column = c;
|
|
338
|
+
return column.accessorKey === globalSearchColumn || column.id === globalSearchColumn;
|
|
339
|
+
});
|
|
340
|
+
return (_ref5 = (_col$meta$type = col === null || col === void 0 || (_col$meta = col.meta) === null || _col$meta === void 0 ? void 0 : _col$meta.type) !== null && _col$meta$type !== void 0 ? _col$meta$type : col === null || col === void 0 || (_col$meta2 = col.meta) === null || _col$meta2 === void 0 ? void 0 : _col$meta2.editinputtype) !== null && _ref5 !== void 0 ? _ref5 : _types.DataType.STRING;
|
|
341
|
+
}() : _types.DataType.STRING
|
|
342
|
+
};
|
|
343
|
+
data = getFilteredData(data, searchObj, visibleCols);
|
|
344
|
+
}
|
|
345
|
+
} else if (filterMode === "multicolumn") {
|
|
346
|
+
// Handle multicolumn filtering
|
|
347
|
+
var filterArray = [];
|
|
348
|
+
(0, _lodashEs.forEach)(columnFilters, function (filterObj, columnId) {
|
|
349
|
+
if (!filterObj) return;
|
|
350
|
+
|
|
351
|
+
// Special match modes that don't require a value
|
|
352
|
+
if ((0, _lodashEs.isNil)(filterObj.value) && !(0, _lodashEs.includes)(EMPTY_MATCH_MODES, filterObj.matchMode)) return;
|
|
353
|
+
|
|
354
|
+
// Find column to get type
|
|
355
|
+
var column = (0, _lodashEs.find)(columns, function (col) {
|
|
356
|
+
var c = col;
|
|
357
|
+
return c.id === columnId || c.accessorKey === columnId;
|
|
358
|
+
});
|
|
359
|
+
if (column && column.accessorKey) {
|
|
360
|
+
var _ref6, _column$meta$type2, _column$meta5, _column$meta6;
|
|
361
|
+
filterArray.push({
|
|
362
|
+
field: column.accessorKey,
|
|
363
|
+
value: filterObj.value,
|
|
364
|
+
matchMode: filterObj.matchMode,
|
|
365
|
+
type: (_ref6 = (_column$meta$type2 = (_column$meta5 = column.meta) === null || _column$meta5 === void 0 ? void 0 : _column$meta5.type) !== null && _column$meta$type2 !== void 0 ? _column$meta$type2 : (_column$meta6 = column.meta) === null || _column$meta6 === void 0 ? void 0 : _column$meta6.editinputtype) !== null && _ref6 !== void 0 ? _ref6 : _types.DataType.STRING
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
// Apply each filter sequentially
|
|
371
|
+
data = filterArray.reduce(function (filteredData, searchObj) {
|
|
372
|
+
return getFilteredData(filteredData, searchObj, visibleCols);
|
|
373
|
+
}, data);
|
|
374
|
+
}
|
|
375
|
+
return data;
|
|
376
|
+
}, [dataset, columns, filterMode, globalFilter, globalSearchColumn, columnFilters, getTableVisibleCols]);
|
|
377
|
+
return {
|
|
378
|
+
globalFilter: globalFilter,
|
|
379
|
+
setGlobalFilter: setGlobalFilter,
|
|
380
|
+
globalSearchColumn: globalSearchColumn,
|
|
381
|
+
setGlobalSearchColumn: setGlobalSearchColumn,
|
|
382
|
+
columnFilters: columnFilters,
|
|
383
|
+
setColumnFilter: setColumnFilter,
|
|
384
|
+
filteredData: filteredData,
|
|
385
|
+
clearAllFilters: clearAllFilters,
|
|
386
|
+
getFilterFields: getFilterFields,
|
|
387
|
+
transformFilterFields: transformFilterFields
|
|
388
|
+
};
|
|
389
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useTableInitialization = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _lodashEs = require("lodash-es");
|
|
9
|
+
/**
|
|
10
|
+
* Hook to handle table initialization and active row synchronization logic
|
|
11
|
+
*/
|
|
12
|
+
var useTableInitialization = exports.useTableInitialization = function useTableInitialization(_ref) {
|
|
13
|
+
var internalDataset = _ref.internalDataset,
|
|
14
|
+
wmTableColumns = _ref.wmTableColumns,
|
|
15
|
+
cellState = _ref.cellState,
|
|
16
|
+
gridfirstrowselect = _ref.gridfirstrowselect,
|
|
17
|
+
useRadioSelect = _ref.useRadioSelect,
|
|
18
|
+
useMultiSelect = _ref.useMultiSelect,
|
|
19
|
+
setActiveRow = _ref.setActiveRow,
|
|
20
|
+
selectedRowId = _ref.selectedRowId,
|
|
21
|
+
selectedRowIds = _ref.selectedRowIds,
|
|
22
|
+
activeRowIds = _ref.activeRowIds,
|
|
23
|
+
formName = _ref.formName,
|
|
24
|
+
editmode = _ref.editmode,
|
|
25
|
+
listener = _ref.listener;
|
|
26
|
+
// Initialize cell state with dataset values for editable columns
|
|
27
|
+
(0, _react.useEffect)(function () {
|
|
28
|
+
if (!internalDataset || internalDataset.length === 0) return;
|
|
29
|
+
|
|
30
|
+
// Find columns that have edit widgets (they might have cell state)
|
|
31
|
+
var editableColumns = wmTableColumns.filter(function (col) {
|
|
32
|
+
return col.editWidgetType && !col.readonly;
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Initialize cell state for each row and editable column
|
|
36
|
+
internalDataset.forEach(function (row) {
|
|
37
|
+
var rowId = row._wmTableRowId || String(row.id) || "";
|
|
38
|
+
editableColumns.forEach(function (column) {
|
|
39
|
+
var fieldName = column.field;
|
|
40
|
+
var currentValue = (0, _lodashEs.get)(row, fieldName);
|
|
41
|
+
cellState.setValue(["cells", rowId, fieldName], currentValue);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}, [internalDataset, wmTableColumns, cellState]);
|
|
45
|
+
|
|
46
|
+
// First row active logic (when no selection mode is active)
|
|
47
|
+
(0, _react.useEffect)(function () {
|
|
48
|
+
if (gridfirstrowselect && !useRadioSelect && !useMultiSelect && internalDataset.length > 0) {
|
|
49
|
+
var firstRowData = internalDataset[0];
|
|
50
|
+
var firstRowId = firstRowData._wmTableRowId || String(firstRowData.id) || String(0);
|
|
51
|
+
setActiveRow(firstRowId);
|
|
52
|
+
}
|
|
53
|
+
}, [gridfirstrowselect, useRadioSelect, useMultiSelect, internalDataset, setActiveRow]);
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Sync active rows with selected rows for multiselect mode
|
|
57
|
+
* When multiselect is enabled, all selected rows should be marked as active
|
|
58
|
+
*/
|
|
59
|
+
(0, _react.useEffect)(function () {
|
|
60
|
+
if (useMultiSelect) {
|
|
61
|
+
// Set all selected rows as active
|
|
62
|
+
setActiveRow(selectedRowIds);
|
|
63
|
+
}
|
|
64
|
+
}, [selectedRowIds, useMultiSelect, setActiveRow]);
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Sync active row with selected row for radioselect mode
|
|
68
|
+
* When radioselect is enabled, the selected row should be marked as active
|
|
69
|
+
*/
|
|
70
|
+
(0, _react.useEffect)(function () {
|
|
71
|
+
if (useRadioSelect && selectedRowId) {
|
|
72
|
+
// Set the selected row as active
|
|
73
|
+
setActiveRow(selectedRowId);
|
|
74
|
+
}
|
|
75
|
+
}, [selectedRowId, useRadioSelect, setActiveRow]);
|
|
76
|
+
|
|
77
|
+
// Monitor when there are no active rows
|
|
78
|
+
(0, _react.useEffect)(function () {
|
|
79
|
+
// Check if there are no active rows
|
|
80
|
+
var hasNoActiveRows = !activeRowIds || activeRowIds.length === 0;
|
|
81
|
+
if (hasNoActiveRows && internalDataset.length > 0) {
|
|
82
|
+
// Handle the case when there are no active rows
|
|
83
|
+
// You can customize this logic based on your requirements
|
|
84
|
+
if (listener && editmode === "form" && formName) {
|
|
85
|
+
setTimeout(function () {
|
|
86
|
+
var _listener$Widgets$for;
|
|
87
|
+
(_listener$Widgets$for = listener.Widgets[formName]) === null || _listener$Widgets$for === void 0 || _listener$Widgets$for.setShowViewMode(true);
|
|
88
|
+
}, 10);
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
if (activeRowIds.length > 0 && listener && editmode === "form" && formName) {
|
|
92
|
+
setTimeout(function () {
|
|
93
|
+
var formWidget = listener.Widgets[formName];
|
|
94
|
+
var getRow = internalDataset.find(function (row) {
|
|
95
|
+
if (row._wmTableRowId === activeRowIds[0]) return true;
|
|
96
|
+
});
|
|
97
|
+
formWidget === null || formWidget === void 0 || formWidget.edit(getRow);
|
|
98
|
+
formWidget === null || formWidget === void 0 || formWidget.setShowViewMode(true);
|
|
99
|
+
}, 10);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}, [activeRowIds, internalDataset, gridfirstrowselect]);
|
|
103
|
+
};
|