@instructure/ui-truncate-text 8.11.2-snapshot.3 → 8.11.2-snapshot.39
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/es/TruncateText/index.js
CHANGED
|
@@ -48,7 +48,7 @@ let TruncateText = (_dec = withStyle(generateStyle, generateComponentTheme), _de
|
|
|
48
48
|
this.ref = null;
|
|
49
49
|
|
|
50
50
|
this.update = () => {
|
|
51
|
-
if (this.
|
|
51
|
+
if (this.ref) {
|
|
52
52
|
this.setState(this.initialState);
|
|
53
53
|
}
|
|
54
54
|
};
|
|
@@ -56,6 +56,10 @@ let TruncateText = (_dec = withStyle(generateStyle, generateComponentTheme), _de
|
|
|
56
56
|
this.state = this.initialState;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
get _ref() {
|
|
60
|
+
return this.ref;
|
|
61
|
+
}
|
|
62
|
+
|
|
59
63
|
get initialState() {
|
|
60
64
|
return {
|
|
61
65
|
isTruncated: false,
|
|
@@ -80,7 +84,7 @@ let TruncateText = (_dec = withStyle(generateStyle, generateComponentTheme), _de
|
|
|
80
84
|
trailing: true
|
|
81
85
|
});
|
|
82
86
|
|
|
83
|
-
const _getBoundingClientRec = getBoundingClientRect(this.
|
|
87
|
+
const _getBoundingClientRec = getBoundingClientRect(this.ref),
|
|
84
88
|
origWidth = _getBoundingClientRec.width;
|
|
85
89
|
|
|
86
90
|
this._resizeListener = new ResizeObserver(entries => {
|
|
@@ -98,7 +102,7 @@ let TruncateText = (_dec = withStyle(generateStyle, generateComponentTheme), _de
|
|
|
98
102
|
});
|
|
99
103
|
});
|
|
100
104
|
|
|
101
|
-
this._resizeListener.observe(this.
|
|
105
|
+
this._resizeListener.observe(this.ref);
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
108
|
|
|
@@ -173,7 +177,7 @@ let TruncateText = (_dec = withStyle(generateStyle, generateComponentTheme), _de
|
|
|
173
177
|
var _this$props$styles;
|
|
174
178
|
|
|
175
179
|
const result = truncate(this._stage, { ...this.props,
|
|
176
|
-
parent: this.
|
|
180
|
+
parent: this.ref,
|
|
177
181
|
lineHeight: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.lineHeight
|
|
178
182
|
});
|
|
179
183
|
|
|
@@ -187,12 +191,14 @@ let TruncateText = (_dec = withStyle(generateStyle, generateComponentTheme), _de
|
|
|
187
191
|
});
|
|
188
192
|
}
|
|
189
193
|
} else {
|
|
194
|
+
var _this$ref;
|
|
195
|
+
|
|
190
196
|
// if dom isn't available, use original children
|
|
191
197
|
this.setState({
|
|
192
198
|
needsSecondRender: false,
|
|
193
199
|
isTruncated: false,
|
|
194
200
|
truncatedElement: this._text,
|
|
195
|
-
truncatedText: this.
|
|
201
|
+
truncatedText: (_this$ref = this.ref) === null || _this$ref === void 0 ? void 0 : _this$ref.textContent
|
|
196
202
|
});
|
|
197
203
|
}
|
|
198
204
|
}
|
|
@@ -239,8 +245,6 @@ let TruncateText = (_dec = withStyle(generateStyle, generateComponentTheme), _de
|
|
|
239
245
|
return jsx("span", {
|
|
240
246
|
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.truncateText,
|
|
241
247
|
ref: el => {
|
|
242
|
-
this._ref = el; // TODO remove this and keep only 'ref' in V9
|
|
243
|
-
|
|
244
248
|
this.ref = el;
|
|
245
249
|
}
|
|
246
250
|
}, children && (truncatedElement ? null : jsx("span", {
|
|
@@ -50,7 +50,7 @@ let TruncateText = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
|
|
|
50
50
|
this.ref = null;
|
|
51
51
|
|
|
52
52
|
this.update = () => {
|
|
53
|
-
if (this.
|
|
53
|
+
if (this.ref) {
|
|
54
54
|
this.setState(this.initialState);
|
|
55
55
|
}
|
|
56
56
|
};
|
|
@@ -58,6 +58,10 @@ let TruncateText = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
|
|
|
58
58
|
this.state = this.initialState;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
get _ref() {
|
|
62
|
+
return this.ref;
|
|
63
|
+
}
|
|
64
|
+
|
|
61
65
|
get initialState() {
|
|
62
66
|
return {
|
|
63
67
|
isTruncated: false,
|
|
@@ -82,7 +86,7 @@ let TruncateText = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
|
|
|
82
86
|
trailing: true
|
|
83
87
|
});
|
|
84
88
|
|
|
85
|
-
const _getBoundingClientRec = (0, _getBoundingClientRect.getBoundingClientRect)(this.
|
|
89
|
+
const _getBoundingClientRec = (0, _getBoundingClientRect.getBoundingClientRect)(this.ref),
|
|
86
90
|
origWidth = _getBoundingClientRec.width;
|
|
87
91
|
|
|
88
92
|
this._resizeListener = new ResizeObserver(entries => {
|
|
@@ -100,7 +104,7 @@ let TruncateText = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
|
|
|
100
104
|
});
|
|
101
105
|
});
|
|
102
106
|
|
|
103
|
-
this._resizeListener.observe(this.
|
|
107
|
+
this._resizeListener.observe(this.ref);
|
|
104
108
|
}
|
|
105
109
|
}
|
|
106
110
|
|
|
@@ -177,7 +181,7 @@ let TruncateText = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
|
|
|
177
181
|
var _this$props$styles;
|
|
178
182
|
|
|
179
183
|
const result = (0, _truncate.default)(this._stage, { ...this.props,
|
|
180
|
-
parent: this.
|
|
184
|
+
parent: this.ref,
|
|
181
185
|
lineHeight: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.lineHeight
|
|
182
186
|
});
|
|
183
187
|
|
|
@@ -191,12 +195,14 @@ let TruncateText = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
|
|
|
191
195
|
});
|
|
192
196
|
}
|
|
193
197
|
} else {
|
|
198
|
+
var _this$ref;
|
|
199
|
+
|
|
194
200
|
// if dom isn't available, use original children
|
|
195
201
|
this.setState({
|
|
196
202
|
needsSecondRender: false,
|
|
197
203
|
isTruncated: false,
|
|
198
204
|
truncatedElement: this._text,
|
|
199
|
-
truncatedText: this.
|
|
205
|
+
truncatedText: (_this$ref = this.ref) === null || _this$ref === void 0 ? void 0 : _this$ref.textContent
|
|
200
206
|
});
|
|
201
207
|
}
|
|
202
208
|
}
|
|
@@ -245,8 +251,6 @@ let TruncateText = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
|
|
|
245
251
|
return (0, _emotion.jsx)("span", {
|
|
246
252
|
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.truncateText,
|
|
247
253
|
ref: el => {
|
|
248
|
-
this._ref = el; // TODO remove this and keep only 'ref' in V9
|
|
249
|
-
|
|
250
254
|
this.ref = el;
|
|
251
255
|
}
|
|
252
256
|
}, children && (truncatedElement ? null : (0, _emotion.jsx)("span", {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-truncate-text",
|
|
3
|
-
"version": "8.11.2-snapshot.
|
|
3
|
+
"version": "8.11.2-snapshot.39+5b3b94d60",
|
|
4
4
|
"description": "A TruncateText component made by Instructure Inc.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -25,23 +25,23 @@
|
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@babel/runtime": "^7.13.10",
|
|
28
|
-
"@instructure/console": "8.11.2-snapshot.
|
|
29
|
-
"@instructure/debounce": "8.11.2-snapshot.
|
|
30
|
-
"@instructure/emotion": "8.11.2-snapshot.
|
|
31
|
-
"@instructure/shared-types": "8.11.2-snapshot.
|
|
32
|
-
"@instructure/ui-dom-utils": "8.11.2-snapshot.
|
|
33
|
-
"@instructure/ui-react-utils": "8.11.2-snapshot.
|
|
34
|
-
"@instructure/ui-testable": "8.11.2-snapshot.
|
|
35
|
-
"@instructure/ui-utils": "8.11.2-snapshot.
|
|
28
|
+
"@instructure/console": "8.11.2-snapshot.39+5b3b94d60",
|
|
29
|
+
"@instructure/debounce": "8.11.2-snapshot.39+5b3b94d60",
|
|
30
|
+
"@instructure/emotion": "8.11.2-snapshot.39+5b3b94d60",
|
|
31
|
+
"@instructure/shared-types": "8.11.2-snapshot.39+5b3b94d60",
|
|
32
|
+
"@instructure/ui-dom-utils": "8.11.2-snapshot.39+5b3b94d60",
|
|
33
|
+
"@instructure/ui-react-utils": "8.11.2-snapshot.39+5b3b94d60",
|
|
34
|
+
"@instructure/ui-testable": "8.11.2-snapshot.39+5b3b94d60",
|
|
35
|
+
"@instructure/ui-utils": "8.11.2-snapshot.39+5b3b94d60",
|
|
36
36
|
"escape-html": "^1",
|
|
37
37
|
"prop-types": "^15"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@instructure/ui-babel-preset": "8.11.2-snapshot.
|
|
41
|
-
"@instructure/ui-color-utils": "8.11.2-snapshot.
|
|
42
|
-
"@instructure/ui-test-utils": "8.11.2-snapshot.
|
|
43
|
-
"@instructure/ui-text": "8.11.2-snapshot.
|
|
44
|
-
"@instructure/ui-themes": "8.11.2-snapshot.
|
|
40
|
+
"@instructure/ui-babel-preset": "8.11.2-snapshot.39+5b3b94d60",
|
|
41
|
+
"@instructure/ui-color-utils": "8.11.2-snapshot.39+5b3b94d60",
|
|
42
|
+
"@instructure/ui-test-utils": "8.11.2-snapshot.39+5b3b94d60",
|
|
43
|
+
"@instructure/ui-text": "8.11.2-snapshot.39+5b3b94d60",
|
|
44
|
+
"@instructure/ui-themes": "8.11.2-snapshot.39+5b3b94d60"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": ">=16.8 <=17"
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
52
|
"sideEffects": false,
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "5b3b94d60693dc069b6ff4fde8f2ca1a72462ab7"
|
|
54
54
|
}
|
|
@@ -74,6 +74,13 @@ class TruncateText extends Component<TruncateTextProps> {
|
|
|
74
74
|
super(props)
|
|
75
75
|
this.state = this.initialState
|
|
76
76
|
}
|
|
77
|
+
get _ref() {
|
|
78
|
+
console.warn(
|
|
79
|
+
'_ref property is deprecated and will be removed in v9, please use ref instead'
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
return this.ref
|
|
83
|
+
}
|
|
77
84
|
|
|
78
85
|
get initialState() {
|
|
79
86
|
return {
|
|
@@ -103,8 +110,7 @@ class TruncateText extends Component<TruncateTextProps> {
|
|
|
103
110
|
trailing: true
|
|
104
111
|
})
|
|
105
112
|
|
|
106
|
-
|
|
107
|
-
const { width: origWidth } = getBoundingClientRect(this._ref)
|
|
113
|
+
const { width: origWidth } = getBoundingClientRect(this.ref)
|
|
108
114
|
// @ts-expect-error ts-migrate(2339) FIXME: Property '_resizeListener' does not exist on type ... Remove this comment to see the full error message
|
|
109
115
|
this._resizeListener = new ResizeObserver((entries) => {
|
|
110
116
|
// requestAnimationFrame call is needed becuase some truncatetext test cases
|
|
@@ -123,7 +129,7 @@ class TruncateText extends Component<TruncateTextProps> {
|
|
|
123
129
|
})
|
|
124
130
|
|
|
125
131
|
// @ts-expect-error ts-migrate(2339) FIXME: Property '_resizeListener' does not exist on type ... Remove this comment to see the full error message
|
|
126
|
-
this._resizeListener.observe(this.
|
|
132
|
+
this._resizeListener.observe(this.ref)
|
|
127
133
|
}
|
|
128
134
|
}
|
|
129
135
|
|
|
@@ -199,8 +205,7 @@ class TruncateText extends Component<TruncateTextProps> {
|
|
|
199
205
|
}
|
|
200
206
|
|
|
201
207
|
update = () => {
|
|
202
|
-
|
|
203
|
-
if (this._ref) {
|
|
208
|
+
if (this.ref) {
|
|
204
209
|
this.setState(this.initialState)
|
|
205
210
|
}
|
|
206
211
|
}
|
|
@@ -215,8 +220,7 @@ class TruncateText extends Component<TruncateTextProps> {
|
|
|
215
220
|
// @ts-expect-error ts-migrate(2339) FIXME: Property '_stage' does not exist on type 'Truncate... Remove this comment to see the full error message
|
|
216
221
|
const result = truncate(this._stage, {
|
|
217
222
|
...this.props,
|
|
218
|
-
|
|
219
|
-
parent: this._ref,
|
|
223
|
+
parent: this.ref,
|
|
220
224
|
lineHeight: this.props.styles?.lineHeight
|
|
221
225
|
})
|
|
222
226
|
if (result) {
|
|
@@ -239,8 +243,7 @@ class TruncateText extends Component<TruncateTextProps> {
|
|
|
239
243
|
isTruncated: false,
|
|
240
244
|
// @ts-expect-error ts-migrate(2339) FIXME: Property '_text' does not exist on type 'TruncateT... Remove this comment to see the full error message
|
|
241
245
|
truncatedElement: this._text,
|
|
242
|
-
|
|
243
|
-
truncatedText: this._ref.textContent
|
|
246
|
+
truncatedText: this.ref?.textContent
|
|
244
247
|
})
|
|
245
248
|
}
|
|
246
249
|
}
|
|
@@ -290,8 +293,6 @@ class TruncateText extends Component<TruncateTextProps> {
|
|
|
290
293
|
<span
|
|
291
294
|
css={this.props.styles?.truncateText}
|
|
292
295
|
ref={(el) => {
|
|
293
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_ref' does not exist on type 'TruncateTe... Remove this comment to see the full error message
|
|
294
|
-
this._ref = el // TODO remove this and keep only 'ref' in V9
|
|
295
296
|
this.ref = el
|
|
296
297
|
}}
|
|
297
298
|
>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/TruncateText/index.tsx"],"names":[],"mappings":"AAuBA,eAAe;AACf,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAWxC,OAAO,EAAa,GAAG,EAAE,MAAM,sBAAsB,CAAA;AAOrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD;;;;GAIG;AACH,cAGM,YAAa,SAAQ,SAAS,CAAC,iBAAiB,CAAC;IACrD,MAAM,CAAC,QAAQ,CA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