@trackunit/react-components 0.1.413 → 0.2.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/index.cjs.js
CHANGED
|
@@ -1292,6 +1292,81 @@ const useSelfUpdatingRef = (initialState) => {
|
|
|
1292
1292
|
return stateRef;
|
|
1293
1293
|
};
|
|
1294
1294
|
|
|
1295
|
+
/**
|
|
1296
|
+
* Maps viewport size keys to their corresponding state property names.
|
|
1297
|
+
*/
|
|
1298
|
+
const propsMap = {
|
|
1299
|
+
xs: "isXs",
|
|
1300
|
+
sm: "isSm",
|
|
1301
|
+
md: "isMd",
|
|
1302
|
+
lg: "isLg",
|
|
1303
|
+
xl: "isXl",
|
|
1304
|
+
"2xl": "is2xl",
|
|
1305
|
+
"3xl": "is3xl",
|
|
1306
|
+
};
|
|
1307
|
+
/**
|
|
1308
|
+
* The default state for viewport sizes, with all values set to false.
|
|
1309
|
+
*/
|
|
1310
|
+
const defaultState = {
|
|
1311
|
+
isXs: false,
|
|
1312
|
+
isSm: false,
|
|
1313
|
+
isMd: false,
|
|
1314
|
+
isLg: false,
|
|
1315
|
+
isXl: false,
|
|
1316
|
+
is2xl: false,
|
|
1317
|
+
is3xl: false,
|
|
1318
|
+
};
|
|
1319
|
+
/**
|
|
1320
|
+
* A custom React hook that provides real-time information about the current viewport size.
|
|
1321
|
+
*
|
|
1322
|
+
* This hook listens to changes in the viewport size and returns an object with boolean values
|
|
1323
|
+
* indicating which breakpoints are currently active. It's useful for creating responsive
|
|
1324
|
+
* layouts and components that need to adapt to different screen sizes.
|
|
1325
|
+
*
|
|
1326
|
+
* @returns {ViewportSizeState} An object containing boolean values for each viewport size breakpoint.
|
|
1327
|
+
* @example
|
|
1328
|
+
* function MyComponent() {
|
|
1329
|
+
* const viewportSize = useViewportSize();
|
|
1330
|
+
*
|
|
1331
|
+
* if (viewportSize.isLg) {
|
|
1332
|
+
* return <LargeScreenLayout />;
|
|
1333
|
+
* } else if (viewportSize.isMd) {
|
|
1334
|
+
* return <MediumScreenLayout />;
|
|
1335
|
+
* } else {
|
|
1336
|
+
* return <SmallScreenLayout />;
|
|
1337
|
+
* }
|
|
1338
|
+
* }
|
|
1339
|
+
*/
|
|
1340
|
+
const useViewportSize = () => {
|
|
1341
|
+
const [viewportSize, setViewportSize] = React.useState(() => defaultState);
|
|
1342
|
+
const updateViewportSize = React.useCallback(() => {
|
|
1343
|
+
const newViewportSize = sharedUtils.objectEntries(uiDesignTokens.themeScreenSizeAsNumber).reduce((acc, [size, minWidth]) => {
|
|
1344
|
+
const matches = window.matchMedia(`(min-width: ${minWidth}px)`).matches;
|
|
1345
|
+
return {
|
|
1346
|
+
...acc,
|
|
1347
|
+
[propsMap[size]]: matches,
|
|
1348
|
+
};
|
|
1349
|
+
}, Object.assign({}, defaultState));
|
|
1350
|
+
setViewportSize(newViewportSize);
|
|
1351
|
+
}, []);
|
|
1352
|
+
React.useEffect(() => {
|
|
1353
|
+
// Initial check
|
|
1354
|
+
updateViewportSize();
|
|
1355
|
+
// Set up listeners for each breakpoint
|
|
1356
|
+
const mediaQueryLists = sharedUtils.objectEntries(uiDesignTokens.themeScreenSizeAsNumber).map(([_, minWidth]) => window.matchMedia(`(min-width: ${minWidth}px)`));
|
|
1357
|
+
mediaQueryLists.forEach(mql => {
|
|
1358
|
+
mql.addEventListener("change", updateViewportSize);
|
|
1359
|
+
});
|
|
1360
|
+
// Cleanup
|
|
1361
|
+
return () => {
|
|
1362
|
+
mediaQueryLists.forEach(mql => {
|
|
1363
|
+
mql.removeEventListener("change", updateViewportSize);
|
|
1364
|
+
});
|
|
1365
|
+
};
|
|
1366
|
+
}, [updateViewportSize]);
|
|
1367
|
+
return viewportSize;
|
|
1368
|
+
};
|
|
1369
|
+
|
|
1295
1370
|
const hasFocus = () => typeof document !== "undefined" && document.hasFocus();
|
|
1296
1371
|
/**
|
|
1297
1372
|
* Use this hook to disable functionality while the tab is hidden within the browser or to react to focus or blur events
|
|
@@ -3673,7 +3748,7 @@ const PopoverTrigger = React.forwardRef(function PopoverTrigger({ children, rend
|
|
|
3673
3748
|
}
|
|
3674
3749
|
});
|
|
3675
3750
|
|
|
3676
|
-
const
|
|
3751
|
+
const cvaTooltipFlexContainer = cssClassVarianceUtilities.cvaMerge(["inline-flex"]);
|
|
3677
3752
|
const cvaTooltipIcon = cssClassVarianceUtilities.cvaMerge(["flex", "h-max", "w-fit", "text-slate-300", "transition", "hover:cursor-pointer", "hover:text-slate-400"], {
|
|
3678
3753
|
variants: {
|
|
3679
3754
|
color: {
|
|
@@ -3696,11 +3771,11 @@ const cvaTooltipPopoverTail = cssClassVarianceUtilities.cvaMerge("", {
|
|
|
3696
3771
|
"bottom-start": "bottom-full left-[5%]",
|
|
3697
3772
|
"bottom-end": "bottom-full right-[5%]",
|
|
3698
3773
|
left: "left-full top-2/4 mt-[-6px]",
|
|
3699
|
-
"left-start": "top-[8%]",
|
|
3700
|
-
"left-end": "bottom-[8%]",
|
|
3774
|
+
"left-start": "top-1/4 top-[8%]",
|
|
3775
|
+
"left-end": "bottom-1/4 bottom-[8%]",
|
|
3701
3776
|
right: "right-full top-2/4 mt-[-6px] ",
|
|
3702
|
-
"right-start": "top-[8%]",
|
|
3703
|
-
"right-end": "bottom-[8%]",
|
|
3777
|
+
"right-start": "top-1/4 top-[8%]",
|
|
3778
|
+
"right-end": "bottom-1/4 bottom-[8%]",
|
|
3704
3779
|
},
|
|
3705
3780
|
mode: {
|
|
3706
3781
|
light: "fill-white",
|
|
@@ -3757,10 +3832,13 @@ const Tooltip = ({ children, dataTestId = "tool-tip", disabled, className, label
|
|
|
3757
3832
|
whileElementsMounted: react.autoUpdate,
|
|
3758
3833
|
});
|
|
3759
3834
|
const { isMounted } = react.useTransitionStatus(context);
|
|
3835
|
+
// Please don't try to move this into the component body directly
|
|
3836
|
+
// I tried and it caused infinite re-renders some places (for whatever reason)
|
|
3837
|
+
const wrappedChildren = (jsxRuntime.jsx("div", { className: cvaTooltipFlexContainer({ className }), "data-testid": dataTestId ? `${dataTestId}-parent` : undefined, children: children }));
|
|
3760
3838
|
if (disabled) {
|
|
3761
|
-
return
|
|
3839
|
+
return wrappedChildren;
|
|
3762
3840
|
}
|
|
3763
|
-
return (jsxRuntime.jsxs(Popover, { activation: { hover: true }, className: cvaTooltipPopover(), dataTestId: dataTestId, id: id, placement: placement === "auto" ? "bottom" : placement, children: [jsxRuntime.jsx(PopoverTrigger, { className: cvaTooltipIcon({ color: mode, className }), "data-testid": dataTestId ? `${dataTestId}-trigger` : null, onMouseEnter: () => setIsOpen(true), onMouseLeave: () => setIsOpen(false), ref: refs.setReference, children: children === undefined ? (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(Icon, { dataTestId: dataTestId ? `${dataTestId}-icon` : undefined, name: "QuestionMarkCircle", size: "small", ...iconProps }) })) : (
|
|
3841
|
+
return (jsxRuntime.jsxs(Popover, { activation: { hover: true }, className: cvaTooltipPopover(), dataTestId: dataTestId, id: id, placement: placement === "auto" ? "bottom" : placement, children: [jsxRuntime.jsx(PopoverTrigger, { className: cvaTooltipIcon({ color: mode, className }), "data-testid": dataTestId ? `${dataTestId}-trigger` : null, onMouseEnter: () => setIsOpen(true), onMouseLeave: () => setIsOpen(false), ref: refs.setReference, children: children === undefined ? (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(Icon, { dataTestId: dataTestId ? `${dataTestId}-icon` : undefined, name: "QuestionMarkCircle", size: "small", ...iconProps }) })) : (wrappedChildren) }), isMounted ? (jsxRuntime.jsx("div", { ref: refs.setFloating, style: floatingStyles, children: jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsxs("div", { "aria-label": typeof label === "string" ? label : undefined, className: cvaTooltipPopoverContent({ color: mode }), "data-testid": `${dataTestId}-content`, children: [jsxRuntime.jsx(Text, { inverted: mode === "dark", type: typeof label === "string" ? "p" : "span", children: label }), placement !== "auto" && jsxRuntime.jsx(FloatingArrowContainer, { arrowRef: arrowRef, mode: mode })] }) }) })) : null] }));
|
|
3764
3842
|
};
|
|
3765
3843
|
|
|
3766
3844
|
const cvaIndicator = cssClassVarianceUtilities.cvaMerge(["flex", "items-center"]);
|
|
@@ -4987,4 +5065,5 @@ exports.usePrompt = usePrompt;
|
|
|
4987
5065
|
exports.useResize = useResize;
|
|
4988
5066
|
exports.useSelfUpdatingRef = useSelfUpdatingRef;
|
|
4989
5067
|
exports.useTimeout = useTimeout;
|
|
5068
|
+
exports.useViewportSize = useViewportSize;
|
|
4990
5069
|
exports.useWindowActivity = useWindowActivity;
|
package/index.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { useRef, useMemo, useEffect, useState, useReducer, useCallback, memo, forwardRef, createContext, useContext, isValidElement, cloneElement, Children } from 'react';
|
|
4
|
-
import { objectKeys, objectValues } from '@trackunit/shared-utils';
|
|
5
|
-
import { rentalStatusPalette, intentPalette, generalPalette, criticalityPalette, activityPalette, utilizationPalette, sitesPalette, color } from '@trackunit/ui-design-tokens';
|
|
4
|
+
import { objectKeys, objectEntries, objectValues } from '@trackunit/shared-utils';
|
|
5
|
+
import { rentalStatusPalette, intentPalette, generalPalette, criticalityPalette, activityPalette, utilizationPalette, sitesPalette, themeScreenSizeAsNumber, color } from '@trackunit/ui-design-tokens';
|
|
6
6
|
import { iconNames } from '@trackunit/ui-icons';
|
|
7
7
|
import IconSpriteMini from '@trackunit/ui-icons/icons-sprite-mini.svg';
|
|
8
8
|
import IconSpriteOutline from '@trackunit/ui-icons/icons-sprite-outline.svg';
|
|
@@ -1272,6 +1272,81 @@ const useSelfUpdatingRef = (initialState) => {
|
|
|
1272
1272
|
return stateRef;
|
|
1273
1273
|
};
|
|
1274
1274
|
|
|
1275
|
+
/**
|
|
1276
|
+
* Maps viewport size keys to their corresponding state property names.
|
|
1277
|
+
*/
|
|
1278
|
+
const propsMap = {
|
|
1279
|
+
xs: "isXs",
|
|
1280
|
+
sm: "isSm",
|
|
1281
|
+
md: "isMd",
|
|
1282
|
+
lg: "isLg",
|
|
1283
|
+
xl: "isXl",
|
|
1284
|
+
"2xl": "is2xl",
|
|
1285
|
+
"3xl": "is3xl",
|
|
1286
|
+
};
|
|
1287
|
+
/**
|
|
1288
|
+
* The default state for viewport sizes, with all values set to false.
|
|
1289
|
+
*/
|
|
1290
|
+
const defaultState = {
|
|
1291
|
+
isXs: false,
|
|
1292
|
+
isSm: false,
|
|
1293
|
+
isMd: false,
|
|
1294
|
+
isLg: false,
|
|
1295
|
+
isXl: false,
|
|
1296
|
+
is2xl: false,
|
|
1297
|
+
is3xl: false,
|
|
1298
|
+
};
|
|
1299
|
+
/**
|
|
1300
|
+
* A custom React hook that provides real-time information about the current viewport size.
|
|
1301
|
+
*
|
|
1302
|
+
* This hook listens to changes in the viewport size and returns an object with boolean values
|
|
1303
|
+
* indicating which breakpoints are currently active. It's useful for creating responsive
|
|
1304
|
+
* layouts and components that need to adapt to different screen sizes.
|
|
1305
|
+
*
|
|
1306
|
+
* @returns {ViewportSizeState} An object containing boolean values for each viewport size breakpoint.
|
|
1307
|
+
* @example
|
|
1308
|
+
* function MyComponent() {
|
|
1309
|
+
* const viewportSize = useViewportSize();
|
|
1310
|
+
*
|
|
1311
|
+
* if (viewportSize.isLg) {
|
|
1312
|
+
* return <LargeScreenLayout />;
|
|
1313
|
+
* } else if (viewportSize.isMd) {
|
|
1314
|
+
* return <MediumScreenLayout />;
|
|
1315
|
+
* } else {
|
|
1316
|
+
* return <SmallScreenLayout />;
|
|
1317
|
+
* }
|
|
1318
|
+
* }
|
|
1319
|
+
*/
|
|
1320
|
+
const useViewportSize = () => {
|
|
1321
|
+
const [viewportSize, setViewportSize] = useState(() => defaultState);
|
|
1322
|
+
const updateViewportSize = useCallback(() => {
|
|
1323
|
+
const newViewportSize = objectEntries(themeScreenSizeAsNumber).reduce((acc, [size, minWidth]) => {
|
|
1324
|
+
const matches = window.matchMedia(`(min-width: ${minWidth}px)`).matches;
|
|
1325
|
+
return {
|
|
1326
|
+
...acc,
|
|
1327
|
+
[propsMap[size]]: matches,
|
|
1328
|
+
};
|
|
1329
|
+
}, Object.assign({}, defaultState));
|
|
1330
|
+
setViewportSize(newViewportSize);
|
|
1331
|
+
}, []);
|
|
1332
|
+
useEffect(() => {
|
|
1333
|
+
// Initial check
|
|
1334
|
+
updateViewportSize();
|
|
1335
|
+
// Set up listeners for each breakpoint
|
|
1336
|
+
const mediaQueryLists = objectEntries(themeScreenSizeAsNumber).map(([_, minWidth]) => window.matchMedia(`(min-width: ${minWidth}px)`));
|
|
1337
|
+
mediaQueryLists.forEach(mql => {
|
|
1338
|
+
mql.addEventListener("change", updateViewportSize);
|
|
1339
|
+
});
|
|
1340
|
+
// Cleanup
|
|
1341
|
+
return () => {
|
|
1342
|
+
mediaQueryLists.forEach(mql => {
|
|
1343
|
+
mql.removeEventListener("change", updateViewportSize);
|
|
1344
|
+
});
|
|
1345
|
+
};
|
|
1346
|
+
}, [updateViewportSize]);
|
|
1347
|
+
return viewportSize;
|
|
1348
|
+
};
|
|
1349
|
+
|
|
1275
1350
|
const hasFocus = () => typeof document !== "undefined" && document.hasFocus();
|
|
1276
1351
|
/**
|
|
1277
1352
|
* Use this hook to disable functionality while the tab is hidden within the browser or to react to focus or blur events
|
|
@@ -3653,7 +3728,7 @@ const PopoverTrigger = forwardRef(function PopoverTrigger({ children, renderButt
|
|
|
3653
3728
|
}
|
|
3654
3729
|
});
|
|
3655
3730
|
|
|
3656
|
-
const
|
|
3731
|
+
const cvaTooltipFlexContainer = cvaMerge(["inline-flex"]);
|
|
3657
3732
|
const cvaTooltipIcon = cvaMerge(["flex", "h-max", "w-fit", "text-slate-300", "transition", "hover:cursor-pointer", "hover:text-slate-400"], {
|
|
3658
3733
|
variants: {
|
|
3659
3734
|
color: {
|
|
@@ -3676,11 +3751,11 @@ const cvaTooltipPopoverTail = cvaMerge("", {
|
|
|
3676
3751
|
"bottom-start": "bottom-full left-[5%]",
|
|
3677
3752
|
"bottom-end": "bottom-full right-[5%]",
|
|
3678
3753
|
left: "left-full top-2/4 mt-[-6px]",
|
|
3679
|
-
"left-start": "top-[8%]",
|
|
3680
|
-
"left-end": "bottom-[8%]",
|
|
3754
|
+
"left-start": "top-1/4 top-[8%]",
|
|
3755
|
+
"left-end": "bottom-1/4 bottom-[8%]",
|
|
3681
3756
|
right: "right-full top-2/4 mt-[-6px] ",
|
|
3682
|
-
"right-start": "top-[8%]",
|
|
3683
|
-
"right-end": "bottom-[8%]",
|
|
3757
|
+
"right-start": "top-1/4 top-[8%]",
|
|
3758
|
+
"right-end": "bottom-1/4 bottom-[8%]",
|
|
3684
3759
|
},
|
|
3685
3760
|
mode: {
|
|
3686
3761
|
light: "fill-white",
|
|
@@ -3737,10 +3812,13 @@ const Tooltip = ({ children, dataTestId = "tool-tip", disabled, className, label
|
|
|
3737
3812
|
whileElementsMounted: autoUpdate,
|
|
3738
3813
|
});
|
|
3739
3814
|
const { isMounted } = useTransitionStatus(context);
|
|
3815
|
+
// Please don't try to move this into the component body directly
|
|
3816
|
+
// I tried and it caused infinite re-renders some places (for whatever reason)
|
|
3817
|
+
const wrappedChildren = (jsx("div", { className: cvaTooltipFlexContainer({ className }), "data-testid": dataTestId ? `${dataTestId}-parent` : undefined, children: children }));
|
|
3740
3818
|
if (disabled) {
|
|
3741
|
-
return
|
|
3819
|
+
return wrappedChildren;
|
|
3742
3820
|
}
|
|
3743
|
-
return (jsxs(Popover, { activation: { hover: true }, className: cvaTooltipPopover(), dataTestId: dataTestId, id: id, placement: placement === "auto" ? "bottom" : placement, children: [jsx(PopoverTrigger, { className: cvaTooltipIcon({ color: mode, className }), "data-testid": dataTestId ? `${dataTestId}-trigger` : null, onMouseEnter: () => setIsOpen(true), onMouseLeave: () => setIsOpen(false), ref: refs.setReference, children: children === undefined ? (jsx("div", { children: jsx(Icon, { dataTestId: dataTestId ? `${dataTestId}-icon` : undefined, name: "QuestionMarkCircle", size: "small", ...iconProps }) })) : (
|
|
3821
|
+
return (jsxs(Popover, { activation: { hover: true }, className: cvaTooltipPopover(), dataTestId: dataTestId, id: id, placement: placement === "auto" ? "bottom" : placement, children: [jsx(PopoverTrigger, { className: cvaTooltipIcon({ color: mode, className }), "data-testid": dataTestId ? `${dataTestId}-trigger` : null, onMouseEnter: () => setIsOpen(true), onMouseLeave: () => setIsOpen(false), ref: refs.setReference, children: children === undefined ? (jsx("div", { children: jsx(Icon, { dataTestId: dataTestId ? `${dataTestId}-icon` : undefined, name: "QuestionMarkCircle", size: "small", ...iconProps }) })) : (wrappedChildren) }), isMounted ? (jsx("div", { ref: refs.setFloating, style: floatingStyles, children: jsx(PopoverContent, { children: jsxs("div", { "aria-label": typeof label === "string" ? label : undefined, className: cvaTooltipPopoverContent({ color: mode }), "data-testid": `${dataTestId}-content`, children: [jsx(Text, { inverted: mode === "dark", type: typeof label === "string" ? "p" : "span", children: label }), placement !== "auto" && jsx(FloatingArrowContainer, { arrowRef: arrowRef, mode: mode })] }) }) })) : null] }));
|
|
3744
3822
|
};
|
|
3745
3823
|
|
|
3746
3824
|
const cvaIndicator = cvaMerge(["flex", "items-center"]);
|
|
@@ -4869,4 +4947,4 @@ const cvaClickable = cvaMerge([
|
|
|
4869
4947
|
},
|
|
4870
4948
|
});
|
|
4871
4949
|
|
|
4872
|
-
export { Alert, Badge, Breadcrumb, BreadcrumbContainer, BreadcrumbItem, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CompletionStatusIndicator, CopyableText, Drawer, EmptyState, EmptyValue, ExternalLink, Heading, Icon, IconButton, Indicator, KPICard, MenuItem, MenuList, MoreMenu, Notice, PackageNameStoryComponent, Page, PageContent, PageHeader, Pagination, Polygon, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tab, TabContent, TabList, Tabs, Tag, Text, Timeline, TimelineElement, ToggleGroup, Tooltip, ValueBar, VirtualizedList, WidgetBody, cvaButton, cvaButtonPrefixSuffix, cvaButtonSpinner, cvaButtonSpinnerContainer, cvaClickable, cvaIconButton, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaInteractableItem, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemStyle, cvaMenuItemSuffix, docs, getDevicePixelRatio, getValueBarColorByValue, iconColorNames, iconPalette, setLocalStorage, useClickOutside, useContinuousTimeout, useDebounce, useDevicePixelRatio, useGeometry, useHover, useIsFirstRender, useIsFullscreen, useIsTextCutOff, useLocalStorage, useLocalStorageReducer, useOptionallyElevatedState, useOverflowItems, usePopoverContext, usePrompt, useResize, useSelfUpdatingRef, useTimeout, useWindowActivity };
|
|
4950
|
+
export { Alert, Badge, Breadcrumb, BreadcrumbContainer, BreadcrumbItem, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CompletionStatusIndicator, CopyableText, Drawer, EmptyState, EmptyValue, ExternalLink, Heading, Icon, IconButton, Indicator, KPICard, MenuItem, MenuList, MoreMenu, Notice, PackageNameStoryComponent, Page, PageContent, PageHeader, Pagination, Polygon, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tab, TabContent, TabList, Tabs, Tag, Text, Timeline, TimelineElement, ToggleGroup, Tooltip, ValueBar, VirtualizedList, WidgetBody, cvaButton, cvaButtonPrefixSuffix, cvaButtonSpinner, cvaButtonSpinnerContainer, cvaClickable, cvaIconButton, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaInteractableItem, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemStyle, cvaMenuItemSuffix, docs, getDevicePixelRatio, getValueBarColorByValue, iconColorNames, iconPalette, setLocalStorage, useClickOutside, useContinuousTimeout, useDebounce, useDevicePixelRatio, useGeometry, useHover, useIsFirstRender, useIsFullscreen, useIsTextCutOff, useLocalStorage, useLocalStorageReducer, useOptionallyElevatedState, useOverflowItems, usePopoverContext, usePrompt, useResize, useSelfUpdatingRef, useTimeout, useViewportSize, useWindowActivity };
|
package/package.json
CHANGED
|
@@ -42,4 +42,4 @@ export interface TooltipProps extends CommonProps {
|
|
|
42
42
|
* @param {TooltipProps} props - The props for the Tooltip component
|
|
43
43
|
* @returns {JSX.Element} Tooltip component
|
|
44
44
|
*/
|
|
45
|
-
export declare const Tooltip: ({ children, dataTestId, disabled, className, label, placement, mode, iconProps, id, }: TooltipProps) =>
|
|
45
|
+
export declare const Tooltip: ({ children, dataTestId, disabled, className, label, placement, mode, iconProps, id, }: TooltipProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const cvaTooltipFlexContainer: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
2
2
|
export declare const cvaTooltipIcon: (props?: ({
|
|
3
3
|
color?: "light" | "dark" | null | undefined;
|
|
4
4
|
defaultVariants?: "color" | null | undefined;
|
package/src/hooks/index.d.ts
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { themeScreenSizeAsNumber } from "@trackunit/ui-design-tokens";
|
|
2
|
+
type ViewportSize = keyof typeof themeScreenSizeAsNumber;
|
|
3
|
+
/**
|
|
4
|
+
* Represents the state of viewport sizes as boolean values.
|
|
5
|
+
* Each property is true if the viewport width is greater than or equal to the corresponding breakpoint.
|
|
6
|
+
*/
|
|
7
|
+
type ViewportSizeState = {
|
|
8
|
+
[K in ViewportSize as `is${Capitalize<K>}`]: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A custom React hook that provides real-time information about the current viewport size.
|
|
12
|
+
*
|
|
13
|
+
* This hook listens to changes in the viewport size and returns an object with boolean values
|
|
14
|
+
* indicating which breakpoints are currently active. It's useful for creating responsive
|
|
15
|
+
* layouts and components that need to adapt to different screen sizes.
|
|
16
|
+
*
|
|
17
|
+
* @returns {ViewportSizeState} An object containing boolean values for each viewport size breakpoint.
|
|
18
|
+
* @example
|
|
19
|
+
* function MyComponent() {
|
|
20
|
+
* const viewportSize = useViewportSize();
|
|
21
|
+
*
|
|
22
|
+
* if (viewportSize.isLg) {
|
|
23
|
+
* return <LargeScreenLayout />;
|
|
24
|
+
* } else if (viewportSize.isMd) {
|
|
25
|
+
* return <MediumScreenLayout />;
|
|
26
|
+
* } else {
|
|
27
|
+
* return <SmallScreenLayout />;
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
*/
|
|
31
|
+
export declare const useViewportSize: () => ViewportSizeState;
|
|
32
|
+
export {};
|