@availity/hooks 3.1.2 → 3.2.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # 3.2.0 (2022-02-18)
7
+
8
+
9
+ ### Features
10
+
11
+ * **hooks:** add documentation to sidebar, some formatting ([fbd9964](https://github.com/Availity/availity-react/commit/fbd99648c18993394f773d8540c1be023acf6e5b))
12
+ * **hooks:** add useWindowDimensionsHook ([203d9c0](https://github.com/Availity/availity-react/commit/203d9c0a31362ec084c94c4ae50ab4b6efbc876b))
13
+
14
+
15
+
16
+
17
+
6
18
  ## [3.1.2](https://github.com/Availity/availity-react/compare/@availity/hooks@3.1.1...@availity/hooks@3.1.2) (2021-12-20)
7
19
 
8
20
  **Note:** Version bump only for package @availity/hooks
package/index.d.ts CHANGED
@@ -7,3 +7,4 @@ export { default as useCurrentUser } from './types/useCurrentUser';
7
7
  export { default as useProviders } from './types/useProviders';
8
8
  export { default as usePermissions } from './types/usePermissions';
9
9
  export { default as useOrganizations } from './types/useOrganizations';
10
+ export { default as useWindowDimensions } from './types/useWindowDimensions';
package/index.js CHANGED
@@ -7,3 +7,4 @@ export { default as useCurrentUser } from './src/useCurrentUser';
7
7
  export { default as useProviders } from './src/useProviders';
8
8
  export { default as usePermissions } from './src/usePermissions';
9
9
  export { default as useOrganizations } from './src/useOrganizations';
10
+ export { default as useWindowDimensions } from './src/useWindowDimensions';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@availity/hooks",
3
- "version": "3.1.2",
3
+ "version": "3.2.0",
4
4
  "description": "A group of pre-built hooks that are common in most apps",
5
5
  "keywords": [
6
6
  "react",
@@ -38,5 +38,5 @@
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "5983e704cd833c6e93ef6d00472f48a0876fe782"
41
+ "gitHead": "abf384b83ac5948b55377ccca91cbdb8ea81f753"
42
42
  }
@@ -0,0 +1,26 @@
1
+ import { useEffect, useState } from 'react';
2
+
3
+ const getWindowDimensions = () => {
4
+ const { innerWidth: width, innerHeight: height } = window;
5
+ return {
6
+ width,
7
+ height,
8
+ };
9
+ };
10
+
11
+ const useWindowDimensions = () => {
12
+ const [windowDimensions, setWindowDimensions] = useState(getWindowDimensions());
13
+
14
+ useEffect(() => {
15
+ const handleResize = () => {
16
+ setWindowDimensions(getWindowDimensions());
17
+ };
18
+
19
+ window.addEventListener('resize', handleResize);
20
+ return () => window.removeEventListener('resize', handleResize);
21
+ }, []);
22
+
23
+ return windowDimensions;
24
+ };
25
+
26
+ export default useWindowDimensions;
@@ -0,0 +1,8 @@
1
+ export type Dimensions = {
2
+ width: number;
3
+ height: number;
4
+ };
5
+
6
+ declare function useWindowDimensions(): Dimensions;
7
+
8
+ export default useWindowDimensions;