@dezkareid/react-hooks 1.1.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/README.md +25 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index2.js +1 -0
- package/dist/cjs/useLocalStorage-ecc946ba.js +1 -0
- package/dist/es/index.js +1 -0
- package/dist/es/index2.js +1 -0
- package/dist/es/useLocalStorage-b2c4f517.js +1 -0
- package/package.json +77 -0
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# React hooks
|
|
2
|
+
|
|
3
|
+
This is just a collection of common functionality I use in my projects
|
|
4
|
+
|
|
5
|
+
## Before to start
|
|
6
|
+
You need the next packages installed:
|
|
7
|
+
* react: ^16.0.0 || ^17.0.0
|
|
8
|
+
|
|
9
|
+
## Getting started
|
|
10
|
+
|
|
11
|
+
To install `@dezkareid/react-hooks` in your project, run next command:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install -S @dezkareid/react-hooks
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
or
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
yarn add @dezkareid/react-hooks
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## List of hooks
|
|
24
|
+
|
|
25
|
+
* [useLocalStorage](src/useLocalStorage/README.md)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("./useLocalStorage-ecc946ba.js");exports.useLocalStorage=t.useLocalStorage,exports.useEventListener=function(t){var r=t.element,n=t.event,o=t.callback;e.useEffect((function(){return r.addEventListener(n,o),function(){r.removeEventListener(n,o)}}),[r,n,o])};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./useLocalStorage-ecc946ba.js");require("react"),module.exports=e.useLocalStorage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=require("react");function r(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}function e(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,a,o=[],l=!0,u=!1;try{for(e=e.call(t);!(l=(n=e.next()).done)&&(o.push(n.value),!r||o.length!==r);l=!0);}catch(t){u=!0,a=t}finally{try{l||null==e.return||e.return()}finally{if(u)throw a}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}exports.useLocalStorage=function(r){var n=r.key,a=r.defaultValue,o=e(t.useState(a),2),l=o[0],u=o[1];return t.useEffect((function(){if(n){var t=localStorage.getItem(n);null!==t&&u(t)}}),[n]),{value:l,saveValue:t.useCallback((function(t){localStorage.setItem(n,t),u(t)}),[n])}};
|
package/dist/es/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useEffect as e}from"react";export{u as useLocalStorage}from"./useLocalStorage-b2c4f517.js";function t(t){var r=t.element,n=t.event,o=t.callback;e((function(){return r.addEventListener(n,o),function(){r.removeEventListener(n,o)}}),[r,n,o])}export{t as useEventListener};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as o}from"./useLocalStorage-b2c4f517.js";export{u as default}from"./useLocalStorage-b2c4f517.js";import"react";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useState as t,useEffect as r,useCallback as e}from"react";function n(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}function o(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,a=[],l=!0,u=!1;try{for(e=e.call(t);!(l=(n=e.next()).done)&&(a.push(n.value),!r||a.length!==r);l=!0);}catch(t){u=!0,o=t}finally{try{l||null==e.return||e.return()}finally{if(u)throw o}}return a}}(t,r)||function(t,r){if(t){if("string"==typeof t)return n(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?n(t,r):void 0}}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(n){var a=n.key,l=n.defaultValue,u=o(t(l),2),i=u[0],c=u[1];return r((function(){if(a){var t=localStorage.getItem(a);null!==t&&c(t)}}),[a]),{value:i,saveValue:e((function(t){localStorage.setItem(a,t),c(t)}),[a])}}export{a as u};
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dezkareid/react-hooks",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "set of react hooks with common functionalities",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"hooks"
|
|
8
|
+
],
|
|
9
|
+
"sideEffects": false,
|
|
10
|
+
"author": "Joel Humberto Gomez Paredes <elmaildeldezkareid@gmail.com>",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"main": "dist/cjs/index.js",
|
|
13
|
+
"module": "dist/es/index.js",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "rollup -c",
|
|
19
|
+
"lint": "eslint ./src",
|
|
20
|
+
"lint:fix": "npm run lint -- --fix",
|
|
21
|
+
"semantic-release": "npx semantic-release",
|
|
22
|
+
"test": "jest",
|
|
23
|
+
"test:watch": "npm run test -- --watch"
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/dezkareid/dezkareid.git"
|
|
28
|
+
},
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/dezkareid/dezkareid/issues"
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=14.17"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"react": "^16.0.0 || ^17.0.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@babel/cli": "^7.15.4",
|
|
43
|
+
"@babel/core": "^7.15.5",
|
|
44
|
+
"@babel/plugin-proposal-export-default-from": "^7.14.5",
|
|
45
|
+
"@babel/plugin-transform-runtime": "^7.15.0",
|
|
46
|
+
"@babel/preset-env": "^7.15.4",
|
|
47
|
+
"@rollup/plugin-babel": "^5.3.0",
|
|
48
|
+
"@rollup/plugin-commonjs": "^20.0.0",
|
|
49
|
+
"@rollup/plugin-node-resolve": "^13.0.5",
|
|
50
|
+
"@semantic-release/changelog": "^6.0.0",
|
|
51
|
+
"@semantic-release/git": "^10.0.0",
|
|
52
|
+
"@testing-library/dom": "^8.7.1",
|
|
53
|
+
"@testing-library/jest-dom": "^5.14.1",
|
|
54
|
+
"@testing-library/react": "^12.1.1",
|
|
55
|
+
"@testing-library/react-hooks": "^7.0.2",
|
|
56
|
+
"babel-eslint": "^10.1.0",
|
|
57
|
+
"babel-jest": "^27.2.4",
|
|
58
|
+
"babel-loader": "^8.2.2",
|
|
59
|
+
"eslint": "^7.32.0",
|
|
60
|
+
"eslint-config-airbnb": "^18.2.1",
|
|
61
|
+
"eslint-config-airbnb-base": "^14.2.1",
|
|
62
|
+
"eslint-config-prettier": "^8.3.0",
|
|
63
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
64
|
+
"eslint-plugin-react": "^7.26.1",
|
|
65
|
+
"eslint-plugin-react-hooks": "^4.2.0",
|
|
66
|
+
"jest": "^27.2.4",
|
|
67
|
+
"prettier": "^2.4.1",
|
|
68
|
+
"react": "^17.0.2",
|
|
69
|
+
"react-test-renderer": "^17.0.2",
|
|
70
|
+
"rollup": "^2.56.3",
|
|
71
|
+
"rollup-plugin-bundle-size": "^1.0.3",
|
|
72
|
+
"rollup-plugin-cleaner": "^1.0.0",
|
|
73
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
74
|
+
"semantic-release": "^18.0.0",
|
|
75
|
+
"semantic-release-monorepo": "^7.0.5"
|
|
76
|
+
}
|
|
77
|
+
}
|