@trackunit/react-components 1.4.4 → 1.4.5
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
|
@@ -864,24 +864,18 @@ const Badge = ({ color = "primary", className, count, max, hideZero = false, dat
|
|
|
864
864
|
* Custom hook to handle click outside events.
|
|
865
865
|
*
|
|
866
866
|
* @param {RefObject<HTMLElement> | Array<RefObject<HTMLElement>>} el - The reference(s) to the element(s) to watch for click outside events.
|
|
867
|
-
* @param {object
|
|
867
|
+
* @param {object} [options={}] - Configuration options.
|
|
868
|
+
* @param {Function} [options.onClick] - The event handler for the click outside event.
|
|
868
869
|
* @param {boolean} [options.active=true] - Whether the click outside event listener should be active.
|
|
869
|
-
* @param {Function} [onClick] - The event handler for the click outside event.
|
|
870
870
|
*/
|
|
871
|
-
const useClickOutside = (el, options
|
|
871
|
+
const useClickOutside = (el, options) => {
|
|
872
872
|
const els = Array.isArray(el) ? el : [el];
|
|
873
|
-
|
|
874
|
-
if (!onClick && typeof options === "function") {
|
|
875
|
-
onClick = options;
|
|
876
|
-
}
|
|
877
|
-
else if (typeof options === "object") {
|
|
878
|
-
active = options.active !== undefined ? options.active : active;
|
|
879
|
-
}
|
|
873
|
+
const active = options.active !== undefined ? options.active : true;
|
|
880
874
|
const handler = (ev) => {
|
|
881
875
|
// eslint-disable-next-line local-rules/no-typescript-assertion
|
|
882
876
|
const target = ev.target;
|
|
883
877
|
if (els.every(ref => !ref.current || !ref.current.contains(target))) {
|
|
884
|
-
onClick
|
|
878
|
+
options.onClick(ev);
|
|
885
879
|
}
|
|
886
880
|
};
|
|
887
881
|
const cleanup = () => window.removeEventListener("click", handler);
|
|
@@ -1069,8 +1063,10 @@ const useContinuousTimeout = ({ onTimeout, onMaxRetries, duration, maxRetries })
|
|
|
1069
1063
|
return {
|
|
1070
1064
|
startTimeouts,
|
|
1071
1065
|
stopTimeouts,
|
|
1072
|
-
retries: retries.current,
|
|
1073
1066
|
isRunning,
|
|
1067
|
+
get retries() {
|
|
1068
|
+
return retries.current;
|
|
1069
|
+
},
|
|
1074
1070
|
};
|
|
1075
1071
|
};
|
|
1076
1072
|
|
|
@@ -1194,31 +1190,35 @@ const useGeometry = (ref) => {
|
|
|
1194
1190
|
if (!ref.current) {
|
|
1195
1191
|
return;
|
|
1196
1192
|
}
|
|
1197
|
-
|
|
1198
|
-
resizeObserver.current
|
|
1199
|
-
|
|
1200
|
-
const
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1193
|
+
const observe = () => {
|
|
1194
|
+
if (!resizeObserver.current) {
|
|
1195
|
+
resizeObserver.current = new ResizeObserver(entries => {
|
|
1196
|
+
for (const entry of entries) {
|
|
1197
|
+
const rect = entry.target.getBoundingClientRect();
|
|
1198
|
+
setGeometry({
|
|
1199
|
+
width: rect.width,
|
|
1200
|
+
height: rect.height,
|
|
1201
|
+
top: rect.top,
|
|
1202
|
+
bottom: rect.bottom,
|
|
1203
|
+
left: rect.left,
|
|
1204
|
+
right: rect.right,
|
|
1205
|
+
x: rect.x,
|
|
1206
|
+
y: rect.y,
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
});
|
|
1210
|
+
}
|
|
1211
|
+
if (ref.current) {
|
|
1212
|
+
resizeObserver.current.observe(ref.current);
|
|
1213
|
+
}
|
|
1214
|
+
};
|
|
1215
|
+
observe();
|
|
1215
1216
|
return () => {
|
|
1216
1217
|
if (resizeObserver.current) {
|
|
1217
1218
|
resizeObserver.current.disconnect();
|
|
1218
1219
|
}
|
|
1219
1220
|
};
|
|
1220
|
-
|
|
1221
|
-
}, [ref.current]);
|
|
1221
|
+
}, [ref]);
|
|
1222
1222
|
return geometry;
|
|
1223
1223
|
};
|
|
1224
1224
|
|
|
@@ -1248,12 +1248,11 @@ const useHover = ({ debounced = false, delay = 100, direction = "out" } = { debo
|
|
|
1248
1248
|
* @returns {boolean} Returns true if it is the first render, false otherwise.
|
|
1249
1249
|
*/
|
|
1250
1250
|
const useIsFirstRender = () => {
|
|
1251
|
-
const
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
return renderRef.current;
|
|
1251
|
+
const [isFirstRender, setIsFirstRender] = react.useState(true);
|
|
1252
|
+
react.useEffect(() => {
|
|
1253
|
+
setIsFirstRender(false);
|
|
1254
|
+
}, []);
|
|
1255
|
+
return isFirstRender;
|
|
1257
1256
|
};
|
|
1258
1257
|
|
|
1259
1258
|
/**
|
|
@@ -2513,7 +2512,7 @@ const FloatingArrowContainer = ({ arrowRef, mode = "dark", }) => {
|
|
|
2513
2512
|
* **Do use** tooltips to expose names of icon buttons that lack visual labels, when more information is useful in helping a user understand the context, when an element needs additional explanation, or use when defining a term or inline item.
|
|
2514
2513
|
*
|
|
2515
2514
|
* **Do not use** tooltips to include information that is necessary for the user to complete their task. Use helper text that is always visible and accessible for vital information.
|
|
2516
|
-
|
|
2515
|
+
*
|
|
2517
2516
|
* @param {TooltipProps} props - The props for the Tooltip component
|
|
2518
2517
|
* @returns {JSX.Element} Tooltip component
|
|
2519
2518
|
*/
|
|
@@ -2524,7 +2523,14 @@ const Tooltip = ({ children, dataTestId = "tool-tip", disabled, className, label
|
|
|
2524
2523
|
placement: placement === "auto" ? "bottom" : placement,
|
|
2525
2524
|
open: isOpen,
|
|
2526
2525
|
onOpenChange: setIsOpen,
|
|
2527
|
-
middleware: [
|
|
2526
|
+
middleware: [
|
|
2527
|
+
react$1.offset(8),
|
|
2528
|
+
react$1.arrow({
|
|
2529
|
+
get element() {
|
|
2530
|
+
return arrowRef;
|
|
2531
|
+
},
|
|
2532
|
+
}),
|
|
2533
|
+
],
|
|
2528
2534
|
whileElementsMounted: react$1.autoUpdate,
|
|
2529
2535
|
});
|
|
2530
2536
|
const { isMounted } = react$1.useTransitionStatus(context);
|
package/index.esm.js
CHANGED
|
@@ -862,24 +862,18 @@ const Badge = ({ color = "primary", className, count, max, hideZero = false, dat
|
|
|
862
862
|
* Custom hook to handle click outside events.
|
|
863
863
|
*
|
|
864
864
|
* @param {RefObject<HTMLElement> | Array<RefObject<HTMLElement>>} el - The reference(s) to the element(s) to watch for click outside events.
|
|
865
|
-
* @param {object
|
|
865
|
+
* @param {object} [options={}] - Configuration options.
|
|
866
|
+
* @param {Function} [options.onClick] - The event handler for the click outside event.
|
|
866
867
|
* @param {boolean} [options.active=true] - Whether the click outside event listener should be active.
|
|
867
|
-
* @param {Function} [onClick] - The event handler for the click outside event.
|
|
868
868
|
*/
|
|
869
|
-
const useClickOutside = (el, options
|
|
869
|
+
const useClickOutside = (el, options) => {
|
|
870
870
|
const els = Array.isArray(el) ? el : [el];
|
|
871
|
-
|
|
872
|
-
if (!onClick && typeof options === "function") {
|
|
873
|
-
onClick = options;
|
|
874
|
-
}
|
|
875
|
-
else if (typeof options === "object") {
|
|
876
|
-
active = options.active !== undefined ? options.active : active;
|
|
877
|
-
}
|
|
871
|
+
const active = options.active !== undefined ? options.active : true;
|
|
878
872
|
const handler = (ev) => {
|
|
879
873
|
// eslint-disable-next-line local-rules/no-typescript-assertion
|
|
880
874
|
const target = ev.target;
|
|
881
875
|
if (els.every(ref => !ref.current || !ref.current.contains(target))) {
|
|
882
|
-
onClick
|
|
876
|
+
options.onClick(ev);
|
|
883
877
|
}
|
|
884
878
|
};
|
|
885
879
|
const cleanup = () => window.removeEventListener("click", handler);
|
|
@@ -1067,8 +1061,10 @@ const useContinuousTimeout = ({ onTimeout, onMaxRetries, duration, maxRetries })
|
|
|
1067
1061
|
return {
|
|
1068
1062
|
startTimeouts,
|
|
1069
1063
|
stopTimeouts,
|
|
1070
|
-
retries: retries.current,
|
|
1071
1064
|
isRunning,
|
|
1065
|
+
get retries() {
|
|
1066
|
+
return retries.current;
|
|
1067
|
+
},
|
|
1072
1068
|
};
|
|
1073
1069
|
};
|
|
1074
1070
|
|
|
@@ -1192,31 +1188,35 @@ const useGeometry = (ref) => {
|
|
|
1192
1188
|
if (!ref.current) {
|
|
1193
1189
|
return;
|
|
1194
1190
|
}
|
|
1195
|
-
|
|
1196
|
-
resizeObserver.current
|
|
1197
|
-
|
|
1198
|
-
const
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1191
|
+
const observe = () => {
|
|
1192
|
+
if (!resizeObserver.current) {
|
|
1193
|
+
resizeObserver.current = new ResizeObserver(entries => {
|
|
1194
|
+
for (const entry of entries) {
|
|
1195
|
+
const rect = entry.target.getBoundingClientRect();
|
|
1196
|
+
setGeometry({
|
|
1197
|
+
width: rect.width,
|
|
1198
|
+
height: rect.height,
|
|
1199
|
+
top: rect.top,
|
|
1200
|
+
bottom: rect.bottom,
|
|
1201
|
+
left: rect.left,
|
|
1202
|
+
right: rect.right,
|
|
1203
|
+
x: rect.x,
|
|
1204
|
+
y: rect.y,
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
if (ref.current) {
|
|
1210
|
+
resizeObserver.current.observe(ref.current);
|
|
1211
|
+
}
|
|
1212
|
+
};
|
|
1213
|
+
observe();
|
|
1213
1214
|
return () => {
|
|
1214
1215
|
if (resizeObserver.current) {
|
|
1215
1216
|
resizeObserver.current.disconnect();
|
|
1216
1217
|
}
|
|
1217
1218
|
};
|
|
1218
|
-
|
|
1219
|
-
}, [ref.current]);
|
|
1219
|
+
}, [ref]);
|
|
1220
1220
|
return geometry;
|
|
1221
1221
|
};
|
|
1222
1222
|
|
|
@@ -1246,12 +1246,11 @@ const useHover = ({ debounced = false, delay = 100, direction = "out" } = { debo
|
|
|
1246
1246
|
* @returns {boolean} Returns true if it is the first render, false otherwise.
|
|
1247
1247
|
*/
|
|
1248
1248
|
const useIsFirstRender = () => {
|
|
1249
|
-
const
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
return renderRef.current;
|
|
1249
|
+
const [isFirstRender, setIsFirstRender] = useState(true);
|
|
1250
|
+
useEffect(() => {
|
|
1251
|
+
setIsFirstRender(false);
|
|
1252
|
+
}, []);
|
|
1253
|
+
return isFirstRender;
|
|
1255
1254
|
};
|
|
1256
1255
|
|
|
1257
1256
|
/**
|
|
@@ -2511,7 +2510,7 @@ const FloatingArrowContainer = ({ arrowRef, mode = "dark", }) => {
|
|
|
2511
2510
|
* **Do use** tooltips to expose names of icon buttons that lack visual labels, when more information is useful in helping a user understand the context, when an element needs additional explanation, or use when defining a term or inline item.
|
|
2512
2511
|
*
|
|
2513
2512
|
* **Do not use** tooltips to include information that is necessary for the user to complete their task. Use helper text that is always visible and accessible for vital information.
|
|
2514
|
-
|
|
2513
|
+
*
|
|
2515
2514
|
* @param {TooltipProps} props - The props for the Tooltip component
|
|
2516
2515
|
* @returns {JSX.Element} Tooltip component
|
|
2517
2516
|
*/
|
|
@@ -2522,7 +2521,14 @@ const Tooltip = ({ children, dataTestId = "tool-tip", disabled, className, label
|
|
|
2522
2521
|
placement: placement === "auto" ? "bottom" : placement,
|
|
2523
2522
|
open: isOpen,
|
|
2524
2523
|
onOpenChange: setIsOpen,
|
|
2525
|
-
middleware: [
|
|
2524
|
+
middleware: [
|
|
2525
|
+
offset(8),
|
|
2526
|
+
arrow({
|
|
2527
|
+
get element() {
|
|
2528
|
+
return arrowRef;
|
|
2529
|
+
},
|
|
2530
|
+
}),
|
|
2531
|
+
],
|
|
2526
2532
|
whileElementsMounted: autoUpdate,
|
|
2527
2533
|
});
|
|
2528
2534
|
const { isMounted } = useTransitionStatus(context);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.5",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"@tanstack/react-router": "1.47.1",
|
|
20
20
|
"string-ts": "^2.0.0",
|
|
21
21
|
"tailwind-merge": "^2.0.0",
|
|
22
|
-
"@trackunit/ui-design-tokens": "1.3.
|
|
23
|
-
"@trackunit/css-class-variance-utilities": "1.3.
|
|
24
|
-
"@trackunit/shared-utils": "1.5.
|
|
25
|
-
"@trackunit/ui-icons": "1.3.
|
|
26
|
-
"@trackunit/react-table-pagination": "1.3.
|
|
22
|
+
"@trackunit/ui-design-tokens": "1.3.5",
|
|
23
|
+
"@trackunit/css-class-variance-utilities": "1.3.5",
|
|
24
|
+
"@trackunit/shared-utils": "1.5.5",
|
|
25
|
+
"@trackunit/ui-icons": "1.3.5",
|
|
26
|
+
"@trackunit/react-table-pagination": "1.3.5"
|
|
27
27
|
},
|
|
28
28
|
"module": "./index.esm.js",
|
|
29
29
|
"main": "./index.cjs.js",
|
|
@@ -41,7 +41,7 @@ export interface TooltipProps extends CommonProps {
|
|
|
41
41
|
* **Do use** tooltips to expose names of icon buttons that lack visual labels, when more information is useful in helping a user understand the context, when an element needs additional explanation, or use when defining a term or inline item.
|
|
42
42
|
*
|
|
43
43
|
* **Do not use** tooltips to include information that is necessary for the user to complete their task. Use helper text that is always visible and accessible for vital information.
|
|
44
|
-
|
|
44
|
+
*
|
|
45
45
|
* @param {TooltipProps} props - The props for the Tooltip component
|
|
46
46
|
* @returns {JSX.Element} Tooltip component
|
|
47
47
|
*/
|
|
@@ -3,10 +3,11 @@ import { RefObject } from "react";
|
|
|
3
3
|
* Custom hook to handle click outside events.
|
|
4
4
|
*
|
|
5
5
|
* @param {RefObject<HTMLElement> | Array<RefObject<HTMLElement>>} el - The reference(s) to the element(s) to watch for click outside events.
|
|
6
|
-
* @param {object
|
|
6
|
+
* @param {object} [options={}] - Configuration options.
|
|
7
|
+
* @param {Function} [options.onClick] - The event handler for the click outside event.
|
|
7
8
|
* @param {boolean} [options.active=true] - Whether the click outside event listener should be active.
|
|
8
|
-
* @param {Function} [onClick] - The event handler for the click outside event.
|
|
9
9
|
*/
|
|
10
|
-
export declare const useClickOutside: (el: RefObject<HTMLElement> | RefObject<HTMLElement>[], options
|
|
10
|
+
export declare const useClickOutside: (el: RefObject<HTMLElement> | RefObject<HTMLElement>[], options: {
|
|
11
|
+
onClick: (ev: MouseEvent) => void;
|
|
11
12
|
active?: boolean;
|
|
12
|
-
}
|
|
13
|
+
}) => void;
|
|
@@ -16,7 +16,7 @@ interface UseContinuousTimeoutProps extends UseTimeoutProps {
|
|
|
16
16
|
export declare const useContinuousTimeout: ({ onTimeout, onMaxRetries, duration, maxRetries }: UseContinuousTimeoutProps) => {
|
|
17
17
|
startTimeouts: () => void;
|
|
18
18
|
stopTimeouts: () => void;
|
|
19
|
-
retries: number;
|
|
20
19
|
isRunning: boolean;
|
|
20
|
+
readonly retries: number;
|
|
21
21
|
};
|
|
22
22
|
export {};
|