@brightleaf/react-hooks
Advanced tools
Comparing version 4.2.0 to 5.0.0
@@ -24,2 +24,8 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "useCustomEvent", { | ||
enumerable: true, | ||
get: function () { | ||
return _useCustomEvent.useCustomEvent; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useEvent", { | ||
@@ -85,2 +91,8 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "useMetaTag", { | ||
enumerable: true, | ||
get: function () { | ||
return _useMetaTag.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useNes", { | ||
@@ -159,2 +171,4 @@ enumerable: true, | ||
var _useCustomEvent = require("./use-custom-event"); | ||
var _useEvent = _interopRequireDefault(require("./use-event")); | ||
@@ -180,2 +194,4 @@ | ||
var _useMetaTag = _interopRequireDefault(require("./use-meta-tag")); | ||
var _useNes = _interopRequireDefault(require("./use-nes")); | ||
@@ -182,0 +198,0 @@ |
@@ -12,2 +12,16 @@ "use strict"; | ||
/** | ||
* @typedef {Object} Async~State | ||
* @property {Object|array} data - The data returned from the function. | ||
* @property {boolean} error - Indicates whether the function had an error. | ||
* @property {boolean} loading - Indicates whether the function is executing | ||
* @property {function} execute - The function to call to execute the async function | ||
*/ | ||
/** | ||
* useAsync hook to handle executing asynchronous function | ||
* | ||
* @param {*} workflow - The async function that will be executed | ||
* @returns {...Async~State} - The states and results and the call to execute function | ||
*/ | ||
const useAsync = workflow => { | ||
@@ -14,0 +28,0 @@ const [state, dispatch] = (0, _react.useReducer)(_reducer.reducer, { |
@@ -10,2 +10,9 @@ "use strict"; | ||
/** | ||
* useEvent Hook to allow binding to DOM events | ||
* | ||
* @param {string} eventName - The name of the event | ||
* @param {function} eventHandler - The handler function | ||
* @param {*} [target=window] - The entity to bind the event on | ||
*/ | ||
const useEventListener = (eventName, handler, target = window) => { | ||
@@ -12,0 +19,0 @@ const refHandler = (0, _react.useRef)(); |
@@ -10,2 +10,9 @@ "use strict"; | ||
/** | ||
* useEvent Hook to allow binding to DOM events | ||
* | ||
* @param {string} eventName - The name of the event | ||
* @param {function} eventHandler - The handler function | ||
* @param {*} [target=window] - The entity to bind the event on | ||
*/ | ||
const useEvent = (eventName, eventHandler, target = window) => { | ||
@@ -12,0 +19,0 @@ (0, _react.useEffect)(() => { |
@@ -10,2 +10,8 @@ "use strict"; | ||
/** | ||
* useFavicon Hook to allow setting of the favicon of a page | ||
* | ||
* @param {string} href - The href of the favicon | ||
* @returns {[string, function]} - The favicon href and setFavicon function to update favicon | ||
*/ | ||
const useFavicon = href => { | ||
@@ -12,0 +18,0 @@ const [favicon, setFavicon] = (0, _react.useState)(href); |
@@ -10,2 +10,8 @@ "use strict"; | ||
/** | ||
* useHover hook that returns if an element is being hovered over | ||
* | ||
* @param {*} rel - The reference to the element to be observed | ||
* @returns {boolean} - The current state of the element if being hovered | ||
*/ | ||
const useHover = rel => { | ||
@@ -12,0 +18,0 @@ const [hovered, setHover] = (0, _react.useState)(false); |
@@ -10,2 +10,8 @@ "use strict"; | ||
/** | ||
* useKeypress Hook to return true when key is pressed | ||
* | ||
* @param {string} key - The text to be used to set the page title | ||
* @param {HTMLElement} element - The element to listen on for the keypress | ||
*/ | ||
const useKeypress = (key, element = window) => { | ||
@@ -12,0 +18,0 @@ const [pressed, setPressed] = (0, _react.useState)(false); |
@@ -10,2 +10,8 @@ "use strict"; | ||
/** | ||
* useKeypressed Hook to return true when key is pressed | ||
* | ||
* @param {string} key - The text to be used to set the page title | ||
* @param {HTMLElement} element - The element to listen on for the keypress | ||
*/ | ||
const useKeypressed = (key, element = window) => { | ||
@@ -12,0 +18,0 @@ const [keyPressed, setKeyPressed] = (0, _react.useState)(false); |
@@ -10,2 +10,10 @@ "use strict"; | ||
/** | ||
* useLocalStorage - Hook to use local storage | ||
* | ||
* @param {string} key - The key to save the item in local storage | ||
* @param {*} initialValue - The initial value | ||
* @param {boolean} [raw=false] - if the object should be JSON.parsed or not | ||
* @returns {Array.<{value: object , setFunction: function}>} The value and the setter function | ||
*/ | ||
const useLocalStorage = (key, initialValue, raw = false) => { | ||
@@ -12,0 +20,0 @@ const [state, setState] = (0, _react.useState)(() => { |
@@ -10,2 +10,8 @@ "use strict"; | ||
/** | ||
* useTitle Hook to allow setting of the page title | ||
* | ||
* @param {string} pageTitle - The text to be used to set the page title | ||
* @returns {[string, function]} - The title and setTitle function | ||
*/ | ||
const useTitle = pageTitle => { | ||
@@ -12,0 +18,0 @@ const [title, setTitle] = (0, _react.useState)(pageTitle); |
{ | ||
"name": "@brightleaf/react-hooks", | ||
"version": "4.2.0", | ||
"version": "5.0.0", | ||
"description": "Useful react hooks", | ||
@@ -42,45 +42,45 @@ "files": [ | ||
"dependencies": { | ||
"@hapi/nes": "^11.2.2" | ||
"@hapi/nes": "^12.0.2" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.7.5", | ||
"@babel/core": "^7.7.5", | ||
"@babel/plugin-proposal-class-properties": "^7.7.4", | ||
"@babel/plugin-syntax-dynamic-import": "^7.7.4", | ||
"@babel/preset-env": "^7.7.6", | ||
"@babel/preset-react": "^7.7.4", | ||
"@babel/cli": "^7.10.4", | ||
"@babel/core": "^7.10.4", | ||
"@babel/plugin-proposal-class-properties": "^7.10.4", | ||
"@babel/plugin-syntax-dynamic-import": "^7.8.3", | ||
"@babel/preset-env": "^7.10.4", | ||
"@babel/preset-react": "^7.10.4", | ||
"@kev_nz/async-tools": "^1.2.3", | ||
"@kev_nz/eslint-config": "^5.1.0", | ||
"@kev_nz/eslint-config": "^5.2.2", | ||
"@kev_nz/publisher": "^4.0.1", | ||
"@reach/router": "^1.2.1", | ||
"@testing-library/react": "^9.3.2", | ||
"@testing-library/react-hooks": "^3.2.1", | ||
"babel-loader": "^8.0.6", | ||
"copy-webpack-plugin": "^5.0.5", | ||
"css-loader": "^3.2.1", | ||
"eslint": "^6.7.2", | ||
"eslint-plugin-react-hooks": "^2.3.0", | ||
"graphql-request": "^1.8.2", | ||
"hash-source": "^1.0.4", | ||
"html-loader": "^0.5.5", | ||
"html-webpack-plugin": "^3.2.0", | ||
"@reach/router": "^1.3.4", | ||
"@testing-library/react": "^10.4.5", | ||
"@testing-library/react-hooks": "^3.3.0", | ||
"babel-loader": "^8.1.0", | ||
"copy-webpack-plugin": "^6.0.3", | ||
"css-loader": "^3.6.0", | ||
"eslint": "^7.4.0", | ||
"eslint-plugin-react-hooks": "^4.0.6", | ||
"graphql-request": "^2.0.0", | ||
"hash-source": "^1.0.5", | ||
"html-loader": "^1.1.0", | ||
"html-webpack-plugin": "^4.3.0", | ||
"isom": "^1.0.0", | ||
"jest": "^24.9.0", | ||
"jest-fetch-mock": "^2.1.2", | ||
"jest-localstorage-mock": "^2.4.0", | ||
"jest-websocket-mock": "^2.0.0", | ||
"jest": "^26.1.0", | ||
"jest-fetch-mock": "^3.0.3", | ||
"jest-localstorage-mock": "^2.4.2", | ||
"jest-websocket-mock": "^2.0.2", | ||
"markdown-loader": "^5.1.0", | ||
"mock-socket": "^9.0.2", | ||
"react": ">=16.12.0", | ||
"react-dom": "^16.12.0", | ||
"react-hot-loader": "^4.12.18", | ||
"react-test-renderer": "^16.12.0", | ||
"rollup": "^1.27.9", | ||
"mock-socket": "^9.0.3", | ||
"react": ">=16.13.1", | ||
"react-dom": "^16.13.1", | ||
"react-hot-loader": "^4.12.21", | ||
"react-test-renderer": "^16.13.1", | ||
"rollup": "^2.21.0", | ||
"rollup-plugin-auto-external": "^2.0.0", | ||
"rollup-plugin-commonjs": "^10.1.0", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"style-loader": "^1.0.1", | ||
"webpack": "^4.41.2", | ||
"webpack-cli": "^3.3.10", | ||
"webpack-dev-server": "^3.9.0" | ||
"style-loader": "^1.2.1", | ||
"webpack": "^4.43.0", | ||
"webpack-cli": "^3.3.12", | ||
"webpack-dev-server": "^3.11.0" | ||
}, | ||
@@ -87,0 +87,0 @@ "peerDependencies": { |
@@ -21,2 +21,3 @@ # Brightleaf React Hooks | ||
* [`useTitle`](#title-hook) - Hook to manipulate the page title | ||
* [`useMetaTag`](#meta-tag-hook) - Hook to manipulate meta tags | ||
* [`useScript`](#script-hook) - Hook to add JavaScript to the page | ||
@@ -285,2 +286,22 @@ * [`useStyles`](#style-hook) - Hook to add CSS to the page | ||
## Meta Tag Hook | ||
```jsx | ||
import React, { useEffect } from 'react' | ||
import { useMetaTag } from '@brightleaf/react-hooks' | ||
export default () => { | ||
const [metaValue, setMetaValue] = useMetaTag('description', 'Brightleaf JS React Hooks') | ||
// <meta name="description" content="Brightleaf JS React Hooks"> | ||
setMetaValue('Awesome React Hooks from Brightleaf JS') | ||
// <meta name="description" content="Awesome React Hooks from Brightleaf JS"> | ||
useMetaTag( | ||
'og:title', | ||
'Brightleaf JS React Hooks', | ||
'property' | ||
) | ||
// <meta property="og:title" content="Brightleaf JS React Hooks"> | ||
return <div>The Page</div> | ||
} | ||
``` | ||
# NES Hook | ||
@@ -287,0 +308,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
72012
40
1967
620
+ Added@hapi/b64@5.0.0(transitive)
+ Added@hapi/boom@9.1.4(transitive)
+ Added@hapi/bounce@2.0.0(transitive)
+ Added@hapi/bourne@2.1.0(transitive)
+ Added@hapi/call@8.0.1(transitive)
+ Added@hapi/cryptiles@5.1.0(transitive)
+ Added@hapi/hoek@9.3.0(transitive)
+ Added@hapi/iron@6.0.0(transitive)
+ Added@hapi/nes@12.0.5(transitive)
+ Added@hapi/teamwork@5.1.1(transitive)
+ Added@hapi/topo@5.1.0(transitive)
+ Added@hapi/validate@1.1.3(transitive)
+ Addedws@7.5.10(transitive)
- Removed@hapi/address@2.1.4(transitive)
- Removed@hapi/b64@4.2.1(transitive)
- Removed@hapi/boom@7.4.11(transitive)
- Removed@hapi/bounce@1.3.2(transitive)
- Removed@hapi/bourne@1.3.2(transitive)
- Removed@hapi/call@5.1.3(transitive)
- Removed@hapi/cryptiles@4.2.1(transitive)
- Removed@hapi/formula@1.2.0(transitive)
- Removed@hapi/hoek@8.5.1(transitive)
- Removed@hapi/iron@5.1.4(transitive)
- Removed@hapi/joi@16.1.8(transitive)
- Removed@hapi/nes@11.2.2(transitive)
- Removed@hapi/pinpoint@1.0.2(transitive)
- Removed@hapi/teamwork@3.3.1(transitive)
- Removed@hapi/topo@3.1.6(transitive)
- Removedasync-limiter@1.0.1(transitive)
- Removedws@6.2.3(transitive)
Updated@hapi/nes@^12.0.2