@elliemae/ds-truncated-expandable-text 2.4.2-rc.9 → 2.4.3-rc.2
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.
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
7
6
|
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
8
7
|
require('core-js/modules/esnext.iterator.constructor.js');
|
|
9
8
|
require('core-js/modules/esnext.iterator.for-each.js');
|
|
@@ -46,7 +45,7 @@ const TruncatedExpandableText = _ref => {
|
|
|
46
45
|
} = element.getBoundingClientRect();
|
|
47
46
|
value.split('').forEach((char, index) => {
|
|
48
47
|
// try the hyphen here
|
|
49
|
-
element.innerText =
|
|
48
|
+
element.innerText = `${newHyphenizedValue}-${char}`;
|
|
50
49
|
const {
|
|
51
50
|
height: newHeight
|
|
52
51
|
} = element.getBoundingClientRect(); // if it's the first line or the height didn't change, hyphen doesn't go here,
|
|
@@ -57,20 +56,20 @@ const TruncatedExpandableText = _ref => {
|
|
|
57
56
|
newHyphenizedValue += char;
|
|
58
57
|
} else if (index < value.length - 1 && value[index + 1].match(/\s/)) {
|
|
59
58
|
// end of word
|
|
60
|
-
element.innerText =
|
|
59
|
+
element.innerText = `${newHyphenizedValue}${char}`; // sometimes the last character is wider and doesn't fit
|
|
61
60
|
|
|
62
61
|
const {
|
|
63
62
|
height: endOfWordHeight
|
|
64
63
|
} = element.getBoundingClientRect();
|
|
65
|
-
if (endOfWordHeight === previousHeight) newHyphenizedValue += char;else newHyphenizedValue +=
|
|
64
|
+
if (endOfWordHeight === previousHeight) newHyphenizedValue += char;else newHyphenizedValue += `-${char}`;
|
|
66
65
|
} else if (char.match(/\s/)) {
|
|
67
66
|
// we dont want "- ", leave the space character only
|
|
68
67
|
newHyphenizedValue += char;
|
|
69
68
|
} else if (newHyphenizedValue.length && newHyphenizedValue[newHyphenizedValue.length - 1].match(/\s/)) {
|
|
70
69
|
// we produce and empty space to make sure to start on the next line
|
|
71
|
-
newHyphenizedValue +=
|
|
70
|
+
newHyphenizedValue += ` ${char}`;
|
|
72
71
|
} else {
|
|
73
|
-
newHyphenizedValue +=
|
|
72
|
+
newHyphenizedValue += `-${char}`;
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
previousHeight = newHeight;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
3
2
|
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
4
3
|
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
5
4
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
@@ -37,7 +36,7 @@ const TruncatedExpandableText = _ref => {
|
|
|
37
36
|
} = element.getBoundingClientRect();
|
|
38
37
|
value.split('').forEach((char, index) => {
|
|
39
38
|
// try the hyphen here
|
|
40
|
-
element.innerText =
|
|
39
|
+
element.innerText = `${newHyphenizedValue}-${char}`;
|
|
41
40
|
const {
|
|
42
41
|
height: newHeight
|
|
43
42
|
} = element.getBoundingClientRect(); // if it's the first line or the height didn't change, hyphen doesn't go here,
|
|
@@ -48,20 +47,20 @@ const TruncatedExpandableText = _ref => {
|
|
|
48
47
|
newHyphenizedValue += char;
|
|
49
48
|
} else if (index < value.length - 1 && value[index + 1].match(/\s/)) {
|
|
50
49
|
// end of word
|
|
51
|
-
element.innerText =
|
|
50
|
+
element.innerText = `${newHyphenizedValue}${char}`; // sometimes the last character is wider and doesn't fit
|
|
52
51
|
|
|
53
52
|
const {
|
|
54
53
|
height: endOfWordHeight
|
|
55
54
|
} = element.getBoundingClientRect();
|
|
56
|
-
if (endOfWordHeight === previousHeight) newHyphenizedValue += char;else newHyphenizedValue +=
|
|
55
|
+
if (endOfWordHeight === previousHeight) newHyphenizedValue += char;else newHyphenizedValue += `-${char}`;
|
|
57
56
|
} else if (char.match(/\s/)) {
|
|
58
57
|
// we dont want "- ", leave the space character only
|
|
59
58
|
newHyphenizedValue += char;
|
|
60
59
|
} else if (newHyphenizedValue.length && newHyphenizedValue[newHyphenizedValue.length - 1].match(/\s/)) {
|
|
61
60
|
// we produce and empty space to make sure to start on the next line
|
|
62
|
-
newHyphenizedValue +=
|
|
61
|
+
newHyphenizedValue += ` ${char}`;
|
|
63
62
|
} else {
|
|
64
|
-
newHyphenizedValue +=
|
|
63
|
+
newHyphenizedValue += `-${char}`;
|
|
65
64
|
}
|
|
66
65
|
|
|
67
66
|
previousHeight = newHeight;
|