allaw-ui 1.0.34 → 1.0.35
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/components/atoms/buttons/SecondaryButton.css +1 -1
- package/dist/components/molecules/pagination/Pagination.d.ts +10 -0
- package/dist/components/molecules/pagination/Pagination.js +64 -0
- package/dist/components/molecules/pagination/index.d.ts +2 -0
- package/dist/components/molecules/pagination/index.js +1 -0
- package/dist/components/molecules/pagination/pagination.css +120 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "./pagination.css";
|
|
3
|
+
import "../../../styles/global.css";
|
|
4
|
+
export interface PaginationProps {
|
|
5
|
+
currentPage: number;
|
|
6
|
+
totalPages: number;
|
|
7
|
+
onPageChange: (page: number) => void;
|
|
8
|
+
}
|
|
9
|
+
declare const Pagination: React.FC<PaginationProps>;
|
|
10
|
+
export default Pagination;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
|
2
|
+
import "./pagination.css";
|
|
3
|
+
import "../../../styles/global.css";
|
|
4
|
+
var Pagination = function (_a) {
|
|
5
|
+
var currentPage = _a.currentPage, totalPages = _a.totalPages, onPageChange = _a.onPageChange;
|
|
6
|
+
var _b = useState(window.innerWidth), setWindowWidth = _b[1];
|
|
7
|
+
var _c = useState(2), range = _c[0], setRange = _c[1];
|
|
8
|
+
useEffect(function () {
|
|
9
|
+
var handleResize = function () {
|
|
10
|
+
setWindowWidth(window.innerWidth);
|
|
11
|
+
// Ajuster le range en fonction de la largeur
|
|
12
|
+
setRange(window.innerWidth < 480 ? 1 : 2);
|
|
13
|
+
};
|
|
14
|
+
window.addEventListener("resize", handleResize);
|
|
15
|
+
handleResize(); // Initialisation
|
|
16
|
+
return function () { return window.removeEventListener("resize", handleResize); };
|
|
17
|
+
}, []);
|
|
18
|
+
// Validation des props
|
|
19
|
+
if (currentPage < 1 || currentPage > totalPages) {
|
|
20
|
+
console.error("Current page must be between 1 and total pages");
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
var handlePageChange = function (newPage) {
|
|
24
|
+
if (newPage >= 1 && newPage <= totalPages) {
|
|
25
|
+
onPageChange(newPage);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var renderPageNumbers = function () {
|
|
29
|
+
var items = [];
|
|
30
|
+
// Bouton Previous
|
|
31
|
+
items.push(React.createElement("button", { key: "prev", className: "pagination-nav-button pagination-prev-button", onClick: function () { return handlePageChange(currentPage - 1); }, disabled: currentPage === 1, "aria-label": "Page pr\u00E9c\u00E9dente", type: "button" },
|
|
32
|
+
React.createElement("span", { className: "allaw-icon-chevron-left pagination-icon", "aria-hidden": "true" }),
|
|
33
|
+
React.createElement("span", { className: "pagination-nav-text" }, "Pr\u00E9c\u00E9dent")));
|
|
34
|
+
// Première page
|
|
35
|
+
items.push(React.createElement("button", { key: 1, className: "pagination-number ".concat(currentPage === 1 ? "active" : ""), onClick: function () { return handlePageChange(1); }, "aria-label": "Page 1", "aria-current": currentPage === 1 ? "page" : undefined, type: "button" }, "1"));
|
|
36
|
+
// Points de suspension gauche
|
|
37
|
+
if (currentPage - range > 2) {
|
|
38
|
+
items.push(React.createElement("span", { key: "ellipsis-left", className: "pagination-ellipsis", "aria-hidden": "true" }, "..."));
|
|
39
|
+
}
|
|
40
|
+
var _loop_1 = function (i) {
|
|
41
|
+
items.push(React.createElement("button", { key: i, className: "pagination-number ".concat(currentPage === i ? "active" : ""), onClick: function () { return handlePageChange(i); }, "aria-label": "Page ".concat(i), "aria-current": currentPage === i ? "page" : undefined, type: "button" }, i));
|
|
42
|
+
};
|
|
43
|
+
// Pages autour de la page courante
|
|
44
|
+
for (var i = Math.max(2, currentPage - range); i <= Math.min(totalPages - 1, currentPage + range); i++) {
|
|
45
|
+
_loop_1(i);
|
|
46
|
+
}
|
|
47
|
+
// Points de suspension droite
|
|
48
|
+
if (currentPage + range < totalPages - 1) {
|
|
49
|
+
items.push(React.createElement("span", { key: "ellipsis-right", className: "pagination-ellipsis", "aria-hidden": "true" }, "..."));
|
|
50
|
+
}
|
|
51
|
+
// Dernière page
|
|
52
|
+
if (totalPages > 1) {
|
|
53
|
+
items.push(React.createElement("button", { key: totalPages, className: "pagination-number ".concat(currentPage === totalPages ? "active" : ""), onClick: function () { return handlePageChange(totalPages); }, "aria-label": "Page ".concat(totalPages), "aria-current": currentPage === totalPages ? "page" : undefined, type: "button" }, totalPages));
|
|
54
|
+
}
|
|
55
|
+
// Bouton Next
|
|
56
|
+
items.push(React.createElement("button", { key: "next", className: "pagination-nav-button pagination-next-button", onClick: function () { return handlePageChange(currentPage + 1); }, disabled: currentPage === totalPages, "aria-label": "Page suivante", type: "button" },
|
|
57
|
+
React.createElement("span", { className: "pagination-nav-text" }, "Suivant"),
|
|
58
|
+
React.createElement("span", { className: "allaw-icon-chevron-right pagination-icon", "aria-hidden": "true" })));
|
|
59
|
+
return items;
|
|
60
|
+
};
|
|
61
|
+
return (React.createElement("nav", { "aria-label": "Navigation des pages" },
|
|
62
|
+
React.createElement("div", { className: "pagination-container", role: "navigation" }, renderPageNumbers())));
|
|
63
|
+
};
|
|
64
|
+
export default Pagination;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Pagination } from "./Pagination";
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
.pagination-container {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
gap: 4px;
|
|
5
|
+
font-family: "Open Sans", sans-serif;
|
|
6
|
+
flex-wrap: wrap;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.pagination-number {
|
|
11
|
+
min-width: 40px;
|
|
12
|
+
height: 40px;
|
|
13
|
+
padding: 4px 8px;
|
|
14
|
+
border: none;
|
|
15
|
+
background: none;
|
|
16
|
+
border-radius: 8px;
|
|
17
|
+
font-size: 14px;
|
|
18
|
+
color: var(--dark-grey);
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
transition: background-color 0.2s;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.pagination-number:hover {
|
|
24
|
+
background-color: var(--grey-venom, #e6edf5);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.pagination-number.active {
|
|
28
|
+
background-color: var(--primary-blue);
|
|
29
|
+
border: 1px solid var(--bleu-allaw, #25beeb);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.pagination-number.active:hover {
|
|
33
|
+
background-color: var(--grey-venom, #e6edf5);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.pagination-nav-button {
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
gap: 8px;
|
|
40
|
+
padding: 4px 12px;
|
|
41
|
+
border: none;
|
|
42
|
+
background: none;
|
|
43
|
+
color: var(--dark-grey);
|
|
44
|
+
font-size: 14px;
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
transition: color 0.2s;
|
|
47
|
+
height: 40px;
|
|
48
|
+
border-radius: 8px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.pagination-prev-button {
|
|
52
|
+
padding-right: 16px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.pagination-next-button {
|
|
56
|
+
padding-left: 16px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.pagination-nav-button:hover {
|
|
60
|
+
background-color: var(--grey-venom, #e6edf5);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.pagination-nav-button:hover:not(:disabled) {
|
|
64
|
+
color: var(--primary-blue);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.pagination-nav-button:disabled {
|
|
68
|
+
opacity: 0.5;
|
|
69
|
+
cursor: not-allowed;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.pagination-ellipsis {
|
|
73
|
+
padding: 4px 8px;
|
|
74
|
+
color: var(--dark-grey);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.pagination-icon {
|
|
78
|
+
font-size: 10px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* Media Queries pour la responsivité */
|
|
82
|
+
@media screen and (max-width: 768px) {
|
|
83
|
+
.pagination-container {
|
|
84
|
+
gap: 2px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.pagination-number {
|
|
88
|
+
min-width: 32px;
|
|
89
|
+
height: 32px;
|
|
90
|
+
font-size: 12px;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@media screen and (max-width: 640px) {
|
|
95
|
+
.pagination-nav-text {
|
|
96
|
+
display: none;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.pagination-nav-button {
|
|
100
|
+
padding: 4px 8px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.pagination-prev-button,
|
|
104
|
+
.pagination-next-button {
|
|
105
|
+
padding: 4px 8px;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@media screen and (max-width: 480px) {
|
|
110
|
+
.pagination-container {
|
|
111
|
+
gap: 1px;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.pagination-number {
|
|
115
|
+
min-width: 28px;
|
|
116
|
+
height: 28px;
|
|
117
|
+
padding: 2px 4px;
|
|
118
|
+
font-size: 12px;
|
|
119
|
+
}
|
|
120
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -54,3 +54,5 @@ export { default as RadioForm } from "./components/molecules/radioForm/RadioForm
|
|
|
54
54
|
export { default as SelectForm } from "./components/molecules/selectForm/SelectForm";
|
|
55
55
|
export { default as Breadcrumb } from "./components/molecules/breadcrumb/Breadcrumb";
|
|
56
56
|
export { default as ProCard } from "./components/molecules/proCard/ProCard";
|
|
57
|
+
export { default as Pagination } from "./components/molecules/pagination/Pagination";
|
|
58
|
+
export type { PaginationProps } from "./components/molecules/pagination/Pagination";
|
package/dist/index.js
CHANGED
|
@@ -74,3 +74,5 @@ export { default as SelectForm } from "./components/molecules/selectForm/SelectF
|
|
|
74
74
|
export { default as Breadcrumb } from "./components/molecules/breadcrumb/Breadcrumb";
|
|
75
75
|
// ProCard
|
|
76
76
|
export { default as ProCard } from "./components/molecules/proCard/ProCard";
|
|
77
|
+
// Pagination
|
|
78
|
+
export { default as Pagination } from "./components/molecules/pagination/Pagination";
|