@inceptionbg/iui 2.0.26 → 2.0.28
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/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Table/Table.tsx +10 -11
- package/src/components/Table/contexts/TableContext.tsx +2 -1
- package/src/components/Table/hooks/localHooks/useLocalTableData.tsx +9 -11
- package/src/components/Table/hooks/localHooks/useLocalTableKeyboard.ts +10 -11
- package/src/types/ITable.ts +1 -0
package/package.json
CHANGED
|
@@ -235,17 +235,16 @@ export const TableContent: FC = () => {
|
|
|
235
235
|
</table>
|
|
236
236
|
</ConditionalWrapper>
|
|
237
237
|
</div>
|
|
238
|
-
{footer &&
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
)}
|
|
238
|
+
{footer && !footer.hidden && (
|
|
239
|
+
<TableFooter
|
|
240
|
+
pagination={footer.paginationControl}
|
|
241
|
+
totalRows={footer.totalRows}
|
|
242
|
+
noTotalRows={noTotalRows}
|
|
243
|
+
customLimit={footer.customPagination?.customLimit}
|
|
244
|
+
refetch={footer.refetch}
|
|
245
|
+
dataLength={data.length}
|
|
246
|
+
/>
|
|
247
|
+
)}
|
|
249
248
|
</div>
|
|
250
249
|
</Loader>
|
|
251
250
|
);
|
|
@@ -83,8 +83,9 @@ export const TableProvider = <T,>({
|
|
|
83
83
|
});
|
|
84
84
|
const data = useLocalTableData<T>({
|
|
85
85
|
initialData,
|
|
86
|
-
|
|
86
|
+
noPagination: !footer || !!footer.hidden,
|
|
87
87
|
controledPagination: !!footer?.paginationControl,
|
|
88
|
+
localPagination,
|
|
88
89
|
dataActions: updatedDataActions,
|
|
89
90
|
isDeletable: updatedDataActions.isDeletable,
|
|
90
91
|
rowSelect,
|
|
@@ -4,12 +4,13 @@ import type {
|
|
|
4
4
|
ITableDataActions,
|
|
5
5
|
ITableDataItem,
|
|
6
6
|
} from '../../../../types/ITable';
|
|
7
|
-
import {
|
|
7
|
+
import { useMemo } from 'react';
|
|
8
8
|
import { Checkbox } from '../../../Inputs/Checkbox';
|
|
9
9
|
import { TableItemActions } from '../../components/items/TableItemActions';
|
|
10
10
|
|
|
11
11
|
interface Props<T> {
|
|
12
12
|
initialData: ITableDataItem<T>[];
|
|
13
|
+
noPagination: boolean;
|
|
13
14
|
controledPagination: boolean;
|
|
14
15
|
localPagination: IPaginationControl;
|
|
15
16
|
dataActions?: ITableDataActions<T>;
|
|
@@ -19,17 +20,16 @@ interface Props<T> {
|
|
|
19
20
|
|
|
20
21
|
export const useLocalTableData = <T,>({
|
|
21
22
|
initialData,
|
|
23
|
+
noPagination,
|
|
22
24
|
controledPagination,
|
|
23
25
|
localPagination,
|
|
24
26
|
dataActions,
|
|
25
27
|
isDeletable,
|
|
26
28
|
rowSelect,
|
|
27
|
-
}: Props<T>) =>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
useEffect(() => {
|
|
29
|
+
}: Props<T>) =>
|
|
30
|
+
useMemo(() => {
|
|
31
31
|
const newData =
|
|
32
|
-
controledPagination || localPagination.limit <= 0
|
|
32
|
+
noPagination || controledPagination || localPagination.limit <= 0
|
|
33
33
|
? initialData
|
|
34
34
|
: initialData.slice(
|
|
35
35
|
localPagination.offset * localPagination.limit,
|
|
@@ -69,16 +69,14 @@ export const useLocalTableData = <T,>({
|
|
|
69
69
|
return e;
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
return finalData;
|
|
73
73
|
}, [
|
|
74
|
-
controledPagination,
|
|
75
74
|
initialData,
|
|
75
|
+
noPagination,
|
|
76
|
+
controledPagination,
|
|
76
77
|
localPagination.limit,
|
|
77
78
|
localPagination.offset,
|
|
78
79
|
rowSelect,
|
|
79
80
|
isDeletable,
|
|
80
81
|
dataActions,
|
|
81
82
|
]);
|
|
82
|
-
|
|
83
|
-
return data;
|
|
84
|
-
};
|
|
@@ -93,25 +93,24 @@ export const useLocalTableKeyboard = () => {
|
|
|
93
93
|
{
|
|
94
94
|
code: 'ArrowLeft',
|
|
95
95
|
ctrl: true,
|
|
96
|
-
disabled: isEditing || isAdding,
|
|
96
|
+
disabled: isEditing || isAdding || !footer || footer.hidden,
|
|
97
97
|
onAction: () =>
|
|
98
|
-
footer
|
|
99
|
-
footer
|
|
98
|
+
footer?.paginationControl &&
|
|
99
|
+
footer.paginationControl.setOffset(offset => (offset > 0 ? offset - 1 : 0)),
|
|
100
100
|
},
|
|
101
101
|
{
|
|
102
102
|
code: 'ArrowRight',
|
|
103
103
|
ctrl: true,
|
|
104
|
-
disabled: isEditing || isAdding,
|
|
104
|
+
disabled: isEditing || isAdding || !footer || footer.hidden,
|
|
105
105
|
onAction: () => {
|
|
106
106
|
if (
|
|
107
|
-
footer?.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
footer?.paginationControl &&
|
|
108
|
+
(footer.noTotalRows
|
|
109
|
+
? footer.paginationControl.limit <= data.length
|
|
110
|
+
: footer.paginationControl.offset + 1 <
|
|
111
|
+
Math.ceil(footer.totalRows! / footer.paginationControl.limit))
|
|
111
112
|
) {
|
|
112
|
-
footer
|
|
113
|
-
footer!.paginationControl!.offset + 1
|
|
114
|
-
);
|
|
113
|
+
footer.paginationControl.setOffset(offset => offset + 1);
|
|
115
114
|
}
|
|
116
115
|
},
|
|
117
116
|
},
|