@trackunit/react-components 0.1.187 → 0.1.189
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 +14 -1
- package/index.esm.js +14 -2
- package/package.json +2 -2
- package/src/hooks/index.d.ts +1 -0
- package/src/hooks/useOptionallyElevatedState.d.ts +9 -0
package/index.cjs.js
CHANGED
|
@@ -39231,6 +39231,18 @@ const useIsTextCutOff = (element) => {
|
|
|
39231
39231
|
return isTextCutOff;
|
|
39232
39232
|
};
|
|
39233
39233
|
|
|
39234
|
+
/**
|
|
39235
|
+
* Use this hook if you want to optionally elevate the state of a component.
|
|
39236
|
+
* Useful when you want to optionally be able to control the state of a component
|
|
39237
|
+
* from a parent componentbut keep the simplicity of not having to.
|
|
39238
|
+
*
|
|
39239
|
+
* If no custom state is provided, the fallback state will be used and it works like a normal useState hook.
|
|
39240
|
+
*/
|
|
39241
|
+
const useOptionallyElevatedState = (initialState, customState) => {
|
|
39242
|
+
const fallbackState = React.useState(initialState);
|
|
39243
|
+
return customState !== null && customState !== void 0 ? customState : fallbackState;
|
|
39244
|
+
};
|
|
39245
|
+
|
|
39234
39246
|
/**
|
|
39235
39247
|
* Custom hook to handle window resize events and provide the current window size.
|
|
39236
39248
|
*
|
|
@@ -39270,7 +39282,7 @@ const getWindowSize = () => {
|
|
|
39270
39282
|
/**
|
|
39271
39283
|
* Returns a callback that will be called when the visibility state of the document changes.
|
|
39272
39284
|
*/
|
|
39273
|
-
const useVisibilityChange = ({ onChange, targetState }) => {
|
|
39285
|
+
const useVisibilityChange = ({ onChange, targetState = "hidden" }) => {
|
|
39274
39286
|
React.useEffect(() => {
|
|
39275
39287
|
const handleVisibilityChange = () => {
|
|
39276
39288
|
if (document.visibilityState === targetState) {
|
|
@@ -39362,6 +39374,7 @@ exports.useIsTextCutOff = useIsTextCutOff;
|
|
|
39362
39374
|
exports.useLocalStorage = useLocalStorage;
|
|
39363
39375
|
exports.useLocalStorageReducer = useLocalStorageReducer;
|
|
39364
39376
|
exports.useModal = useModal;
|
|
39377
|
+
exports.useOptionallyElevatedState = useOptionallyElevatedState;
|
|
39365
39378
|
exports.usePopoverContext = usePopoverContext;
|
|
39366
39379
|
exports.usePrompt = usePrompt;
|
|
39367
39380
|
exports.useResize = useResize;
|
package/index.esm.js
CHANGED
|
@@ -39202,6 +39202,18 @@ const useIsTextCutOff = (element) => {
|
|
|
39202
39202
|
return isTextCutOff;
|
|
39203
39203
|
};
|
|
39204
39204
|
|
|
39205
|
+
/**
|
|
39206
|
+
* Use this hook if you want to optionally elevate the state of a component.
|
|
39207
|
+
* Useful when you want to optionally be able to control the state of a component
|
|
39208
|
+
* from a parent componentbut keep the simplicity of not having to.
|
|
39209
|
+
*
|
|
39210
|
+
* If no custom state is provided, the fallback state will be used and it works like a normal useState hook.
|
|
39211
|
+
*/
|
|
39212
|
+
const useOptionallyElevatedState = (initialState, customState) => {
|
|
39213
|
+
const fallbackState = useState(initialState);
|
|
39214
|
+
return customState !== null && customState !== void 0 ? customState : fallbackState;
|
|
39215
|
+
};
|
|
39216
|
+
|
|
39205
39217
|
/**
|
|
39206
39218
|
* Custom hook to handle window resize events and provide the current window size.
|
|
39207
39219
|
*
|
|
@@ -39241,7 +39253,7 @@ const getWindowSize = () => {
|
|
|
39241
39253
|
/**
|
|
39242
39254
|
* Returns a callback that will be called when the visibility state of the document changes.
|
|
39243
39255
|
*/
|
|
39244
|
-
const useVisibilityChange = ({ onChange, targetState }) => {
|
|
39256
|
+
const useVisibilityChange = ({ onChange, targetState = "hidden" }) => {
|
|
39245
39257
|
useEffect(() => {
|
|
39246
39258
|
const handleVisibilityChange = () => {
|
|
39247
39259
|
if (document.visibilityState === targetState) {
|
|
@@ -39255,4 +39267,4 @@ const useVisibilityChange = ({ onChange, targetState }) => {
|
|
|
39255
39267
|
}, [onChange, targetState]);
|
|
39256
39268
|
};
|
|
39257
39269
|
|
|
39258
|
-
export { Alert, Badge, Button$1 as 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, useHover, useIsFirstRender, useIsFullscreen, useIsTextCutOff, useLocalStorage, useLocalStorageReducer, useModal, usePopoverContext, usePrompt, useResize, useTimeout, useVisibilityChange };
|
|
39270
|
+
export { Alert, Badge, Button$1 as 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, useHover, useIsFirstRender, useIsFullscreen, useIsTextCutOff, useLocalStorage, useLocalStorageReducer, useModal, useOptionallyElevatedState, usePopoverContext, usePrompt, useResize, useTimeout, useVisibilityChange };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-components",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.189",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"@floating-ui/react": "0.25.4",
|
|
11
11
|
"@trackunit/css-class-variance-utilities": "0.0.15",
|
|
12
12
|
"@trackunit/css-core": "0.0.99",
|
|
13
|
-
"@trackunit/shared-utils": "0.0.
|
|
13
|
+
"@trackunit/shared-utils": "0.0.15",
|
|
14
14
|
"@trackunit/ui-design-tokens": "0.0.79",
|
|
15
15
|
"@trackunit/ui-icons": "0.0.78",
|
|
16
16
|
"date-fns": "2.29.3",
|
package/src/hooks/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from "./useHover";
|
|
|
9
9
|
export * from "./useIsFirstRender";
|
|
10
10
|
export * from "./useIsFullScreen";
|
|
11
11
|
export * from "./useIsTextCutOff";
|
|
12
|
+
export * from "./useOptionallyElevatedState";
|
|
12
13
|
export * from "./useResize";
|
|
13
14
|
export * from "./useTimeout";
|
|
14
15
|
export * from "./useVisibilityChange";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Use this hook if you want to optionally elevate the state of a component.
|
|
4
|
+
* Useful when you want to optionally be able to control the state of a component
|
|
5
|
+
* from a parent componentbut keep the simplicity of not having to.
|
|
6
|
+
*
|
|
7
|
+
* If no custom state is provided, the fallback state will be used and it works like a normal useState hook.
|
|
8
|
+
*/
|
|
9
|
+
export declare const useOptionallyElevatedState: <T>(initialState: T, customState?: [T, Dispatch<SetStateAction<T>>] | undefined) => [T, Dispatch<SetStateAction<T>>];
|