@trackunit/react-components 0.1.147 → 0.1.149
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
|
@@ -181,6 +181,7 @@ const cvaButton = cssClassVarianceUtilities.cvaMerge([
|
|
|
181
181
|
"text-sm",
|
|
182
182
|
"font-medium",
|
|
183
183
|
"align-middle",
|
|
184
|
+
"h-min",
|
|
184
185
|
], {
|
|
185
186
|
variants: {
|
|
186
187
|
color: {
|
|
@@ -19179,6 +19180,20 @@ const MenuList = (_a) => {
|
|
|
19179
19180
|
return (jsxRuntime.jsx("div", { "data-testid": dataTestId, className: cvaMenuList({ stickyHeader: withStickyHeader, className }), tabIndex: 0, role: "list", children: React.Children.map(childrenArr, (menuItem, index) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [menuItem, showDivider && !isLastItem(index) && jsxRuntime.jsx("hr", { className: cvaMenuListDivider() })] }))) }));
|
|
19180
19181
|
};
|
|
19181
19182
|
|
|
19183
|
+
/**
|
|
19184
|
+
* Sets a value in the local storage with the specified key.
|
|
19185
|
+
* Thin wrapper around localStorage.setItem() that is slightly more type safe
|
|
19186
|
+
* Stringifies value automatically.
|
|
19187
|
+
* Useful if you for some reason can't use the useLocalStorage hook for React lifecycle reasons
|
|
19188
|
+
*
|
|
19189
|
+
* @template TValue - The type of value to be stored.
|
|
19190
|
+
* @param {string} key - The key under which to store the value.
|
|
19191
|
+
* @param {TValue} value - The value to store in the local storage.
|
|
19192
|
+
*/
|
|
19193
|
+
const setLocalStorage = (key, value) => {
|
|
19194
|
+
localStorage.setItem(key, JSON.stringify(value));
|
|
19195
|
+
};
|
|
19196
|
+
|
|
19182
19197
|
/**
|
|
19183
19198
|
* Validates the state object using a Zod schema.
|
|
19184
19199
|
*
|
|
@@ -36458,8 +36473,7 @@ const useLocalStorageEffect = ({ key, state, defaultState, schema, onValidationF
|
|
|
36458
36473
|
onValidationFailed === null || onValidationFailed === void 0 ? void 0 : onValidationFailed(error);
|
|
36459
36474
|
},
|
|
36460
36475
|
onValidationSuccessful: () => {
|
|
36461
|
-
|
|
36462
|
-
localStorage.setItem(key, stringifiedState);
|
|
36476
|
+
setLocalStorage(key, state);
|
|
36463
36477
|
onValidationSuccessful === null || onValidationSuccessful === void 0 ? void 0 : onValidationSuccessful();
|
|
36464
36478
|
},
|
|
36465
36479
|
});
|
|
@@ -36728,6 +36742,23 @@ const useTimeout = ({ onTimeout, duration }) => {
|
|
|
36728
36742
|
return [startTimeout, stopTimeout];
|
|
36729
36743
|
};
|
|
36730
36744
|
|
|
36745
|
+
/**
|
|
36746
|
+
* Returns a callback that will be called when the visibility state of the document changes.
|
|
36747
|
+
*/
|
|
36748
|
+
const useVisibilityChange = ({ onChange, targetState }) => {
|
|
36749
|
+
React.useEffect(() => {
|
|
36750
|
+
const handleVisibilityChange = () => {
|
|
36751
|
+
if (document.visibilityState === targetState) {
|
|
36752
|
+
onChange();
|
|
36753
|
+
}
|
|
36754
|
+
};
|
|
36755
|
+
window.addEventListener("visibilitychange", handleVisibilityChange);
|
|
36756
|
+
return () => {
|
|
36757
|
+
window.removeEventListener("visibilitychange", handleVisibilityChange);
|
|
36758
|
+
};
|
|
36759
|
+
}, [onChange, targetState]);
|
|
36760
|
+
};
|
|
36761
|
+
|
|
36731
36762
|
const cvaMoreMenu = cssClassVarianceUtilities.cvaMerge(["p-4"]);
|
|
36732
36763
|
|
|
36733
36764
|
/**
|
|
@@ -39062,6 +39093,7 @@ exports.cvaMenuItemSuffix = cvaMenuItemSuffix;
|
|
|
39062
39093
|
exports.docs = docs;
|
|
39063
39094
|
exports.getDevicePixelRatio = getDevicePixelRatio;
|
|
39064
39095
|
exports.getValueBarColorByValue = getValueBarColorByValue;
|
|
39096
|
+
exports.setLocalStorage = setLocalStorage;
|
|
39065
39097
|
exports.useClickOutside = useClickOutside;
|
|
39066
39098
|
exports.useContainerProps = useContainerProps;
|
|
39067
39099
|
exports.useDebounce = useDebounce;
|
|
@@ -39075,3 +39107,4 @@ exports.usePopoverContext = usePopoverContext;
|
|
|
39075
39107
|
exports.usePrompt = usePrompt;
|
|
39076
39108
|
exports.useResize = useResize;
|
|
39077
39109
|
exports.useTimeout = useTimeout;
|
|
39110
|
+
exports.useVisibilityChange = useVisibilityChange;
|
package/index.esm.js
CHANGED
|
@@ -154,6 +154,7 @@ const cvaButton = cvaMerge([
|
|
|
154
154
|
"text-sm",
|
|
155
155
|
"font-medium",
|
|
156
156
|
"align-middle",
|
|
157
|
+
"h-min",
|
|
157
158
|
], {
|
|
158
159
|
variants: {
|
|
159
160
|
color: {
|
|
@@ -19152,6 +19153,20 @@ const MenuList = (_a) => {
|
|
|
19152
19153
|
return (jsx("div", { "data-testid": dataTestId, className: cvaMenuList({ stickyHeader: withStickyHeader, className }), tabIndex: 0, role: "list", children: Children.map(childrenArr, (menuItem, index) => (jsxs(Fragment, { children: [menuItem, showDivider && !isLastItem(index) && jsx("hr", { className: cvaMenuListDivider() })] }))) }));
|
|
19153
19154
|
};
|
|
19154
19155
|
|
|
19156
|
+
/**
|
|
19157
|
+
* Sets a value in the local storage with the specified key.
|
|
19158
|
+
* Thin wrapper around localStorage.setItem() that is slightly more type safe
|
|
19159
|
+
* Stringifies value automatically.
|
|
19160
|
+
* Useful if you for some reason can't use the useLocalStorage hook for React lifecycle reasons
|
|
19161
|
+
*
|
|
19162
|
+
* @template TValue - The type of value to be stored.
|
|
19163
|
+
* @param {string} key - The key under which to store the value.
|
|
19164
|
+
* @param {TValue} value - The value to store in the local storage.
|
|
19165
|
+
*/
|
|
19166
|
+
const setLocalStorage = (key, value) => {
|
|
19167
|
+
localStorage.setItem(key, JSON.stringify(value));
|
|
19168
|
+
};
|
|
19169
|
+
|
|
19155
19170
|
/**
|
|
19156
19171
|
* Validates the state object using a Zod schema.
|
|
19157
19172
|
*
|
|
@@ -36431,8 +36446,7 @@ const useLocalStorageEffect = ({ key, state, defaultState, schema, onValidationF
|
|
|
36431
36446
|
onValidationFailed === null || onValidationFailed === void 0 ? void 0 : onValidationFailed(error);
|
|
36432
36447
|
},
|
|
36433
36448
|
onValidationSuccessful: () => {
|
|
36434
|
-
|
|
36435
|
-
localStorage.setItem(key, stringifiedState);
|
|
36449
|
+
setLocalStorage(key, state);
|
|
36436
36450
|
onValidationSuccessful === null || onValidationSuccessful === void 0 ? void 0 : onValidationSuccessful();
|
|
36437
36451
|
},
|
|
36438
36452
|
});
|
|
@@ -36701,6 +36715,23 @@ const useTimeout = ({ onTimeout, duration }) => {
|
|
|
36701
36715
|
return [startTimeout, stopTimeout];
|
|
36702
36716
|
};
|
|
36703
36717
|
|
|
36718
|
+
/**
|
|
36719
|
+
* Returns a callback that will be called when the visibility state of the document changes.
|
|
36720
|
+
*/
|
|
36721
|
+
const useVisibilityChange = ({ onChange, targetState }) => {
|
|
36722
|
+
useEffect(() => {
|
|
36723
|
+
const handleVisibilityChange = () => {
|
|
36724
|
+
if (document.visibilityState === targetState) {
|
|
36725
|
+
onChange();
|
|
36726
|
+
}
|
|
36727
|
+
};
|
|
36728
|
+
window.addEventListener("visibilitychange", handleVisibilityChange);
|
|
36729
|
+
return () => {
|
|
36730
|
+
window.removeEventListener("visibilitychange", handleVisibilityChange);
|
|
36731
|
+
};
|
|
36732
|
+
}, [onChange, targetState]);
|
|
36733
|
+
};
|
|
36734
|
+
|
|
36704
36735
|
const cvaMoreMenu = cvaMerge(["p-4"]);
|
|
36705
36736
|
|
|
36706
36737
|
/**
|
|
@@ -38973,4 +39004,4 @@ const cvaClickable = cvaMerge([
|
|
|
38973
39004
|
},
|
|
38974
39005
|
});
|
|
38975
39006
|
|
|
38976
|
-
export { Alert, Badge, Button$1 as Button, Card, CardBody, CardFooter, CardHeader, Collapse, CopyableText, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, Drawer, EmptyState, ExternalLink, Heading, Icon, IconButton, Indicator, MenuItem, MenuList, Modal, ModalBackdrop, MoreMenu, PageHeader, Pagination, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text, Timeline, TimelineElement, Tip, Tooltip, ValueBar, cvaButton, cvaButtonSpinner, cvaClickable, cvaIconButtonContainer, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemSuffix, docs, getDevicePixelRatio, getValueBarColorByValue, useClickOutside, useContainerProps, useDebounce, useDevicePixelRatio, useHover, useIsFirstRender, useLocalStorage, useLocalStorageReducer, useModal, usePopoverContext, usePrompt, useResize, useTimeout };
|
|
39007
|
+
export { Alert, Badge, Button$1 as Button, Card, CardBody, CardFooter, CardHeader, Collapse, CopyableText, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, Drawer, EmptyState, ExternalLink, Heading, Icon, IconButton, Indicator, MenuItem, MenuList, Modal, ModalBackdrop, MoreMenu, PageHeader, Pagination, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text, Timeline, TimelineElement, Tip, Tooltip, ValueBar, cvaButton, cvaButtonSpinner, cvaClickable, cvaIconButtonContainer, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemSuffix, docs, getDevicePixelRatio, getValueBarColorByValue, setLocalStorage, useClickOutside, useContainerProps, useDebounce, useDevicePixelRatio, useHover, useIsFirstRender, useLocalStorage, useLocalStorageReducer, useModal, usePopoverContext, usePrompt, useResize, useTimeout, useVisibilityChange };
|
package/package.json
CHANGED
package/src/hooks/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from "./localStorage/setLocalStorage";
|
|
1
2
|
export * from "./localStorage/useLocalStorage";
|
|
2
3
|
export * from "./localStorage/useLocalStorageReducer";
|
|
3
4
|
export * from "./useClickOutside";
|
|
@@ -7,3 +8,4 @@ export * from "./useHover";
|
|
|
7
8
|
export * from "./useIsFirstRender";
|
|
8
9
|
export * from "./useResize";
|
|
9
10
|
export * from "./useTimeout";
|
|
11
|
+
export * from "./useVisibilityChange";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets a value in the local storage with the specified key.
|
|
3
|
+
* Thin wrapper around localStorage.setItem() that is slightly more type safe
|
|
4
|
+
* Stringifies value automatically.
|
|
5
|
+
* Useful if you for some reason can't use the useLocalStorage hook for React lifecycle reasons
|
|
6
|
+
*
|
|
7
|
+
* @template TValue - The type of value to be stored.
|
|
8
|
+
* @param {string} key - The key under which to store the value.
|
|
9
|
+
* @param {TValue} value - The value to store in the local storage.
|
|
10
|
+
*/
|
|
11
|
+
export declare const setLocalStorage: <TValue>(key: string, value: TValue) => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type VisibilityState = "hidden" | "visible";
|
|
2
|
+
interface VisibilityChangeOptions {
|
|
3
|
+
onChange: () => void;
|
|
4
|
+
targetState: VisibilityState;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Returns a callback that will be called when the visibility state of the document changes.
|
|
8
|
+
*/
|
|
9
|
+
export declare const useVisibilityChange: ({ onChange, targetState }: VisibilityChangeOptions) => void;
|
|
10
|
+
export default useVisibilityChange;
|