@antscorp/antsomi-ui 1.3.5-beta.420 → 1.3.5-beta.421
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.
|
@@ -13,6 +13,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
13
13
|
import React, { useMemo } from 'react';
|
|
14
14
|
import { Resizable } from 'react-resizable';
|
|
15
15
|
import { MIN_COLUMN_WIDTH } from '../../constants';
|
|
16
|
+
// Components
|
|
17
|
+
import { Typography } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
16
18
|
export const ResizableCell = props => {
|
|
17
19
|
var _a;
|
|
18
20
|
const { width, handleProps, disableResize, children, style, fixed, index, tableRef, onResize, onResizeStop, onClick = () => { } } = props, restProps = __rest(props, ["width", "handleProps", "disableResize", "children", "style", "fixed", "index", "tableRef", "onResize", "onResizeStop", "onClick"]);
|
|
@@ -20,7 +22,7 @@ export const ResizableCell = props => {
|
|
|
20
22
|
const isResizing = React.useRef(false);
|
|
21
23
|
// Memos
|
|
22
24
|
const columnStyle = useMemo(() => (Object.assign(Object.assign({}, style), { zIndex: fixed ? 100 - (index || 0) : undefined })), [style, fixed, index]);
|
|
23
|
-
const CellHeaderContent = children;
|
|
25
|
+
const CellHeaderContent = (React.createElement(Typography.Text, { ellipsis: { tooltip: true }, style: { width: '100%' } }, children));
|
|
24
26
|
const isRowSelectionCol = (_a = props === null || props === void 0 ? void 0 : props.className) === null || _a === void 0 ? void 0 : _a.includes('antsomi-table-selection-column');
|
|
25
27
|
if (isRowSelectionCol || !width || disableResize) {
|
|
26
28
|
return (React.createElement("th", Object.assign({}, restProps, { style: columnStyle, onClick: onClick }), CellHeaderContent));
|
|
@@ -60,7 +60,7 @@ export const ToolbarActionButtons = memo(() => {
|
|
|
60
60
|
`${label}`.toUpperCase()));
|
|
61
61
|
// If customRender is exist then return custom render instead of render internal component
|
|
62
62
|
if (customRender)
|
|
63
|
-
return
|
|
63
|
+
return actionButton;
|
|
64
64
|
switch (key) {
|
|
65
65
|
case 'SEARCH': {
|
|
66
66
|
const _a = action, { addFilterInfo, onClickSearchItem, isAddFilterFromSearchItem } = _a, restOfAction = __rest(_a, ["addFilterInfo", "onClickSearchItem", "isAddFilterFromSearchItem"]);
|
|
@@ -55,6 +55,7 @@ const initialState = {
|
|
|
55
55
|
sorter: {},
|
|
56
56
|
};
|
|
57
57
|
export function useDataTableListing(props) {
|
|
58
|
+
var _a, _b;
|
|
58
59
|
// Props
|
|
59
60
|
const { config, name = 'default', table: tableProps, search: searchProps, filter: filterProps, } = props || {};
|
|
60
61
|
// Hooks
|
|
@@ -64,10 +65,10 @@ export function useDataTableListing(props) {
|
|
|
64
65
|
// Variables
|
|
65
66
|
const { env = appConfig === null || appConfig === void 0 ? void 0 : appConfig.env, auth = appConfig === null || appConfig === void 0 ? void 0 : appConfig.auth, api, object } = config;
|
|
66
67
|
const { column: apiColumn, filter: apiFilter, listing: apiListing, search: apiSearch, } = api || {};
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const
|
|
68
|
+
const _c = apiColumn || {}, { url: columnUrl = `${COLUMN_DOMAIN[env || 'development']}/api/column`, enabled: enabledApiColumn = true } = _c, restOfApiColumnRequest = __rest(_c, ["url", "enabled"]);
|
|
69
|
+
const _d = apiFilter || {}, { url: filterUrl = `${COLUMN_DOMAIN[env || 'development']}/api/filter`, enabled: enabledApiFilter = true } = _d, restOfApiFilterRequest = __rest(_d, ["url", "enabled"]);
|
|
70
|
+
const _e = apiListing || {}, { url: listingUrl = '', enabled: enabledApiListing = true } = _e, restOfApiListingRequest = __rest(_e, ["url", "enabled"]);
|
|
71
|
+
const _f = apiSearch || {}, { url: searchUrl = '', enabled: enabledApiSearch = true } = _f, restOfApiSearchRequest = __rest(_f, ["url", "enabled"]);
|
|
71
72
|
const { filters, selectedFilterId, pagination, selectedRowKeys, searchValue, table, sorter } = state;
|
|
72
73
|
const { externalFilters } = filterProps || {};
|
|
73
74
|
const modifyColumnAuth = Object.assign(Object.assign({}, auth), { url: columnUrl });
|
|
@@ -126,10 +127,13 @@ export function useDataTableListing(props) {
|
|
|
126
127
|
enabled: enabledApiFilter,
|
|
127
128
|
},
|
|
128
129
|
});
|
|
130
|
+
// Variables
|
|
131
|
+
const { data: modifyColumnsData, isLoading: isModifyColumnsLoading } = getModifyColumnList || {};
|
|
132
|
+
const modifyColumnSelected = useDeepCompareMemo(() => { var _a; return ((_a = modifyColumnsData === null || modifyColumnsData === void 0 ? void 0 : modifyColumnsData.find(({ isLasted }) => +isLasted === 1)) === null || _a === void 0 ? void 0 : _a.modifyColId) || ''; }, [modifyColumnsData]);
|
|
129
133
|
const getTableListing = useGetTableListing({
|
|
130
134
|
args: {
|
|
131
135
|
auth: listingAuth,
|
|
132
|
-
params: Object.assign({ limit: pagination.pageSize, page: pagination.page, filter: JSON.stringify(mapFiltersToApiFilters([...(filters || []), ...(externalFilters || [])])) }, ((sorter === null || sorter === void 0 ? void 0 : sorter.order) &&
|
|
136
|
+
params: Object.assign({ limit: pagination.pageSize, page: pagination.page, filter: JSON.stringify(mapFiltersToApiFilters([...(filters || []), ...(externalFilters || [])])), columns: JSON.stringify(((_b = (_a = modifyColumnsData === null || modifyColumnsData === void 0 ? void 0 : modifyColumnsData.find(modifyColumnItem => modifyColumnItem.modifyColId === modifyColumnSelected)) === null || _a === void 0 ? void 0 : _a.columns) === null || _b === void 0 ? void 0 : _b.map(col => { var _a; return (_a = col.metricCode) === null || _a === void 0 ? void 0 : _a.toUpperCase(); })) || []) }, ((sorter === null || sorter === void 0 ? void 0 : sorter.order) &&
|
|
133
137
|
(sorter === null || sorter === void 0 ? void 0 : sorter.columnKey) && {
|
|
134
138
|
sort: sorter.columnKey.toString(),
|
|
135
139
|
az: SORT_MAP[sorter.order],
|
|
@@ -154,7 +158,6 @@ export function useDataTableListing(props) {
|
|
|
154
158
|
});
|
|
155
159
|
// Variables
|
|
156
160
|
const { data: columnMetricsData } = getColumnMetrics || {};
|
|
157
|
-
const { data: modifyColumnsData, isLoading: isModifyColumnsLoading } = getModifyColumnList || {};
|
|
158
161
|
const { data: savedFiltersData } = getSavedFilterList || {};
|
|
159
162
|
const { data: filterMetricsData } = getFilterMetricList || {};
|
|
160
163
|
const { data: tableListing, isLoading: isTableListingLoading, isRefetching: isTableListingRefetching, refetch: refetchTableListing, } = getTableListing || {};
|
|
@@ -202,7 +205,6 @@ export function useDataTableListing(props) {
|
|
|
202
205
|
removable: !MODIFY_COLUMN_DISABLE_REMOVE.includes(modifyName),
|
|
203
206
|
metrics: columns === null || columns === void 0 ? void 0 : columns.map(({ metricCode, metricId }) => metricCode || metricId || -1),
|
|
204
207
|
})).reverse()) || [], [modifyColumnsData]);
|
|
205
|
-
const modifyColumnSelected = useDeepCompareMemo(() => { var _a; return ((_a = modifyColumnsData === null || modifyColumnsData === void 0 ? void 0 : modifyColumnsData.find(({ isLasted }) => +isLasted === 1)) === null || _a === void 0 ? void 0 : _a.modifyColId) || ''; }, [modifyColumnsData]);
|
|
206
208
|
const filterMetrics = useDeepCompareMemo(() => {
|
|
207
209
|
const serializeFilterMetrics = (metrics) => {
|
|
208
210
|
const result = metrics.map(metric => {
|
|
@@ -322,7 +324,7 @@ export function useDataTableListing(props) {
|
|
|
322
324
|
}, 500);
|
|
323
325
|
}, [mapObject, refetchTableListing, updateModifyColumn]);
|
|
324
326
|
const onApplyModifyColumn = useCallback((args) => __awaiter(this, void 0, void 0, function* () {
|
|
325
|
-
var
|
|
327
|
+
var _g;
|
|
326
328
|
const { selectedMetrics, columnSetName, existColumnSet } = args || {};
|
|
327
329
|
const flattenMetrics = flatTree(columnMetricsData, 'child');
|
|
328
330
|
const selectedColumnMetrics = selectedMetrics
|
|
@@ -335,7 +337,7 @@ export function useDataTableListing(props) {
|
|
|
335
337
|
exitModifyColumnId = (existColumnSet === null || existColumnSet === void 0 ? void 0 : existColumnSet.id) || '';
|
|
336
338
|
if (columnSetName === '') {
|
|
337
339
|
exitModifyColumnId =
|
|
338
|
-
((
|
|
340
|
+
((_g = modifyColumnsData === null || modifyColumnsData === void 0 ? void 0 : modifyColumnsData.find(modifyColumn => modifyColumn.modifyName === 'Custom')) === null || _g === void 0 ? void 0 : _g.modifyColId) || '';
|
|
339
341
|
}
|
|
340
342
|
}
|
|
341
343
|
/**
|