@elliemae/ds-pagination 2.3.0 → 2.3.1

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.
@@ -107,11 +107,11 @@ const Paginator = props => {
107
107
  setIsOpened(false);
108
108
  (_btnRef$current2 = btnRef.current) === null || _btnRef$current2 === void 0 ? void 0 : _btnRef$current2.focus();
109
109
  },
110
- customOffset: [0, 2],
111
- startPlacementPreference: "top-end",
110
+ customOffset: [-23, 2],
111
+ startPlacementPreference: "top-start",
112
112
  actionRef: actionRef,
113
113
  onKeyDown: onKeyDown,
114
- minWidth: btnWidth + 23,
114
+ minWidth: pageDetails.length !== 0 ? btnWidth + 23 : pageCount.toString().length * 6 + 90,
115
115
  maxHeight: 300,
116
116
  HeaderComp: () => pageDetailsTitle !== '' ? /*#__PURE__*/_jsx__default["default"](Grid__default["default"], {
117
117
  cols: ["".concat(txtWidth + 50, "px"), '8px', 'auto']
@@ -151,12 +151,12 @@ const Paginator = props => {
151
151
  display: "grid"
152
152
  }, void 0, /*#__PURE__*/_jsx__default["default"](dsTruncatedTooltipText.SimpleTruncatedTooltipText, {
153
153
  value: pageDetails[pageIndex]
154
- }, void 0, pageDetails[pageIndex]))]
154
+ }, void 0, pageDetails[pageIndex]), pageDetails.map(pageDetail => /*#__PURE__*/_jsx__default["default"](styled.InvisibleDetail, {
155
+ "data-testid": "ds-pagination-invisible-detail-for-width-calc"
156
+ }, void 0, pageDetail)))]
155
157
  }), /*#__PURE__*/_jsx__default["default"](dsIcons.ChevronDown, {
156
158
  color: ['brand-primary', '700']
157
- }), pageDetails.map(pageDetail => /*#__PURE__*/_jsx__default["default"](styled.InvisibleDetail, {
158
- "data-testid": "ds-pagination-invisible-detail-for-width-calc"
159
- }, void 0, pageDetail))))), _PaginationSeparator4 || (_PaginationSeparator4 = /*#__PURE__*/_jsx__default["default"](styled.PaginationSeparator, {}))]
159
+ })))), _PaginationSeparator4 || (_PaginationSeparator4 = /*#__PURE__*/_jsx__default["default"](styled.PaginationSeparator, {}))]
160
160
  });
161
161
  };
162
162
 
@@ -4,6 +4,9 @@ var _jsx = require('@babel/runtime/helpers/jsx');
4
4
  require('core-js/modules/esnext.async-iterator.map.js');
5
5
  require('core-js/modules/esnext.iterator.map.js');
6
6
  require('core-js/modules/web.dom-collections.iterator.js');
7
+ require('core-js/modules/esnext.async-iterator.reduce.js');
8
+ require('core-js/modules/esnext.iterator.constructor.js');
9
+ require('core-js/modules/esnext.iterator.reduce.js');
7
10
  var react = require('react');
8
11
  var memoize = require('memoize-one');
9
12
  var dsUtilities = require('@elliemae/ds-utilities');
@@ -57,9 +60,14 @@ const PerPageSelector = props => {
57
60
  } // eslint-disable-next-line react-hooks/exhaustive-deps
58
61
 
59
62
  }, [isOpened]);
60
- const {
61
- width
62
- } = dsUtilities.useOnElementResize(btnRef);
63
+ const width = react.useMemo(() => {
64
+ const maxLength = options.reduce((acc, cur) => {
65
+ var _length, _cur$label;
66
+
67
+ return Math.max(acc, (_length = cur === null || cur === void 0 ? void 0 : (_cur$label = cur.label) === null || _cur$label === void 0 ? void 0 : _cur$label.length) !== null && _length !== void 0 ? _length : 0);
68
+ }, 0);
69
+ return maxLength * 6 + 90;
70
+ }, [options]);
63
71
  return /*#__PURE__*/_jsx__default["default"](dsDropdownmenu.DSDropdownMenuV2, {
64
72
  isOpened: isOpened,
65
73
  options: options,
@@ -79,10 +87,10 @@ const PerPageSelector = props => {
79
87
  setIsOpened(false);
80
88
  (_btnRef$current2 = btnRef.current) === null || _btnRef$current2 === void 0 ? void 0 : _btnRef$current2.focus();
81
89
  },
82
- customOffset: [0, 2],
83
- startPlacementPreference: "top-end",
90
+ customOffset: [10, 2],
91
+ startPlacementPreference: "top-start",
84
92
  actionRef: actionRef,
85
- minWidth: width + 25,
93
+ minWidth: width,
86
94
  maxHeight: 300,
87
95
  HeaderComp: () => 'Per Page'
88
96
  }, void 0, /*#__PURE__*/_jsx__default["default"]("div", {
@@ -100,11 +100,11 @@ const Paginator = props => {
100
100
  setIsOpened(false);
101
101
  (_btnRef$current2 = btnRef.current) === null || _btnRef$current2 === void 0 ? void 0 : _btnRef$current2.focus();
102
102
  },
103
- customOffset: [0, 2],
104
- startPlacementPreference: "top-end",
103
+ customOffset: [-23, 2],
104
+ startPlacementPreference: "top-start",
105
105
  actionRef: actionRef,
106
106
  onKeyDown: onKeyDown,
107
- minWidth: btnWidth + 23,
107
+ minWidth: pageDetails.length !== 0 ? btnWidth + 23 : pageCount.toString().length * 6 + 90,
108
108
  maxHeight: 300,
109
109
  HeaderComp: () => pageDetailsTitle !== '' ? /*#__PURE__*/_jsx(Grid, {
110
110
  cols: ["".concat(txtWidth + 50, "px"), '8px', 'auto']
@@ -144,12 +144,12 @@ const Paginator = props => {
144
144
  display: "grid"
145
145
  }, void 0, /*#__PURE__*/_jsx(SimpleTruncatedTooltipText, {
146
146
  value: pageDetails[pageIndex]
147
- }, void 0, pageDetails[pageIndex]))]
147
+ }, void 0, pageDetails[pageIndex]), pageDetails.map(pageDetail => /*#__PURE__*/_jsx(InvisibleDetail, {
148
+ "data-testid": "ds-pagination-invisible-detail-for-width-calc"
149
+ }, void 0, pageDetail)))]
148
150
  }), /*#__PURE__*/_jsx(ChevronDown, {
149
151
  color: ['brand-primary', '700']
150
- }), pageDetails.map(pageDetail => /*#__PURE__*/_jsx(InvisibleDetail, {
151
- "data-testid": "ds-pagination-invisible-detail-for-width-calc"
152
- }, void 0, pageDetail))))), _PaginationSeparator4 || (_PaginationSeparator4 = /*#__PURE__*/_jsx(PaginationSeparator, {}))]
152
+ })))), _PaginationSeparator4 || (_PaginationSeparator4 = /*#__PURE__*/_jsx(PaginationSeparator, {}))]
153
153
  });
