izen-react-starter 2.0.0 → 2.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 +51 -10
- package/dist/{MIMHJGAX-DM3PPc6i.js → MIMHJGAX-BUG-Z2YP.js} +1 -1
- package/dist/{Q7LWSL4U-Dp8mxbtM.js → Q7LWSL4U-CGtIukTY.js} +2 -2
- package/dist/{VLTTJS3N-Dfn6o7Pv.js → VLTTJS3N-DuHfwBTL.js} +2 -2
- package/dist/{index-Dnn3beiE.js → index-BNRXa5M-.js} +7456 -7607
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/izen-react-starter.css +1 -1
- package/dist/rbac/AccessControlWrapper.d.ts +32 -5
- package/dist/rbac/AccessControlWrapper.d.ts.map +1 -1
- package/dist/rbac/RBACProvider.d.ts +55 -0
- package/dist/rbac/RBACProvider.d.ts.map +1 -0
- package/dist/rbac/UpdateAccessControlWrapper.d.ts +14 -2
- package/dist/rbac/UpdateAccessControlWrapper.d.ts.map +1 -1
- package/dist/rbac/access-rules.d.ts +26 -45
- package/dist/rbac/access-rules.d.ts.map +1 -1
- package/dist/rbac/index.d.ts +4 -1
- package/dist/rbac/index.d.ts.map +1 -1
- package/dist/rbac/useAccessControl.d.ts +16 -3
- package/dist/rbac/useAccessControl.d.ts.map +1 -1
- package/dist/react-starter.js +219 -221
- package/dist/react-starter.umd.cjs +132 -132
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ A modern React component library built with Vite, TypeScript, and best practices
|
|
|
11
11
|
- 🎨 **Theme Provider**: Dark/light mode with system preference support
|
|
12
12
|
- 🌐 **API Service**: Axios-based service for data fetching and posting
|
|
13
13
|
- 🔄 **React Query Integration**: Built-in query client and provider
|
|
14
|
-
-
|
|
14
|
+
- 🔐 **RBAC System**: Fully configurable role-based access control - bring your own roles and resources
|
|
15
15
|
- 🎣 **Custom Hooks**: Utility hooks like useIsMobile, useRouter, usePathname
|
|
16
16
|
- 🛠️ **Utility Functions**: Helper functions for common tasks (cn, debounce, throttle, etc.)
|
|
17
17
|
- 💾 **Cache Utilities**: React Query cache manipulation helpers
|
|
@@ -559,25 +559,63 @@ export function UsersPage() {
|
|
|
559
559
|
|
|
560
560
|
### Role-Based Access Control (RBAC)
|
|
561
561
|
|
|
562
|
+
The RBAC system is now fully configurable! Define your own roles, resources, and rules.
|
|
563
|
+
|
|
562
564
|
```tsx
|
|
563
565
|
import {
|
|
566
|
+
RBACProvider,
|
|
564
567
|
useAccessControl,
|
|
565
568
|
AccessControlWrapper,
|
|
566
569
|
withAccessControl,
|
|
567
|
-
|
|
568
|
-
|
|
570
|
+
CommonActions,
|
|
571
|
+
RBACConfig
|
|
569
572
|
} from 'izen-react-starter';
|
|
570
573
|
|
|
571
|
-
//
|
|
574
|
+
// 1. Define your RBAC configuration
|
|
575
|
+
const rbacConfig: RBACConfig = {
|
|
576
|
+
roles: ['admin', 'editor', 'viewer'],
|
|
577
|
+
resources: ['posts', 'comments', 'users'],
|
|
578
|
+
rules: {
|
|
579
|
+
admin: {
|
|
580
|
+
[CommonActions.Manage]: { can: 'all' },
|
|
581
|
+
[CommonActions.Create]: { can: 'all' },
|
|
582
|
+
[CommonActions.Read]: { can: 'all' },
|
|
583
|
+
[CommonActions.Update]: { can: 'all' },
|
|
584
|
+
[CommonActions.Delete]: { can: 'all' },
|
|
585
|
+
},
|
|
586
|
+
editor: {
|
|
587
|
+
[CommonActions.Create]: { can: ['posts', 'comments'] },
|
|
588
|
+
[CommonActions.Read]: { can: 'all' },
|
|
589
|
+
[CommonActions.Update]: { can: ['posts', 'comments'] },
|
|
590
|
+
[CommonActions.Delete]: { can: ['comments'] },
|
|
591
|
+
},
|
|
592
|
+
viewer: {
|
|
593
|
+
[CommonActions.Read]: { can: 'all' },
|
|
594
|
+
},
|
|
595
|
+
},
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
// 2. Wrap your app with RBACProvider
|
|
599
|
+
function App() {
|
|
600
|
+
return (
|
|
601
|
+
<AuthProvider>
|
|
602
|
+
<RBACProvider config={rbacConfig}>
|
|
603
|
+
<YourApp />
|
|
604
|
+
</RBACProvider>
|
|
605
|
+
</AuthProvider>
|
|
606
|
+
);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
// 3. Use access control in your components
|
|
572
610
|
function AdminPanel() {
|
|
573
611
|
const { isAllowed } = useAccessControl();
|
|
574
612
|
|
|
575
613
|
return (
|
|
576
614
|
<div>
|
|
577
|
-
{isAllowed(
|
|
615
|
+
{isAllowed('create', 'users') && (
|
|
578
616
|
<button>Create User</button>
|
|
579
617
|
)}
|
|
580
|
-
{isAllowed(
|
|
618
|
+
{isAllowed('delete', 'users') && (
|
|
581
619
|
<button>Delete User</button>
|
|
582
620
|
)}
|
|
583
621
|
</div>
|
|
@@ -587,8 +625,8 @@ function AdminPanel() {
|
|
|
587
625
|
// Using the wrapper component
|
|
588
626
|
function Dashboard() {
|
|
589
627
|
return (
|
|
590
|
-
<AccessControlWrapper resource=
|
|
591
|
-
<
|
|
628
|
+
<AccessControlWrapper resource="posts" action="create">
|
|
629
|
+
<CreatePostButton />
|
|
592
630
|
</AccessControlWrapper>
|
|
593
631
|
);
|
|
594
632
|
}
|
|
@@ -597,12 +635,15 @@ function Dashboard() {
|
|
|
597
635
|
const ProtectedComponent = withAccessControl(MyComponent);
|
|
598
636
|
|
|
599
637
|
<ProtectedComponent
|
|
600
|
-
accessedResource=
|
|
601
|
-
accessAction=
|
|
638
|
+
accessedResource="users"
|
|
639
|
+
accessAction="update"
|
|
602
640
|
otherProp="value"
|
|
603
641
|
/>
|
|
604
642
|
```
|
|
605
643
|
|
|
644
|
+
> 📖 **See [RBAC.md](./RBAC.md) for comprehensive documentation** including custom actions, multiple roles, migration guide, and advanced examples.
|
|
645
|
+
```
|
|
646
|
+
|
|
606
647
|
### Utility Functions
|
|
607
648
|
|
|
608
649
|
```tsx
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var ws = Object.defineProperty;
|
|
2
2
|
var xs = (e, t, n) => t in e ? ws(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var Re = (e, t, n) => xs(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
-
import { b as $e, d as B, o as xt, e as H, c as L, a as v, P as zo, m as ye, S as K, t as P, i as k, f as U, h as F, j as $s, k as sr, u as Ce, l as V, s as Vn, n as jn, p as ft, q as T, r as Cs, v as cn, w as qe, x as Ss, y as _t, z as Kt, A as ks, B as Es, C as Cn, F as Ds, D as Hr, E as Nt, $ as Ko, G as Ms, H as As, I as W, J as Gr, K as Ts, L as Fs, M as ar, N as Is, O as Os, Q as Kn, R as Ls, T as Ps, U as ie, V as qs, W as _s } from "./index-
|
|
4
|
+
import { b as $e, d as B, o as xt, e as H, c as L, a as v, P as zo, m as ye, S as K, t as P, i as k, f as U, h as F, j as $s, k as sr, u as Ce, l as V, s as Vn, n as jn, p as ft, q as T, r as Cs, v as cn, w as qe, x as Ss, y as _t, z as Kt, A as ks, B as Es, C as Cn, F as Ds, D as Hr, E as Nt, $ as Ko, G as Ms, H as As, I as W, J as Gr, K as Ts, L as Fs, M as ar, N as Is, O as Os, Q as Kn, R as Ls, T as Ps, U as ie, V as qs, W as _s } from "./index-BNRXa5M-.js";
|
|
5
5
|
var Rs = (e) => e != null, zs = (e) => e.filter(Rs);
|
|
6
6
|
function Ks(e) {
|
|
7
7
|
return (...t) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c, T as l, P as m, a as u, D as v, Q as i } from "./MIMHJGAX-
|
|
2
|
-
import { g as d, c as f, a as e } from "./index-
|
|
1
|
+
import { c, T as l, P as m, a as u, D as v, Q as i } from "./MIMHJGAX-BUG-Z2YP.js";
|
|
2
|
+
import { g as d, c as f, a as e } from "./index-BNRXa5M-.js";
|
|
3
3
|
var h = (t) => {
|
|
4
4
|
const [r, o] = c({
|
|
5
5
|
prefix: "TanstackQueryDevtools"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as s, T as c, P as u, a as i, b as m, C as P, Q as d } from "./MIMHJGAX-
|
|
2
|
-
import { g as h, c as v, a as e } from "./index-
|
|
1
|
+
import { c as s, T as c, P as u, a as i, b as m, C as P, Q as d } from "./MIMHJGAX-BUG-Z2YP.js";
|
|
2
|
+
import { g as h, c as v, a as e } from "./index-BNRXa5M-.js";
|
|
3
3
|
var C = (r) => {
|
|
4
4
|
const [t, o] = s({
|
|
5
5
|
prefix: "TanstackQueryDevtools"
|