@thecb/components 7.7.4-beta.5 → 7.7.4-beta.7
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 +9 -12
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +9 -12
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/molecules/pagination/Pagination.js +76 -77
- 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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useContext } from "react";
|
|
2
2
|
import { ThemeContext } from "styled-components";
|
|
3
3
|
|
|
4
|
-
import { Cluster, Box } from "../../atoms/layouts";
|
|
4
|
+
import { Cluster, Cover, Box } from "../../atoms/layouts";
|
|
5
5
|
import Text from "../../atoms/text";
|
|
6
6
|
import ButtonWithAction from "../../atoms/button-with-action";
|
|
7
7
|
import { ChevronIcon } from "../../atoms/icons";
|
|
@@ -92,9 +92,9 @@ const Pagination = ({
|
|
|
92
92
|
activeBorderWidth = "3px",
|
|
93
93
|
arrowColor,
|
|
94
94
|
borderRadius = "3px",
|
|
95
|
-
buttonHeight = "
|
|
96
|
-
buttonWidth = "
|
|
97
|
-
childGap = "
|
|
95
|
+
buttonHeight = "44px",
|
|
96
|
+
buttonWidth = "44px",
|
|
97
|
+
childGap = "24px",
|
|
98
98
|
currentPage,
|
|
99
99
|
fontSize = "17px",
|
|
100
100
|
fontWeight = "900",
|
|
@@ -127,88 +127,87 @@ const Pagination = ({
|
|
|
127
127
|
/>
|
|
128
128
|
)
|
|
129
129
|
)}
|
|
130
|
-
{isMobile
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
variant="pXL"
|
|
135
|
-
weight={fontWeight}
|
|
136
|
-
color={numberColor ?? themeValues.numberColor}
|
|
137
|
-
extraStyles={`font-size: ${fontSize}`}
|
|
138
|
-
>
|
|
139
|
-
{`${currentPage} of ${pageCount}`}
|
|
140
|
-
</Text>
|
|
141
|
-
</Cluster>
|
|
142
|
-
</Box>
|
|
143
|
-
) : (
|
|
144
|
-
getPagesPanel(currentPage, pageCount).map((item, index) =>
|
|
145
|
-
item.isButton ? (
|
|
146
|
-
<Box padding="0" extraStyles={`max-height: ${buttonHeight};`}>
|
|
147
|
-
<ButtonWithAction
|
|
148
|
-
variant="ghost"
|
|
149
|
-
key={item.index}
|
|
150
|
-
text={item.index}
|
|
151
|
-
disabled={item.active}
|
|
152
|
-
extraDisabledStyles={`
|
|
153
|
-
border: ${activeBorderWidth} solid ${numberColor ??
|
|
154
|
-
themeValues.numberColor};
|
|
155
|
-
color: ${numberColor ?? themeValues.activeColor};
|
|
156
|
-
background-color: ${themeValues.activeBackgroundColor};
|
|
157
|
-
&:focus {
|
|
158
|
-
box-shadow: none;
|
|
159
|
-
}
|
|
160
|
-
&:hover {
|
|
161
|
-
background-color: initial;
|
|
162
|
-
}
|
|
163
|
-
`}
|
|
164
|
-
action={
|
|
165
|
-
!item.active
|
|
166
|
-
? () => setCurrentPage({ pageNumber: item.index })
|
|
167
|
-
: noop
|
|
168
|
-
}
|
|
169
|
-
textExtraStyles={`font-size: ${fontSize}; font-weight: ${fontWeight};`}
|
|
170
|
-
extraStyles={`
|
|
171
|
-
min-width: ${buttonWidth}; min-height: 100%; padding: 0;
|
|
172
|
-
border-radius: ${borderRadius};
|
|
173
|
-
&:hover, &:focus {
|
|
174
|
-
text-decoration: none;
|
|
175
|
-
> * > span {
|
|
176
|
-
text-decoration: none;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
> * > span {
|
|
180
|
-
color: ${numberColor ?? themeValues.numberColor}
|
|
181
|
-
}
|
|
182
|
-
margin: 0;
|
|
183
|
-
&:hover {
|
|
184
|
-
background-color: ${themeValues.hoverBackgroundColor}
|
|
185
|
-
}
|
|
186
|
-
&:focus {
|
|
187
|
-
outline: none
|
|
188
|
-
}
|
|
189
|
-
`}
|
|
190
|
-
dataQa={index}
|
|
191
|
-
>
|
|
192
|
-
{item.index}
|
|
193
|
-
</ButtonWithAction>
|
|
194
|
-
</Box>
|
|
195
|
-
) : (
|
|
196
|
-
<Box padding="0 10px">
|
|
197
|
-
<Cluster justify="flex-end">
|
|
130
|
+
{isMobile
|
|
131
|
+
? pageCount > 0 && (
|
|
132
|
+
<Box padding="0">
|
|
133
|
+
<Cover singleChild>
|
|
198
134
|
<Text
|
|
199
|
-
key={index}
|
|
200
135
|
variant="pXL"
|
|
201
136
|
weight={fontWeight}
|
|
202
137
|
color={numberColor ?? themeValues.numberColor}
|
|
203
138
|
extraStyles={`font-size: ${fontSize}`}
|
|
204
139
|
>
|
|
205
|
-
{
|
|
140
|
+
{`${currentPage} of ${pageCount}`}
|
|
206
141
|
</Text>
|
|
207
|
-
</
|
|
142
|
+
</Cover>
|
|
208
143
|
</Box>
|
|
209
144
|
)
|
|
210
|
-
)
|
|
211
|
-
|
|
145
|
+
: getPagesPanel(currentPage, pageCount).map((item, index) =>
|
|
146
|
+
item.isButton ? (
|
|
147
|
+
<Box padding="0" extraStyles={`max-height: ${buttonHeight};`}>
|
|
148
|
+
<ButtonWithAction
|
|
149
|
+
variant="ghost"
|
|
150
|
+
key={item.index}
|
|
151
|
+
text={item.index}
|
|
152
|
+
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
|
+
`}
|
|
165
|
+
action={
|
|
166
|
+
!item.active
|
|
167
|
+
? () => setCurrentPage({ pageNumber: item.index })
|
|
168
|
+
: noop
|
|
169
|
+
}
|
|
170
|
+
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
|
+
`}
|
|
191
|
+
dataQa={index}
|
|
192
|
+
>
|
|
193
|
+
{item.index}
|
|
194
|
+
</ButtonWithAction>
|
|
195
|
+
</Box>
|
|
196
|
+
) : (
|
|
197
|
+
<Box padding="0 10px">
|
|
198
|
+
<Cluster justify="flex-end">
|
|
199
|
+
<Text
|
|
200
|
+
key={index}
|
|
201
|
+
variant="pXL"
|
|
202
|
+
weight={fontWeight}
|
|
203
|
+
color={numberColor ?? themeValues.numberColor}
|
|
204
|
+
>
|
|
205
|
+
{"..."}
|
|
206
|
+
</Text>
|
|
207
|
+
</Cluster>
|
|
208
|
+
</Box>
|
|
209
|
+
)
|
|
210
|
+
)}
|
|
212
211
|
{currentPage < pageCount ? (
|
|
213
212
|
<PrevNextButton
|
|
214
213
|
action={pageNext}
|
|
@@ -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);
|