@jobber/hooks 2.9.7 → 2.9.9-fix-input-.53

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/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # Atlantis Hooks
2
+
3
+ Shared hooks for components in Atlantis.
4
+
5
+ ## Hooks
6
+
7
+ - [useAssert](../?path=/docs/hooks-useassert--docs)
8
+ - [useBool](../?path=/docs/hooks-usebool--docs)
9
+ - [useCollectionQuery](../?path=/docs/hooks-usecollectionquery--docs)
10
+ - [useFormState](../?path=/docs/hooks-useformstate--docs)
11
+ - [useIsMounted](../?path=/docs/hooks-useismounted--docs)
12
+ - [useLiveAnnounce](../?path=/docs/hooks-useliveannounce--docs)
13
+ - [useOnKeyDown](../?path=/docs/hooks-useonkeydown--docs)
14
+ - [usePasswordStrength](../?path=/docs/hooks-usepasswordstrength--docs)
15
+ - [useRefocusOnActivator](../?path=/docs/hooks-userefocusonactivator--docs)
16
+ - [useResizeObserver](../?path=/docs/hooks-useresizeobserver--docs)
17
+ - [useWindowDimensions](../?path=/docs/hooks-usewindowdimensions--docs)
18
+
19
+ ## Installing
20
+
21
+ `npm install hooks @jobber/hooks`
package/dist/index.d.ts CHANGED
@@ -13,3 +13,4 @@ export * from "./useRefocusOnActivator";
13
13
  export * from "./useResizeObserver";
14
14
  export * from "./useSafeLayoutEffect";
15
15
  export * from "./useShowClear";
16
+ export * from "./useWindowDimensions";
package/dist/index.js CHANGED
@@ -29,3 +29,4 @@ __exportStar(require("./useRefocusOnActivator"), exports);
29
29
  __exportStar(require("./useResizeObserver"), exports);
30
30
  __exportStar(require("./useSafeLayoutEffect"), exports);
31
31
  __exportStar(require("./useShowClear"), exports);
32
+ __exportStar(require("./useWindowDimensions"), exports);
@@ -6,7 +6,7 @@ export declare const BREAKPOINT_SIZES: {
6
6
  };
7
7
  /**
8
8
  * Hook equivalent of CSS media queries with our
9
- * [supported breakpoints](https://atlantis.getjobber.com/?path=/docs/design-breakpoints--page).
9
+ * [supported breakpoints](https://atlantis.getjobber.com/?path=/docs/design-breakpoints--docs).
10
10
  */
