namirasoft-site-react 1.3.251 → 1.3.254
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/dist/App.js +1 -1
- package/dist/App.js.map +1 -1
- package/dist/components/NSBoxBoolean.d.ts +6 -7
- package/dist/components/NSBoxBoolean.js +8 -12
- package/dist/components/NSBoxBoolean.js.map +1 -1
- package/dist/components/NSBoxDate.d.ts +3 -2
- package/dist/components/NSBoxDate.js +5 -7
- package/dist/components/NSBoxDate.js.map +1 -1
- package/dist/components/NSBoxDateTime.d.ts +3 -2
- package/dist/components/NSBoxDateTime.js +5 -7
- package/dist/components/NSBoxDateTime.js.map +1 -1
- package/dist/components/NSBoxDouble.d.ts +3 -2
- package/dist/components/NSBoxDouble.js +5 -7
- package/dist/components/NSBoxDouble.js.map +1 -1
- package/dist/components/NSBoxDuration.d.ts +3 -2
- package/dist/components/NSBoxDuration.js +5 -7
- package/dist/components/NSBoxDuration.js.map +1 -1
- package/dist/components/NSBoxEmail.d.ts +3 -2
- package/dist/components/NSBoxEmail.js +6 -8
- package/dist/components/NSBoxEmail.js.map +1 -1
- package/dist/components/NSBoxEntity.d.ts +6 -3
- package/dist/components/NSBoxEntity.js +13 -10
- package/dist/components/NSBoxEntity.js.map +1 -1
- package/dist/components/NSBoxEnum.d.ts +3 -2
- package/dist/components/NSBoxEnum.js +5 -8
- package/dist/components/NSBoxEnum.js.map +1 -1
- package/dist/components/NSBoxErrorNotifier.d.ts +1 -0
- package/dist/components/NSBoxErrorNotifier.js +5 -1
- package/dist/components/NSBoxErrorNotifier.js.map +1 -1
- package/dist/components/NSBoxIPV4.d.ts +3 -2
- package/dist/components/NSBoxIPV4.js +5 -7
- package/dist/components/NSBoxIPV4.js.map +1 -1
- package/dist/components/NSBoxIPV6.d.ts +3 -2
- package/dist/components/NSBoxIPV6.js +5 -7
- package/dist/components/NSBoxIPV6.js.map +1 -1
- package/dist/components/NSBoxInteger.d.ts +3 -2
- package/dist/components/NSBoxInteger.js +5 -7
- package/dist/components/NSBoxInteger.js.map +1 -1
- package/dist/components/NSBoxLabel.d.ts +2 -1
- package/dist/components/NSBoxLabel.js +2 -1
- package/dist/components/NSBoxLabel.js.map +1 -1
- package/dist/components/NSBoxOTP.d.ts +2 -0
- package/dist/components/NSBoxOTP.js +2 -1
- package/dist/components/NSBoxOTP.js.map +1 -1
- package/dist/components/NSBoxPassword.d.ts +3 -2
- package/dist/components/NSBoxPassword.js +5 -7
- package/dist/components/NSBoxPassword.js.map +1 -1
- package/dist/components/NSBoxPhone.d.ts +3 -2
- package/dist/components/NSBoxPhone.js +1 -4
- package/dist/components/NSBoxPhone.js.map +1 -1
- package/dist/components/NSBoxPrice.d.ts +3 -2
- package/dist/components/NSBoxPrice.js +6 -8
- package/dist/components/NSBoxPrice.js.map +1 -1
- package/dist/components/NSBoxString.d.ts +3 -2
- package/dist/components/NSBoxString.js +6 -8
- package/dist/components/NSBoxString.js.map +1 -1
- package/dist/components/NSBoxTextArea.d.ts +3 -2
- package/dist/components/NSBoxTextArea.js +7 -9
- package/dist/components/NSBoxTextArea.js.map +1 -1
- package/dist/components/NSBoxTime.d.ts +3 -2
- package/dist/components/NSBoxTime.js +5 -7
- package/dist/components/NSBoxTime.js.map +1 -1
- package/dist/components/NSFilterBoxDialog.js +1 -1
- package/dist/components/NSGroupedList.module.css +1 -0
- package/dist/components/NSPagination.d.ts +15 -2
- package/dist/components/NSPagination.js +73 -44
- package/dist/components/NSPagination.js.map +1 -1
- package/dist/components/NSTable.d.ts +4 -3
- package/dist/components/NSTable.js +8 -6
- package/dist/components/NSTable.js.map +1 -1
- package/dist/props/IBaseComponentProps.d.ts +1 -0
- package/package.json +2 -2
- package/src/App.tsx +2 -2
- package/src/components/NSBoxBoolean.tsx +18 -27
- package/src/components/NSBoxDate.tsx +14 -15
- package/src/components/NSBoxDateTime.tsx +14 -15
- package/src/components/NSBoxDouble.tsx +15 -17
- package/src/components/NSBoxDuration.tsx +14 -14
- package/src/components/NSBoxEmail.tsx +19 -18
- package/src/components/NSBoxEntity.tsx +23 -14
- package/src/components/NSBoxEnum.tsx +10 -13
- package/src/components/NSBoxErrorNotifier.tsx +7 -1
- package/src/components/NSBoxIPV4.tsx +14 -14
- package/src/components/NSBoxIPV6.tsx +14 -14
- package/src/components/NSBoxInteger.tsx +14 -14
- package/src/components/NSBoxLabel.tsx +3 -2
- package/src/components/NSBoxOTP.tsx +19 -15
- package/src/components/NSBoxPassword.tsx +14 -14
- package/src/components/NSBoxPhone.tsx +4 -9
- package/src/components/NSBoxPrice.tsx +15 -15
- package/src/components/NSBoxString.tsx +16 -16
- package/src/components/NSBoxTextArea.tsx +13 -17
- package/src/components/NSBoxTime.tsx +14 -14
- package/src/components/NSFilterBoxDialog.tsx +2 -2
- package/src/components/NSGroupedList.module.css +1 -0
- package/src/components/NSPagination.tsx +154 -117
- package/src/components/NSTable.tsx +8 -8
- package/src/props/IBaseComponentProps.ts +1 -0
|
@@ -1,154 +1,191 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Component } from 'react';
|
|
2
2
|
import { IBaseComponentProps } from '../props/IBaseComponentProps';
|
|
3
3
|
import { NSBoxEnum } from './NSBoxEnum';
|
|
4
4
|
import Styles from './NSPagination.module.css';
|
|
5
|
+
import React from "react";
|
|
5
6
|
|
|
6
7
|
export interface INSPaginationProps extends IBaseComponentProps
|
|
7
8
|
{
|
|
8
9
|
totalItems: number;
|
|
9
|
-
currentPage: number;
|
|
10
10
|
onPageChange: (page: number, size: number) => void;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
interface INSPaginationState
|
|
14
14
|
{
|
|
15
|
+
currentPage: number;
|
|
15
16
|
pageSize: number;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
let pageSizes = [25, 50, 100, 200, 500];
|
|
19
20
|
|
|
20
|
-
export
|
|
21
|
+
export class NSPagination extends Component<INSPaginationProps, INSPaginationState>
|
|
21
22
|
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
PageSize = React.createRef<NSBoxEnum>();
|
|
24
|
+
constructor(props: INSPaginationProps)
|
|
25
|
+
{
|
|
26
|
+
super(props);
|
|
27
|
+
this.state = { currentPage: 1, pageSize: pageSizes[0] };
|
|
28
|
+
}
|
|
29
|
+
getCurrentPage(): number
|
|
30
|
+
{
|
|
31
|
+
return this.state.currentPage;
|
|
32
|
+
}
|
|
33
|
+
getPageSize(): number
|
|
34
|
+
{
|
|
35
|
+
return this.state.pageSize;
|
|
36
|
+
}
|
|
37
|
+
override render()
|
|
38
|
+
{
|
|
39
|
+
let pageSize = this.state.pageSize;
|
|
26
40
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
41
|
+
const { totalItems, onPageChange } = this.props;
|
|
42
|
+
const totalPages = Math.ceil(totalItems / pageSize);
|
|
43
|
+
const windowSize = 2;
|
|
44
|
+
const minPage = Math.max(2, this.state.currentPage - windowSize);
|
|
45
|
+
const maxPage = Math.min(this.state.currentPage + windowSize, totalPages - 1);
|
|
46
|
+
const current_min = Math.min(totalItems, (this.state.currentPage - 1) * pageSize + 1);
|
|
47
|
+
const current_max = Math.min(totalItems, this.state.currentPage * pageSize);
|
|
48
|
+
const pages = [];
|
|
35
49
|
|
|
36
|
-
|
|
37
|
-
|
|
50
|
+
const pushPage = (page: number) =>
|
|
51
|
+
{
|
|
52
|
+
pages.push(
|
|
53
|
+
<div key={page} className={`${Styles.ns_select_number_parent}`}>
|
|
54
|
+
<a
|
|
55
|
+
href="#"
|
|
56
|
+
className={`${Styles.ns_paginate_link} ${page === this.state.currentPage ? Styles.ns_select_number : ''}`}
|
|
57
|
+
onClick={(e) =>
|
|
58
|
+
{
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
let currentPage = page;
|
|
61
|
+
let pageSize = this.state.pageSize;
|
|
62
|
+
this.setState({ currentPage, pageSize }, () =>
|
|
63
|
+
{
|
|
64
|
+
onPageChange(currentPage, pageSize);
|
|
65
|
+
});
|
|
66
|
+
}}
|
|
67
|
+
>
|
|
68
|
+
{page}
|
|
69
|
+
</a>
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
//prev
|
|
38
74
|
pages.push(
|
|
39
|
-
<div key=
|
|
75
|
+
<div key="prev">
|
|
40
76
|
<a
|
|
41
77
|
href="#"
|
|
42
|
-
className={`${Styles.ns_paginate_link} ${page === currentPage ? Styles.ns_select_number : ''}`}
|
|
43
78
|
onClick={(e) =>
|
|
44
79
|
{
|
|
45
80
|
e.preventDefault();
|
|
46
|
-
|
|
81
|
+
if (this.state.currentPage > 1)
|
|
82
|
+
{
|
|
83
|
+
let currentPage = this.state.currentPage - 1;
|
|
84
|
+
let pageSize = this.state.pageSize;
|
|
85
|
+
this.setState({ currentPage, pageSize }, () =>
|
|
86
|
+
{
|
|
87
|
+
onPageChange(currentPage, pageSize);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
47
90
|
}}
|
|
48
91
|
>
|
|
49
|
-
|
|
92
|
+
<img
|
|
93
|
+
style={{ margin: "0 8px 0 0" }}
|
|
94
|
+
src="https://static.namirasoft.com/image/concept/arrow/left/white-blue.svg"
|
|
95
|
+
alt="left_vector"
|
|
96
|
+
width={32}
|
|
97
|
+
height={32}
|
|
98
|
+
/>
|
|
50
99
|
</a>
|
|
51
100
|
</div>
|
|
52
101
|
);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
{
|
|
80
|
-
pages.push(
|
|
81
|
-
<div key="ellipsis1" className={Styles.ns_pagination_left_ellipses}>
|
|
82
|
-
<a href="#" className={`${Styles.ns_paginate_link}`} onClick={(e) => e.preventDefault()}>...</a>
|
|
83
|
-
</div>
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
for (let i = minPage; i <= maxPage; i++)
|
|
87
|
-
pushPage(i);
|
|
88
|
-
if (currentPage < totalPages - windowSize - 1)
|
|
89
|
-
{
|
|
102
|
+
//FirstPage
|
|
103
|
+
pushPage(1);
|
|
104
|
+
if (this.state.currentPage > windowSize + 2)
|
|
105
|
+
{
|
|
106
|
+
pages.push(
|
|
107
|
+
<div key="ellipsis1" className={Styles.ns_pagination_left_ellipses}>
|
|
108
|
+
<a href="#" className={`${Styles.ns_paginate_link}`} onClick={(e) => e.preventDefault()}>...</a>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
for (let i = minPage; i <= maxPage; i++)
|
|
113
|
+
pushPage(i);
|
|
114
|
+
if (this.state.currentPage < totalPages - windowSize - 1)
|
|
115
|
+
{
|
|
116
|
+
pages.push(
|
|
117
|
+
<div key="ellipsis2" className={Styles.ns_pagination_right_ellipses}>
|
|
118
|
+
<a href="#" className={`${Styles.ns_paginate_link}`} onClick={(e) => e.preventDefault()}>...</a>
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
//LastPage
|
|
123
|
+
if (totalPages > 1)
|
|
124
|
+
{
|
|
125
|
+
pushPage(totalPages);
|
|
126
|
+
}
|
|
127
|
+
//next
|
|
90
128
|
pages.push(
|
|
91
|
-
<div key="
|
|
92
|
-
<a
|
|
129
|
+
<div key="next">
|
|
130
|
+
<a
|
|
131
|
+
href="#"
|
|
132
|
+
onClick={(e) =>
|
|
133
|
+
{
|
|
134
|
+
e.preventDefault();
|
|
135
|
+
if (this.state.currentPage < totalPages)
|
|
136
|
+
{
|
|
137
|
+
let currentPage = this.state.currentPage + 1;
|
|
138
|
+
let pageSize = this.state.pageSize;
|
|
139
|
+
this.setState({ currentPage, pageSize }, () =>
|
|
140
|
+
{
|
|
141
|
+
onPageChange(currentPage, pageSize);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}}
|
|
145
|
+
>
|
|
146
|
+
<img
|
|
147
|
+
style={{ margin: "0 0 0 8px" }}
|
|
148
|
+
src="https://static.namirasoft.com/image/concept/arrow/right/white-blue.svg"
|
|
149
|
+
width={32}
|
|
150
|
+
height={32}
|
|
151
|
+
alt="right_vector"
|
|
152
|
+
/>
|
|
153
|
+
</a>
|
|
93
154
|
</div>
|
|
94
155
|
);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
<div
|
|
126
|
-
id={props.id}
|
|
127
|
-
className={`${Styles.ns_pagination_container} ${props.classList?.join(' ')}`}
|
|
128
|
-
style={props.style}
|
|
129
|
-
>
|
|
130
|
-
{pages}
|
|
131
|
-
<div className={Styles.ns_pagination_info}>
|
|
132
|
-
<div style={{ width: 70 }}>
|
|
133
|
-
<NSBoxEnum
|
|
134
|
-
ref={PageSize}
|
|
135
|
-
title=''
|
|
136
|
-
multiple={false}
|
|
137
|
-
required={false}
|
|
138
|
-
options={pageSizes.map(pagesize => { return { desc: pagesize.toString(), value: pagesize.toString() } })}
|
|
139
|
-
onChange={() =>
|
|
140
|
-
{
|
|
141
|
-
setState({ pageSize: parseInt(PageSize.current?.getValue() ?? pageSizes[0].toString()) });
|
|
142
|
-
onPageChange(currentPage + 1, state.pageSize);
|
|
143
|
-
}}
|
|
144
|
-
/>
|
|
156
|
+
return (
|
|
157
|
+
<>
|
|
158
|
+
<div
|
|
159
|
+
id={this.props.id}
|
|
160
|
+
className={`${Styles.ns_pagination_container} ${this.props.classList?.join(' ')}`}
|
|
161
|
+
style={this.props.style}
|
|
162
|
+
>
|
|
163
|
+
{pages}
|
|
164
|
+
<div className={Styles.ns_pagination_info}>
|
|
165
|
+
<div style={{ width: 70 }}>
|
|
166
|
+
<NSBoxEnum
|
|
167
|
+
ref={this.PageSize}
|
|
168
|
+
title=''
|
|
169
|
+
multiple={false}
|
|
170
|
+
required={false}
|
|
171
|
+
options={pageSizes.map(pagesize => { return { desc: pagesize.toString(), value: pagesize.toString() } })}
|
|
172
|
+
onChanged={() =>
|
|
173
|
+
{
|
|
174
|
+
let currentPage = this.state.currentPage;
|
|
175
|
+
let pageSize = parseInt(this.PageSize.current?.getValue() ?? pageSizes[0].toString());
|
|
176
|
+
this.setState({ currentPage, pageSize }, () =>
|
|
177
|
+
{
|
|
178
|
+
onPageChange(currentPage, pageSize);
|
|
179
|
+
});
|
|
180
|
+
}}
|
|
181
|
+
/>
|
|
182
|
+
</div>
|
|
183
|
+
<h6>
|
|
184
|
+
{`(${current_min} - ${current_max}) of ${totalItems}`}
|
|
185
|
+
</h6>
|
|
145
186
|
</div>
|
|
146
|
-
<h6>
|
|
147
|
-
{`(${current_min} - ${current_max}) of ${totalItems}`}
|
|
148
|
-
</h6>
|
|
149
187
|
</div>
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
);
|
|
188
|
+
</>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
154
191
|
}
|
|
@@ -14,7 +14,7 @@ export interface INSTableProps<RowType> extends IBaseComponentProps
|
|
|
14
14
|
{
|
|
15
15
|
columns: { [key: string]: string };
|
|
16
16
|
totalItems: number;
|
|
17
|
-
reload: (page: number) => void
|
|
17
|
+
reload: (page: number, size: number) => void
|
|
18
18
|
getRowKey: (row: RowType, rowIndex: number) => string;
|
|
19
19
|
getColumnAttributes?: (column: string, columnIndex: number) => { [key: string]: string };
|
|
20
20
|
getCell?: (row: RowType, column: string, rowIndex: number, columnIndex: number) => any;
|
|
@@ -28,7 +28,6 @@ export interface NSTableState<RowType>
|
|
|
28
28
|
columns: { [key: string]: string };
|
|
29
29
|
rows: RowType[] | null;
|
|
30
30
|
title?: string;
|
|
31
|
-
currentPage: number,
|
|
32
31
|
model: {
|
|
33
32
|
show: boolean;
|
|
34
33
|
description?: string;
|
|
@@ -37,10 +36,11 @@ export interface NSTableState<RowType>
|
|
|
37
36
|
|
|
38
37
|
export class NSTable<RowType> extends Component<INSTableProps<RowType>, NSTableState<RowType>>
|
|
39
38
|
{
|
|
39
|
+
NSPagination = React.createRef<NSPagination>();
|
|
40
40
|
constructor(props: INSTableProps<RowType>)
|
|
41
41
|
{
|
|
42
42
|
super(props);
|
|
43
|
-
this.state = { columns: props.columns, rows: null,
|
|
43
|
+
this.state = { columns: props.columns, rows: null, model: { show: false } };
|
|
44
44
|
this.setColumns = this.setColumns.bind(this);
|
|
45
45
|
this.setRows = this.setRows.bind(this);
|
|
46
46
|
this.showModal = this.showModal.bind(this);
|
|
@@ -63,10 +63,9 @@ export class NSTable<RowType> extends Component<INSTableProps<RowType>, NSTableS
|
|
|
63
63
|
{
|
|
64
64
|
this.setState({ model: { show: false } });
|
|
65
65
|
}
|
|
66
|
-
onPageChange = (page: number) =>
|
|
66
|
+
onPageChange = (page: number, size: number) =>
|
|
67
67
|
{
|
|
68
|
-
this.
|
|
69
|
-
this.props.reload(page);
|
|
68
|
+
this.props.reload(page, size);
|
|
70
69
|
}
|
|
71
70
|
override render()
|
|
72
71
|
{
|
|
@@ -159,14 +158,15 @@ export class NSTable<RowType> extends Component<INSTableProps<RowType>, NSTableS
|
|
|
159
158
|
</table>
|
|
160
159
|
<NSSpace size={NSSpaceSizeType.MICRO} />
|
|
161
160
|
<section className={Styles.ns_pagination_button}>
|
|
162
|
-
<NSPagination
|
|
161
|
+
<NSPagination ref={this.NSPagination} totalItems={this.props.totalItems} onPageChange={this.onPageChange} />
|
|
163
162
|
<NSSpace size={NSSpaceSizeType.SMALL} />
|
|
164
163
|
<div className={Styles.ns_button}>
|
|
165
164
|
<NSButton title='Print' icon={{ src: "https://static.namirasoft.com/image/concept/export/blue.svg" }} onClick={() => { }} style={{ border: '1px solid rgba(255, 148, 50, 1)', width: "128px" }} />
|
|
166
165
|
<NSButton title='Export' icon={{ src: "https://static.namirasoft.com/image/concept/export/blue.svg" }} onClick={() => { }} style={{ border: '1px solid rgba(255, 148, 50, 1)', width: "128px" }} />
|
|
167
166
|
<NSButton title='Refresh' icon={{ src: "https://static.namirasoft.com/image/concept/export/blue.svg" }} onClick={() =>
|
|
168
167
|
{
|
|
169
|
-
|
|
168
|
+
if (this.NSPagination.current)
|
|
169
|
+
this.props.reload(this.NSPagination.current.getCurrentPage(), this.NSPagination.current.getPageSize());
|
|
170
170
|
}} style={{ border: '1px solid rgba(3, 119, 255, 1)', width: "128px" }} />
|
|
171
171
|
</div>
|
|
172
172
|
</section>
|