ar-design 0.3.47 → 0.3.48
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/assets/css/components/navigation/pagination/{pagination.css → styles.css} +7 -1
- package/dist/components/data-display/table/index.js +10 -5
- package/dist/components/navigation/pagination/IProps.d.ts +1 -0
- package/dist/components/navigation/pagination/index.d.ts +1 -1
- package/dist/components/navigation/pagination/index.js +16 -2
- package/package.json +1 -1
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
.ar-pagination {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: row;
|
|
4
|
+
align-items: center;
|
|
5
|
+
gap: 0 0.5rem;
|
|
6
|
+
}
|
|
1
7
|
.ar-pagination > ul {
|
|
2
8
|
display: flex;
|
|
3
9
|
flex-direction: row;
|
|
@@ -9,7 +15,7 @@
|
|
|
9
15
|
display: flex;
|
|
10
16
|
justify-content: center;
|
|
11
17
|
align-items: center;
|
|
12
|
-
width: 1.75rem;
|
|
18
|
+
min-width: 1.75rem;
|
|
13
19
|
height: 100%;
|
|
14
20
|
border-radius: var(--border-radius-pill);
|
|
15
21
|
box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.1);
|
|
@@ -70,6 +70,7 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
70
70
|
// states -> Pagination
|
|
71
71
|
const [totalRecords, setTotalRecords] = useState(0);
|
|
72
72
|
const [currentPage, setCurrentPage] = useState(1);
|
|
73
|
+
const [selectedPerPage, setSelectedPerPage] = useState(pagination?.perPage ?? 10);
|
|
73
74
|
if (config && Object.keys(config.scroll || {}).length > 0) {
|
|
74
75
|
if (_tableContent.current && config.scroll) {
|
|
75
76
|
if (config.scroll.maxHeight) {
|
|
@@ -338,12 +339,12 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
338
339
|
setTotalRecords(data.length);
|
|
339
340
|
}
|
|
340
341
|
if (pagination && !config.isServerSide) {
|
|
341
|
-
const indexOfLastRow = currentPage *
|
|
342
|
-
const indexOfFirstRow = indexOfLastRow -
|
|
342
|
+
const indexOfLastRow = currentPage * selectedPerPage;
|
|
343
|
+
const indexOfFirstRow = indexOfLastRow - selectedPerPage;
|
|
343
344
|
_data = _data.slice(indexOfFirstRow, indexOfLastRow);
|
|
344
345
|
}
|
|
345
346
|
return _data;
|
|
346
|
-
}, [data, searchedText, currentPage]);
|
|
347
|
+
}, [data, searchedText, currentPage, selectedPerPage]);
|
|
347
348
|
const renderRow = (item, index, deph) => {
|
|
348
349
|
const isHasSubitems = _subrowSelector in item;
|
|
349
350
|
// TODO: Keylere bakılacak...
|
|
@@ -510,6 +511,10 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
510
511
|
setTimeout(() => handleScroll(), 0);
|
|
511
512
|
setCurrentPage(pagination?.currentPage ?? 1);
|
|
512
513
|
}, [pagination?.currentPage]);
|
|
514
|
+
useLayoutEffect(() => {
|
|
515
|
+
setCurrentPage(1);
|
|
516
|
+
setTimeout(() => handleScroll(), 0);
|
|
517
|
+
}, [selectedPerPage]);
|
|
513
518
|
return (React.createElement("div", { ref: _tableWrapper, className: _tableClassName.map((c) => c).join(" ") },
|
|
514
519
|
(title || description || actions || React.Children.count(children) > 0) && (React.createElement("div", { className: "header" },
|
|
515
520
|
React.createElement("div", { className: "title" },
|
|
@@ -636,9 +641,9 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
636
641
|
" ",
|
|
637
642
|
React.createElement("span", null,
|
|
638
643
|
"of ",
|
|
639
|
-
|
|
644
|
+
selectedPerPage ?? getData.length,
|
|
640
645
|
" agreement")),
|
|
641
|
-
React.createElement(Pagination, { totalRecords: config.isServerSide ? pagination.totalRecords : totalRecords ?? 0, currentPage: currentPage, perPage:
|
|
646
|
+
React.createElement(Pagination, { totalRecords: config.isServerSide ? pagination.totalRecords : totalRecords ?? 0, currentPage: currentPage, perPage: selectedPerPage, onPerPageChange: (perPage) => setSelectedPerPage(perPage), onChange: (currentPage) => {
|
|
642
647
|
if (config.isServerSide && pagination && pagination.onChange)
|
|
643
648
|
pagination.onChange(currentPage);
|
|
644
649
|
setTimeout(() => handleScroll(), 0);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import IProps from "./IProps";
|
|
3
|
-
import "../../../assets/css/components/navigation/pagination/
|
|
3
|
+
import "../../../assets/css/components/navigation/pagination/styles.css";
|
|
4
4
|
declare const Pagination: React.FC<IProps>;
|
|
5
5
|
export default Pagination;
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import React, { useContext, useEffect, useState } from "react";
|
|
3
|
-
import "../../../assets/css/components/navigation/pagination/
|
|
3
|
+
import "../../../assets/css/components/navigation/pagination/styles.css";
|
|
4
4
|
import { ConfigContext } from "../../../libs/core/application/contexts/Config";
|
|
5
|
-
|
|
5
|
+
import Select from "../../form/select";
|
|
6
|
+
const perPageOptions = [
|
|
7
|
+
{ value: 5, text: "5" },
|
|
8
|
+
{ value: 10, text: "10" },
|
|
9
|
+
{ value: 15, text: "15" },
|
|
10
|
+
{ value: 50, text: "50" },
|
|
11
|
+
{ value: 75, text: "75" },
|
|
12
|
+
{ value: 100, text: "100" },
|
|
13
|
+
];
|
|
14
|
+
const Pagination = ({ currentPage, totalRecords, perPage, onPerPageChange, onChange }) => {
|
|
6
15
|
// context
|
|
7
16
|
const { config } = useContext(ConfigContext);
|
|
8
17
|
// states
|
|
9
18
|
const [pages, setPages] = useState([]);
|
|
10
19
|
const [totalPageCount, setTotalPageCount] = useState(0);
|
|
20
|
+
const [selectedPerPage, setSelectedPerPage] = useState(perPageOptions.find((x) => x.value === 10));
|
|
11
21
|
// methods
|
|
12
22
|
const handlePageChange = (page) => onChange(page);
|
|
13
23
|
// useEffects
|
|
@@ -29,6 +39,10 @@ const Pagination = ({ currentPage, totalRecords, perPage, onChange }) => {
|
|
|
29
39
|
setPages(liItems);
|
|
30
40
|
}, [totalRecords, currentPage, perPage, config.perPage]);
|
|
31
41
|
return (React.createElement("div", { className: "ar-pagination" },
|
|
42
|
+
React.createElement(Select, { value: selectedPerPage, options: [...perPageOptions, { value: totalRecords, text: "Tümü" }], onChange: (option) => {
|
|
43
|
+
setSelectedPerPage(option);
|
|
44
|
+
onPerPageChange(option?.value);
|
|
45
|
+
} }),
|
|
32
46
|
React.createElement("ul", null,
|
|
33
47
|
React.createElement("li", { className: currentPage === 1 ? "passive" : "", onClick: () => {
|
|
34
48
|
if (currentPage === 1)
|