@wavemaker/react-runtime 11.14.1-rc.236
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 +10183 -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,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useRowHandlers = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _utils = require("../utils");
|
|
9
|
+
/**
|
|
10
|
+
* Hook to consolidate all row click handlers
|
|
11
|
+
*/
|
|
12
|
+
var useRowHandlers = exports.useRowHandlers = function useRowHandlers(_ref) {
|
|
13
|
+
var editingRowId = _ref.editingRowId,
|
|
14
|
+
isAddingNewRow = _ref.isAddingNewRow,
|
|
15
|
+
handleRowSelectionClick = _ref.handleRowSelectionClick,
|
|
16
|
+
handleTableEditRowClick = _ref.handleTableEditRowClick,
|
|
17
|
+
handleRowActiveClick = _ref.handleRowActiveClick,
|
|
18
|
+
onRowclick = _ref.onRowclick;
|
|
19
|
+
var handleRowClick = (0, _react.useCallback)(function (event, rowData, rowId) {
|
|
20
|
+
// Handle row selection first
|
|
21
|
+
var isSelectionHandled = handleRowSelectionClick(event, rowId, rowData);
|
|
22
|
+
if (onRowclick) {
|
|
23
|
+
onRowclick(event, {}, (0, _utils.cleanRowData)(rowData));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Handle table edit row click (works for both inline and quickedit)
|
|
27
|
+
handleTableEditRowClick(rowData, rowId);
|
|
28
|
+
|
|
29
|
+
// Don't change active row if currently editing or adding new row
|
|
30
|
+
var isEditingOrAdding = editingRowId !== null || isAddingNewRow;
|
|
31
|
+
|
|
32
|
+
// Handle active row state
|
|
33
|
+
handleRowActiveClick(rowId, isSelectionHandled, isEditingOrAdding);
|
|
34
|
+
}, [editingRowId, isAddingNewRow, handleRowSelectionClick, handleTableEditRowClick, handleRowActiveClick]);
|
|
35
|
+
return {
|
|
36
|
+
handleRowClick: handleRowClick
|
|
37
|
+
};
|
|
38
|
+
};
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useRowSelection = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _selectionUtils = require("../utils/selectionUtils");
|
|
11
|
+
var _tableHelpers = require("../utils/table-helpers");
|
|
12
|
+
var useRowSelection = exports.useRowSelection = function useRowSelection(_ref) {
|
|
13
|
+
var _ref$radioselect = _ref.radioselect,
|
|
14
|
+
radioselect = _ref$radioselect === void 0 ? false : _ref$radioselect,
|
|
15
|
+
_ref$multiselect = _ref.multiselect,
|
|
16
|
+
multiselect = _ref$multiselect === void 0 ? false : _ref$multiselect,
|
|
17
|
+
_ref$gridfirstrowsele = _ref.gridfirstrowselect,
|
|
18
|
+
gridfirstrowselect = _ref$gridfirstrowsele === void 0 ? false : _ref$gridfirstrowsele,
|
|
19
|
+
internalDataset = _ref.internalDataset,
|
|
20
|
+
cellState = _ref.cellState,
|
|
21
|
+
name = _ref.name,
|
|
22
|
+
statehandler = _ref.statehandler,
|
|
23
|
+
initialActualPageSize = _ref.initialActualPageSize,
|
|
24
|
+
getTableCurrentState = _ref.getTableState;
|
|
25
|
+
// Keep a ref to always have the latest dataset
|
|
26
|
+
var datasetRef = (0, _react.useRef)(internalDataset);
|
|
27
|
+
(0, _react.useEffect)(function () {
|
|
28
|
+
datasetRef.current = internalDataset;
|
|
29
|
+
}, [internalDataset]);
|
|
30
|
+
|
|
31
|
+
// State only for forcing updates when needed
|
|
32
|
+
var _useState = (0, _react.useState)({}),
|
|
33
|
+
forceUpdate = _useState[1];
|
|
34
|
+
|
|
35
|
+
// Priority rule: If both radioselect and multiselect are true, multiselect takes precedence
|
|
36
|
+
var useMultiSelect = multiselect;
|
|
37
|
+
var useRadioSelect = radioselect && !multiselect;
|
|
38
|
+
|
|
39
|
+
// Helper function to save state immediately
|
|
40
|
+
var saveStateImmediate = (0, _react.useCallback)(function () {
|
|
41
|
+
if (!statehandler || !getTableCurrentState) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
var _getTableCurrentState = getTableCurrentState(),
|
|
45
|
+
currentPage = _getTableCurrentState.currentPage,
|
|
46
|
+
currentPageSize = _getTableCurrentState.currentPageSize;
|
|
47
|
+
|
|
48
|
+
// Get current selections
|
|
49
|
+
// If not multiselect, treat as radio select (single selection)
|
|
50
|
+
var selectedIds = useMultiSelect ? _selectionUtils.selectionStateHelpers.getMultiSelection(cellState) : _selectionUtils.selectionStateHelpers.getRadioSelection(cellState) ? [_selectionUtils.selectionStateHelpers.getRadioSelection(cellState)] : [];
|
|
51
|
+
|
|
52
|
+
// Find selected indices in current dataset
|
|
53
|
+
var selectedIndices = [];
|
|
54
|
+
selectedIds.forEach(function (rowId) {
|
|
55
|
+
var index = internalDataset.findIndex(function (row) {
|
|
56
|
+
return row._wmTableRowId === rowId || row.id === rowId;
|
|
57
|
+
});
|
|
58
|
+
if (index >= 0) {
|
|
59
|
+
selectedIndices.push(index);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Build selected items with page info
|
|
64
|
+
var selectedItemsWithPage = selectedIndices.map(function (idx) {
|
|
65
|
+
return {
|
|
66
|
+
page: currentPage,
|
|
67
|
+
index: idx
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
var stateToSave = {
|
|
71
|
+
pagination: currentPage,
|
|
72
|
+
selectedItem: selectedItemsWithPage
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// Include actualPageSize if available
|
|
76
|
+
if (initialActualPageSize !== undefined) {
|
|
77
|
+
stateToSave.actualpagesize = initialActualPageSize;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Check if this is default state
|
|
81
|
+
var isDefaultState = currentPage === 1 && selectedIds.length === 0;
|
|
82
|
+
if (isDefaultState) {
|
|
83
|
+
// Clear state if returning to default
|
|
84
|
+
(0, _tableHelpers.saveTableState)(name, statehandler, {});
|
|
85
|
+
} else {
|
|
86
|
+
// Get existing state
|
|
87
|
+
var existingState = (0, _tableHelpers.getTableState)(name, statehandler);
|
|
88
|
+
|
|
89
|
+
// For radio select or default mode (when neither multi nor radio is explicitly enabled),
|
|
90
|
+
// don't merge - just replace with current selection
|
|
91
|
+
if (useRadioSelect || !useMultiSelect) {
|
|
92
|
+
// Radio select or default mode should only have one item selected at a time
|
|
93
|
+
stateToSave.selectedItem = selectedItemsWithPage;
|
|
94
|
+
} else {
|
|
95
|
+
// For multi-select, merge selected items from different pages
|
|
96
|
+
if (existingState && existingState.selectedItem) {
|
|
97
|
+
var otherPageSelections = existingState.selectedItem.filter(function (item) {
|
|
98
|
+
return item.page !== currentPage;
|
|
99
|
+
});
|
|
100
|
+
stateToSave.selectedItem = [].concat((0, _toConsumableArray2["default"])(otherPageSelections), (0, _toConsumableArray2["default"])(selectedItemsWithPage));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Preserve pagesize if exists
|
|
105
|
+
if (existingState !== null && existingState !== void 0 && existingState.pagesize) {
|
|
106
|
+
stateToSave.pagesize = existingState.pagesize;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Preserve actualpagesize if exists and not in new state
|
|
110
|
+
if (!stateToSave.actualpagesize && existingState !== null && existingState !== void 0 && existingState.actualpagesize) {
|
|
111
|
+
stateToSave.actualpagesize = existingState.actualpagesize;
|
|
112
|
+
}
|
|
113
|
+
(0, _tableHelpers.saveTableState)(name, statehandler, stateToSave);
|
|
114
|
+
}
|
|
115
|
+
}, [statehandler, getTableCurrentState, name, useMultiSelect, useRadioSelect, cellState, internalDataset, initialActualPageSize]);
|
|
116
|
+
|
|
117
|
+
// Handle radio selection changes
|
|
118
|
+
var handleRadioSelection = (0, _react.useCallback)(function (rowId, rowData) {
|
|
119
|
+
_selectionUtils.selectionStateHelpers.setRadioSelection(cellState, rowId);
|
|
120
|
+
forceUpdate({});
|
|
121
|
+
saveStateImmediate(); // Save state immediately
|
|
122
|
+
}, [cellState, saveStateImmediate]);
|
|
123
|
+
|
|
124
|
+
// Handle multiselect checkbox changes
|
|
125
|
+
var handleMultiSelection = (0, _react.useCallback)(function (rowId, rowData, isSelected) {
|
|
126
|
+
if (isSelected) {
|
|
127
|
+
_selectionUtils.selectionStateHelpers.addToMultiSelection(cellState, rowId);
|
|
128
|
+
} else {
|
|
129
|
+
_selectionUtils.selectionStateHelpers.removeFromMultiSelection(cellState, rowId);
|
|
130
|
+
}
|
|
131
|
+
forceUpdate({});
|
|
132
|
+
saveStateImmediate(); // Save state immediately
|
|
133
|
+
}, [cellState, saveStateImmediate]);
|
|
134
|
+
|
|
135
|
+
// Toggle all rows selection for multiselect
|
|
136
|
+
var handleSelectAll = (0, _react.useCallback)(function (isSelected) {
|
|
137
|
+
if (isSelected) {
|
|
138
|
+
// Use ref to ensure we always have the latest dataset
|
|
139
|
+
var allRowIds = (0, _selectionUtils.getRowIdsFromDataset)(datasetRef.current);
|
|
140
|
+
_selectionUtils.selectionStateHelpers.setAllMultiSelection(cellState, allRowIds);
|
|
141
|
+
} else {
|
|
142
|
+
_selectionUtils.selectionStateHelpers.clearMultiSelection(cellState);
|
|
143
|
+
}
|
|
144
|
+
forceUpdate({});
|
|
145
|
+
saveStateImmediate(); // Save state immediately
|
|
146
|
+
}, [cellState, saveStateImmediate]);
|
|
147
|
+
|
|
148
|
+
// Handle row selection on click
|
|
149
|
+
var handleRowSelectionClick = (0, _react.useCallback)(function (event, rowId, rowData) {
|
|
150
|
+
// If clicking on an interactive element, don't handle row selection
|
|
151
|
+
if ((0, _selectionUtils.isInteractiveElement)(event)) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Handle multiselect if enabled
|
|
156
|
+
if (useMultiSelect) {
|
|
157
|
+
_selectionUtils.selectionStateHelpers.toggleMultiSelection(cellState, rowId);
|
|
158
|
+
saveStateImmediate(); // Save state immediately
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
// Handle radio selection if enabled (and multiselect is not)
|
|
162
|
+
else {
|
|
163
|
+
handleRadioSelection(rowId, rowData);
|
|
164
|
+
// No need to call saveStateImmediate here as handleRadioSelection already does it
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
}, [useMultiSelect, useRadioSelect, handleRadioSelection, cellState, saveStateImmediate]);
|
|
168
|
+
|
|
169
|
+
// First row selection logic
|
|
170
|
+
(0, _react.useEffect)(function () {
|
|
171
|
+
// Only proceed if gridfirstrowselect is true and we have data
|
|
172
|
+
if (gridfirstrowselect && internalDataset.length > 0) {
|
|
173
|
+
var firstRowData = internalDataset[0];
|
|
174
|
+
var firstRowId = firstRowData._wmTableRowId || String(firstRowData.id) || String(0);
|
|
175
|
+
if (useMultiSelect) {
|
|
176
|
+
// For multiselect, only add to selection if no rows are currently selected
|
|
177
|
+
var selectedIds = _selectionUtils.selectionStateHelpers.getMultiSelection(cellState);
|
|
178
|
+
if (selectedIds.length === 0) {
|
|
179
|
+
_selectionUtils.selectionStateHelpers.addToMultiSelection(cellState, firstRowId);
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
// For radio select or default mode (when neither is explicitly enabled),
|
|
183
|
+
// only select the first row if no row is currently selected
|
|
184
|
+
// or if the currently selected row no longer exists in the dataset
|
|
185
|
+
var currentSelectedId = _selectionUtils.selectionStateHelpers.getRadioSelection(cellState);
|
|
186
|
+
if (!currentSelectedId || !(0, _selectionUtils.rowExistsInDataset)(currentSelectedId, internalDataset)) {
|
|
187
|
+
handleRadioSelection(firstRowId, firstRowData);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}, [gridfirstrowselect, internalDataset, useMultiSelect, useRadioSelect, handleRadioSelection, cellState]);
|
|
192
|
+
|
|
193
|
+
// Check if a row is selected - memoized
|
|
194
|
+
var isRowSelected = (0, _react.useCallback)(function (rowId) {
|
|
195
|
+
return _selectionUtils.selectionStateHelpers.isRowSelected(cellState, rowId, useMultiSelect, useRadioSelect);
|
|
196
|
+
}, [useMultiSelect, useRadioSelect, cellState]);
|
|
197
|
+
|
|
198
|
+
// Get selected values without forcing re-renders
|
|
199
|
+
var selectedRowId = useRadioSelect ? _selectionUtils.selectionStateHelpers.getRadioSelection(cellState) : null;
|
|
200
|
+
var selectedRowIds = useMultiSelect ? _selectionUtils.selectionStateHelpers.getMultiSelection(cellState) : [];
|
|
201
|
+
return {
|
|
202
|
+
selectedRowId: selectedRowId,
|
|
203
|
+
selectedRowIds: selectedRowIds,
|
|
204
|
+
useMultiSelect: useMultiSelect,
|
|
205
|
+
useRadioSelect: useRadioSelect,
|
|
206
|
+
handleRadioSelection: handleRadioSelection,
|
|
207
|
+
handleMultiSelection: handleMultiSelection,
|
|
208
|
+
handleSelectAll: handleSelectAll,
|
|
209
|
+
handleRowSelectionClick: handleRowSelectionClick,
|
|
210
|
+
isRowSelected: isRowSelected,
|
|
211
|
+
isInteractiveElement: _selectionUtils.isInteractiveElement
|
|
212
|
+
};
|
|
213
|
+
};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useServerSideSorting = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
var _crudHandlers = require("../utils/crud-handlers");
|
|
12
|
+
var _utils = require("../utils");
|
|
13
|
+
/**
|
|
14
|
+
* Hook to handle server-side sorting for table data
|
|
15
|
+
*/
|
|
16
|
+
var useServerSideSorting = exports.useServerSideSorting = function useServerSideSorting(_ref) {
|
|
17
|
+
var datasource = _ref.datasource,
|
|
18
|
+
sorting = _ref.sorting,
|
|
19
|
+
setInternalDataset = _ref.setInternalDataset,
|
|
20
|
+
showToast = _ref.showToast,
|
|
21
|
+
isServerSidePagination = _ref.isServerSidePagination,
|
|
22
|
+
pageIndex = _ref.pageIndex,
|
|
23
|
+
onError = _ref.onError,
|
|
24
|
+
filterFields = _ref.filterFields,
|
|
25
|
+
logicalOp = _ref.logicalOp,
|
|
26
|
+
setLoading = _ref.setLoading;
|
|
27
|
+
var prevSortingRef = (0, _react.useRef)(sorting);
|
|
28
|
+
var prevPageRef = (0, _react.useRef)(pageIndex);
|
|
29
|
+
var prevFilterRef = (0, _react.useRef)("");
|
|
30
|
+
var isMountedRef = (0, _react.useRef)(false);
|
|
31
|
+
var isFetchingRef = (0, _react.useRef)(false);
|
|
32
|
+
|
|
33
|
+
// Determine if we should use server-side sorting
|
|
34
|
+
var isServerSideSorting = !!(datasource && isServerSidePagination);
|
|
35
|
+
|
|
36
|
+
// Convert TanStack sorting state to orderBy string
|
|
37
|
+
var convertSortingToOrderBy = (0, _react.useCallback)(function (sortingState) {
|
|
38
|
+
if (!sortingState || sortingState.length === 0) {
|
|
39
|
+
return "";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Map sorting state to orderBy format (e.g., "name asc, age desc")
|
|
43
|
+
return sortingState.map(function (sort) {
|
|
44
|
+
return "".concat(sort.id, " ").concat(sort.desc ? "desc" : "asc");
|
|
45
|
+
}).join(", ");
|
|
46
|
+
}, []);
|
|
47
|
+
|
|
48
|
+
// Fetch data with sorting
|
|
49
|
+
var fetchSortedData = (0, _react.useCallback)(/*#__PURE__*/function () {
|
|
50
|
+
var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(forcePage) {
|
|
51
|
+
var orderBy, currentPage, response, responseData, dataWithIds;
|
|
52
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
53
|
+
while (1) switch (_context.prev = _context.next) {
|
|
54
|
+
case 0:
|
|
55
|
+
if (!(!datasource || !isServerSideSorting || isFetchingRef.current)) {
|
|
56
|
+
_context.next = 2;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
return _context.abrupt("return");
|
|
60
|
+
case 2:
|
|
61
|
+
// Prevent duplicate fetches
|
|
62
|
+
isFetchingRef.current = true;
|
|
63
|
+
setLoading(true);
|
|
64
|
+
_context.prev = 4;
|
|
65
|
+
orderBy = convertSortingToOrderBy(sorting); // Use forcePage if provided (for sorting changes), otherwise use current page
|
|
66
|
+
currentPage = forcePage !== undefined ? forcePage : pageIndex + 1; // Convert 0-based to 1-based
|
|
67
|
+
_context.next = 9;
|
|
68
|
+
return (0, _crudHandlers.refreshDataSource)(datasource, {
|
|
69
|
+
orderBy: orderBy,
|
|
70
|
+
page: currentPage || 1,
|
|
71
|
+
filterFields: filterFields || {},
|
|
72
|
+
condition: logicalOp || ""
|
|
73
|
+
});
|
|
74
|
+
case 9:
|
|
75
|
+
response = _context.sent;
|
|
76
|
+
if (response) {
|
|
77
|
+
responseData = []; // Handle different response formats
|
|
78
|
+
if (response.data) {
|
|
79
|
+
responseData = response.data;
|
|
80
|
+
}
|
|
81
|
+
// Add unique row IDs to the server response data
|
|
82
|
+
dataWithIds = (0, _utils.addUniqueRowIds)(responseData);
|
|
83
|
+
setInternalDataset(dataWithIds);
|
|
84
|
+
}
|
|
85
|
+
_context.next = 18;
|
|
86
|
+
break;
|
|
87
|
+
case 13:
|
|
88
|
+
_context.prev = 13;
|
|
89
|
+
_context.t0 = _context["catch"](4);
|
|
90
|
+
console.error("Error fetching sorted data:", _context.t0);
|
|
91
|
+
if (showToast) {
|
|
92
|
+
showToast("Failed to sort data", "Error");
|
|
93
|
+
}
|
|
94
|
+
if (onError) {
|
|
95
|
+
onError("sort", _context.t0);
|
|
96
|
+
}
|
|
97
|
+
case 18:
|
|
98
|
+
_context.prev = 18;
|
|
99
|
+
isFetchingRef.current = false;
|
|
100
|
+
setLoading(false);
|
|
101
|
+
return _context.finish(18);
|
|
102
|
+
case 22:
|
|
103
|
+
case "end":
|
|
104
|
+
return _context.stop();
|
|
105
|
+
}
|
|
106
|
+
}, _callee, null, [[4, 13, 18, 22]]);
|
|
107
|
+
}));
|
|
108
|
+
return function (_x) {
|
|
109
|
+
return _ref2.apply(this, arguments);
|
|
110
|
+
};
|
|
111
|
+
}(), [datasource, isServerSideSorting, sorting, pageIndex, convertSortingToOrderBy, setInternalDataset, showToast, onError, filterFields, logicalOp]);
|
|
112
|
+
|
|
113
|
+
// Combined effect to handle sorting, pagination, and filter changes
|
|
114
|
+
(0, _react.useEffect)(function () {
|
|
115
|
+
// Skip if not server-side sorting
|
|
116
|
+
if (!isServerSideSorting) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Skip initial mount
|
|
121
|
+
if (!isMountedRef.current) {
|
|
122
|
+
isMountedRef.current = true;
|
|
123
|
+
prevSortingRef.current = sorting;
|
|
124
|
+
prevPageRef.current = pageIndex;
|
|
125
|
+
prevFilterRef.current = JSON.stringify({
|
|
126
|
+
filterFields: filterFields,
|
|
127
|
+
logicalOp: logicalOp
|
|
128
|
+
});
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Check what changed
|
|
133
|
+
var sortingString = JSON.stringify(sorting);
|
|
134
|
+
var prevSortingString = JSON.stringify(prevSortingRef.current);
|
|
135
|
+
var filterString = JSON.stringify({
|
|
136
|
+
filterFields: filterFields,
|
|
137
|
+
logicalOp: logicalOp
|
|
138
|
+
});
|
|
139
|
+
var sortingChanged = sortingString !== prevSortingString;
|
|
140
|
+
// const pageChanged = pageIndex !== prevPageRef.current;
|
|
141
|
+
var filterChanged = filterString !== prevFilterRef.current;
|
|
142
|
+
|
|
143
|
+
// Only fetch if something actually changed
|
|
144
|
+
if (sortingChanged || filterChanged) {
|
|
145
|
+
// Update refs before fetching to prevent duplicate calls
|
|
146
|
+
prevSortingRef.current = sorting;
|
|
147
|
+
prevPageRef.current = pageIndex;
|
|
148
|
+
prevFilterRef.current = filterString;
|
|
149
|
+
|
|
150
|
+
// When sorting or filter changes, fetch from page 1
|
|
151
|
+
fetchSortedData(1);
|
|
152
|
+
}
|
|
153
|
+
}, [sorting, pageIndex, filterFields, logicalOp, isServerSideSorting, fetchSortedData]);
|
|
154
|
+
|
|
155
|
+
// Custom sorting change handler
|
|
156
|
+
var handleSortingChange = (0, _react.useCallback)(function (updaterOrValue) {
|
|
157
|
+
// This will be called instead of the default setSorting
|
|
158
|
+
// We'll still update the sorting state, but also trigger server-side fetch
|
|
159
|
+
return updaterOrValue;
|
|
160
|
+
}, []);
|
|
161
|
+
return {
|
|
162
|
+
handleSortingChange: handleSortingChange,
|
|
163
|
+
isServerSideSorting: isServerSideSorting
|
|
164
|
+
};
|
|
165
|
+
};
|
|
@@ -0,0 +1,263 @@
|
|
|
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.useTableColumns = void 0;
|
|
9
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _material = require("@mui/material");
|
|
13
|
+
var _lodashEs = require("lodash-es");
|
|
14
|
+
var _utils = require("../utils");
|
|
15
|
+
var _renderDisplayCell = require("../utils/renderDisplayCell");
|
|
16
|
+
var _columnBuilder = require("../utils/columnBuilder");
|
|
17
|
+
var _columnWidthDistribution = require("../utils/columnWidthDistribution");
|
|
18
|
+
var _useResponsiveColumns = require("./useResponsiveColumns");
|
|
19
|
+
var _tableRowAction = _interopRequireDefault(require("../table-row-action"));
|
|
20
|
+
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); }
|
|
21
|
+
var __jsx = _react["default"].createElement;
|
|
22
|
+
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; }
|
|
23
|
+
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; }
|
|
24
|
+
// Extract action button rendering to reduce re-renders
|
|
25
|
+
var ActionButton = /*#__PURE__*/_react["default"].memo(function (_ref) {
|
|
26
|
+
var action = _ref.action,
|
|
27
|
+
index = _ref.index,
|
|
28
|
+
rowData = _ref.rowData,
|
|
29
|
+
rowIndex = _ref.rowIndex,
|
|
30
|
+
rowId = _ref.rowId,
|
|
31
|
+
listener = _ref.listener;
|
|
32
|
+
var actionKey = action.key || action.name;
|
|
33
|
+
var btnClass = (0, _utils.getActionButtonClass)(action);
|
|
34
|
+
return __jsx(_tableRowAction["default"], {
|
|
35
|
+
key: "row-action-".concat(index, "-").concat(actionKey),
|
|
36
|
+
name: action.name || "table-row-action-".concat(index, "-").concat(actionKey),
|
|
37
|
+
className: btnClass,
|
|
38
|
+
"data-action-key": actionKey,
|
|
39
|
+
displayName: action["displayName"] || "",
|
|
40
|
+
title: action.title,
|
|
41
|
+
iconclass: action.iconclass,
|
|
42
|
+
action: action.action,
|
|
43
|
+
row: rowData,
|
|
44
|
+
rowIndex: rowIndex,
|
|
45
|
+
listener: listener,
|
|
46
|
+
show: action.show,
|
|
47
|
+
onClick: action.onClick,
|
|
48
|
+
widgettype: action.widgettype
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
ActionButton.displayName = "ActionButton";
|
|
52
|
+
|
|
53
|
+
// Extract editing action buttons
|
|
54
|
+
var EditingActionButtons = /*#__PURE__*/_react["default"].memo(function (_ref2) {
|
|
55
|
+
var onSave = _ref2.onSave,
|
|
56
|
+
onCancel = _ref2.onCancel,
|
|
57
|
+
rowData = _ref2.rowData,
|
|
58
|
+
rowIndex = _ref2.rowIndex,
|
|
59
|
+
listener = _ref2.listener;
|
|
60
|
+
var buttons = (0, _columnBuilder.createEditingActionButtons)();
|
|
61
|
+
return __jsx(_react["default"].Fragment, null, buttons.map(function (button) {
|
|
62
|
+
return __jsx(_tableRowAction["default"], {
|
|
63
|
+
key: button.key,
|
|
64
|
+
name: button.name,
|
|
65
|
+
className: button.className,
|
|
66
|
+
"data-action-key": button.dataActionKey,
|
|
67
|
+
displayName: button.displayName,
|
|
68
|
+
title: button.title,
|
|
69
|
+
iconclass: button.iconclass,
|
|
70
|
+
action: button.action,
|
|
71
|
+
row: rowData,
|
|
72
|
+
rowIndex: rowIndex,
|
|
73
|
+
listener: listener,
|
|
74
|
+
show: button.show,
|
|
75
|
+
onClick: function onClick(event, widget) {
|
|
76
|
+
event === null || event === void 0 || event.preventDefault();
|
|
77
|
+
event === null || event === void 0 || event.stopPropagation();
|
|
78
|
+
button.key === "save-edit" ? onSave() : onCancel();
|
|
79
|
+
},
|
|
80
|
+
widgettype: button.widgettype
|
|
81
|
+
});
|
|
82
|
+
}));
|
|
83
|
+
});
|
|
84
|
+
EditingActionButtons.displayName = "EditingActionButtons";
|
|
85
|
+
var useTableColumns = exports.useTableColumns = function useTableColumns(_ref3) {
|
|
86
|
+
var wmTableColumns = _ref3.wmTableColumns,
|
|
87
|
+
rowActions = _ref3.rowActions,
|
|
88
|
+
listener = _ref3.listener,
|
|
89
|
+
deleteRecord = _ref3.deleteRecord,
|
|
90
|
+
showrowindex = _ref3.showrowindex,
|
|
91
|
+
editmode = _ref3.editmode,
|
|
92
|
+
renderEditableCell = _ref3.renderEditableCell,
|
|
93
|
+
isRowEditing = _ref3.isRowEditing,
|
|
94
|
+
startEditing = _ref3.startEditing,
|
|
95
|
+
cancelEditing = _ref3.cancelEditing,
|
|
96
|
+
saveEditing = _ref3.saveEditing,
|
|
97
|
+
cellState = _ref3.cellState,
|
|
98
|
+
isResizing = _ref3.isResizing;
|
|
99
|
+
// Filter columns based on viewport
|
|
100
|
+
var visibleColumns = (0, _useResponsiveColumns.useResponsiveColumns)(wmTableColumns);
|
|
101
|
+
|
|
102
|
+
// Memoize the cell render function to prevent re-renders
|
|
103
|
+
var renderCell = (0, _react.useCallback)(function (wmColumn, row) {
|
|
104
|
+
var rowId = row.original._wmTableRowId || row.id;
|
|
105
|
+
return __jsx(_material.Box, {
|
|
106
|
+
"data-col-identifier": wmColumn.field
|
|
107
|
+
}, (editmode === "inline" || editmode === "quickedit") && isRowEditing(rowId) && !wmColumn.readonly ? renderEditableCell(wmColumn, row.original, rowId) : (0, _renderDisplayCell.renderDisplayCell)(wmColumn, row.original, listener, cellState));
|
|
108
|
+
}, [editmode, isRowEditing, renderEditableCell, cellState, listener]);
|
|
109
|
+
|
|
110
|
+
// Filter row actions once
|
|
111
|
+
var filteredRowActions = (0, _react.useMemo)(function () {
|
|
112
|
+
if (editmode === "quickedit") {
|
|
113
|
+
return (0, _lodashEs.filter)(rowActions, function (action) {
|
|
114
|
+
return action.key === "deleterow" || action.action === "delete";
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return rowActions;
|
|
118
|
+
}, [rowActions, editmode]);
|
|
119
|
+
|
|
120
|
+
// Create action column cell renderer
|
|
121
|
+
var renderActionCell = (0, _react.useCallback)(function (_ref4) {
|
|
122
|
+
var row = _ref4.row;
|
|
123
|
+
var rowId = row.original._wmTableRowId || row.id;
|
|
124
|
+
var isEditing = isRowEditing(rowId);
|
|
125
|
+
return __jsx(_material.Box, {
|
|
126
|
+
component: "span",
|
|
127
|
+
className: "actions-column",
|
|
128
|
+
"data-identifier": "actionButtons"
|
|
129
|
+
}, isEditing && editmode !== "quickedit" ? __jsx(EditingActionButtons, {
|
|
130
|
+
onSave: saveEditing,
|
|
131
|
+
onCancel: cancelEditing,
|
|
132
|
+
rowData: row.original,
|
|
133
|
+
rowIndex: row.index,
|
|
134
|
+
listener: listener
|
|
135
|
+
}) : (0, _lodashEs.map)(filteredRowActions, function (action, index) {
|
|
136
|
+
return __jsx(ActionButton, {
|
|
137
|
+
key: "".concat(row.id, "-").concat(index),
|
|
138
|
+
action: action,
|
|
139
|
+
index: index,
|
|
140
|
+
rowData: row.original,
|
|
141
|
+
rowIndex: row.index,
|
|
142
|
+
rowId: rowId,
|
|
143
|
+
listener: listener
|
|
144
|
+
});
|
|
145
|
+
}));
|
|
146
|
+
}, [isRowEditing, editmode, filteredRowActions, saveEditing, cancelEditing, listener]);
|
|
147
|
+
|
|
148
|
+
// Create TanStack table column definitions
|
|
149
|
+
var columns = (0, _react.useMemo)(function () {
|
|
150
|
+
var columnDefs = [];
|
|
151
|
+
|
|
152
|
+
// Separate manual action column (binding="rowOperations") from regular columns
|
|
153
|
+
var manualActionColumn = visibleColumns.find(function (col) {
|
|
154
|
+
return col.binding === "rowOperations";
|
|
155
|
+
});
|
|
156
|
+
var dataColumns = visibleColumns.filter(function (col) {
|
|
157
|
+
return col.binding !== "rowOperations";
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// Add row index column if showrowindex is true
|
|
161
|
+
if (showrowindex) {
|
|
162
|
+
columnDefs.push((0, _columnBuilder.createRowIndexColumn)());
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Determine where to insert the actions column
|
|
166
|
+
var insertActionColumn = function insertActionColumn() {
|
|
167
|
+
// If we have a manual action column, create a custom action column with its properties
|
|
168
|
+
if (manualActionColumn) {
|
|
169
|
+
var _manualActionColumn$s;
|
|
170
|
+
var _getActionColumnSize = (0, _columnBuilder.getActionColumnSize)(editmode),
|
|
171
|
+
size = _getActionColumnSize.size,
|
|
172
|
+
minSize = _getActionColumnSize.minSize;
|
|
173
|
+
|
|
174
|
+
// Extract width from manual action column styles or width prop
|
|
175
|
+
var columnSize = size;
|
|
176
|
+
if (manualActionColumn.width) {
|
|
177
|
+
columnSize = parseInt(manualActionColumn.width);
|
|
178
|
+
} else if ((_manualActionColumn$s = manualActionColumn.styles) !== null && _manualActionColumn$s !== void 0 && _manualActionColumn$s.width) {
|
|
179
|
+
columnSize = (0, _utils.parseWidth)(manualActionColumn.styles.width);
|
|
180
|
+
}
|
|
181
|
+
columnDefs.push({
|
|
182
|
+
id: "actions",
|
|
183
|
+
header: manualActionColumn.caption || "Actions",
|
|
184
|
+
size: columnSize,
|
|
185
|
+
minSize: minSize,
|
|
186
|
+
enableResizing: true,
|
|
187
|
+
cell: renderActionCell,
|
|
188
|
+
enableSorting: manualActionColumn.sortable !== false,
|
|
189
|
+
meta: _objectSpread({
|
|
190
|
+
textAlign: manualActionColumn.textalignment,
|
|
191
|
+
backgroundColor: manualActionColumn.backgroundcolor,
|
|
192
|
+
className: manualActionColumn.colClass
|
|
193
|
+
}, manualActionColumn.styles)
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
// If no manual action column but we have row actions and editmode is not 'none'
|
|
197
|
+
else if (rowActions.length > 0 && editmode !== "none") {
|
|
198
|
+
var _getActionColumnSize2 = (0, _columnBuilder.getActionColumnSize)(editmode),
|
|
199
|
+
_size = _getActionColumnSize2.size,
|
|
200
|
+
_minSize = _getActionColumnSize2.minSize;
|
|
201
|
+
columnDefs.push({
|
|
202
|
+
id: "actions",
|
|
203
|
+
header: "Actions",
|
|
204
|
+
size: _size,
|
|
205
|
+
minSize: _minSize,
|
|
206
|
+
maxSize: _size,
|
|
207
|
+
// Fix the width for default action columns
|
|
208
|
+
enableResizing: false,
|
|
209
|
+
// Disable resizing for default action columns
|
|
210
|
+
cell: renderActionCell
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
// Handle action column positioning
|
|
216
|
+
if (manualActionColumn || rowActions.length > 0 && editmode !== "none") {
|
|
217
|
+
// For manual action column, use its rowactionsposition property
|
|
218
|
+
var position = (manualActionColumn === null || manualActionColumn === void 0 ? void 0 : manualActionColumn.rowactionsposition) !== undefined ? Number(manualActionColumn.rowactionsposition) : -1;
|
|
219
|
+
|
|
220
|
+
// Position 0 means right after system columns (row index, selection) but before data columns
|
|
221
|
+
if (position === 0) {
|
|
222
|
+
// Insert action column immediately after system columns
|
|
223
|
+
insertActionColumn();
|
|
224
|
+
// Then add all data columns
|
|
225
|
+
columnDefs.push.apply(columnDefs, (0, _toConsumableArray2["default"])((0, _columnBuilder.createDataColumns)(dataColumns, renderCell)));
|
|
226
|
+
}
|
|
227
|
+
// Positive position means insert at specific index among data columns
|
|
228
|
+
else if (position > 0 && position <= dataColumns.length) {
|
|
229
|
+
// Add data columns before position
|
|
230
|
+
var columnsBeforePosition = dataColumns.slice(0, position);
|
|
231
|
+
columnDefs.push.apply(columnDefs, (0, _toConsumableArray2["default"])((0, _columnBuilder.createDataColumns)(columnsBeforePosition, renderCell)));
|
|
232
|
+
|
|
233
|
+
// Insert action column
|
|
234
|
+
insertActionColumn();
|
|
235
|
+
|
|
236
|
+
// Add remaining data columns
|
|
237
|
+
var columnsAfterPosition = dataColumns.slice(position);
|
|
238
|
+
columnDefs.push.apply(columnDefs, (0, _toConsumableArray2["default"])((0, _columnBuilder.createDataColumns)(columnsAfterPosition, renderCell)));
|
|
239
|
+
}
|
|
240
|
+
// Default or -1: add action column at the end
|
|
241
|
+
else {
|
|
242
|
+
// Add all data columns first
|
|
243
|
+
columnDefs.push.apply(columnDefs, (0, _toConsumableArray2["default"])((0, _columnBuilder.createDataColumns)(dataColumns, renderCell)));
|
|
244
|
+
// Then add action column
|
|
245
|
+
insertActionColumn();
|
|
246
|
+
}
|
|
247
|
+
} else {
|
|
248
|
+
// No actions column needed, just add data columns
|
|
249
|
+
columnDefs.push.apply(columnDefs, (0, _toConsumableArray2["default"])((0, _columnBuilder.createDataColumns)(dataColumns, renderCell)));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Apply equal width distribution for data columns without explicit widths
|
|
253
|
+
// This ensures non-data columns (S.No, Actions, MultiSelect, RadioSelect) take minimum space
|
|
254
|
+
// while data columns without explicit widths share the remaining space equally
|
|
255
|
+
// Skip width distribution during active resizing to prevent infinite loops
|
|
256
|
+
return isResizing ? columnDefs : (0, _columnWidthDistribution.distributeColumnWidths)(columnDefs);
|
|
257
|
+
}, [visibleColumns, rowActions, showrowindex, editmode, renderCell, renderActionCell, isResizing]);
|
|
258
|
+
return {
|
|
259
|
+
columns: columns,
|
|
260
|
+
wmTableColumns: wmTableColumns,
|
|
261
|
+
rowActions: rowActions
|
|
262
|
+
};
|
|
263
|
+
};
|