@box/blueprint-web 7.33.4 → 7.34.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/lib-esm/index.d.ts
CHANGED
|
@@ -68,4 +68,5 @@ export * from './util-components/scrollable-container/scrollable-container';
|
|
|
68
68
|
export * from './util-components/text-with-info-badge';
|
|
69
69
|
export * from './utils/keyboardUtils';
|
|
70
70
|
export * from './utils/useBreakpoint';
|
|
71
|
+
export * from './utils/useFullTextTooltip';
|
|
71
72
|
export * from './visually-hidden';
|
package/lib-esm/index.js
CHANGED
|
@@ -82,6 +82,7 @@ export { ScrollContext, ScrollableContainer, useScroll, useScrollContext } from
|
|
|
82
82
|
export { TextWithInfoBadge } from './util-components/text-with-info-badge/text-with-info-badge.js';
|
|
83
83
|
export { isCtrlKeyPressed, isDeleteKeyPressed, keys } from './utils/keyboardUtils.js';
|
|
84
84
|
export { Breakpoint, useBreakpoint } from './utils/useBreakpoint.js';
|
|
85
|
+
export { useFullTextTooltip } from './utils/useFullTextTooltip.js';
|
|
85
86
|
export { VisuallyHidden } from './visually-hidden/visually-hidden.js';
|
|
86
87
|
export { useNotification } from './primitives/notification/notification-provider.js';
|
|
87
88
|
export { useTabs } from './primitives/tabs/use-tabs.js';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useState, useEffect, Fragment } from 'react';
|
|
2
2
|
import { Tooltip } from '../tooltip/tooltip.js';
|
|
3
|
+
import { debounce } from './debounce.js';
|
|
3
4
|
|
|
4
5
|
const useFullTextTooltip = ({
|
|
5
6
|
ref,
|
|
@@ -9,13 +10,32 @@ const useFullTextTooltip = ({
|
|
|
9
10
|
}) => {
|
|
10
11
|
const [isOverflowing, setIsOverflowing] = useState(false);
|
|
11
12
|
useEffect(() => {
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
const checkIfOverflowing = () => {
|
|
14
|
+
const element = ref?.current;
|
|
15
|
+
if (element && !skipOverflowCheck) {
|
|
16
|
+
setIsOverflowing(element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
// Create debounced version of checkIfOverflowing
|
|
20
|
+
const debouncedCheckIfOverflowing = debounce(checkIfOverflowing, 100);
|
|
21
|
+
const element = ref?.current;
|
|
22
|
+
let resizeObserver = null;
|
|
23
|
+
if (element) {
|
|
24
|
+
// Create a ResizeObserver to observe the size of the element
|
|
25
|
+
resizeObserver = new ResizeObserver(debouncedCheckIfOverflowing);
|
|
26
|
+
resizeObserver.observe(element);
|
|
14
27
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
28
|
+
// Initial check
|
|
29
|
+
debouncedCheckIfOverflowing();
|
|
30
|
+
// Cleanup function to disconnect the observer and clear debounced timeouts
|
|
31
|
+
return () => {
|
|
32
|
+
if (resizeObserver && element) {
|
|
33
|
+
resizeObserver.unobserve(element);
|
|
34
|
+
resizeObserver.disconnect();
|
|
35
|
+
}
|
|
36
|
+
debouncedCheckIfOverflowing.clear();
|
|
37
|
+
};
|
|
38
|
+
}, [ref, skipOverflowCheck, textValue, children]);
|
|
19
39
|
const Wrapper = isOverflowing ? Tooltip : Fragment;
|
|
20
40
|
const wrapperProps = isOverflowing ? {
|
|
21
41
|
content: textValue ?? children
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/blueprint-web",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.34.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"publishConfig": {
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"react-stately": "^3.31.1",
|
|
64
64
|
"tsx": "^4.16.5"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "a7a7ecec4025edfd157a90e5a0700b7baef995a1",
|
|
67
67
|
"module": "lib-esm/index.js",
|
|
68
68
|
"main": "lib-esm/index.js",
|
|
69
69
|
"exports": {
|