@instructure/ui-truncate-text 10.0.1-snapshot-9 → 10.0.1-snapshot-11
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 +1 -1
- package/package.json +14 -14
- package/src/TruncateText/README.md +63 -32
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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
|
-
## [10.0.1-snapshot-
|
|
6
|
+
## [10.0.1-snapshot-11](https://github.com/instructure/instructure-ui/compare/v10.0.0...v10.0.1-snapshot-11) (2024-08-14)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-truncate-text
|
|
9
9
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-truncate-text",
|
|
3
|
-
"version": "10.0.1-snapshot-
|
|
3
|
+
"version": "10.0.1-snapshot-11",
|
|
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.24.5",
|
|
27
|
-
"@instructure/console": "10.0.1-snapshot-
|
|
28
|
-
"@instructure/debounce": "10.0.1-snapshot-
|
|
29
|
-
"@instructure/emotion": "10.0.1-snapshot-
|
|
30
|
-
"@instructure/shared-types": "10.0.1-snapshot-
|
|
31
|
-
"@instructure/ui-dom-utils": "10.0.1-snapshot-
|
|
32
|
-
"@instructure/ui-react-utils": "10.0.1-snapshot-
|
|
33
|
-
"@instructure/ui-testable": "10.0.1-snapshot-
|
|
34
|
-
"@instructure/ui-utils": "10.0.1-snapshot-
|
|
27
|
+
"@instructure/console": "10.0.1-snapshot-11",
|
|
28
|
+
"@instructure/debounce": "10.0.1-snapshot-11",
|
|
29
|
+
"@instructure/emotion": "10.0.1-snapshot-11",
|
|
30
|
+
"@instructure/shared-types": "10.0.1-snapshot-11",
|
|
31
|
+
"@instructure/ui-dom-utils": "10.0.1-snapshot-11",
|
|
32
|
+
"@instructure/ui-react-utils": "10.0.1-snapshot-11",
|
|
33
|
+
"@instructure/ui-testable": "10.0.1-snapshot-11",
|
|
34
|
+
"@instructure/ui-utils": "10.0.1-snapshot-11",
|
|
35
35
|
"escape-html": "^1.0.3",
|
|
36
36
|
"prop-types": "^15.8.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@instructure/ui-babel-preset": "10.0.1-snapshot-
|
|
40
|
-
"@instructure/ui-color-utils": "10.0.1-snapshot-
|
|
41
|
-
"@instructure/ui-test-utils": "10.0.1-snapshot-
|
|
42
|
-
"@instructure/ui-text": "10.0.1-snapshot-
|
|
43
|
-
"@instructure/ui-themes": "10.0.1-snapshot-
|
|
39
|
+
"@instructure/ui-babel-preset": "10.0.1-snapshot-11",
|
|
40
|
+
"@instructure/ui-color-utils": "10.0.1-snapshot-11",
|
|
41
|
+
"@instructure/ui-test-utils": "10.0.1-snapshot-11",
|
|
42
|
+
"@instructure/ui-text": "10.0.1-snapshot-11",
|
|
43
|
+
"@instructure/ui-themes": "10.0.1-snapshot-11",
|
|
44
44
|
"@types/escape-html": "^1.0.4"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
@@ -169,54 +169,85 @@ type: example
|
|
|
169
169
|
|
|
170
170
|
It's best practice to make the complete text of a truncated element available via a [Tooltip](#Tooltip).
|
|
171
171
|
|
|
172
|
-
```js
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
isTruncated
|
|
179
|
-
|
|
172
|
+
- ```js
|
|
173
|
+
class Example extends React.Component {
|
|
174
|
+
state = {
|
|
175
|
+
isTruncated: false
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
handleUpdate = (isTruncated) => {
|
|
179
|
+
if (this.state.isTruncated !== isTruncated) {
|
|
180
|
+
this.setState({ isTruncated })
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
renderLink() {
|
|
185
|
+
return (
|
|
186
|
+
<Link href="#">
|
|
187
|
+
<TruncateText onUpdate={this.handleUpdate}>
|
|
188
|
+
{this.props.message}
|
|
189
|
+
</TruncateText>
|
|
190
|
+
</Link>
|
|
191
|
+
)
|
|
192
|
+
}
|
|
180
193
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
194
|
+
render() {
|
|
195
|
+
return (
|
|
196
|
+
<View as="div" padding="xx-small none" maxWidth="230px" withVisualDebug>
|
|
197
|
+
{this.state.isTruncated ? (
|
|
198
|
+
<Tooltip
|
|
199
|
+
renderTip={this.props.message}
|
|
200
|
+
mountNode={() => document.getElementById('main')}
|
|
201
|
+
>
|
|
202
|
+
{this.renderLink()}
|
|
203
|
+
</Tooltip>
|
|
204
|
+
) : (
|
|
205
|
+
this.renderLink()
|
|
206
|
+
)}
|
|
207
|
+
</View>
|
|
208
|
+
)
|
|
184
209
|
}
|
|
185
210
|
}
|
|
211
|
+
render(
|
|
212
|
+
<Example message="A tooltip will display only when this text is truncated" />
|
|
213
|
+
)
|
|
214
|
+
```
|
|
186
215
|
|
|
187
|
-
|
|
188
|
-
|
|
216
|
+
- ```js
|
|
217
|
+
const Example = (props) => {
|
|
218
|
+
const [isTruncated, setIsTruncated] = useState(false)
|
|
219
|
+
|
|
220
|
+
const handleUpdate = (newIsTruncated) => {
|
|
221
|
+
if (isTruncated !== newIsTruncated) {
|
|
222
|
+
setIsTruncated(newIsTruncated)
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const renderLink = () => (
|
|
189
227
|
<Link href="#">
|
|
190
|
-
<TruncateText onUpdate={
|
|
191
|
-
{this.props.message}
|
|
192
|
-
</TruncateText>
|
|
228
|
+
<TruncateText onUpdate={handleUpdate}>{props.message}</TruncateText>
|
|
193
229
|
</Link>
|
|
194
230
|
)
|
|
195
|
-
}
|
|
196
231
|
|
|
197
|
-
render () {
|
|
198
232
|
return (
|
|
199
|
-
<View
|
|
200
|
-
|
|
201
|
-
padding="xx-small none"
|
|
202
|
-
maxWidth="230px"
|
|
203
|
-
withVisualDebug
|
|
204
|
-
>
|
|
205
|
-
{this.state.isTruncated ? (
|
|
233
|
+
<View as="div" padding="xx-small none" maxWidth="230px" withVisualDebug>
|
|
234
|
+
{isTruncated ? (
|
|
206
235
|
<Tooltip
|
|
207
|
-
renderTip={
|
|
236
|
+
renderTip={props.message}
|
|
208
237
|
mountNode={() => document.getElementById('main')}
|
|
209
238
|
>
|
|
210
|
-
{
|
|
239
|
+
{renderLink()}
|
|
211
240
|
</Tooltip>
|
|
212
|
-
) :
|
|
241
|
+
) : (
|
|
242
|
+
renderLink()
|
|
243
|
+
)}
|
|
213
244
|
</View>
|
|
214
245
|
)
|
|
215
246
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
```
|
|
247
|
+
render(
|
|
248
|
+
<Example message="A tooltip will display only when this text is truncated" />
|
|
249
|
+
)
|
|
250
|
+
```
|
|
220
251
|
|
|
221
252
|
### Guidelines
|
|
222
253
|
|