@trackunit/react-components 2.13.24 → 2.13.26

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
@@ -14349,6 +14349,37 @@ const useElevatedState = (initialState, customState) => {
14349
14349
  return react.useMemo(() => customState ?? [fallbackValue, fallbackSetter], [customState, fallbackValue, fallbackSetter]);
14350
14350
  };
14351
14351
 
14352
+ /**
14353
+ * The useHold hook freezes a value at its last non-exiting state while `isExiting` is true, so
14354
+ * that content (e.g. inside a closing drawer) can keep rendering its last known value while an
14355
+ * exit animation plays, instead of flashing to a new/empty value mid-animation.
14356
+ *
14357
+ * It is a pure value-holding primitive: it has no knowledge of animation duration and does not
14358
+ * debounce or delay anything. As soon as `isExiting` flips back to `false`, the live `value` is
14359
+ * returned immediately.
14360
+ *
14361
+ * @example
14362
+ * const heldValue = useHold(value, isExiting);
14363
+ */
14364
+ const useHold = (value, isExiting) => {
14365
+ const ref = react.useRef(value);
14366
+ react.useEffect(() => {
14367
+ if (!isExiting) {
14368
+ ref.current = value;
14369
+ }
14370
+ }, [value, isExiting]);
14371
+ // Wrapped in a getter (rather than reading `ref.current` directly during render) to satisfy
14372
+ // the `react-hooks/refs` lint rule, which forbids accessing ref values during render. The memo
14373
+ // must depend on `[isExiting, value]` (unlike usePrevious's stable `[]`-deps wrapper) because
14374
+ // the getter itself branches on the current render's `isExiting`/`value`, not just on `ref`.
14375
+ const wrapper = react.useMemo(() => ({
14376
+ get current() {
14377
+ return isExiting ? ref.current : value;
14378
+ },
14379
+ }), [isExiting, value]);
14380
+ return wrapper.current;
14381
+ };
14382
+
14352
14383
  /**
14353
14384
  * Custom hook for checking if the browser is in fullscreen mode.
14354
14385
  */
@@ -15259,6 +15290,7 @@ exports.useElevatedReducer = useElevatedReducer;
15259
15290
  exports.useElevatedState = useElevatedState;
15260
15291
  exports.useGridAreas = useGridAreas;
15261
15292
  exports.useHashParamSync = useHashParamSync;
15293
+ exports.useHold = useHold;
15262
15294
  exports.useHover = useHover;
15263
15295
  exports.useInfiniteScroll = useInfiniteScroll;
15264
15296
  exports.useIsFirstRender = useIsFirstRender;
package/index.esm.js CHANGED
@@ -14348,6 +14348,37 @@ const useElevatedState = (initialState, customState) => {
14348
14348
  return useMemo(() => customState ?? [fallbackValue, fallbackSetter], [customState, fallbackValue, fallbackSetter]);
14349
14349
  };
14350
14350
 
14351
+ /**
14352
+ * The useHold hook freezes a value at its last non-exiting state while `isExiting` is true, so
14353
+ * that content (e.g. inside a closing drawer) can keep rendering its last known value while an
14354
+ * exit animation plays, instead of flashing to a new/empty value mid-animation.
14355
+ *
14356
+ * It is a pure value-holding primitive: it has no knowledge of animation duration and does not
14357
+ * debounce or delay anything. As soon as `isExiting` flips back to `false`, the live `value` is
14358
+ * returned immediately.
14359
+ *
14360
+ * @example
14361
+ * const heldValue = useHold(value, isExiting);
14362
+ */
14363
+ const useHold = (value, isExiting) => {
14364
+ const ref = useRef(value);
14365
+ useEffect(() => {
14366
+ if (!isExiting) {
14367
+ ref.current = value;
14368
+ }
14369
+ }, [value, isExiting]);
14370
+ // Wrapped in a getter (rather than reading `ref.current` directly during render) to satisfy
14371
+ // the `react-hooks/refs` lint rule, which forbids accessing ref values during render. The memo
14372
+ // must depend on `[isExiting, value]` (unlike usePrevious's stable `[]`-deps wrapper) because
14373
+ // the getter itself branches on the current render's `isExiting`/`value`, not just on `ref`.
14374
+ const wrapper = useMemo(() => ({
14375
+ get current() {
14376
+ return isExiting ? ref.current : value;
14377
+ },
14378
+ }), [isExiting, value]);
14379
+ return wrapper.current;
14380
+ };
14381
+
14351
14382
  /**
14352
14383
  * Custom hook for checking if the browser is in fullscreen mode.
14353
14384
  */
