@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.
@@ -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
- React.createElement(Flex, { align: "center", gap: 10 },
45
- React.createElement(Text, null,
46
- t(translations.pagination.showRow).toString(),
47
- ":"),
48
- React.createElement(Select, { defaultValue: DEFAULT_PAGE_SIZE, value: pageSize, className: "show-row-select", options: paginationSizeOptions, popupMatchSelectWidth: 70, onChange: value => onChangePagination({ pageSize: value, page: 1 }) })),
49
- React.createElement(Text, null, `${total ? page * pageSize - pageSize + 1 : 0} - ${Math.min(page * pageSize, total)} of ${total}`),
50
- React.createElement(Flex, { align: "center", gap: 10 },
51
- React.createElement(ActionButton, { onClick: () => onChangePagination({ page: 1 }), disabled: disabledPrevious },
52
- React.createElement(Icon, { type: "icon-ants-first-page", size: 12 })),
53
- React.createElement(ActionButton, { disabled: disabledPrevious, onClick: () => onChangePagination({ page: page - 1 }) },
54
- React.createElement(Icon, { type: "icon-ants-angle-left", size: 12 })),
55
- React.createElement(ActionButton, { disabled: disabledNext, onClick: () => onChangePagination({ page: page + 1 }) },
56
- React.createElement(Icon, { type: "icon-ants-angle-right", size: 12 })),
57
- React.createElement(ActionButton, { onClick: () => onChangePagination({ page: Math.ceil(total / pageSize) }), disabled: disabledNext },
58
- React.createElement(Icon, { type: "icon-ants-last-page", size: 12 })))));
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
- height: 60px;
8
+ flex-shrink: 0;
9
+ min-height: 40px;
9
10
 
10
11
  .show-row-select {
11
12
  width: 50px;
@@ -69,6 +69,10 @@ export const StyledTable = styled(Table) `
69
69
  .antsomi-table-cell[aria-resizable='true'] {
70
70
  border-inline-end: 2px solid ${blue1} !important;
71
71
  }
72
+
73
+ .antsomi-table-cell {
74
+ overflow: hidden;
75
+ }
72
76
  }
73
77
  }
74
78
 
@@ -9,11 +9,6 @@ export const DataTableWrapper = styled.div `
9
9
  position: relative;
10
10
  width: 100%;
11
11
  height: 100%;
12
-
13
- #data-table-pagination {
14
- margin-top: 5px;
15
- justify-content: flex-end;
16
- }
17
12
  `;
18
13
  export const IconButton = styled.div `
19
14
  width: 20px;
@@ -10,6 +10,7 @@ export type DataTableHeaderItem = {
10
10
  label: string;
11
11
  name: string;
12
12
  sortable: boolean;
13
+ isSort?: string;
13
14
  type: number;
14
15
  };
15
16
  export type DataTableColumnDefItem = {
@@ -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;
@@ -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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.523",
3
+ "version": "1.3.5-beta.524",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",