11
11
  export declare function useBreakpoints(): {
12
12
  smallAndUp: boolean;
@@ -5,7 +5,7 @@ const useMediaQuery_1 = require("./useMediaQuery");
5
5
  exports.BREAKPOINT_SIZES = { sm: 490, md: 768, lg: 1080, xl: 1440 };
6
6
  /**
7
7
  * Hook equivalent of CSS media queries with our
8
- * [supported breakpoints](https://atlantis.getjobber.com/?path=/docs/design-breakpoints--page).
8
+ * [supported breakpoints](https://atlantis.getjobber.com/?path=/docs/design-breakpoints--docs).
9
9
  */
10
10
  function useBreakpoints() {
11
11
  const { sm, md, lg, xl } = exports.BREAKPOINT_SIZES;
@@ -0,0 +1 @@
1
+ export { useWindowDimensions } from "./useWindowDimensions";
@@ -0,0 +1,5 @@
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; } });
@@ -0,0 +1,23 @@
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");
6
+ describe("useWindowDimensions", () => {
7
+ it("should return window dimensions", () => {
8
+ window.innerHeight = 100;
9
+ window.innerWidth = 1000;
10
+ const { result } = (0, react_hooks_1.renderHook)(() => (0, useWindowDimensions_1.useWindowDimensions)());
11
+ expect(result.current).toEqual({ width: 1000, height: 100 });
12
+ });
13
+ describe("resize event", () => {
14
+ it("should return window dimensions after resize", () => {
15
+ window.innerHeight = 100;
16
+ window.innerWidth = 1000;
17
+ const { result } = (0, react_hooks_1.renderHook)(() => (0, useWindowDimensions_1.useWindowDimensions)());
18
+ window.innerWidth = 500;
19
+ (0, react_1.fireEvent)(window, new Event("resize"));
20
+ expect(result.current).toEqual({ width: 500, height: 100 });
21
+ });
22
+ });
23
+ });
@@ -0,0 +1,4 @@
1
+ export declare function useWindowDimensions(): {
2
+ width: number;
3
+ height: number;
4
+ };
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useWindowDimensions = void 0;
4
+ const react_1 = require("react");
5
+ function getWindowDimensions() {
6
+ if (!(globalThis === null || globalThis === void 0 ? void 0 : globalThis.document)) {
7
+ return {
8
+ width: 0,
9
+ height: 0,
10
+ };
11
+ }
12
+ const { innerWidth: width, innerHeight: height } = window;
13
+ return {
14
+ width,
15
+ height,
16
+ };
17
+ }
18
+ function useWindowDimensions() {
19
+ const [windowDimensions, setWindowDimensions] = (0, react_1.useState)(getWindowDimensions());
20
+ (0, react_1.useEffect)(() => {
21
+ function handleResize() {
22
+ setWindowDimensions(getWindowDimensions());
23
+ }
24
+ window === null || window === void 0 ? void 0 : window.addEventListener("resize", handleResize);
25
+ return () => window === null || window === void 0 ? void 0 : window.removeEventListener("resize", handleResize);
26
+ }, []);
27
+ return windowDimensions;
28
+ }
29
+ exports.useWindowDimensions = useWindowDimensions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/hooks",
3
- "version": "2.9.7",
3
+ "version": "2.9.9-fix-input-.53+19040e2c",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@apollo/client": "^3.0.0",
45
- "react": "^18"
45
+ "react": "^18.2.0"
46
46
  },
47
- "gitHead": "b10e7ce1c463c1ecde128866ea95ba9fc2b9aaee"
47
+ "gitHead": "19040e2c3db4f2b65e952bb08bcceb3b77f556e2"
48
48
  }
@@ -0,0 +1 @@
1
+ export * from "./dist/useWindowDimensions";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+
7
+ var useWindowDimensions = require("./dist/useWindowDimensions");
8
+
9
+ Object.keys(useWindowDimensions).forEach(function(key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ Object.defineProperty(exports, key, {
12
+ enumerable: true,
13
+ get: function get() {
14
+ return useWindowDimensions[key];
15
+ },
16
+ });
17
+ });
package/README.mdx DELETED
@@ -1,20 +0,0 @@
1
- # Atlantis Hooks
2
-
3
- Shared hooks for components in Atlantis.
4
-
5
- ## Hooks
6
-
7
- - [useAssert](../?path=/docs/hooks-useassert--page)
8
- - [useBool](../?path=/docs/hooks-usebool--page)
9
- - [useCollectionQuery](../?path=/docs/hooks-usecollectionquery--use-collection-query)
10
- - [useFormState](../?path=/docs/hooks-useformstate--use-form-state)
11
- - [useIsMounted](../?path=/docs/hooks-useismounted--use-is-mounted)
12
- - [useLiveAnnounce](../?path=/docs/hooks-useliveannounce--use-live-announce)
13
- - [useOnKeyDown](../?path=/docs/hooks-useonkeydown--use-on-key-down)
14
- - [usePasswordStrength](../?path=/docs/hooks-usepasswordstrength--use-password-strength)
15
- - [useRefocusOnActivator](../?path=/docs/hooks-userefocusonactivator--use-refocus-on-activator)
16
- - [useResizeObserver](../?path=/docs/packages-hooks--page)
17
-
18
- ## Installing
19
-
20
- `npm install hooks @jobber/hooks`
@@ -1,6 +0,0 @@
1
- import { Meta } from "@storybook/addon-docs";
2
- import Readme from "./README.mdx";
3
-
4
- <Meta title="Packages/Hooks" />
5
-
6
- <Readme />