@jobber/hooks 2.17.2 → 2.17.3

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.
Files changed (63) hide show
  1. package/dist/index.js +34 -18
  2. package/dist/useBool/index.js +5 -1
  3. package/dist/useBool/useBool.js +9 -6
  4. package/dist/useBool/useBool.test.js +11 -9
  5. package/dist/useBreakpoints/index.js +20 -2
  6. package/dist/useBreakpoints/mockViewportWidth/index.js +17 -1
  7. package/dist/useBreakpoints/mockViewportWidth/mockViewportWidth.js +6 -2
  8. package/dist/useBreakpoints/mockViewportWidth/mockViewportWidth.test.js +6 -4
  9. package/dist/useBreakpoints/useBreakpoints.js +13 -9
  10. package/dist/useBreakpoints/useBreakpoints.test.js +35 -30
  11. package/dist/useBreakpoints/useMediaQuery.js +9 -5
  12. package/dist/useCallbackRef/index.js +5 -1
  13. package/dist/useCallbackRef/useCallbackRef.js +8 -5
  14. package/dist/useCallbackRef/useCallbackRef.test.js +6 -4
  15. package/dist/useCollectionQuery/index.js +5 -1
  16. package/dist/useCollectionQuery/mdxUtils.js +12 -8
  17. package/dist/useCollectionQuery/test-utilities/index.js +19 -3
  18. package/dist/useCollectionQuery/test-utilities/mocks.js +30 -19
  19. package/dist/useCollectionQuery/test-utilities/queries.js +7 -4
  20. package/dist/useCollectionQuery/test-utilities/utils.js +4 -1
  21. package/dist/useCollectionQuery/uniqueEdges.js +6 -2
  22. package/dist/useCollectionQuery/uniqueNodes.js +4 -1
  23. package/dist/useCollectionQuery/useCollectionQuery.js +34 -27
  24. package/dist/useCollectionQuery/useCollectionQuery.test.js +128 -126
  25. package/dist/useDebounce/index.js +5 -1
  26. package/dist/useDebounce/useDebounce.js +11 -8
  27. package/dist/useDebounce/useDebounce.test.js +70 -42
  28. package/dist/useFocusTrap/index.js +5 -1
  29. package/dist/useFocusTrap/useFocusTrap.js +7 -4
  30. package/dist/useFocusTrap/useFocusTrap.test.js +31 -26
  31. package/dist/useFormState/index.js +5 -1
  32. package/dist/useFormState/useFormState.js +6 -3
  33. package/dist/useInView/index.js +17 -1
  34. package/dist/useInView/useInView.js +9 -6
  35. package/dist/useInView/useInView.test.js +17 -12
  36. package/dist/useIsMounted/index.js +5 -1
  37. package/dist/useIsMounted/useIsMounted.js +8 -5
  38. package/dist/useIsMounted/useIsMounted.test.js +6 -4
  39. package/dist/useLiveAnnounce/index.js +5 -1
  40. package/dist/useLiveAnnounce/useLiveAnnounce.js +7 -4
  41. package/dist/useLiveAnnounce/useLiveAnnounce.test.js +24 -19
  42. package/dist/useOnKeyDown/index.js +5 -1
  43. package/dist/useOnKeyDown/useOnKeyDown.js +6 -3
  44. package/dist/useOnKeyDown/useOnKeyDown.test.js +12 -7
  45. package/dist/useOnMount/index.js +5 -1
  46. package/dist/useOnMount/useOnMount.js +10 -6
  47. package/dist/useOnMount/useOnMount.test.js +6 -4
  48. package/dist/useRefocusOnActivator/index.js +5 -1
  49. package/dist/useRefocusOnActivator/useRefocusOnActivator.js +6 -3
  50. package/dist/useResizeObserver/index.js +17 -1
  51. package/dist/useResizeObserver/useResizeObserver.js +16 -9
  52. package/dist/useSafeLayoutEffect/index.js +5 -1
  53. package/dist/useSafeLayoutEffect/useSafeLayoutEffect.js +7 -4
  54. package/dist/useShowClear/index.js +5 -1
  55. package/dist/useShowClear/useShowClear.js +4 -1
  56. package/dist/useShowClear/useShowClear.test.js +8 -6
  57. package/dist/useStepper/index.js +5 -1
  58. package/dist/useStepper/useStepper.js +15 -9
  59. package/dist/useStepper/useStepper.test.js +17 -15
  60. package/dist/useWindowDimensions/index.js +5 -1
  61. package/dist/useWindowDimensions/useWIndowDimensions.test.js +8 -6
  62. package/dist/useWindowDimensions/useWindowDimensions.js +7 -4
  63. package/package.json +5 -102
