@trackunit/react-components 0.1.198 → 0.1.200

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
@@ -2865,6 +2865,19 @@ const getWindowSize = () => {
2865
2865
  }
2866
2866
  };
2867
2867
 
2868
+ /**
2869
+ * A useRef that updates its given value whenever it changes.
2870
+ *
2871
+ * @returns {boolean} Returns true if it is the first render, false otherwise.
2872
+ */
2873
+ const useSelfUpdatingRef = (initialState) => {
2874
+ const stateRef = React.useRef(initialState);
2875
+ React.useEffect(() => {
2876
+ stateRef.current = initialState;
2877
+ }, [initialState]);
2878
+ return stateRef;
2879
+ };
2880
+
2868
2881
  /**
2869
2882
  * Returns a callback that will be called when the visibility state of the document changes.
2870
2883
  */
@@ -2966,5 +2979,6 @@ exports.useOverflowItems = useOverflowItems;
2966
2979
  exports.usePopoverContext = usePopoverContext;
2967
2980
  exports.usePrompt = usePrompt;
2968
2981
  exports.useResize = useResize;
2982
+ exports.useSelfUpdatingRef = useSelfUpdatingRef;
2969
2983
  exports.useTimeout = useTimeout;
2970
2984
  exports.useVisibilityChange = useVisibilityChange;
package/index.esm.js CHANGED
@@ -2836,6 +2836,19 @@ const getWindowSize = () => {
2836
2836
  }
2837
2837
  };
2838
2838
 
2839
+ /**
2840
+ * A useRef that updates its given value whenever it changes.
2841
+ *
2842
+ * @returns {boolean} Returns true if it is the first render, false otherwise.
2843
+ */
2844
+ const useSelfUpdatingRef = (initialState) => {
2845
+ const stateRef = useRef(initialState);
2846
+ useEffect(() => {
2847
+ stateRef.current = initialState;
2848
+ }, [initialState]);
2849
+ return stateRef;
2850
+ };
2851
+
2839
2852
  /**
2840
2853
  * Returns a callback that will be called when the visibility state of the document changes.
2841
2854
  */
@@ -2853,4 +2866,4 @@ const useVisibilityChange = ({ onChange, targetState = "hidden" }) => {
2853
2866
  }, [onChange, targetState]);
2854
2867
  };
2855
2868
 
2856
- export { Alert, Badge, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CopyableText, DayPicker, DayPickerPopover, DayRangePicker, Drawer, EmptyState, ExternalLink, Heading, Icon, IconButton, Indicator, MenuItem, MenuList, Modal, ModalBackdrop, MoreMenu, PackageNameStoryComponent, PageHeader, Pagination, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text, Timeline, TimelineElement, Tip, Tooltip, ValueBar, WidgetBody, cvaButton, cvaButtonSpinner, cvaClickable, cvaIconButtonContainer, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemSuffix, docs, getDevicePixelRatio, getValueBarColorByValue, iconColorNames, iconPalette, setLocalStorage, useClickOutside, useContainerProps, useContinuousTimeout, useDebounce, useDevicePixelRatio, useGeometry, useHover, useIsFirstRender, useIsFullscreen, useIsTextCutOff, useLocalStorage, useLocalStorageReducer, useModal, useOptionallyElevatedState, useOverflowItems, usePopoverContext, usePrompt, useResize, useTimeout, useVisibilityChange };
2869
+ export { Alert, Badge, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CopyableText, DayPicker, DayPickerPopover, DayRangePicker, Drawer, EmptyState, ExternalLink, Heading, Icon, IconButton, Indicator, MenuItem, MenuList, Modal, ModalBackdrop, MoreMenu, PackageNameStoryComponent, PageHeader, Pagination, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text, Timeline, TimelineElement, Tip, Tooltip, ValueBar, WidgetBody, cvaButton, cvaButtonSpinner, cvaClickable, cvaIconButtonContainer, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemSuffix, docs, getDevicePixelRatio, getValueBarColorByValue, iconColorNames, iconPalette, setLocalStorage, useClickOutside, useContainerProps, useContinuousTimeout, useDebounce, useDevicePixelRatio, useGeometry, useHover, useIsFirstRender, useIsFullscreen, useIsTextCutOff, useLocalStorage, useLocalStorageReducer, useModal, useOptionallyElevatedState, useOverflowItems, usePopoverContext, usePrompt, useResize, useSelfUpdatingRef, useTimeout, useVisibilityChange };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.1.198",
3
+ "version": "0.1.200",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -12,5 +12,6 @@ export * from "./useIsFullScreen";
12
12
  export * from "./useIsTextCutOff";
13
13
  export * from "./useOptionallyElevatedState";
14
14
  export * from "./useResize";
15
+ export * from "./useSelfUpdatingRef";
15
16
  export * from "./useTimeout";
16
17
  export * from "./useVisibilityChange";
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * A useRef that updates its given value whenever it changes.
4
+ *
5
+ * @returns {boolean} Returns true if it is the first render, false otherwise.
6
+ */
7
+ export declare const useSelfUpdatingRef: <T>(initialState: T) => import("react").MutableRefObject<T>;