@elliemae/ds-pagination 2.2.0-alpha.2 → 2.2.0-beta.0
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/cjs/Pagination.js +35 -49
- package/cjs/PaginationDataTestID.js +9 -37
- package/cjs/hooks/usePaginationSearch.js +20 -48
- package/cjs/index.d.js +2 -27
- package/cjs/index.js +10 -28
- package/cjs/parts/PageNextButton.js +32 -52
- package/cjs/parts/PagePrevButton.js +31 -51
- package/cjs/parts/PaginationContent.js +77 -91
- package/cjs/parts/Paginator.js +124 -112
- package/cjs/parts/PerPageSelector.js +63 -68
- package/cjs/props.js +34 -63
- package/cjs/styled.js +47 -112
- package/esm/Pagination.js +23 -17
- package/esm/PaginationDataTestID.js +5 -8
- package/esm/hooks/usePaginationSearch.js +13 -16
- package/esm/index.d.js +1 -2
- package/esm/index.js +1 -3
- package/esm/parts/PageNextButton.js +24 -23
- package/esm/parts/PagePrevButton.js +23 -22
- package/esm/parts/PaginationContent.js +68 -62
- package/esm/parts/Paginator.js +110 -76
- package/esm/parts/PerPageSelector.js +49 -32
- package/esm/props.js +29 -34
- package/esm/styled.js +33 -83
- package/package.json +7 -7
- package/cjs/Pagination.js.map +0 -7
- package/cjs/PaginationDataTestID.js.map +0 -7
- package/cjs/hooks/usePaginationSearch.js.map +0 -7
- package/cjs/index.d.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/parts/PageNextButton.js.map +0 -7
- package/cjs/parts/PagePrevButton.js.map +0 -7
- package/cjs/parts/PaginationContent.js.map +0 -7
- package/cjs/parts/Paginator.js.map +0 -7
- package/cjs/parts/PerPageSelector.js.map +0 -7
- package/cjs/props.js.map +0 -7
- package/cjs/styled.js.map +0 -7
- package/esm/Pagination.js.map +0 -7
- package/esm/PaginationDataTestID.js.map +0 -7
- package/esm/hooks/usePaginationSearch.js.map +0 -7
- package/esm/index.d.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/parts/PageNextButton.js.map +0 -7
- package/esm/parts/PagePrevButton.js.map +0 -7
- package/esm/parts/PaginationContent.js.map +0 -7
- package/esm/parts/Paginator.js.map +0 -7
- package/esm/parts/PerPageSelector.js.map +0 -7
- package/esm/props.js.map +0 -7
- package/esm/styled.js.map +0 -7
package/esm/parts/Paginator.js
CHANGED
|
@@ -1,41 +1,64 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
3
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
5
|
+
import { useState, useRef, useMemo, useEffect } from 'react';
|
|
6
|
+
import { Checkmark, ChevronDown } from '@elliemae/ds-icons';
|
|
7
|
+
import { useOnElementResize } from '@elliemae/ds-utilities';
|
|
8
|
+
import Grid from '@elliemae/ds-grid';
|
|
9
|
+
import { DSDropdownMenuV2 } from '@elliemae/ds-dropdownmenu';
|
|
10
|
+
import { PaginationSeparator, PaginationDropdownButton, PaginationBoldText } from '../styled.js';
|
|
11
|
+
import { usePaginationSearch } from '../hooks/usePaginationSearch.js';
|
|
12
|
+
import { jsxs, Fragment } from 'react/jsx-runtime';
|
|
13
|
+
|
|
14
|
+
var _div, _PaginationSeparator, _PaginationSeparator2, _PaginationSeparator3, _PaginationSeparator4;
|
|
15
|
+
|
|
16
|
+
const Paginator = props => {
|
|
17
|
+
var _span2;
|
|
18
|
+
|
|
19
|
+
const {
|
|
20
|
+
pageIndex,
|
|
21
|
+
pageCount,
|
|
22
|
+
onPageChange,
|
|
23
|
+
pageDetails,
|
|
24
|
+
pageDetailsTitle
|
|
25
|
+
} = props;
|
|
11
26
|
const [isOpened, setIsOpened] = useState(false);
|
|
12
27
|
const btnRef = useRef(null);
|
|
13
28
|
const pageInfoRef = useRef(null);
|
|
14
|
-
const {
|
|
15
|
-
|
|
29
|
+
const {
|
|
30
|
+
width: btnWidth
|
|
31
|
+
} = useOnElementResize(btnRef);
|
|
32
|
+
const {
|
|
33
|
+
width: txtWidth
|
|
34
|
+
} = useOnElementResize(pageInfoRef);
|
|
16
35
|
const options = useMemo(() => new Array(pageCount).fill(0).map((_, index) => {
|
|
36
|
+
var _span;
|
|
37
|
+
|
|
17
38
|
const option = {
|
|
18
39
|
dsId: (index + 1).toString(),
|
|
19
40
|
label: (index + 1).toString(),
|
|
20
41
|
value: index + 1,
|
|
21
|
-
type:
|
|
42
|
+
type: 'single'
|
|
22
43
|
};
|
|
44
|
+
|
|
23
45
|
if (pageDetails.length) {
|
|
24
|
-
option.render = () =>
|
|
25
|
-
cols: [
|
|
46
|
+
option.render = () => /*#__PURE__*/_jsx(Grid, {
|
|
47
|
+
cols: ['16px', "".concat(txtWidth + 16, "px"), 'auto'],
|
|
26
48
|
gutter: "xxs",
|
|
27
49
|
alignItems: "center"
|
|
28
|
-
}, pageIndex === index ?
|
|
50
|
+
}, void 0, pageIndex === index ? /*#__PURE__*/_jsx(Checkmark, {
|
|
29
51
|
size: "s",
|
|
30
|
-
color: [
|
|
31
|
-
}) :
|
|
52
|
+
color: ['brand-primary', '600']
|
|
53
|
+
}) : _div || (_div = /*#__PURE__*/_jsx("div", {})), _span || (_span = /*#__PURE__*/_jsx("span", {}, void 0, index + 1)), /*#__PURE__*/_jsx("span", {
|
|
32
54
|
style: {
|
|
33
|
-
whiteSpace:
|
|
34
|
-
textOverflow:
|
|
35
|
-
overflow:
|
|
55
|
+
whiteSpace: 'nowrap',
|
|
56
|
+
textOverflow: 'ellipsis',
|
|
57
|
+
overflow: 'hidden'
|
|
36
58
|
}
|
|
37
|
-
}, pageDetails[index]));
|
|
59
|
+
}, void 0, pageDetails[index]));
|
|
38
60
|
}
|
|
61
|
+
|
|
39
62
|
return option;
|
|
40
63
|
}), [pageCount, pageDetails, pageIndex, txtWidth]);
|
|
41
64
|
const actionRef = useRef({});
|
|
@@ -43,60 +66,71 @@ const Paginator = (props) => {
|
|
|
43
66
|
if (isOpened) {
|
|
44
67
|
actionRef.current.setActiveDescendant((pageIndex + 1).toString());
|
|
45
68
|
actionRef.current.scrollOptionIntoView((pageIndex + 1).toString());
|
|
46
|
-
}
|
|
69
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
70
|
+
|
|
47
71
|
}, [isOpened]);
|
|
48
72
|
const onKeyDown = usePaginationSearch(pageCount, actionRef);
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
73
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
74
|
+
children: [_PaginationSeparator || (_PaginationSeparator = /*#__PURE__*/_jsx(PaginationSeparator, {})), /*#__PURE__*/_jsx(DSDropdownMenuV2, {
|
|
75
|
+
isOpened: isOpened,
|
|
76
|
+
options: options,
|
|
77
|
+
selectedOptions: {
|
|
78
|
+
[(pageIndex + 1).toString()]: true
|
|
79
|
+
},
|
|
80
|
+
onOptionClick: (_, clickedOption) => {
|
|
81
|
+
onPageChange(clickedOption.value);
|
|
82
|
+
setIsOpened(false);
|
|
83
|
+
btnRef.current.focus();
|
|
84
|
+
},
|
|
85
|
+
onClickOutside: () => {
|
|
86
|
+
setIsOpened(false);
|
|
87
|
+
btnRef.current.focus();
|
|
88
|
+
},
|
|
89
|
+
customOffset: [0, 2],
|
|
90
|
+
startPlacementPreference: "top-end",
|
|
91
|
+
actionRef: actionRef,
|
|
92
|
+
onKeyDown: onKeyDown,
|
|
93
|
+
minWidth: btnWidth + 23,
|
|
94
|
+
maxHeight: 300,
|
|
95
|
+
HeaderComp: () => pageDetailsTitle !== '' ? /*#__PURE__*/_jsx(Grid, {
|
|
96
|
+
cols: ["".concat(txtWidth + 50, "px"), '8px', 'auto']
|
|
97
|
+
}, void 0, /*#__PURE__*/_jsx("span", {
|
|
98
|
+
style: {
|
|
99
|
+
marginLeft: '8px'
|
|
100
|
+
}
|
|
101
|
+
}, void 0, "Page"), _PaginationSeparator2 || (_PaginationSeparator2 = /*#__PURE__*/_jsx(PaginationSeparator, {
|
|
102
|
+
height: "100%"
|
|
103
|
+
})), _span2 || (_span2 = /*#__PURE__*/_jsx("span", {}, void 0, pageDetailsTitle))) : 'Page'
|
|
104
|
+
}, void 0, /*#__PURE__*/_jsx(PaginationDropdownButton, {
|
|
105
|
+
buttonType: "raw",
|
|
106
|
+
onClick: () => setIsOpened(true),
|
|
107
|
+
innerRef: btnRef
|
|
108
|
+
}, void 0, /*#__PURE__*/_jsx("div", {
|
|
109
|
+
style: {
|
|
110
|
+
display: 'flex',
|
|
111
|
+
gridGap: '8px',
|
|
112
|
+
alignItems: 'center'
|
|
113
|
+
}
|
|
114
|
+
}, void 0, /*#__PURE__*/jsxs(Grid, {
|
|
115
|
+
cols: ['auto', 'auto', 'auto'],
|
|
116
|
+
alignItems: "center",
|
|
117
|
+
gutter: "xxxs",
|
|
118
|
+
ref: pageInfoRef,
|
|
119
|
+
children: [/*#__PURE__*/_jsx(PaginationBoldText, {
|
|
120
|
+
fontSize: "18px"
|
|
121
|
+
}, void 0, pageIndex + 1), " / ", pageCount]
|
|
122
|
+
}), pageDetails.length !== 0 && /*#__PURE__*/jsxs(Fragment, {
|
|
123
|
+
children: [_PaginationSeparator3 || (_PaginationSeparator3 = /*#__PURE__*/_jsx(PaginationSeparator, {
|
|
124
|
+
height: "12px",
|
|
125
|
+
ml: "8px"
|
|
126
|
+
})), /*#__PURE__*/_jsx(PaginationBoldText, {
|
|
127
|
+
fontSize: "13px",
|
|
128
|
+
mr: "8px"
|
|
129
|
+
}, void 0, pageDetails[pageIndex])]
|
|
130
|
+
}), /*#__PURE__*/_jsx(ChevronDown, {
|
|
131
|
+
color: ['brand-primary', '700']
|
|
132
|
+
})))), _PaginationSeparator4 || (_PaginationSeparator4 = /*#__PURE__*/_jsx(PaginationSeparator, {}))]
|
|
133
|
+
});
|
|
101
134
|
};
|
|
102
|
-
|
|
135
|
+
|
|
136
|
+
export { Paginator as default };
|
|
@@ -1,31 +1,44 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
4
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
5
|
+
import { useState, useMemo, useRef, useEffect } from 'react';
|
|
6
|
+
import memoize from 'memoize-one';
|
|
7
|
+
import { range, useOnElementResize } from '@elliemae/ds-utilities';
|
|
8
|
+
import { DSDropdownMenuV2 } from '@elliemae/ds-dropdownmenu';
|
|
9
|
+
import { ChevronDown } from '@elliemae/ds-icons';
|
|
10
|
+
import { PaginationDropdownButton } from '../styled.js';
|
|
11
|
+
|
|
12
|
+
const generateOption = value => {
|
|
13
|
+
if (typeof value === 'object') {
|
|
10
14
|
return value;
|
|
11
15
|
}
|
|
16
|
+
|
|
12
17
|
return {
|
|
13
18
|
dsId: value.toString(),
|
|
14
19
|
value,
|
|
15
20
|
label: value.toString(),
|
|
16
|
-
type:
|
|
21
|
+
type: 'single'
|
|
17
22
|
};
|
|
18
23
|
};
|
|
24
|
+
|
|
19
25
|
const getOptions = memoize((step, min, max) => {
|
|
20
26
|
const options = range(min, max + step, step).map(generateOption);
|
|
21
27
|
return min === 0 ? options.slice(1, options.length) : options;
|
|
22
28
|
});
|
|
23
|
-
|
|
29
|
+
|
|
30
|
+
const PerPageSelector = props => {
|
|
24
31
|
const [isOpened, setIsOpened] = useState(false);
|
|
25
|
-
const {
|
|
32
|
+
const {
|
|
33
|
+
pageSize,
|
|
34
|
+
onPageSizeChange,
|
|
35
|
+
perPageOptions,
|
|
36
|
+
maxPerPage,
|
|
37
|
+
perPageStep,
|
|
38
|
+
minPerPage
|
|
39
|
+
} = props;
|
|
26
40
|
const options = useMemo(() => {
|
|
27
|
-
if (perPageOptions)
|
|
28
|
-
return perPageOptions.map(generateOption);
|
|
41
|
+
if (perPageOptions) return perPageOptions.map(generateOption);
|
|
29
42
|
return getOptions(perPageStep, minPerPage, maxPerPage);
|
|
30
43
|
}, [maxPerPage, minPerPage, perPageOptions, perPageStep]);
|
|
31
44
|
const actionRef = useRef({});
|
|
@@ -34,13 +47,18 @@ const PerPageSelector = (props) => {
|
|
|
34
47
|
if (isOpened) {
|
|
35
48
|
actionRef.current.setActiveDescendant(pageSize.toString());
|
|
36
49
|
actionRef.current.scrollOptionIntoView(pageSize.toString());
|
|
37
|
-
}
|
|
50
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
51
|
+
|
|
38
52
|
}, [isOpened]);
|
|
39
|
-
const {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
53
|
+
const {
|
|
54
|
+
width
|
|
55
|
+
} = useOnElementResize(btnRef);
|
|
56
|
+
return /*#__PURE__*/_jsx(DSDropdownMenuV2, {
|
|
57
|
+
isOpened: isOpened,
|
|
58
|
+
options: options,
|
|
59
|
+
selectedOptions: {
|
|
60
|
+
[pageSize.toString()]: true
|
|
61
|
+
},
|
|
44
62
|
onOptionClick: (_, clickedOption) => {
|
|
45
63
|
onPageSizeChange(clickedOption.value);
|
|
46
64
|
setIsOpened(false);
|
|
@@ -52,23 +70,22 @@ const PerPageSelector = (props) => {
|
|
|
52
70
|
},
|
|
53
71
|
customOffset: [0, 2],
|
|
54
72
|
startPlacementPreference: "top-end",
|
|
55
|
-
actionRef,
|
|
73
|
+
actionRef: actionRef,
|
|
56
74
|
minWidth: width + 25,
|
|
57
75
|
maxHeight: 300,
|
|
58
|
-
HeaderComp: () =>
|
|
59
|
-
},
|
|
60
|
-
style: {
|
|
61
|
-
|
|
76
|
+
HeaderComp: () => 'Per Page'
|
|
77
|
+
}, void 0, /*#__PURE__*/_jsx("div", {
|
|
78
|
+
style: {
|
|
79
|
+
marginLeft: '32px'
|
|
80
|
+
}
|
|
81
|
+
}, void 0, /*#__PURE__*/_jsx(PaginationDropdownButton, {
|
|
62
82
|
buttonType: "raw",
|
|
63
83
|
onClick: () => setIsOpened(true),
|
|
64
84
|
"aria-pressed": isOpened,
|
|
65
85
|
innerRef: btnRef
|
|
66
|
-
}, pageSize, " / page",
|
|
67
|
-
color: [
|
|
86
|
+
}, void 0, pageSize, " / page", /*#__PURE__*/_jsx(ChevronDown, {
|
|
87
|
+
color: ['brand-primary', '700']
|
|
68
88
|
}))));
|
|
69
89
|
};
|
|
70
|
-
|
|
71
|
-
export {
|
|
72
|
-
PerPageSelector_default as default
|
|
73
|
-
};
|
|
74
|
-
//# sourceMappingURL=PerPageSelector.js.map
|
|
90
|
+
|
|
91
|
+
export { PerPageSelector as default };
|
package/esm/props.js
CHANGED
|
@@ -1,32 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { PropTypes } from 'react-desc';
|
|
2
|
+
|
|
3
3
|
const emptyFunc = () => null;
|
|
4
|
+
|
|
4
5
|
const propTypes = {
|
|
5
|
-
pageCount: PropTypes.number.description(
|
|
6
|
-
pageIndex: PropTypes.number.description(
|
|
7
|
-
canPreviousPage: PropTypes.bool.description(
|
|
8
|
-
canNextPage: PropTypes.bool.description(
|
|
9
|
-
pageSize: PropTypes.number.description(
|
|
10
|
-
showPerPageSelector: PropTypes.bool.description(
|
|
11
|
-
perPageOptions: PropTypes.arrayOf(PropTypes.oneOfType([
|
|
12
|
-
PropTypes.
|
|
13
|
-
PropTypes.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
pageDetails: PropTypes.arrayOf(PropTypes.string).description("Details to provide for each page").defaultValue([]),
|
|
28
|
-
pageDetailsTitle: PropTypes.string.description("The title of the details (usually a column of your dataset)").defaultValue(""),
|
|
29
|
-
width: PropTypes.any.description("Width for the container of the pagination").defaultValue("100%")
|
|
6
|
+
pageCount: PropTypes.number.description('How many pages are there'),
|
|
7
|
+
pageIndex: PropTypes.number.description('Index of the current page, starting from 1').defaultValue(1),
|
|
8
|
+
canPreviousPage: PropTypes.bool.description('Whether the previous button is disabled or not').defaultValue(true),
|
|
9
|
+
canNextPage: PropTypes.bool.description('Whether the next button is disabled or not').defaultValue(true),
|
|
10
|
+
pageSize: PropTypes.number.description('The current page size').defaultValue(10),
|
|
11
|
+
showPerPageSelector: PropTypes.bool.description('Whether to show the page selector').defaultValue(true),
|
|
12
|
+
perPageOptions: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
|
13
|
+
dsId: PropTypes.string,
|
|
14
|
+
value: PropTypes.number,
|
|
15
|
+
label: PropTypes.string,
|
|
16
|
+
type: PropTypes.oneOf(['single'])
|
|
17
|
+
})])).description('The available options for page size').defaultValue([10]),
|
|
18
|
+
perPageStep: PropTypes.number.description('Step for the per page options').defaultValue(5),
|
|
19
|
+
minPerPage: PropTypes.number.description('Step for the per page options').defaultValue(0),
|
|
20
|
+
maxPerPage: PropTypes.number.description('Step for the per page options').defaultValue(100),
|
|
21
|
+
onPageSizeChange: PropTypes.func.description('Function invoked when the page size changes').defaultValue(() => null),
|
|
22
|
+
onPreviousPage: PropTypes.func.description('Function invoked when the previous button is pressed').defaultValue(() => null),
|
|
23
|
+
onPageChange: PropTypes.func.description('Function invoked when the page changes').defaultValue(() => null),
|
|
24
|
+
onNextPage: PropTypes.func.description('Function invoked when next button is pressed').defaultValue(() => null),
|
|
25
|
+
pageDetails: PropTypes.arrayOf(PropTypes.string).description('Details to provide for each page').defaultValue([]),
|
|
26
|
+
pageDetailsTitle: PropTypes.string.description('The title of the details (usually a column of your dataset)').defaultValue(''),
|
|
27
|
+
width: PropTypes.any.description('Width for the container of the pagination').defaultValue('100%')
|
|
30
28
|
};
|
|
31
29
|
const defaultProps = {
|
|
32
30
|
pageIndex: 1,
|
|
@@ -43,11 +41,8 @@ const defaultProps = {
|
|
|
43
41
|
onNextPage: emptyFunc,
|
|
44
42
|
onPageChange: emptyFunc,
|
|
45
43
|
pageDetails: [],
|
|
46
|
-
pageDetailsTitle:
|
|
47
|
-
width:
|
|
44
|
+
pageDetailsTitle: '',
|
|
45
|
+
width: '100%'
|
|
48
46
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
propTypes
|
|
52
|
-
};
|
|
53
|
-
//# sourceMappingURL=props.js.map
|
|
47
|
+
|
|
48
|
+
export { defaultProps, propTypes };
|
package/esm/styled.js
CHANGED
|
@@ -1,84 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
const sizeToCss =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
top: 0;
|
|
13
|
-
left: 0;
|
|
14
|
-
right: 0;
|
|
15
|
-
bottom: 0;
|
|
16
|
-
border: 2px solid ${theme.colors.brand[700]};
|
|
17
|
-
pointer-events: none;
|
|
18
|
-
z-index: 7;
|
|
19
|
-
}`;
|
|
20
|
-
const PaginationContainer = styled(Grid)`
|
|
21
|
-
padding: 0 ${(props) => props.theme.space.xs};
|
|
22
|
-
height: 42px;
|
|
23
|
-
width: ${(props) => sizeToCss(props.width) || "100%"};
|
|
24
|
-
max-width: 100%;
|
|
25
|
-
align-items: center;
|
|
26
|
-
box-shadow: 0 -1px 3px 0 rgba(0, 0, 0, 0.5);
|
|
27
|
-
`;
|
|
28
|
-
const PaginationWrapper = styled.div`
|
|
29
|
-
display: flex;
|
|
30
|
-
justify-content: center;
|
|
31
|
-
align-items: center;
|
|
32
|
-
margin: 0 32px;
|
|
33
|
-
`;
|
|
34
|
-
const PaginationSeparator = styled(Grid)`
|
|
35
|
-
background-color: ${(props) => props.theme.colors.neutral[300]};
|
|
36
|
-
width: 1px;
|
|
37
|
-
height: ${(props) => props.height || "30px"};
|
|
38
|
-
`;
|
|
39
|
-
const PaginationBoldText = styled.span`
|
|
40
|
-
font-weight: ${(props) => props.theme.fontWeights.semibold};
|
|
41
|
-
${typography}
|
|
42
|
-
${space}
|
|
43
|
-
position: relative;
|
|
44
|
-
`;
|
|
45
|
-
const PaginationDropdownButton = styled(DSButtonV2)`
|
|
46
|
-
height: 42px;
|
|
47
|
-
display: flex;
|
|
48
|
-
justify-content: center;
|
|
49
|
-
align-items: center;
|
|
50
|
-
position: relative;
|
|
51
|
-
padding-left: 16px;
|
|
52
|
-
padding-right: 16px;
|
|
53
|
-
grid-gap: 8px;
|
|
54
|
-
font-size: 13px;
|
|
55
|
-
color: ${(props) => props.theme.colors.neutral[700]};
|
|
56
|
-
cursor: pointer;
|
|
57
|
-
border-radius: 0;
|
|
58
|
-
font-weight: ${(props) => props.theme.fontWeights.regular};
|
|
59
|
-
:focus {
|
|
60
|
-
${styledFocusCss}
|
|
61
|
-
}
|
|
62
|
-
`;
|
|
63
|
-
const PreviousNextPageButton = styled(DSButtonV2)`
|
|
64
|
-
height: 42px;
|
|
65
|
-
display: grid;
|
|
66
|
-
place-items: center;
|
|
67
|
-
position: relative;
|
|
68
|
-
padding-left: 8px;
|
|
69
|
-
padding-right: 8px;
|
|
70
|
-
border-radius: 0;
|
|
71
|
-
cursor: ${(props) => props.disabled ? "not-allowed" : "pointer"};
|
|
72
|
-
:focus {
|
|
73
|
-
${styledFocusCss}
|
|
74
|
-
}
|
|
75
|
-
`;
|
|
76
|
-
export {
|
|
77
|
-
PaginationBoldText,
|
|
78
|
-
PaginationContainer,
|
|
79
|
-
PaginationDropdownButton,
|
|
80
|
-
PaginationSeparator,
|
|
81
|
-
PaginationWrapper,
|
|
82
|
-
PreviousNextPageButton
|
|
1
|
+
import Grid from '@elliemae/ds-grid';
|
|
2
|
+
import { DSButtonV2 } from '@elliemae/ds-button';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { typography, space } from '@xstyled/styled-components';
|
|
5
|
+
|
|
6
|
+
const sizeToCss = size => typeof size === 'number' && !Number.isNaN(size) ? "".concat(size, "px") : size;
|
|
7
|
+
|
|
8
|
+
const styledFocusCss = _ref => {
|
|
9
|
+
let {
|
|
10
|
+
theme
|
|
11
|
+
} = _ref;
|
|
12
|
+
return "\n&:after {\n display: block;\n content: ' ';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n border: 2px solid ".concat(theme.colors.brand[700], ";\n pointer-events: none;\n z-index: 7;\n}");
|
|
83
13
|
};
|
|
84
|
-
|
|
14
|
+
|
|
15
|
+
const PaginationContainer = /*#__PURE__*/styled(Grid).withConfig({
|
|
16
|
+
componentId: "sc-mxz59e-0"
|
|
17
|
+
})(["padding:0 ", ";height:42px;width:", ";max-width:100%;align-items:center;box-shadow:0 -1px 3px 0 rgba(0,0,0,0.5);"], props => props.theme.space.xs, props => sizeToCss(props.width) || '100%');
|
|
18
|
+
const PaginationWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
19
|
+
componentId: "sc-mxz59e-1"
|
|
20
|
+
})(["display:flex;justify-content:center;align-items:center;margin:0 32px;"]);
|
|
21
|
+
const PaginationSeparator = /*#__PURE__*/styled(Grid).withConfig({
|
|
22
|
+
componentId: "sc-mxz59e-2"
|
|
23
|
+
})(["background-color:", ";width:1px;height:", ";"], props => props.theme.colors.neutral[300], props => props.height || '30px');
|
|
24
|
+
const PaginationBoldText = /*#__PURE__*/styled.span.withConfig({
|
|
25
|
+
componentId: "sc-mxz59e-3"
|
|
26
|
+
})(["font-weight:", ";", " ", " position:relative;"], props => props.theme.fontWeights.semibold, typography, space);
|
|
27
|
+
const PaginationDropdownButton = /*#__PURE__*/styled(DSButtonV2).withConfig({
|
|
28
|
+
componentId: "sc-mxz59e-4"
|
|
29
|
+
})(["height:42px;display:flex;justify-content:center;align-items:center;position:relative;padding-left:16px;padding-right:16px;grid-gap:8px;font-size:13px;color:", ";cursor:pointer;border-radius:0;font-weight:", ";:focus{", "}"], props => props.theme.colors.neutral[700], props => props.theme.fontWeights.regular, styledFocusCss);
|
|
30
|
+
const PreviousNextPageButton = /*#__PURE__*/styled(DSButtonV2).withConfig({
|
|
31
|
+
componentId: "sc-mxz59e-5"
|
|
32
|
+
})(["height:42px;display:grid;place-items:center;position:relative;padding-left:8px;padding-right:8px;border-radius:0;cursor:", ";:focus{", "}"], props => props.disabled ? 'not-allowed' : 'pointer', styledFocusCss);
|
|
33
|
+
|
|
34
|
+
export { PaginationBoldText, PaginationContainer, PaginationDropdownButton, PaginationSeparator, PaginationWrapper, PreviousNextPageButton };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-pagination",
|
|
3
|
-
"version": "2.2.0-
|
|
3
|
+
"version": "2.2.0-beta.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Pagination",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -72,12 +72,12 @@
|
|
|
72
72
|
"build": "node ../../scripts/build/build.js"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@elliemae/ds-button": "2.2.0-
|
|
76
|
-
"@elliemae/ds-dropdownmenu": "2.2.0-
|
|
77
|
-
"@elliemae/ds-grid": "2.2.0-
|
|
78
|
-
"@elliemae/ds-icons": "2.2.0-
|
|
79
|
-
"@elliemae/ds-props-helpers": "2.2.0-
|
|
80
|
-
"@elliemae/ds-utilities": "2.2.0-
|
|
75
|
+
"@elliemae/ds-button": "2.2.0-beta.0",
|
|
76
|
+
"@elliemae/ds-dropdownmenu": "2.2.0-beta.0",
|
|
77
|
+
"@elliemae/ds-grid": "2.2.0-beta.0",
|
|
78
|
+
"@elliemae/ds-icons": "2.2.0-beta.0",
|
|
79
|
+
"@elliemae/ds-props-helpers": "2.2.0-beta.0",
|
|
80
|
+
"@elliemae/ds-utilities": "2.2.0-beta.0",
|
|
81
81
|
"memoize-one": "~5.1.1",
|
|
82
82
|
"react-desc": "~4.1.3"
|
|
83
83
|
},
|
package/cjs/Pagination.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/Pagination.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';\nimport { describe } from 'react-desc';\nimport { PaginationContent } from './parts/PaginationContent';\nimport { propTypes, defaultProps } from './props';\nimport { DSPaginationProps } from './index.d';\n\nconst DSPagination: React.ComponentType<DSPaginationProps> = (props) => {\n const propsWithDefault = useMemoMergePropsWithDefault(props, defaultProps);\n useValidateTypescriptPropTypes(propsWithDefault, propTypes);\n\n return <PaginationContent {...propsWithDefault} />;\n};\n\nDSPagination.propTypes = propTypes;\nconst DSPaginationWithSchema = describe(DSPagination).description('DSPagination');\nDSPaginationWithSchema.propTypes = propTypes;\n\nexport { DSPagination, DSPaginationWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAClB,8BAA6E;AAC7E,wBAAyB;AACzB,+BAAkC;AAClC,mBAAwC;AAGxC,MAAM,eAAuD,CAAC,UAAU;AACtE,QAAM,mBAAmB,0DAA6B,OAAO;AAC7D,8DAA+B,kBAAkB;AAEjD,SAAO,mDAAC,4CAAD;AAAA,OAAuB;AAAA;AAAA;AAGhC,aAAa,YAAY;AACzB,MAAM,yBAAyB,gCAAS,cAAc,YAAY;AAClE,uBAAuB,YAAY;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/PaginationDataTestID.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["export const PAGINATION_DATA_TESTID = {\n PREVIOUS_BUTTON: 'data-table-pagination-prev-button',\n NEXT_BUTTON: 'data-table-pagination-next-button',\n CONTAINER: 'data-table-pagination-container',\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,MAAM,yBAAyB;AAAA,EACpC,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,WAAW;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/hooks/usePaginationSearch.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import { useCallback, useEffect, useRef, useState } from 'react';\n\nexport const usePaginationSearch = (\n pageCount: number,\n actionRef: React.MutableRefObject<any>,\n): React.KeyboardEventHandler => {\n const [searchValue, setSearchValue] = useState('');\n const [shouldResetSearchValue, setShouldResetSearchValue] = useState(true);\n\n const timeoutRef = useRef<NodeJS.Timeout>(null);\n\n useEffect(() => {\n if (searchValue !== '' && Number.parseInt(searchValue, 10) <= pageCount) {\n actionRef.current.setActiveDescendant(searchValue);\n actionRef.current.scrollOptionIntoView(searchValue);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [searchValue]);\n\n const onKeyDown = useCallback(\n (e) => {\n if (e.code.startsWith('Digit')) {\n if (shouldResetSearchValue) setSearchValue(e.key);\n else setSearchValue((prevValue) => prevValue + e.key);\n\n setShouldResetSearchValue(false);\n clearTimeout(timeoutRef.current);\n timeoutRef.current = setTimeout(() => {\n setShouldResetSearchValue(true);\n }, 1000);\n }\n },\n [shouldResetSearchValue],\n );\n\n return onKeyDown;\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAyD;AAElD,MAAM,sBAAsB,CACjC,WACA,cAC+B;AAC/B,QAAM,CAAC,aAAa,kBAAkB,2BAAS;AAC/C,QAAM,CAAC,wBAAwB,6BAA6B,2BAAS;AAErE,QAAM,aAAa,yBAAuB;AAE1C,8BAAU,MAAM;AACd,QAAI,gBAAgB,MAAM,OAAO,SAAS,aAAa,OAAO,WAAW;AACvE,gBAAU,QAAQ,oBAAoB;AACtC,gBAAU,QAAQ,qBAAqB;AAAA;AAAA,KAGxC,CAAC;AAEJ,QAAM,YAAY,8BAChB,CAAC,MAAM;AACL,QAAI,EAAE,KAAK,WAAW,UAAU;AAC9B,UAAI;AAAwB,uBAAe,EAAE;AAAA;AACxC,uBAAe,CAAC,cAAc,YAAY,EAAE;AAEjD,gCAA0B;AAC1B,mBAAa,WAAW;AACxB,iBAAW,UAAU,WAAW,MAAM;AACpC,kCAA0B;AAAA,SACzB;AAAA;AAAA,KAGP,CAAC;AAGH,SAAO;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/cjs/index.d.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/index.d.ts", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["export interface DSPaginationProps {\n pageCount: number;\n pageIndex?: number;\n canPreviousPage?: boolean;\n canNextPage?: boolean;\n pageSize?: number;\n showPerPageSelector?: boolean;\n perPageOptions?: number[];\n perPageStep?: number;\n minPerPage?: number;\n maxPerPage?: number;\n onPageSizeChange?: (pageSize: number) => void;\n onPreviousPage?: () => void;\n onNextPage?: () => void;\n onPageChange?: (page: number) => void;\n pageDetails?: string[];\n pageDetailsTitle?: string;\n width?: any;\n}\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA,YAAuB;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/cjs/index.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/index.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["export * from './Pagination';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA,YAAuB;ADAvB,wBAAc;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/parts/PageNextButton.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable react/prop-types */\nimport React from 'react';\nimport { ChevronRight } from '@elliemae/ds-icons';\nimport { PAGINATION_DATA_TESTID } from '../PaginationDataTestID';\nimport { PreviousNextPageButton } from '../styled';\nimport { DSPaginationProps } from '../index.d';\n\nexport const PageNextButton: React.ComponentType<Pick<DSPaginationProps, 'onNextPage' | 'canNextPage'>> = ({\n onNextPage,\n canNextPage,\n}) => (\n <PreviousNextPageButton\n onClick={() => {\n if (canNextPage) onNextPage();\n }}\n disabled={!canNextPage}\n buttonType=\"raw\"\n data-testid={PAGINATION_DATA_TESTID.NEXT_BUTTON}\n HeaderComp={() => 'Page'}\n >\n <ChevronRight color={canNextPage ? ['brand-primary', '700'] : ['neutral', '500']} />\n </PreviousNextPageButton>\n);\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAkB;AAClB,sBAA6B;AAC7B,kCAAuC;AACvC,oBAAuC;AAGhC,MAAM,iBAA6F,CAAC;AAAA,EACzG;AAAA,EACA;AAAA,MAEA,mDAAC,sCAAD;AAAA,EACE,SAAS,MAAM;AACb,QAAI;AAAa;AAAA;AAAA,EAEnB,UAAU,CAAC;AAAA,EACX,YAAW;AAAA,EACX,eAAa,mDAAuB;AAAA,EACpC,YAAY,MAAM;AAAA,GAElB,mDAAC,8BAAD;AAAA,EAAc,OAAO,cAAc,CAAC,iBAAiB,SAAS,CAAC,WAAW;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/parts/PagePrevButton.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable react/prop-types */\nimport React from 'react';\nimport { ChevronLeft } from '@elliemae/ds-icons';\nimport { PAGINATION_DATA_TESTID } from '../PaginationDataTestID';\nimport { PreviousNextPageButton } from '../styled';\nimport { DSPaginationProps } from '../index.d';\n\nexport const PagePrevButton: React.ComponentType<Pick<DSPaginationProps, 'onPreviousPage' | 'canPreviousPage'>> = ({\n onPreviousPage,\n canPreviousPage,\n}) => (\n <PreviousNextPageButton\n onClick={() => {\n if (canPreviousPage) onPreviousPage();\n }}\n disabled={!canPreviousPage}\n buttonType=\"raw\"\n data-testid={PAGINATION_DATA_TESTID.PREVIOUS_BUTTON}\n >\n <ChevronLeft color={canPreviousPage ? ['brand-primary', '700'] : ['neutral', '500']} />\n </PreviousNextPageButton>\n);\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAkB;AAClB,sBAA4B;AAC5B,kCAAuC;AACvC,oBAAuC;AAGhC,MAAM,iBAAqG,CAAC;AAAA,EACjH;AAAA,EACA;AAAA,MAEA,mDAAC,sCAAD;AAAA,EACE,SAAS,MAAM;AACb,QAAI;AAAiB;AAAA;AAAA,EAEvB,UAAU,CAAC;AAAA,EACX,YAAW;AAAA,EACX,eAAa,mDAAuB;AAAA,GAEpC,mDAAC,6BAAD;AAAA,EAAa,OAAO,kBAAkB,CAAC,iBAAiB,SAAS,CAAC,WAAW;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|