@trackunit/react-components 1.0.4 → 1.0.7
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
|
@@ -1135,6 +1135,18 @@ function getDevicePixelRatio(options) {
|
|
|
1135
1135
|
return Math.min(Math.max(1, round ? Math.floor(dpr) : dpr), maxDpr);
|
|
1136
1136
|
}
|
|
1137
1137
|
|
|
1138
|
+
/**
|
|
1139
|
+
* Use this hook if you want to optionally elevate the state of a component.
|
|
1140
|
+
* Useful when you want to optionally be able to control the state of a component
|
|
1141
|
+
* from a parent componentbut keep the simplicity of not having to.
|
|
1142
|
+
*
|
|
1143
|
+
* If no custom state is provided, the fallback state will be used and it works like a normal useState hook.
|
|
1144
|
+
*/
|
|
1145
|
+
const useElevatedState = (initialState, customState) => {
|
|
1146
|
+
const fallbackState = React.useState(initialState);
|
|
1147
|
+
return customState !== null && customState !== void 0 ? customState : fallbackState;
|
|
1148
|
+
};
|
|
1149
|
+
|
|
1138
1150
|
/**
|
|
1139
1151
|
* Custom hook to get the geometry of an element.
|
|
1140
1152
|
* Size and position of the element relative to the viewport.
|
|
@@ -1151,9 +1163,8 @@ const useGeometry = (ref) => {
|
|
|
1151
1163
|
y: 0,
|
|
1152
1164
|
});
|
|
1153
1165
|
const resizeObserver = React.useRef(null);
|
|
1154
|
-
const refCurrent = ref.current;
|
|
1155
1166
|
React.useEffect(() => {
|
|
1156
|
-
if (!
|
|
1167
|
+
if (!ref.current) {
|
|
1157
1168
|
return;
|
|
1158
1169
|
}
|
|
1159
1170
|
if (!resizeObserver.current) {
|
|
@@ -1173,13 +1184,14 @@ const useGeometry = (ref) => {
|
|
|
1173
1184
|
}
|
|
1174
1185
|
});
|
|
1175
1186
|
}
|
|
1176
|
-
resizeObserver.current.observe(
|
|
1187
|
+
resizeObserver.current.observe(ref.current);
|
|
1177
1188
|
return () => {
|
|
1178
1189
|
if (resizeObserver.current) {
|
|
1179
1190
|
resizeObserver.current.disconnect();
|
|
1180
1191
|
}
|
|
1181
1192
|
};
|
|
1182
|
-
|
|
1193
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1194
|
+
}, [ref.current]);
|
|
1183
1195
|
return geometry;
|
|
1184
1196
|
};
|
|
1185
1197
|
|
|
@@ -1251,18 +1263,6 @@ const useIsTextCutOff = (element) => {
|
|
|
1251
1263
|
return isTextCutOff;
|
|
1252
1264
|
};
|
|
1253
1265
|
|
|
1254
|
-
/**
|
|
1255
|
-
* Use this hook if you want to optionally elevate the state of a component.
|
|
1256
|
-
* Useful when you want to optionally be able to control the state of a component
|
|
1257
|
-
* from a parent componentbut keep the simplicity of not having to.
|
|
1258
|
-
*
|
|
1259
|
-
* If no custom state is provided, the fallback state will be used and it works like a normal useState hook.
|
|
1260
|
-
*/
|
|
1261
|
-
const useOptionallyElevatedState = (initialState, customState) => {
|
|
1262
|
-
const fallbackState = React.useState(initialState);
|
|
1263
|
-
return customState !== null && customState !== void 0 ? customState : fallbackState;
|
|
1264
|
-
};
|
|
1265
|
-
|
|
1266
1266
|
/**
|
|
1267
1267
|
* Custom hook to handle window resize events and provide the current window size.
|
|
1268
1268
|
*
|
|
@@ -1660,8 +1660,8 @@ const Card = ({ children, onClick, fullHeight = false, onMouseEnter, onMouseLeav
|
|
|
1660
1660
|
* @param {CardBodyProps} props - The props for the CardBody component
|
|
1661
1661
|
* @returns {JSX.Element} CardBody component
|
|
1662
1662
|
*/
|
|
1663
|
-
const CardBody = ({ density = "auto", children, dataTestId, className, disableGap, id }) => {
|
|
1664
|
-
return (jsxRuntime.jsx("div", { className: cvaCardBodyDensityContainer({ density, disableGap, className }), "data-testid": dataTestId, id: id, children: children }));
|
|
1663
|
+
const CardBody = ({ density = "auto", children, dataTestId, className, direction, disableGap, id, }) => {
|
|
1664
|
+
return (jsxRuntime.jsx("div", { className: cvaCardBodyDensityContainer({ density, disableGap, className, direction }), "data-testid": dataTestId, id: id, children: children }));
|
|
1665
1665
|
};
|
|
1666
1666
|
|
|
1667
1667
|
/**
|
|
@@ -4965,12 +4965,12 @@ exports.useContainerBreakpoints = useContainerBreakpoints;
|
|
|
4965
4965
|
exports.useContinuousTimeout = useContinuousTimeout;
|
|
4966
4966
|
exports.useDebounce = useDebounce;
|
|
4967
4967
|
exports.useDevicePixelRatio = useDevicePixelRatio;
|
|
4968
|
+
exports.useElevatedState = useElevatedState;
|
|
4968
4969
|
exports.useGeometry = useGeometry;
|
|
4969
4970
|
exports.useHover = useHover;
|
|
4970
4971
|
exports.useIsFirstRender = useIsFirstRender;
|
|
4971
4972
|
exports.useIsFullscreen = useIsFullscreen;
|
|
4972
4973
|
exports.useIsTextCutOff = useIsTextCutOff;
|
|
4973
|
-
exports.useOptionallyElevatedState = useOptionallyElevatedState;
|
|
4974
4974
|
exports.useOverflowItems = useOverflowItems;
|
|
4975
4975
|
exports.usePopoverContext = usePopoverContext;
|
|
4976
4976
|
exports.usePrompt = usePrompt;
|
package/index.esm.js
CHANGED
|
@@ -1115,6 +1115,18 @@ function getDevicePixelRatio(options) {
|
|
|
1115
1115
|
return Math.min(Math.max(1, round ? Math.floor(dpr) : dpr), maxDpr);
|
|
1116
1116
|
}
|
|
1117
1117
|
|
|
1118
|
+
/**
|
|
1119
|
+
* Use this hook if you want to optionally elevate the state of a component.
|
|
1120
|
+
* Useful when you want to optionally be able to control the state of a component
|
|
1121
|
+
* from a parent componentbut keep the simplicity of not having to.
|
|
1122
|
+
*
|
|
1123
|
+
* If no custom state is provided, the fallback state will be used and it works like a normal useState hook.
|
|
1124
|
+
*/
|
|
1125
|
+
const useElevatedState = (initialState, customState) => {
|
|
1126
|
+
const fallbackState = useState(initialState);
|
|
1127
|
+
return customState !== null && customState !== void 0 ? customState : fallbackState;
|
|
1128
|
+
};
|
|
1129
|
+
|
|
1118
1130
|
/**
|
|
1119
1131
|
* Custom hook to get the geometry of an element.
|
|
1120
1132
|
* Size and position of the element relative to the viewport.
|
|
@@ -1131,9 +1143,8 @@ const useGeometry = (ref) => {
|
|
|
1131
1143
|
y: 0,
|
|
1132
1144
|
});
|
|
1133
1145
|
const resizeObserver = useRef(null);
|
|
1134
|
-
const refCurrent = ref.current;
|
|
1135
1146
|
useEffect(() => {
|
|
1136
|
-
if (!
|
|
1147
|
+
if (!ref.current) {
|
|
1137
1148
|
return;
|
|
1138
1149
|
}
|
|
1139
1150
|
if (!resizeObserver.current) {
|
|
@@ -1153,13 +1164,14 @@ const useGeometry = (ref) => {
|
|
|
1153
1164
|
}
|
|
1154
1165
|
});
|
|
1155
1166
|
}
|
|
1156
|
-
resizeObserver.current.observe(
|
|
1167
|
+
resizeObserver.current.observe(ref.current);
|
|
1157
1168
|
return () => {
|
|
1158
1169
|
if (resizeObserver.current) {
|
|
1159
1170
|
resizeObserver.current.disconnect();
|
|
1160
1171
|
}
|
|
1161
1172
|
};
|
|
1162
|
-
|
|
1173
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1174
|
+
}, [ref.current]);
|
|
1163
1175
|
return geometry;
|
|
1164
1176
|
};
|
|
1165
1177
|
|
|
@@ -1231,18 +1243,6 @@ const useIsTextCutOff = (element) => {
|
|
|
1231
1243
|
return isTextCutOff;
|
|
1232
1244
|
};
|
|
1233
1245
|
|
|
1234
|
-
/**
|
|
1235
|
-
* Use this hook if you want to optionally elevate the state of a component.
|
|
1236
|
-
* Useful when you want to optionally be able to control the state of a component
|
|
1237
|
-
* from a parent componentbut keep the simplicity of not having to.
|
|
1238
|
-
*
|
|
1239
|
-
* If no custom state is provided, the fallback state will be used and it works like a normal useState hook.
|
|
1240
|
-
*/
|
|
1241
|
-
const useOptionallyElevatedState = (initialState, customState) => {
|
|
1242
|
-
const fallbackState = useState(initialState);
|
|
1243
|
-
return customState !== null && customState !== void 0 ? customState : fallbackState;
|
|
1244
|
-
};
|
|
1245
|
-
|
|
1246
1246
|
/**
|
|
1247
1247
|
* Custom hook to handle window resize events and provide the current window size.
|
|
1248
1248
|
*
|
|
@@ -1640,8 +1640,8 @@ const Card = ({ children, onClick, fullHeight = false, onMouseEnter, onMouseLeav
|
|
|
1640
1640
|
* @param {CardBodyProps} props - The props for the CardBody component
|
|
1641
1641
|
* @returns {JSX.Element} CardBody component
|
|
1642
1642
|
*/
|
|
1643
|
-
const CardBody = ({ density = "auto", children, dataTestId, className, disableGap, id }) => {
|
|
1644
|
-
return (jsx("div", { className: cvaCardBodyDensityContainer({ density, disableGap, className }), "data-testid": dataTestId, id: id, children: children }));
|
|
1643
|
+
const CardBody = ({ density = "auto", children, dataTestId, className, direction, disableGap, id, }) => {
|
|
1644
|
+
return (jsx("div", { className: cvaCardBodyDensityContainer({ density, disableGap, className, direction }), "data-testid": dataTestId, id: id, children: children }));
|
|
1645
1645
|
};
|
|
1646
1646
|
|
|
1647
1647
|
/**
|
|
@@ -4862,4 +4862,4 @@ const cvaClickable = cvaMerge([
|
|
|
4862
4862
|
},
|
|
4863
4863
|
});
|
|
4864
4864
|
|
|
4865
|
-
export { Alert, Badge, Breadcrumb, BreadcrumbContainer, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CompletionStatusIndicator, CopyableText, EmptyState, EmptyValue, ExternalLink, Heading, Icon, IconButton, Indicator, KPICard, MenuDivider, MenuItem, MenuList, MoreMenu, Notice, PackageNameStoryComponent, Page, PageContent, PageHeader, Pagination, Polygon, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Portal, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tab, TabContent, TabList, Tabs, Tag, Text, ToggleGroup, ToggleItem, Tooltip, ValueBar, VirtualizedList, WidgetBody, cvaButton, cvaButtonPrefixSuffix, cvaButtonSpinner, cvaButtonSpinnerContainer, cvaClickable, cvaIconButton, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaInteractableItem, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemStyle, cvaMenuItemSuffix, docs, getDevicePixelRatio, getValueBarColorByValue, iconColorNames, iconPalette, useClickOutside, useContainerBreakpoints, useContinuousTimeout, useDebounce, useDevicePixelRatio, useGeometry, useHover, useIsFirstRender, useIsFullscreen, useIsTextCutOff,
|
|
4865
|
+
export { Alert, Badge, Breadcrumb, BreadcrumbContainer, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CompletionStatusIndicator, CopyableText, EmptyState, EmptyValue, ExternalLink, Heading, Icon, IconButton, Indicator, KPICard, MenuDivider, MenuItem, MenuList, MoreMenu, Notice, PackageNameStoryComponent, Page, PageContent, PageHeader, Pagination, Polygon, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Portal, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tab, TabContent, TabList, Tabs, Tag, Text, ToggleGroup, ToggleItem, Tooltip, ValueBar, VirtualizedList, WidgetBody, cvaButton, cvaButtonPrefixSuffix, cvaButtonSpinner, cvaButtonSpinnerContainer, cvaClickable, cvaIconButton, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaInteractableItem, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemStyle, cvaMenuItemSuffix, docs, getDevicePixelRatio, getValueBarColorByValue, iconColorNames, iconPalette, useClickOutside, useContainerBreakpoints, useContinuousTimeout, useDebounce, useDevicePixelRatio, useElevatedState, useGeometry, useHover, useIsFirstRender, useIsFullscreen, useIsTextCutOff, useOverflowItems, usePopoverContext, usePrompt, useResize, useScrollDetection, useSelfUpdatingRef, useTimeout, useViewportBreakpoints, useWindowActivity };
|
package/package.json
CHANGED
|
@@ -5,6 +5,10 @@ export interface CardBodyProps extends CommonProps {
|
|
|
5
5
|
* Sets gap, padding and margin.
|
|
6
6
|
*/
|
|
7
7
|
density?: Density;
|
|
8
|
+
/**
|
|
9
|
+
* Sets flex direction
|
|
10
|
+
*/
|
|
11
|
+
direction?: "row" | "row-reverse" | "column" | "column-reverse";
|
|
8
12
|
/**
|
|
9
13
|
* Set gap to be 0px (not preferable)
|
|
10
14
|
*/
|
|
@@ -26,4 +30,4 @@ export interface CardBodyProps extends CommonProps {
|
|
|
26
30
|
* @param {CardBodyProps} props - The props for the CardBody component
|
|
27
31
|
* @returns {JSX.Element} CardBody component
|
|
28
32
|
*/
|
|
29
|
-
export declare const CardBody: ({ density, children, dataTestId, className, disableGap, id }: CardBodyProps) => import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export declare const CardBody: ({ density, children, dataTestId, className, direction, disableGap, id, }: CardBodyProps) => import("react/jsx-runtime").JSX.Element;
|
package/src/hooks/index.d.ts
CHANGED
|
@@ -3,12 +3,12 @@ export * from "./useContainerBreakpoints";
|
|
|
3
3
|
export * from "./useContinuousTimeout";
|
|
4
4
|
export * from "./useDebounce";
|
|
5
5
|
export * from "./useDevicePixelRatio";
|
|
6
|
+
export * from "./useElevatedState";
|
|
6
7
|
export * from "./useGeometry";
|
|
7
8
|
export * from "./useHover";
|
|
8
9
|
export * from "./useIsFirstRender";
|
|
9
10
|
export * from "./useIsFullScreen";
|
|
10
11
|
export * from "./useIsTextCutOff";
|
|
11
|
-
export * from "./useOptionallyElevatedState";
|
|
12
12
|
export * from "./useResize";
|
|
13
13
|
export * from "./useScrollDetection";
|
|
14
14
|
export * from "./useSelfUpdatingRef";
|
|
@@ -6,4 +6,4 @@ import { Dispatch, SetStateAction } from "react";
|
|
|
6
6
|
*
|
|
7
7
|
* If no custom state is provided, the fallback state will be used and it works like a normal useState hook.
|
|
8
8
|
*/
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const useElevatedState: <TState>(initialState: TState, customState?: [TState, Dispatch<SetStateAction<TState>>]) => [TState, Dispatch<SetStateAction<TState>>];
|