@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.
Files changed (49) hide show
  1. package/cjs/Pagination.js +35 -49
  2. package/cjs/PaginationDataTestID.js +9 -37
  3. package/cjs/hooks/usePaginationSearch.js +20 -48
  4. package/cjs/index.d.js +2 -27
  5. package/cjs/index.js +10 -28
  6. package/cjs/parts/PageNextButton.js +32 -52
  7. package/cjs/parts/PagePrevButton.js +31 -51
  8. package/cjs/parts/PaginationContent.js +77 -91
  9. package/cjs/parts/Paginator.js +124 -112
  10. package/cjs/parts/PerPageSelector.js +63 -68
  11. package/cjs/props.js +34 -63
  12. package/cjs/styled.js +47 -112
  13. package/esm/Pagination.js +23 -17
  14. package/esm/PaginationDataTestID.js +5 -8
  15. package/esm/hooks/usePaginationSearch.js +13 -16
  16. package/esm/index.d.js +1 -2
  17. package/esm/index.js +1 -3
  18. package/esm/parts/PageNextButton.js +24 -23
  19. package/esm/parts/PagePrevButton.js +23 -22
  20. package/esm/parts/PaginationContent.js +68 -62
  21. package/esm/parts/Paginator.js +110 -76
  22. package/esm/parts/PerPageSelector.js +49 -32
  23. package/esm/props.js +29 -34
  24. package/esm/styled.js +33 -83
  25. package/package.json +7 -7
  26. package/cjs/Pagination.js.map +0 -7
  27. package/cjs/PaginationDataTestID.js.map +0 -7
  28. package/cjs/hooks/usePaginationSearch.js.map +0 -7
  29. package/cjs/index.d.js.map +0 -7
  30. package/cjs/index.js.map +0 -7
  31. package/cjs/parts/PageNextButton.js.map +0 -7
  32. package/cjs/parts/PagePrevButton.js.map +0 -7
  33. package/cjs/parts/PaginationContent.js.map +0 -7
  34. package/cjs/parts/Paginator.js.map +0 -7
  35. package/cjs/parts/PerPageSelector.js.map +0 -7
  36. package/cjs/props.js.map +0 -7
  37. package/cjs/styled.js.map +0 -7
  38. package/esm/Pagination.js.map +0 -7
  39. package/esm/PaginationDataTestID.js.map +0 -7
  40. package/esm/hooks/usePaginationSearch.js.map +0 -7
  41. package/esm/index.d.js.map +0 -7
  42. package/esm/index.js.map +0 -7
  43. package/esm/parts/PageNextButton.js.map +0 -7
  44. package/esm/parts/PagePrevButton.js.map +0 -7
  45. package/esm/parts/PaginationContent.js.map +0 -7
  46. package/esm/parts/Paginator.js.map +0 -7
  47. package/esm/parts/PerPageSelector.js.map +0 -7
  48. package/esm/props.js.map +0 -7
  49. package/esm/styled.js.map +0 -7
@@ -1,41 +1,64 @@
1
- import * as React from "react";
2
- import React2, { useEffect, useMemo, useRef, useState } from "react";
3
- import { Checkmark, ChevronDown } from "@elliemae/ds-icons";
4
- import { useOnElementResize } from "@elliemae/ds-utilities";
5
- import Grid from "@elliemae/ds-grid";
6
- import { DSDropdownMenuV2 } from "@elliemae/ds-dropdownmenu";
7
- import { PaginationBoldText, PaginationDropdownButton, PaginationSeparator } from "../styled";
8
- import { usePaginationSearch } from "../hooks/usePaginationSearch";
9
- const Paginator = (props) => {
10
- const { pageIndex, pageCount, onPageChange, pageDetails, pageDetailsTitle } = props;
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 { width: btnWidth } = useOnElementResize(btnRef);
15
- const { width: txtWidth } = useOnElementResize(pageInfoRef);
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: "single"
42
+ type: 'single'
22
43
  };
