@elliemae/ds-read-more 1.57.1-rc.0 → 2.0.0-alpha.11

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/DSReadMore.js CHANGED
@@ -2,80 +2,57 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
6
- var React = require('react');
5
+ var _jsx2 = require('@babel/runtime/helpers/jsx');
6
+ require('core-js/modules/web.dom-collections.iterator.js');
7
+ var react = require('react');
7
8
  var reactDesc = require('react-desc');
8
9
  var styled = require('styled-components');
9
10
  var DSButton = require('@elliemae/ds-button');
11
+ var propTypes = require('@elliemae/ds-shared/prop-types');
10
12
  var MoreLessButton = require('./MoreLessButton.js');
13
+ var jsxRuntime = require('react/jsx-runtime');
11
14
 
12
15
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
16
 
14
- var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
15
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
17
+ var _jsx2__default = /*#__PURE__*/_interopDefaultLegacy(_jsx2);
16
18
  var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
17
19
 
18
- /* eslint-disable max-lines */
19
- const dsBasicSizes = ['s', 'm', 'l'];
20
-
21
- var Text = /*#__PURE__*/styled__default['default'].span.withConfig({
20
+ const Text = /*#__PURE__*/styled__default["default"].span.withConfig({
22
21
  componentId: "sc-1c4w5m6-0"
23
- })(["display:-webkit-box;-webkit-line-clamp:", ";-webkit-box-orient:vertical;-webkit-hyphens:auto;-moz-hyphens:auto;-ms-hyphens:auto;hyphens:auto;word-break:break-all;"], function (_ref) {
24
- var lines = _ref.lines,
25
- expanded = _ref.expanded;
26
- return expanded ? 'unset' : lines;
27
- });
28
-
29
- var DSReadMore = function DSReadMore(_ref2) {
30
- var _ref2$lines = _ref2.lines,
31
- lines = _ref2$lines === void 0 ? 2 : _ref2$lines,
32
- _ref2$more = _ref2.more,
33
- more = _ref2$more === void 0 ? 'more' : _ref2$more,
34
- _ref2$less = _ref2.less,
35
- less = _ref2$less === void 0 ? 'less' : _ref2$less,
36
- _ref2$onMore = _ref2.onMore,
37
- onMore = _ref2$onMore === void 0 ? function () {
38
- return null;
39
- } : _ref2$onMore,
40
- _ref2$onLess = _ref2.onLess,
41
- onLess = _ref2$onLess === void 0 ? function () {
42
- return null;
43
- } : _ref2$onLess,
44
- content = _ref2.content,
45
- _ref2$buttonType = _ref2.buttonType,
46
- buttonType = _ref2$buttonType === void 0 ? 'link' : _ref2$buttonType,
47
- _ref2$size = _ref2.size,
48
- size = _ref2$size === void 0 ? 's' : _ref2$size,
49
- _ref2$ellipsis = _ref2.ellipsis,
50
- ellipsis = _ref2$ellipsis === void 0 ? '...' : _ref2$ellipsis;
51
- var ref = React.useRef();
52
-
53
- var _useState = React.useState(false),
54
- _useState2 = _slicedToArray__default['default'](_useState, 2),
55
- showButton = _useState2[0],
56
- setShowButton = _useState2[1];
57
-
58
- var _useState3 = React.useState(false),
59
- _useState4 = _slicedToArray__default['default'](_useState3, 2),
60
- expanded = _useState4[0],
61
- setExpanded = _useState4[1]; // offsetHeight + 2 takes into consideration any size of the button
62
-
63
-
64
- var overflows = function overflows(_ref3) {
65
- var offsetHeight = _ref3.offsetHeight,
66
- scrollHeight = _ref3.scrollHeight;
67
- return offsetHeight + 2 < scrollHeight;
68
- }; // Searchs the optimum cut on the text to have the button in the same line
69
-
70
-
71
- var binSearchTextOverflow = function binSearchTextOverflow(element, parent) {
72
- var text = element.innerText;
73
- var left = 1;
74
- var right = text.length;
75
- var textEnd = 0;
22
+ })(["display:-webkit-box;-webkit-line-clamp:", ";-webkit-box-orient:vertical;-webkit-hyphens:auto;-moz-hyphens:auto;-ms-hyphens:auto;hyphens:auto;word-break:break-all;"], ({
23
+ lines,
24
+ expanded
25
+ }) => expanded ? 'unset' : lines);
26
+
27
+ const DSReadMore = ({
28
+ lines = 2,
29
+ more = 'more',
30
+ less = 'less',
31
+ onMore = () => null,
32
+ onLess = () => null,
33
+ content,
34
+ buttonType = 'link',
35
+ size = 's',
36
+ ellipsis = '...'
37
+ }) => {
38
+ const ref = react.useRef();
39
+ const [showButton, setShowButton] = react.useState(false);
40
+ const [expanded, setExpanded] = react.useState(false); // offsetHeight + 2 takes into consideration any size of the button
41
+
42
+ const overflows = ({
43
+ offsetHeight,
44
+ scrollHeight
45
+ }) => offsetHeight + 2 < scrollHeight; // Searchs the optimum cut on the text to have the button in the same line
46
+
47
+
48
+ const binSearchTextOverflow = (element, parent) => {
49
+ const text = element.innerText;
50
+ let left = 1;
51
+ let right = text.length;
52
+ let textEnd = 0;
76
53
 
77
54
  while (left <= right) {
78
- var middle = (left + right) / 2;
55
+ const middle = (left + right) / 2;
79
56
  element.innerText = content.slice(0, middle);
80
57
  if (overflows(parent)) right = middle - 1;else {
81
58
  left = middle + 1;
@@ -86,11 +63,11 @@ var DSReadMore = function DSReadMore(_ref2) {
86
63
  element.innerText = content.slice(0, textEnd);
87
64
  };
88
65
 
89
- React.useLayoutEffect(function () {
66
+ react.useLayoutEffect(() => {
90
67
  var _ref$current;
91
68
 
92
- var textElement = ref.current;
93
- var parentElement = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.parentElement;
69
+ const textElement = ref.current;
70
+ const parentElement = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.parentElement;
94
71
 
95
72
  if (parentElement) {
96
73
  textElement.innerText = content;
@@ -102,30 +79,29 @@ var DSReadMore = function DSReadMore(_ref2) {
102
79
  }
103
80
  }, [lines, content, expanded, showButton, more, less]);
104
81
 
105
- var toggleExpanded = function toggleExpanded(newExpanded) {
82
+ const toggleExpanded = newExpanded => {
106
83
  setExpanded(newExpanded);
107
84
  if (newExpanded) onMore();else onLess();
108
85
  };
109
86
 
110
- return /*#__PURE__*/React__default['default'].createElement(Text, {
87
+ return /*#__PURE__*/_jsx2__default["default"](Text, {
111
88
  lines: lines,
112
89
  expanded: expanded
113
- }, /*#__PURE__*/React__default['default'].createElement("span", {
90
+ }, void 0, /*#__PURE__*/jsxRuntime.jsx("span", {
114
91
  ref: ref,
115
- "data-testid": "ds-read_more-text"
116
- }, content), showButton && /*#__PURE__*/React__default['default'].createElement("span", null, /*#__PURE__*/React__default['default'].createElement(MoreLessButton.MoreLessButton, {
92
+ "data-testid": "ds-read_more-text",
93
+ children: content
94
+ }), showButton && /*#__PURE__*/_jsx2__default["default"]("span", {}, void 0, /*#__PURE__*/_jsx2__default["default"](MoreLessButton.MoreLessButton, {
117
95
  expanded: expanded,
118
96
  label: expanded ? less : more,
119
- onClick: function onClick() {
120
- return toggleExpanded(!expanded);
121
- },
97
+ onClick: () => toggleExpanded(!expanded),
122
98
  buttonType: buttonType,
123
99
  size: size,
124
100
  ellipsis: ellipsis
125
101
  })));
126
102
  };
127
103
 
128
- var DSReadMoreProps = {
104
+ const DSReadMoreProps = {
129
105
  /** Ammount of lines after you want to display an ellipsis + more/less button */
130
106
  lines: reactDesc.PropTypes.number.description('Ammount of lines after you want to display an ellipsis + more/less button').defaultValue(2),
131
107
 
@@ -150,16 +126,14 @@ var DSReadMoreProps = {
150
126
  /**
151
127
  * ['s', 'm', 'l']
152
128
  */
153
- size: reactDesc.PropTypes.oneOf(dsBasicSizes).description('Size of the button').defaultValue('s'),
129
+ size: reactDesc.PropTypes.oneOf(propTypes.dsBasicSizes).description('Size of the button').defaultValue('s'),
154
130
 
155
131
  /** The text you want to appear when truncating */
156
132
  ellipsis: reactDesc.PropTypes.string.description('The text you want to appear when truncating').defaultValue('...')
157
133
  };
158
- DSReadMore.propTypes = DSReadMoreProps;
159
- var DSReadMoreWithSchema = reactDesc.describe(DSReadMore).description('ReadMore component');
134
+ const DSReadMoreWithSchema = reactDesc.describe(DSReadMore).description('ReadMore component');
160
135
  DSReadMoreWithSchema.propTypes = DSReadMoreProps;
161
136
 
162
137
  exports.DSReadMore = DSReadMore;
163
138
  exports.DSReadMoreWithSchema = DSReadMoreWithSchema;
164
- exports['default'] = DSReadMore;
165
- //# sourceMappingURL=DSReadMore.js.map
139
+ exports["default"] = DSReadMore;
@@ -2,40 +2,28 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var React = require('react');
6
- var reactDesc = require('react-desc');
5
+ var _jsx2 = require('@babel/runtime/helpers/jsx');
6
+ require('react');
7
7
  var DSButton = require('@elliemae/ds-button');
8
8
 
9
9
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
10
 
11
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
11
+ var _jsx2__default = /*#__PURE__*/_interopDefaultLegacy(_jsx2);
12
12
  var DSButton__default = /*#__PURE__*/_interopDefaultLegacy(DSButton);
13
13
 
14
- var MoreLessButton = function MoreLessButton(_ref) {
15
- var expanded = _ref.expanded,
16
- label = _ref.label,
17
- onClick = _ref.onClick,
18
- buttonType = _ref.buttonType,
19
- size = _ref.size,
20
- ellipsis = _ref.ellipsis;
21
- return /*#__PURE__*/React__default['default'].createElement("span", null, expanded ? ' ' : ellipsis, /*#__PURE__*/React__default['default'].createElement(DSButton__default['default'], {
22
- buttonType: buttonType,
23
- labelText: label,
24
- onClick: onClick,
25
- size: size,
26
- "data-testid": "ds-read_more-button"
27
- }));
28
- };
29
-
30
- var MoreLessButtonProps = {
31
- expanded: reactDesc.PropTypes.boolean,
32
- label: reactDesc.PropTypes.string,
33
- onClick: reactDesc.PropTypes.func,
34
- buttonType: reactDesc.PropTypes.string,
35
- size: reactDesc.PropTypes.string,
36
- ellipsis: reactDesc.PropTypes.string
37
- };
38
- MoreLessButton.propTypes = MoreLessButtonProps;
14
+ const MoreLessButton = ({
15
+ expanded,
16
+ label,
17
+ onClick,
18
+ buttonType,
19
+ size,
20
+ ellipsis
21
+ }) => /*#__PURE__*/_jsx2__default["default"]("span", {}, void 0, expanded ? ' ' : ellipsis, /*#__PURE__*/_jsx2__default["default"](DSButton__default["default"], {
22
+ buttonType: buttonType,
23
+ labelText: label,
24
+ onClick: onClick,
25
+ size: size,
26
+ "data-testid": "ds-read_more-button"
27
+ }));
39
28
 
40
29
  exports.MoreLessButton = MoreLessButton;
41
- //# sourceMappingURL=MoreLessButton.js.map
package/cjs/index.js CHANGED
@@ -3,16 +3,9 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var DSReadMore = require('./DSReadMore.js');
6
- require('@babel/runtime/helpers/slicedToArray');
7
- require('react');
8
- require('react-desc');
9
- require('styled-components');
10
- require('@elliemae/ds-button');
11
- require('./MoreLessButton.js');
12
6
 
13
7
 
14
8
 
15
9
  exports.DSReadMore = DSReadMore.DSReadMore;
16
10
  exports.DSReadMoreWithSchema = DSReadMore.DSReadMoreWithSchema;
17
- exports.default = DSReadMore.DSReadMore;
18
- //# sourceMappingURL=index.js.map
11
+ exports["default"] = DSReadMore.DSReadMore;
package/esm/DSReadMore.js CHANGED
@@ -1,71 +1,49 @@
1
- import _slicedToArray from '@babel/runtime/helpers/esm/slicedToArray';
2
- import React, { useRef, useState, useLayoutEffect } from 'react';
1
+ import _jsx2 from '@babel/runtime/helpers/esm/jsx';
2
+ import 'core-js/modules/web.dom-collections.iterator.js';
3
+ import { useRef, useState, useLayoutEffect } from 'react';
3
4
  import { PropTypes, describe } from 'react-desc';
4
5
  import styled from 'styled-components';
5
6
  import { buttonTypes } from '@elliemae/ds-button';
7
+ import { dsBasicSizes } from '@elliemae/ds-shared/prop-types';
6
8
  import { MoreLessButton } from './MoreLessButton.js';
9
+ import { jsx } from 'react/jsx-runtime';
7
10
 
8
- /* eslint-disable max-lines */
9
- const dsBasicSizes = ['s', 'm', 'l'];
10
-
11
- var Text = /*#__PURE__*/styled.span.withConfig({
11
+ const Text = /*#__PURE__*/styled.span.withConfig({
12
12
  componentId: "sc-1c4w5m6-0"
13
- })(["display:-webkit-box;-webkit-line-clamp:", ";-webkit-box-orient:vertical;-webkit-hyphens:auto;-moz-hyphens:auto;-ms-hyphens:auto;hyphens:auto;word-break:break-all;"], function (_ref) {
14
- var lines = _ref.lines,
15
- expanded = _ref.expanded;
16
- return expanded ? 'unset' : lines;
17
- });
18
-
19
- var DSReadMore = function DSReadMore(_ref2) {
20
- var _ref2$lines = _ref2.lines,
21
- lines = _ref2$lines === void 0 ? 2 : _ref2$lines,
22
- _ref2$more = _ref2.more,
23
- more = _ref2$more === void 0 ? 'more' : _ref2$more,
24
- _ref2$less = _ref2.less,
25
- less = _ref2$less === void 0 ? 'less' : _ref2$less,
26
- _ref2$onMore = _ref2.onMore,
27
- onMore = _ref2$onMore === void 0 ? function () {
28
- return null;
29
- } : _ref2$onMore,
30
- _ref2$onLess = _ref2.onLess,
31
- onLess = _ref2$onLess === void 0 ? function () {
32
- return null;
33
- } : _ref2$onLess,
34
- content = _ref2.content,
35
- _ref2$buttonType = _ref2.buttonType,
36
- buttonType = _ref2$buttonType === void 0 ? 'link' : _ref2$buttonType,
37
- _ref2$size = _ref2.size,
38
- size = _ref2$size === void 0 ? 's' : _ref2$size,
39
- _ref2$ellipsis = _ref2.ellipsis,
40
- ellipsis = _ref2$ellipsis === void 0 ? '...' : _ref2$ellipsis;
41
- var ref = useRef();
42
-
43
- var _useState = useState(false),
44
- _useState2 = _slicedToArray(_useState, 2),
45
- showButton = _useState2[0],
46
- setShowButton = _useState2[1];
47
-
48
- var _useState3 = useState(false),
49
- _useState4 = _slicedToArray(_useState3, 2),
50
- expanded = _useState4[0],
51
- setExpanded = _useState4[1]; // offsetHeight + 2 takes into consideration any size of the button
52
-
53
-
54
- var overflows = function overflows(_ref3) {
55
- var offsetHeight = _ref3.offsetHeight,
56
- scrollHeight = _ref3.scrollHeight;
57
- return offsetHeight + 2 < scrollHeight;
58
- }; // Searchs the optimum cut on the text to have the button in the same line
59
-
60
-
61
- var binSearchTextOverflow = function binSearchTextOverflow(element, parent) {
62
- var text = element.innerText;
63
- var left = 1;
64
- var right = text.length;
65
- var textEnd = 0;
13
+ })(["display:-webkit-box;-webkit-line-clamp:", ";-webkit-box-orient:vertical;-webkit-hyphens:auto;-moz-hyphens:auto;-ms-hyphens:auto;hyphens:auto;word-break:break-all;"], ({
14
+ lines,
15
+ expanded
16
+ }) => expanded ? 'unset' : lines);
17
+
18
+ const DSReadMore = ({
19
+ lines = 2,
20
+ more = 'more',
21
+ less = 'less',
22
+ onMore = () => null,
23
+ onLess = () => null,
24
+ content,
25
+ buttonType = 'link',
26
+ size = 's',
27
+ ellipsis = '...'
28
+ }) => {
29
+ const ref = useRef();
30
+ const [showButton, setShowButton] = useState(false);
31
+ const [expanded, setExpanded] = useState(false); // offsetHeight + 2 takes into consideration any size of the button
32
+
33
+ const overflows = ({
34
+ offsetHeight,
35
+ scrollHeight
36
+ }) => offsetHeight + 2 < scrollHeight; // Searchs the optimum cut on the text to have the button in the same line
37
+
38
+
39
+ const binSearchTextOverflow = (element, parent) => {
40
+ const text = element.innerText;
41
+ let left = 1;
42
+ let right = text.length;
43
+ let textEnd = 0;
66
44
 
67
45
  while (left <= right) {
68
- var middle = (left + right) / 2;
46
+ const middle = (left + right) / 2;
69
47
  element.innerText = content.slice(0, middle);
70
48
  if (overflows(parent)) right = middle - 1;else {
71
49
  left = middle + 1;
@@ -76,11 +54,11 @@ var DSReadMore = function DSReadMore(_ref2) {
76
54
  element.innerText = content.slice(0, textEnd);
77
55
  };
78
56
 
79
- useLayoutEffect(function () {
57
+ useLayoutEffect(() => {
80
58
  var _ref$current;
81
59
 
82
- var textElement = ref.current;
83
- var parentElement = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.parentElement;
60
+ const textElement = ref.current;
61
+ const parentElement = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.parentElement;
84
62
 
85
63
  if (parentElement) {
86
64
  textElement.innerText = content;
@@ -92,30 +70,29 @@ var DSReadMore = function DSReadMore(_ref2) {
92
70
  }
93
71
  }, [lines, content, expanded, showButton, more, less]);
94
72
 
95
- var toggleExpanded = function toggleExpanded(newExpanded) {
73
+ const toggleExpanded = newExpanded => {
96
74
  setExpanded(newExpanded);
97
75
  if (newExpanded) onMore();else onLess();
98
76
  };
99
77
 
100
- return /*#__PURE__*/React.createElement(Text, {
78
+ return /*#__PURE__*/_jsx2(Text, {
101
79
  lines: lines,
102
80
  expanded: expanded
103
- }, /*#__PURE__*/React.createElement("span", {
81
+ }, void 0, /*#__PURE__*/jsx("span", {
104
82
  ref: ref,
105
- "data-testid": "ds-read_more-text"
106
- }, content), showButton && /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(MoreLessButton, {
83
+ "data-testid": "ds-read_more-text",
84
+ children: content
85
+ }), showButton && /*#__PURE__*/_jsx2("span", {}, void 0, /*#__PURE__*/_jsx2(MoreLessButton, {
107
86
  expanded: expanded,
108
87
  label: expanded ? less : more,
109
- onClick: function onClick() {
110
- return toggleExpanded(!expanded);
111
- },
88
+ onClick: () => toggleExpanded(!expanded),
112
89
  buttonType: buttonType,
113
90
  size: size,
114
91
  ellipsis: ellipsis
115
92
  })));
116
93
  };
117
94
 
118
- var DSReadMoreProps = {
95
+ const DSReadMoreProps = {
119
96
  /** Ammount of lines after you want to display an ellipsis + more/less button */
120
97
  lines: PropTypes.number.description('Ammount of lines after you want to display an ellipsis + more/less button').defaultValue(2),
121
98
 
@@ -145,9 +122,7 @@ var DSReadMoreProps = {
145
122
  /** The text you want to appear when truncating */
146
123
  ellipsis: PropTypes.string.description('The text you want to appear when truncating').defaultValue('...')
147
124
  };
148
- DSReadMore.propTypes = DSReadMoreProps;
149
- var DSReadMoreWithSchema = describe(DSReadMore).description('ReadMore component');
125
+ const DSReadMoreWithSchema = describe(DSReadMore).description('ReadMore component');
150
126
  DSReadMoreWithSchema.propTypes = DSReadMoreProps;
151
127
 
152
128
  export { DSReadMore, DSReadMoreWithSchema, DSReadMore as default };
153
- //# sourceMappingURL=DSReadMore.js.map
@@ -1,32 +1,20 @@
1
- import React from 'react';
2
- import { PropTypes } from 'react-desc';
1
+ import _jsx2 from '@babel/runtime/helpers/esm/jsx';
2
+ import 'react';
3
3
  import DSButton from '@elliemae/ds-button';
4
4
 
5
- var MoreLessButton = function MoreLessButton(_ref) {
6
- var expanded = _ref.expanded,
7
- label = _ref.label,
8
- onClick = _ref.onClick,
9
- buttonType = _ref.buttonType,
10
- size = _ref.size,
11
- ellipsis = _ref.ellipsis;
12
- return /*#__PURE__*/React.createElement("span", null, expanded ? ' ' : ellipsis, /*#__PURE__*/React.createElement(DSButton, {
13
- buttonType: buttonType,
14
- labelText: label,
15
- onClick: onClick,
16
- size: size,
17
- "data-testid": "ds-read_more-button"
18
- }));
19
- };
20
-
21
- var MoreLessButtonProps = {
22
- expanded: PropTypes.boolean,
23
- label: PropTypes.string,
24
- onClick: PropTypes.func,
25
- buttonType: PropTypes.string,
26
- size: PropTypes.string,
27
- ellipsis: PropTypes.string
28
- };
29
- MoreLessButton.propTypes = MoreLessButtonProps;
5
+ const MoreLessButton = ({
6
+ expanded,
7
+ label,
8
+ onClick,
9
+ buttonType,
10
+ size,
11
+ ellipsis
12
+ }) => /*#__PURE__*/_jsx2("span", {}, void 0, expanded ? ' ' : ellipsis, /*#__PURE__*/_jsx2(DSButton, {
13
+ buttonType: buttonType,
14
+ labelText: label,
15
+ onClick: onClick,
16
+ size: size,
17
+ "data-testid": "ds-read_more-button"
18
+ }));
30
19
 
31
20
  export { MoreLessButton };
32
- //# sourceMappingURL=MoreLessButton.js.map
package/esm/index.js CHANGED
@@ -1,8 +1 @@
1
1
  export { DSReadMore, DSReadMoreWithSchema, DSReadMore as default } from './DSReadMore.js';
2
- import '@babel/runtime/helpers/esm/slicedToArray';
3
- import 'react';
4
- import 'react-desc';
5
- import 'styled-components';
6
- import '@elliemae/ds-button';
7
- import './MoreLessButton.js';
8
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,14 +1,38 @@
1
1
  {
2
2
  "name": "@elliemae/ds-read-more",
3
- "version": "1.57.1-rc.0",
3
+ "version": "2.0.0-alpha.11",
4
4
  "license": "MIT",
5
- "description": "Ellie Mae - Dim Sum - Read More",
6
- "module": "esm/index.js",
7
- "main": "cjs/index.js",
5
+ "description": "ICE MT - Dimsum - Read More",
6
+ "module": "./esm/index.js",
7
+ "main": "./cjs/index.js",
8
+ "types": "./types/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./esm/index.js",
12
+ "require": "./cjs/index.js"
13
+ },
14
+ "./MoreLessButton": {
15
+ "import": "./esm/MoreLessButton.js",
16
+ "require": "./cjs/MoreLessButton.js"
17
+ },
18
+ "./DSReadMore": {
19
+ "import": "./esm/DSReadMore.js",
20
+ "require": "./cjs/DSReadMore.js"
21
+ }
22
+ },
8
23
  "sideEffects": [
9
24
  "*.css",
10
25
  "*.scss"
11
26
  ],
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "https://git.elliemae.io/platform-ui/dimsum.git"
30
+ },
31
+ "engines": {
32
+ "npm": ">=7",
33
+ "node": ">=14"
34
+ },
35
+ "author": "ICE MT",
12
36
  "scripts": {
13
37
  "dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
14
38
  "prebuild": "exit 0",
@@ -16,20 +40,20 @@
16
40
  "build": "node ../../scripts/build/build.js"
17
41
  },
18
42
  "dependencies": {
19
- "@elliemae/ds-basic": "1.57.1-rc.0",
20
- "@elliemae/ds-button": "1.57.1-rc.0",
21
- "react-desc": "^4.1.2"
43
+ "@elliemae/ds-button": "2.0.0-alpha.11",
44
+ "react-desc": "~4.1.3"
22
45
  },
23
46
  "devDependencies": {
24
- "styled-components": "~5.3.0"
47
+ "styled-components": "~5.3.1"
25
48
  },
26
49
  "peerDependencies": {
27
- "react": "^17.0.1",
28
- "react-dom": "^17.0.1",
29
- "styled-components": "^5.3.0"
50
+ "react": "^17.0.2",
51
+ "react-dom": "^17.0.2",
52
+ "styled-components": "^5.3.1"
30
53
  },
31
54
  "publishConfig": {
32
55
  "access": "public",
33
- "directory": "dist"
56
+ "directory": "dist",
57
+ "generateSubmodules": true
34
58
  }
35
59
  }
@@ -0,0 +1,39 @@
1
+ /// <reference types="react" />
2
+ declare const DSReadMore: {
3
+ ({ lines, more, less, onMore, onLess, content, buttonType, size, ellipsis, }: {
4
+ lines?: number | undefined;
5
+ more?: string | undefined;
6
+ less?: string | undefined;
7
+ onMore?: (() => null) | undefined;
8
+ onLess?: (() => null) | undefined;
9
+ content: any;
10
+ buttonType?: string | undefined;
11
+ size?: string | undefined;
12
+ ellipsis?: string | undefined;
13
+ }): JSX.Element;
14
+ propTypes: {
15
+ /** Ammount of lines after you want to display an ellipsis + more/less button */
16
+ lines: any;
17
+ /** Label which will appear on the 'More' button */
18
+ more: any;
19
+ /** Label which will appear on the 'Less' button */
20
+ less: any;
21
+ /** Function which will execute when the user click the 'More' button */
22
+ onMore: any;
23
+ /** Function which will execute when the user click the 'Less' button */
24
+ onLess: any;
25
+ /** The text content you want displayed */
26
+ content: any;
27
+ /** 'The type of button for more/less button' */
28
+ buttonType: any;
29
+ /**
30
+ * ['s', 'm', 'l']
31
+ */
32
+ size: any;
33
+ /** The text you want to appear when truncating */
34
+ ellipsis: any;
35
+ };
36
+ };
37
+ declare const DSReadMoreWithSchema: any;
38
+ export { DSReadMore, DSReadMoreWithSchema };
39
+ export default DSReadMore;
@@ -0,0 +1,20 @@
1
+ /// <reference types="react" />
2
+ declare const MoreLessButton: {
3
+ ({ expanded, label, onClick, buttonType, size, ellipsis, }: {
4
+ expanded: any;
5
+ label: any;
6
+ onClick: any;
7
+ buttonType: any;
8
+ size: any;
9
+ ellipsis: any;
10
+ }): JSX.Element;
11
+ propTypes: {
12
+ expanded: any;
13
+ label: any;
14
+ onClick: any;
15
+ buttonType: any;
16
+ size: any;
17
+ ellipsis: any;
18
+ };
19
+ };
20
+ export { MoreLessButton };
@@ -0,0 +1,2 @@
1
+ export * from './DSReadMore';
2
+ export { default } from './DSReadMore';
@@ -0,0 +1 @@
1
+ export {};
@@ -1,10 +0,0 @@
1
- {
2
- "name": "@elliemae/ds-read-more/DSReadMore",
3
- "sideEffects": [
4
- "*.css",
5
- "*.scss"
6
- ],
7
- "private": true,
8
- "main": "../cjs/DSReadMore.js",
9
- "module": "../esm/DSReadMore.js"
10
- }
@@ -1,10 +0,0 @@
1
- {
2
- "name": "@elliemae/ds-read-more/MoreLessButton",
3
- "sideEffects": [
4
- "*.css",
5
- "*.scss"
6
- ],
7
- "private": true,
8
- "main": "../cjs/MoreLessButton.js",
9
- "module": "../esm/MoreLessButton.js"
10
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"DSReadMore.js","sources":["../../../../shared-configs/prop-types.js","../../src/DSReadMore.tsx"],"sourcesContent":["/* eslint-disable max-lines */\nexport const dsBasicSizes = ['s', 'm', 'l'];\n\nexport const sizes = ['xsmall', 'small', 'medium', 'large', 'xlarge'];\n\nexport const iconSizes = ['xxs', 'xs', 's', 'm', 'l', 'xl', 'xxl'];\n\nexport const iconColors = [\n ['neutral', '900'],\n ['neutral', '0'],\n ['danger', '900'],\n ['warning', '500'],\n ['success', '900'],\n ['brand-primary', '600'],\n];\n\nexport const CHECKBOX_VARIANT = {\n DEFAULT: 'variant-default',\n FOCUS: 'variant-focus',\n ACTIVE: 'variant-active',\n DISABLED: 'variant-disabled',\n ERROR: 'variant-error',\n};\nexport const checkboxVariants = [\n CHECKBOX_VARIANT.DEFAULT,\n CHECKBOX_VARIANT.FOCUS,\n CHECKBOX_VARIANT.ACTIVE,\n CHECKBOX_VARIANT.DISABLED,\n CHECKBOX_VARIANT.ERROR,\n];\n\nexport const COMBOBOX_VARIANT = {\n DEFAULT: 'variant-default',\n FOCUS: 'variant-focus-input',\n FOCUS_ICON: 'variant-focus-icon',\n ACTIVE: 'variant-active-input',\n ACTIVE_ICON: 'variant-active-icon',\n DISABLED: 'variant-disabled',\n ERROR: 'variant-error',\n};\n\nexport const comboBoxVariants = [\n COMBOBOX_VARIANT.DEFAULT,\n COMBOBOX_VARIANT.FOCUS,\n COMBOBOX_VARIANT.FOCUS_ICON,\n COMBOBOX_VARIANT.ACTIVE,\n COMBOBOX_VARIANT.ACTIVE_ICON,\n COMBOBOX_VARIANT.DISABLED,\n COMBOBOX_VARIANT.ERROR,\n];\n\nexport const sizeVariants = {\n S: 's',\n M: 'm',\n L: 'l',\n};\n\nexport const position = {\n LEFT: 'left',\n RIGHT: 'right',\n CENTER: 'center',\n};\n\nexport const fontColor = {\n NEUTRAL500: 'neutral500',\n NEUTRAL700: 'neutral700',\n};\n\nexport const orientation = ['horizontal', 'vertical'];\n\nexport const orientationVariants = {\n HORIZONTAL: 'horizontal',\n VERTICAL: 'vertical',\n};\n","/* eslint-disable max-lines */\nimport React, { useLayoutEffect, useRef, useState } from 'react';\nimport { describe, PropTypes } from 'react-desc';\nimport styled from 'styled-components';\nimport { buttonTypes } from '@elliemae/ds-button';\nimport { dsBasicSizes } from '../../../shared-configs/prop-types';\nimport { MoreLessButton } from './MoreLessButton';\n\nconst Text = styled.span`\n display: -webkit-box;\n -webkit-line-clamp: ${({ lines, expanded }) => (expanded ? 'unset' : lines)};\n -webkit-box-orient: vertical;\n -webkit-hyphens: auto;\n -moz-hyphens: auto;\n -ms-hyphens: auto;\n hyphens: auto;\n word-break: break-all;\n`;\n\nconst DSReadMore = ({\n lines = 2,\n more = 'more',\n less = 'less',\n onMore = () => null,\n onLess = () => null,\n content,\n buttonType = 'link',\n size = 's',\n ellipsis = '...',\n}) => {\n const ref = useRef();\n const [showButton, setShowButton] = useState(false);\n const [expanded, setExpanded] = useState(false);\n\n // offsetHeight + 2 takes into consideration any size of the button\n const overflows = ({ offsetHeight, scrollHeight }) =>\n offsetHeight + 2 < scrollHeight;\n\n // Searchs the optimum cut on the text to have the button in the same line\n const binSearchTextOverflow = (element, parent) => {\n const text = element.innerText;\n let left = 1;\n let right = text.length;\n let textEnd = 0;\n while (left <= right) {\n const middle = (left + right) / 2;\n element.innerText = content.slice(0, middle);\n if (overflows(parent)) right = middle - 1;\n else {\n left = middle + 1;\n textEnd = middle;\n }\n }\n element.innerText = content.slice(0, textEnd);\n };\n\n useLayoutEffect(() => {\n const textElement = ref.current;\n const parentElement = ref.current?.parentElement;\n if (parentElement) {\n textElement.innerText = content;\n setShowButton(expanded || overflows(parentElement));\n if (!expanded && overflows(parentElement)) {\n binSearchTextOverflow(textElement, parentElement);\n }\n }\n }, [lines, content, expanded, showButton, more, less]);\n\n const toggleExpanded = (newExpanded) => {\n setExpanded(newExpanded);\n if (newExpanded) onMore();\n else onLess();\n };\n\n return (\n <Text lines={lines} expanded={expanded}>\n <span ref={ref} data-testid=\"ds-read_more-text\">\n {content}\n </span>\n {showButton && (\n <span>\n <MoreLessButton\n expanded={expanded}\n label={expanded ? less : more}\n onClick={() => toggleExpanded(!expanded)}\n buttonType={buttonType}\n size={size}\n ellipsis={ellipsis}\n />\n </span>\n )}\n </Text>\n );\n};\n\nconst DSReadMoreProps = {\n /** Ammount of lines after you want to display an ellipsis + more/less button */\n lines: PropTypes.number\n .description(\n 'Ammount of lines after you want to display an ellipsis + more/less button',\n )\n .defaultValue(2),\n /** Label which will appear on the 'More' button */\n more: PropTypes.string\n .description(\"Label which will appear on the 'More' button\")\n .defaultValue('more'),\n /** Label which will appear on the 'Less' button */\n less: PropTypes.string\n .description(\"Label which will appear on the 'Less' button\")\n .defaultValue('less'),\n /** Function which will execute when the user click the 'More' button */\n onMore: PropTypes.func.description(\n \"Function which will execute when the user click the 'More' button\",\n ),\n /** Function which will execute when the user click the 'Less' button */\n onLess: PropTypes.func.description(\n \"Function which will execute when the user click the 'Less' button\",\n ),\n /** The text content you want displayed */\n content: PropTypes.string.isRequired.description(\n 'The text content you want displayed',\n ),\n\n /** 'The type of button for more/less button' */\n buttonType: PropTypes.oneOf(buttonTypes)\n .description('The type for the more/less button')\n .defaultValue('link'),\n /**\n * ['s', 'm', 'l']\n */\n size: PropTypes.oneOf(dsBasicSizes)\n .description('Size of the button')\n .defaultValue('s'),\n\n /** The text you want to appear when truncating */\n ellipsis: PropTypes.string\n .description('The text you want to appear when truncating')\n .defaultValue('...'),\n};\n\nDSReadMore.propTypes = DSReadMoreProps;\n\nconst DSReadMoreWithSchema = describe(DSReadMore).description(\n 'ReadMore component',\n);\n\nDSReadMoreWithSchema.propTypes = DSReadMoreProps;\n\nexport { DSReadMore, DSReadMoreWithSchema };\nexport default DSReadMore;\n"],"names":["Text","styled","span","lines","expanded","DSReadMore","more","less","onMore","onLess","content","buttonType","size","ellipsis","ref","useRef","useState","showButton","setShowButton","setExpanded","overflows","offsetHeight","scrollHeight","binSearchTextOverflow","element","parent","text","innerText","left","right","length","textEnd","middle","slice","useLayoutEffect","textElement","current","parentElement","toggleExpanded","newExpanded","React","MoreLessButton","DSReadMoreProps","PropTypes","number","description","defaultValue","string","func","isRequired","oneOf","buttonTypes","dsBasicSizes","propTypes","DSReadMoreWithSchema","describe"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AACO,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;;ACO3C,IAAMA,IAAI,gBAAGC,0BAAM,CAACC,IAAV;AAAA;AAAA,2KAEc;AAAA,MAAGC,KAAH,QAAGA,KAAH;AAAA,MAAUC,QAAV,QAAUA,QAAV;AAAA,SAA0BA,QAAQ,GAAG,OAAH,GAAaD,KAA/C;AAAA,CAFd,CAAV;;IAWME,UAAU,GAAG,SAAbA,UAAa,QAUb;AAAA,0BATJF,KASI;AAAA,MATJA,KASI,4BATI,CASJ;AAAA,yBARJG,IAQI;AAAA,MARJA,IAQI,2BARG,MAQH;AAAA,yBAPJC,IAOI;AAAA,MAPJA,IAOI,2BAPG,MAOH;AAAA,2BANJC,MAMI;AAAA,MANJA,MAMI,6BANK;AAAA,WAAM,IAAN;AAAA,GAML;AAAA,2BALJC,MAKI;AAAA,MALJA,MAKI,6BALK;AAAA,WAAM,IAAN;AAAA,GAKL;AAAA,MAJJC,OAII,SAJJA,OAII;AAA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;;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"MoreLessButton.js","sources":["../../src/MoreLessButton.tsx"],"sourcesContent":["import React from 'react';\nimport { PropTypes } from 'react-desc';\nimport DSButton from '@elliemae/ds-button';\n\nconst MoreLessButton = ({\n expanded,\n label,\n onClick,\n buttonType,\n size,\n ellipsis,\n}) => (\n <span>\n {expanded ? ' ' : ellipsis}\n <DSButton\n buttonType={buttonType}\n labelText={label}\n onClick={onClick}\n size={size}\n data-testid=\"ds-read_more-button\"\n />\n </span>\n);\n\nconst MoreLessButtonProps = {\n expanded: PropTypes.boolean,\n label: PropTypes.string,\n onClick: PropTypes.func,\n buttonType: PropTypes.string,\n size: PropTypes.string,\n ellipsis: PropTypes.string,\n};\n\nMoreLessButton.propTypes = MoreLessButtonProps;\n\nexport { MoreLessButton };\n"],"names":["MoreLessButton","expanded","label","onClick","buttonType","size","ellipsis","React","DSButton","MoreLessButtonProps","PropTypes","boolean","string","func","propTypes"],"mappings":";;;;;;;;;;;;;IAIMA,cAAc,GAAG,SAAjBA,cAAiB;AAAA,MACrBC,QADqB,QACrBA,QADqB;AAAA,MAErBC,KAFqB,QAErBA,KAFqB;AAAA,MAGrBC,OAHqB,QAGrBA,OAHqB;AAAA,MAIrBC,UAJqB,QAIrBA,UAJqB;AAAA,MAKrBC,IALqB,QAKrBA,IALqB;AAAA,MAMrBC,QANqB,QAMrBA,QANqB;AAAA,sBAQrBC,sDACGN,QAAQ,GAAG,GAAH,GAASK,QADpB,eAEEC,wCAACC,4BAAD;AACE,IAAA,UAAU,EAAEJ,UADd;AAEE,IAAA,SAAS,EAAEF,KAFb;AAGE,IAAA,OAAO,EAAEC,OAHX;AAIE,IAAA,IAAI,EAAEE,IAJR;AAKE,mBAAY;AALd,IAFF,CARqB;AAAA;;AAoBvB,IAAMI,mBAAmB,GAAG;AAC1BR,EAAAA,QAAQ,EAAES,mBAAS,CAACC,OADM;AAE1BT,EAAAA,KAAK,EAAEQ,mBAAS,CAACE,MAFS;AAG1BT,EAAAA,OAAO,EAAEO,mBAAS,CAACG,IAHO;AAI1BT,EAAAA,UAAU,EAAEM,mBAAS,CAACE,MAJI;AAK1BP,EAAAA,IAAI,EAAEK,mBAAS,CAACE,MALU;AAM1BN,EAAAA,QAAQ,EAAEI,mBAAS,CAACE;AANM,CAA5B;AASAZ,cAAc,CAACc,SAAf,GAA2BL,mBAA3B;;;;"}
package/cjs/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"DSReadMore.js","sources":["../../../../shared-configs/prop-types.js","../../src/DSReadMore.tsx"],"sourcesContent":["/* eslint-disable max-lines */\nexport const dsBasicSizes = ['s', 'm', 'l'];\n\nexport const sizes = ['xsmall', 'small', 'medium', 'large', 'xlarge'];\n\nexport const iconSizes = ['xxs', 'xs', 's', 'm', 'l', 'xl', 'xxl'];\n\nexport const iconColors = [\n ['neutral', '900'],\n ['neutral', '0'],\n ['danger', '900'],\n ['warning', '500'],\n ['success', '900'],\n ['brand-primary', '600'],\n];\n\nexport const CHECKBOX_VARIANT = {\n DEFAULT: 'variant-default',\n FOCUS: 'variant-focus',\n ACTIVE: 'variant-active',\n DISABLED: 'variant-disabled',\n ERROR: 'variant-error',\n};\nexport const checkboxVariants = [\n CHECKBOX_VARIANT.DEFAULT,\n CHECKBOX_VARIANT.FOCUS,\n CHECKBOX_VARIANT.ACTIVE,\n CHECKBOX_VARIANT.DISABLED,\n CHECKBOX_VARIANT.ERROR,\n];\n\nexport const COMBOBOX_VARIANT = {\n DEFAULT: 'variant-default',\n FOCUS: 'variant-focus-input',\n FOCUS_ICON: 'variant-focus-icon',\n ACTIVE: 'variant-active-input',\n ACTIVE_ICON: 'variant-active-icon',\n DISABLED: 'variant-disabled',\n ERROR: 'variant-error',\n};\n\nexport const comboBoxVariants = [\n COMBOBOX_VARIANT.DEFAULT,\n COMBOBOX_VARIANT.FOCUS,\n COMBOBOX_VARIANT.FOCUS_ICON,\n COMBOBOX_VARIANT.ACTIVE,\n COMBOBOX_VARIANT.ACTIVE_ICON,\n COMBOBOX_VARIANT.DISABLED,\n COMBOBOX_VARIANT.ERROR,\n];\n\nexport const sizeVariants = {\n S: 's',\n M: 'm',\n L: 'l',\n};\n\nexport const position = {\n LEFT: 'left',\n RIGHT: 'right',\n CENTER: 'center',\n};\n\nexport const fontColor = {\n NEUTRAL500: 'neutral500',\n NEUTRAL700: 'neutral700',\n};\n\nexport const orientation = ['horizontal', 'vertical'];\n\nexport const orientationVariants = {\n HORIZONTAL: 'horizontal',\n VERTICAL: 'vertical',\n};\n","/* eslint-disable max-lines */\nimport React, { useLayoutEffect, useRef, useState } from 'react';\nimport { describe, PropTypes } from 'react-desc';\nimport styled from 'styled-components';\nimport { buttonTypes } from '@elliemae/ds-button';\nimport { dsBasicSizes } from '../../../shared-configs/prop-types';\nimport { MoreLessButton } from './MoreLessButton';\n\nconst Text = styled.span`\n display: -webkit-box;\n -webkit-line-clamp: ${({ lines, expanded }) => (expanded ? 'unset' : lines)};\n -webkit-box-orient: vertical;\n -webkit-hyphens: auto;\n -moz-hyphens: auto;\n -ms-hyphens: auto;\n hyphens: auto;\n word-break: break-all;\n`;\n\nconst DSReadMore = ({\n lines = 2,\n more = 'more',\n less = 'less',\n onMore = () => null,\n onLess = () => null,\n content,\n buttonType = 'link',\n size = 's',\n ellipsis = '...',\n}) => {\n const ref = useRef();\n const [showButton, setShowButton] = useState(false);\n const [expanded, setExpanded] = useState(false);\n\n // offsetHeight + 2 takes into consideration any size of the button\n const overflows = ({ offsetHeight, scrollHeight }) =>\n offsetHeight + 2 < scrollHeight;\n\n // Searchs the optimum cut on the text to have the button in the same line\n const binSearchTextOverflow = (element, parent) => {\n const text = element.innerText;\n let left = 1;\n let right = text.length;\n let textEnd = 0;\n while (left <= right) {\n const middle = (left + right) / 2;\n element.innerText = content.slice(0, middle);\n if (overflows(parent)) right = middle - 1;\n else {\n left = middle + 1;\n textEnd = middle;\n }\n }\n element.innerText = content.slice(0, textEnd);\n };\n\n useLayoutEffect(() => {\n const textElement = ref.current;\n const parentElement = ref.current?.parentElement;\n if (parentElement) {\n textElement.innerText = content;\n setShowButton(expanded || overflows(parentElement));\n if (!expanded && overflows(parentElement)) {\n binSearchTextOverflow(textElement, parentElement);\n }\n }\n }, [lines, content, expanded, showButton, more, less]);\n\n const toggleExpanded = (newExpanded) => {\n setExpanded(newExpanded);\n if (newExpanded) onMore();\n else onLess();\n };\n\n return (\n <Text lines={lines} expanded={expanded}>\n <span ref={ref} data-testid=\"ds-read_more-text\">\n {content}\n </span>\n {showButton && (\n <span>\n <MoreLessButton\n expanded={expanded}\n label={expanded ? less : more}\n onClick={() => toggleExpanded(!expanded)}\n buttonType={buttonType}\n size={size}\n ellipsis={ellipsis}\n />\n </span>\n )}\n </Text>\n );\n};\n\nconst DSReadMoreProps = {\n /** Ammount of lines after you want to display an ellipsis + more/less button */\n lines: PropTypes.number\n .description(\n 'Ammount of lines after you want to display an ellipsis + more/less button',\n )\n .defaultValue(2),\n /** Label which will appear on the 'More' button */\n more: PropTypes.string\n .description(\"Label which will appear on the 'More' button\")\n .defaultValue('more'),\n /** Label which will appear on the 'Less' button */\n less: PropTypes.string\n .description(\"Label which will appear on the 'Less' button\")\n .defaultValue('less'),\n /** Function which will execute when the user click the 'More' button */\n onMore: PropTypes.func.description(\n \"Function which will execute when the user click the 'More' button\",\n ),\n /** Function which will execute when the user click the 'Less' button */\n onLess: PropTypes.func.description(\n \"Function which will execute when the user click the 'Less' button\",\n ),\n /** The text content you want displayed */\n content: PropTypes.string.isRequired.description(\n 'The text content you want displayed',\n ),\n\n /** 'The type of button for more/less button' */\n buttonType: PropTypes.oneOf(buttonTypes)\n .description('The type for the more/less button')\n .defaultValue('link'),\n /**\n * ['s', 'm', 'l']\n */\n size: PropTypes.oneOf(dsBasicSizes)\n .description('Size of the button')\n .defaultValue('s'),\n\n /** The text you want to appear when truncating */\n ellipsis: PropTypes.string\n .description('The text you want to appear when truncating')\n .defaultValue('...'),\n};\n\nDSReadMore.propTypes = DSReadMoreProps;\n\nconst DSReadMoreWithSchema = describe(DSReadMore).description(\n 'ReadMore component',\n);\n\nDSReadMoreWithSchema.propTypes = DSReadMoreProps;\n\nexport { DSReadMore, DSReadMoreWithSchema };\nexport default DSReadMore;\n"],"names":["Text","styled","span","lines","expanded","DSReadMore","more","less","onMore","onLess","content","buttonType","size","ellipsis","ref","useRef","useState","showButton","setShowButton","setExpanded","overflows","offsetHeight","scrollHeight","binSearchTextOverflow","element","parent","text","innerText","left","right","length","textEnd","middle","slice","useLayoutEffect","textElement","current","parentElement","toggleExpanded","newExpanded","DSReadMoreProps","PropTypes","number","description","defaultValue","string","func","isRequired","oneOf","buttonTypes","dsBasicSizes","propTypes","DSReadMoreWithSchema","describe"],"mappings":";;;;;;;AAAA;AACO,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;;ACO3C,IAAMA,IAAI,gBAAGC,MAAM,CAACC,IAAV;AAAA;AAAA,2KAEc;AAAA,MAAGC,KAAH,QAAGA,KAAH;AAAA,MAAUC,QAAV,QAAUA,QAAV;AAAA,SAA0BA,QAAQ,GAAG,OAAH,GAAaD,KAA/C;AAAA,CAFd,CAAV;;IAWME,UAAU,GAAG,SAAbA,UAAa,QAUb;AAAA,0BATJF,KASI;AAAA,MATJA,KASI,4BATI,CASJ;AAAA,yBARJG,IAQI;AAAA,MARJA,IAQI,2BARG,MAQH;AAAA,yBAPJC,IAOI;AAAA,MAPJA,IAOI,2BAPG,MAOH;AAAA,2BANJC,MAMI;AAAA,MANJA,MAMI,6BANK;AAAA,WAAM,IAAN;AAAA,GAML;AAAA,2BALJC,MAKI;AAAA,MALJA,MAKI,6BALK;AAAA,WAAM,IAAN;AAAA,GAKL;AAAA,MAJJC,OAII,SAJJA,OAII;AAAA,+BAHJC,UAGI;AAAA,MAHJA,UA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../../src/MoreLessButton.tsx"],"sourcesContent":["import React from 'react';\nimport { PropTypes } from 'react-desc';\nimport DSButton from '@elliemae/ds-button';\n\nconst MoreLessButton = ({\n expanded,\n label,\n onClick,\n buttonType,\n size,\n ellipsis,\n}) => (\n <span>\n {expanded ? ' ' : ellipsis}\n <DSButton\n buttonType={buttonType}\n labelText={label}\n onClick={onClick}\n size={size}\n data-testid=\"ds-read_more-button\"\n />\n </span>\n);\n\nconst MoreLessButtonProps = {\n expanded: PropTypes.boolean,\n label: PropTypes.string,\n onClick: PropTypes.func,\n buttonType: PropTypes.string,\n size: PropTypes.string,\n ellipsis: PropTypes.string,\n};\n\nMoreLessButton.propTypes = MoreLessButtonProps;\n\nexport { MoreLessButton };\n"],"names":["MoreLessButton","expanded","label","onClick","buttonType","size","ellipsis","MoreLessButtonProps","PropTypes","boolean","string","func","propTypes"],"mappings":";;;;IAIMA,cAAc,GAAG,SAAjBA,cAAiB;AAAA,MACrBC,QADqB,QACrBA,QADqB;AAAA,MAErBC,KAFqB,QAErBA,KAFqB;AAAA,MAGrBC,OAHqB,QAGrBA,OAHqB;AAAA,MAIrBC,UAJqB,QAIrBA,UAJqB;AAAA,MAKrBC,IALqB,QAKrBA,IALqB;AAAA,MAMrBC,QANqB,QAMrBA,QANqB;AAAA,sBAQrB,kCACGL,QAAQ,GAAG,GAAH,GAASK,QADpB,eAEE,oBAAC,QAAD;AACE,IAAA,UAAU,EAAEF,UADd;AAEE,IAAA,SAAS,EAAEF,KAFb;AAGE,IAAA,OAAO,EAAEC,OAHX;AAIE,IAAA,IAAI,EAAEE,IAJR;AAKE,mBAAY;AALd,IAFF,CARqB;AAAA;;AAoBvB,IAAME,mBAAmB,GAAG;AAC1BN,EAAAA,QAAQ,EAAEO,SAAS,CAACC,OADM;AAE1BP,EAAAA,KAAK,EAAEM,SAAS,CAACE,MAFS;AAG1BP,EAAAA,OAAO,EAAEK,SAAS,CAACG,IAHO;AAI1BP,EAAAA,UAAU,EAAEI,SAAS,CAACE,MAJI;AAK1BL,EAAAA,IAAI,EAAEG,SAAS,CAACE,MALU;AAM1BJ,EAAAA,QAAQ,EAAEE,SAAS,CAACE;AANM,CAA5B;AASAV,cAAc,CAACY,SAAf,GAA2BL,mBAA3B;;;;"}
package/esm/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}