@trackunit/react-components 1.0.8 → 1.0.10
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/index.cjs.js +13 -11
- package/index.esm.js +13 -11
- package/package.json +2 -2
- package/src/hooks/useIsTextCutOff.d.ts +3 -2
- package/src/hooks/useIsTextWrapping.d.ts +3 -2
package/index.cjs.js
CHANGED
|
@@ -290,18 +290,19 @@ const PackageNameStoryComponent = ({ packageJSON }) => {
|
|
|
290
290
|
/**
|
|
291
291
|
* Hook to detect if text content is wrapping to multiple lines
|
|
292
292
|
*
|
|
293
|
-
* @param {HTMLElement
|
|
293
|
+
* @param {RefObject<HTMLElement>} ref - The ref to the element to check for text wrapping
|
|
294
294
|
* @returns {boolean} True if the text spans multiple lines
|
|
295
295
|
*/
|
|
296
|
-
const useIsTextWrapping = (
|
|
296
|
+
const useIsTextWrapping = (ref) => {
|
|
297
|
+
var _a, _b;
|
|
297
298
|
const [isWrapping, setIsWrapping] = React.useState(false);
|
|
298
299
|
React.useEffect(() => {
|
|
299
|
-
if (!
|
|
300
|
+
if (!ref.current) {
|
|
300
301
|
setIsWrapping(false);
|
|
301
302
|
return;
|
|
302
303
|
}
|
|
303
|
-
setIsWrapping(
|
|
304
|
-
}, [
|
|
304
|
+
setIsWrapping(ref.current.clientHeight > ref.current.scrollHeight / 2);
|
|
305
|
+
}, [(_a = ref.current) === null || _a === void 0 ? void 0 : _a.clientHeight, (_b = ref.current) === null || _b === void 0 ? void 0 : _b.scrollHeight, ref]);
|
|
305
306
|
return isWrapping;
|
|
306
307
|
};
|
|
307
308
|
|
|
@@ -776,7 +777,7 @@ const cvaAlertIconContainer = cssClassVarianceUtilities.cvaMerge(["self-start",
|
|
|
776
777
|
const Alert = ({ color = "info", title, className, children, primaryAction, secondaryAction, onClose, dataTestId, autoScroll, }) => {
|
|
777
778
|
const ref = React__namespace.useRef(null);
|
|
778
779
|
const titleRef = React__namespace.useRef(null);
|
|
779
|
-
const isWrapping = useIsTextWrapping(titleRef
|
|
780
|
+
const isWrapping = useIsTextWrapping(titleRef);
|
|
780
781
|
React__namespace.useEffect(() => {
|
|
781
782
|
var _a, _b;
|
|
782
783
|
if (autoScroll) {
|
|
@@ -1248,18 +1249,19 @@ const useIsFullscreen = () => {
|
|
|
1248
1249
|
/**
|
|
1249
1250
|
* Check if text is cut off.
|
|
1250
1251
|
*
|
|
1251
|
-
* @param {HTMLElement
|
|
1252
|
+
* @param {RefObject<HTMLElement>} ref The ref to the element to check.
|
|
1252
1253
|
* @returns {boolean} True if the text is cut off.
|
|
1253
1254
|
*/
|
|
1254
|
-
const useIsTextCutOff = (
|
|
1255
|
+
const useIsTextCutOff = (ref) => {
|
|
1256
|
+
var _a, _b;
|
|
1255
1257
|
const [isTextCutOff, setIsTextCutOff] = React.useState(false);
|
|
1256
1258
|
React.useEffect(() => {
|
|
1257
|
-
if (!
|
|
1259
|
+
if (!ref.current) {
|
|
1258
1260
|
setIsTextCutOff(false);
|
|
1259
1261
|
return;
|
|
1260
1262
|
}
|
|
1261
|
-
setIsTextCutOff(
|
|
1262
|
-
}, [
|
|
1263
|
+
setIsTextCutOff(ref.current.offsetWidth < ref.current.scrollWidth);
|
|
1264
|
+
}, [(_a = ref.current) === null || _a === void 0 ? void 0 : _a.offsetWidth, (_b = ref.current) === null || _b === void 0 ? void 0 : _b.scrollWidth, ref]);
|
|
1263
1265
|
return isTextCutOff;
|
|
1264
1266
|
};
|
|
1265
1267
|
|
package/index.esm.js
CHANGED
|
@@ -270,18 +270,19 @@ const PackageNameStoryComponent = ({ packageJSON }) => {
|
|
|
270
270
|
/**
|
|
271
271
|
* Hook to detect if text content is wrapping to multiple lines
|
|
272
272
|
*
|
|
273
|
-
* @param {HTMLElement
|
|
273
|
+
* @param {RefObject<HTMLElement>} ref - The ref to the element to check for text wrapping
|
|
274
274
|
* @returns {boolean} True if the text spans multiple lines
|
|
275
275
|
*/
|
|
276
|
-
const useIsTextWrapping = (
|
|
276
|
+
const useIsTextWrapping = (ref) => {
|
|
277
|
+
var _a, _b;
|
|
277
278
|
const [isWrapping, setIsWrapping] = useState(false);
|
|
278
279
|
useEffect(() => {
|
|
279
|
-
if (!
|
|
280
|
+
if (!ref.current) {
|
|
280
281
|
setIsWrapping(false);
|
|
281
282
|
return;
|
|
282
283
|
}
|
|
283
|
-
setIsWrapping(
|
|
284
|
-
}, [
|
|
284
|
+
setIsWrapping(ref.current.clientHeight > ref.current.scrollHeight / 2);
|
|
285
|
+
}, [(_a = ref.current) === null || _a === void 0 ? void 0 : _a.clientHeight, (_b = ref.current) === null || _b === void 0 ? void 0 : _b.scrollHeight, ref]);
|
|
285
286
|
return isWrapping;
|
|
286
287
|
};
|
|
287
288
|
|
|
@@ -756,7 +757,7 @@ const cvaAlertIconContainer = cvaMerge(["self-start", "shrink-0", "grid", "w-min
|
|
|
756
757
|
const Alert = ({ color = "info", title, className, children, primaryAction, secondaryAction, onClose, dataTestId, autoScroll, }) => {
|
|
757
758
|
const ref = React.useRef(null);
|
|
758
759
|
const titleRef = React.useRef(null);
|
|
759
|
-
const isWrapping = useIsTextWrapping(titleRef
|
|
760
|
+
const isWrapping = useIsTextWrapping(titleRef);
|
|
760
761
|
React.useEffect(() => {
|
|
761
762
|
var _a, _b;
|
|
762
763
|
if (autoScroll) {
|
|
@@ -1228,18 +1229,19 @@ const useIsFullscreen = () => {
|
|
|
1228
1229
|
/**
|
|
1229
1230
|
* Check if text is cut off.
|
|
1230
1231
|
*
|
|
1231
|
-
* @param {HTMLElement
|
|
1232
|
+
* @param {RefObject<HTMLElement>} ref The ref to the element to check.
|
|
1232
1233
|
* @returns {boolean} True if the text is cut off.
|
|
1233
1234
|
*/
|
|
1234
|
-
const useIsTextCutOff = (
|
|
1235
|
+
const useIsTextCutOff = (ref) => {
|
|
1236
|
+
var _a, _b;
|
|
1235
1237
|
const [isTextCutOff, setIsTextCutOff] = useState(false);
|
|
1236
1238
|
useEffect(() => {
|
|
1237
|
-
if (!
|
|
1239
|
+
if (!ref.current) {
|
|
1238
1240
|
setIsTextCutOff(false);
|
|
1239
1241
|
return;
|
|
1240
1242
|
}
|
|
1241
|
-
setIsTextCutOff(
|
|
1242
|
-
}, [
|
|
1243
|
+
setIsTextCutOff(ref.current.offsetWidth < ref.current.scrollWidth);
|
|
1244
|
+
}, [(_a = ref.current) === null || _a === void 0 ? void 0 : _a.offsetWidth, (_b = ref.current) === null || _b === void 0 ? void 0 : _b.scrollWidth, ref]);
|
|
1243
1245
|
return isTextCutOff;
|
|
1244
1246
|
};
|
|
1245
1247
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"tailwind-merge": "^2.0.0",
|
|
22
22
|
"@trackunit/ui-design-tokens": "^1.0.1",
|
|
23
23
|
"@trackunit/css-class-variance-utilities": "^1.0.1",
|
|
24
|
-
"@trackunit/shared-utils": "^1.0.
|
|
24
|
+
"@trackunit/shared-utils": "^1.0.3",
|
|
25
25
|
"@trackunit/ui-icons": "^1.0.1",
|
|
26
26
|
"@trackunit/react-table-pagination": "^1.0.1"
|
|
27
27
|
},
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
1
2
|
/**
|
|
2
3
|
* Check if text is cut off.
|
|
3
4
|
*
|
|
4
|
-
* @param {HTMLElement
|
|
5
|
+
* @param {RefObject<HTMLElement>} ref The ref to the element to check.
|
|
5
6
|
* @returns {boolean} True if the text is cut off.
|
|
6
7
|
*/
|
|
7
|
-
export declare const useIsTextCutOff: (
|
|
8
|
+
export declare const useIsTextCutOff: (ref: RefObject<HTMLElement>) => boolean;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
1
2
|
/**
|
|
2
3
|
* Hook to detect if text content is wrapping to multiple lines
|
|
3
4
|
*
|
|
4
|
-
* @param {HTMLElement
|
|
5
|
+
* @param {RefObject<HTMLElement>} ref - The ref to the element to check for text wrapping
|
|
5
6
|
* @returns {boolean} True if the text spans multiple lines
|
|
6
7
|
*/
|
|
7
|
-
export declare const useIsTextWrapping: (
|
|
8
|
+
export declare const useIsTextWrapping: (ref: RefObject<HTMLElement>) => boolean;
|