44
+
23
45
  if (pageDetails.length) {
24
- option.render = () => /* @__PURE__ */ React2.createElement(Grid, {
25
- cols: ["16px", `${txtWidth + 16}px`, "auto"],
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 ? /* @__PURE__ */ React2.createElement(Checkmark, {
50
+ }, void 0, pageIndex === index ? /*#__PURE__*/_jsx(Checkmark, {
29
51
  size: "s",
30
- color: ["brand-primary", "600"]
31
- }) : /* @__PURE__ */ React2.createElement("div", null), /* @__PURE__ */ React2.createElement("span", null, index + 1), /* @__PURE__ */ React2.createElement("span", {
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: "nowrap",
34
- textOverflow: "ellipsis",
35
- overflow: "hidden"
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 /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(PaginationSeparator, null), /* @__PURE__ */ React2.createElement(DSDropdownMenuV2, {
50
- isOpened,
51
- options,
52
- selectedOptions: { [(pageIndex + 1).toString()]: true },
53
- onOptionClick: (_, clickedOption) => {
54
- onPageChange(clickedOption.value);
55
- setIsOpened(false);
56
- btnRef.current.focus();
57
- },
58
- onClickOutside: () => {
59
- setIsOpened(false);
60
- btnRef.current.focus();
61
- },
62
- customOffset: [0, 2],
63
- startPlacementPreference: "top-end",
64
- actionRef,
65
- onKeyDown,
66
- minWidth: btnWidth + 23,
67
- maxHeight: 300,
68
- HeaderComp: () => pageDetailsTitle !== "" ? /* @__PURE__ */ React2.createElement(Grid, {
69
- cols: [`${txtWidth + 50}px`, "8px", "auto"]
70
- }, /* @__PURE__ */ React2.createElement("span", {
71
- style: { marginLeft: "8px" }
72
- }, "Page"), /* @__PURE__ */ React2.createElement(PaginationSeparator, {
73
- height: "100%"
74
- }), /* @__PURE__ */ React2.createElement("span", null, pageDetailsTitle)) : "Page"
75
- }, /* @__PURE__ */ React2.createElement(PaginationDropdownButton, {
76
- buttonType: "raw",
77
- onClick: () => setIsOpened(true),
78
- innerRef: btnRef
79
- }, /* @__PURE__ */ React2.createElement("div", {
80
- style: { display: "flex", gridGap: "8px", alignItems: "center" }
81
- }, /* @__PURE__ */ React2.createElement(Grid, {
82
- cols: ["auto", "auto", "auto"],
83
- alignItems: "center",
84
- gutter: "xxxs",
85
- ref: pageInfoRef
86
- }, /* @__PURE__ */ React2.createElement(PaginationBoldText, {
87
- fontSize: "18px"
88
- }, pageIndex + 1), " / ", pageCount), pageDetails.length !== 0 && /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(PaginationSeparator, {
89
- height: "12px",
90
- ml: "8px"
91
- }), /* @__PURE__ */ React2.createElement(PaginationBoldText, {
92
- fontSize: "13px",
93
- mr: "8px"
94
- }, pageDetails[pageIndex])), /* @__PURE__ */ React2.createElement(ChevronDown, {
95
- color: ["brand-primary", "700"]
96
- })))), /* @__PURE__ */ React2.createElement(PaginationSeparator, null));
97
- };
98
- var Paginator_default = Paginator;
99
- export {
100
- Paginator_default as default
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
- //# sourceMappingURL=Paginator.js.map
135
+
136
+ export { Paginator as default };
@@ -1,31 +1,44 @@
1
- import * as React from "react";
2
- import React2, { useEffect, useMemo, useRef, useState } from "react";
3
- import memoize from "memoize-one";
4
- import { range, useOnElementResize } from "@elliemae/ds-utilities";
5
- import { DSDropdownMenuV2 } from "@elliemae/ds-dropdownmenu";
6
- import { ChevronDown } from "@elliemae/ds-icons";
7
- import { PaginationDropdownButton } from "../styled";
8
- const generateOption = (value) => {
9
- if (typeof value === "object") {
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: "single"
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
- const PerPageSelector = (props) => {
29
+
30
+ const PerPageSelector = props => {
24
31
  const [isOpened, setIsOpened] = useState(false);
25
- const { pageSize, onPageSizeChange, perPageOptions, maxPerPage, perPageStep, minPerPage } = props;
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 { width } = useOnElementResize(btnRef);
40
- return /* @__PURE__ */ React2.createElement(DSDropdownMenuV2, {
41
- isOpened,
42
- options,
43
- selectedOptions: { [pageSize.toString()]: true },
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: () => "Per Page"
59
- }, /* @__PURE__ */ React2.createElement("div", {
60
- style: { marginLeft: "32px" }
61
- }, /* @__PURE__ */ React2.createElement(PaginationDropdownButton, {
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", /* @__PURE__ */ React2.createElement(ChevronDown, {
67
- color: ["brand-primary", "700"]
86
+ }, void 0, pageSize, " / page", /*#__PURE__*/_jsx(ChevronDown, {
87
+ color: ['brand-primary', '700']
68
88
  }))));
69
89
  };
70
- var PerPageSelector_default = PerPageSelector;
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 * as React from "react";
2
- import { PropTypes } from "react-desc";
1
+ import { PropTypes } from 'react-desc';
2
+
3
3
  const emptyFunc = () => null;
4
+
4
5
  const propTypes = {
5
- pageCount: PropTypes.number.description("How many pages are there"),
6
- pageIndex: PropTypes.number.description("Index of the current page, starting from 1").defaultValue(1),
7
- canPreviousPage: PropTypes.bool.description("Whether the previous button is disabled or not").defaultValue(true),
8
- canNextPage: PropTypes.bool.description("Whether the next button is disabled or not").defaultValue(true),
9
- pageSize: PropTypes.number.description("The current page size").defaultValue(10),
10
- showPerPageSelector: PropTypes.bool.description("Whether to show the page selector").defaultValue(true),
11
- perPageOptions: PropTypes.arrayOf(PropTypes.oneOfType([
12
- PropTypes.number,
13
- PropTypes.shape({
14
- dsId: PropTypes.string,
15
- value: PropTypes.number,
16
- label: PropTypes.string,
17
- type: PropTypes.oneOf(["single"])
18
- })
19
- ])).description("The available options for page size").defaultValue([10]),
20
- perPageStep: PropTypes.number.description("Step for the per page options").defaultValue(5),
21
- minPerPage: PropTypes.number.description("Step for the per page options").defaultValue(0),
22
- maxPerPage: PropTypes.number.description("Step for the per page options").defaultValue(100),
23
- onPageSizeChange: PropTypes.func.description("Function invoked when the page size changes").defaultValue(() => null),
24
- onPreviousPage: PropTypes.func.description("Function invoked when the previous button is pressed").defaultValue(() => null),
25
- onPageChange: PropTypes.func.description("Function invoked when the page changes").defaultValue(() => null),
26
- onNextPage: PropTypes.func.description("Function invoked when next button is pressed").defaultValue(() => null),
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: "100%"
44
+ pageDetailsTitle: '',
45
+ width: '100%'
48
46
  };
49
- export {
50
- defaultProps,
51
- propTypes
52
- };
53
- //# sourceMappingURL=props.js.map
47
+
48
+ export { defaultProps, propTypes };
package/esm/styled.js CHANGED
@@ -1,84 +1,34 @@
1
- import * as React from "react";
2
- import Grid from "@elliemae/ds-grid";
3
- import { DSButtonV2 } from "@elliemae/ds-button";
4
- import styled from "styled-components";
5
- import { space, typography } from "@xstyled/styled-components";
6
- const sizeToCss = (size) => typeof size === "number" && !Number.isNaN(size) ? `${size}px` : size;
7
- const styledFocusCss = ({ theme }) => `
8
- &:after {
9
- display: block;
10
- content: ' ';
11
- position: absolute;
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
- //# sourceMappingURL=styled.js.map
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-alpha.2",
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-alpha.2",
76
- "@elliemae/ds-dropdownmenu": "2.2.0-alpha.2",
77
- "@elliemae/ds-grid": "2.2.0-alpha.2",
78
- "@elliemae/ds-icons": "2.2.0-alpha.2",
79
- "@elliemae/ds-props-helpers": "2.2.0-alpha.2",
80
- "@elliemae/ds-utilities": "2.2.0-alpha.2",
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
  },
@@ -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
- }
@@ -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
- }