react-state-custom 1.0.23 โ†’ 1.0.25

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.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +85 -1
  3. package/dist/dev-tool/DataViewComponent.d.ts +6 -0
  4. package/dist/dev-tool/DevTool.d.ts +5 -0
  5. package/dist/dev-tool/DevToolState.d.ts +9 -0
  6. package/dist/dev-tool/StateLabelRender.d.ts +2 -0
  7. package/dist/dev-tool/useHighlight.d.ts +11 -0
  8. package/dist/index.d.ts +2 -1
  9. package/dist/index.es.js +332 -488
  10. package/dist/index.es.js.map +1 -1
  11. package/dist/index.umd.js +1 -1
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/react-state-custom.css +1 -1
  14. package/dist/state-utils/createAutoCtx.d.ts +1 -1
  15. package/dist/state-utils/createRootCtx.d.ts +1 -0
  16. package/dist/state-utils/ctx.d.ts +2 -1
  17. package/package.json +22 -3
  18. package/.github/copilot-instructions.md +0 -42
  19. package/.vscode/extensions.json +0 -5
  20. package/.vscode/settings.json +0 -8
  21. package/API_DOCUMENTATION.md +0 -883
  22. package/dist/DevTool.d.ts +0 -4
  23. package/dist/DevToolState.d.ts +0 -15
  24. package/dist/Test.d.ts +0 -1
  25. package/dist/dev.d.ts +0 -1
  26. package/fix-vscode-yarn-pnp.sh +0 -26
  27. package/index.html +0 -14
  28. package/src/DevTool.css +0 -218
  29. package/src/DevTool.tsx +0 -19
  30. package/src/DevToolState.tsx +0 -358
  31. package/src/Test.tsx +0 -97
  32. package/src/dev.tsx +0 -14
  33. package/src/index.ts +0 -21
  34. package/src/state-utils/createAutoCtx.tsx +0 -191
  35. package/src/state-utils/createRootCtx.tsx +0 -117
  36. package/src/state-utils/ctx.ts +0 -346
  37. package/src/state-utils/useArrayHash.ts +0 -53
  38. package/src/state-utils/useObjectHash.ts +0 -53
  39. package/src/state-utils/useQuickSubscribe.ts +0 -110
  40. package/src/state-utils/useRefValue.ts +0 -8
  41. package/src/state-utils/utils.ts +0 -43
  42. package/tsconfig.json +0 -18
  43. package/vite.config.dev.ts +0 -11
  44. package/vite.config.ts +0 -39
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Vo Thanh Dat
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 CHANGED
@@ -4,10 +4,16 @@
4
4
 
5
5
  A lightweight React state management library that combines the simplicity of React hooks with the power of event-driven subscriptions. No boilerplate, no complexityโ€”just pure, performant state management.
6
6
 
