@trackunit/react-components 0.1.132 → 0.1.134

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 CHANGED
@@ -18868,8 +18868,20 @@ const SkeletonLines = React.memo(({ margin = "10px 0", lines = 1, height, width
18868
18868
  return jsxRuntime.jsx(jsxRuntime.Fragment, { children: skeletonLines });
18869
18869
  });
18870
18870
 
18871
- const containerStyles = cssClassVarianceUtilities.cvaMerge(["flex flex-col items-center gap-5 p-12 text-center justify-center h-full"]);
18872
- const textStyles = cssClassVarianceUtilities.cvaMerge(["flex flex-col items-center gap-2"]);
18871
+ const cvaContainerStyles = cssClassVarianceUtilities.cvaMerge([
18872
+ "flex",
18873
+ "flex-col",
18874
+ "items-center",
18875
+ "gap-5",
18876
+ "p-4",
18877
+ "sm:p-6",
18878
+ "md:p-12",
18879
+ "text-center",
18880
+ "justify-center",
18881
+ "h-full",
18882
+ ]);
18883
+ const cvaTextStyles = cssClassVarianceUtilities.cvaMerge(["flex", "flex-col", "items-center", "gap-2"]);
18884
+ const cvaImgStyles = cssClassVarianceUtilities.cvaMerge(["w-2/3", "min-w-[60px]", "max-w-[200px]"]);
18873
18885
 
18874
18886
  var WorkerWithSign = "8df3d27593b5fba4.svg";
18875
18887
 
@@ -18915,7 +18927,7 @@ const EmptyState = ({ title, description, altText, image, customImageSrc, action
18915
18927
  lazyLoadImage();
18916
18928
  }
18917
18929
  }, [customImageSrc, image]);
18918
- return (jsxRuntime.jsx("div", { className: `${containerStyles()} ${className}`, "data-testid": dataTestId !== null && dataTestId !== void 0 ? dataTestId : "empty-state", children: loading ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Spinner, { dataTestId: "spinner", size: "large", centering: "centered" }), jsxRuntime.jsx(SkeletonLines, { dataTestId: "skeleton-lines", width: 50 })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("img", { src: customImageSrc ? customImageSrc : imageSource, alt: altText }), jsxRuntime.jsxs("div", { className: textStyles(), children: [jsxRuntime.jsx(Heading, { variant: "secondary", children: title }), jsxRuntime.jsx(Text, { align: "center", children: description })] }), action] })) }));
18930
+ return (jsxRuntime.jsx("div", { className: `${cvaContainerStyles()} ${className}`, "data-testid": dataTestId !== null && dataTestId !== void 0 ? dataTestId : "empty-state", children: loading ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Spinner, { dataTestId: "spinner", size: "large", centering: "centered" }), jsxRuntime.jsx(SkeletonLines, { dataTestId: "skeleton-lines", width: 50 })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("img", { className: cvaImgStyles(), width: 200, height: 200, src: customImageSrc ? customImageSrc : imageSource, alt: altText }), jsxRuntime.jsxs("div", { className: cvaTextStyles(), children: [jsxRuntime.jsx(Heading, { variant: "secondary", children: title }), jsxRuntime.jsx(Text, { align: "center", children: description })] }), action] })) }));
18919
18931
  };
18920
18932
 
18921
18933
  /**
@@ -36470,7 +36482,7 @@ const useLocalStorageReducer = ({ key, defaultState, reducer, schema, onValidati
36470
36482
  * Custom hook to handle click outside events.
36471
36483
  *
36472
36484
  * @param {RefObject<HTMLElement> | Array<RefObject<HTMLElement>>} el - The reference(s) to the element(s) to watch for click outside events.
36473
- * @param {Object | Function} [options={}] - Configuration options or the click event handler if options are not provided.
36485
+ * @param {object | Function} [options={}] - Configuration options or the click event handler if options are not provided.
36474
36486
  * @param {boolean} [options.active=true] - Whether the click outside event listener should be active.
36475
36487
  * @param {Function} [onClick] - The event handler for the click outside event.
36476
36488
  */
