react-state-bucket 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/LICENSE +21 -0
- package/README.md +181 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +134 -0
- package/dist/index.js.map +1 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Naxrul Ahmed
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# React Mini State
|
|
2
|
+
|
|
3
|
+
`react-state-bucket` is a lightweight state management library for React. It allows developers to create global states that can be accessed and modified from any component. The state can be stored in memory, session storage, or the URL query parameters, providing flexibility for different use cases.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Lightweight and easy-to-use global state management.
|
|
8
|
+
- Supports three storage options: memory, session storage, and URL.
|
|
9
|
+
- Fully TypeScript-supported API.
|
|
10
|
+
- React hook-based implementation for seamless integration.
|
|
11
|
+
- Ideal for both small and large-scale React applications.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
Install the package via npm or yarn:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install react-state-bucket
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
or
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
yarn add react-state-bucket
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### Importing the Package
|
|
30
|
+
|
|
31
|
+
The package is designed for use with React's client-side components. Start by importing the required functionality:
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
"use client";
|
|
35
|
+
import { createState } from "react-state-bucket";
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Creating a State
|
|
39
|
+
|
|
40
|
+
Use the `createState` function to define a global state. Provide an initial state object and optionally specify the storage type (`"memory"`, `"session"`, or `"url"`).
|
|
41
|
+
|
|
42
|
+
```javascript
|
|
43
|
+
const useGlobalState = createState({
|
|
44
|
+
count: 0,
|
|
45
|
+
name: "React",
|
|
46
|
+
}, {
|
|
47
|
+
store: "memory", // Optional: Defaults to "memory"
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Using the State in Components
|
|
52
|
+
|
|
53
|
+
Components can access and manipulate the state by calling the `useGlobalState` hook.
|
|
54
|
+
|
|
55
|
+
#### Example:
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
import React from "react";
|
|
59
|
+
|
|
60
|
+
function Counter() {
|
|
61
|
+
const state = useGlobalState();
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<div>
|
|
65
|
+
<h1>Count: {state.get("count")}</h1>
|
|
66
|
+
<button onClick={() => state.set("count", state.get("count") + 1)}>
|
|
67
|
+
Increment
|
|
68
|
+
</button>
|
|
69
|
+
<button onClick={() => state.delete("count")}>Reset</button>
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function App() {
|
|
75
|
+
return (
|
|
76
|
+
<div>
|
|
77
|
+
<Counter />
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export default App;
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### State API
|
|
86
|
+
|
|
87
|
+
When you call the hook returned by `createState`, you gain access to a set of utility methods:
|
|
88
|
+
|
|
89
|
+
| Method | Description |
|
|
90
|
+
| ----------------- | ---------------------------------------------------------- |
|
|
91
|
+
| `set(key, value)` | Sets the value of a specific key in the state. |
|
|
92
|
+
| `get(key)` | Gets the value of a specific key from the state. |
|
|
93
|
+
| `delete(key)` | Deletes a specific key from the state. |
|
|
94
|
+
| `clear()` | Clears all keys from the state. |
|
|
95
|
+
| `getState()` | Retrieves the entire state object. |
|
|
96
|
+
| `setState(state)` | Updates the state with a partial object. |
|
|
97
|
+
| `isChange(key)` | Checks if a specific key has changed since the last clear. |
|
|
98
|
+
| `getChanges()` | Retrieves an object representing all changed keys. |
|
|
99
|
+
| `clearChanges()` | Clears the record of changes. |
|
|
100
|
+
|
|
101
|
+
### Storage Options
|
|
102
|
+
|
|
103
|
+
The `createState` function supports three storage types:
|
|
104
|
+
|
|
105
|
+
1. **Memory (default):** Stores the state in memory for the duration of the session.
|
|
106
|
+
2. **Session:** Persists the state in `sessionStorage` across page reloads.
|
|
107
|
+
3. **URL:** Stores the state in the URL's query parameters, enabling sharable states.
|
|
108
|
+
|
|
109
|
+
#### Example with URL Storage:
|
|
110
|
+
|
|
111
|
+
```javascript
|
|
112
|
+
const useURLState = createState({
|
|
113
|
+
theme: "light",
|
|
114
|
+
}, {
|
|
115
|
+
store: "url",
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
function ThemeSwitcher() {
|
|
119
|
+
const state = useURLState();
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<button onClick={() => state.set("theme", state.get("theme") === "light" ? "dark" : "light")}>
|
|
123
|
+
Toggle Theme (Current: {state.get("theme")})
|
|
124
|
+
</button>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Real-World Example
|
|
130
|
+
|
|
131
|
+
### Managing a Multi-Step Form
|
|
132
|
+
|
|
133
|
+
```javascript
|
|
134
|
+
const useFormState = createState({
|
|
135
|
+
step: 1,
|
|
136
|
+
formData: {},
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
function MultiStepForm() {
|
|
140
|
+
const state = useFormState();
|
|
141
|
+
|
|
142
|
+
const nextStep = () => state.set("step", state.get("step") + 1);
|
|
143
|
+
const prevStep = () => state.set("step", state.get("step") - 1);
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<div>
|
|
147
|
+
<h2>Step {state.get("step")}</h2>
|
|
148
|
+
<button onClick={prevStep} disabled={state.get("step") === 1}>Back</button>
|
|
149
|
+
<button onClick={nextStep}>Next</button>
|
|
150
|
+
</div>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Best Practices
|
|
156
|
+
|
|
157
|
+
- Use `memory` storage for temporary UI states that don't need persistence.
|
|
158
|
+
- Use `session` storage for states that should persist across page reloads but not sessions.
|
|
159
|
+
- Use `url` storage for sharable states, like filters or query parameters.
|
|
160
|
+
|
|
161
|
+
## FAQs
|
|
162
|
+
|
|
163
|
+
### 1. Can I use `react-state-bucket` in a server-side rendered (SSR) application?
|
|
164
|
+
Currently, `react-state-bucket` is designed for client-side use only.
|
|
165
|
+
|
|
166
|
+
### 2. What happens if I try to set an undefined key?
|
|
167
|
+
An error will be thrown, ensuring state integrity.
|
|
168
|
+
|
|
169
|
+
### 3. Can I use this package with TypeScript?
|
|
170
|
+
Yes, `react-state-bucket` fully supports TypeScript with type-safe APIs.
|
|
171
|
+
|
|
172
|
+
## GitHub Repository
|
|
173
|
+
|
|
174
|
+
Find the source code and contribute to the project on GitHub:
|
|
175
|
+
[https://github.com/devnax/react-state-bucket.git](https://github.com/devnax/react-state-bucket.git)
|
|
176
|
+
|
|
177
|
+
[](https://www.npmjs.com/package/react-state-bucket)
|
|
178
|
+
|
|
179
|
+
## License
|
|
180
|
+
|
|
181
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type Option = {
|
|
2
|
+
store: "memory" | "session" | "url";
|
|
3
|
+
};
|
|
4
|
+
export declare const createState: <IT extends {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}>(initial: IT, option?: Option) => () => {
|
|
7
|
+
set: <T extends keyof IT>(key: T, value: IT[T]) => void;
|
|
8
|
+
get: <T extends keyof IT>(key: T) => IT[T];
|
|
9
|
+
delete: <T extends keyof IT>(key: T) => void;
|
|
10
|
+
clear: () => void;
|
|
11
|
+
getState: () => IT;
|
|
12
|
+
setState: (state: Partial<IT>) => void;
|
|
13
|
+
isChange: <T extends keyof IT>(key: T) => boolean;
|
|
14
|
+
getChanges: () => { [key in keyof IT]: boolean; };
|
|
15
|
+
clearChanges: () => void;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useId, useState } from "react";
|
|
3
|
+
export const createState = (initial, option) => {
|
|
4
|
+
const hooks = new Map();
|
|
5
|
+
let data = new Map();
|
|
6
|
+
let changes = new Map();
|
|
7
|
+
let url = new URL(window.location.href);
|
|
8
|
+
let _option = {
|
|
9
|
+
store: "memory",
|
|
10
|
+
...option,
|
|
11
|
+
};
|
|
12
|
+
const setIntial = () => {
|
|
13
|
+
for (let key in initial) {
|
|
14
|
+
let value = initial[key];
|
|
15
|
+
switch (_option.store) {
|
|
16
|
+
case "memory":
|
|
17
|
+
data.set(key, value);
|
|
18
|
+
break;
|
|
19
|
+
case "session":
|
|
20
|
+
if (!sessionStorage.getItem(key)) {
|
|
21
|
+
sessionStorage.setItem(key, value);
|
|
22
|
+
}
|
|
23
|
+
break;
|
|
24
|
+
case "url":
|
|
25
|
+
if (!url.searchParams.has(key)) {
|
|
26
|
+
url.searchParams.set(key, value);
|
|
27
|
+
window.history.replaceState(null, '', url.toString());
|
|
28
|
+
}
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
changes.set(key, true);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
setIntial();
|
|
35
|
+
const useHook = () => {
|
|
36
|
+
const id = useId();
|
|
37
|
+
const [, up] = useState(0);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
hooks.set(id, () => up(Math.random()));
|
|
40
|
+
return () => {
|
|
41
|
+
hooks.delete(id);
|
|
42
|
+
};
|
|
43
|
+
}, []);
|
|
44
|
+
const root = {
|
|
45
|
+
set: (key, value) => {
|
|
46
|
+
if (!(key in initial))
|
|
47
|
+
throw new Error(`(${key}) Invalid key provided in the set function. Please verify the structure of the initial state data.`);
|
|
48
|
+
switch (_option.store) {
|
|
49
|
+
case "memory":
|
|
50
|
+
data.set(key, value);
|
|
51
|
+
break;
|
|
52
|
+
case "session":
|
|
53
|
+
sessionStorage.setItem(key, value);
|
|
54
|
+
break;
|
|
55
|
+
case "url":
|
|
56
|
+
url.searchParams.set(key, value);
|
|
57
|
+
window.history.replaceState(null, '', url.toString());
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
changes.set(key, true);
|
|
61
|
+
hooks.forEach(d => d());
|
|
62
|
+
},
|
|
63
|
+
get: (key) => {
|
|
64
|
+
switch (_option.store) {
|
|
65
|
+
case "memory":
|
|
66
|
+
return data.get(key);
|
|
67
|
+
case "session":
|
|
68
|
+
return sessionStorage.getItem(key);
|
|
69
|
+
case "url":
|
|
70
|
+
return url.searchParams.get(key);
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
delete: (key) => {
|
|
74
|
+
switch (_option.store) {
|
|
75
|
+
case "memory":
|
|
76
|
+
data.delete(key);
|
|
77
|
+
break;
|
|
78
|
+
case "session":
|
|
79
|
+
sessionStorage.removeItem(key);
|
|
80
|
+
break;
|
|
81
|
+
case "url":
|
|
82
|
+
url.searchParams.delete(key);
|
|
83
|
+
window.history.replaceState(null, '', url.toString());
|
|
84
|
+
console.log(url.searchParams);
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
changes.set(key, true);
|
|
88
|
+
hooks.forEach(d => d());
|
|
89
|
+
},
|
|
90
|
+
clear: () => {
|
|
91
|
+
for (let key in initial) {
|
|
92
|
+
root.delete(key);
|
|
93
|
+
changes.set(key, true);
|
|
94
|
+
}
|
|
95
|
+
hooks.forEach(d => d());
|
|
96
|
+
},
|
|
97
|
+
getState: () => {
|
|
98
|
+
let d = {};
|
|
99
|
+
for (let key of data.keys()) {
|
|
100
|
+
d[key] = root.get(key);
|
|
101
|
+
}
|
|
102
|
+
return d;
|
|
103
|
+
},
|
|
104
|
+
setState: (state) => {
|
|
105
|
+
for (let key in state) {
|
|
106
|
+
if (!(key in initial))
|
|
107
|
+
throw new Error(`(${key}) Invalid key provided in the setState function. Please verify the structure of the initial state data.`);
|
|
108
|
+
root.set(key, state[key]);
|
|
109
|
+
changes.set(key, true);
|
|
110
|
+
}
|
|
111
|
+
hooks.forEach(d => d());
|
|
112
|
+
},
|
|
113
|
+
isChange: (key) => Boolean(changes.get(key)),
|
|
114
|
+
getChanges: () => {
|
|
115
|
+
let _changes = {};
|
|
116
|
+
for (let key of changes.keys()) {
|
|
117
|
+
const is = changes.get(key);
|
|
118
|
+
if (is) {
|
|
119
|
+
_changes[key] = true;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return _changes;
|
|
123
|
+
},
|
|
124
|
+
clearChanges: () => {
|
|
125
|
+
for (let key of changes.keys()) {
|
|
126
|
+
changes.set(key, false);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
return root;
|
|
131
|
+
};
|
|
132
|
+
return useHook;
|
|
133
|
+
};
|
|
134
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AACZ,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAMlD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAoC,OAAW,EAAE,MAAe,EAAE,EAAE;IAC3F,MAAM,KAAK,GAAG,IAAI,GAAG,EAAoB,CAAA;IACzC,IAAI,IAAI,GAAG,IAAI,GAAG,EAAY,CAAA;IAC9B,IAAI,OAAO,GAAG,IAAI,GAAG,EAAmB,CAAA;IACxC,IAAI,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAExC,IAAI,OAAO,GAAW;QAClB,KAAK,EAAE,QAAQ;QACf,GAAG,MAAM;KACZ,CAAA;IAED,MAAM,SAAS,GAAG,GAAG,EAAE;QACnB,KAAK,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;YACtB,IAAI,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;YACxB,QAAQ,OAAO,CAAC,KAAK,EAAE,CAAC;gBACpB,KAAK,QAAQ;oBACT,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;oBACpB,MAAM;gBACV,KAAK,SAAS;oBACV,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;wBAC/B,cAAc,CAAC,O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AE,CAAC,CAAC,EAAE,CAAC,CAAA;YAC3B,CAAC;YAED,QAAQ,EAAE,CAAqB,GAAM,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,GAAa,CAAC,CAAC;YAC7E,UAAU,EAAE,GAAG,EAAE;gBACb,IAAI,QAAQ,GAAQ,EAAE,CAAA;gBACtB,KAAK,IAAI,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;oBAC7B,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,GAAa,CAAC,CAAA;oBACrC,IAAI,EAAE,EAAE,CAAC;wBACL,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;oBACxB,CAAC;gBACL,CAAC;gBACD,OAAO,QAA0C,CAAA;YACrD,CAAC;YACD,YAAY,EAAE,GAAG,EAAE;gBACf,KAAK,IAAI,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;oBAC7B,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;gBAC3B,CAAC;YACL,CAAC;SACJ,CAAA;QAED,OAAO,IAAI,CAAA;IACf,CAAC,CAAA;IAED,OAAO,OAAO,CAAA;AAClB,CAAC,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.0",
|
|
3
|
+
"name": "react-state-bucket",
|
|
4
|
+
"author": "Naxrul Ahmed",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"typings": "dist/index.d.ts",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "github",
|
|
10
|
+
"url": "https://github.com/devnax/react-state-bucket.git"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=10"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"start": "parcel index.html",
|
|
20
|
+
"build": "npx rimraf ./dist && npx tsc",
|
|
21
|
+
"prepare": "npm run build"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"react": ">=16"
|
|
25
|
+
},
|
|
26
|
+
"prettier": {
|
|
27
|
+
"printWidth": 80,
|
|
28
|
+
"semi": true,
|
|
29
|
+
"singleQuote": true,
|
|
30
|
+
"trailingComma": "es5"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@size-limit/preset-small-lib": "^11.1.4",
|
|
34
|
+
"@types/react": "^18.3.3",
|
|
35
|
+
"@types/react-dom": "^18.3.0",
|
|
36
|
+
"parcel": "^2.12.0",
|
|
37
|
+
"process": "^0.11.10",
|
|
38
|
+
"react": "^18.3.1",
|
|
39
|
+
"react-dom": "^18.3.1",
|
|
40
|
+
"typescript": "^5.5.3"
|
|
41
|
+
}
|
|
42
|
+
}
|