react-show-more-text 1.6.0 → 1.6.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.
package/README.md CHANGED
@@ -1,9 +1,8 @@
1
- # React Show More Text 1.6.0
1
+ # React Show More Text 1.6.1
2
2
 
3
3
  [![NPM version][npm-image]][npm-url]
4
4
  [![Downloads][downloads-image]][npm-url]
5
5
  [![Build status][travis-image]][travis-url]
6
- [![Dependency status][david-dm-image]][david-dm-url]
7
6
 
8
7
  The text surrounded by the component will be truncated. Anything surrounded by the component could be evaluated as text. The component react-show-more-text/ShowMoreText is fork of react-show-more/ShowMore, applied improvements, works with React 16.x.x, React 18.x.x added onClick event.
9
8
 
@@ -128,7 +127,5 @@ $ npm run storybook --legacy-peer-deps=true
128
127
  [npm-url]: https://npmjs.org/package/react-show-more-text
129
128
  [downloads-image]: http://img.shields.io/npm/dm/react-show-more-text.svg
130
129
  [npm-image]: https://badge.fury.io/js/react-show-more-text.svg
131
- [travis-url]: https://travis-ci.com/devzonetech/react-show-more-text
132
- [travis-image]: https://travis-ci.com/devzonetech/react-show-more-text.svg?branch=master
133
- [david-dm-url]: https://david-dm.org/devzonetech/react-show-more-text
134
- [david-dm-image]: https://david-dm.org/devzonetech/react-show-more-text.svg
130
+ [travis-url]: https://app.travis-ci.com/github/devzonetech/react-show-more-text
131
+ [travis-image]: https://travis-ci.com/devzonetech/react-show-more-text.svg?branch=master
@@ -64,6 +64,8 @@ var ShowMoreText = /*#__PURE__*/function (_Component) {
64
64
  if (truncated) {
65
65
  _this.truncateRef.onResize();
66
66
  }
67
+
68
+ _this.props.onTruncate && _this.props.onTruncate();
67
69
  }
68
70
  });
69
71
 
@@ -130,7 +132,8 @@ var ShowMoreText = /*#__PURE__*/function (_Component) {
130
132
  className = _this$props.className,
131
133
  width = _this$props.width,
132
134
  keepNewLines = _this$props.keepNewLines,
133
- truncatedEndingComponent = _this$props.truncatedEndingComponent;
135
+ truncatedEndingComponent = _this$props.truncatedEndingComponent,
136
+ onTruncate = _this$props.onTruncate;
134
137
  var _this$state = this.state,
135
138
  expanded = _this$state.expanded,
136
139
  truncated = _this$state.truncated;
@@ -181,7 +184,8 @@ _defineProperty(ShowMoreText, "defaultProps", {
181
184
  width: 0,
182
185
  keepNewLines: false,
183
186
  truncatedEndingComponent: '... ',
184
- expandByClick: true
187
+ expandByClick: true,
188
+ onTruncate: undefined
185
189
  });
186
190
 
187
191
  _defineProperty(ShowMoreText, "propTypes", {
@@ -196,7 +200,8 @@ _defineProperty(ShowMoreText, "propTypes", {
196
200
  width: _propTypes.PropTypes.number,
197
201
  keepNewLines: _propTypes.PropTypes.bool,
198
202
  truncatedEndingComponent: _propTypes.PropTypes.node,
199
- expandByClick: _propTypes.PropTypes.bool
203
+ expandByClick: _propTypes.PropTypes.bool,
204
+ onTruncate: _propTypes.PropTypes.func
200
205
  });
201
206
 
202
207
  var _default = ShowMoreText;
package/lib/Truncate.js CHANGED
@@ -330,7 +330,7 @@ var Truncate = /*#__PURE__*/function (_React$Component) {
330
330
  this.canvasContext = canvas.getContext('2d');
331
331
  calcTargetWidth(function () {
332
332
  // Node not needed in document tree to read its content
333
- if (text) {
333
+ if (text && text.parentNode) {
334
334
  text.parentNode.removeChild(text);
335
335
  }
336
336
  });
@@ -355,7 +355,11 @@ var Truncate = /*#__PURE__*/function (_React$Component) {
355
355
  var ellipsis = this.elements.ellipsis,
356
356
  onResize = this.onResize,
357
357
  timeout = this.timeout;
358
- ellipsis.parentNode.removeChild(ellipsis);
358
+
359
+ if (ellipsis.parentNode) {
360
+ ellipsis.parentNode.removeChild(ellipsis);
361
+ }
362
+
359
363
  window.removeEventListener('resize', onResize);
360
364
  window.cancelAnimationFrame(timeout);
361
365
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-show-more-text",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "The text surrounded by the component will be truncated. Anything surrounded by the component could be evaluated as text. The component react-show-more-text/ShowMoreText is fork of react-show-more/ShowMore, applied improvements, works with React 16.x.x, added onClick event.",
5
5
  "main": "lib/ShowMoreText.js",
6
6
  "files": [
@@ -49,12 +49,12 @@
49
49
  "@babel/preset-env": "^7.12.1",
50
50
  "@babel/preset-react": "^7.12.1",
51
51
  "@storybook/addon-actions": "^6.5.12",
52
- "@storybook/addon-essentials": "^6.5.12",
52
+ "@storybook/addon-essentials": "^6.4.22",
53
53
  "@storybook/addon-interactions": "^6.5.12",
54
54
  "@storybook/addon-links": "^6.5.12",
55
55
  "@storybook/builder-webpack4": "^6.5.12",
56
56
  "@storybook/manager-webpack4": "^6.5.12",
57
- "@storybook/react": "^6.5.12",
57
+ "@storybook/react": "^6.1.21",
58
58
  "@storybook/testing-library": "^0.0.13",
59
59
  "babel-eslint": "^10.1.0",
60
60
  "babel-loader": "^8.2.5",
@@ -64,7 +64,7 @@
64
64
  "coveralls": "^3.0.7",
65
65
  "enzyme": "^3.11.0",
66
66
  "enzyme-adapter-react-16": "^1.15.5",
67
- "eslint": "^4.14.0",
67
+ "eslint": "^8.24.0",
68
68
  "eslint-config-onelint": "^3.0.0",
69
69
  "eslint-config-onelint-react": "^2.0.1",
70
70
  "eslint-config-react-app": "^6.0.0",
@@ -74,8 +74,9 @@
74
74
  "eslint-plugin-jsx-a11y": "^6.4.1",
75
75
  "eslint-plugin-react": "^7.21.5",
76
76
  "eslint-plugin-react-hooks": "^4.2.0",
77
- "jest": "^25.3.0",
78
- "jest-enzyme": "^7.1.2",
77
+ "jest": "^29.1.2",
78
+ "jest-environment-jsdom": "^29.1.2",
79
+ "jest-enzyme": "^4.2.0",
79
80
  "nyc": "^14.1.1",
80
81
  "onchange": "^6.1.1",
81
82
  "react": "^16.14.0",