7
+ [![Demo](https://img.shields.io/badge/Demo-Live-blue?style=flat-square)](https://vothanhdat.github.io/react-state-custom/)
8
+ [![npm version](https://img.shields.io/npm/v/react-state-custom?style=flat-square)](https://www.npmjs.com/package/react-state-custom)
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
10
+
7
11
  ```bash
8
12
  npm install react-state-custom
9
13
  ```
10
14
 
15
+ ๐ŸŽฎ **[Try the Live Demo โ†’](https://vothanhdat.github.io/react-state-custom/)**
16
+
11
17
  ## Why React State Custom?
12
18
 
13
19
  **Zero Boilerplate** โ€ข **Type-Safe** โ€ข **Selective Re-renders** โ€ข **Hook-Based** โ€ข **~10KB Bundle**
@@ -105,7 +111,7 @@ Full type inference and type safety throughout. Your IDE knows exactly what's in
105
111
  | **Boilerplate** | โœ… None | โŒ Heavy | โœ… Minimal |
106
112
  | **Type Safety** | โœ… Full inference | โš ๏ธ Requires setup | โœ… Good |
107
113
  | **Selective Re-renders** | โœ… Built-in | โš ๏ธ Requires selectors | โœ… Built-in |
108
- | **DevTools** | โš ๏ธ Console logging | โœ… Redux DevTools | โœ… DevTools support |
114
+ | **DevTools** | โœ… Built-in UI | โœ… Redux DevTools | โœ… DevTools support |
109
115
  | **Async Support** | โœ… Native (hooks) | โš ๏ธ Requires middleware | โœ… Native |
110
116
  | **Context Composition** | โœ… Automatic | โŒ Manual | โš ๏ธ Manual store combination |
111
117
 
@@ -243,6 +249,37 @@ const { useCtxState } = createAutoCtx(rootContext);
243
249
 
244
250
  ## ๐Ÿš€ Advanced Features
245
251
 
252
+ ### Developer Tools
253
+ Visual debugging component to inspect all your context data in real-time:
254
+
255
+ ```typescript
256
+ import { DevToolContainer } from 'react-state-custom';
257
+ import 'react-state-custom/dist/react-state-custom.css';
258
+
259
+ function App() {
260
+ return (
261
+ <>
262
+ <AutoRootCtx />
263
+ <YourAppContent />
264
+ <DevToolContainer />
265
+ </>
266
+ );
267
+ }
268
+ ```
269
+
270
+ **Custom data viewer with rich object visualization:**
271
+ ```typescript
272
+ import { DataViewComponent } from 'react-state-custom';
273
+ import { ObjectView } from 'react-obj-view';
274
+ import 'react-obj-view/dist/react-obj-view.css'; // Required for ObjectView styling
275
+
276
+ const CustomDataView: DataViewComponent = ({ name, value }) => {
277
+ return <ObjectView name={name} value={value} expandLevel={2} />;
278
+ };
279
+
280
+ <DevToolContainer Component={CustomDataView} />
281
+ ```
282
+
246
283
  ### Parameterized Contexts
247
284
  Create multiple instances of the same state with different parameters:
248
285
 
@@ -285,10 +322,57 @@ const userStats = useDataSubscribeWithTransform(
285
322
  );
286
323
  ```
287
324
 
325
+ ## ๐ŸŽฎ Live Examples
326
+
327
+ Explore interactive examples in the **[Live Demo](https://vothanhdat.github.io/react-state-custom/)**:
328
+
329
+ - **Counter** - Basic state management with increment, decrement, and reset
330
+ - **Todo List** - Multiple independent lists with scoped contexts
331
+ - **Form Validation** - Real-time validation with error handling
332
+ - **Timer** - Side effects and cleanup with millisecond precision
333
+ - **Shopping Cart** - Complex state with derived values (total, itemCount)
334
+
335
+ Each example includes live code editing with syntax highlighting, powered by Sandpack!
336
+
288
337
  ## ๐Ÿ“– Documentation
289
338
 
290
339
  For complete API documentation, examples, and advanced patterns, see:
291
340
  - **[API_DOCUMENTATION.md](./API_DOCUMENTATION.md)** - Complete API reference
341
+ - **[Live Demo](https://vothanhdat.github.io/react-state-custom/)** - Interactive examples
342
+
343
+ ## ๐Ÿ› ๏ธ Development
344
+
345
+ ```bash
346
+ # Install dependencies
347
+ yarn install
348
+
349
+ # Run development UI with example selector
350
+ yarn dev
351
+
352
+ # Run interactive playground with live code editing
353
+ yarn dev:playground
354
+
355
+ # Build library
356
+ yarn build
357
+
358
+ # Build demo site
359
+ yarn build:demo
360
+
361
+ # Preview demo locally
362
+ yarn preview
363
+ ```
364
+
365
+ ### Development Modes
366
+
367
+ **`yarn dev`** - Starts a clean development UI with an interactive example selector. Great for:
368
+ - Testing all examples in one place
369
+ - Quick switching between different examples
370
+ - Visual debugging with DevTool component
371
+
372
+ **`yarn dev:playground`** - Starts the Sandpack-powered playground with live code editing. Perfect for:
373
+ - Creating interactive demos
374
+ - Live code editing and experimentation
375
+ - Sharing editable examples
292
376
 
293
377
  ## ๐ŸŽ“ Learning Path
294
378
 
@@ -0,0 +1,6 @@
1
+ import { default as React } from 'react';
2
+ export type DataViewComponent = React.FC<{
3
+ value: any;
4
+ name: string;
5
+ }>;
6
+ export declare const DataViewDefault: DataViewComponent;
@@ -0,0 +1,5 @@
1
+ export declare const DevToolContainer: ({ toggleButton, Component, ...props }: {
2
+ [x: string]: any;
3
+ toggleButton?: string | undefined;
4
+ Component?: import('./DataViewComponent').DataViewComponent | undefined;
5
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { default as React } from 'react';
2
+ import { DataViewComponent } from './DataViewComponent';
3
+ export declare const DevToolState: React.FC<{
4
+ Component: DataViewComponent;
5
+ }>;
6
+ export declare const StateView: React.FC<{
7
+ dataKey: string;
8
+ Component: DataViewComponent;
9
+ }>;
@@ -0,0 +1,2 @@
1
+ import { default as React } from 'react';
2
+ export declare const StateLabelRender: React.FC<any>;
@@ -0,0 +1,11 @@
1
+ import { default as React } from 'react';
2
+ export declare function useHighlight(filterString: string): {
3
+ highlight: RegExp;
4
+ };
5
+ export declare const HightlightWrapper: React.FC<{
6
+ highlight: string;
7
+ children: any;
8
+ }>;
9
+ export declare const HighlightString: React.FC<{
10
+ text: string;
11
+ }>;
package/dist/index.d.ts CHANGED
@@ -3,4 +3,5 @@ export { createRootCtx } from './state-utils/createRootCtx';
3
3
  export { AutoRootCtx, createAutoCtx } from './state-utils/createAutoCtx';
4
4
  export { useArrayHash } from './state-utils/useArrayHash';
5
5
  export { useQuickSubscribe } from './state-utils/useQuickSubscribe';
6
- export { DevToolContainer } from './DevTool';
6
+ export { DevToolContainer } from './dev-tool/DevTool';
7
+ export type { DataViewComponent } from './dev-tool/DataViewComponent';