react-globo-state 1.0.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/CODEOWNERS +1 -0
- package/COPYRIGHT.md +4 -0
- package/LICENSE +9 -0
- package/README.md +85 -0
- package/SECURITY.md +3 -0
- package/index.d.ts +9 -0
- package/index.js +1 -0
- package/package.json +39 -0
package/CODEOWNERS
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* @passariello
|
package/COPYRIGHT.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# MIT license
|
|
2
|
+
|
|
3
|
+
Copyright 1995 - 2026 Dario Passariello
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# [React Globo State](https://npmjs.com/package/react-globo-state)
|
|
2
|
+
|
|
3
|
+
You can pass a react component or html element and append it where you want.
|
|
4
|
+
|
|
5
|
+
**React Globo State** by [Dario Passariello](https://dario.passariello.ca) (c)
|
|
6
|
+
|
|
7
|
+
[](https://npmjs.org/package/react-globo-state)
|
|
8
|
+
[](https://npmjs.org/package/react-globo-state)
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+

|
|
12
|
+

|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
## install
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm i -D react-globo-state
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
You use:
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
|
|
25
|
+
// Import the init
|
|
26
|
+
import globoState from "react-globo-state"
|
|
27
|
+
|
|
28
|
+
// start the state
|
|
29
|
+
// * need to be inside your App() only at top and one time...
|
|
30
|
+
|
|
31
|
+
globoState()
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
> now you can use your global react state everywhere.
|
|
36
|
+
|
|
37
|
+
## EXAMPLE
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
import globoState from "react-globo-state"
|
|
41
|
+
|
|
42
|
+
const App = () => {
|
|
43
|
+
|
|
44
|
+
// init gState
|
|
45
|
+
globoState()
|
|
46
|
+
|
|
47
|
+
return <div>MyApp</div>
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## how works and use
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
|
|
57
|
+
// now you can use your global react state everywhere.
|
|
58
|
+
// you can use also in useEffect and Dispatch
|
|
59
|
+
|
|
60
|
+
// Create a state
|
|
61
|
+
gState.set("name", { test:"test" })
|
|
62
|
+
|
|
63
|
+
// Get a state
|
|
64
|
+
gState.get("name")
|
|
65
|
+
|
|
66
|
+
// Remove a state
|
|
67
|
+
gState.remove("name")
|
|
68
|
+
// or
|
|
69
|
+
gState.delete("name")
|
|
70
|
+
|
|
71
|
+
// gState.deleteAll() // coming soon
|
|
72
|
+
|
|
73
|
+
// List all states
|
|
74
|
+
gState.list()
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## See a demo
|
|
79
|
+
|
|
80
|
+
If you are interested to see a demo live visit [EXAMPLEPAGE](https://examplepage.picla.net) and look the console.
|
|
81
|
+
|
|
82
|
+
Thank you!
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
Copyright by
|
package/SECURITY.md
ADDED
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useState as u}from"react";const e={},n=s=>{const[r,o]=u(null);return globalThis.gState={get:t=>{if(t&&t)return r?.[t]?r[t]:null},set:(t,l)=>{!t||!l||(e[t]=l,o({...e}))},remove:t=>{t&&(delete e[t],o({...e}))},delete:t=>{t&&gState.remove(t)},list:()=>r},n};var g=n;export{g as default,n as globoState};
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-globo-state",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A react state everywhere made easy",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"react",
|
|
8
|
+
"state",
|
|
9
|
+
"render",
|
|
10
|
+
"global",
|
|
11
|
+
"component",
|
|
12
|
+
"dario",
|
|
13
|
+
"passariello"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "Dario Passariello",
|
|
17
|
+
"type": "module",
|
|
18
|
+
"main": "./index.js",
|
|
19
|
+
"types": "./index.d.ts",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"react": "^19.2.3",
|
|
22
|
+
"react-dom": "^19.2.3"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "node ./esbuild.config.mjs",
|
|
26
|
+
"npm:publish": "npm run build && npm publish ./dist"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@typescript-eslint/eslint-plugin": "8.53.0",
|
|
30
|
+
"@typescript-eslint/parser": "8.53.0",
|
|
31
|
+
"esbuild": "0.27.2",
|
|
32
|
+
"esbuild-plugin-copy": "2.1.1",
|
|
33
|
+
"eslint": "9.39.2",
|
|
34
|
+
"ts-jest": "29.4.6",
|
|
35
|
+
"ts-node": "^10.9.2",
|
|
36
|
+
"tslib": "^2.8.1",
|
|
37
|
+
"typescript": "^5.9.3"
|
|
38
|
+
}
|
|
39
|
+
}
|