@@ -36590,8 +36602,8 @@ function getDevicePixelRatio(options) {
36590
36602
  * The boolean will be true if the element is being hovered, and false if it is not.
36591
36603
  * Can be directionally debounced.
36592
36604
  *
36593
- * @param {ConditionalUseHoverProps} param0 The options
36594
- * @returns {Object} The object containing the onMouseEnter, onMouseLeave and hovering props
36605
+ * @param {UseHoverProps} param0 The options
36606
+ * @returns {object} The object containing the onMouseEnter, onMouseLeave and hovering props
36595
36607
  */
36596
36608
  const useHover = ({ debounced = false, delay = 100, direction = "out" } = { debounced: false }) => {
36597
36609
  const [hovering, setHovering] = React.useState(false);
@@ -37265,13 +37277,17 @@ function useConfirmExit(confirmExit, when = true) {
37265
37277
  */
37266
37278
  const usePrompt = (message, when = true) => {
37267
37279
  React.useEffect(() => {
37280
+ const onBeforeUnload = (event) => {
37281
+ // According to https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
37282
+ // preventDefault() should be called to indicate that the event was handled.
37283
+ event.preventDefault();
37284
+ return message;
37285
+ };
37268
37286
  if (when) {
37269
- window.onbeforeunload = function () {
37270
- return message;
37271
- };
37287
+ window.addEventListener("beforeunload", onBeforeUnload);
37272
37288
  }
37273
37289
  return () => {
37274
- window.onbeforeunload = null;
37290
+ window.removeEventListener("beforeunload", onBeforeUnload);
37275
37291
  };
37276
37292
  }, [message, when]);
37277
37293
  const confirmExit = React.useCallback(() => {
package/index.js CHANGED
@@ -18841,8 +18841,20 @@ const SkeletonLines = memo(({ margin = "10px 0", lines = 1, height, width = "100
18841
18841
  return jsx(Fragment, { children: skeletonLines });
18842
18842
  });
18843
18843
 
18844
- const containerStyles = cvaMerge(["flex flex-col items-center gap-5 p-12 text-center justify-center h-full"]);
18845
- const textStyles = cvaMerge(["flex flex-col items-center gap-2"]);
18844
+ const cvaContainerStyles = cvaMerge([
18845
+ "flex",
18846
+ "flex-col",
18847
+ "items-center",
18848
+ "gap-5",
18849
+ "p-4",
18850
+ "sm:p-6",
18851
+ "md:p-12",
18852
+ "text-center",
18853
+ "justify-center",
18854
+ "h-full",
18855
+ ]);
18856
+ const cvaTextStyles = cvaMerge(["flex", "flex-col", "items-center", "gap-2"]);
18857
+ const cvaImgStyles = cvaMerge(["w-2/3", "min-w-[60px]", "max-w-[200px]"]);
18846
18858
 
18847
18859
  var WorkerWithSign = "8df3d27593b5fba4.svg";
18848
18860
 
@@ -18888,7 +18900,7 @@ const EmptyState = ({ title, description, altText, image, customImageSrc, action
18888
18900
  lazyLoadImage();
18889
18901
  }
18890
18902
  }, [customImageSrc, image]);
18891
- return (jsx("div", { className: `${containerStyles()} ${className}`, "data-testid": dataTestId !== null && dataTestId !== void 0 ? dataTestId : "empty-state", children: loading ? (jsxs(Fragment, { children: [jsx(Spinner, { dataTestId: "spinner", size: "large", centering: "centered" }), jsx(SkeletonLines, { dataTestId: "skeleton-lines", width: 50 })] })) : (jsxs(Fragment, { children: [jsx("img", { src: customImageSrc ? customImageSrc : imageSource, alt: altText }), jsxs("div", { className: textStyles(), children: [jsx(Heading, { variant: "secondary", children: title }), jsx(Text, { align: "center", children: description })] }), action] })) }));
18903
+ return (jsx("div", { className: `${cvaContainerStyles()} ${className}`, "data-testid": dataTestId !== null && dataTestId !== void 0 ? dataTestId : "empty-state", children: loading ? (jsxs(Fragment, { children: [jsx(Spinner, { dataTestId: "spinner", size: "large", centering: "centered" }), jsx(SkeletonLines, { dataTestId: "skeleton-lines", width: 50 })] })) : (jsxs(Fragment, { children: [jsx("img", { className: cvaImgStyles(), width: 200, height: 200, src: customImageSrc ? customImageSrc : imageSource, alt: altText }), jsxs("div", { className: cvaTextStyles(), children: [jsx(Heading, { variant: "secondary", children: title }), jsx(Text, { align: "center", children: description })] }), action] })) }));
18892
18904
  };
18893
18905
 
18894
18906
  /**
@@ -36443,7 +36455,7 @@ const useLocalStorageReducer = ({ key, defaultState, reducer, schema, onValidati
36443
36455
  * Custom hook to handle click outside events.
36444
36456
  *
36445
36457
  * @param {RefObject<HTMLElement> | Array<RefObject<HTMLElement>>} el - The reference(s) to the element(s) to watch for click outside events.
36446
- * @param {Object | Function} [options={}] - Configuration options or the click event handler if options are not provided.
36458
+ * @param {object | Function} [options={}] - Configuration options or the click event handler if options are not provided.
36447
36459
  * @param {boolean} [options.active=true] - Whether the click outside event listener should be active.
36448
36460
  * @param {Function} [onClick] - The event handler for the click outside event.
36449
36461
  */
@@ -36563,8 +36575,8 @@ function getDevicePixelRatio(options) {
36563
36575
  * The boolean will be true if the element is being hovered, and false if it is not.
36564
36576
  * Can be directionally debounced.
36565
36577
  *
36566
- * @param {ConditionalUseHoverProps} param0 The options
36567
- * @returns {Object} The object containing the onMouseEnter, onMouseLeave and hovering props
36578
+ * @param {UseHoverProps} param0 The options
36579
+ * @returns {object} The object containing the onMouseEnter, onMouseLeave and hovering props
36568
36580
  */
36569
36581
  const useHover = ({ debounced = false, delay = 100, direction = "out" } = { debounced: false }) => {
36570
36582
  const [hovering, setHovering] = useState(false);
@@ -37238,13 +37250,17 @@ function useConfirmExit(confirmExit, when = true) {
37238
37250
  */
37239
37251
  const usePrompt = (message, when = true) => {
37240
37252
  useEffect(() => {
37253
+ const onBeforeUnload = (event) => {
37254
+ // According to https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
37255
+ // preventDefault() should be called to indicate that the event was handled.
37256
+ event.preventDefault();
37257
+ return message;
37258
+ };
37241
37259
  if (when) {
37242
- window.onbeforeunload = function () {
37243
- return message;
37244
- };
37260
+ window.addEventListener("beforeunload", onBeforeUnload);
37245
37261
  }
37246
37262
  return () => {
37247
- window.onbeforeunload = null;
37263
+ window.removeEventListener("beforeunload", onBeforeUnload);
37248
37264
  };
37249
37265
  }, [message, when]);
37250
37266
  const confirmExit = useCallback(() => {
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.1.132",
3
+ "version": "0.1.134",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
7
- "node": ">=16.x"
7
+ "node": ">=18.x"
8
8
  },
9
9
  "dependencies": {
10
10
  "@floating-ui/react": "0.22.2",
11
- "@trackunit/css-class-variance-utilities": "0.0.10",
12
- "@trackunit/css-core": "0.0.89",
13
- "@trackunit/tailwind-styled-components": "0.0.58",
14
- "@trackunit/ui-design-tokens": "0.0.73",
15
- "@trackunit/ui-icons": "0.0.70",
11
+ "@trackunit/css-class-variance-utilities": "0.0.11",
12
+ "@trackunit/css-core": "0.0.90",
13
+ "@trackunit/tailwind-styled-components": "0.0.59",
14
+ "@trackunit/ui-design-tokens": "0.0.74",
15
+ "@trackunit/ui-icons": "0.0.71",
16
16
  "date-fns": "2.29.3",
17
17
  "lodash": "4.17.21",
18
18
  "react": "18.2.0",
@@ -25,7 +25,7 @@ export interface CardProps extends CommonProps, React.InputHTMLAttributes<HTMLDi
25
25
  */
26
26
  onMouseEnter?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
27
27
  /**
28
- * A MouseLEave handler function
28
+ * A MouseLeave handler function
29
29
  */
30
30
  onMouseLeave?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
31
31
  }
@@ -1,2 +1,3 @@
1
- export declare const containerStyles: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
2
- export declare const textStyles: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
1
+ export declare const cvaContainerStyles: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
2
+ export declare const cvaTextStyles: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
3
+ export declare const cvaImgStyles: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
@@ -5,7 +5,18 @@ export type ButtonVariant = "filled" | "transparent";
5
5
  export type ButtonColor = Extract<GeneralColors, "primary" | "secondary"> | Extract<IntentColors, "warning" | "danger"> | "tertiary";
6
6
  export type ButtonType = "button" | "submit";
7
7
  export interface ButtonCommonProps extends CommonProps {
8
+ /**
9
+ * An onClick handler
10
+ */
8
11
  onClick?: (event: React.MouseEvent<HTMLElement>) => void;
12
+ /**
13
+ * A MouseEnter handler function
14
+ */
15
+ onMouseEnter?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
16
+ /**
17
+ * A MouseLeave handler function
18
+ */
19
+ onMouseLeave?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
9
20
  /**
10
21
  * Whether the button is loading.
11
22
  */
@@ -3,7 +3,7 @@ import { RefObject } from "react";
3
3
  * Custom hook to handle click outside events.
4
4
  *
5
5
  * @param {RefObject<HTMLElement> | Array<RefObject<HTMLElement>>} el - The reference(s) to the element(s) to watch for click outside events.
6
- * @param {Object | Function} [options={}] - Configuration options or the click event handler if options are not provided.
6
+ * @param {object | Function} [options={}] - Configuration options or the click event handler if options are not provided.
7
7
  * @param {boolean} [options.active=true] - Whether the click outside event listener should be active.
8
8
  * @param {Function} [onClick] - The event handler for the click outside event.
9
9
  */
@@ -1,5 +1,5 @@
1
1
  import { DebounceDirection } from "./useDebounce";
2
- type ConditionalUseHoverProps = {
2
+ type UseHoverProps = {
3
3
  debounced: true;
4
4
  delay?: number;
5
5
  direction?: DebounceDirection;
@@ -13,10 +13,10 @@ type ConditionalUseHoverProps = {
13
13
  * The boolean will be true if the element is being hovered, and false if it is not.
14
14
  * Can be directionally debounced.
15
15
  *
16
- * @param {ConditionalUseHoverProps} param0 The options
17
- * @returns {Object} The object containing the onMouseEnter, onMouseLeave and hovering props
16
+ * @param {UseHoverProps} param0 The options
17
+ * @returns {object} The object containing the onMouseEnter, onMouseLeave and hovering props
18
18
  */
19
- export declare const useHover: ({ debounced, delay, direction }?: ConditionalUseHoverProps) => {
19
+ export declare const useHover: ({ debounced, delay, direction }?: UseHoverProps) => {
20
20
  onMouseEnter: () => void;
21
21
  onMouseLeave: () => void;
22
22
  hovering: boolean;