@elliemae/ds-pagination 2.3.0-alpha.8 → 2.3.0-next.2

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.
Files changed (83) hide show
  1. package/cjs/Pagination.js +35 -0
  2. package/cjs/PaginationDataTestID.js +11 -0
  3. package/cjs/hooks/usePaginationSearch.js +32 -0
  4. package/cjs/index.d.js +2 -0
  5. package/cjs/index.js +10 -0
  6. package/cjs/parts/PageNextButton.js +33 -0
  7. package/cjs/parts/PagePrevButton.js +32 -0
  8. package/cjs/parts/PaginationContent.js +95 -0
  9. package/cjs/parts/Paginator.js +153 -0
  10. package/cjs/parts/PerPageSelector.js +102 -0
  11. package/cjs/props.js +53 -0
  12. package/cjs/styled.js +57 -0
  13. package/esm/Pagination.js +26 -0
  14. package/esm/PaginationDataTestID.js +7 -0
  15. package/{dist/esm → esm}/hooks/usePaginationSearch.js +13 -16
  16. package/esm/index.d.js +1 -0
  17. package/esm/index.js +1 -0
  18. package/esm/parts/PageNextButton.js +25 -0
  19. package/esm/parts/PagePrevButton.js +24 -0
  20. package/esm/parts/PaginationContent.js +85 -0
  21. package/esm/parts/Paginator.js +146 -0
  22. package/esm/parts/PerPageSelector.js +95 -0
  23. package/esm/props.js +48 -0
  24. package/esm/styled.js +40 -0
  25. package/package.json +44 -44
  26. package/types/Pagination.d.ts +5 -0
  27. package/types/PaginationDataTestID.d.ts +5 -0
  28. package/types/hooks/usePaginationSearch.d.ts +1 -0
  29. package/types/index.d.ts +1 -0
  30. package/types/parts/PageNextButton.d.ts +3 -0
  31. package/types/parts/PagePrevButton.d.ts +3 -0
  32. package/types/parts/PaginationContent.d.ts +3 -0
  33. package/types/parts/Paginator.d.ts +10 -0
  34. package/types/parts/PerPageSelector.d.ts +4 -0
  35. package/types/props.d.ts +20 -0
  36. package/types/styled.d.ts +16 -0
  37. package/dist/cjs/Pagination.js +0 -50
  38. package/dist/cjs/Pagination.js.map +0 -7
  39. package/dist/cjs/PaginationDataTestID.js +0 -39
  40. package/dist/cjs/PaginationDataTestID.js.map +0 -7
  41. package/dist/cjs/hooks/usePaginationSearch.js +0 -60
  42. package/dist/cjs/hooks/usePaginationSearch.js.map +0 -7
  43. package/dist/cjs/index.d.js +0 -27
  44. package/dist/cjs/index.d.js.map +0 -7
  45. package/dist/cjs/index.js +0 -28
  46. package/dist/cjs/index.js.map +0 -7
  47. package/dist/cjs/parts/PageNextButton.js +0 -53
  48. package/dist/cjs/parts/PageNextButton.js.map +0 -7
  49. package/dist/cjs/parts/PagePrevButton.js +0 -52
  50. package/dist/cjs/parts/PagePrevButton.js.map +0 -7
  51. package/dist/cjs/parts/PaginationContent.js +0 -92
  52. package/dist/cjs/parts/PaginationContent.js.map +0 -7
  53. package/dist/cjs/parts/Paginator.js +0 -131
  54. package/dist/cjs/parts/Paginator.js.map +0 -7
  55. package/dist/cjs/parts/PerPageSelector.js +0 -103
  56. package/dist/cjs/parts/PerPageSelector.js.map +0 -7
  57. package/dist/cjs/props.js +0 -82
  58. package/dist/cjs/props.js.map +0 -7
  59. package/dist/cjs/styled.js +0 -113
  60. package/dist/cjs/styled.js.map +0 -7
  61. package/dist/esm/Pagination.js +0 -21
  62. package/dist/esm/Pagination.js.map +0 -7
  63. package/dist/esm/PaginationDataTestID.js +0 -10
  64. package/dist/esm/PaginationDataTestID.js.map +0 -7
  65. package/dist/esm/hooks/usePaginationSearch.js.map +0 -7
  66. package/dist/esm/index.d.js +0 -2
  67. package/dist/esm/index.d.js.map +0 -7
  68. package/dist/esm/index.js +0 -3
  69. package/dist/esm/index.js.map +0 -7
  70. package/dist/esm/parts/PageNextButton.js +0 -24
  71. package/dist/esm/parts/PageNextButton.js.map +0 -7
  72. package/dist/esm/parts/PagePrevButton.js +0 -23
  73. package/dist/esm/parts/PagePrevButton.js.map +0 -7
  74. package/dist/esm/parts/PaginationContent.js +0 -63
  75. package/dist/esm/parts/PaginationContent.js.map +0 -7
  76. package/dist/esm/parts/Paginator.js +0 -102
  77. package/dist/esm/parts/Paginator.js.map +0 -7
  78. package/dist/esm/parts/PerPageSelector.js +0 -74
  79. package/dist/esm/parts/PerPageSelector.js.map +0 -7
  80. package/dist/esm/props.js +0 -53
  81. package/dist/esm/props.js.map +0 -7
  82. package/dist/esm/styled.js +0 -84
  83. package/dist/esm/styled.js.map +0 -7
