@instructure/ui-truncate-text 8.11.2-snapshot.7 → 8.12.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/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [8.12.0](https://github.com/instructure/instructure-ui/compare/v8.11.1...v8.12.0) (2021-11-17)
7
+
8
+ **Note:** Version bump only for package @instructure/ui-truncate-text
9
+
6
10
  ## [8.11.1](https://github.com/instructure/instructure-ui/compare/v8.11.0...v8.11.1) (2021-10-19)
7
11
 
8
12
  **Note:** Version bump only for package @instructure/ui-truncate-text
@@ -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._ref) {
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._ref),
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._ref);
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._ref,
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._ref.textContent
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", {
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -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._ref) {
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._ref),
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._ref);
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._ref,
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._ref.textContent
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.7+2681e145a",
3
+ "version": "8.12.0",
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.7+2681e145a",
29
- "@instructure/debounce": "8.11.2-snapshot.7+2681e145a",
30
- "@instructure/emotion": "8.11.2-snapshot.7+2681e145a",
31
- "@instructure/shared-types": "8.11.2-snapshot.7+2681e145a",
32
- "@instructure/ui-dom-utils": "8.11.2-snapshot.7+2681e145a",
33
- "@instructure/ui-react-utils": "8.11.2-snapshot.7+2681e145a",
34
- "@instructure/ui-testable": "8.11.2-snapshot.7+2681e145a",
35
- "@instructure/ui-utils": "8.11.2-snapshot.7+2681e145a",
28
+ "@instructure/console": "8.12.0",
29
+ "@instructure/debounce": "8.12.0",
30
+ "@instructure/emotion": "8.12.0",
31
+ "@instructure/shared-types": "8.12.0",
32
+ "@instructure/ui-dom-utils": "8.12.0",
33
+ "@instructure/ui-react-utils": "8.12.0",
34
+ "@instructure/ui-testable": "8.12.0",
35
+ "@instructure/ui-utils": "8.12.0",
36
36
  "escape-html": "^1",
37
37
  "prop-types": "^15"
38
38
  },
39
39
  "devDependencies": {
40
- "@instructure/ui-babel-preset": "8.11.2-snapshot.7+2681e145a",
41
- "@instructure/ui-color-utils": "8.11.2-snapshot.7+2681e145a",
42
- "@instructure/ui-test-utils": "8.11.2-snapshot.7+2681e145a",
43
- "@instructure/ui-text": "8.11.2-snapshot.7+2681e145a",
44
- "@instructure/ui-themes": "8.11.2-snapshot.7+2681e145a"
40
+ "@instructure/ui-babel-preset": "8.12.0",
41
+ "@instructure/ui-color-utils": "8.12.0",
42
+ "@instructure/ui-test-utils": "8.12.0",
43
+ "@instructure/ui-text": "8.12.0",
44
+ "@instructure/ui-themes": "8.12.0"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "react": ">=16.8 <=17"
@@ -49,6 +49,5 @@
49
49
  "publishConfig": {
50
50
  "access": "public"
51
51
  },
52
- "sideEffects": false,
53
- "gitHead": "2681e145ad469e1396536d3e9eed75a19995eb8a"
52
+ "sideEffects": false
54
53
  }
@@ -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
- // @ts-expect-error ts-migrate(2339) FIXME: Property 'width' does not exist on type '{}'.
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._ref)
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
- // @ts-expect-error ts-migrate(2339) FIXME: Property '_ref' does not exist on type 'TruncateTe... Remove this comment to see the full error message
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
- // @ts-expect-error ts-migrate(2339) FIXME: Property '_ref' does not exist on type 'TruncateTe... Remove this comment to see the full error message
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
- // @ts-expect-error ts-migrate(2339) FIXME: Property '_ref' does not exist on type 'TruncateTe... Remove this comment to see the full error message
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
  >
@@ -42,6 +42,7 @@ declare class TruncateText extends Component<TruncateTextProps> {
42
42
  };
43
43
  ref: Element | null;
44
44
  constructor(props: any);
45
+ get _ref(): Element | null;
45
46
  get initialState(): {
46
47
  isTruncated: boolean;
47
48
  needsSecondRender: boolean;
@@ -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,sBAA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IAED,IAAI,YAAY;;;;;MAOf;IAED,iBAAiB;IA0CjB,oBAAoB;IAepB,kBAAkB,CAAC,SAAS,KAAA;IAkC5B,aAAa;IAsBb,MAAM,aAIL;IAED,QAAQ;IAuCR,cAAc,CAAC,SAAS,KAAA,EAAE,IAAI,KAAA,EAAE,KAAK,KAAA;IAmCrC,MAAM;CA2BP;AAED,eAAe,YAAY,CAAA;AAC3B,OAAO,EAAE,YAAY,EAAE,CAAA"}
package/LICENSE.md DELETED
@@ -1,27 +0,0 @@
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.