@trackunit/react-components 0.1.131 → 0.1.133

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
@@ -36470,7 +36470,7 @@ const useLocalStorageReducer = ({ key, defaultState, reducer, schema, onValidati
36470
36470
  * Custom hook to handle click outside events.
36471
36471
  *
36472
36472
  * @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.
36473
+ * @param {object | Function} [options={}] - Configuration options or the click event handler if options are not provided.
36474
36474
  * @param {boolean} [options.active=true] - Whether the click outside event listener should be active.
36475
36475
  * @param {Function} [onClick] - The event handler for the click outside event.
36476
36476
  */
@@ -36591,7 +36591,7 @@ function getDevicePixelRatio(options) {
36591
36591
  * Can be directionally debounced.
36592
36592
  *
36593
36593
  * @param {ConditionalUseHoverProps} param0 The options
36594
- * @returns {Object} The object containing the onMouseEnter, onMouseLeave and hovering props
36594
+ * @returns {object} The object containing the onMouseEnter, onMouseLeave and hovering props
36595
36595
  */
36596
36596
  const useHover = ({ debounced = false, delay = 100, direction = "out" } = { debounced: false }) => {
36597
36597
  const [hovering, setHovering] = React.useState(false);
@@ -37265,13 +37265,17 @@ function useConfirmExit(confirmExit, when = true) {
37265
37265
  */
37266
37266
  const usePrompt = (message, when = true) => {
37267
37267
  React.useEffect(() => {
37268
+ const onBeforeUnload = (event) => {
37269
+ // According to https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
37270
+ // preventDefault() should be called to indicate that the event was handled.
37271
+ event.preventDefault();
37272
+ return message;
37273
+ };
37268
37274
  if (when) {
37269
- window.onbeforeunload = function () {
37270
- return message;
37271
- };
37275
+ window.addEventListener("beforeunload", onBeforeUnload);
37272
37276
  }
37273
37277
  return () => {
37274
- window.onbeforeunload = null;
37278
+ window.removeEventListener("beforeunload", onBeforeUnload);
37275
37279
  };
37276
37280
  }, [message, when]);
37277
37281
  const confirmExit = React.useCallback(() => {
package/index.js CHANGED
@@ -36443,7 +36443,7 @@ const useLocalStorageReducer = ({ key, defaultState, reducer, schema, onValidati
36443
36443
  * Custom hook to handle click outside events.
36444
36444
  *
36445
36445
  * @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.
36446
+ * @param {object | Function} [options={}] - Configuration options or the click event handler if options are not provided.
36447
36447
  * @param {boolean} [options.active=true] - Whether the click outside event listener should be active.
36448
36448
  * @param {Function} [onClick] - The event handler for the click outside event.
36449
36449
  */
@@ -36564,7 +36564,7 @@ function getDevicePixelRatio(options) {
36564
36564
  * Can be directionally debounced.
36565
36565
  *
36566
36566
  * @param {ConditionalUseHoverProps} param0 The options
36567
- * @returns {Object} The object containing the onMouseEnter, onMouseLeave and hovering props
36567
+ * @returns {object} The object containing the onMouseEnter, onMouseLeave and hovering props
36568
36568
  */
36569
36569
  const useHover = ({ debounced = false, delay = 100, direction = "out" } = { debounced: false }) => {
36570
36570
  const [hovering, setHovering] = useState(false);
@@ -37238,13 +37238,17 @@ function useConfirmExit(confirmExit, when = true) {
37238
37238
  */
37239
37239
  const usePrompt = (message, when = true) => {
37240
37240
  useEffect(() => {
37241
+ const onBeforeUnload = (event) => {
37242
+ // According to https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
37243
+ // preventDefault() should be called to indicate that the event was handled.
37244
+ event.preventDefault();
37245
+ return message;
37246
+ };
37241
37247
  if (when) {
37242
- window.onbeforeunload = function () {
37243
- return message;
37244
- };
37248
+ window.addEventListener("beforeunload", onBeforeUnload);
37245
37249
  }
37246
37250
  return () => {
37247
- window.onbeforeunload = null;
37251
+ window.removeEventListener("beforeunload", onBeforeUnload);
37248
37252
  };
37249
37253
  }, [message, when]);
37250
37254
  const confirmExit = useCallback(() => {
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.1.131",
3
+ "version": "0.1.133",
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.9",
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",
@@ -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
  */
@@ -14,7 +14,7 @@ type ConditionalUseHoverProps = {
14
14
  * Can be directionally debounced.
15
15
  *
16
16
  * @param {ConditionalUseHoverProps} param0 The options
17
- * @returns {Object} The object containing the onMouseEnter, onMouseLeave and hovering props
17
+ * @returns {object} The object containing the onMouseEnter, onMouseLeave and hovering props
18
18
  */
19
19
  export declare const useHover: ({ debounced, delay, direction }?: ConditionalUseHoverProps) => {
20
20
  onMouseEnter: () => void;