@okyrychenko-dev/react-action-guard 0.6.1 → 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/README.md +23 -13
- package/dist/index.cjs +179 -132
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +446 -411
- package/dist/index.d.ts +446 -411
- package/dist/index.js +174 -130
- package/dist/index.js.map +1 -1
- package/package.json +12 -11
package/README.md
CHANGED
|
@@ -36,8 +36,14 @@ pnpm add @okyrychenko-dev/react-action-guard zustand
|
|
|
36
36
|
|
|
37
37
|
This package requires the following peer dependencies:
|
|
38
38
|
|
|
39
|
-
- [React](https://react.dev/) ^
|
|
40
|
-
- [Zustand](https://zustand-demo.pmnd.rs/) ^
|
|
39
|
+
- [React](https://react.dev/) ^18.0.0 || ^19.0.0
|
|
40
|
+
- [Zustand](https://zustand-demo.pmnd.rs/) ^5.0.0 - State management library
|
|
41
|
+
|
|
42
|
+
## 1.0 Migration
|
|
43
|
+
|
|
44
|
+
`1.0.0` removes public re-exports of internal `react-zustand-toolkit` helpers from the root package.
|
|
45
|
+
|
|
46
|
+
If you previously imported `createShallowStore`, `createStoreToolkit`, `createStoreProvider`, or `createResolvedStoreHooks` from `@okyrychenko-dev/react-action-guard`, import them directly from `@okyrychenko-dev/react-zustand-toolkit` instead.
|
|
41
47
|
|
|
42
48
|
## Quick Start
|
|
43
49
|
|
|
@@ -65,7 +71,7 @@ npm run storybook
|
|
|
65
71
|
|
|
66
72
|
### Hooks
|
|
67
73
|
|
|
68
|
-
#### `useBlocker(blockerId, config, isActive)`
|
|
74
|
+
#### `useBlocker(blockerId, config, isActive?)`
|
|
69
75
|
|
|
70
76
|
Automatically adds a blocker when the component mounts and removes it on unmount.
|
|
71
77
|
|
|
@@ -80,6 +86,8 @@ Automatically adds a blocker when the component mounts and removes it on unmount
|
|
|
80
86
|
- `onTimeout?: (blockerId: string) => void` - Callback when auto-removed
|
|
81
87
|
- `isActive?: boolean` - Whether the blocker is active (default: true)
|
|
82
88
|
|
|
89
|
+
When `isActive` is `true`, changing `config` updates the existing blocker via `updateBlocker` without requiring unmount/remount.
|
|
90
|
+
|
|
83
91
|
**Example:**
|
|
84
92
|
|
|
85
93
|
```jsx
|
|
@@ -422,9 +430,17 @@ function MicroFrontend() {
|
|
|
422
430
|
|
|
423
431
|
#### Context Hooks
|
|
424
432
|
|
|
425
|
-
- `useUIBlockingContext()` - Get store from context (throws if outside provider)
|
|
433
|
+
- `useUIBlockingContext()` - Get store API from context (throws if outside provider)
|
|
434
|
+
- `useOptionalUIBlockingContext()` - Get store API from context or `null` outside provider
|
|
426
435
|
- `useIsInsideUIBlockingProvider()` - Check if inside a provider
|
|
427
436
|
- `useUIBlockingStoreFromContext(selector)` - Select state from context store
|
|
437
|
+
- `useResolvedStoreApi()` - Resolve to provider store API or global store API
|
|
438
|
+
- `useResolvedValue(selector)` - Resolve to provider/global store and select with shallow comparison
|
|
439
|
+
|
|
440
|
+
Legacy aliases remain available for backward compatibility:
|
|
441
|
+
- `useOptionalContext()` -> `useOptionalUIBlockingContext()`
|
|
442
|
+
- `useResolvedStore()` -> `useResolvedStoreApi()`
|
|
443
|
+
- `useResolvedStoreWithSelector()` -> `useResolvedValue()`
|
|
428
444
|
|
|
429
445
|
### Store
|
|
430
446
|
|
|
@@ -505,15 +521,6 @@ uiBlockingStoreApi.getState().addBlocker("server-call", {
|
|
|
505
521
|
});
|
|
506
522
|
```
|
|
507
523
|
|
|
508
|
-
### Store Toolkit Helpers
|
|
509
|
-
|
|
510
|
-
Advanced store helpers are re-exported from the internal toolkit for custom setups:
|
|
511
|
-
|
|
512
|
-
- `createShallowStore`
|
|
513
|
-
- `createStoreToolkit`
|
|
514
|
-
- `createStoreProvider`
|
|
515
|
-
- `createResolvedStoreHooks`
|
|
516
|
-
|
|
517
524
|
## Middleware System
|
|
518
525
|
|
|
519
526
|
The library includes a powerful middleware system that allows you to hook into blocker lifecycle events for analytics, logging, and performance monitoring.
|
|
@@ -604,6 +611,9 @@ configureMiddleware([
|
|
|
604
611
|
```
|
|
605
612
|
|
|
606
613
|
Note: `configureMiddleware` registers middleware on the global store. If you use `UIBlockingProvider`, register middleware via the provider's `middlewares` prop instead.
|
|
614
|
+
Each `configureMiddleware(...)` call replaces previously configured global middlewares (`middleware-*`) and keeps provider-level middlewares untouched.
|
|
615
|
+
|
|
616
|
+
Analytics middleware is SSR-safe: in non-browser environments it becomes a no-op for `ga`, `mixpanel`, and `amplitude` providers.
|
|
607
617
|
|
|
608
618
|
### Custom Middleware
|
|
609
619
|
|