@trackunit/react-components 1.0.8 → 1.0.9

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 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 | null} element - The element to check for text wrapping
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 = (element) => {
296
+ const useIsTextWrapping = (ref) => {
297
+ var _a, _b;
297
298
  const [isWrapping, setIsWrapping] = React.useState(false);
298
299
  React.useEffect(() => {
299
- if (!element) {
300
+ if (!ref.current) {
300
301
  setIsWrapping(false);
301
302
  return;
302
303
  }
303
- setIsWrapping(element.clientHeight > element.scrollHeight / 2);
304
- }, [element]);
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.current);
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| null} element The element to check.
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 = (element) => {
1255
+ const useIsTextCutOff = (ref) => {
1256
+ var _a, _b;
1255
1257
  const [isTextCutOff, setIsTextCutOff] = React.useState(false);
1256
1258
  React.useEffect(() => {
1257
- if (!element) {
1259
+ if (!ref.current) {
1258
1260
  setIsTextCutOff(false);
1259
1261
  return;
1260
1262
  }
1261
- setIsTextCutOff(element.offsetWidth < element.scrollWidth);
1262
- }, [element]);
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 | null} element - The element to check for text wrapping
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 = (element) => {
276
+ const useIsTextWrapping = (ref) => {
277
+ var _a, _b;
277
278
  const [isWrapping, setIsWrapping] = useState(false);
278
279
  useEffect(() => {
279
- if (!element) {
280
+ if (!ref.current) {
280
281
  setIsWrapping(false);
281
282
  return;
282
283
  }
283
- setIsWrapping(element.clientHeight > element.scrollHeight / 2);
284
- }, [element]);
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.current);
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| null} element The element to check.
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 = (element) => {
1235
+ const useIsTextCutOff = (ref) => {
1236
+ var _a, _b;
1235
1237
  const [isTextCutOff, setIsTextCutOff] = useState(false);
1236
1238
  useEffect(() => {
1237
- if (!element) {
1239
+ if (!ref.current) {
1238
1240
  setIsTextCutOff(false);
1239
1241
  return;
1240
1242
  }
1241
- setIsTextCutOff(element.offsetWidth < element.scrollWidth);
1242
- }, [element]);
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.8",
3
+ "version": "1.0.9",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -1,7 +1,8 @@
1
+ import { RefObject } from "react";
1
2
  /**
2
3
  * Check if text is cut off.
3
4
  *
4
- * @param {HTMLElement| null} element The element to check.
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: (element: HTMLElement | null) => boolean;
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 | null} element - The element to check for text wrapping
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: (element: HTMLElement | null) => boolean;
8
+ export declare const useIsTextWrapping: (ref: RefObject<HTMLElement>) => boolean;