@@ -1,31 +1,28 @@
1
- import * as React from "react";
2
- import { useCallback, useEffect, useRef, useState } from "react";
1
+ import 'core-js/modules/web.dom-collections.iterator.js';
2
+ import { useState, useRef, useEffect, useCallback } from 'react';
3
+
3
4
  const usePaginationSearch = (pageCount, actionRef) => {
4
- const [searchValue, setSearchValue] = useState("");
5
+ const [searchValue, setSearchValue] = useState('');
5
6
  const [shouldResetSearchValue, setShouldResetSearchValue] = useState(true);
6
7
  const timeoutRef = useRef(null);
7
8
  useEffect(() => {
8
- if (searchValue !== "" && Number.parseInt(searchValue, 10) <= pageCount) {
9
+ if (searchValue !== '' && Number.parseInt(searchValue, 10) <= pageCount) {
9
10
  actionRef.current.setActiveDescendant(searchValue);
10
11
  actionRef.current.scrollOptionIntoView(searchValue);
11
- }
12
+ } // eslint-disable-next-line react-hooks/exhaustive-deps
13
+
12
14
  }, [searchValue]);
13
- const onKeyDown = useCallback((e) => {
14
- if (e.code.startsWith("Digit")) {
15
- if (shouldResetSearchValue)
16
- setSearchValue(e.key);
17
- else
18
- setSearchValue((prevValue) => prevValue + e.key);
15
+ const onKeyDown = useCallback(e => {
16
+ if (e.code.startsWith('Digit')) {
17
+ if (shouldResetSearchValue) setSearchValue(e.key);else setSearchValue(prevValue => prevValue + e.key);
19
18
  setShouldResetSearchValue(false);
20
19
  clearTimeout(timeoutRef.current);
21
20
  timeoutRef.current = setTimeout(() => {
22
21
  setShouldResetSearchValue(true);
23
- }, 1e3);
22
+ }, 1000);
24
23
  }
25
24
  }, [shouldResetSearchValue]);
26
25
  return onKeyDown;
27
26
  };
28
- export {
29
- usePaginationSearch
30
- };
31
- //# sourceMappingURL=usePaginationSearch.js.map
27
+
28
+ export { usePaginationSearch };
package/esm/index.d.js ADDED
@@ -0,0 +1 @@
1
+
package/esm/index.js ADDED
@@ -0,0 +1 @@
1
+ export { DSPagination, DSPaginationWithSchema } from './Pagination.js';
@@ -0,0 +1,25 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import 'react';
3
+ import { ChevronRight } from '@elliemae/ds-icons';
4
+ import { PAGINATION_DATA_TESTID } from '../PaginationDataTestID.js';
5
+ import { PreviousNextPageButton } from '../styled.js';
6
+
7
+ const PageNextButton = _ref => {
8
+ let {
9
+ onNextPage,
10
+ canNextPage
11
+ } = _ref;
12
+ return /*#__PURE__*/_jsx(PreviousNextPageButton, {
13
+ onClick: () => {
14
+ if (canNextPage) onNextPage();
15
+ },
16
+ disabled: !canNextPage,
17
+ buttonType: "raw",
18
+ "data-testid": PAGINATION_DATA_TESTID.NEXT_BUTTON,
19
+ HeaderComp: () => 'Page'
20
+ }, void 0, /*#__PURE__*/_jsx(ChevronRight, {
21
+ color: canNextPage ? ['brand-primary', '700'] : ['neutral', '500']
22
+ }));
23
+ };
24
+
25
+ export { PageNextButton };
@@ -0,0 +1,24 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import 'react';
3
+ import { ChevronLeft } from '@elliemae/ds-icons';
4
+ import { PAGINATION_DATA_TESTID } from '../PaginationDataTestID.js';
5
+ import { PreviousNextPageButton } from '../styled.js';
6
+
7
+ const PagePrevButton = _ref => {
8
+ let {
9
+ onPreviousPage,
10
+ canPreviousPage
11
+ } = _ref;
12
+ return /*#__PURE__*/_jsx(PreviousNextPageButton, {
13
+ onClick: () => {
14
+ if (canPreviousPage) onPreviousPage();
15
+ },
16
+ disabled: !canPreviousPage,
17
+ buttonType: "raw",
18
+ "data-testid": PAGINATION_DATA_TESTID.PREVIOUS_BUTTON
19
+ }, void 0, /*#__PURE__*/_jsx(ChevronLeft, {
20
+ color: canPreviousPage ? ['brand-primary', '700'] : ['neutral', '500']
21
+ }));
22
+ };
23
+
24
+ export { PagePrevButton };
@@ -0,0 +1,85 @@
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
6
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
7
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
8
+ import 'react';
9
+ import Grid from '@elliemae/ds-grid';
10
+ import { useGetGlobalAttributes } from '@elliemae/ds-props-helpers';
11
+ import { PaginationContainer, PaginationWrapper, PaginationSeparator } from '../styled.js';
12
+ import PerPageSelector from './PerPageSelector.js';
13
+ import Paginator from './Paginator.js';
14
+ import { PAGINATION_DATA_TESTID } from '../PaginationDataTestID.js';
15
+ import { PagePrevButton } from './PagePrevButton.js';
16
+ import { PageNextButton } from './PageNextButton.js';
17
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
18
+
19
+ var _PaginationSeparator;
20
+
21
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
22
+
23
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
24
+ const PaginationContent = props => {
25
+ const {
26
+ pageIndex,
27
+ pageSize,
28
+ canPreviousPage,
29
+ canNextPage,
30
+ onPageSizeChange,
31
+ onNextPage,
32
+ onPreviousPage,
33
+ onPageChange,
34
+ pageCount,
35
+ showPerPageSelector,
36
+ pageDetails,
37
+ pageDetailsTitle,
38
+ perPageOptions,
39
+ maxPerPage,
40
+ perPageStep,
41
+ minPerPage,
42
+ width
43
+ } = props;
44
+ const globalAttributes = useGetGlobalAttributes(props);
45
+ return /*#__PURE__*/jsx(PaginationContainer, _objectSpread(_objectSpread({
46
+ justifyContent: "center",
47
+ alignItems: "center",
48
+ width: width.toString(),
49
+ "data-testid": PAGINATION_DATA_TESTID.CONTAINER,
50
+ cols: ['minmax(auto, 80%)']
51
+ }, globalAttributes), {}, {
52
+ children: /*#__PURE__*/_jsx(PaginationWrapper, {}, void 0, showPerPageSelector && /*#__PURE__*/jsxs(Fragment, {
53
+ children: [/*#__PURE__*/_jsx(PerPageSelector, {
54
+ pageSize: pageSize,
55
+ onPageSizeChange: onPageSizeChange,
56
+ perPageOptions: perPageOptions,
57
+ maxPerPage: maxPerPage,
58
+ perPageStep: perPageStep,
59
+ minPerPage: minPerPage
60
+ }), _PaginationSeparator || (_PaginationSeparator = /*#__PURE__*/_jsx(PaginationSeparator, {
61
+ mr: 24
62
+ }))]
63
+ }), /*#__PURE__*/_jsx(Grid, {
64
+ mr: "32px",
65
+ alignItems: "center",
66
+ style: {
67
+ gridAutoFlow: 'column'
68
+ }
69
+ }, void 0, /*#__PURE__*/_jsx(PagePrevButton, {
70
+ canPreviousPage: canPreviousPage,
71
+ onPreviousPage: onPreviousPage
72
+ }), /*#__PURE__*/_jsx(Paginator, {
73
+ pageCount: pageCount,
74
+ pageIndex: pageIndex,
75
+ onPageChange: onPageChange,
76
+ pageDetails: pageDetails,
77
+ pageDetailsTitle: pageDetailsTitle
78
+ }), /*#__PURE__*/_jsx(PageNextButton, {
79
+ canNextPage: canNextPage,
80
+ onNextPage: onNextPage
81
+ })))
82
+ }));
83
+ };
84
+
85
+ export { PaginationContent };
@@ -0,0 +1,146 @@
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.reduce.js';
4
+ import 'core-js/modules/esnext.iterator.constructor.js';
5
+ import 'core-js/modules/esnext.iterator.reduce.js';
6
+ import 'core-js/modules/esnext.async-iterator.map.js';
7
+ import 'core-js/modules/esnext.iterator.map.js';
8
+ import { useState, useRef, useMemo, useEffect } from 'react';
9
+ import { Checkmark, ChevronDown } from '@elliemae/ds-icons';
10
+ import { useOnElementResize } from '@elliemae/ds-utilities';
11
+ import Grid from '@elliemae/ds-grid';
12
+ import { DSDropdownMenuV2 } from '@elliemae/ds-dropdownmenu';
13
+ import { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';
14
+ import { PaginationSeparator, PaginationDropdownButton, PaginationBoldText, InvisibleDetail, PaginationDetail } from '../styled.js';
15
+ import { usePaginationSearch } from '../hooks/usePaginationSearch.js';
16
+ import { jsxs, Fragment } from 'react/jsx-runtime';
17
+
18
+ var _div, _PaginationSeparator, _PaginationSeparator2, _PaginationSeparator3, _PaginationSeparator4;
19
+
20
+ const Paginator = props => {
21
+ var _span2;
22
+
23
+ const {
24
+ pageIndex,
25
+ pageCount,
26
+ onPageChange,
27
+ pageDetails,
28
+ pageDetailsTitle
29
+ } = props;
30
+ const [isOpened, setIsOpened] = useState(false);
31
+ const btnRef = useRef(null);
32
+ const pageInfoRef = useRef(null);
33
+ const longestPageDetail = pageDetails.reduce((acc, cur) => acc.length > cur.length ? acc : cur, '');
34
+ const {
35
+ width: btnWidth
36
+ } = useOnElementResize(btnRef);
37
+ const {
38
+ width: txtWidth
39
+ } = useOnElementResize(pageInfoRef);
40
+ const options = useMemo(() => new Array(pageCount).fill(0).map((_, index) => {
41
+ var _span;
42
+
43
+ const option = {
44
+ dsId: (index + 1).toString(),
45
+ label: (index + 1).toString(),
46
+ value: index + 1,
47
+ type: 'single'
48
+ };
49
+
50
+ if (pageDetails !== null && pageDetails !== void 0 && pageDetails.length) {
51
+ option.render = () => /*#__PURE__*/_jsx(Grid, {
52
+ cols: ['16px', "".concat(txtWidth + 16, "px"), 'auto'],
53
+ gutter: "xxs",
54
+ alignItems: "center"
55
+ }, void 0, pageIndex === index ? /*#__PURE__*/_jsx(Checkmark, {
56
+ size: "s",
57
+ color: ['brand-primary', '600']
58
+ }) : _div || (_div = /*#__PURE__*/_jsx("div", {})), _span || (_span = /*#__PURE__*/_jsx("span", {}, void 0, index + 1)), /*#__PURE__*/_jsx("span", {
59
+ style: {
60
+ whiteSpace: 'nowrap',
61
+ textOverflow: 'ellipsis',
62
+ overflow: 'hidden'
63
+ }
64
+ }, void 0, pageDetails[index]));
65
+ }
66
+
67
+ return option;
68
+ }), [pageCount, pageDetails, pageIndex, txtWidth]);
69
+ const actionRef = useRef({});
70
+ useEffect(() => {
71
+ if (isOpened) {
72
+ actionRef.current.setActiveDescendant((pageIndex + 1).toString());
73
+ actionRef.current.scrollOptionIntoView((pageIndex + 1).toString());
74
+ } // eslint-disable-next-line react-hooks/exhaustive-deps
75
+
76
+ }, [isOpened]);
77
+ const onKeyDown = usePaginationSearch(pageCount, actionRef);
78
+ return /*#__PURE__*/jsxs(Fragment, {
79
+ children: [_PaginationSeparator || (_PaginationSeparator = /*#__PURE__*/_jsx(PaginationSeparator, {})), /*#__PURE__*/_jsx(DSDropdownMenuV2, {
80
+ isOpened: isOpened,
81
+ options: options,
82
+ selectedOptions: {
83
+ [(pageIndex + 1).toString()]: true
84
+ },
85
+ onOptionClick: (_, clickedOption) => {
86
+ var _btnRef$current;
87
+
88
+ onPageChange(clickedOption.value);
89
+ setIsOpened(false);
90
+ (_btnRef$current = btnRef.current) === null || _btnRef$current === void 0 ? void 0 : _btnRef$current.focus();
91
+ },
92
+ onClickOutside: () => {
93
+ var _btnRef$current2;
94
+
95
+ setIsOpened(false);
96
+ (_btnRef$current2 = btnRef.current) === null || _btnRef$current2 === void 0 ? void 0 : _btnRef$current2.focus();
97
+ },
98
+ customOffset: [0, 2],
99
+ startPlacementPreference: "top-end",
100
+ actionRef: actionRef,
101
+ onKeyDown: onKeyDown,
102
+ minWidth: btnWidth + 23,
103
+ maxHeight: 300,
104
+ HeaderComp: () => pageDetailsTitle !== '' ? /*#__PURE__*/_jsx(Grid, {
105
+ cols: ["".concat(txtWidth + 50, "px"), '8px', 'auto']
106
+ }, void 0, /*#__PURE__*/_jsx("span", {
107
+ style: {
108
+ marginLeft: '8px'
109
+ }
110
+ }, void 0, "Page"), _PaginationSeparator2 || (_PaginationSeparator2 = /*#__PURE__*/_jsx(PaginationSeparator, {
111
+ height: "100%"
112
+ })), _span2 || (_span2 = /*#__PURE__*/_jsx("span", {}, void 0, pageDetailsTitle))) : 'Page'
113
+ }, void 0, /*#__PURE__*/_jsx(PaginationDropdownButton, {
114
+ buttonType: "raw",
115
+ onClick: () => setIsOpened(prev => !prev),
116
+ innerRef: btnRef
117
+ }, void 0, /*#__PURE__*/_jsx(Grid, {
118
+ gutter: "xxs",
119
+ alignItems: "center",
120
+ cols: pageDetails.length !== 0 ? ['auto', 'min-content', 'minmax(100px, 70%)', 'min-content'] : ['auto', 'min-content']
121
+ }, void 0, /*#__PURE__*/jsxs(Grid, {
122
+ alignItems: "center",
123
+ gutter: "xxxs",
124
+ ref: pageInfoRef,
125
+ style: {
126
+ gridAutoFlow: 'column'
127
+ },
128
+ children: [/*#__PURE__*/_jsx(PaginationBoldText, {
129
+ fontSize: "18px"
130
+ }, void 0, pageIndex + 1), " / ", pageCount]
131
+ }), pageDetails.length !== 0 && /*#__PURE__*/jsxs(Fragment, {
132
+ children: [_PaginationSeparator3 || (_PaginationSeparator3 = /*#__PURE__*/_jsx(PaginationSeparator, {
133
+ height: "12px",
134
+ ml: "8px"
135
+ })), /*#__PURE__*/_jsx(PaginationBoldText, {
136
+ fontSize: "13px"
137
+ }, void 0, /*#__PURE__*/_jsx(InvisibleDetail, {}, void 0, longestPageDetail), /*#__PURE__*/_jsx(PaginationDetail, {}, void 0, /*#__PURE__*/_jsx(SimpleTruncatedTooltipText, {
138
+ value: pageDetails[pageIndex]
139
+ }, void 0, pageDetails[pageIndex])))]
140
+ }), /*#__PURE__*/_jsx(ChevronDown, {
141
+ color: ['brand-primary', '700']
142
+ })))), _PaginationSeparator4 || (_PaginationSeparator4 = /*#__PURE__*/_jsx(PaginationSeparator, {}))]
143
+ });
144
+ };
145
+
146
+ export { Paginator as default };
@@ -0,0 +1,95 @@
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') {
14
+ return value;
15
+ }
16
+
17
+ return {
18
+ dsId: value.toString(),
19
+ value,
20
+ label: value.toString(),
21
+ type: 'single'
22
+ };
23
+ };
24
+
25
+ const getOptions = memoize((step, min, max) => {
26
+ const options = range(min, max + step, step).map(generateOption);
27
+ return min === 0 ? options.slice(1, options.length) : options;
28
+ });
29
+
30
+ const PerPageSelector = props => {
31
+ const [isOpened, setIsOpened] = useState(false);
32
+ const {
33
+ pageSize,
34
+ onPageSizeChange,
35
+ perPageOptions,
36
+ maxPerPage,
37
+ perPageStep,
38
+ minPerPage
39
+ } = props;
40
+ const options = useMemo(() => {
41
+ if (perPageOptions) return perPageOptions.map(generateOption);
42
+ return getOptions(perPageStep, minPerPage, maxPerPage);
43
+ }, [maxPerPage, minPerPage, perPageOptions, perPageStep]);
44
+ const actionRef = useRef({});
45
+ const btnRef = useRef(null);
46
+ useEffect(() => {
47
+ if (isOpened) {
48
+ actionRef.current.setActiveDescendant(pageSize.toString());
49
+ actionRef.current.scrollOptionIntoView(pageSize.toString());
50
+ } // eslint-disable-next-line react-hooks/exhaustive-deps
51
+
52
+ }, [isOpened]);
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
+ },
62
+ onOptionClick: (_, clickedOption) => {
63
+ var _btnRef$current;
64
+
65
+ onPageSizeChange(clickedOption.value);
66
+ setIsOpened(false);
67
+ (_btnRef$current = btnRef.current) === null || _btnRef$current === void 0 ? void 0 : _btnRef$current.focus();
68
+ },
69
+ onClickOutside: () => {
70
+ var _btnRef$current2;
71
+
72
+ setIsOpened(false);
73
+ (_btnRef$current2 = btnRef.current) === null || _btnRef$current2 === void 0 ? void 0 : _btnRef$current2.focus();
74
+ },
75
+ customOffset: [0, 2],
76
+ startPlacementPreference: "top-end",
77
+ actionRef: actionRef,
78
+ minWidth: width + 25,
79
+ maxHeight: 300,
80
+ HeaderComp: () => 'Per Page'
81
+ }, void 0, /*#__PURE__*/_jsx("div", {
82
+ style: {
83
+ marginLeft: '32px'
84
+ }
85
+ }, void 0, /*#__PURE__*/_jsx(PaginationDropdownButton, {
86
+ buttonType: "raw",
87
+ onClick: () => setIsOpened(prev => !prev),
88
+ "aria-pressed": isOpened,
89
+ innerRef: btnRef
90
+ }, void 0, pageSize, " / page", /*#__PURE__*/_jsx(ChevronDown, {
91
+ color: ['brand-primary', '700']
92
+ }))));
93
+ };
94
+
95
+ export { PerPageSelector as default };
package/esm/props.js ADDED
@@ -0,0 +1,48 @@
1
+ import { PropTypes } from '@elliemae/ds-props-helpers';
2
+
3
+ const emptyFunc = () => null;
4
+
5
+ const propTypes = {
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%')
28
+ };
29
+ const defaultProps = {
30
+ pageIndex: 1,
31
+ canPreviousPage: true,
32
+ canNextPage: true,
33
+ pageSize: 10,
34
+ showPerPageSelector: true,
35
+ perPageOptions: [10],
36
+ perPageStep: 5,
37
+ minPerPage: 0,
38
+ maxPerPage: 100,
39
+ onPageSizeChange: emptyFunc,
40
+ onPreviousPage: emptyFunc,
41
+ onNextPage: emptyFunc,
42
+ onPageChange: emptyFunc,
43
+ pageDetails: [],
44
+ pageDetailsTitle: '',
45
+ width: '100%'
46
+ };
47
+
48
+ export { defaultProps, propTypes };
package/esm/styled.js ADDED
@@ -0,0 +1,40 @@
1
+ import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
2
+ import Grid from '@elliemae/ds-grid';
3
+ import { DSButtonV2 } from '@elliemae/ds-button';
4
+ import styled from 'styled-components';
5
+ import { typography, space } from '@xstyled/styled-components';
6
+ import { css } from '@elliemae/ds-system';
7
+
8
+ var _templateObject;
9
+ const styledFocusCss = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\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 ", ";\n pointer-events: none;\n z-index: 7;\n }\n"])), _ref => {
10
+ let {
11
+ theme
12
+ } = _ref;
13
+ return theme.colors.brand[700];
14
+ });
15
+ const PaginationContainer = /*#__PURE__*/styled(Grid).withConfig({
16
+ componentId: "sc-mxz59e-0"
17
+ })(["height:42px;max-width:100%;align-items:center;box-shadow:0 -1px 3px 0 rgba(0,0,0,0.5);"]);
18
+ const PaginationWrapper = /*#__PURE__*/styled.div.withConfig({
19
+ componentId: "sc-mxz59e-1"
20
+ })(["display:flex;justify-content:center;align-items:center;"]);
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 InvisibleDetail = /*#__PURE__*/styled.div.withConfig({
28
+ componentId: "sc-mxz59e-4"
29
+ })(["opacity:0;padding-right:8px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"]);
30
+ const PaginationDetail = /*#__PURE__*/styled.span.withConfig({
31
+ componentId: "sc-mxz59e-5"
32
+ })(["position:absolute;top:0;left:0;width:100%;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"]);
33
+ const PaginationDropdownButton = /*#__PURE__*/styled(DSButtonV2).withConfig({
34
+ componentId: "sc-mxz59e-6"
35
+ })(["height:42px;display:grid;grid-auto-flow:column;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{", "}white-space:nowrap;"], props => props.theme.colors.neutral[700], props => props.theme.fontWeights.regular, styledFocusCss);
36
+ const PreviousNextPageButton = /*#__PURE__*/styled(DSButtonV2).withConfig({
37
+ componentId: "sc-mxz59e-7"
38
+ })(["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);
39
+
40
+ export { InvisibleDetail, PaginationBoldText, PaginationContainer, PaginationDetail, PaginationDropdownButton, PaginationSeparator, PaginationWrapper, PreviousNextPageButton };
package/package.json CHANGED
@@ -1,58 +1,55 @@
1
1
  {
2
2
  "name": "@elliemae/ds-pagination",
3
- "version": "2.3.0-alpha.8",
3
+ "version": "2.3.0-next.2",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Pagination",
6
- "files": [
7
- "dist"
8
- ],
9
- "module": "./dist/esm/index.js",
10
- "main": "./dist/cjs/index.js",
11
- "types": "./dist/types/index.d.ts",
6
+ "module": "./esm/index.js",
7
+ "main": "./cjs/index.js",
8
+ "types": "./types/index.d.ts",
12
9
  "exports": {
13
10
  ".": {
14
- "import": "./dist/esm/index.js",
15
- "require": "./dist/cjs/index.js"
11
+ "import": "./esm/index.js",
12
+ "require": "./cjs/index.js"
16
13
  },
17
14
  "./styled": {
18
- "import": "./dist/esm/styled.js",
19
- "require": "./dist/cjs/styled.js"
15
+ "import": "./esm/styled.js",
16
+ "require": "./cjs/styled.js"
20
17
  },
21
18
  "./props": {
22
- "import": "./dist/esm/props.js",
23
- "require": "./dist/cjs/props.js"
19
+ "import": "./esm/props.js",
20
+ "require": "./cjs/props.js"
24
21
  },
25
22
  "./parts/PerPageSelector": {
26
- "import": "./dist/esm/parts/PerPageSelector.js",
27
- "require": "./dist/cjs/parts/PerPageSelector.js"
23
+ "import": "./esm/parts/PerPageSelector.js",
24
+ "require": "./cjs/parts/PerPageSelector.js"
28
25
  },
29
26
  "./parts/Paginator": {
30
- "import": "./dist/esm/parts/Paginator.js",
31
- "require": "./dist/cjs/parts/Paginator.js"
27
+ "import": "./esm/parts/Paginator.js",
28
+ "require": "./cjs/parts/Paginator.js"
32
29
  },
33
30
  "./parts/PaginationContent": {
34
- "import": "./dist/esm/parts/PaginationContent.js",
35
- "require": "./dist/cjs/parts/PaginationContent.js"
31
+ "import": "./esm/parts/PaginationContent.js",
32
+ "require": "./cjs/parts/PaginationContent.js"
36
33
  },
37
34
  "./parts/PagePrevButton": {
38
- "import": "./dist/esm/parts/PagePrevButton.js",
39
- "require": "./dist/cjs/parts/PagePrevButton.js"
35
+ "import": "./esm/parts/PagePrevButton.js",
36
+ "require": "./cjs/parts/PagePrevButton.js"
40
37
  },
41
38
  "./parts/PageNextButton": {
42
- "import": "./dist/esm/parts/PageNextButton.js",
43
- "require": "./dist/cjs/parts/PageNextButton.js"
39
+ "import": "./esm/parts/PageNextButton.js",
40
+ "require": "./cjs/parts/PageNextButton.js"
44
41
  },
45
42
  "./PaginationDataTestID": {
46
- "import": "./dist/esm/PaginationDataTestID.js",
47
- "require": "./dist/cjs/PaginationDataTestID.js"
43
+ "import": "./esm/PaginationDataTestID.js",
44
+ "require": "./cjs/PaginationDataTestID.js"
48
45
  },
49
46
  "./Pagination": {
50
- "import": "./dist/esm/Pagination.js",
51
- "require": "./dist/cjs/Pagination.js"
47
+ "import": "./esm/Pagination.js",
48
+ "require": "./cjs/Pagination.js"
52
49
  },
53
50
  "./hooks/usePaginationSearch": {
54
- "import": "./dist/esm/hooks/usePaginationSearch.js",
55
- "require": "./dist/cjs/hooks/usePaginationSearch.js"
51
+ "import": "./esm/hooks/usePaginationSearch.js",
52
+ "require": "./cjs/hooks/usePaginationSearch.js"
56
53
  }
57
54
  },
58
55
  "sideEffects": [
@@ -64,17 +61,25 @@
64
61
  "url": "https://git.elliemae.io/platform-ui/dimsum.git"
65
62
  },
66
63
  "engines": {
67
- "pnpm": ">=6",
68
- "node": ">=16"
64
+ "npm": ">=7",
65
+ "node": ">=14"
69
66
  },
70
67
  "author": "ICE MT",
68
+ "scripts": {
69
+ "dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
70
+ "prebuild": "exit 0",
71
+ "predev": "exit 0",
72
+ "build": "node ../../scripts/build/build.js"
73
+ },
71
74
  "dependencies": {
72
- "@elliemae/ds-button": "2.3.0-alpha.8",
73
- "@elliemae/ds-dropdownmenu": "2.3.0-alpha.8",
74
- "@elliemae/ds-grid": "2.3.0-alpha.8",
75
- "@elliemae/ds-icons": "2.3.0-alpha.8",
76
- "@elliemae/ds-props-helpers": "2.3.0-alpha.8",
77
- "@elliemae/ds-utilities": "2.3.0-alpha.8",
75
+ "@elliemae/ds-button": "2.3.0-next.2",
76
+ "@elliemae/ds-dropdownmenu": "2.3.0-next.2",
77
+ "@elliemae/ds-grid": "2.3.0-next.2",
78
+ "@elliemae/ds-icons": "2.3.0-next.2",
79
+ "@elliemae/ds-props-helpers": "2.3.0-next.2",
80
+ "@elliemae/ds-system": "2.3.0-next.1",
81
+ "@elliemae/ds-truncated-tooltip-text": "2.3.0-next.2",
82
+ "@elliemae/ds-utilities": "2.3.0-next.2",
78
83
  "memoize-one": "~5.1.1",
79
84
  "react-desc": "~4.1.3"
80
85
  },
@@ -91,12 +96,7 @@
91
96
  },
92
97
  "publishConfig": {
93
98
  "access": "public",
94
- "typeSafety": false
95
- },
96
- "scripts": {
97
- "dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
98
- "prebuild": "exit 0",
99
- "predev": "exit 0",
100
- "build": "node ../../scripts/build/build.js"
99
+ "directory": "dist",
100
+ "generateSubmodules": true
101
101
  }
102
102
  }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { DSPaginationProps } from './index.d';
3
+ declare const DSPagination: React.ComponentType<DSPaginationProps>;
4
+ declare const DSPaginationWithSchema: import("@elliemae/ds-props-helpers/types/propTypes/types").DocumentedReactComponent<DSPaginationProps>;
5
+ export { DSPagination, DSPaginationWithSchema };