@almadar/ui 6.12.0 → 6.14.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/dist/{UserContext-g_LcDiGN.d.cts → CurrentPagePathContext-J1lqjvAq.d.cts} +2 -97
- package/dist/{UserContext-g_LcDiGN.d.ts → CurrentPagePathContext-J1lqjvAq.d.ts} +2 -97
- package/dist/{EntityBindingContext-D5lRu6p1.d.cts → EntityBindingContext-BMz9xiBa.d.cts} +2 -3
- package/dist/{EntityBindingContext-D5lRu6p1.d.ts → EntityBindingContext-BMz9xiBa.d.ts} +2 -3
- package/dist/{GameAudioProvider-D8GynTNq.d.cts → GameAudioProvider-Cpw_lMPY.d.cts} +1 -1
- package/dist/{GameAudioProvider-Dozqx4sL.d.ts → GameAudioProvider-DIjFiy70.d.ts} +1 -1
- package/dist/UserContext-D566nfWA.d.cts +99 -0
- package/dist/UserContext-D566nfWA.d.ts +99 -0
- package/dist/avl/index.cjs +571 -70
- package/dist/avl/index.d.cts +1 -1
- package/dist/avl/index.d.ts +1 -1
- package/dist/avl/index.js +573 -72
- package/dist/{avl-schema-parser-PVu8rgsy.d.cts → avl-schema-parser-B25PL-a8.d.cts} +1 -1
- package/dist/{avl-schema-parser-DX-aVCCm.d.ts → avl-schema-parser-CM0pQo8E.d.ts} +1 -1
- package/dist/components/index.cjs +564 -117
- package/dist/components/index.d.cts +8 -24
- package/dist/components/index.d.ts +8 -24
- package/dist/components/index.js +566 -118
- package/dist/context/index.d.cts +2 -1
- package/dist/context/index.d.ts +2 -1
- package/dist/lib/drawable/three/index.cjs +126 -3
- package/dist/lib/drawable/three/index.d.cts +3 -3
- package/dist/lib/drawable/three/index.d.ts +3 -3
- package/dist/lib/drawable/three/index.js +126 -3
- package/dist/lib/index.cjs +1 -4
- package/dist/lib/index.d.cts +2 -2
- package/dist/lib/index.d.ts +2 -2
- package/dist/lib/index.js +1 -4
- package/dist/{offline-executor-QUdKOj7f.d.cts → offline-executor-DdV2o0Zu.d.cts} +4 -19
- package/dist/{offline-executor-QUdKOj7f.d.ts → offline-executor-DdV2o0Zu.d.ts} +4 -19
- package/dist/{paintDispatch-CK5uwYEq.d.cts → paintDispatch-Dh1pgljl.d.cts} +79 -1
- package/dist/{paintDispatch-CK5uwYEq.d.ts → paintDispatch-Dh1pgljl.d.ts} +79 -1
- package/dist/providers/index.cjs +558 -62
- package/dist/providers/index.d.cts +10 -9
- package/dist/providers/index.d.ts +10 -9
- package/dist/providers/index.js +559 -63
- package/dist/renderer/index.cjs +0 -15
- package/dist/renderer/index.d.cts +4 -9
- package/dist/renderer/index.d.ts +4 -9
- package/dist/renderer/index.js +1 -15
- package/dist/runtime/index.cjs +573 -81
- package/dist/runtime/index.d.cts +14 -11
- package/dist/runtime/index.d.ts +14 -11
- package/dist/runtime/index.js +575 -83
- package/dist/{verificationRegistry-D8bHWD8Q.d.ts → verificationRegistry-Cwa52VyK.d.ts} +1 -1
- package/dist/{verificationRegistry-BLsjb1oU.d.cts → verificationRegistry-DTrKDRoa.d.cts} +1 -1
- package/package.json +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { ReactNode, ReactElement } from 'react';
|
|
3
|
-
import { ThemeRef
|
|
3
|
+
import { ThemeRef } from '@almadar/core';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Unified ThemeContext - Single provider for theme and color mode
|
|
@@ -164,99 +164,4 @@ interface CurrentPagePathProviderProps {
|
|
|
164
164
|
declare const CurrentPagePathProvider: React__default.FC<CurrentPagePathProviderProps>;
|
|
165
165
|
declare const useCurrentPagePath: () => string | undefined;
|
|
166
166
|
|
|
167
|
-
|
|
168
|
-
* UserContext
|
|
169
|
-
*
|
|
170
|
-
* React context for providing user data throughout the application.
|
|
171
|
-
* Enables @user bindings in S-expressions for role-based UI and permissions.
|
|
172
|
-
*
|
|
173
|
-
* Usage:
|
|
174
|
-
* ```tsx
|
|
175
|
-
* // In App.tsx or layout
|
|
176
|
-
* <UserProvider user={{ id: '123', role: 'admin', permissions: ['read', 'write'] }}>
|
|
177
|
-
* <App />
|
|
178
|
-
* </UserProvider>
|
|
179
|
-
*
|
|
180
|
-
* // In components - access via hook
|
|
181
|
-
* const { user, hasRole, hasPermission } = useUser();
|
|
182
|
-
* if (hasRole('admin')) { ... }
|
|
183
|
-
* if (hasPermission('delete')) { ... }
|
|
184
|
-
* ```
|
|
185
|
-
*
|
|
186
|
-
* @packageDocumentation
|
|
187
|
-
*/
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* User data for `@user` bindings — the canonical `UserContext` from
|
|
191
|
-
* `@almadar/core`, kept under this name for existing consumers. Declaring the
|
|
192
|
-
* shape locally let it drift from the type both execution paths resolve against.
|
|
193
|
-
*/
|
|
194
|
-
type UserData = UserContext$1;
|
|
195
|
-
/**
|
|
196
|
-
* User context value.
|
|
197
|
-
*/
|
|
198
|
-
interface UserContextValue {
|
|
199
|
-
/** Current user data (null if not logged in) */
|
|
200
|
-
user: UserData | null;
|
|
201
|
-
/** Check if user is logged in */
|
|
202
|
-
isLoggedIn: boolean;
|
|
203
|
-
/** Check if user has a specific role */
|
|
204
|
-
hasRole: (role: string) => boolean;
|
|
205
|
-
/** Check if user has a specific permission */
|
|
206
|
-
hasPermission: (permission: string) => boolean;
|
|
207
|
-
/** Check if user has any of the specified roles */
|
|
208
|
-
hasAnyRole: (roles: string[]) => boolean;
|
|
209
|
-
/** Check if user has all of the specified permissions */
|
|
210
|
-
hasAllPermissions: (permissions: string[]) => boolean;
|
|
211
|
-
/** Get a user field by path (for @user.field bindings) */
|
|
212
|
-
getUserField: (path: string) => FieldValue | undefined;
|
|
213
|
-
}
|
|
214
|
-
declare const UserContext: React__default.Context<UserContextValue | null>;
|
|
215
|
-
interface UserProviderProps {
|
|
216
|
-
/** User data (null if not logged in) */
|
|
217
|
-
user?: UserData | null;
|
|
218
|
-
/** Children to render */
|
|
219
|
-
children: React__default.ReactNode;
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Provider component that provides user context to the application.
|
|
223
|
-
*
|
|
224
|
-
* Provides RBAC helpers and field access for @user bindings.
|
|
225
|
-
*/
|
|
226
|
-
declare function UserProvider({ user, children, }: UserProviderProps): React__default.ReactElement;
|
|
227
|
-
/**
|
|
228
|
-
* Hook to access the user context.
|
|
229
|
-
*
|
|
230
|
-
* Returns default values if used outside of UserProvider (for resilience).
|
|
231
|
-
*
|
|
232
|
-
* @example
|
|
233
|
-
* ```tsx
|
|
234
|
-
* function AdminPanel() {
|
|
235
|
-
* const { user, hasRole, hasPermission } = useUser();
|
|
236
|
-
*
|
|
237
|
-
* if (!hasRole('admin') && !hasPermission('admin:access')) {
|
|
238
|
-
* return <AccessDenied />;
|
|
239
|
-
* }
|
|
240
|
-
*
|
|
241
|
-
* return <div>Welcome, {user?.name}</div>;
|
|
242
|
-
* }
|
|
243
|
-
* ```
|
|
244
|
-
*/
|
|
245
|
-
declare function useUser(): UserContextValue;
|
|
246
|
-
/**
|
|
247
|
-
* Hook to check if user has a specific role.
|
|
248
|
-
* Convenience wrapper around useUser().hasRole().
|
|
249
|
-
*/
|
|
250
|
-
declare function useHasRole(role: string): boolean;
|
|
251
|
-
/**
|
|
252
|
-
* Hook to check if user has a specific permission.
|
|
253
|
-
* Convenience wrapper around useUser().hasPermission().
|
|
254
|
-
*/
|
|
255
|
-
declare function useHasPermission(permission: string): boolean;
|
|
256
|
-
/**
|
|
257
|
-
* Hook to get user data for @user bindings in S-expressions.
|
|
258
|
-
* Returns the user data object compatible with EvaluationContext.user
|
|
259
|
-
*/
|
|
260
|
-
declare function useUserForEvaluation(): UserData | undefined;
|
|
261
|
-
|
|
262
|
-
export { BUILT_IN_THEMES as B, type ColorMode as C, type DesignTheme as D, OrbitalThemeProvider as O, type ResolvedMode as R, ThemeContext as T, type UIThemeDefinition as U, CurrentPagePathContext as a, CurrentPagePathProvider as b, type CurrentPagePathProviderProps as c, DesignThemeProvider as d, type OrbitalThemeProviderProps as e, ThemeProvider as f, type ThemeProviderProps as g, UserContext as h, type UserContextValue as i, type UserData as j, UserProvider as k, type UserProviderProps as l, useDesignTheme as m, useHasPermission as n, useHasRole as o, useTheme as p, useUser as q, useUserForEvaluation as r, useCurrentPagePath as u };
|
|
167
|
+
export { BUILT_IN_THEMES as B, type ColorMode as C, type DesignTheme as D, OrbitalThemeProvider as O, type ResolvedMode as R, ThemeContext as T, type UIThemeDefinition as U, CurrentPagePathContext as a, CurrentPagePathProvider as b, type CurrentPagePathProviderProps as c, DesignThemeProvider as d, type OrbitalThemeProviderProps as e, ThemeProvider as f, type ThemeProviderProps as g, useDesignTheme as h, useTheme as i, useCurrentPagePath as u };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { ReactNode, ReactElement } from 'react';
|
|
3
|
-
import { ThemeRef
|
|
3
|
+
import { ThemeRef } from '@almadar/core';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Unified ThemeContext - Single provider for theme and color mode
|
|
@@ -164,99 +164,4 @@ interface CurrentPagePathProviderProps {
|
|
|
164
164
|
declare const CurrentPagePathProvider: React__default.FC<CurrentPagePathProviderProps>;
|
|
165
165
|
declare const useCurrentPagePath: () => string | undefined;
|
|
166
166
|
|
|
167
|
-
|
|
168
|
-
* UserContext
|
|
169
|
-
*
|
|
170
|
-
* React context for providing user data throughout the application.
|
|
171
|
-
* Enables @user bindings in S-expressions for role-based UI and permissions.
|
|
172
|
-
*
|
|
173
|
-
* Usage:
|
|
174
|
-
* ```tsx
|
|
175
|
-
* // In App.tsx or layout
|
|
176
|
-
* <UserProvider user={{ id: '123', role: 'admin', permissions: ['read', 'write'] }}>
|
|
177
|
-
* <App />
|
|
178
|
-
* </UserProvider>
|
|
179
|
-
*
|
|
180
|
-
* // In components - access via hook
|
|
181
|
-
* const { user, hasRole, hasPermission } = useUser();
|
|
182
|
-
* if (hasRole('admin')) { ... }
|
|
183
|
-
* if (hasPermission('delete')) { ... }
|
|
184
|
-
* ```
|
|
185
|
-
*
|
|
186
|
-
* @packageDocumentation
|
|
187
|
-
*/
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* User data for `@user` bindings — the canonical `UserContext` from
|
|
191
|
-
* `@almadar/core`, kept under this name for existing consumers. Declaring the
|
|
192
|
-
* shape locally let it drift from the type both execution paths resolve against.
|
|
193
|
-
*/
|
|
194
|
-
type UserData = UserContext$1;
|
|
195
|
-
/**
|
|
196
|
-
* User context value.
|
|
197
|
-
*/
|
|
198
|
-
interface UserContextValue {
|
|
199
|
-
/** Current user data (null if not logged in) */
|
|
200
|
-
user: UserData | null;
|
|
201
|
-
/** Check if user is logged in */
|
|
202
|
-
isLoggedIn: boolean;
|
|
203
|
-
/** Check if user has a specific role */
|
|
204
|
-
hasRole: (role: string) => boolean;
|
|
205
|
-
/** Check if user has a specific permission */
|
|
206
|
-
hasPermission: (permission: string) => boolean;
|
|
207
|
-
/** Check if user has any of the specified roles */
|
|
208
|
-
hasAnyRole: (roles: string[]) => boolean;
|
|
209
|
-
/** Check if user has all of the specified permissions */
|
|
210
|
-
hasAllPermissions: (permissions: string[]) => boolean;
|
|
211
|
-
/** Get a user field by path (for @user.field bindings) */
|
|
212
|
-
getUserField: (path: string) => FieldValue | undefined;
|
|
213
|
-
}
|
|
214
|
-
declare const UserContext: React__default.Context<UserContextValue | null>;
|
|
215
|
-
interface UserProviderProps {
|
|
216
|
-
/** User data (null if not logged in) */
|
|
217
|
-
user?: UserData | null;
|
|
218
|
-
/** Children to render */
|
|
219
|
-
children: React__default.ReactNode;
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Provider component that provides user context to the application.
|
|
223
|
-
*
|
|
224
|
-
* Provides RBAC helpers and field access for @user bindings.
|
|
225
|
-
*/
|
|
226
|
-
declare function UserProvider({ user, children, }: UserProviderProps): React__default.ReactElement;
|
|
227
|
-
/**
|
|
228
|
-
* Hook to access the user context.
|
|
229
|
-
*
|
|
230
|
-
* Returns default values if used outside of UserProvider (for resilience).
|
|
231
|
-
*
|
|
232
|
-
* @example
|
|
233
|
-
* ```tsx
|
|
234
|
-
* function AdminPanel() {
|
|
235
|
-
* const { user, hasRole, hasPermission } = useUser();
|
|
236
|
-
*
|
|
237
|
-
* if (!hasRole('admin') && !hasPermission('admin:access')) {
|
|
238
|
-
* return <AccessDenied />;
|
|
239
|
-
* }
|
|
240
|
-
*
|
|
241
|
-
* return <div>Welcome, {user?.name}</div>;
|
|
242
|
-
* }
|
|
243
|
-
* ```
|
|
244
|
-
*/
|
|
245
|
-
declare function useUser(): UserContextValue;
|
|
246
|
-
/**
|
|
247
|
-
* Hook to check if user has a specific role.
|
|
248
|
-
* Convenience wrapper around useUser().hasRole().
|
|
249
|
-
*/
|
|
250
|
-
declare function useHasRole(role: string): boolean;
|
|
251
|
-
/**
|
|
252
|
-
* Hook to check if user has a specific permission.
|
|
253
|
-
* Convenience wrapper around useUser().hasPermission().
|
|
254
|
-
*/
|
|
255
|
-
declare function useHasPermission(permission: string): boolean;
|
|
256
|
-
/**
|
|
257
|
-
* Hook to get user data for @user bindings in S-expressions.
|
|
258
|
-
* Returns the user data object compatible with EvaluationContext.user
|
|
259
|
-
*/
|
|
260
|
-
declare function useUserForEvaluation(): UserData | undefined;
|
|
261
|
-
|
|
262
|
-
export { BUILT_IN_THEMES as B, type ColorMode as C, type DesignTheme as D, OrbitalThemeProvider as O, type ResolvedMode as R, ThemeContext as T, type UIThemeDefinition as U, CurrentPagePathContext as a, CurrentPagePathProvider as b, type CurrentPagePathProviderProps as c, DesignThemeProvider as d, type OrbitalThemeProviderProps as e, ThemeProvider as f, type ThemeProviderProps as g, UserContext as h, type UserContextValue as i, type UserData as j, UserProvider as k, type UserProviderProps as l, useDesignTheme as m, useHasPermission as n, useHasRole as o, useTheme as p, useUser as q, useUserForEvaluation as r, useCurrentPagePath as u };
|
|
167
|
+
export { BUILT_IN_THEMES as B, type ColorMode as C, type DesignTheme as D, OrbitalThemeProvider as O, type ResolvedMode as R, ThemeContext as T, type UIThemeDefinition as U, CurrentPagePathContext as a, CurrentPagePathProvider as b, type CurrentPagePathProviderProps as c, DesignThemeProvider as d, type OrbitalThemeProviderProps as e, ThemeProvider as f, type ThemeProviderProps as g, useDesignTheme as h, useTheme as i, useCurrentPagePath as u };
|
|
@@ -85,7 +85,7 @@ declare function useEntitySchema(): EntitySchemaContextValue;
|
|
|
85
85
|
declare function useEntitySchemaOptional(): EntitySchemaContextValue | null;
|
|
86
86
|
|
|
87
87
|
/** Wire-format client effect tuple from the server response. */
|
|
88
|
-
type ClientEffectTuple = ['render-ui', string, AnyPatternConfig | null, ...SExpr[]] | ['navigate', string, ...SExpr[]] | ['navigate-back']
|
|
88
|
+
type ClientEffectTuple = ['render-ui', string, AnyPatternConfig | null, ...SExpr[]] | ['navigate', string, ...SExpr[]] | ['navigate-back'];
|
|
89
89
|
interface OrbitalEventResponse {
|
|
90
90
|
success: boolean;
|
|
91
91
|
transitioned: boolean;
|
|
@@ -123,14 +123,13 @@ interface OrbitalEventResponse {
|
|
|
123
123
|
error?: string;
|
|
124
124
|
}
|
|
125
125
|
interface ServerClientEffect {
|
|
126
|
-
type: 'render-ui' | 'navigate' | 'navigate-back'
|
|
126
|
+
type: 'render-ui' | 'navigate' | 'navigate-back';
|
|
127
127
|
slot?: string;
|
|
128
128
|
pattern?: AnyPatternConfig;
|
|
129
129
|
route?: string;
|
|
130
130
|
params?: EventPayload;
|
|
131
131
|
/** Nav-stack entry label carried by the navigate effect's options. */
|
|
132
132
|
crumb?: string;
|
|
133
|
-
message?: string;
|
|
134
133
|
/**
|
|
135
134
|
* Trait that emitted this effect. Used by `<TraitFrame>` to resolve
|
|
136
135
|
* `@trait.X` bindings. Undefined when the server didn't tag the effect
|
|
@@ -85,7 +85,7 @@ declare function useEntitySchema(): EntitySchemaContextValue;
|
|
|
85
85
|
declare function useEntitySchemaOptional(): EntitySchemaContextValue | null;
|
|
86
86
|
|
|
87
87
|
/** Wire-format client effect tuple from the server response. */
|
|
88
|
-
type ClientEffectTuple = ['render-ui', string, AnyPatternConfig | null, ...SExpr[]] | ['navigate', string, ...SExpr[]] | ['navigate-back']
|
|
88
|
+
type ClientEffectTuple = ['render-ui', string, AnyPatternConfig | null, ...SExpr[]] | ['navigate', string, ...SExpr[]] | ['navigate-back'];
|
|
89
89
|
interface OrbitalEventResponse {
|
|
90
90
|
success: boolean;
|
|
91
91
|
transitioned: boolean;
|
|
@@ -123,14 +123,13 @@ interface OrbitalEventResponse {
|
|
|
123
123
|
error?: string;
|
|
124
124
|
}
|
|
125
125
|
interface ServerClientEffect {
|
|
126
|
-
type: 'render-ui' | 'navigate' | 'navigate-back'
|
|
126
|
+
type: 'render-ui' | 'navigate' | 'navigate-back';
|
|
127
127
|
slot?: string;
|
|
128
128
|
pattern?: AnyPatternConfig;
|
|
129
129
|
route?: string;
|
|
130
130
|
params?: EventPayload;
|
|
131
131
|
/** Nav-stack entry label carried by the navigate effect's options. */
|
|
132
132
|
crumb?: string;
|
|
133
|
-
message?: string;
|
|
134
133
|
/**
|
|
135
134
|
* Trait that emitted this effect. Used by `<TraitFrame>` to resolve
|
|
136
135
|
* `@trait.X` bindings. Undefined when the server didn't tag the effect
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
2
|
import { AudioManifest } from '@almadar/core';
|
|
3
|
-
import { U as UiError } from './paintDispatch-
|
|
3
|
+
import { U as UiError } from './paintDispatch-Dh1pgljl.cjs';
|
|
4
4
|
|
|
5
5
|
/** Core owns the sound-manifest shape (`@almadar/core` `types/asset.ts`) so the
|
|
6
6
|
* pattern extractor and the generated `.lolo` factories resolve the same
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
2
|
import { AudioManifest } from '@almadar/core';
|
|
3
|
-
import { U as UiError } from './paintDispatch-
|
|
3
|
+
import { U as UiError } from './paintDispatch-Dh1pgljl.js';
|
|
4
4
|
|
|
5
5
|
/** Core owns the sound-manifest shape (`@almadar/core` `types/asset.ts`) so the
|
|
6
6
|
* pattern extractor and the generated `.lolo` factories resolve the same
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { UserContext as UserContext$1, FieldValue } from '@almadar/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* UserContext
|
|
6
|
+
*
|
|
7
|
+
* React context for providing user data throughout the application.
|
|
8
|
+
* Enables @user bindings in S-expressions for role-based UI and permissions.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* ```tsx
|
|
12
|
+
* // In App.tsx or layout
|
|
13
|
+
* <UserProvider user={{ id: '123', role: 'admin', permissions: ['read', 'write'] }}>
|
|
14
|
+
* <App />
|
|
15
|
+
* </UserProvider>
|
|
16
|
+
*
|
|
17
|
+
* // In components - access via hook
|
|
18
|
+
* const { user, hasRole, hasPermission } = useUser();
|
|
19
|
+
* if (hasRole('admin')) { ... }
|
|
20
|
+
* if (hasPermission('delete')) { ... }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @packageDocumentation
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* User data for `@user` bindings — the canonical `UserContext` from
|
|
28
|
+
* `@almadar/core`, kept under this name for existing consumers. Declaring the
|
|
29
|
+
* shape locally let it drift from the type both execution paths resolve against.
|
|
30
|
+
*/
|
|
31
|
+
type UserData = UserContext$1;
|
|
32
|
+
/**
|
|
33
|
+
* User context value.
|
|
34
|
+
*/
|
|
35
|
+
interface UserContextValue {
|
|
36
|
+
/** Current user data (null if not logged in) */
|
|
37
|
+
user: UserData | null;
|
|
38
|
+
/** Check if user is logged in */
|
|
39
|
+
isLoggedIn: boolean;
|
|
40
|
+
/** Check if user has a specific role */
|
|
41
|
+
hasRole: (role: string) => boolean;
|
|
42
|
+
/** Check if user has a specific permission */
|
|
43
|
+
hasPermission: (permission: string) => boolean;
|
|
44
|
+
/** Check if user has any of the specified roles */
|
|
45
|
+
hasAnyRole: (roles: string[]) => boolean;
|
|
46
|
+
/** Check if user has all of the specified permissions */
|
|
47
|
+
hasAllPermissions: (permissions: string[]) => boolean;
|
|
48
|
+
/** Get a user field by path (for @user.field bindings) */
|
|
49
|
+
getUserField: (path: string) => FieldValue | undefined;
|
|
50
|
+
}
|
|
51
|
+
declare const UserContext: React__default.Context<UserContextValue | null>;
|
|
52
|
+
interface UserProviderProps {
|
|
53
|
+
/** User data (null if not logged in) */
|
|
54
|
+
user?: UserData | null;
|
|
55
|
+
/** Children to render */
|
|
56
|
+
children: React__default.ReactNode;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Provider component that provides user context to the application.
|
|
60
|
+
*
|
|
61
|
+
* Provides RBAC helpers and field access for @user bindings.
|
|
62
|
+
*/
|
|
63
|
+
declare function UserProvider({ user, children, }: UserProviderProps): React__default.ReactElement;
|
|
64
|
+
/**
|
|
65
|
+
* Hook to access the user context.
|
|
66
|
+
*
|
|
67
|
+
* Returns default values if used outside of UserProvider (for resilience).
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```tsx
|
|
71
|
+
* function AdminPanel() {
|
|
72
|
+
* const { user, hasRole, hasPermission } = useUser();
|
|
73
|
+
*
|
|
74
|
+
* if (!hasRole('admin') && !hasPermission('admin:access')) {
|
|
75
|
+
* return <AccessDenied />;
|
|
76
|
+
* }
|
|
77
|
+
*
|
|
78
|
+
* return <div>Welcome, {user?.name}</div>;
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
declare function useUser(): UserContextValue;
|
|
83
|
+
/**
|
|
84
|
+
* Hook to check if user has a specific role.
|
|
85
|
+
* Convenience wrapper around useUser().hasRole().
|
|
86
|
+
*/
|
|
87
|
+
declare function useHasRole(role: string): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Hook to check if user has a specific permission.
|
|
90
|
+
* Convenience wrapper around useUser().hasPermission().
|
|
91
|
+
*/
|
|
92
|
+
declare function useHasPermission(permission: string): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Hook to get user data for @user bindings in S-expressions.
|
|
95
|
+
* Returns the user data object compatible with EvaluationContext.user
|
|
96
|
+
*/
|
|
97
|
+
declare function useUserForEvaluation(): UserData | undefined;
|
|
98
|
+
|
|
99
|
+
export { UserContext as U, type UserContextValue as a, type UserData as b, UserProvider as c, type UserProviderProps as d, useHasRole as e, useUser as f, useUserForEvaluation as g, useHasPermission as u };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { UserContext as UserContext$1, FieldValue } from '@almadar/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* UserContext
|
|
6
|
+
*
|
|
7
|
+
* React context for providing user data throughout the application.
|
|
8
|
+
* Enables @user bindings in S-expressions for role-based UI and permissions.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* ```tsx
|
|
12
|
+
* // In App.tsx or layout
|
|
13
|
+
* <UserProvider user={{ id: '123', role: 'admin', permissions: ['read', 'write'] }}>
|
|
14
|
+
* <App />
|
|
15
|
+
* </UserProvider>
|
|
16
|
+
*
|
|
17
|
+
* // In components - access via hook
|
|
18
|
+
* const { user, hasRole, hasPermission } = useUser();
|
|
19
|
+
* if (hasRole('admin')) { ... }
|
|
20
|
+
* if (hasPermission('delete')) { ... }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @packageDocumentation
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* User data for `@user` bindings — the canonical `UserContext` from
|
|
28
|
+
* `@almadar/core`, kept under this name for existing consumers. Declaring the
|
|
29
|
+
* shape locally let it drift from the type both execution paths resolve against.
|
|
30
|
+
*/
|
|
31
|
+
type UserData = UserContext$1;
|
|
32
|
+
/**
|
|
33
|
+
* User context value.
|
|
34
|
+
*/
|
|
35
|
+
interface UserContextValue {
|
|
36
|
+
/** Current user data (null if not logged in) */
|
|
37
|
+
user: UserData | null;
|
|
38
|
+
/** Check if user is logged in */
|
|
39
|
+
isLoggedIn: boolean;
|
|
40
|
+
/** Check if user has a specific role */
|
|
41
|
+
hasRole: (role: string) => boolean;
|
|
42
|
+
/** Check if user has a specific permission */
|
|
43
|
+
hasPermission: (permission: string) => boolean;
|
|
44
|
+
/** Check if user has any of the specified roles */
|
|
45
|
+
hasAnyRole: (roles: string[]) => boolean;
|
|
46
|
+
/** Check if user has all of the specified permissions */
|
|
47
|
+
hasAllPermissions: (permissions: string[]) => boolean;
|
|
48
|
+
/** Get a user field by path (for @user.field bindings) */
|
|
49
|
+
getUserField: (path: string) => FieldValue | undefined;
|
|
50
|
+
}
|
|
51
|
+
declare const UserContext: React__default.Context<UserContextValue | null>;
|
|
52
|
+
interface UserProviderProps {
|
|
53
|
+
/** User data (null if not logged in) */
|
|
54
|
+
user?: UserData | null;
|
|
55
|
+
/** Children to render */
|
|
56
|
+
children: React__default.ReactNode;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Provider component that provides user context to the application.
|
|
60
|
+
*
|
|
61
|
+
* Provides RBAC helpers and field access for @user bindings.
|
|
62
|
+
*/
|
|
63
|
+
declare function UserProvider({ user, children, }: UserProviderProps): React__default.ReactElement;
|
|
64
|
+
/**
|
|
65
|
+
* Hook to access the user context.
|
|
66
|
+
*
|
|
67
|
+
* Returns default values if used outside of UserProvider (for resilience).
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```tsx
|
|
71
|
+
* function AdminPanel() {
|
|
72
|
+
* const { user, hasRole, hasPermission } = useUser();
|
|
73
|
+
*
|
|
74
|
+
* if (!hasRole('admin') && !hasPermission('admin:access')) {
|
|
75
|
+
* return <AccessDenied />;
|
|
76
|
+
* }
|
|
77
|
+
*
|
|
78
|
+
* return <div>Welcome, {user?.name}</div>;
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
declare function useUser(): UserContextValue;
|
|
83
|
+
/**
|
|
84
|
+
* Hook to check if user has a specific role.
|
|
85
|
+
* Convenience wrapper around useUser().hasRole().
|
|
86
|
+
*/
|
|
87
|
+
declare function useHasRole(role: string): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Hook to check if user has a specific permission.
|
|
90
|
+
* Convenience wrapper around useUser().hasPermission().
|
|
91
|
+
*/
|
|
92
|
+
declare function useHasPermission(permission: string): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Hook to get user data for @user bindings in S-expressions.
|
|
95
|
+
* Returns the user data object compatible with EvaluationContext.user
|
|
96
|
+
*/
|
|
97
|
+
declare function useUserForEvaluation(): UserData | undefined;
|
|
98
|
+
|
|
99
|
+
export { UserContext as U, type UserContextValue as a, type UserData as b, UserProvider as c, type UserProviderProps as d, useHasRole as e, useUser as f, useUserForEvaluation as g, useHasPermission as u };
|