@antscorp/antsomi-ui 1.3.5-beta.414 → 1.3.5-beta.415
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/es/components/organism/DataTable/components/AddButton/index.js +1 -0
- package/es/components/organism/DataTable/components/Toolbar/index.js +8 -1
- package/es/components/organism/DataTable/hooks/useDataTableListing/types.d.ts +3 -0
- package/es/components/organism/DataTable/hooks/useDataTableListing/useDataTableListing.js +9 -2
- package/es/constants/queries.d.ts +1 -0
- package/es/constants/queries.js +1 -0
- package/es/queries/DataTable/index.js +2 -2
- package/package.json +1 -1
|
@@ -22,6 +22,7 @@ const StyledAddButton = styled(Flex) `
|
|
|
22
22
|
height: 30px;
|
|
23
23
|
background-color: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.colorPrimary};
|
|
24
24
|
color: #fff;
|
|
25
|
+
flex-shrink: 0;
|
|
25
26
|
cursor: pointer;
|
|
26
27
|
`;
|
|
27
28
|
export const AddButton = memo(props => {
|
|
@@ -38,7 +38,13 @@ export const Toolbar = memo(() => {
|
|
|
38
38
|
if (addButtonComponent) {
|
|
39
39
|
return (React.createElement(React.Fragment, null,
|
|
40
40
|
addButtonComponent,
|
|
41
|
-
React.createElement(Divider, { dashed: true, type: "vertical", style: {
|
|
41
|
+
React.createElement(Divider, { dashed: true, type: "vertical", style: {
|
|
42
|
+
height: 38,
|
|
43
|
+
margin: '0px 10px',
|
|
44
|
+
borderWidth: 2,
|
|
45
|
+
borderSpacing: 5,
|
|
46
|
+
borderLeftStyle: 'dotted',
|
|
47
|
+
} })));
|
|
42
48
|
}
|
|
43
49
|
return null;
|
|
44
50
|
};
|
|
@@ -54,6 +60,7 @@ export const Toolbar = memo(() => {
|
|
|
54
60
|
margin: '0px 5px',
|
|
55
61
|
borderWidth: 2,
|
|
56
62
|
borderSpacing: 5,
|
|
63
|
+
borderLeftStyle: 'dotted',
|
|
57
64
|
} }),
|
|
58
65
|
React.createElement(CollapseButton, { "$collapsed": !!collapsed, onClick: () => onCollapse && onCollapse(!collapsed) },
|
|
59
66
|
React.createElement(Icon, { type: "icon-ants-angle-down", size: 12 })))))) : (React.createElement(FilterActionButton, null))));
|
|
@@ -47,6 +47,9 @@ export interface UseDataTableListingProps<TTableType = any, TSearchType = any> {
|
|
|
47
47
|
itemMapKeys: Record<keyof Omit<TSearchItem, 'icon' | 'link'>, keyof TSearchType>;
|
|
48
48
|
render?: (record: TSearchType, index: number, node: ReactNode) => ReactNode;
|
|
49
49
|
};
|
|
50
|
+
filter?: {
|
|
51
|
+
externalFilters?: FilterItem[];
|
|
52
|
+
};
|
|
50
53
|
}
|
|
51
54
|
export interface DataTableLocalStorage {
|
|
52
55
|
filter?: {
|
|
@@ -54,7 +54,7 @@ const initialState = {
|
|
|
54
54
|
};
|
|
55
55
|
export function useDataTableListing(props) {
|
|
56
56
|
// Props
|
|
57
|
-
const { config, name = 'default', table: tableProps, search: searchProps } = props || {};
|
|
57
|
+
const { config, name = 'default', table: tableProps, search: searchProps, filter: filterProps, } = props || {};
|
|
58
58
|
// Hooks
|
|
59
59
|
const { appConfig } = useAppConfigContext();
|
|
60
60
|
// State
|
|
@@ -67,6 +67,7 @@ export function useDataTableListing(props) {
|
|
|
67
67
|
const _c = apiListing || {}, { url: listingUrl = '', enabled: enabledApiListing = true } = _c, restOfApiListingRequest = __rest(_c, ["url", "enabled"]);
|
|
68
68
|
const _d = apiSearch || {}, { url: searchUrl = '', enabled: enabledApiSearch = true } = _d, restOfApiSearchRequest = __rest(_d, ["url", "enabled"]);
|
|
69
69
|
const { filters, selectedFilterId, pagination, selectedRowKeys, searchValue } = state;
|
|
70
|
+
const { externalFilters } = filterProps || {};
|
|
70
71
|
const modifyColumnAuth = Object.assign(Object.assign({}, auth), { url: columnUrl });
|
|
71
72
|
const filterAuth = Object.assign(Object.assign({}, auth), { url: filterUrl });
|
|
72
73
|
const listingAuth = Object.assign(Object.assign({}, auth), { url: listingUrl });
|
|
@@ -129,7 +130,7 @@ export function useDataTableListing(props) {
|
|
|
129
130
|
params: {
|
|
130
131
|
limit: pagination.pageSize,
|
|
131
132
|
page: pagination.page,
|
|
132
|
-
filter: JSON.stringify(mapFiltersToApiFilters(filters || [])),
|
|
133
|
+
filter: JSON.stringify(mapFiltersToApiFilters([...(filters || []), ...(externalFilters || [])])),
|
|
133
134
|
},
|
|
134
135
|
request: restOfApiListingRequest,
|
|
135
136
|
},
|
|
@@ -285,6 +286,12 @@ export function useDataTableListing(props) {
|
|
|
285
286
|
setState(prev => (Object.assign(Object.assign({}, prev), { pagination })));
|
|
286
287
|
}
|
|
287
288
|
}, [localStorageValues]);
|
|
289
|
+
// /** Update filters from external filters */
|
|
290
|
+
// useDeepCompareEffect(() => {
|
|
291
|
+
// if (externalFilters) {
|
|
292
|
+
// setState(prev => ({ ...prev, filters: [...(filters || []), ...externalFilters] }));
|
|
293
|
+
// }
|
|
294
|
+
// }, [externalFilters]);
|
|
288
295
|
// Handlers
|
|
289
296
|
/* Modify Column */
|
|
290
297
|
const handleUpdatePagination = useCallback((pagination) => {
|
|
@@ -28,6 +28,7 @@ export declare const QUERY_KEYS: {
|
|
|
28
28
|
GET_RECENT_ACCOUNT: string;
|
|
29
29
|
GET_ABSTRACT_USERS: string;
|
|
30
30
|
GET_COLUMN_METRICS: string;
|
|
31
|
+
GET_DATA_TABLE_LISTING: string;
|
|
31
32
|
GET_MODIFY_COLUMN_LIST: string;
|
|
32
33
|
GET_SAVED_FILTER_LIST: string;
|
|
33
34
|
GET_FILTER_METRIC_LIST: string;
|
package/es/constants/queries.js
CHANGED
|
@@ -41,6 +41,7 @@ export const QUERY_KEYS = {
|
|
|
41
41
|
GET_ABSTRACT_USERS: 'GET_ABSTRACT_USERS',
|
|
42
42
|
// DATA TABLE
|
|
43
43
|
GET_COLUMN_METRICS: 'GET_COLUMN_METRICS',
|
|
44
|
+
GET_DATA_TABLE_LISTING: 'GET_DATA_TABLE_LISTING',
|
|
44
45
|
GET_MODIFY_COLUMN_LIST: 'GET_MODIFY_COLUMN_LIST',
|
|
45
46
|
GET_SAVED_FILTER_LIST: 'GET_SAVED_FILTER_LIST',
|
|
46
47
|
GET_FILTER_METRIC_LIST: 'GET_FILTER_METRIC_LIST',
|
|
@@ -4,7 +4,7 @@ import { useMutation, useQuery, useQueryClient, } from '@tanstack/react-query';
|
|
|
4
4
|
import { dataTableServices, } from '../../services/DataTable';
|
|
5
5
|
// Constants
|
|
6
6
|
import { QUERY_KEYS } from '../../constants';
|
|
7
|
-
const { GET_COLUMN_METRICS, GET_MODIFY_COLUMN_LIST, GET_SAVED_FILTER_LIST, GET_FILTER_METRIC_LIST, GET_SEARCH_LIST, } = QUERY_KEYS;
|
|
7
|
+
const { GET_COLUMN_METRICS, GET_MODIFY_COLUMN_LIST, GET_SAVED_FILTER_LIST, GET_FILTER_METRIC_LIST, GET_SEARCH_LIST, GET_DATA_TABLE_LISTING, } = QUERY_KEYS;
|
|
8
8
|
/* Column */
|
|
9
9
|
export const useGetColumnMetrics = (params) => {
|
|
10
10
|
const { args, options } = params;
|
|
@@ -80,7 +80,7 @@ export const useDeleteSavedFilter = (params) => {
|
|
|
80
80
|
/* Table Listing */
|
|
81
81
|
export const useGetTableListing = (params) => {
|
|
82
82
|
const { options, args } = params || {};
|
|
83
|
-
return useQuery(Object.assign({ queryKey: [
|
|
83
|
+
return useQuery(Object.assign({ queryKey: [GET_DATA_TABLE_LISTING, args === null || args === void 0 ? void 0 : args.params, args === null || args === void 0 ? void 0 : args.request], queryFn: () => dataTableServices.listing.getTableListing(args) }, options));
|
|
84
84
|
};
|
|
85
85
|
export const useGetSearchListing = (params) => {
|
|
86
86
|
const { args, options } = params || {};
|