react-show-more-text 1.7.1 → 1.7.2-rc.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.
- package/lib/ShowMoreText.js +8 -8
- package/lib/Truncate.js +26 -23
- package/package.json +22 -42
package/lib/ShowMoreText.js
CHANGED
|
@@ -7,10 +7,11 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = require("prop-types");
|
|
9
9
|
var _Truncate = _interopRequireDefault(require("./Truncate"));
|
|
10
|
-
function _interopRequireDefault(
|
|
11
|
-
function
|
|
12
|
-
function
|
|
13
|
-
function
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
12
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
15
|
class ShowMoreText extends _react.Component {
|
|
15
16
|
constructor(props) {
|
|
16
17
|
super(props);
|
|
@@ -101,10 +102,10 @@ class ShowMoreText extends _react.Component {
|
|
|
101
102
|
key: i + "br"
|
|
102
103
|
})];
|
|
103
104
|
}
|
|
104
|
-
}) : children
|
|
105
|
+
}) : children, !truncated && expanded && /*#__PURE__*/_react.default.createElement("span", null, " ", /*#__PURE__*/_react.default.createElement("span", {
|
|
105
106
|
className: anchorClass,
|
|
106
107
|
onClick: this.toggleLines
|
|
107
|
-
}, less)));
|
|
108
|
+
}, less))));
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
_defineProperty(ShowMoreText, "defaultProps", {
|
|
@@ -135,5 +136,4 @@ _defineProperty(ShowMoreText, "propTypes", {
|
|
|
135
136
|
expandByClick: _propTypes.PropTypes.bool,
|
|
136
137
|
onTruncate: _propTypes.PropTypes.func
|
|
137
138
|
});
|
|
138
|
-
var _default = ShowMoreText;
|
|
139
|
-
exports.default = _default;
|
|
139
|
+
var _default = exports.default = ShowMoreText;
|
package/lib/Truncate.js
CHANGED
|
@@ -6,24 +6,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
function _interopRequireDefault(
|
|
10
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (
|
|
11
|
-
function _defineProperty(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
11
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
12
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
13
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /**
|
|
14
|
+
* LICENSE
|
|
15
|
+
* https://github.com/pablosichert/react-truncate/blob/master/LICENSE.md
|
|
16
|
+
*
|
|
17
|
+
* ISC License
|
|
18
|
+
Copyright (c) 2016, One.com
|
|
19
|
+
|
|
20
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is
|
|
21
|
+
hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
|
|
24
|
+
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
|
|
25
|
+
FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
26
|
+
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
27
|
+
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
28
|
+
*/ // Initial version of react-truncate module (v2.4.0)
|
|
27
29
|
class Truncate extends _react.default.Component {
|
|
28
30
|
constructor() {
|
|
29
31
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -49,6 +51,10 @@ class Truncate extends _react.default.Component {
|
|
|
49
51
|
});
|
|
50
52
|
return this.createMarkup(content);
|
|
51
53
|
});
|
|
54
|
+
_defineProperty(this, "stripHtmlTags", str => {
|
|
55
|
+
return str.replace(/<[^>]*>/g, " ");
|
|
56
|
+
});
|
|
57
|
+
// Shim innerText to consistently break lines at <br/> but not at \n
|
|
52
58
|
_defineProperty(this, "innerText", node => {
|
|
53
59
|
const div = document.createElement("div");
|
|
54
60
|
const contentKey = "innerText" in window.HTMLElement.prototype ? "innerText" : "textContent";
|
|
@@ -109,7 +115,7 @@ class Truncate extends _react.default.Component {
|
|
|
109
115
|
}, callback);
|
|
110
116
|
});
|
|
111
117
|
_defineProperty(this, "measureWidth", text => {
|
|
112
|
-
return this.canvasContext.measureText(text).width;
|
|
118
|
+
return this.canvasContext.measureText(this.stripHtmlTags(text)).width;
|
|
113
119
|
});
|
|
114
120
|
_defineProperty(this, "ellipsisWidth", node => {
|
|
115
121
|
return node.offsetWidth;
|
|
@@ -298,9 +304,6 @@ class Truncate extends _react.default.Component {
|
|
|
298
304
|
window.removeEventListener("resize", onResize);
|
|
299
305
|
window.cancelAnimationFrame(timeout);
|
|
300
306
|
}
|
|
301
|
-
|
|
302
|
-
// Shim innerText to consistently break lines at <br/> but not at \n
|
|
303
|
-
|
|
304
307
|
render() {
|
|
305
308
|
const {
|
|
306
309
|
elements: {
|
|
@@ -337,7 +340,7 @@ class Truncate extends _react.default.Component {
|
|
|
337
340
|
}), /*#__PURE__*/_react.default.createElement("span", {
|
|
338
341
|
style: {
|
|
339
342
|
display: "block",
|
|
340
|
-
maxWidth: spanProps.width > 0 ?
|
|
343
|
+
maxWidth: spanProps.width > 0 ? `${spanProps.width}px` : "unset"
|
|
341
344
|
}
|
|
342
345
|
}, text), /*#__PURE__*/_react.default.createElement("span", {
|
|
343
346
|
ref: textEl => {
|
package/package.json
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-show-more-text",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2-rc.0",
|
|
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": [
|
|
7
7
|
"lib"
|
|
8
8
|
],
|
|
9
9
|
"scripts": {
|
|
10
|
-
"compile": "
|
|
10
|
+
"compile": "babel src/ShowMoreText.js src/Truncate.js --out-dir lib",
|
|
11
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
|
-
"prepublish": "rm -rf ./lib && npm run compile",
|
|
15
14
|
"preversion": "npm run test",
|
|
16
15
|
"report-coverage": "npm run coverage | coveralls",
|
|
17
|
-
"test": "
|
|
18
|
-
"test:watch": "
|
|
19
|
-
"travis": "npm run compile && npm run test"
|
|
20
|
-
"storybook": "start-storybook -p 6006",
|
|
21
|
-
"build-storybook": "build-storybook"
|
|
16
|
+
"test": "jest --runInBand",
|
|
17
|
+
"test:watch": "jest --watch --runInBand",
|
|
18
|
+
"travis": "npm run compile && npm run test"
|
|
22
19
|
},
|
|
23
20
|
"repository": {
|
|
24
21
|
"type": "git",
|
|
@@ -43,47 +40,30 @@
|
|
|
43
40
|
"react": "16 - 18.x"
|
|
44
41
|
},
|
|
45
42
|
"devDependencies": {
|
|
46
|
-
"@babel/cli": "^7.
|
|
47
|
-
"@babel/core": "^7.
|
|
43
|
+
"@babel/cli": "^7.22.10",
|
|
44
|
+
"@babel/core": "^7.22.10",
|
|
45
|
+
"@babel/eslint-parser": "^7.22.10",
|
|
48
46
|
"@babel/plugin-proposal-class-properties": "^7.12.1",
|
|
49
|
-
"@babel/preset-env": "^7.
|
|
50
|
-
"@babel/preset-react": "^7.
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"@storybook/addon-interactions": "^6.5.12",
|
|
54
|
-
"@storybook/addon-links": "^6.5.12",
|
|
55
|
-
"@storybook/builder-webpack4": "^6.5.12",
|
|
56
|
-
"@storybook/manager-webpack4": "^6.5.12",
|
|
57
|
-
"@storybook/react": "^6.1.21",
|
|
58
|
-
"@storybook/testing-library": "^0.0.13",
|
|
59
|
-
"babel-eslint": "^10.1.0",
|
|
60
|
-
"babel-loader": "^8.2.5",
|
|
61
|
-
"babel-preset-minify": "^0.5.1",
|
|
62
|
-
"canvas": "^2.8.0",
|
|
63
|
-
"core-js": "^3.6.5",
|
|
64
|
-
"coveralls": "^3.0.7",
|
|
47
|
+
"@babel/preset-env": "^7.22.10",
|
|
48
|
+
"@babel/preset-react": "^7.22.10",
|
|
49
|
+
"babel-jest": "^29.6.4",
|
|
50
|
+
"cheerio": "0.22.0",
|
|
65
51
|
"enzyme": "^3.11.0",
|
|
66
52
|
"enzyme-adapter-react-16": "^1.15.5",
|
|
67
|
-
"eslint": "^8.
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"eslint-plugin-flowtype": "^5.8.1",
|
|
72
|
-
"eslint-plugin-import": "^2.23.4",
|
|
73
|
-
"eslint-plugin-jest": "^23.20.0",
|
|
74
|
-
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
75
|
-
"eslint-plugin-react": "^7.21.5",
|
|
76
|
-
"eslint-plugin-react-hooks": "^4.2.0",
|
|
77
|
-
"jest": "^29.1.2",
|
|
78
|
-
"jest-environment-jsdom": "^29.1.2",
|
|
79
|
-
"jest-enzyme": "^4.2.0",
|
|
80
|
-
"nyc": "^14.1.1",
|
|
81
|
-
"onchange": "^6.1.1",
|
|
53
|
+
"eslint": "^8.50.0",
|
|
54
|
+
"jest": "^29.6.4",
|
|
55
|
+
"jest-environment-jsdom": "^30.2.0",
|
|
56
|
+
"onchange": "^7.0.0",
|
|
82
57
|
"react": "^16.14.0",
|
|
83
|
-
"react-dom": "^16.14.0"
|
|
58
|
+
"react-dom": "^16.14.0",
|
|
59
|
+
"react-test-renderer": "^16.14.0"
|
|
84
60
|
},
|
|
85
61
|
"dependencies": {
|
|
86
62
|
"prop-types": "^15.7.2"
|
|
87
63
|
},
|
|
88
64
|
"browserslist": "> 0.25%, not dead"
|
|
65
|
+
,
|
|
66
|
+
"overrides": {
|
|
67
|
+
"cheerio": "0.22.0"
|
|
68
|
+
}
|
|
89
69
|
}
|