@instructure/ui-truncate-text 8.18.0 → 8.18.1-snapshot.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.
package/LICENSE.md ADDED
@@ -0,0 +1,27 @@
1
+ ---
2
+ title: The MIT License (MIT)
3
+ category: Getting Started
4
+ order: 9
5
+ ---
6
+
7
+ # The MIT License (MIT)
8
+
9
+ Copyright (c) 2015 Instructure, Inc.
10
+
11
+ **Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions.**
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
@@ -79,7 +79,7 @@ let TruncateText = (_dec = withStyle(generateStyle, generateComponentTheme), _de
79
79
  const _this$props = this.props,
80
80
  children = _this$props.children,
81
81
  makeStyles = _this$props.makeStyles;
82
- makeStyles?.();
82
+ makeStyles === null || makeStyles === void 0 ? void 0 : makeStyles();
83
83
 
84
84
  if (children) {
85
85
  this.checkChildren();
@@ -128,7 +128,7 @@ let TruncateText = (_dec = withStyle(generateStyle, generateComponentTheme), _de
128
128
  children = _this$props2.children,
129
129
  onUpdate = _this$props2.onUpdate,
130
130
  makeStyles = _this$props2.makeStyles;
131
- makeStyles?.();
131
+ makeStyles === null || makeStyles === void 0 ? void 0 : makeStyles();
132
132
  const _this$state = this.state,
133
133
  isTruncated = _this$state.isTruncated,
134
134
  needsSecondRender = _this$state.needsSecondRender,
@@ -149,7 +149,7 @@ let TruncateText = (_dec = withStyle(generateStyle, generateComponentTheme), _de
149
149
  }
150
150
 
151
151
  if (!needsSecondRender && (isTruncated || this._wasTruncated)) {
152
- onUpdate?.(isTruncated, truncatedText);
152
+ onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(isTruncated, truncatedText);
153
153
  this._wasTruncated = isTruncated;
154
154
  } else {
155
155
  this.truncate();
@@ -182,9 +182,11 @@ let TruncateText = (_dec = withStyle(generateStyle, generateComponentTheme), _de
182
182
  }
183
183
 
184
184
  if (canUseDOM) {
185
+ var _this$props$styles;
186
+
185
187
  const result = truncate(this._stage, { ...this.props,
186
188
  parent: this.ref ? this.ref : void 0,
187
- lineHeight: this.props.styles?.lineHeight
189
+ lineHeight: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.lineHeight
188
190
  });
189
191
 
190
192
  if (result) {
@@ -197,7 +199,9 @@ let TruncateText = (_dec = withStyle(generateStyle, generateComponentTheme), _de
197
199
  });
198
200
  }
199
201
  } else {
200
- const textContent = this.ref?.textContent ? this.ref?.textContent : void 0; // if dom isn't available, use original children
202
+ var _this$ref, _this$ref2;
203
+
204
+ const textContent = (_this$ref = this.ref) !== null && _this$ref !== void 0 && _this$ref.textContent ? (_this$ref2 = this.ref) === null || _this$ref2 === void 0 ? void 0 : _this$ref2.textContent : void 0; // if dom isn't available, use original children
201
205
 
202
206
  this.setState({
203
207
  needsSecondRender: false,
@@ -209,6 +213,8 @@ let TruncateText = (_dec = withStyle(generateStyle, generateComponentTheme), _de
209
213
  }
210
214
 
211
215
  renderChildren(truncated, data, width) {
216
+ var _this$props$styles2;
217
+
212
218
  if (!truncated) {
213
219
  return this._text;
214
220
  }
@@ -232,7 +238,7 @@ let TruncateText = (_dec = withStyle(generateStyle, generateComponentTheme), _de
232
238
 
233
239
 
234
240
  childElements.push(jsx("span", {
235
- css: this.props.styles?.spacer,
241
+ css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.spacer,
236
242
  style: {
237
243
  width: width || void 0
238
244
  }
@@ -242,10 +248,12 @@ let TruncateText = (_dec = withStyle(generateStyle, generateComponentTheme), _de
242
248
  }
243
249
 
244
250
  render() {
251
+ var _this$props$styles3;
252
+
245
253
  const truncatedElement = this.state.truncatedElement;
246
254
  const children = this.props.children;
247
255
  return jsx("span", {
248
- css: this.props.styles?.truncateText,
256
+ css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.truncateText,
249
257
  ref: el => {
250
258
  this.ref = el;
251
259
  }
@@ -30,8 +30,8 @@
30
30
  const generateComponentTheme = theme => {
31
31
  const typography = theme.typography;
32
32
  const componentVariables = {
33
- fontFamily: typography?.fontFamily,
34
- lineHeight: typography?.lineHeight
33
+ fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
34
+ lineHeight: typography === null || typography === void 0 ? void 0 : typography.lineHeight
35
35
  };
36
36
  return { ...componentVariables
37
37
  };
@@ -69,7 +69,7 @@ class Truncator {
69
69
  this._maxHeight = void 0;
70
70
  this._maxWidth = void 0;
71
71
  this._maxLines = void 0;
72
- const parentElement = element?.parentElement ? element?.parentElement : void 0;
72
+ const parentElement = element !== null && element !== void 0 && element.parentElement ? element === null || element === void 0 ? void 0 : element.parentElement : void 0;
73
73
  this._options = {
74
74
  parent: options.parent || parentElement,
75
75
  maxLines: options.maxLines || 1,
@@ -81,7 +81,7 @@ let TruncateText = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
81
81
  const _this$props = this.props,
82
82
  children = _this$props.children,
83
83
  makeStyles = _this$props.makeStyles;
84
- makeStyles?.();
84
+ makeStyles === null || makeStyles === void 0 ? void 0 : makeStyles();
85
85
 
86
86
  if (children) {
87
87
  this.checkChildren();
@@ -130,7 +130,7 @@ let TruncateText = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
130
130
  children = _this$props2.children,
131
131
  onUpdate = _this$props2.onUpdate,
132
132
  makeStyles = _this$props2.makeStyles;
133
- makeStyles?.();
133
+ makeStyles === null || makeStyles === void 0 ? void 0 : makeStyles();
134
134
  const _this$state = this.state,
135
135
  isTruncated = _this$state.isTruncated,
136
136
  needsSecondRender = _this$state.needsSecondRender,
@@ -151,7 +151,7 @@ let TruncateText = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
151
151
  }
152
152
 
153
153
  if (!needsSecondRender && (isTruncated || this._wasTruncated)) {
154
- onUpdate?.(isTruncated, truncatedText);
154
+ onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(isTruncated, truncatedText);
155
155
  this._wasTruncated = isTruncated;
156
156
  } else {
157
157
  this.truncate();
@@ -186,9 +186,11 @@ let TruncateText = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
186
186
  }
187
187
 
188
188
  if (_canUseDOM.canUseDOM) {
189
+ var _this$props$styles;
190
+
189
191
  const result = (0, _truncate.default)(this._stage, { ...this.props,
190
192
  parent: this.ref ? this.ref : void 0,
191
- lineHeight: this.props.styles?.lineHeight
193
+ lineHeight: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.lineHeight
192
194
  });
193
195
 
194
196
  if (result) {
@@ -201,7 +203,9 @@ let TruncateText = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
201
203
  });
202
204
  }
203
205
  } else {
204
- const textContent = this.ref?.textContent ? this.ref?.textContent : void 0; // if dom isn't available, use original children
206
+ var _this$ref, _this$ref2;
207
+
208
+ const textContent = (_this$ref = this.ref) !== null && _this$ref !== void 0 && _this$ref.textContent ? (_this$ref2 = this.ref) === null || _this$ref2 === void 0 ? void 0 : _this$ref2.textContent : void 0; // if dom isn't available, use original children
205
209
 
206
210
  this.setState({
207
211
  needsSecondRender: false,
@@ -213,6 +217,8 @@ let TruncateText = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
213
217
  }
214
218
 
215
219
  renderChildren(truncated, data, width) {
220
+ var _this$props$styles2;
221
+
216
222
  if (!truncated) {
217
223
  return this._text;
218
224
  }
@@ -236,7 +242,7 @@ let TruncateText = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
236
242
 
237
243
 
238
244
  childElements.push((0, _emotion.jsx)("span", {
239
- css: this.props.styles?.spacer,
245
+ css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.spacer,
240
246
  style: {
241
247
  width: width || void 0
242
248
  }
@@ -248,10 +254,12 @@ let TruncateText = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
248
254
  }
249
255
 
250
256
  render() {
257
+ var _this$props$styles3;
258
+
251
259
  const truncatedElement = this.state.truncatedElement;
252
260
  const children = this.props.children;
253
261
  return (0, _emotion.jsx)("span", {
254
- css: this.props.styles?.truncateText,
262
+ css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.truncateText,
255
263
  ref: el => {
256
264
  this.ref = el;
257
265
  }
@@ -37,8 +37,8 @@ exports.default = void 0;
37
37
  const generateComponentTheme = theme => {
38
38
  const typography = theme.typography;
39
39
  const componentVariables = {
40
- fontFamily: typography?.fontFamily,
41
- lineHeight: typography?.lineHeight
40
+ fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
41
+ lineHeight: typography === null || typography === void 0 ? void 0 : typography.lineHeight
42
42
  };
43
43
  return { ...componentVariables
44
44
  };
@@ -89,7 +89,7 @@ class Truncator {
89
89
  this._maxHeight = void 0;
90
90
  this._maxWidth = void 0;
91
91
  this._maxLines = void 0;
92
- const parentElement = element?.parentElement ? element?.parentElement : void 0;
92
+ const parentElement = element !== null && element !== void 0 && element.parentElement ? element === null || element === void 0 ? void 0 : element.parentElement : void 0;
93
93
  this._options = {
94
94
  parent: options.parent || parentElement,
95
95
  maxLines: options.maxLines || 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-truncate-text",
3
- "version": "8.18.0",
3
+ "version": "8.18.1-snapshot.2+ca4c1ff9d",
4
4
  "description": "A TruncateText component made by Instructure Inc.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -24,23 +24,23 @@
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
26
  "@babel/runtime": "^7.13.10",
27
- "@instructure/console": "8.18.0",
28
- "@instructure/debounce": "8.18.0",
29
- "@instructure/emotion": "8.18.0",
30
- "@instructure/shared-types": "8.18.0",
31
- "@instructure/ui-dom-utils": "8.18.0",
32
- "@instructure/ui-react-utils": "8.18.0",
33
- "@instructure/ui-testable": "8.18.0",
34
- "@instructure/ui-utils": "8.18.0",
27
+ "@instructure/console": "8.18.1-snapshot.2+ca4c1ff9d",
28
+ "@instructure/debounce": "8.18.1-snapshot.2+ca4c1ff9d",
29
+ "@instructure/emotion": "8.18.1-snapshot.2+ca4c1ff9d",
30
+ "@instructure/shared-types": "8.18.1-snapshot.2+ca4c1ff9d",
31
+ "@instructure/ui-dom-utils": "8.18.1-snapshot.2+ca4c1ff9d",
32
+ "@instructure/ui-react-utils": "8.18.1-snapshot.2+ca4c1ff9d",
33
+ "@instructure/ui-testable": "8.18.1-snapshot.2+ca4c1ff9d",
34
+ "@instructure/ui-utils": "8.18.1-snapshot.2+ca4c1ff9d",
35
35
  "escape-html": "^1",
36
36
  "prop-types": "^15"
37
37
  },
38
38
  "devDependencies": {
39
- "@instructure/ui-babel-preset": "8.18.0",
40
- "@instructure/ui-color-utils": "8.18.0",
41
- "@instructure/ui-test-utils": "8.18.0",
42
- "@instructure/ui-text": "8.18.0",
43
- "@instructure/ui-themes": "8.18.0",
39
+ "@instructure/ui-babel-preset": "8.18.1-snapshot.2+ca4c1ff9d",
40
+ "@instructure/ui-color-utils": "8.18.1-snapshot.2+ca4c1ff9d",
41
+ "@instructure/ui-test-utils": "8.18.1-snapshot.2+ca4c1ff9d",
42
+ "@instructure/ui-text": "8.18.1-snapshot.2+ca4c1ff9d",
43
+ "@instructure/ui-themes": "8.18.1-snapshot.2+ca4c1ff9d",
44
44
  "@types/escape-html": "^1"
45
45
  },
46
46
  "peerDependencies": {
@@ -49,5 +49,6 @@
49
49
  "publishConfig": {
50
50
  "access": "public"
51
51
  },
52
- "sideEffects": false
52
+ "sideEffects": false,
53
+ "gitHead": "ca4c1ff9d3985151ae0758fb596de41652dbb58b"
53
54
  }