@trackunit/react-components 1.9.35 → 1.9.38
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 +5 -63
- package/index.esm.js +6 -62
- package/package.json +6 -6
- package/src/components/ListItem/ListItemSkeleton.d.ts +3 -0
- package/src/hooks/index.d.ts +0 -2
- package/src/hooks/useStable.d.ts +0 -22
- package/src/hooks/useWatch.d.ts +0 -19
package/index.cjs.js
CHANGED
|
@@ -1796,36 +1796,6 @@ const useSelfUpdatingRef = (initialState) => {
|
|
|
1796
1796
|
return stateRef;
|
|
1797
1797
|
};
|
|
1798
1798
|
|
|
1799
|
-
/**
|
|
1800
|
-
* The useStable hook ensures that a value is computed only once and remains stable across renders.
|
|
1801
|
-
* This is useful for expensive computations or when you need a value to never change after initial creation.
|
|
1802
|
-
* Perfect for generating stable random values, creating stable object references, or any one-time computation.
|
|
1803
|
-
*
|
|
1804
|
-
* @example
|
|
1805
|
-
* // Stable random ID that never changes
|
|
1806
|
-
* const stableId = useStable(() => Math.random().toString(36));
|
|
1807
|
-
* @example
|
|
1808
|
-
* // Stable configuration object
|
|
1809
|
-
* const config = useStable(() => ({
|
|
1810
|
-
* apiKey: generateApiKey(),
|
|
1811
|
-
* timestamp: Date.now()
|
|
1812
|
-
* }));
|
|
1813
|
-
* @example
|
|
1814
|
-
* // Stable random widths for skeleton loading
|
|
1815
|
-
* const lineWidths = useStable(() => ({
|
|
1816
|
-
* title: Math.floor(Math.random() * 100) + 120,
|
|
1817
|
-
* description: Math.floor(Math.random() * 80) + 80
|
|
1818
|
-
* }));
|
|
1819
|
-
*/
|
|
1820
|
-
const useStable = (factory) => {
|
|
1821
|
-
const ref = react.useRef(null);
|
|
1822
|
-
// Compute value only once and store it
|
|
1823
|
-
if (ref.current === null) {
|
|
1824
|
-
ref.current = { value: factory() };
|
|
1825
|
-
}
|
|
1826
|
-
return ref.current.value;
|
|
1827
|
-
};
|
|
1828
|
-
|
|
1829
1799
|
/**
|
|
1830
1800
|
* A custom React hook that provides real-time information about the current viewport size.
|
|
1831
1801
|
* ! Consider using `useContainerBreakpoints` instead, and only use this when you need to actually react to the viewport size, not the container size.
|
|
@@ -1878,35 +1848,6 @@ const useViewportBreakpoints = () => {
|
|
|
1878
1848
|
return viewportSize;
|
|
1879
1849
|
};
|
|
1880
1850
|
|
|
1881
|
-
const UNINITIALIZED = Symbol("UNINITIALIZED");
|
|
1882
|
-
/**
|
|
1883
|
-
* Hook to watch for changes in a value and react to them.
|
|
1884
|
-
*
|
|
1885
|
-
* @param props - The hook properties
|
|
1886
|
-
* @param props.value - The value to watch for changes
|
|
1887
|
-
* @param props.onChange - Function to call when the value changes
|
|
1888
|
-
* @param props.immediate - Whether to run the callback immediately on mount (default: false)
|
|
1889
|
-
* @param props.isEqual - Custom equality function to determine if value has changed. Defaults to stringified equality.
|
|
1890
|
-
*/
|
|
1891
|
-
const useWatch = ({ value, onChange, immediate = false, isEqual }) => {
|
|
1892
|
-
const prevValue = react.useRef(UNINITIALIZED);
|
|
1893
|
-
react.useEffect(() => {
|
|
1894
|
-
const prev = prevValue.current;
|
|
1895
|
-
const hasChanged = prev === UNINITIALIZED
|
|
1896
|
-
? false
|
|
1897
|
-
: isEqual !== undefined
|
|
1898
|
-
? !isEqual(value, prev)
|
|
1899
|
-
: JSON.stringify(value) !== JSON.stringify(prev);
|
|
1900
|
-
if (immediate && prev === UNINITIALIZED) {
|
|
1901
|
-
onChange(value, null);
|
|
1902
|
-
}
|
|
1903
|
-
else if (hasChanged && prev !== UNINITIALIZED) {
|
|
1904
|
-
onChange(value, prev);
|
|
1905
|
-
}
|
|
1906
|
-
prevValue.current = value;
|
|
1907
|
-
}, [value, onChange, immediate, isEqual]);
|
|
1908
|
-
};
|
|
1909
|
-
|
|
1910
1851
|
const hasFocus = () => typeof document !== "undefined" && document.hasFocus();
|
|
1911
1852
|
/**
|
|
1912
1853
|
* Use this hook to disable functionality while the tab is hidden within the browser or to react to focus or blur events
|
|
@@ -3516,6 +3457,9 @@ const cvaThumbnailContainer = cssClassVarianceUtilities.cvaMerge([
|
|
|
3516
3457
|
"rounded-md",
|
|
3517
3458
|
]);
|
|
3518
3459
|
|
|
3460
|
+
/**
|
|
3461
|
+
* Default property values for ListItemSkeleton component.
|
|
3462
|
+
*/
|
|
3519
3463
|
const DEFAULT_SKELETON_LIST_ITEM_PROPS = {
|
|
3520
3464
|
hasThumbnail: true,
|
|
3521
3465
|
thumbnailShape: "circle",
|
|
@@ -3529,14 +3473,14 @@ const DEFAULT_SKELETON_LIST_ITEM_PROPS = {
|
|
|
3529
3473
|
*/
|
|
3530
3474
|
const ListItemSkeleton = ({ hasThumbnail = DEFAULT_SKELETON_LIST_ITEM_PROPS.hasThumbnail, thumbnailShape = "circle", hasDescription = DEFAULT_SKELETON_LIST_ITEM_PROPS.hasDescription, hasMeta = DEFAULT_SKELETON_LIST_ITEM_PROPS.hasMeta, hasDetails = DEFAULT_SKELETON_LIST_ITEM_PROPS.hasDetails, }) => {
|
|
3531
3475
|
// Generate stable random widths once and never change them
|
|
3532
|
-
const lineWidths =
|
|
3476
|
+
const lineWidths = react.useMemo(() => {
|
|
3533
3477
|
return {
|
|
3534
3478
|
title: getResponsiveRandomWidthPercentage({ min: 60, max: 85 }),
|
|
3535
3479
|
description: getResponsiveRandomWidthPercentage({ min: 45, max: 70 }),
|
|
3536
3480
|
meta: getResponsiveRandomWidthPercentage({ min: 30, max: 55 }),
|
|
3537
3481
|
details: getResponsiveRandomWidthPercentage({ min: 25, max: 45 }),
|
|
3538
3482
|
};
|
|
3539
|
-
});
|
|
3483
|
+
}, []);
|
|
3540
3484
|
return (jsxRuntime.jsxs("div", { className: cvaListItem({ className: "w-full" }), children: [jsxRuntime.jsxs("div", { className: cvaMainInformationClass({ hasThumbnail, className: "w-full" }), children: [hasThumbnail ? (jsxRuntime.jsx("div", { className: cvaThumbnailContainer({ className: "bg-gray-200" }), children: jsxRuntime.jsx("div", { className: tailwindMerge.twMerge("bg-gray-300", thumbnailShape === "circle" ? "rounded-full" : "rounded"), style: { width: 20, height: 20 } }) })) : null, jsxRuntime.jsxs("div", { className: "grid-rows-min-fr grid w-full items-center gap-1 text-sm", children: [jsxRuntime.jsx(SkeletonLines, { height: "0.875em", lines: 1, width: lineWidths.title }), hasDescription ? jsxRuntime.jsx(SkeletonLines, { height: "0.75em", lines: 1, width: lineWidths.description }) : null, hasMeta ? jsxRuntime.jsx(SkeletonLines, { height: "0.75em", lines: 1, width: lineWidths.meta }) : null] })] }), hasDetails ? (jsxRuntime.jsx("div", { className: "pl-2 text-sm", children: jsxRuntime.jsx(SkeletonLines, { height: "0.875em", lines: 1, width: lineWidths.details }) })) : null] }));
|
|
3541
3485
|
};
|
|
3542
3486
|
|
|
@@ -5343,8 +5287,6 @@ exports.useRelayPagination = useRelayPagination;
|
|
|
5343
5287
|
exports.useResize = useResize;
|
|
5344
5288
|
exports.useScrollDetection = useScrollDetection;
|
|
5345
5289
|
exports.useSelfUpdatingRef = useSelfUpdatingRef;
|
|
5346
|
-
exports.useStable = useStable;
|
|
5347
5290
|
exports.useTimeout = useTimeout;
|
|
5348
5291
|
exports.useViewportBreakpoints = useViewportBreakpoints;
|
|
5349
|
-
exports.useWatch = useWatch;
|
|
5350
5292
|
exports.useWindowActivity = useWindowActivity;
|
package/index.esm.js
CHANGED
|
@@ -1794,36 +1794,6 @@ const useSelfUpdatingRef = (initialState) => {
|
|
|
1794
1794
|
return stateRef;
|
|
1795
1795
|
};
|
|
1796
1796
|
|
|
1797
|
-
/**
|
|
1798
|
-
* The useStable hook ensures that a value is computed only once and remains stable across renders.
|
|
1799
|
-
* This is useful for expensive computations or when you need a value to never change after initial creation.
|
|
1800
|
-
* Perfect for generating stable random values, creating stable object references, or any one-time computation.
|
|
1801
|
-
*
|
|
1802
|
-
* @example
|
|
1803
|
-
* // Stable random ID that never changes
|
|
1804
|
-
* const stableId = useStable(() => Math.random().toString(36));
|
|
1805
|
-
* @example
|
|
1806
|
-
* // Stable configuration object
|
|
1807
|
-
* const config = useStable(() => ({
|
|
1808
|
-
* apiKey: generateApiKey(),
|
|
1809
|
-
* timestamp: Date.now()
|
|
1810
|
-
* }));
|
|
1811
|
-
* @example
|
|
1812
|
-
* // Stable random widths for skeleton loading
|
|
1813
|
-
* const lineWidths = useStable(() => ({
|
|
1814
|
-
* title: Math.floor(Math.random() * 100) + 120,
|
|
1815
|
-
* description: Math.floor(Math.random() * 80) + 80
|
|
1816
|
-
* }));
|
|
1817
|
-
*/
|
|
1818
|
-
const useStable = (factory) => {
|
|
1819
|
-
const ref = useRef(null);
|
|
1820
|
-
// Compute value only once and store it
|
|
1821
|
-
if (ref.current === null) {
|
|
1822
|
-
ref.current = { value: factory() };
|
|
1823
|
-
}
|
|
1824
|
-
return ref.current.value;
|
|
1825
|
-
};
|
|
1826
|
-
|
|
1827
1797
|
/**
|
|
1828
1798
|
* A custom React hook that provides real-time information about the current viewport size.
|
|
1829
1799
|
* ! Consider using `useContainerBreakpoints` instead, and only use this when you need to actually react to the viewport size, not the container size.
|
|
@@ -1876,35 +1846,6 @@ const useViewportBreakpoints = () => {
|
|
|
1876
1846
|
return viewportSize;
|
|
1877
1847
|
};
|
|
1878
1848
|
|
|
1879
|
-
const UNINITIALIZED = Symbol("UNINITIALIZED");
|
|
1880
|
-
/**
|
|
1881
|
-
* Hook to watch for changes in a value and react to them.
|
|
1882
|
-
*
|
|
1883
|
-
* @param props - The hook properties
|
|
1884
|
-
* @param props.value - The value to watch for changes
|
|
1885
|
-
* @param props.onChange - Function to call when the value changes
|
|
1886
|
-
* @param props.immediate - Whether to run the callback immediately on mount (default: false)
|
|
1887
|
-
* @param props.isEqual - Custom equality function to determine if value has changed. Defaults to stringified equality.
|
|
1888
|
-
*/
|
|
1889
|
-
const useWatch = ({ value, onChange, immediate = false, isEqual }) => {
|
|
1890
|
-
const prevValue = useRef(UNINITIALIZED);
|
|
1891
|
-
useEffect(() => {
|
|
1892
|
-
const prev = prevValue.current;
|
|
1893
|
-
const hasChanged = prev === UNINITIALIZED
|
|
1894
|
-
? false
|
|
1895
|
-
: isEqual !== undefined
|
|
1896
|
-
? !isEqual(value, prev)
|
|
1897
|
-
: JSON.stringify(value) !== JSON.stringify(prev);
|
|
1898
|
-
if (immediate && prev === UNINITIALIZED) {
|
|
1899
|
-
onChange(value, null);
|
|
1900
|
-
}
|
|
1901
|
-
else if (hasChanged && prev !== UNINITIALIZED) {
|
|
1902
|
-
onChange(value, prev);
|
|
1903
|
-
}
|
|
1904
|
-
prevValue.current = value;
|
|
1905
|
-
}, [value, onChange, immediate, isEqual]);
|
|
1906
|
-
};
|
|
1907
|
-
|
|
1908
1849
|
const hasFocus = () => typeof document !== "undefined" && document.hasFocus();
|
|
1909
1850
|
/**
|
|
1910
1851
|
* Use this hook to disable functionality while the tab is hidden within the browser or to react to focus or blur events
|
|
@@ -3514,6 +3455,9 @@ const cvaThumbnailContainer = cvaMerge([
|
|
|
3514
3455
|
"rounded-md",
|
|
3515
3456
|
]);
|
|
3516
3457
|
|
|
3458
|
+
/**
|
|
3459
|
+
* Default property values for ListItemSkeleton component.
|
|
3460
|
+
*/
|
|
3517
3461
|
const DEFAULT_SKELETON_LIST_ITEM_PROPS = {
|
|
3518
3462
|
hasThumbnail: true,
|
|
3519
3463
|
thumbnailShape: "circle",
|
|
@@ -3527,14 +3471,14 @@ const DEFAULT_SKELETON_LIST_ITEM_PROPS = {
|
|
|
3527
3471
|
*/
|
|
3528
3472
|
const ListItemSkeleton = ({ hasThumbnail = DEFAULT_SKELETON_LIST_ITEM_PROPS.hasThumbnail, thumbnailShape = "circle", hasDescription = DEFAULT_SKELETON_LIST_ITEM_PROPS.hasDescription, hasMeta = DEFAULT_SKELETON_LIST_ITEM_PROPS.hasMeta, hasDetails = DEFAULT_SKELETON_LIST_ITEM_PROPS.hasDetails, }) => {
|
|
3529
3473
|
// Generate stable random widths once and never change them
|
|
3530
|
-
const lineWidths =
|
|
3474
|
+
const lineWidths = useMemo(() => {
|
|
3531
3475
|
return {
|
|
3532
3476
|
title: getResponsiveRandomWidthPercentage({ min: 60, max: 85 }),
|
|
3533
3477
|
description: getResponsiveRandomWidthPercentage({ min: 45, max: 70 }),
|
|
3534
3478
|
meta: getResponsiveRandomWidthPercentage({ min: 30, max: 55 }),
|
|
3535
3479
|
details: getResponsiveRandomWidthPercentage({ min: 25, max: 45 }),
|
|
3536
3480
|
};
|
|
3537
|
-
});
|
|
3481
|
+
}, []);
|
|
3538
3482
|
return (jsxs("div", { className: cvaListItem({ className: "w-full" }), children: [jsxs("div", { className: cvaMainInformationClass({ hasThumbnail, className: "w-full" }), children: [hasThumbnail ? (jsx("div", { className: cvaThumbnailContainer({ className: "bg-gray-200" }), children: jsx("div", { className: twMerge("bg-gray-300", thumbnailShape === "circle" ? "rounded-full" : "rounded"), style: { width: 20, height: 20 } }) })) : null, jsxs("div", { className: "grid-rows-min-fr grid w-full items-center gap-1 text-sm", children: [jsx(SkeletonLines, { height: "0.875em", lines: 1, width: lineWidths.title }), hasDescription ? jsx(SkeletonLines, { height: "0.75em", lines: 1, width: lineWidths.description }) : null, hasMeta ? jsx(SkeletonLines, { height: "0.75em", lines: 1, width: lineWidths.meta }) : null] })] }), hasDetails ? (jsx("div", { className: "pl-2 text-sm", children: jsx(SkeletonLines, { height: "0.875em", lines: 1, width: lineWidths.details }) })) : null] }));
|
|
3539
3483
|
};
|
|
3540
3484
|
|
|
@@ -5214,4 +5158,4 @@ const cvaClickable = cvaMerge([
|
|
|
5214
5158
|
},
|
|
5215
5159
|
});
|
|
5216
5160
|
|
|
5217
|
-
export { ActionRenderer, Alert, Badge, Breadcrumb, BreadcrumbContainer, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CompletionStatusIndicator, CopyableText, DetailsList, EmptyState, EmptyValue, ExternalLink, Heading, Highlight, HorizontalOverflowScroller, Icon, IconButton, Indicator, KPI, KPICard, List, ListItem, MenuDivider, MenuItem, MenuList, MoreMenu, Notice, PackageNameStoryComponent, Page, PageContent, PageHeader, PageHeaderKpiMetrics, PageHeaderSecondaryActions, PageHeaderTitle, Pagination, Polygon, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Portal, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tab, TabContent, TabList, Tabs, Tag, Text, ToggleGroup, Tooltip, ValueBar, ZStack, cvaButton, cvaButtonPrefixSuffix, cvaButtonSpinner, cvaButtonSpinnerContainer, cvaClickable, cvaContainerStyles, cvaIconButton, cvaImgStyles, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaInteractableItem, cvaList, cvaListContainer, cvaListItem$1 as cvaListItem, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemStyle, cvaMenuItemSuffix, cvaPageHeader, cvaPageHeaderContainer, cvaPageHeaderHeading, cvaToggleGroup, cvaToggleGroupWithSlidingBackground, cvaToggleItem, cvaToggleItemContent, cvaToggleItemText, cvaZStackContainer, cvaZStackItem, defaultPageSize, docs, getDevicePixelRatio, getResponsiveRandomWidthPercentage, getValueBarColorByValue, iconColorNames, iconPalette, noPagination, useClickOutside, useContainerBreakpoints, useContinuousTimeout, useDebounce, useDevicePixelRatio, useElevatedReducer, useElevatedState, useGeometry, useHover, useInfiniteScroll, useIsFirstRender, useIsFullscreen, useIsTextTruncated, useList, useListItemHeight, useModifierKey, useOverflowItems, usePopoverContext, usePrompt, useRelayPagination, useResize, useScrollDetection, useSelfUpdatingRef,
|
|
5161
|
+
export { ActionRenderer, Alert, Badge, Breadcrumb, BreadcrumbContainer, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CompletionStatusIndicator, CopyableText, DetailsList, EmptyState, EmptyValue, ExternalLink, Heading, Highlight, HorizontalOverflowScroller, Icon, IconButton, Indicator, KPI, KPICard, List, ListItem, MenuDivider, MenuItem, MenuList, MoreMenu, Notice, PackageNameStoryComponent, Page, PageContent, PageHeader, PageHeaderKpiMetrics, PageHeaderSecondaryActions, PageHeaderTitle, Pagination, Polygon, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Portal, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tab, TabContent, TabList, Tabs, Tag, Text, ToggleGroup, Tooltip, ValueBar, ZStack, cvaButton, cvaButtonPrefixSuffix, cvaButtonSpinner, cvaButtonSpinnerContainer, cvaClickable, cvaContainerStyles, cvaIconButton, cvaImgStyles, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaInteractableItem, cvaList, cvaListContainer, cvaListItem$1 as cvaListItem, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemStyle, cvaMenuItemSuffix, cvaPageHeader, cvaPageHeaderContainer, cvaPageHeaderHeading, cvaToggleGroup, cvaToggleGroupWithSlidingBackground, cvaToggleItem, cvaToggleItemContent, cvaToggleItemText, cvaZStackContainer, cvaZStackItem, defaultPageSize, docs, getDevicePixelRatio, getResponsiveRandomWidthPercentage, getValueBarColorByValue, iconColorNames, iconPalette, noPagination, useClickOutside, useContainerBreakpoints, useContinuousTimeout, useDebounce, useDevicePixelRatio, useElevatedReducer, useElevatedState, useGeometry, useHover, useInfiniteScroll, useIsFirstRender, useIsFullscreen, useIsTextTruncated, useList, useListItemHeight, useModifierKey, useOverflowItems, usePopoverContext, usePrompt, useRelayPagination, useResize, useScrollDetection, useSelfUpdatingRef, useTimeout, useViewportBreakpoints, useWindowActivity };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-components",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.38",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
"@floating-ui/react": "^0.26.25",
|
|
17
17
|
"string-ts": "^2.0.0",
|
|
18
18
|
"tailwind-merge": "^2.0.0",
|
|
19
|
-
"@trackunit/ui-design-tokens": "1.7.
|
|
20
|
-
"@trackunit/css-class-variance-utilities": "1.7.
|
|
21
|
-
"@trackunit/shared-utils": "1.9.
|
|
22
|
-
"@trackunit/ui-icons": "1.7.
|
|
23
|
-
"@trackunit/react-test-setup": "1.4.
|
|
19
|
+
"@trackunit/ui-design-tokens": "1.7.27",
|
|
20
|
+
"@trackunit/css-class-variance-utilities": "1.7.26",
|
|
21
|
+
"@trackunit/shared-utils": "1.9.26",
|
|
22
|
+
"@trackunit/ui-icons": "1.7.28",
|
|
23
|
+
"@trackunit/react-test-setup": "1.4.26",
|
|
24
24
|
"@tanstack/react-router": "1.114.29",
|
|
25
25
|
"es-toolkit": "^1.39.10",
|
|
26
26
|
"@tanstack/react-virtual": "3.13.12"
|
package/src/hooks/index.d.ts
CHANGED
|
@@ -17,8 +17,6 @@ export * from "./useRelayPagination";
|
|
|
17
17
|
export * from "./useResize";
|
|
18
18
|
export * from "./useScrollDetection";
|
|
19
19
|
export * from "./useSelfUpdatingRef";
|
|
20
|
-
export * from "./useStable";
|
|
21
20
|
export * from "./useTimeout";
|
|
22
21
|
export * from "./useViewportBreakpoints";
|
|
23
|
-
export * from "./useWatch";
|
|
24
22
|
export * from "./useWindowActivity";
|
package/src/hooks/useStable.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The useStable hook ensures that a value is computed only once and remains stable across renders.
|
|
3
|
-
* This is useful for expensive computations or when you need a value to never change after initial creation.
|
|
4
|
-
* Perfect for generating stable random values, creating stable object references, or any one-time computation.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* // Stable random ID that never changes
|
|
8
|
-
* const stableId = useStable(() => Math.random().toString(36));
|
|
9
|
-
* @example
|
|
10
|
-
* // Stable configuration object
|
|
11
|
-
* const config = useStable(() => ({
|
|
12
|
-
* apiKey: generateApiKey(),
|
|
13
|
-
* timestamp: Date.now()
|
|
14
|
-
* }));
|
|
15
|
-
* @example
|
|
16
|
-
* // Stable random widths for skeleton loading
|
|
17
|
-
* const lineWidths = useStable(() => ({
|
|
18
|
-
* title: Math.floor(Math.random() * 100) + 120,
|
|
19
|
-
* description: Math.floor(Math.random() * 80) + 80
|
|
20
|
-
* }));
|
|
21
|
-
*/
|
|
22
|
-
export declare const useStable: <TValue>(factory: () => TValue) => TValue;
|
package/src/hooks/useWatch.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
interface UseWatchOptions<TValue> {
|
|
2
|
-
immediate?: boolean;
|
|
3
|
-
isEqual?: (prev: TValue, next: TValue) => boolean;
|
|
4
|
-
}
|
|
5
|
-
interface UseWatchProps<TValue> extends UseWatchOptions<TValue> {
|
|
6
|
-
value: TValue;
|
|
7
|
-
onChange: (value: TValue, prevValue: TValue | null) => void;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Hook to watch for changes in a value and react to them.
|
|
11
|
-
*
|
|
12
|
-
* @param props - The hook properties
|
|
13
|
-
* @param props.value - The value to watch for changes
|
|
14
|
-
* @param props.onChange - Function to call when the value changes
|
|
15
|
-
* @param props.immediate - Whether to run the callback immediately on mount (default: false)
|
|
16
|
-
* @param props.isEqual - Custom equality function to determine if value has changed. Defaults to stringified equality.
|
|
17
|
-
*/
|
|
18
|
-
export declare const useWatch: <TValue>({ value, onChange, immediate, isEqual }: UseWatchProps<TValue>) => void;
|
|
19
|
-
export {};
|