@instructure/ui-truncate-text 11.7.8 → 11.7.9-pr-snapshot-1792147648392

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/es/TruncateText/v1/index.js +195 -245
  3. package/es/TruncateText/v1/props.js +12 -26
  4. package/es/TruncateText/v1/styles.js +23 -57
  5. package/es/TruncateText/v1/theme.js +10 -41
  6. package/es/TruncateText/v1/utils/cleanData.js +98 -151
  7. package/es/TruncateText/v1/utils/cleanString.js +14 -51
  8. package/es/TruncateText/v1/utils/measureText.js +35 -69
  9. package/es/TruncateText/v1/utils/truncate.js +237 -322
  10. package/es/TruncateText/v2/index.js +191 -244
  11. package/es/TruncateText/v2/props.js +12 -26
  12. package/es/TruncateText/v2/styles.js +22 -56
  13. package/es/TruncateText/v2/utils/cleanData.js +98 -151
  14. package/es/TruncateText/v2/utils/cleanString.js +14 -51
  15. package/es/TruncateText/v2/utils/measureText.js +35 -69
  16. package/es/TruncateText/v2/utils/truncate.js +236 -321
  17. package/es/exports/a.js +1 -24
  18. package/es/exports/b.js +1 -24
  19. package/package.json +15 -21
  20. package/tsconfig.build.json +0 -1
  21. package/tsconfig.build.tsbuildinfo +1 -1
  22. package/lib/TruncateText/v1/index.js +0 -278
  23. package/lib/TruncateText/v1/props.js +0 -31
  24. package/lib/TruncateText/v1/styles.js +0 -64
  25. package/lib/TruncateText/v1/theme.js +0 -48
  26. package/lib/TruncateText/v1/utils/cleanData.js +0 -166
  27. package/lib/TruncateText/v1/utils/cleanString.js +0 -59
  28. package/lib/TruncateText/v1/utils/measureText.js +0 -79
  29. package/lib/TruncateText/v1/utils/truncate.js +0 -353
  30. package/lib/TruncateText/v2/index.js +0 -275
  31. package/lib/TruncateText/v2/props.js +0 -31
  32. package/lib/TruncateText/v2/styles.js +0 -63
  33. package/lib/TruncateText/v2/utils/cleanData.js +0 -166
  34. package/lib/TruncateText/v2/utils/cleanString.js +0 -59
  35. package/lib/TruncateText/v2/utils/measureText.js +0 -79
  36. package/lib/TruncateText/v2/utils/truncate.js +0 -353
  37. package/lib/exports/a.js +0 -12
  38. package/lib/exports/b.js +0 -12
  39. package/lib/package.json +0 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,19 @@
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
+ ## [11.7.9-pr-snapshot-1792147648392](https://github.com/instructure/instructure-ui/compare/v11.7.8...v11.7.9-pr-snapshot-1792147648392) (2026-10-16)
7
+
8
+ ### Build System
9
+
10
+ * **many:** replace babel with swc ([7e36c54](https://github.com/instructure/instructure-ui/commit/7e36c54d240b4fa483801c03ab18e7f860f561e2))
11
+
12
+ ### BREAKING CHANGES
13
+
14
+ * **many:** `@instructure/ui-babel-preset` and
15
+ `@instructure/browserslist-config-instui` are removed and will no longer be
16
+ published. Packages depend on `@swc/helpers` instead of `@babel/runtime`.
17
+
18
+
6
19
  ## [11.7.8](https://github.com/instructure/instructure-ui/compare/v11.7.7...v11.7.8) (2026-10-02)
7
20
 
8
21
  **Note:** Version bump only for package @instructure/ui-truncate-text
@@ -1,28 +1,5 @@
1
- var _dec, _class;
2
- /*
3
- * The MIT License (MIT)
4
- *
5
- * Copyright (c) 2015 - present Instructure, Inc.
6
- *
7
- * Permission is hereby granted, free of charge, to any person obtaining a copy
8
- * of this software and associated documentation files (the "Software"), to deal
9
- * in the Software without restriction, including without limitation the rights
10
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- * copies of the Software, and to permit persons to whom the Software is
12
- * furnished to do so, subject to the following conditions:
13
- *
14
- * The above copyright notice and this permission notice shall be included in all
15
- * copies or substantial portions of the Software.
16
- *
17
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- * SOFTWARE.
24
- */
25
-
1
+ import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
26
3
  import { Children, Component } from 'react';
27
4
  import { debounce } from '@instructure/debounce';
28
5
  import { canUseDOM, getBoundingClientRect } from '@instructure/ui-dom-utils';
@@ -33,239 +10,212 @@ import generateStyle from './styles.js';
33
10
  import generateComponentTheme from './theme.js';
34
11
  import truncate from './utils/truncate.js';
35
12
  import { allowedProps } from './props.js';
36
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
37
- /**
38
- ---
39
- category: components
40
- ---
41
- **/
42
- let TruncateText = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = class TruncateText extends Component {
43
- static displayName = 'TruncateText';
44
- static componentId = 'TruncateText';
45
- static allowedProps = allowedProps;
46
- static defaultProps = {
47
- maxLines: 1,
48
- ellipsis: '\u2026',
49
- truncate: 'character',
50
- position: 'end',
51
- ignore: [' ', '.', ','],
52
- debounce: 0
53
- };
54
- ref = null;
55
- _text;
56
- _debounced;
57
- _stage = null;
58
- _wasTruncated;
59
- _resizeListener;
60
- _prevWidth = null;
61
- constructor(props) {
62
- super(props);
63
- this.state = this.initialState;
64
- }
65
- get _ref() {
66
- return this.ref;
67
- }
68
- get initialState() {
69
- return {
70
- isTruncated: false,
71
- needsSecondRender: true,
72
- truncatedElement: undefined,
73
- truncatedText: undefined
74
- };
75
- }
76
- componentDidMount() {
77
- const {
78
- children,
79
- makeStyles
80
- } = this.props;
81
- makeStyles?.();
82
- if (children) {
83
- this.checkChildren();
84
- const txt = ensureSingleChild(children);
85
- this._text = txt ? txt : undefined;
86
- this.truncate();
87
- this._debounced = debounce(this.update, this.props.debounce, {
88
- leading: true,
89
- trailing: true
90
- });
91
- this._prevWidth = getBoundingClientRect(this.ref)?.width;
92
- this._resizeListener = new ResizeObserver(entries => {
93
- // requestAnimationFrame call is needed becuase some truncatetext test cases
94
- // failed due to ResizeObserver was not able to deliver all observations within a single animation frame
95
- // see: https://stackoverflow.com/questions/49384120/resizeobserver-loop-limit-exceeded
96
- requestAnimationFrame(() => {
97
- for (const entry of entries) {
98
- const {
99
- width
100
- } = entry.contentRect;
101
- if (this._prevWidth !== width) {
102
- this._prevWidth = width;
103
- this.props.debounce === 0 ? this.update() : this._debounced();
13
+ class TruncateText extends Component {
14
+ static{
15
+ this.displayName = 'TruncateText';
16
+ }
17
+ static{
18
+ this.componentId = 'TruncateText';
19
+ }
20
+ static{
21
+ this.allowedProps = allowedProps;
22
+ }
23
+ static{
24
+ this.defaultProps = {
25
+ maxLines: 1,
26
+ ellipsis: '\u2026',
27
+ truncate: 'character',
28
+ position: 'end',
29
+ ignore: [
30
+ ' ',
31
+ '.',
32
+ ','
33
+ ],
34
+ debounce: 0
35
+ };
36
+ }
37
+ constructor(props){
38
+ super(props), this.ref = null, this._stage = null, this._prevWidth = null, this.update = ()=>{
39
+ if (this.ref) {
40
+ this.setState(this.initialState);
104
41
  }
105
- }
106
- });
107
- });
108
- this._resizeListener.observe(this.ref);
42
+ };
43
+ this.state = this.initialState;
109
44
  }
110
- }
111
- componentWillUnmount() {
112
- if (this._resizeListener) {
113
- this._resizeListener.disconnect();
45
+ get _ref() {
46
+ void 0;
47
+ return this.ref;
114
48
  }
115
- if (this._debounced) {
116
- this._debounced.cancel();
49
+ get initialState() {
50
+ return {
51
+ isTruncated: false,
52
+ needsSecondRender: true,
53
+ truncatedElement: undefined,
54
+ truncatedText: undefined
55
+ };
117
56
  }
118
- }
119
- shallowCompare(obj1, obj2) {
120
- const keys1 = Object.keys(obj1);
121
- const keys2 = Object.keys(obj2);
122
- if (keys1.length !== keys2.length) {
123
- return false;
57
+ componentDidMount() {
58
+ const { children, makeStyles } = this.props;
59
+ makeStyles?.();
60
+ if (children) {
61
+ this.checkChildren();
62
+ const txt = ensureSingleChild(children);
63
+ this._text = txt ? txt : undefined;
64
+ this.truncate();
65
+ this._debounced = debounce(this.update, this.props.debounce, {
66
+ leading: true,
67
+ trailing: true
68
+ });
69
+ this._prevWidth = getBoundingClientRect(this.ref)?.width;
70
+ this._resizeListener = new ResizeObserver((entries)=>{
71
+ requestAnimationFrame(()=>{
72
+ for (const entry of entries){
73
+ const { width } = entry.contentRect;
74
+ if (this._prevWidth !== width) {
75
+ this._prevWidth = width;
76
+ this.props.debounce === 0 ? this.update() : this._debounced();
77
+ }
78
+ }
79
+ });
80
+ });
81
+ this._resizeListener.observe(this.ref);
82
+ }
124
83
  }
125
- for (const key of keys1) {
126
- if (obj1[key] !== obj2[key]) {
127
- return false;
128
- }
84
+ componentWillUnmount() {
85
+ if (this._resizeListener) {
86
+ this._resizeListener.disconnect();
87
+ }
88
+ if (this._debounced) {
89
+ this._debounced.cancel();
90
+ }
129
91
  }
130
- return true;
131
- }
132
- componentDidUpdate(prevProps) {
133
- const {
134
- children,
135
- onUpdate,
136
- makeStyles
137
- } = this.props;
138
- makeStyles?.();
139
- const {
140
- isTruncated,
141
- needsSecondRender,
142
- truncatedText
143
- } = this.state;
144
- if (children) {
145
- // for some reason in React 19 prevPros and this.props are a different
146
- // object even if their contents are the same, so we cannot use !==
147
- if (!this.shallowCompare(prevProps, this.props)) {
148
- if (prevProps.children !== this.props.children) {
149
- // reset internal text variable if children change
150
- this.checkChildren();
151
- const txt = ensureSingleChild(children);
152
- this._text = txt ? txt : undefined;
92
+ shallowCompare(obj1, obj2) {
93
+ const keys1 = Object.keys(obj1);
94
+ const keys2 = Object.keys(obj2);
95
+ if (keys1.length !== keys2.length) {
96
+ return false;
97
+ }
98
+ for (const key of keys1){
99
+ if (obj1[key] !== obj2[key]) {
100
+ return false;
101
+ }
153
102
  }
154
- // require the double render whenever props change
155
- this.setState(this.initialState);
156
- return;
157
- }
158
- if (!needsSecondRender && (isTruncated || this._wasTruncated)) {
159
- onUpdate?.(isTruncated, truncatedText);
160
- this._wasTruncated = isTruncated;
161
- } else {
162
- this.truncate();
163
- }
103
+ return true;
164
104
  }
165
- }
166
- checkChildren() {
167
- error(!(() => {
168
- let isTooDeep = false;
169
- const text = ensureSingleChild(this.props.children);
170
- Children.forEach(text.props.children, child => {
171
- if (child.props) {
172
- Children.forEach(child.props.children, grandChild => {
173
- // currently we don't support node trees deeper than 2 levels
174
- // truncation will still occur on their text content, but their actual node structure will be lost
175
- if (grandChild.props) {
176
- isTooDeep = true;
105
+ componentDidUpdate(prevProps) {
106
+ const { children, onUpdate, makeStyles } = this.props;
107
+ makeStyles?.();
108
+ const { isTruncated, needsSecondRender, truncatedText } = this.state;
109
+ if (children) {
110
+ if (!this.shallowCompare(prevProps, this.props)) {
111
+ if (prevProps.children !== this.props.children) {
112
+ this.checkChildren();
113
+ const txt = ensureSingleChild(children);
114
+ this._text = txt ? txt : undefined;
115
+ }
116
+ this.setState(this.initialState);
117
+ return;
118
+ }
119
+ if (!needsSecondRender && (isTruncated || this._wasTruncated)) {
120
+ onUpdate?.(isTruncated, truncatedText);
121
+ this._wasTruncated = isTruncated;
122
+ } else {
123
+ this.truncate();
177
124
  }
178
- });
179
125
  }
180
- });
181
- return isTooDeep;
182
- })(), `[TruncateText] Some children are too deep in the node tree and will not render.`);
183
- }
184
- update = () => {
185
- if (this.ref) {
186
- this.setState(this.initialState);
187
126
  }
188
- };
189
- truncate() {
190
- if (!this.state.needsSecondRender) {
191
- return;
127
+ checkChildren() {
128
+ error(!(()=>{
129
+ let isTooDeep = false;
130
+ const text = ensureSingleChild(this.props.children);
131
+ Children.forEach(text.props.children, (child)=>{
132
+ if (child.props) {
133
+ Children.forEach(child.props.children, (grandChild)=>{
134
+ if (grandChild.props) {
135
+ isTooDeep = true;
136
+ }
137
+ });
138
+ }
139
+ });
140
+ return isTooDeep;
141
+ })(), `[TruncateText] Some children are too deep in the node tree and will not render.`);
192
142
  }
193
- if (canUseDOM) {
194
- const result = truncate(this._stage, {
195
- ...this.props,
196
- parent: this.ref ? this.ref : undefined,
197
- lineHeight: this.props.styles?.lineHeight
198
- });
199
- if (result) {
200
- const element = this.renderChildren(result.isTruncated, result.data, result.constraints.width);
201
- this.setState({
202
- needsSecondRender: false,
203
- isTruncated: result.isTruncated,
204
- truncatedElement: element,
205
- truncatedText: result.text
206
- });
207
- }
208
- } else {
209
- const textContent = this.ref?.textContent ? this.ref?.textContent : undefined;
210
- // if dom isn't available, use original children
211
- this.setState({
212
- needsSecondRender: false,
213
- isTruncated: false,
214
- truncatedElement: this._text,
215
- truncatedText: textContent
216
- });
143
+ truncate() {
144
+ if (!this.state.needsSecondRender) {
145
+ return;
146
+ }
147
+ if (canUseDOM) {
148
+ const result = truncate(this._stage, {
149
+ ...this.props,
150
+ parent: this.ref ? this.ref : undefined,
151
+ lineHeight: this.props.styles?.lineHeight
152
+ });
153
+ if (result) {
154
+ const element = this.renderChildren(result.isTruncated, result.data, result.constraints.width);
155
+ this.setState({
156
+ needsSecondRender: false,
157
+ isTruncated: result.isTruncated,
158
+ truncatedElement: element,
159
+ truncatedText: result.text
160
+ });
161
+ }
162
+ } else {
163
+ const textContent = this.ref?.textContent ? this.ref?.textContent : undefined;
164
+ this.setState({
165
+ needsSecondRender: false,
166
+ isTruncated: false,
167
+ truncatedElement: this._text,
168
+ truncatedText: textContent
169
+ });
170
+ }
217
171
  }
218
- }
219
- renderChildren(truncated, data, width) {
220
- if (!truncated) {
221
- return this._text;
172
+ renderChildren(truncated, data, width) {
173
+ if (!truncated) {
174
+ return this._text;
175
+ }
176
+ const childElements = [];
177
+ for(let i = 0; i < data.length; i++){
178
+ const item = data[i];
179
+ const element = this._text.props.children[i];
180
+ const nodeText = item.join('');
181
+ if (element && element.props) {
182
+ childElements.push(safeCloneElement(element, element.props, nodeText));
183
+ } else {
184
+ childElements.push(nodeText);
185
+ }
186
+ }
187
+ childElements.push(/*#__PURE__*/ _jsx("span", {
188
+ css: this.props.styles?.spacer,
189
+ style: {
190
+ width: width || undefined
191
+ }
192
+ }, "spacer"));
193
+ const children = Children.map(childElements, (child)=>child);
194
+ return this._text.props ? safeCloneElement(this._text, this._text.props, children) : children;
222
195
  }
223
- const childElements = [];
224
- // iterate over each node used in the truncated string
225
- for (let i = 0; i < data.length; i++) {
226
- const item = data[i];
227
- const element = this._text.props.children[i];
228
- const nodeText = item.join('');
229
- if (element && element.props) {
230
- // if node is an html element and not just a string
231
- childElements.push(safeCloneElement(element, element.props, nodeText));
232
- } else {
233
- childElements.push(nodeText);
234
- }
196
+ render() {
197
+ const { truncatedElement } = this.state;
198
+ const { children } = this.props;
199
+ return /*#__PURE__*/ _jsxs("span", {
200
+ "data-cid": "TruncateText",
201
+ css: this.props.styles?.truncateText,
202
+ ref: (el)=>{
203
+ this.ref = el;
204
+ },
205
+ children: [
206
+ children && (truncatedElement ? null : /*#__PURE__*/ _jsx("span", {
207
+ ref: (el)=>{
208
+ this._stage = el;
209
+ },
210
+ children: ensureSingleChild(children)
211
+ })),
212
+ truncatedElement
213
+ ]
214
+ });
235
215
  }
236
- // this spacer element is set to the max width the full text could
237
- // potentially be without this, text in `width: auto` elements won't expand
238
- // to accommodate more text, once truncated
239
- childElements.push(_jsx("span", {
240
- css: this.props.styles?.spacer,
241
- style: {
242
- width: width || undefined
243
- }
244
- }, "spacer"));
245
- const children = Children.map(childElements, child => child);
246
- return this._text.props ? safeCloneElement(this._text, this._text.props, children) : children;
247
- }
248
- render() {
249
- const {
250
- truncatedElement
251
- } = this.state;
252
- const {
253
- children
254
- } = this.props;
255
- return _jsxs("span", {
256
- "data-cid": "TruncateText",
257
- css: this.props.styles?.truncateText,
258
- ref: el => {
259
- this.ref = el;
260
- },
261
- children: [children && (truncatedElement ? null : _jsx("span", {
262
- ref: el => {
263
- this._stage = el;
264
- },
265
- children: ensureSingleChild(children)
266
- })), truncatedElement]
267
- });
268
- }
269
- }) || _class);
216
+ }
217
+ TruncateText = _ts_decorate([
218
+ withStyle(generateStyle, generateComponentTheme)
219
+ ], TruncateText);
270
220
  export default TruncateText;
271
- export { TruncateText };
221
+ export { TruncateText };
@@ -1,26 +1,12 @@
1
- /*
2
- * The MIT License (MIT)
3
- *
4
- * Copyright (c) 2015 - present Instructure, Inc.
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
-
25
- const allowedProps = ['children', 'maxLines', 'position', 'truncate', 'ellipsis', 'ignore', 'debounce', 'onUpdate', 'shouldTruncateWhenInvisible'];
26
- export { allowedProps };
1
+ const allowedProps = [
2
+ 'children',
3
+ 'maxLines',
4
+ 'position',
5
+ 'truncate',
6
+ 'ellipsis',
7
+ 'ignore',
8
+ 'debounce',
9
+ 'onUpdate',
10
+ 'shouldTruncateWhenInvisible'
11
+ ];
12
+ export { allowedProps };
@@ -1,58 +1,24 @@
1
- /*
2
- * The MIT License (MIT)
3
- *
4
- * Copyright (c) 2015 - present Instructure, Inc.
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
-
25
- /**
26
- * ---
27
- * private: true
28
- * ---
29
- * Generates the style object from the theme and provided additional information
30
- * @param {Object} componentTheme The theme variable object.
31
- * @param {Object} props the props of the component, the style is applied to
32
- * @param {Object} state the state of the component, the style is applied to
33
- * @return {Object} The final style object, which will be used in the component
34
- */
35
- const generateStyle = componentTheme => {
36
- return {
37
- truncateText: {
38
- label: 'truncateText',
39
- display: 'block',
40
- overflow: 'hidden',
41
- wordWrap: 'break-word',
42
- whiteSpace: 'normal',
43
- fontFamily: componentTheme.fontFamily
44
- },
45
- auto: {
46
- label: 'truncateText__auto',
47
- height: '100%'
48
- },
49
- spacer: {
50
- label: 'truncateText__spacer',
51
- visibility: 'hidden',
52
- maxHeight: '0',
53
- display: 'block'
54
- },
55
- lineHeight: componentTheme.lineHeight
56
- };
1
+ const generateStyle = (componentTheme)=>{
2
+ return {
3
+ truncateText: {
4
+ label: 'truncateText',
5
+ display: 'block',
6
+ overflow: 'hidden',
7
+ wordWrap: 'break-word',
8
+ whiteSpace: 'normal',
9
+ fontFamily: componentTheme.fontFamily
10
+ },
11
+ auto: {
12
+ label: 'truncateText__auto',
13
+ height: '100%'
14
+ },
15
+ spacer: {
16
+ label: 'truncateText__spacer',
17
+ visibility: 'hidden',
18
+ maxHeight: '0',
19
+ display: 'block'
20
+ },
21
+ lineHeight: componentTheme.lineHeight
22
+ };
57
23
  };
58
- export default generateStyle;
24
+ export default generateStyle;
@@ -1,42 +1,11 @@
1
- /*
2
- * The MIT License (MIT)
3
- *
4
- * Copyright (c) 2015 - present Instructure, Inc.
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
-
25
- /**
26
- * Generates the theme object for the component from the theme and provided additional information
27
- * @param {Object} theme The actual theme object.
28
- * @return {Object} The final theme object with the overrides and component variables
29
- */
30
- const generateComponentTheme = theme => {
31
- const {
32
- typography
33
- } = theme;
34
- const componentVariables = {
35
- fontFamily: typography?.fontFamily,
36
- lineHeight: typography?.lineHeight
37
- };
38
- return {
39
- ...componentVariables
40
- };
1
+ const generateComponentTheme = (theme)=>{
2
+ const { typography } = theme;
3
+ const componentVariables = {
4
+ fontFamily: typography?.fontFamily,
5
+ lineHeight: typography?.lineHeight
6
+ };
7
+ return {
8
+ ...componentVariables
9
+ };
41
10
  };
42
- export default generateComponentTheme;
11
+ export default generateComponentTheme;