@antscorp/antsomi-ui 1.3.5-beta.523 → 1.3.5-beta.524
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/Pagination/index.d.ts +2 -1
- package/es/components/organism/DataTable/components/Pagination/index.js +19 -17
- package/es/components/organism/DataTable/components/Pagination/styled.js +2 -1
- package/es/components/organism/DataTable/components/Table/styled.js +4 -0
- package/es/components/organism/DataTable/styled/index.js +0 -5
- package/es/models/DataTable/DataTableListing.d.ts +1 -0
- package/es/utils/dataTable.d.ts +1 -0
- package/es/utils/dataTable.js +19 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
import { FlexProps } from 'antd/lib';
|
|
3
3
|
export type TChangePageSizePayload = {
|
|
4
4
|
pageSize: number;
|
|
@@ -8,6 +8,7 @@ export interface PaginationProps extends Omit<FlexProps, 'children' | 'onChange'
|
|
|
8
8
|
page?: number;
|
|
9
9
|
pageSize?: number;
|
|
10
10
|
total?: number;
|
|
11
|
+
extraContent?: ReactNode;
|
|
11
12
|
onChange?: (payload: TChangePageSizePayload) => void;
|
|
12
13
|
}
|
|
13
14
|
export declare const Pagination: React.FC<PaginationProps>;
|
|
@@ -25,7 +25,7 @@ import { DEFAULT_PAGE, DEFAULT_PAGE_SIZE, PAGE_SIZE_OPTIONS } from '../../consta
|
|
|
25
25
|
const { Text } = Typography;
|
|
26
26
|
export const Pagination = props => {
|
|
27
27
|
// Props
|
|
28
|
-
const { pageSize = DEFAULT_PAGE_SIZE, page = DEFAULT_PAGE, total = 0, onChange } = props, restProps = __rest(props, ["pageSize", "page", "total", "onChange"]);
|
|
28
|
+
const { pageSize = DEFAULT_PAGE_SIZE, page = DEFAULT_PAGE, total = 0, extraContent, onChange } = props, restProps = __rest(props, ["pageSize", "page", "total", "extraContent", "onChange"]);
|
|
29
29
|
// Instance
|
|
30
30
|
const { t } = i18nInstance;
|
|
31
31
|
// Memo
|
|
@@ -40,20 +40,22 @@ export const Pagination = props => {
|
|
|
40
40
|
pageSize }, payload));
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
-
return (React.createElement(PaginationWrapper, Object.assign({ align: "center", gap: 10 }, restProps),
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
React.createElement(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
43
|
+
return (React.createElement(PaginationWrapper, Object.assign({ align: "center", justify: extraContent ? 'space-between' : 'flex-end', gap: 10 }, restProps),
|
|
44
|
+
extraContent,
|
|
45
|
+
React.createElement(Flex, { align: "center", gap: 10, style: { flexShrink: 0, height: 'fit-content', alignSelf: 'flex-end' } },
|
|
46
|
+
React.createElement(Flex, { align: "center", gap: 10 },
|
|
47
|
+
React.createElement(Text, null,
|
|
48
|
+
t(translations.pagination.showRow).toString(),
|
|
49
|
+
":"),
|
|
50
|
+
React.createElement(Select, { defaultValue: DEFAULT_PAGE_SIZE, value: pageSize, className: "show-row-select", options: paginationSizeOptions, popupMatchSelectWidth: 70, onChange: value => onChangePagination({ pageSize: value, page: 1 }) })),
|
|
51
|
+
React.createElement(Text, null, `${total ? page * pageSize - pageSize + 1 : 0} - ${Math.min(page * pageSize, total)} of ${total}`),
|
|
52
|
+
React.createElement(Flex, { align: "center", gap: 10 },
|
|
53
|
+
React.createElement(ActionButton, { onClick: () => onChangePagination({ page: 1 }), disabled: disabledPrevious },
|
|
54
|
+
React.createElement(Icon, { type: "icon-ants-first-page", size: 12 })),
|
|
55
|
+
React.createElement(ActionButton, { disabled: disabledPrevious, onClick: () => onChangePagination({ page: page - 1 }) },
|
|
56
|
+
React.createElement(Icon, { type: "icon-ants-angle-left", size: 12 })),
|
|
57
|
+
React.createElement(ActionButton, { disabled: disabledNext, onClick: () => onChangePagination({ page: page + 1 }) },
|
|
58
|
+
React.createElement(Icon, { type: "icon-ants-angle-right", size: 12 })),
|
|
59
|
+
React.createElement(ActionButton, { onClick: () => onChangePagination({ page: Math.ceil(total / pageSize) }), disabled: disabledNext },
|
|
60
|
+
React.createElement(Icon, { type: "icon-ants-last-page", size: 12 }))))));
|
|
59
61
|
};
|
|
@@ -5,7 +5,8 @@ import { Flex } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
|
5
5
|
// Constants
|
|
6
6
|
import { globalToken } from '@antscorp/antsomi-ui/es/constants';
|
|
7
7
|
export const PaginationWrapper = styled(Flex) `
|
|
8
|
-
|
|
8
|
+
flex-shrink: 0;
|
|
9
|
+
min-height: 40px;
|
|
9
10
|
|
|
10
11
|
.show-row-select {
|
|
11
12
|
width: 50px;
|
package/es/utils/dataTable.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DataTableColumnDefItem, DataTableHeaderItem } from '../models/DataTable/DataTableListing';
|
|
2
2
|
export declare const mapColumnDefItemToGeneral: (columnDefItem: DataTableColumnDefItem) => DataTableHeaderItem;
|
|
3
|
+
export declare const mapColumnToGeneral: ({ sortable, isSort, ...restOfColumn }: DataTableHeaderItem) => DataTableHeaderItem;
|
|
3
4
|
export declare const mapResponseListingToGeneral: (response: Record<string, any>) => {
|
|
4
5
|
body: any;
|
|
5
6
|
header: any;
|
package/es/utils/dataTable.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
export const mapColumnDefItemToGeneral = (columnDefItem) => ({
|
|
2
13
|
editable: false,
|
|
3
14
|
fixColumn: false,
|
|
@@ -6,13 +17,19 @@ export const mapColumnDefItemToGeneral = (columnDefItem) => ({
|
|
|
6
17
|
sortable: !!parseInt(columnDefItem.enableSorting),
|
|
7
18
|
type: parseInt(columnDefItem.type),
|
|
8
19
|
});
|
|
20
|
+
export const mapColumnToGeneral = (_a) => {
|
|
21
|
+
var { sortable, isSort } = _a, restOfColumn = __rest(_a, ["sortable", "isSort"]);
|
|
22
|
+
return (Object.assign(Object.assign({}, restOfColumn), {
|
|
23
|
+
/** Convert isSort to boolean */
|
|
24
|
+
sortable: isSort === '1' ? true : sortable }));
|
|
25
|
+
};
|
|
9
26
|
// NOTES: Improve typescript
|
|
10
27
|
export const mapResponseListingToGeneral = (response) => {
|
|
11
28
|
const { body, header, total, entries, column_defs, rows, total_records } = response || {};
|
|
12
29
|
return {
|
|
13
30
|
body: body || entries || rows || [],
|
|
14
|
-
header: header ||
|
|
15
|
-
column_defs.map(columnDefItem => mapColumnDefItemToGeneral(columnDefItem || {})) ||
|
|
31
|
+
header: (header === null || header === void 0 ? void 0 : header.map(col => mapColumnToGeneral(col || {}))) ||
|
|
32
|
+
(column_defs === null || column_defs === void 0 ? void 0 : column_defs.map(columnDefItem => mapColumnDefItemToGeneral(columnDefItem || {}))) ||
|
|
16
33
|
[],
|
|
17
34
|
total: total || total_records || 0,
|
|
18
35
|
};
|