154
154
  };
155
155
 
@@ -2,9 +2,12 @@ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
2
  import 'core-js/modules/esnext.async-iterator.map.js';
3
3
  import 'core-js/modules/esnext.iterator.map.js';
4
4
  import 'core-js/modules/web.dom-collections.iterator.js';
5
+ import 'core-js/modules/esnext.async-iterator.reduce.js';
6
+ import 'core-js/modules/esnext.iterator.constructor.js';
7
+ import 'core-js/modules/esnext.iterator.reduce.js';
5
8
  import { useState, useMemo, useRef, useEffect } from 'react';
6
9
  import memoize from 'memoize-one';
7
- import { range, useOnElementResize } from '@elliemae/ds-utilities';
10
+ import { range } from '@elliemae/ds-utilities';
8
11
  import { DSDropdownMenuV2 } from '@elliemae/ds-dropdownmenu';
9
12
  import { ChevronDown } from '@elliemae/ds-icons';
10
13
  import { PaginationDropdownButton } from '../styled.js';
@@ -50,9 +53,14 @@ const PerPageSelector = props => {
50
53
  } // eslint-disable-next-line react-hooks/exhaustive-deps
51
54
 
52
55
  }, [isOpened]);
53
- const {
54
- width
55
- } = useOnElementResize(btnRef);
56
+ const width = useMemo(() => {
57
+ const maxLength = options.reduce((acc, cur) => {
58
+ var _length, _cur$label;
59
+
60
+ return Math.max(acc, (_length = cur === null || cur === void 0 ? void 0 : (_cur$label = cur.label) === null || _cur$label === void 0 ? void 0 : _cur$label.length) !== null && _length !== void 0 ? _length : 0);
61
+ }, 0);
62
+ return maxLength * 6 + 90;
63
+ }, [options]);
56
64
  return /*#__PURE__*/_jsx(DSDropdownMenuV2, {
57
65
  isOpened: isOpened,
58
66
  options: options,
@@ -72,10 +80,10 @@ const PerPageSelector = props => {
72
80
  setIsOpened(false);
73
81
  (_btnRef$current2 = btnRef.current) === null || _btnRef$current2 === void 0 ? void 0 : _btnRef$current2.focus();
74
82
  },
75
- customOffset: [0, 2],
76
- startPlacementPreference: "top-end",
83
+ customOffset: [10, 2],
84
+ startPlacementPreference: "top-start",
77
85
  actionRef: actionRef,
78
- minWidth: width + 25,
86
+ minWidth: width,
79
87
  maxHeight: 300,
80
88
  HeaderComp: () => 'Per Page'
81
89
  }, void 0, /*#__PURE__*/_jsx("div", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-pagination",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Pagination",
6
6
  "module": "./esm/index.js",
@@ -72,14 +72,16 @@
72
72
  "build": "node ../../scripts/build/build.js"
73
73
  },
74
74
  "dependencies": {
75
- "@elliemae/ds-button": "2.3.0",
76
- "@elliemae/ds-dropdownmenu": "2.3.0",
77
- "@elliemae/ds-grid": "2.3.0",
78
- "@elliemae/ds-icons": "2.3.0",
79
- "@elliemae/ds-props-helpers": "2.3.0",
80
- "@elliemae/ds-utilities": "2.3.0",
81
- "memoize-one": "~5.1.1",
82
- "react-desc": "~4.1.3"
75
+ "@elliemae/ds-button": "2.3.1",
76
+ "@elliemae/ds-dropdownmenu": "2.3.1",
77
+ "@elliemae/ds-grid": "2.3.1",
78
+ "@elliemae/ds-icons": "2.3.1",
79
+ "@elliemae/ds-props-helpers": "2.3.1",
80
+ "@elliemae/ds-system": "2.3.1",
81
+ "@elliemae/ds-truncated-tooltip-text": "2.3.1",
82
+ "@elliemae/ds-utilities": "2.3.1",
83
+ "@xstyled/styled-components": "~3.1.1",
84
+ "memoize-one": "~5.1.1"
83
85
  },
84
86
  "devDependencies": {
85
87
  "styled-components": "~5.3.3",