@@ -1,11 +1,16 @@
1
- import React from "react";
2
- import { fireEvent, render } from "@testing-library/react";
3
- import { useOnKeyDown } from ".";
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ const react_2 = require("@testing-library/react");
8
+ const _1 = require(".");
4
9
  test("fires the method when the key is pressed", () => {
5
10
  const keypressCallback = jest.fn();
6
- const { container } = render(React.createElement(TestComponent, { callback: keypressCallback }));
11
+ const { container } = (0, react_2.render)(react_1.default.createElement(TestComponent, { callback: keypressCallback }));
7
12
  expect(keypressCallback).toHaveBeenCalledTimes(0);
8
- fireEvent(container, new KeyboardEvent("keydown", {
13
+ (0, react_2.fireEvent)(container, new KeyboardEvent("keydown", {
9
14
  key: "Enter",
10
15
  bubbles: true,
11
16
  cancelable: false,
@@ -13,6 +18,6 @@ test("fires the method when the key is pressed", () => {
13
18
  expect(keypressCallback).toHaveBeenCalledTimes(1);
14
19
  });
15
20
  function TestComponent({ callback }) {
16
- useOnKeyDown(callback, "Enter");
17
- return React.createElement(React.Fragment, null, "Look at me!");
21
+ (0, _1.useOnKeyDown)(callback, "Enter");
22
+ return react_1.default.createElement(react_1.default.Fragment, null, "Look at me!");
18
23
  }
@@ -1 +1,5 @@
1
- export { useOnMount } from "./useOnMount";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useOnMount = void 0;
4
+ var useOnMount_1 = require("./useOnMount");
5
+ Object.defineProperty(exports, "useOnMount", { enumerable: true, get: function () { return useOnMount_1.useOnMount; } });
@@ -1,16 +1,20 @@
1
- import { useEffect, useRef } from "react";
2
- import { useCallbackRef } from "../useCallbackRef";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useOnMount = void 0;
4
+ const react_1 = require("react");
5
+ const useCallbackRef_1 = require("../useCallbackRef");
3
6
  /**
4
7
  * A custom hook that will call the provided function only once when the component mounts. Useful for emitting
5
8
  * analytics tracking events on component mount.
6
9
  */
7
- export const useOnMount = (fn) => {
8
- const mountedRef = useRef(false);
9
- const callback = useCallbackRef(fn);
10
- useEffect(() => {
10
+ const useOnMount = (fn) => {
11
+ const mountedRef = (0, react_1.useRef)(false);
12
+ const callback = (0, useCallbackRef_1.useCallbackRef)(fn);
13
+ (0, react_1.useEffect)(() => {
11
14
  if (!mountedRef.current) {
12
15
  mountedRef.current = true;
13
16
  callback();
14
17
  }
15
18
  }, [callback]);
16
19
  };
20
+ exports.useOnMount = useOnMount;
@@ -1,14 +1,16 @@
1
- import { renderHook } from "@testing-library/react";
2
- import { useOnMount } from "./useOnMount";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_1 = require("@testing-library/react");
4
+ const useOnMount_1 = require("./useOnMount");
3
5
  describe("useOnMount", () => {
4
6
  it("should call the function on mount", () => {
5
7
  const fn = jest.fn();
6
- renderHook(() => useOnMount(fn));
8
+ (0, react_1.renderHook)(() => (0, useOnMount_1.useOnMount)(fn));
7
9
  expect(fn).toHaveBeenCalledTimes(1);
8
10
  });
9
11
  it("should only call function once when re-rendered", () => {
10
12
  const fn = jest.fn();
11
- const view = renderHook(() => useOnMount(fn));
13
+ const view = (0, react_1.renderHook)(() => (0, useOnMount_1.useOnMount)(fn));
12
14
  expect(fn).toHaveBeenCalledTimes(1);
13
15
  view.rerender();
14
16
  expect(fn).toHaveBeenCalledTimes(1);
@@ -1 +1,5 @@
1
- export { useRefocusOnActivator } from "./useRefocusOnActivator";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useRefocusOnActivator = void 0;
4
+ var useRefocusOnActivator_1 = require("./useRefocusOnActivator");
5
+ Object.defineProperty(exports, "useRefocusOnActivator", { enumerable: true, get: function () { return useRefocusOnActivator_1.useRefocusOnActivator; } });
@@ -1,12 +1,15 @@
1
- import { useEffect } from "react";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useRefocusOnActivator = useRefocusOnActivator;
4
+ const react_1 = require("react");
2
5
  /**
3
6
  * Brings back the focus to the element that opened an overlaid element once
4
7
  * said overlaid element is dismissed.
5
8
  *
6
9
  * @param active - Determines if it should focus or not
7
10
  */
8
- export function useRefocusOnActivator(active) {
9
- useEffect(() => {
11
+ function useRefocusOnActivator(active) {
12
+ (0, react_1.useEffect)(() => {
10
13
  let activator;
11
14
  if (active && !activator) {
12
15
  activator = document.activeElement;
@@ -1 +1,17 @@
1
- export * from "./useResizeObserver";
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./useResizeObserver"), exports);
@@ -1,9 +1,16 @@
1
- import { useMemo, useState } from "react";
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Breakpoints = void 0;
7
+ exports.useResizeObserver = useResizeObserver;
8
+ const react_1 = require("react");
2
9
  // Importing the polyfilled version of ResizeObserver
3
10
  // eslint-disable-next-line import/no-internal-modules
4
- import useResizeObserverPackage from "use-resize-observer/polyfilled";
5
- import throttle from "lodash/throttle";
6
- export const Breakpoints = {
11
+ const polyfilled_1 = __importDefault(require("use-resize-observer/polyfilled"));
12
+ const throttle_1 = __importDefault(require("lodash/throttle"));
13
+ exports.Breakpoints = {
7
14
  base: 640,
8
15
  small: 500,
9
16
  smaller: 265,
@@ -11,13 +18,13 @@ export const Breakpoints = {
11
18
  larger: 1024,
12
19
  };
13
20
  const wait = 100;
14
- export function useResizeObserver({ widths = Breakpoints, heights = Breakpoints, } = {}) {
15
- const [exactSize, setSize] = useState({
21
+ function useResizeObserver({ widths = exports.Breakpoints, heights = exports.Breakpoints, } = {}) {
22
+ const [exactSize, setSize] = (0, react_1.useState)({
16
23
  width: undefined,
17
24
  height: undefined,
18
25
  });
19
- const onResize = useMemo(() => {
20
- return throttle(({ width, height }) => {
26
+ const onResize = (0, react_1.useMemo)(() => {
27
+ return (0, throttle_1.default)(({ width, height }) => {
21
28
  if (!width || width <= 1) {
22
29
  // Ignore invalid values. ResizeObserver is unexpectedly looping between 1 and the actual
23
30
  // width of the element. This is only happening in playwright chromium.
@@ -27,7 +34,7 @@ export function useResizeObserver({ widths = Breakpoints, heights = Breakpoints,
27
34
  setSize({ width, height });
28
35
  }, wait);
29
36
  }, []);
30
- const { ref } = useResizeObserverPackage({
37
+ const { ref } = (0, polyfilled_1.default)({
31
38
  onResize,
32
39
  });
33
40
  const exactWidth = exactSize.width;
@@ -1 +1,5 @@
1
- export { useSafeLayoutEffect } from "./useSafeLayoutEffect";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useSafeLayoutEffect = void 0;
4
+ var useSafeLayoutEffect_1 = require("./useSafeLayoutEffect");
5
+ Object.defineProperty(exports, "useSafeLayoutEffect", { enumerable: true, get: function () { return useSafeLayoutEffect_1.useSafeLayoutEffect; } });
@@ -1,4 +1,7 @@
1
- import { useEffect, useLayoutEffect } from "react";
2
- export const useSafeLayoutEffect = (globalThis === null || globalThis === void 0 ? void 0 : globalThis.document)
3
- ? useLayoutEffect
4
- : useEffect;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useSafeLayoutEffect = void 0;
4
+ const react_1 = require("react");
5
+ exports.useSafeLayoutEffect = (globalThis === null || globalThis === void 0 ? void 0 : globalThis.document)
6
+ ? react_1.useLayoutEffect
7
+ : react_1.useEffect;
@@ -1 +1,5 @@
1
- export { useShowClear } from "./useShowClear";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useShowClear = void 0;
4
+ var useShowClear_1 = require("./useShowClear");
5
+ Object.defineProperty(exports, "useShowClear", { enumerable: true, get: function () { return useShowClear_1.useShowClear; } });
@@ -1,4 +1,7 @@
1
- export function useShowClear({ clearable, multiline, focused, hasValue, readonly, disabled = false, }) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useShowClear = useShowClear;
4
+ function useShowClear({ clearable, multiline, focused, hasValue, readonly, disabled = false, }) {
2
5
  if (multiline && clearable !== "never") {
3
6
  throw new Error("Multiline inputs can not be clearable");
4
7
  }
@@ -1,4 +1,6 @@
1
- import { useShowClear } from "./useShowClear";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const useShowClear_1 = require("./useShowClear");
2
4
  describe("useShowClear", () => {
3
5
  describe.each([
4
6
  {
@@ -154,7 +156,7 @@ describe("useShowClear", () => {
154
156
  },
155
157
  ])("%j", ({ clearable, hasValue, focused, multiline, disabled, readonly, expected, }) => {
156
158
  it(`returns ${expected}`, () => {
157
- expect(useShowClear({
159
+ expect((0, useShowClear_1.useShowClear)({
158
160
  clearable,
159
161
  multiline,
160
162
  focused,
@@ -166,7 +168,7 @@ describe("useShowClear", () => {
166
168
  });
167
169
  it("throws an error if multiline is true and clearable isn't never", () => {
168
170
  expect(() => {
169
- useShowClear({
171
+ (0, useShowClear_1.useShowClear)({
170
172
  clearable: "always",
171
173
  multiline: true,
172
174
  focused: true,
@@ -175,7 +177,7 @@ describe("useShowClear", () => {
175
177
  });
176
178
  }).toThrow();
177
179
  expect(() => {
178
- useShowClear({
180
+ (0, useShowClear_1.useShowClear)({
179
181
  clearable: "while-editing",
180
182
  multiline: true,
181
183
  focused: true,
@@ -184,7 +186,7 @@ describe("useShowClear", () => {
184
186
  });
185
187
  }).toThrow();
186
188
  expect(() => {
187
- useShowClear({
189
+ (0, useShowClear_1.useShowClear)({
188
190
  clearable: "never",
189
191
  multiline: true,
190
192
  focused: true,
@@ -195,7 +197,7 @@ describe("useShowClear", () => {
195
197
  });
196
198
  it("respects readonly in multiline inputs", () => {
197
199
  expect(() => {
198
- useShowClear({
200
+ (0, useShowClear_1.useShowClear)({
199
201
  clearable: "never",
200
202
  multiline: true,
201
203
  focused: true,
@@ -1 +1,5 @@
1
- export { useStepper } from "./useStepper";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useStepper = void 0;
4
+ var useStepper_1 = require("./useStepper");
5
+ Object.defineProperty(exports, "useStepper", { enumerable: true, get: function () { return useStepper_1.useStepper; } });
@@ -1,16 +1,22 @@
1
- import { useMemo, useState } from "react";
2
- import invariant from "tiny-invariant";
3
- export function useStepper(steps, options = {}) {
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useStepper = useStepper;
7
+ const react_1 = require("react");
8
+ const tiny_invariant_1 = __importDefault(require("tiny-invariant"));
9
+ function useStepper(steps, options = {}) {
4
10
  var _a;
5
11
  const firstStep = (_a = options === null || options === void 0 ? void 0 : options.defaultStep) !== null && _a !== void 0 ? _a : steps[0];
6
- invariant(firstStep, "Steps array cannot be empty");
7
- const [currentStep, setCurrentStep] = useState(firstStep);
8
- const currentActiveStep = useMemo(() => ({
12
+ (0, tiny_invariant_1.default)(firstStep, "Steps array cannot be empty");
13
+ const [currentStep, setCurrentStep] = (0, react_1.useState)(firstStep);
14
+ const currentActiveStep = (0, react_1.useMemo)(() => ({
9
15
  currentStep,
10
16
  isFirst: currentStep === steps[0],
11
17
  isLast: currentStep === steps[steps.length - 1],
12
18
  }), [currentStep, steps]);
13
- const handlers = useMemo(() => ({
19
+ const handlers = (0, react_1.useMemo)(() => ({
14
20
  goToStep: (step) => {
15
21
  setCurrentStep(step);
16
22
  },
@@ -18,7 +24,7 @@ export function useStepper(steps, options = {}) {
18
24
  setCurrentStep(prevCurrentStep => {
19
25
  const currentIndex = steps.indexOf(prevCurrentStep);
20
26
  const nextStep = steps[Math.min(currentIndex + 1, steps.length - 1)];
21
- invariant(nextStep, `Index out of bounds: ${currentIndex + 1}`);
27
+ (0, tiny_invariant_1.default)(nextStep, `Index out of bounds: ${currentIndex + 1}`);
22
28
  return nextStep;
23
29
  });
24
30
  },
@@ -26,7 +32,7 @@ export function useStepper(steps, options = {}) {
26
32
  setCurrentStep(prevCurrentStep => {
27
33
  const currentIndex = steps.indexOf(prevCurrentStep);
28
34
  const previousStep = steps[Math.max(currentIndex - 1, 0)];
29
- invariant(previousStep, `Index out of bounds: ${currentIndex - 1}`);
35
+ (0, tiny_invariant_1.default)(previousStep, `Index out of bounds: ${currentIndex - 1}`);
30
36
  return previousStep;
31
37
  });
32
38
  },
@@ -1,15 +1,17 @@
1
- import { act, renderHook } from "@testing-library/react";
2
- import { useStepper } from ".";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_1 = require("@testing-library/react");
4
+ const _1 = require(".");
3
5
  const steps = ["step1", "step2", "step3"];
4
6
  describe("useStepper", () => {
5
7
  it("initializes with first step when no initial step provided", () => {
6
- const { result } = renderHook(() => useStepper(steps));
8
+ const { result } = (0, react_1.renderHook)(() => (0, _1.useStepper)(steps));
7
9
  expect(result.current.currentStep).toBe("step1");
8
10
  expect(result.current.isFirst).toBe(true);
9
11
  expect(result.current.isLast).toBe(false);
10
12
  });
11
13
  it("initializes with provided initial step", () => {
12
- const { result } = renderHook(() => useStepper(["step1", "step2", "step3"], {
14
+ const { result } = (0, react_1.renderHook)(() => (0, _1.useStepper)(["step1", "step2", "step3"], {
13
15
  defaultStep: "step2",
14
16
  }));
15
17
  expect(result.current.currentStep).toBe("step2");
@@ -17,8 +19,8 @@ describe("useStepper", () => {
17
19
  expect(result.current.isLast).toBe(false);
18
20
  });
19
21
  it("moves to next step when nextStep is called", () => {
20
- const { result } = renderHook(() => useStepper(steps));
21
- act(() => {
22
+ const { result } = (0, react_1.renderHook)(() => (0, _1.useStepper)(steps));
23
+ (0, react_1.act)(() => {
22
24
  result.current.goToNextStep();
23
25
  });
24
26
  expect(result.current.currentStep).toBe("step2");
@@ -26,10 +28,10 @@ describe("useStepper", () => {
26
28
  expect(result.current.isFirst).toBe(false);
27
29
  });
28
30
  it("moves to previous step when previousStep is called", () => {
29
- const { result } = renderHook(() => useStepper(steps, {
31
+ const { result } = (0, react_1.renderHook)(() => (0, _1.useStepper)(steps, {
30
32
  defaultStep: "step2",
31
33
  }));
32
- act(() => {
34
+ (0, react_1.act)(() => {
33
35
  result.current.goToPreviousStep();
34
36
  });
35
37
  expect(result.current.currentStep).toBe("step1");
@@ -37,10 +39,10 @@ describe("useStepper", () => {
37
39
  expect(result.current.isFirst).toBe(true);
38
40
  });
39
41
  it("does not move past the last step", () => {
40
- const { result } = renderHook(() => useStepper(steps, {
42
+ const { result } = (0, react_1.renderHook)(() => (0, _1.useStepper)(steps, {
41
43
  defaultStep: "step3",
42
44
  }));
43
- act(() => {
45
+ (0, react_1.act)(() => {
44
46
  result.current.goToNextStep();
45
47
  });
46
48
  expect(result.current.currentStep).toBe("step3");
@@ -48,10 +50,10 @@ describe("useStepper", () => {
48
50
  expect(result.current.isFirst).toBe(false);
49
51
  });
50
52
  it("does not move before the first step", () => {
51
- const { result } = renderHook(() => useStepper(steps, {
53
+ const { result } = (0, react_1.renderHook)(() => (0, _1.useStepper)(steps, {
52
54
  defaultStep: "step1",
53
55
  }));
54
- act(() => {
56
+ (0, react_1.act)(() => {
55
57
  result.current.goToPreviousStep();
56
58
  });
57
59
  expect(result.current.currentStep).toBe("step1");
@@ -59,8 +61,8 @@ describe("useStepper", () => {
59
61
  expect(result.current.isLast).toBe(false);
60
62
  });
61
63
  it("moves to specific step when goToStep is called", () => {
62
- const { result } = renderHook(() => useStepper(steps));
63
- act(() => {
64
+ const { result } = (0, react_1.renderHook)(() => (0, _1.useStepper)(steps));
65
+ (0, react_1.act)(() => {
64
66
  result.current.goToStep("step3");
65
67
  });
66
68
  expect(result.current.currentStep).toBe("step3");
@@ -70,7 +72,7 @@ describe("useStepper", () => {
70
72
  describe("error handling", () => {
71
73
  it("throws error when steps array is empty", () => {
72
74
  expect(() => {
73
- renderHook(() => useStepper([]));
75
+ (0, react_1.renderHook)(() => (0, _1.useStepper)([]));
74
76
  }).toThrow(new Error("Invariant failed: Steps array cannot be empty"));
75
77
  });
76
78
  });
@@ -1 +1,5 @@
1
- export { useWindowDimensions } from "./useWindowDimensions";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useWindowDimensions = void 0;
4
+ var useWindowDimensions_1 = require("./useWindowDimensions");
5
+ Object.defineProperty(exports, "useWindowDimensions", { enumerable: true, get: function () { return useWindowDimensions_1.useWindowDimensions; } });
@@ -1,20 +1,22 @@
1
- import { renderHook } from "@testing-library/react-hooks";
2
- import { fireEvent } from "@testing-library/react";
3
- import { useWindowDimensions } from "./useWindowDimensions";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_hooks_1 = require("@testing-library/react-hooks");
4
+ const react_1 = require("@testing-library/react");
5
+ const useWindowDimensions_1 = require("./useWindowDimensions");
4
6
  describe("useWindowDimensions", () => {
5
7
  it("should return window dimensions", () => {
6
8
  window.innerHeight = 100;
7
9
  window.innerWidth = 1000;
8
- const { result } = renderHook(() => useWindowDimensions());
10
+ const { result } = (0, react_hooks_1.renderHook)(() => (0, useWindowDimensions_1.useWindowDimensions)());
9
11
  expect(result.current).toEqual({ width: 1000, height: 100 });
10
12
  });
11
13
  describe("resize event", () => {
12
14
  it("should return window dimensions after resize", () => {
13
15
  window.innerHeight = 100;
14
16
  window.innerWidth = 1000;
15
- const { result } = renderHook(() => useWindowDimensions());
17
+ const { result } = (0, react_hooks_1.renderHook)(() => (0, useWindowDimensions_1.useWindowDimensions)());
16
18
  window.innerWidth = 500;
17
- fireEvent(window, new Event("resize"));
19
+ (0, react_1.fireEvent)(window, new Event("resize"));
18
20
  expect(result.current).toEqual({ width: 500, height: 100 });
19
21
  });
20
22
  });
@@ -1,4 +1,7 @@
1
- import { useEffect, useState } from "react";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useWindowDimensions = useWindowDimensions;
4
+ const react_1 = require("react");
2
5
  function getWindowDimensions() {
3
6
  if (!(globalThis === null || globalThis === void 0 ? void 0 : globalThis.document)) {
4
7
  return {
@@ -12,9 +15,9 @@ function getWindowDimensions() {
12
15
  height,
13
16
  };
14
17
  }
15
- export function useWindowDimensions() {
16
- const [windowDimensions, setWindowDimensions] = useState(getWindowDimensions());
17
- useEffect(() => {
18
+ function useWindowDimensions() {
19
+ const [windowDimensions, setWindowDimensions] = (0, react_1.useState)(getWindowDimensions());
20
+ (0, react_1.useEffect)(() => {
18
21
  function handleResize() {
19
22
  setWindowDimensions(getWindowDimensions());
20
23
  }
package/package.json CHANGED
@@ -1,106 +1,9 @@
1
1
  {
2
2
  "name": "@jobber/hooks",
3
- "version": "2.17.2",
3
+ "version": "2.17.3",
4
4
  "license": "MIT",
5
- "types": "./dist/index.d.ts",
6
- "type": "module",
7
- "exports": {
8
- ".": {
9
- "types": "./dist/index.d.ts",
10
- "import": "./dist/index.js",
11
- "require": "./dist/index.js"
12
- },
13
- "./useBool": {
14
- "types": "./dist/useBool/index.d.ts",
15
- "import": "./dist/useBool/index.js",
16
- "require": "./dist/useBool/index.js"
17
- },
18
- "./useBreakpoints": {
19
- "types": "./dist/useBreakpoints/index.d.ts",
20
- "import": "./dist/useBreakpoints/index.js",
21
- "require": "./dist/useBreakpoints/index.js"
22
- },
23
- "./useCallbackRef": {
24
- "types": "./dist/useCallbackRef/index.d.ts",
25
- "import": "./dist/useCallbackRef/index.js",
26
- "require": "./dist/useCallbackRef/index.js"
27
- },
28
- "./useCollectionQuery": {
29
- "types": "./dist/useCollectionQuery/index.d.ts",
30
- "import": "./dist/useCollectionQuery/index.js",
31
- "require": "./dist/useCollectionQuery/index.js"
32
- },
33
- "./useDebounce": {
34
- "types": "./dist/useDebounce/index.d.ts",
35
- "import": "./dist/useDebounce/index.js",
36
- "require": "./dist/useDebounce/index.js"
37
- },
38
- "./useFocusTrap": {
39
- "types": "./dist/useFocusTrap/index.d.ts",
40
- "import": "./dist/useFocusTrap/index.js",
41
- "require": "./dist/useFocusTrap/index.js"
42
- },
43
- "./useFormState": {
44
- "types": "./dist/useFormState/index.d.ts",
45
- "import": "./dist/useFormState/index.js",
46
- "require": "./dist/useFormState/index.js"
47
- },
48
- "./useInView": {
49
- "types": "./dist/useInView/index.d.ts",
50
- "import": "./dist/useInView/index.js",
51
- "require": "./dist/useInView/index.js"
52
- },
53
- "./useIsMounted": {
54
- "types": "./dist/useIsMounted/index.d.ts",
55
- "import": "./dist/useIsMounted/index.js",
56
- "require": "./dist/useIsMounted/index.js"
57
- },
58
- "./useLiveAnnounce": {
59
- "types": "./dist/useLiveAnnounce/index.d.ts",
60
- "import": "./dist/useLiveAnnounce/index.js",
61
- "require": "./dist/useLiveAnnounce/index.js"
62
- },
63
- "./useOnKeyDown": {
64
- "types": "./dist/useOnKeyDown/index.d.ts",
65
- "import": "./dist/useOnKeyDown/index.js",
66
- "require": "./dist/useOnKeyDown/index.js"
67
- },
68
- "./useOnMount": {
69
- "types": "./dist/useOnMount/index.d.ts",
70
- "import": "./dist/useOnMount/index.js",
71
- "require": "./dist/useOnMount/index.js"
72
- },
73
- "./useRefocusOnActivator": {
74
- "types": "./dist/useRefocusOnActivator/index.d.ts",
75
- "import": "./dist/useRefocusOnActivator/index.js",
76
- "require": "./dist/useRefocusOnActivator/index.js"
77
- },
78
- "./useResizeObserver": {
79
- "types": "./dist/useResizeObserver/index.d.ts",
80
- "import": "./dist/useResizeObserver/index.js",
81
- "require": "./dist/useResizeObserver/index.js"
82
- },
83
- "./useSafeLayoutEffect": {
84
- "types": "./dist/useSafeLayoutEffect/index.d.ts",
85
- "import": "./dist/useSafeLayoutEffect/index.js",
86
- "require": "./dist/useSafeLayoutEffect/index.js"
87
- },
88
- "./useShowClear": {
89
- "types": "./dist/useShowClear/index.d.ts",
90
- "import": "./dist/useShowClear/index.js",
91
- "require": "./dist/useShowClear/index.js"
92
- },
93
- "./useStepper": {
94
- "types": "./dist/useStepper/index.d.ts",
95
- "import": "./dist/useStepper/index.js",
96
- "require": "./dist/useStepper/index.js"
97
- },
98
- "./useWindowDimensions": {
99
- "types": "./dist/useWindowDimensions/index.d.ts",
100
- "import": "./dist/useWindowDimensions/index.js",
101
- "require": "./dist/useWindowDimensions/index.js"
102
- }
103
- },
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.js",
104
7
  "scripts": {
105
8
  "build": "tsc --project . --skipLibCheck",
106
9
  "clean": "rm -rf dist/* tsconfig.tsbuildinfo",
@@ -117,7 +20,7 @@
117
20
  ],
118
21
  "devDependencies": {
119
22
  "@apollo/react-testing": "^4.0.0",
120
- "@jobber/formatters": "^0.4.1",
23
+ "@jobber/formatters": "^0.4.2",
121
24
  "@types/lodash": "4.14.136",
122
25
  "@types/react": "^18.0.28",
123
26
  "@types/react-dom": "^18.0.11",
@@ -137,5 +40,5 @@
137
40
  "@apollo/client": "^3.0.0",
138
41
  "react": "^18.2.0"
139
42
  },
140
- "gitHead": "14679bfc84922e1c758fbd6118ce3fd7b5142315"
43
+ "gitHead": "5bbca8eb6e0837b469d2343f9d0fa98a46f7d689"
141
44
  }