@@ -15104,4 +15135,4 @@ const useWindowActivity = ({ onFocus, onBlur, skip = false } = { onBlur: undefin
15104
15135
  */
15105
15136
  setupLibraryTranslations();
15106
15137
 
15107
- export { Alert, Badge, Breadcrumb, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CompletionStatusIndicator, CopyButton, CopyableText, DEFAULT_SKELETON_PREFERENCE_CARD_PROPS, DetailsList, EmptyState, EmptyValue, ExternalLink, GridAreas, Heading, Highlight, HorizontalOverflowScroller, Icon, IconButton, Indicator, KPI, KPICard, KPICardSkeleton, KPISkeleton, LabeledValue, LabeledValueList, List, ListItem, MAX_HASH_LENGTH, MAX_URL_LENGTH, MenuContent, MenuDivider, MenuItem, MenuTree, MoreMenu, Notice, PackageNameStoryComponent, Page, PageContent, PageHeader, PageHeaderKpiMetrics, PageHeaderSecondaryActions, PageHeaderTitle, Pagination, Polygon, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Portal, PreferenceCard, PreferenceCardSkeleton, Prompt, ROLE_CARD, SHEET_TRANSITION_DURATION, SHEET_TRANSITION_DURATION_MS, SHEET_TRANSITION_EASING, SectionHeader, SegmentedValueBar, Sheet, Sidebar, SidebarContentLayout, SkeletonBlock, SkeletonLabel, SkeletonLines, Spacer, Spinner, StarButton, Tab, TabContent, TabList, Tabs, Tag, Text, ToggleGroup, Tooltip, TrendIndicator, TrendIndicators, ValueBar, ZStack, createGrid, cvaButton, cvaButtonPrefixSuffix, cvaButtonSpinner, cvaButtonSpinnerContainer, cvaClickable, cvaContainerStyles, cvaContentContainer, cvaContentWrapper, cvaDescriptionCard, cvaIconBackground, cvaIconButton, cvaImgStyles, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaInputContainer, cvaInteractableItem, cvaList, cvaListContainer, cvaListItem$1 as cvaListItem, cvaMenu, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemStyle, cvaMenuItemSuffix, cvaMenuList, cvaMenuListDivider, cvaMenuListItem, cvaMenuListMultiSelect, cvaPageHeader, cvaPageHeaderContainer, cvaPageHeaderHeading, cvaPreferenceCard, cvaTitleCard, cvaToggleGroup, cvaToggleGroupWithSlidingBackground, cvaToggleItem, cvaToggleItemContent, cvaToggleItemText, cvaZStackContainer, cvaZStackItem, defaultPageSize, docs, getDevicePixelRatio, getValueBarColorByValue, iconColorNames, iconPalette, noPagination, preferenceCardGrid, useBidirectionalScroll, useClickOutside, useContainerBreakpoints, useContinuousTimeout, useCopyToClipboard, useCursorUrlSync, useCustomEncoding, useDebounce, useDevicePixelRatio, useElevatedReducer, useElevatedState, useGridAreas, useHashParamSync, useHover, useInfiniteScroll, useIsFirstRender, useIsFullscreen, useIsTextTruncated, useKeyboardShortcut, useList, useListItemHeight, useLocalStorage, useLocalStorageReducer, useMeasure, useMenuSearchField, useMenuTree, useMergeRefs, useModifierKey, useOptionalPopoverContext, useOverflowBorder, useOverflowItems, usePersistedState, usePopoverContext, usePrevious, usePrompt, useRandomCSSLengths, useRelayPagination, useResize, useScrollBlock, useScrollDetection, useSearchParamSync, useSelfUpdatingRef, useSessionStorage, useSessionStorageReducer, useSheet, useSheetSnap, useStorageKey, useTextSearch, useTimeout, useViewportBreakpoints, useWatch, useWindowActivity };
15138
+ export { Alert, Badge, Breadcrumb, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CompletionStatusIndicator, CopyButton, CopyableText, DEFAULT_SKELETON_PREFERENCE_CARD_PROPS, DetailsList, EmptyState, EmptyValue, ExternalLink, GridAreas, Heading, Highlight, HorizontalOverflowScroller, Icon, IconButton, Indicator, KPI, KPICard, KPICardSkeleton, KPISkeleton, LabeledValue, LabeledValueList, List, ListItem, MAX_HASH_LENGTH, MAX_URL_LENGTH, MenuContent, MenuDivider, MenuItem, MenuTree, MoreMenu, Notice, PackageNameStoryComponent, Page, PageContent, PageHeader, PageHeaderKpiMetrics, PageHeaderSecondaryActions, PageHeaderTitle, Pagination, Polygon, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Portal, PreferenceCard, PreferenceCardSkeleton, Prompt, ROLE_CARD, SHEET_TRANSITION_DURATION, SHEET_TRANSITION_DURATION_MS, SHEET_TRANSITION_EASING, SectionHeader, SegmentedValueBar, Sheet, Sidebar, SidebarContentLayout, SkeletonBlock, SkeletonLabel, SkeletonLines, Spacer, Spinner, StarButton, Tab, TabContent, TabList, Tabs, Tag, Text, ToggleGroup, Tooltip, TrendIndicator, TrendIndicators, ValueBar, ZStack, createGrid, cvaButton, cvaButtonPrefixSuffix, cvaButtonSpinner, cvaButtonSpinnerContainer, cvaClickable, cvaContainerStyles, cvaContentContainer, cvaContentWrapper, cvaDescriptionCard, cvaIconBackground, cvaIconButton, cvaImgStyles, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaInputContainer, cvaInteractableItem, cvaList, cvaListContainer, cvaListItem$1 as cvaListItem, cvaMenu, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemStyle, cvaMenuItemSuffix, cvaMenuList, cvaMenuListDivider, cvaMenuListItem, cvaMenuListMultiSelect, cvaPageHeader, cvaPageHeaderContainer, cvaPageHeaderHeading, cvaPreferenceCard, cvaTitleCard, cvaToggleGroup, cvaToggleGroupWithSlidingBackground, cvaToggleItem, cvaToggleItemContent, cvaToggleItemText, cvaZStackContainer, cvaZStackItem, defaultPageSize, docs, getDevicePixelRatio, getValueBarColorByValue, iconColorNames, iconPalette, noPagination, preferenceCardGrid, useBidirectionalScroll, useClickOutside, useContainerBreakpoints, useContinuousTimeout, useCopyToClipboard, useCursorUrlSync, useCustomEncoding, useDebounce, useDevicePixelRatio, useElevatedReducer, useElevatedState, useGridAreas, useHashParamSync, useHold, useHover, useInfiniteScroll, useIsFirstRender, useIsFullscreen, useIsTextTruncated, useKeyboardShortcut, useList, useListItemHeight, useLocalStorage, useLocalStorageReducer, useMeasure, useMenuSearchField, useMenuTree, useMergeRefs, useModifierKey, useOptionalPopoverContext, useOverflowBorder, useOverflowItems, usePersistedState, usePopoverContext, usePrevious, usePrompt, useRandomCSSLengths, useRelayPagination, useResize, useScrollBlock, useScrollDetection, useSearchParamSync, useSelfUpdatingRef, useSessionStorage, useSessionStorageReducer, useSheet, useSheetSnap, useStorageKey, useTextSearch, useTimeout, useViewportBreakpoints, useWatch, useWindowActivity };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "2.13.24",
3
+ "version": "2.13.26",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "migrations": "./migrations.json",
@@ -23,7 +23,7 @@
23
23
  "dequal": "^2.0.3",
24
24
  "fflate": "^0.8.2",
25
25
  "zod": "^3.25.76",
26
- "@trackunit/i18n-library-translation": "2.4.63"
26
+ "@trackunit/i18n-library-translation": "2.4.64"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "react": "^19.0.0",
@@ -145,7 +145,7 @@ export declare const cvaButton: import("cva").CVAComponent<Omit<{
145
145
  false: never[];
146
146
  };
147
147
  };
148
- defaultVariants: Omit<{}, "size" | "disabled" | "square" | "variant" | "fullWidth"> & {
148
+ defaultVariants: Omit<{}, "size" | "square" | "disabled" | "variant" | "fullWidth"> & {
149
149
  variant: "primary";
150
150
  size: "medium";
151
151
  fullWidth: false;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The useHold hook freezes a value at its last non-exiting state while `isExiting` is true, so
3
+ * that content (e.g. inside a closing drawer) can keep rendering its last known value while an
4
+ * exit animation plays, instead of flashing to a new/empty value mid-animation.
5
+ *
6
+ * It is a pure value-holding primitive: it has no knowledge of animation duration and does not
7
+ * debounce or delay anything. As soon as `isExiting` flips back to `false`, the live `value` is
8
+ * returned immediately.
9
+ *
10
+ * @example
11
+ * const heldValue = useHold(value, isExiting);
12
+ */
13
+ export declare const useHold: <TValue>(value: TValue, isExiting: boolean) => TValue;
package/src/index.d.ts CHANGED
@@ -138,6 +138,7 @@ export * from "./hooks/useDebounce";
138
138
  export * from "./hooks/useDevicePixelRatio";
139
139
  export * from "./hooks/useElevatedReducer";
140
140
  export * from "./hooks/useElevatedState";
141
+ export * from "./hooks/useHold";
141
142
  export * from "./hooks/useHover";
142
143
  export * from "./hooks/useInfiniteScroll";
143
144
  export * from "./hooks/useIsFirstRender";