@jobber/hooks 2.9.6 → 2.9.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/README.mdx +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/package.json +2 -2
- package/dist/useWindowDimensions/index.d.ts +0 -1
- package/dist/useWindowDimensions/index.js +0 -5
- package/dist/useWindowDimensions/useWIndowDimensions.test.d.ts +0 -1
- package/dist/useWindowDimensions/useWIndowDimensions.test.js +0 -23
- package/dist/useWindowDimensions/useWindowDimensions.d.ts +0 -4
- package/dist/useWindowDimensions/useWindowDimensions.js +0 -29
- package/useWindowDimensions.d.ts +0 -1
- package/useWindowDimensions.js +0 -17
package/README.mdx
CHANGED
|
@@ -14,7 +14,6 @@ Shared hooks for components in Atlantis.
|
|
|
14
14
|
- [usePasswordStrength](../?path=/docs/hooks-usepasswordstrength--use-password-strength)
|
|
15
15
|
- [useRefocusOnActivator](../?path=/docs/hooks-userefocusonactivator--use-refocus-on-activator)
|
|
16
16
|
- [useResizeObserver](../?path=/docs/packages-hooks--page)
|
|
17
|
-
- [useWindowDimensions](../?path=/docs/hooks-usewindowdimensions--page)
|
|
18
17
|
|
|
19
18
|
## Installing
|
|
20
19
|
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -29,4 +29,3 @@ __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);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/hooks",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.js",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"@apollo/client": "^3.0.0",
|
|
45
45
|
"react": "^18"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "b10e7ce1c463c1ecde128866ea95ba9fc2b9aaee"
|
|
48
48
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useWindowDimensions } from "./useWindowDimensions";
|
|
@@ -1,5 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
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/useWindowDimensions.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./dist/useWindowDimensions";
|
package/useWindowDimensions.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
});
|