react-show-more-text 1.5.0 → 1.5.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/CHANGELOG.md CHANGED
@@ -1,9 +1,13 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [1.5.1] - 2021-11-24
5
+ - [#34](https://github.com/devzonetech/react-show-more-text/issues/34) Added props expandByClick true/false #34
6
+
4
7
  ## [1.5.0] - 2021-07-25
5
8
  ### Added
6
9
  - [#31](https://github.com/devzonetech/react-show-more-text/issues/31) Ability to change or remove the ... at the end
10
+ - [#25](https://github.com/devzonetech/react-show-more-text/issues/25)Showing [@ at the end
7
11
  ### Fixed
8
12
  - Dependencies updated
9
13
 
package/README.md CHANGED
@@ -86,7 +86,8 @@ class Foo extends Component {
86
86
  | className | string | '' | Class name(s) to add on component content wrapper div. | `'wrapper-class'`, `'wrapper-class-1 wrapper-class-2'` |
87
87
  | anchorClass | string | '' | Class name(s) to add to the anchor elements. | `'my-anchor-class'`, `'class-1 class-2'` |
88
88
  | onClick | Function | | Function executed on click on 'Show more' or 'Show less' | `onClick={this.executeOnClick}` |
89
- | expanded | boolean | 'false' | Control the text to be shown as expanded | `expanded={true}` |
89
+ | expanded | boolean | 'false' | Control the text to be shown as expanded | `expanded={true}` |
90
+ | expandByClick | boolean | 'true' | Cancel the default anchor click expand behavior | `expandByClick={false}` |
90
91
  | width | number | `0` | If not `0`, the calculation of the content will be based on this number. | |
91
92
  | keepNewLines | boolean | 'false' | Controls the new lines in text to be kept or not. When set to true, only strings can be passed in as children, and not html nodes. | `keepNewLines={true}` |
92
93
  | truncatedEndingComponent | string | '...' | Control the text to be shown at the end of short text | `truncatedEndingComponent={'... '}` |
@@ -72,6 +72,14 @@ var ShowMoreText = /*#__PURE__*/function (_Component) {
72
72
 
73
73
  var _self = _assertThisInitialized(_this);
74
74
 
75
+ if (!_self.props.expandByClick) {
76
+ if (_self.props.onClick) {
77
+ _self.props.onClick(_self.state.expanded);
78
+ }
79
+
80
+ return;
81
+ }
82
+
75
83
  if (_this._isMounted) {
76
84
  _this.setState({
77
85
  expanded: !_this.state.expanded
@@ -172,7 +180,8 @@ _defineProperty(ShowMoreText, "defaultProps", {
172
180
  expanded: false,
173
181
  width: 0,
174
182
  keepNewLines: false,
175
- truncatedEndingComponent: '... '
183
+ truncatedEndingComponent: '... ',
184
+ expandByClick: true
176
185
  });
177
186
 
178
187
  _defineProperty(ShowMoreText, "propTypes", {
@@ -186,7 +195,8 @@ _defineProperty(ShowMoreText, "propTypes", {
186
195
  expanded: _propTypes.PropTypes.bool,
187
196
  width: _propTypes.PropTypes.number,
188
197
  keepNewLines: _propTypes.PropTypes.bool,
189
- truncatedEndingComponent: _propTypes.PropTypes.node
198
+ truncatedEndingComponent: _propTypes.PropTypes.node,
199
+ expandByClick: _propTypes.PropTypes.bool
190
200
  });
191
201
 
192
202
  var _default = ShowMoreText;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-show-more-text",
3
- "version": "1.5.0",
3
+ "version": "1.5.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": [
@@ -8,7 +8,7 @@
8
8
  ],
9
9
  "scripts": {
10
10
  "compile": "./node_modules/.bin/babel src/ShowMoreText.js src/Truncate.js --out-dir lib",
11
- "compile:watch": "onchange \"src/**/*.js\" -- npm run compile --silent",
11
+ "compile:watch": "onchange \"src/**/*.js\" -- npm run compile --silent --source-maps",
12
12
  "coverage": "nyc npm test && nyc report --reporter=text-lcov",
13
13
  "lint": "eslint .",
14
14
  "prepublish": "rm -rf ./lib && npm run compile",