@thecb/components 7.7.4-beta.6 → 7.7.4-beta.8
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.cjs.js +5 -6
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +5 -6
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/molecules/pagination/Pagination.js +36 -33
- package/src/components/molecules/pagination/Pagination.theme.js +0 -2
- package/src/components/molecules/pagination/index.d.ts +23 -0
- package/src/components/molecules/pagination/Pagination.new.js +0 -187
package/package.json
CHANGED
|
@@ -107,6 +107,40 @@ const Pagination = ({
|
|
|
107
107
|
}) => {
|
|
108
108
|
const { isMobile } = useContext(ThemeContext);
|
|
109
109
|
|
|
110
|
+
const extraStyles = `
|
|
111
|
+
min-width: ${buttonWidth}; min-height: 100%; padding: 0;
|
|
112
|
+
border-radius: ${borderRadius};
|
|
113
|
+
&:hover, &:focus {
|
|
114
|
+
text-decoration: none;
|
|
115
|
+
> * > span {
|
|
116
|
+
text-decoration: none;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
> * > span {
|
|
120
|
+
color: ${numberColor ?? themeValues.numberColor}
|
|
121
|
+
}
|
|
122
|
+
margin: 0;
|
|
123
|
+
&:hover {
|
|
124
|
+
background-color: ${themeValues.hoverBackgroundColor}
|
|
125
|
+
}
|
|
126
|
+
&:focus {
|
|
127
|
+
outline: none
|
|
128
|
+
}
|
|
129
|
+
`;
|
|
130
|
+
|
|
131
|
+
const extraDisabledStyles = `
|
|
132
|
+
border: ${activeBorderWidth} solid ${numberColor ??
|
|
133
|
+
themeValues.numberColor};
|
|
134
|
+
color: ${numberColor ?? themeValues.activeColor};
|
|
135
|
+
background-color: ${themeValues.activeBackgroundColor};
|
|
136
|
+
&:focus {
|
|
137
|
+
box-shadow: none;
|
|
138
|
+
}
|
|
139
|
+
&:hover {
|
|
140
|
+
background-color: initial;
|
|
141
|
+
}
|
|
142
|
+
`;
|
|
143
|
+
|
|
110
144
|
return (
|
|
111
145
|
<Cluster justify="center" childGap={childGap}>
|
|
112
146
|
{currentPage > 1 ? (
|
|
@@ -150,44 +184,14 @@ const Pagination = ({
|
|
|
150
184
|
key={item.index}
|
|
151
185
|
text={item.index}
|
|
152
186
|
disabled={item.active}
|
|
153
|
-
extraDisabledStyles={
|
|
154
|
-
border: ${activeBorderWidth} solid ${numberColor ??
|
|
155
|
-
themeValues.numberColor};
|
|
156
|
-
color: ${numberColor ?? themeValues.activeColor};
|
|
157
|
-
background-color: ${themeValues.activeBackgroundColor};
|
|
158
|
-
&:focus {
|
|
159
|
-
box-shadow: none;
|
|
160
|
-
}
|
|
161
|
-
&:hover {
|
|
162
|
-
background-color: initial;
|
|
163
|
-
}
|
|
164
|
-
`}
|
|
187
|
+
extraDisabledStyles={extraDisabledStyles}
|
|
165
188
|
action={
|
|
166
189
|
!item.active
|
|
167
190
|
? () => setCurrentPage({ pageNumber: item.index })
|
|
168
191
|
: noop
|
|
169
192
|
}
|
|
170
193
|
textExtraStyles={`font-size: ${fontSize}; font-weight: ${fontWeight};`}
|
|
171
|
-
extraStyles={
|
|
172
|
-
min-width: ${buttonWidth}; min-height: 100%; padding: 0;
|
|
173
|
-
border-radius: ${borderRadius};
|
|
174
|
-
&:hover, &:focus {
|
|
175
|
-
text-decoration: none;
|
|
176
|
-
> * > span {
|
|
177
|
-
text-decoration: none;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
> * > span {
|
|
181
|
-
color: ${numberColor ?? themeValues.numberColor}
|
|
182
|
-
}
|
|
183
|
-
margin: 0;
|
|
184
|
-
&:hover {
|
|
185
|
-
background-color: ${themeValues.hoverBackgroundColor}
|
|
186
|
-
}
|
|
187
|
-
&:focus {
|
|
188
|
-
outline: none
|
|
189
|
-
}
|
|
190
|
-
`}
|
|
194
|
+
extraStyles={extraStyles}
|
|
191
195
|
dataQa={index}
|
|
192
196
|
>
|
|
193
197
|
{item.index}
|
|
@@ -201,7 +205,6 @@ const Pagination = ({
|
|
|
201
205
|
variant="pXL"
|
|
202
206
|
weight={fontWeight}
|
|
203
207
|
color={numberColor ?? themeValues.numberColor}
|
|
204
|
-
extraStyles={`font-size: ${fontSize}`}
|
|
205
208
|
>
|
|
206
209
|
{"..."}
|
|
207
210
|
</Text>
|
|
@@ -9,13 +9,11 @@ const arrowColor = WHITE;
|
|
|
9
9
|
const numberColor = MATISSE_BLUE;
|
|
10
10
|
const hoverBackgroundColor = ALABASTER_WHITE;
|
|
11
11
|
const activeBackgroundColor = WHITE;
|
|
12
|
-
const activeBorderColor = MATISSE_BLUE;
|
|
13
12
|
const activeColor = MATISSE_BLUE;
|
|
14
13
|
|
|
15
14
|
export const fallbackValues = {
|
|
16
15
|
activeColor,
|
|
17
16
|
activeBackgroundColor,
|
|
18
|
-
activeBorderColor,
|
|
19
17
|
arrowColor,
|
|
20
18
|
hoverBackgroundColor,
|
|
21
19
|
numberColor
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Expand from "../../../util/expand";
|
|
3
|
+
|
|
4
|
+
export interface PaginationProps {
|
|
5
|
+
extraStyles?: string;
|
|
6
|
+
activeBorderWidth?: string;
|
|
7
|
+
arrowColor?: string;
|
|
8
|
+
borderRadius?: string;
|
|
9
|
+
buttonHeight?: string;
|
|
10
|
+
buttonWidth?: string;
|
|
11
|
+
childGap?: string;
|
|
12
|
+
currentPage: number;
|
|
13
|
+
fontSize?: string;
|
|
14
|
+
fontWeight?: string;
|
|
15
|
+
numberColor?: string;
|
|
16
|
+
pageCount: number;
|
|
17
|
+
pageNext: () => void;
|
|
18
|
+
pagePrevious: () => void;
|
|
19
|
+
setCurrentPage: ({ currentPage: number }) => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const Pagination: React.FC<Expand<PaginationProps> &
|
|
23
|
+
React.HTMLAttributes<HTMLElement>>;
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Cluster, Box } from "../../atoms/layouts";
|
|
3
|
-
import Text from "../../atoms/text";
|
|
4
|
-
import ButtonWithAction from "../../atoms/button-with-action";
|
|
5
|
-
import { ChevronIcon } from "../../atoms/icons";
|
|
6
|
-
import { noop } from "../../../util/general";
|
|
7
|
-
import { themeComponent } from "../../../util/themeUtils";
|
|
8
|
-
import { fallbackValues } from "./Pagination.theme";
|
|
9
|
-
|
|
10
|
-
const PAGING_SPACE = 2; // how many pages we want to have before/after delimiter
|
|
11
|
-
const PAGING_INIT_SPACE = 3; // first delimiter should appear after 3 pages
|
|
12
|
-
|
|
13
|
-
const PrevNextButton = ({
|
|
14
|
-
action,
|
|
15
|
-
arrowColor,
|
|
16
|
-
borderRadius,
|
|
17
|
-
numberColor,
|
|
18
|
-
buttonHeight,
|
|
19
|
-
buttonWidth,
|
|
20
|
-
type
|
|
21
|
-
}) => (
|
|
22
|
-
<Box
|
|
23
|
-
padding="0 10px 0"
|
|
24
|
-
minHeight={buttonHeight}
|
|
25
|
-
extraStyles={`max-height: ${buttonHeight};`}
|
|
26
|
-
>
|
|
27
|
-
<ButtonWithAction
|
|
28
|
-
action={action}
|
|
29
|
-
contentOverride
|
|
30
|
-
dataQa={type}
|
|
31
|
-
extraStyles={`
|
|
32
|
-
min-width: ${buttonWidth};
|
|
33
|
-
min-height: 100%;
|
|
34
|
-
max-height: ${buttonHeight};
|
|
35
|
-
padding: 6px;
|
|
36
|
-
border-radius: ${borderRadius};
|
|
37
|
-
background-color: ${numberColor};
|
|
38
|
-
border-color: ${numberColor};
|
|
39
|
-
margin: 0;
|
|
40
|
-
`}
|
|
41
|
-
>
|
|
42
|
-
<Box padding="0" extraStyles={type === "prev" && "transform: scaleX(-1)"}>
|
|
43
|
-
<ChevronIcon variant="darkMode" iconFill={arrowColor} />
|
|
44
|
-
</Box>
|
|
45
|
-
</ButtonWithAction>
|
|
46
|
-
</Box>
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
export const getPagesPanel = (page, pagesCount) => {
|
|
50
|
-
if (!pagesCount || pagesCount <= 1) {
|
|
51
|
-
return [];
|
|
52
|
-
}
|
|
53
|
-
const lastPageNumber = pagesCount;
|
|
54
|
-
const space = page === 1 ? PAGING_INIT_SPACE : PAGING_SPACE;
|
|
55
|
-
const pages = [{ index: 1, isButton: true }];
|
|
56
|
-
if (page > space + 1) {
|
|
57
|
-
pages.push({ isDelimiter: true });
|
|
58
|
-
}
|
|
59
|
-
for (
|
|
60
|
-
let j = Math.max(1, page - space) + 1;
|
|
61
|
-
j < Math.min(lastPageNumber, page + space);
|
|
62
|
-
j++
|
|
63
|
-
) {
|
|
64
|
-
pages.push({ index: j, isButton: true });
|
|
65
|
-
}
|
|
66
|
-
if (page < lastPageNumber - space) {
|
|
67
|
-
pages.push({ isDelimiter: true });
|
|
68
|
-
}
|
|
69
|
-
pages.push({ index: lastPageNumber, isButton: true });
|
|
70
|
-
const activePage = pages.find(p => p.index === page);
|
|
71
|
-
if (activePage) {
|
|
72
|
-
activePage.active = true;
|
|
73
|
-
}
|
|
74
|
-
return pages;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const Pagination = ({
|
|
78
|
-
activeBorderWidth = "1px",
|
|
79
|
-
applyActivePageDisabledStyles = true,
|
|
80
|
-
arrowColor,
|
|
81
|
-
borderRadius = "3px",
|
|
82
|
-
buttonHeight = "40px",
|
|
83
|
-
buttonWidth = "40px",
|
|
84
|
-
childGap = "10px",
|
|
85
|
-
currentPage,
|
|
86
|
-
fontSize = "17px",
|
|
87
|
-
fontWeight = "900",
|
|
88
|
-
numberColor,
|
|
89
|
-
pageCount,
|
|
90
|
-
pageNext,
|
|
91
|
-
pagePrevious,
|
|
92
|
-
setCurrentPage,
|
|
93
|
-
themeValues
|
|
94
|
-
}) => (
|
|
95
|
-
<Cluster justify="center" childGap={childGap}>
|
|
96
|
-
{currentPage > 1 && (
|
|
97
|
-
<PrevNextButton
|
|
98
|
-
action={pagePrevious}
|
|
99
|
-
arrowColor={arrowColor ?? themeValues.arrowColor}
|
|
100
|
-
borderRadius={borderRadius}
|
|
101
|
-
buttonHeight={buttonHeight}
|
|
102
|
-
buttonWidth={buttonWidth}
|
|
103
|
-
numberColor={numberColor ?? themeValues.numberColor}
|
|
104
|
-
type="prev"
|
|
105
|
-
/>
|
|
106
|
-
)}
|
|
107
|
-
{getPagesPanel(currentPage, pageCount).map((item, index) =>
|
|
108
|
-
item.isButton ? (
|
|
109
|
-
<Box padding="0" extraStyles={`max-height: ${buttonHeight};`}>
|
|
110
|
-
<ButtonWithAction
|
|
111
|
-
variant="ghost"
|
|
112
|
-
key={item.index}
|
|
113
|
-
text={item.index}
|
|
114
|
-
disabled={item.active}
|
|
115
|
-
applyDisabledStyles={applyActivePageDisabledStyles}
|
|
116
|
-
action={
|
|
117
|
-
!item.active
|
|
118
|
-
? () => setCurrentPage({ pageNumber: item.index })
|
|
119
|
-
: noop
|
|
120
|
-
}
|
|
121
|
-
textExtraStyles={`font-size: ${fontSize}; font-weight: ${fontWeight};`}
|
|
122
|
-
extraStyles={`
|
|
123
|
-
${
|
|
124
|
-
item.active
|
|
125
|
-
? `border: ${activeBorderWidth} solid ${numberColor ??
|
|
126
|
-
themeValues.numberColor};`
|
|
127
|
-
: ""
|
|
128
|
-
}
|
|
129
|
-
min-width: ${buttonWidth}; min-height: 100%; padding: 0;
|
|
130
|
-
border-radius: ${borderRadius};
|
|
131
|
-
&:hover, &:focus {
|
|
132
|
-
text-decoration: none;
|
|
133
|
-
> * > span {
|
|
134
|
-
text-decoration: none;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
> * > span {
|
|
138
|
-
color: ${numberColor ?? themeValues.numberColor}
|
|
139
|
-
}
|
|
140
|
-
margin: 0;
|
|
141
|
-
}
|
|
142
|
-
&:hover { ${
|
|
143
|
-
item.active
|
|
144
|
-
? `cursor: default;
|
|
145
|
-
border: ${activeBorderWidth} solid ${numberColor ??
|
|
146
|
-
themeValues.numberColor};
|
|
147
|
-
> * > span {
|
|
148
|
-
cursor: default;
|
|
149
|
-
}`
|
|
150
|
-
: `background-color: ${themeValues.hoverBackgroundColor}`
|
|
151
|
-
} }
|
|
152
|
-
`}
|
|
153
|
-
dataQa={index}
|
|
154
|
-
>
|
|
155
|
-
{item.index}
|
|
156
|
-
</ButtonWithAction>
|
|
157
|
-
</Box>
|
|
158
|
-
) : (
|
|
159
|
-
<Box padding="0 10px">
|
|
160
|
-
<Cluster justify="flex-end">
|
|
161
|
-
<Text
|
|
162
|
-
key={index}
|
|
163
|
-
variant="pXL"
|
|
164
|
-
weight={fontWeight}
|
|
165
|
-
color={numberColor ?? themeValues.numberColor}
|
|
166
|
-
>
|
|
167
|
-
{"..."}
|
|
168
|
-
</Text>
|
|
169
|
-
</Cluster>
|
|
170
|
-
</Box>
|
|
171
|
-
)
|
|
172
|
-
)}
|
|
173
|
-
{currentPage < pageCount && (
|
|
174
|
-
<PrevNextButton
|
|
175
|
-
action={pageNext}
|
|
176
|
-
arrowColor={arrowColor ?? themeValues.arrowColor}
|
|
177
|
-
borderRadius={borderRadius}
|
|
178
|
-
buttonHeight={buttonHeight}
|
|
179
|
-
buttonWidth={buttonWidth}
|
|
180
|
-
numberColor={numberColor ?? themeValues.numberColor}
|
|
181
|
-
type="next"
|
|
182
|
-
/>
|
|
183
|
-
)}
|
|
184
|
-
</Cluster>
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
export default themeComponent(Pagination, "Pagination", fallbackValues);
|