@almadar/ui 5.127.0 → 5.128.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-BKckAUv7.d.cts → UserContext-g_LcDiGN.d.cts} +6 -22
- package/dist/{UserContext-BKckAUv7.d.ts → UserContext-g_LcDiGN.d.ts} +6 -22
- package/dist/avl/index.cjs +1 -1
- package/dist/avl/index.js +1 -1
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.js +1 -1
- package/dist/context/index.d.cts +2 -2
- package/dist/context/index.d.ts +2 -2
- package/dist/providers/index.cjs +98 -102
- package/dist/providers/index.d.cts +15 -4
- package/dist/providers/index.d.ts +15 -4
- package/dist/providers/index.js +97 -103
- package/dist/runtime/index.cjs +1 -1
- package/dist/runtime/index.js +1 -1
- package/package.json +5 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { ReactNode, ReactElement } from 'react';
|
|
3
|
-
import { ThemeRef, FieldValue } from '@almadar/core';
|
|
3
|
+
import { ThemeRef, UserContext as UserContext$1, FieldValue } from '@almadar/core';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Unified ThemeContext - Single provider for theme and color mode
|
|
@@ -187,23 +187,11 @@ declare const useCurrentPagePath: () => string | undefined;
|
|
|
187
187
|
*/
|
|
188
188
|
|
|
189
189
|
/**
|
|
190
|
-
* User data for
|
|
191
|
-
*
|
|
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.
|
|
192
193
|
*/
|
|
193
|
-
|
|
194
|
-
/** User's unique ID */
|
|
195
|
-
id: string;
|
|
196
|
-
/** User's email */
|
|
197
|
-
email?: string;
|
|
198
|
-
/** User's display name */
|
|
199
|
-
name?: string;
|
|
200
|
-
/** User's role (for RBAC) */
|
|
201
|
-
role?: string;
|
|
202
|
-
/** User's permissions */
|
|
203
|
-
permissions?: string[];
|
|
204
|
-
/** Additional custom profile fields */
|
|
205
|
-
[key: string]: FieldValue | undefined;
|
|
206
|
-
}
|
|
194
|
+
type UserData = UserContext$1;
|
|
207
195
|
/**
|
|
208
196
|
* User context value.
|
|
209
197
|
*/
|
|
@@ -223,10 +211,6 @@ interface UserContextValue {
|
|
|
223
211
|
/** Get a user field by path (for @user.field bindings) */
|
|
224
212
|
getUserField: (path: string) => FieldValue | undefined;
|
|
225
213
|
}
|
|
226
|
-
/**
|
|
227
|
-
* Anonymous user for when no user is logged in.
|
|
228
|
-
*/
|
|
229
|
-
declare const ANONYMOUS_USER: UserData;
|
|
230
214
|
declare const UserContext: React__default.Context<UserContextValue | null>;
|
|
231
215
|
interface UserProviderProps {
|
|
232
216
|
/** User data (null if not logged in) */
|
|
@@ -275,4 +259,4 @@ declare function useHasPermission(permission: string): boolean;
|
|
|
275
259
|
*/
|
|
276
260
|
declare function useUserForEvaluation(): UserData | undefined;
|
|
277
261
|
|
|
278
|
-
export {
|
|
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 };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { ReactNode, ReactElement } from 'react';
|
|
3
|
-
import { ThemeRef, FieldValue } from '@almadar/core';
|
|
3
|
+
import { ThemeRef, UserContext as UserContext$1, FieldValue } from '@almadar/core';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Unified ThemeContext - Single provider for theme and color mode
|
|
@@ -187,23 +187,11 @@ declare const useCurrentPagePath: () => string | undefined;
|
|
|
187
187
|
*/
|
|
188
188
|
|
|
189
189
|
/**
|
|
190
|
-
* User data for
|
|
191
|
-
*
|
|
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.
|
|
192
193
|
*/
|
|
193
|
-
|
|
194
|
-
/** User's unique ID */
|
|
195
|
-
id: string;
|
|
196
|
-
/** User's email */
|
|
197
|
-
email?: string;
|
|
198
|
-
/** User's display name */
|
|
199
|
-
name?: string;
|
|
200
|
-
/** User's role (for RBAC) */
|
|
201
|
-
role?: string;
|
|
202
|
-
/** User's permissions */
|
|
203
|
-
permissions?: string[];
|
|
204
|
-
/** Additional custom profile fields */
|
|
205
|
-
[key: string]: FieldValue | undefined;
|
|
206
|
-
}
|
|
194
|
+
type UserData = UserContext$1;
|
|
207
195
|
/**
|
|
208
196
|
* User context value.
|
|
209
197
|
*/
|
|
@@ -223,10 +211,6 @@ interface UserContextValue {
|
|
|
223
211
|
/** Get a user field by path (for @user.field bindings) */
|
|
224
212
|
getUserField: (path: string) => FieldValue | undefined;
|
|
225
213
|
}
|
|
226
|
-
/**
|
|
227
|
-
* Anonymous user for when no user is logged in.
|
|
228
|
-
*/
|
|
229
|
-
declare const ANONYMOUS_USER: UserData;
|
|
230
214
|
declare const UserContext: React__default.Context<UserContextValue | null>;
|
|
231
215
|
interface UserProviderProps {
|
|
232
216
|
/** User data (null if not logged in) */
|
|
@@ -275,4 +259,4 @@ declare function useHasPermission(permission: string): boolean;
|
|
|
275
259
|
*/
|
|
276
260
|
declare function useUserForEvaluation(): UserData | undefined;
|
|
277
261
|
|
|
278
|
-
export {
|
|
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 };
|
package/dist/avl/index.cjs
CHANGED
|
@@ -24334,7 +24334,7 @@ var init_DashboardLayout = __esm({
|
|
|
24334
24334
|
]
|
|
24335
24335
|
}
|
|
24336
24336
|
),
|
|
24337
|
-
user && /* @__PURE__ */ jsxRuntime.jsxs(Box, { className: "relative", children: [
|
|
24337
|
+
user?.name && /* @__PURE__ */ jsxRuntime.jsxs(Box, { className: "relative", children: [
|
|
24338
24338
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
24339
24339
|
Button,
|
|
24340
24340
|
{
|
package/dist/avl/index.js
CHANGED
|
@@ -24258,7 +24258,7 @@ var init_DashboardLayout = __esm({
|
|
|
24258
24258
|
]
|
|
24259
24259
|
}
|
|
24260
24260
|
),
|
|
24261
|
-
user && /* @__PURE__ */ jsxs(Box, { className: "relative", children: [
|
|
24261
|
+
user?.name && /* @__PURE__ */ jsxs(Box, { className: "relative", children: [
|
|
24262
24262
|
/* @__PURE__ */ jsxs(
|
|
24263
24263
|
Button,
|
|
24264
24264
|
{
|
|
@@ -19648,7 +19648,7 @@ var init_DashboardLayout = __esm({
|
|
|
19648
19648
|
]
|
|
19649
19649
|
}
|
|
19650
19650
|
),
|
|
19651
|
-
user && /* @__PURE__ */ jsxRuntime.jsxs(exports.Box, { className: "relative", children: [
|
|
19651
|
+
user?.name && /* @__PURE__ */ jsxRuntime.jsxs(exports.Box, { className: "relative", children: [
|
|
19652
19652
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
19653
19653
|
exports.Button,
|
|
19654
19654
|
{
|
package/dist/components/index.js
CHANGED
|
@@ -19573,7 +19573,7 @@ var init_DashboardLayout = __esm({
|
|
|
19573
19573
|
]
|
|
19574
19574
|
}
|
|
19575
19575
|
),
|
|
19576
|
-
user && /* @__PURE__ */ jsxs(Box, { className: "relative", children: [
|
|
19576
|
+
user?.name && /* @__PURE__ */ jsxs(Box, { className: "relative", children: [
|
|
19577
19577
|
/* @__PURE__ */ jsxs(
|
|
19578
19578
|
Button,
|
|
19579
19579
|
{
|
package/dist/context/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { U as UISlotContext, a as UISlotProvider, u as useSlotContent, b as useSlotHasContent, c as useUISlots } from '../UISlotContext-D8_SoDsD.cjs';
|
|
2
|
-
export {
|
|
2
|
+
export { B as BUILT_IN_THEMES, C as ColorMode, a as CurrentPagePathContext, b as CurrentPagePathProvider, c as CurrentPagePathProviderProps, D as DesignTheme, d as DesignThemeProvider, O as OrbitalThemeProvider, e as OrbitalThemeProviderProps, R as ResolvedMode, T as ThemeContext, f as ThemeProvider, g as ThemeProviderProps, U as UIThemeDefinition, h as UserContext, i as UserContextValue, j as UserData, k as UserProvider, l as UserProviderProps, u as useCurrentPagePath, m as useDesignTheme, n as useHasPermission, o as useHasRole, p as useTheme, q as useUser, r as useUserForEvaluation } from '../UserContext-g_LcDiGN.cjs';
|
|
3
3
|
import { ThemeRef, ThemeDefinition, ThemeTokens, ThemeVariant } from '@almadar/core';
|
|
4
|
-
export { UISlot } from '@almadar/core';
|
|
4
|
+
export { ANONYMOUS_USER, UISlot } from '@almadar/core';
|
|
5
5
|
export { S as SlotAnimation, a as SlotChangeCallback, b as SlotContent, c as SlotRenderConfig, U as UISlotManager } from '../useUISlots-BesZYMks.cjs';
|
|
6
6
|
import 'react';
|
|
7
7
|
|
package/dist/context/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { U as UISlotContext, a as UISlotProvider, u as useSlotContent, b as useSlotHasContent, c as useUISlots } from '../UISlotContext-C1FsU9GB.js';
|
|
2
|
-
export {
|
|
2
|
+
export { B as BUILT_IN_THEMES, C as ColorMode, a as CurrentPagePathContext, b as CurrentPagePathProvider, c as CurrentPagePathProviderProps, D as DesignTheme, d as DesignThemeProvider, O as OrbitalThemeProvider, e as OrbitalThemeProviderProps, R as ResolvedMode, T as ThemeContext, f as ThemeProvider, g as ThemeProviderProps, U as UIThemeDefinition, h as UserContext, i as UserContextValue, j as UserData, k as UserProvider, l as UserProviderProps, u as useCurrentPagePath, m as useDesignTheme, n as useHasPermission, o as useHasRole, p as useTheme, q as useUser, r as useUserForEvaluation } from '../UserContext-g_LcDiGN.js';
|
|
3
3
|
import { ThemeRef, ThemeDefinition, ThemeTokens, ThemeVariant } from '@almadar/core';
|
|
4
|
-
export { UISlot } from '@almadar/core';
|
|
4
|
+
export { ANONYMOUS_USER, UISlot } from '@almadar/core';
|
|
5
5
|
export { S as SlotAnimation, a as SlotChangeCallback, b as SlotContent, c as SlotRenderConfig, U as UISlotManager } from '../useUISlots-BesZYMks.js';
|
|
6
6
|
import 'react';
|
|
7
7
|
|
package/dist/providers/index.cjs
CHANGED
|
@@ -22068,7 +22068,7 @@ var init_DashboardLayout = __esm({
|
|
|
22068
22068
|
]
|
|
22069
22069
|
}
|
|
22070
22070
|
),
|
|
22071
|
-
user && /* @__PURE__ */ jsxRuntime.jsxs(Box, { className: "relative", children: [
|
|
22071
|
+
user?.name && /* @__PURE__ */ jsxRuntime.jsxs(Box, { className: "relative", children: [
|
|
22072
22072
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
22073
22073
|
Button,
|
|
22074
22074
|
{
|
|
@@ -45154,6 +45154,96 @@ function VerificationProvider({
|
|
|
45154
45154
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
45155
45155
|
}
|
|
45156
45156
|
VerificationProvider.displayName = "VerificationProvider";
|
|
45157
|
+
var UserContext = React84.createContext(null);
|
|
45158
|
+
function UserProvider({
|
|
45159
|
+
user = null,
|
|
45160
|
+
children
|
|
45161
|
+
}) {
|
|
45162
|
+
const hasRole = React84.useCallback(
|
|
45163
|
+
(role) => {
|
|
45164
|
+
if (!user) return role === "anonymous";
|
|
45165
|
+
return user.role === role;
|
|
45166
|
+
},
|
|
45167
|
+
[user]
|
|
45168
|
+
);
|
|
45169
|
+
const hasPermission = React84.useCallback(
|
|
45170
|
+
(permission) => {
|
|
45171
|
+
if (!user) return false;
|
|
45172
|
+
return user.permissions?.includes(permission) ?? false;
|
|
45173
|
+
},
|
|
45174
|
+
[user]
|
|
45175
|
+
);
|
|
45176
|
+
const hasAnyRole = React84.useCallback(
|
|
45177
|
+
(roles) => {
|
|
45178
|
+
if (!user) return roles.includes("anonymous");
|
|
45179
|
+
return user.role ? roles.includes(user.role) : false;
|
|
45180
|
+
},
|
|
45181
|
+
[user]
|
|
45182
|
+
);
|
|
45183
|
+
const hasAllPermissions = React84.useCallback(
|
|
45184
|
+
(permissions) => {
|
|
45185
|
+
if (!user || !user.permissions) return false;
|
|
45186
|
+
return permissions.every((p) => user.permissions?.includes(p));
|
|
45187
|
+
},
|
|
45188
|
+
[user]
|
|
45189
|
+
);
|
|
45190
|
+
const getUserField = React84.useCallback(
|
|
45191
|
+
(path) => {
|
|
45192
|
+
const viewer = user ?? core.ANONYMOUS_USER;
|
|
45193
|
+
const [first, ...rest] = path.split(".");
|
|
45194
|
+
if (!first) return void 0;
|
|
45195
|
+
let value = viewer[first];
|
|
45196
|
+
for (const segment of rest) {
|
|
45197
|
+
if (value === null || typeof value !== "object" || Array.isArray(value) || value instanceof Date) {
|
|
45198
|
+
return void 0;
|
|
45199
|
+
}
|
|
45200
|
+
value = value[segment];
|
|
45201
|
+
}
|
|
45202
|
+
return value;
|
|
45203
|
+
},
|
|
45204
|
+
[user]
|
|
45205
|
+
);
|
|
45206
|
+
const contextValue = React84.useMemo(
|
|
45207
|
+
() => ({
|
|
45208
|
+
user,
|
|
45209
|
+
isLoggedIn: user !== null,
|
|
45210
|
+
hasRole,
|
|
45211
|
+
hasPermission,
|
|
45212
|
+
hasAnyRole,
|
|
45213
|
+
hasAllPermissions,
|
|
45214
|
+
getUserField
|
|
45215
|
+
}),
|
|
45216
|
+
[user, hasRole, hasPermission, hasAnyRole, hasAllPermissions, getUserField]
|
|
45217
|
+
);
|
|
45218
|
+
return /* @__PURE__ */ jsxRuntime.jsx(UserContext.Provider, { value: contextValue, children });
|
|
45219
|
+
}
|
|
45220
|
+
function useUser() {
|
|
45221
|
+
const context = React84.useContext(UserContext);
|
|
45222
|
+
if (!context) {
|
|
45223
|
+
return {
|
|
45224
|
+
user: null,
|
|
45225
|
+
isLoggedIn: false,
|
|
45226
|
+
hasRole: (role) => role === "anonymous",
|
|
45227
|
+
hasPermission: () => false,
|
|
45228
|
+
hasAnyRole: (roles) => roles.includes("anonymous"),
|
|
45229
|
+
hasAllPermissions: () => false,
|
|
45230
|
+
getUserField: () => void 0
|
|
45231
|
+
};
|
|
45232
|
+
}
|
|
45233
|
+
return context;
|
|
45234
|
+
}
|
|
45235
|
+
function useHasRole(role) {
|
|
45236
|
+
const { hasRole } = useUser();
|
|
45237
|
+
return hasRole(role);
|
|
45238
|
+
}
|
|
45239
|
+
function useHasPermission(permission) {
|
|
45240
|
+
const { hasPermission } = useUser();
|
|
45241
|
+
return hasPermission(permission);
|
|
45242
|
+
}
|
|
45243
|
+
function useUserForEvaluation() {
|
|
45244
|
+
const { user, isLoggedIn } = useUser();
|
|
45245
|
+
return isLoggedIn && user ? user : void 0;
|
|
45246
|
+
}
|
|
45157
45247
|
function OrbitalProvider({
|
|
45158
45248
|
children,
|
|
45159
45249
|
themes,
|
|
@@ -45165,13 +45255,14 @@ function OrbitalProvider({
|
|
|
45165
45255
|
initialData,
|
|
45166
45256
|
suspense = false,
|
|
45167
45257
|
verification,
|
|
45168
|
-
isolated = false
|
|
45258
|
+
isolated = false,
|
|
45259
|
+
user = null
|
|
45169
45260
|
}) {
|
|
45170
45261
|
const suspenseConfig = React84.useMemo(
|
|
45171
45262
|
() => ({ enabled: suspense }),
|
|
45172
45263
|
[suspense]
|
|
45173
45264
|
);
|
|
45174
|
-
const inner = /* @__PURE__ */ jsxRuntime.jsx(EventBusProvider, { debug: debug2, isolated, children: /* @__PURE__ */ jsxRuntime.jsx(VerificationProvider, { enabled: verification, children: /* @__PURE__ */ jsxRuntime.jsx(SelectionProvider, { debug: debug2, children: /* @__PURE__ */ jsxRuntime.jsx(SuspenseConfigProvider, { config: suspenseConfig, children }) }) }) });
|
|
45265
|
+
const inner = /* @__PURE__ */ jsxRuntime.jsx(EventBusProvider, { debug: debug2, isolated, children: /* @__PURE__ */ jsxRuntime.jsx(VerificationProvider, { enabled: verification, children: /* @__PURE__ */ jsxRuntime.jsx(UserProvider, { user, children: /* @__PURE__ */ jsxRuntime.jsx(SelectionProvider, { debug: debug2, children: /* @__PURE__ */ jsxRuntime.jsx(SuspenseConfigProvider, { config: suspenseConfig, children }) }) }) }) });
|
|
45175
45266
|
if (skipTheme) {
|
|
45176
45267
|
return inner;
|
|
45177
45268
|
}
|
|
@@ -45427,104 +45518,6 @@ var CurrentPagePathProvider = ({
|
|
|
45427
45518
|
}) => /* @__PURE__ */ jsxRuntime.jsx(CurrentPagePathContext.Provider, { value, children });
|
|
45428
45519
|
CurrentPagePathProvider.displayName = "CurrentPagePathProvider";
|
|
45429
45520
|
var useCurrentPagePath2 = () => React84.useContext(CurrentPagePathContext);
|
|
45430
|
-
var ANONYMOUS_USER = {
|
|
45431
|
-
id: "anonymous",
|
|
45432
|
-
role: "anonymous",
|
|
45433
|
-
permissions: []
|
|
45434
|
-
};
|
|
45435
|
-
var UserContext = React84.createContext(null);
|
|
45436
|
-
function UserProvider({
|
|
45437
|
-
user = null,
|
|
45438
|
-
children
|
|
45439
|
-
}) {
|
|
45440
|
-
const hasRole = React84.useCallback(
|
|
45441
|
-
(role) => {
|
|
45442
|
-
if (!user) return role === "anonymous";
|
|
45443
|
-
return user.role === role;
|
|
45444
|
-
},
|
|
45445
|
-
[user]
|
|
45446
|
-
);
|
|
45447
|
-
const hasPermission = React84.useCallback(
|
|
45448
|
-
(permission) => {
|
|
45449
|
-
if (!user) return false;
|
|
45450
|
-
return user.permissions?.includes(permission) ?? false;
|
|
45451
|
-
},
|
|
45452
|
-
[user]
|
|
45453
|
-
);
|
|
45454
|
-
const hasAnyRole = React84.useCallback(
|
|
45455
|
-
(roles) => {
|
|
45456
|
-
if (!user) return roles.includes("anonymous");
|
|
45457
|
-
return user.role ? roles.includes(user.role) : false;
|
|
45458
|
-
},
|
|
45459
|
-
[user]
|
|
45460
|
-
);
|
|
45461
|
-
const hasAllPermissions = React84.useCallback(
|
|
45462
|
-
(permissions) => {
|
|
45463
|
-
if (!user || !user.permissions) return false;
|
|
45464
|
-
return permissions.every((p) => user.permissions?.includes(p));
|
|
45465
|
-
},
|
|
45466
|
-
[user]
|
|
45467
|
-
);
|
|
45468
|
-
const getUserField = React84.useCallback(
|
|
45469
|
-
(path) => {
|
|
45470
|
-
const userData = user ?? ANONYMOUS_USER;
|
|
45471
|
-
const parts = path.split(".");
|
|
45472
|
-
let value = userData;
|
|
45473
|
-
for (const segment of parts) {
|
|
45474
|
-
if (value === null || value === void 0) {
|
|
45475
|
-
return void 0;
|
|
45476
|
-
}
|
|
45477
|
-
if (typeof value === "object") {
|
|
45478
|
-
value = value[segment];
|
|
45479
|
-
} else {
|
|
45480
|
-
return void 0;
|
|
45481
|
-
}
|
|
45482
|
-
}
|
|
45483
|
-
return value;
|
|
45484
|
-
},
|
|
45485
|
-
[user]
|
|
45486
|
-
);
|
|
45487
|
-
const contextValue = React84.useMemo(
|
|
45488
|
-
() => ({
|
|
45489
|
-
user,
|
|
45490
|
-
isLoggedIn: user !== null,
|
|
45491
|
-
hasRole,
|
|
45492
|
-
hasPermission,
|
|
45493
|
-
hasAnyRole,
|
|
45494
|
-
hasAllPermissions,
|
|
45495
|
-
getUserField
|
|
45496
|
-
}),
|
|
45497
|
-
[user, hasRole, hasPermission, hasAnyRole, hasAllPermissions, getUserField]
|
|
45498
|
-
);
|
|
45499
|
-
return /* @__PURE__ */ jsxRuntime.jsx(UserContext.Provider, { value: contextValue, children });
|
|
45500
|
-
}
|
|
45501
|
-
function useUser() {
|
|
45502
|
-
const context = React84.useContext(UserContext);
|
|
45503
|
-
if (!context) {
|
|
45504
|
-
return {
|
|
45505
|
-
user: null,
|
|
45506
|
-
isLoggedIn: false,
|
|
45507
|
-
hasRole: (role) => role === "anonymous",
|
|
45508
|
-
hasPermission: () => false,
|
|
45509
|
-
hasAnyRole: (roles) => roles.includes("anonymous"),
|
|
45510
|
-
hasAllPermissions: () => false,
|
|
45511
|
-
getUserField: () => void 0
|
|
45512
|
-
};
|
|
45513
|
-
}
|
|
45514
|
-
return context;
|
|
45515
|
-
}
|
|
45516
|
-
function useHasRole(role) {
|
|
45517
|
-
const { hasRole } = useUser();
|
|
45518
|
-
return hasRole(role);
|
|
45519
|
-
}
|
|
45520
|
-
function useHasPermission(permission) {
|
|
45521
|
-
const { hasPermission } = useUser();
|
|
45522
|
-
return hasPermission(permission);
|
|
45523
|
-
}
|
|
45524
|
-
function useUserForEvaluation() {
|
|
45525
|
-
const { user, isLoggedIn } = useUser();
|
|
45526
|
-
return isLoggedIn && user ? user : void 0;
|
|
45527
|
-
}
|
|
45528
45521
|
var EntitySchemaContext = React84.createContext(null);
|
|
45529
45522
|
function EntitySchemaProvider({
|
|
45530
45523
|
entities,
|
|
@@ -46248,7 +46241,10 @@ Object.defineProperty(exports, "useDesignTheme", {
|
|
|
46248
46241
|
enumerable: true,
|
|
46249
46242
|
get: function () { return context.useDesignTheme; }
|
|
46250
46243
|
});
|
|
46251
|
-
exports
|
|
46244
|
+
Object.defineProperty(exports, "ANONYMOUS_USER", {
|
|
46245
|
+
enumerable: true,
|
|
46246
|
+
get: function () { return core.ANONYMOUS_USER; }
|
|
46247
|
+
});
|
|
46252
46248
|
exports.CurrentPagePathContext = CurrentPagePathContext;
|
|
46253
46249
|
exports.CurrentPagePathProvider = CurrentPagePathProvider;
|
|
46254
46250
|
exports.EntitySchemaProvider = EntitySchemaProvider;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React__default, { ReactNode } from 'react';
|
|
2
2
|
import { EntityRow, FieldValue } from '@almadar/core';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
export { ANONYMOUS_USER } from '@almadar/core';
|
|
4
|
+
import { U as UIThemeDefinition, j as UserData } from '../UserContext-g_LcDiGN.cjs';
|
|
5
|
+
export { a as CurrentPagePathContext, b as CurrentPagePathProvider, c as CurrentPagePathProviderProps, d as DesignThemeProvider, O as OrbitalThemeProvider, e as OrbitalThemeProviderProps, h as UserContext, i as UserContextValue, k as UserProvider, l as UserProviderProps, u as useCurrentPagePath, m as useDesignTheme, n as useHasPermission, o as useHasRole, q as useUser, r as useUserForEvaluation } from '../UserContext-g_LcDiGN.cjs';
|
|
5
6
|
export { E as EntitySchemaContextValue, a as EntitySchemaProvider, b as EntitySchemaProviderProps, S as SendEventResult, c as ServerBridgeContextValue, d as ServerBridgeProvider, e as ServerBridgeProviderProps, f as ServerBridgeTransport, g as ServerClientEffect, h as ServerResponseMeta, T as TraitContext, i as TraitContextValue, j as TraitInstance, k as TraitProvider, l as TraitProviderProps, u as useEntitySchema, m as useEntitySchemaOptional, n as useServerBridge, o as useTrait, p as useTraitContext } from '../TraitProvider-Ch79cUcb.cjs';
|
|
6
7
|
import { U as UseOfflineExecutorResult, a as UseOfflineExecutorOptions } from '../offline-executor-Qz4b6GpF.cjs';
|
|
7
8
|
export { N as NavigationContextValue, b as NavigationProvider, c as NavigationProviderProps, d as NavigationState, e as comparePathSpecificity, f as extractRouteParams, g as findPageByName, h as findPageByPath, i as getAllPages, j as getDefaultPage, m as matchPath, k as matchPathAmong, p as pathMatches, u as useActivePage, l as useInitPayload, n as useNavigateTo, o as useNavigation, q as useNavigationId, r as useNavigationState } from '../offline-executor-Qz4b6GpF.cjs';
|
|
@@ -145,6 +146,7 @@ declare function useSelectionOptional<T = EntityRow>(): SelectionContextType<T>
|
|
|
145
146
|
* - ThemeProvider - Theme and color mode management
|
|
146
147
|
* - EventBusProvider - Page-scoped event pub/sub
|
|
147
148
|
* - SelectionProvider - Selected entity tracking
|
|
149
|
+
* - UserProvider - the viewer `@user.x` bindings resolve against
|
|
148
150
|
*
|
|
149
151
|
* Entity data flows through props (via enrichFromResponse in ServerBridge),
|
|
150
152
|
* not through context. FetchedDataProvider has been removed.
|
|
@@ -188,6 +190,15 @@ interface OrbitalProviderProps {
|
|
|
188
190
|
* preview's events don't clobber the host's global bus). Default false.
|
|
189
191
|
*/
|
|
190
192
|
isolated?: boolean;
|
|
193
|
+
/**
|
|
194
|
+
* The signed-in viewer. Generated trait hooks read `@user.x` through
|
|
195
|
+
* `useUser()`, so without this every role gate takes its negative branch and
|
|
196
|
+
* every ownership-scoped list renders empty — silently, since `useUser()`
|
|
197
|
+
* falls back to anonymous rather than throwing
|
|
198
|
+
* (U-USERPROVIDER-MOUNTED-NOWHERE). Mounting the provider here means every
|
|
199
|
+
* host that already wraps its app in OrbitalProvider only has to pass the user.
|
|
200
|
+
*/
|
|
201
|
+
user?: UserData | null;
|
|
191
202
|
}
|
|
192
203
|
/**
|
|
193
204
|
* OrbitalProvider - Unified context provider for Orbital applications
|
|
@@ -236,7 +247,7 @@ interface OrbitalProviderProps {
|
|
|
236
247
|
* }
|
|
237
248
|
* ```
|
|
238
249
|
*/
|
|
239
|
-
declare function OrbitalProvider({ children, themes, defaultTheme, defaultMode, targetRef, skipTheme, debug, initialData, suspense, verification, isolated, }: OrbitalProviderProps): React__default.ReactElement;
|
|
250
|
+
declare function OrbitalProvider({ children, themes, defaultTheme, defaultMode, targetRef, skipTheme, debug, initialData, suspense, verification, isolated, user, }: OrbitalProviderProps): React__default.ReactElement;
|
|
240
251
|
declare namespace OrbitalProvider {
|
|
241
252
|
var displayName: string;
|
|
242
253
|
}
|
|
@@ -454,4 +465,4 @@ declare function useOfflineMode(): OfflineModeContextValue;
|
|
|
454
465
|
*/
|
|
455
466
|
declare function useOptionalOfflineMode(): OfflineModeContextValue | null;
|
|
456
467
|
|
|
457
|
-
export { EventBusContext, EventBusProvider, type OfflineModeContextValue, OfflineModeProvider, type OfflineModeProviderProps, OrbitalProvider, type OrbitalProviderProps, SelectionContext, type SelectionContextType, SelectionProvider, type TraitScope, TraitScopeProvider, type TraitScopeProviderProps, UIThemeDefinition, VerificationProvider, type VerificationProviderProps, useOfflineMode, useOptionalOfflineMode, useSelection, useSelectionOptional, useTraitScope, useTraitScopeChain };
|
|
468
|
+
export { EventBusContext, EventBusProvider, type OfflineModeContextValue, OfflineModeProvider, type OfflineModeProviderProps, OrbitalProvider, type OrbitalProviderProps, SelectionContext, type SelectionContextType, SelectionProvider, type TraitScope, TraitScopeProvider, type TraitScopeProviderProps, UIThemeDefinition, UserData, VerificationProvider, type VerificationProviderProps, useOfflineMode, useOptionalOfflineMode, useSelection, useSelectionOptional, useTraitScope, useTraitScopeChain };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React__default, { ReactNode } from 'react';
|
|
2
2
|
import { EntityRow, FieldValue } from '@almadar/core';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
export { ANONYMOUS_USER } from '@almadar/core';
|
|
4
|
+
import { U as UIThemeDefinition, j as UserData } from '../UserContext-g_LcDiGN.js';
|
|
5
|
+
export { a as CurrentPagePathContext, b as CurrentPagePathProvider, c as CurrentPagePathProviderProps, d as DesignThemeProvider, O as OrbitalThemeProvider, e as OrbitalThemeProviderProps, h as UserContext, i as UserContextValue, k as UserProvider, l as UserProviderProps, u as useCurrentPagePath, m as useDesignTheme, n as useHasPermission, o as useHasRole, q as useUser, r as useUserForEvaluation } from '../UserContext-g_LcDiGN.js';
|
|
5
6
|
export { E as EntitySchemaContextValue, a as EntitySchemaProvider, b as EntitySchemaProviderProps, S as SendEventResult, c as ServerBridgeContextValue, d as ServerBridgeProvider, e as ServerBridgeProviderProps, f as ServerBridgeTransport, g as ServerClientEffect, h as ServerResponseMeta, T as TraitContext, i as TraitContextValue, j as TraitInstance, k as TraitProvider, l as TraitProviderProps, u as useEntitySchema, m as useEntitySchemaOptional, n as useServerBridge, o as useTrait, p as useTraitContext } from '../TraitProvider-Ch79cUcb.js';
|
|
6
7
|
import { U as UseOfflineExecutorResult, a as UseOfflineExecutorOptions } from '../offline-executor-Qz4b6GpF.js';
|
|
7
8
|
export { N as NavigationContextValue, b as NavigationProvider, c as NavigationProviderProps, d as NavigationState, e as comparePathSpecificity, f as extractRouteParams, g as findPageByName, h as findPageByPath, i as getAllPages, j as getDefaultPage, m as matchPath, k as matchPathAmong, p as pathMatches, u as useActivePage, l as useInitPayload, n as useNavigateTo, o as useNavigation, q as useNavigationId, r as useNavigationState } from '../offline-executor-Qz4b6GpF.js';
|
|
@@ -145,6 +146,7 @@ declare function useSelectionOptional<T = EntityRow>(): SelectionContextType<T>
|
|
|
145
146
|
* - ThemeProvider - Theme and color mode management
|
|
146
147
|
* - EventBusProvider - Page-scoped event pub/sub
|
|
147
148
|
* - SelectionProvider - Selected entity tracking
|
|
149
|
+
* - UserProvider - the viewer `@user.x` bindings resolve against
|
|
148
150
|
*
|
|
149
151
|
* Entity data flows through props (via enrichFromResponse in ServerBridge),
|
|
150
152
|
* not through context. FetchedDataProvider has been removed.
|
|
@@ -188,6 +190,15 @@ interface OrbitalProviderProps {
|
|
|
188
190
|
* preview's events don't clobber the host's global bus). Default false.
|
|
189
191
|
*/
|
|
190
192
|
isolated?: boolean;
|
|
193
|
+
/**
|
|
194
|
+
* The signed-in viewer. Generated trait hooks read `@user.x` through
|
|
195
|
+
* `useUser()`, so without this every role gate takes its negative branch and
|
|
196
|
+
* every ownership-scoped list renders empty — silently, since `useUser()`
|
|
197
|
+
* falls back to anonymous rather than throwing
|
|
198
|
+
* (U-USERPROVIDER-MOUNTED-NOWHERE). Mounting the provider here means every
|
|
199
|
+
* host that already wraps its app in OrbitalProvider only has to pass the user.
|
|
200
|
+
*/
|
|
201
|
+
user?: UserData | null;
|
|
191
202
|
}
|
|
192
203
|
/**
|
|
193
204
|
* OrbitalProvider - Unified context provider for Orbital applications
|
|
@@ -236,7 +247,7 @@ interface OrbitalProviderProps {
|
|
|
236
247
|
* }
|
|
237
248
|
* ```
|
|
238
249
|
*/
|
|
239
|
-
declare function OrbitalProvider({ children, themes, defaultTheme, defaultMode, targetRef, skipTheme, debug, initialData, suspense, verification, isolated, }: OrbitalProviderProps): React__default.ReactElement;
|
|
250
|
+
declare function OrbitalProvider({ children, themes, defaultTheme, defaultMode, targetRef, skipTheme, debug, initialData, suspense, verification, isolated, user, }: OrbitalProviderProps): React__default.ReactElement;
|
|
240
251
|
declare namespace OrbitalProvider {
|
|
241
252
|
var displayName: string;
|
|
242
253
|
}
|
|
@@ -454,4 +465,4 @@ declare function useOfflineMode(): OfflineModeContextValue;
|
|
|
454
465
|
*/
|
|
455
466
|
declare function useOptionalOfflineMode(): OfflineModeContextValue | null;
|
|
456
467
|
|
|
457
|
-
export { EventBusContext, EventBusProvider, type OfflineModeContextValue, OfflineModeProvider, type OfflineModeProviderProps, OrbitalProvider, type OrbitalProviderProps, SelectionContext, type SelectionContextType, SelectionProvider, type TraitScope, TraitScopeProvider, type TraitScopeProviderProps, UIThemeDefinition, VerificationProvider, type VerificationProviderProps, useOfflineMode, useOptionalOfflineMode, useSelection, useSelectionOptional, useTraitScope, useTraitScopeChain };
|
|
468
|
+
export { EventBusContext, EventBusProvider, type OfflineModeContextValue, OfflineModeProvider, type OfflineModeProviderProps, OrbitalProvider, type OrbitalProviderProps, SelectionContext, type SelectionContextType, SelectionProvider, type TraitScope, TraitScopeProvider, type TraitScopeProviderProps, UIThemeDefinition, UserData, VerificationProvider, type VerificationProviderProps, useOfflineMode, useOptionalOfflineMode, useSelection, useSelectionOptional, useTraitScope, useTraitScopeChain };
|
package/dist/providers/index.js
CHANGED
|
@@ -68,7 +68,8 @@ import ReactMarkdown from 'react-markdown';
|
|
|
68
68
|
import remarkGfm from 'remark-gfm';
|
|
69
69
|
import remarkMath from 'remark-math';
|
|
70
70
|
import rehypeKatex from 'rehype-katex';
|
|
71
|
-
import { isInlineTrait } from '@almadar/core';
|
|
71
|
+
import { ANONYMOUS_USER, isInlineTrait } from '@almadar/core';
|
|
72
|
+
export { ANONYMOUS_USER } from '@almadar/core';
|
|
72
73
|
import { DndContext, pointerWithin, rectIntersection, closestCorners, useSensors, useSensor, PointerSensor, KeyboardSensor, useDroppable } from '@dnd-kit/core';
|
|
73
74
|
import { useSortable, arrayMove, sortableKeyboardCoordinates, SortableContext, rectSortingStrategy, verticalListSortingStrategy } from '@dnd-kit/sortable';
|
|
74
75
|
import { CSS } from '@dnd-kit/utilities';
|
|
@@ -21993,7 +21994,7 @@ var init_DashboardLayout = __esm({
|
|
|
21993
21994
|
]
|
|
21994
21995
|
}
|
|
21995
21996
|
),
|
|
21996
|
-
user && /* @__PURE__ */ jsxs(Box, { className: "relative", children: [
|
|
21997
|
+
user?.name && /* @__PURE__ */ jsxs(Box, { className: "relative", children: [
|
|
21997
21998
|
/* @__PURE__ */ jsxs(
|
|
21998
21999
|
Button,
|
|
21999
22000
|
{
|
|
@@ -45079,6 +45080,96 @@ function VerificationProvider({
|
|
|
45079
45080
|
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
45080
45081
|
}
|
|
45081
45082
|
VerificationProvider.displayName = "VerificationProvider";
|
|
45083
|
+
var UserContext = createContext(null);
|
|
45084
|
+
function UserProvider({
|
|
45085
|
+
user = null,
|
|
45086
|
+
children
|
|
45087
|
+
}) {
|
|
45088
|
+
const hasRole = useCallback(
|
|
45089
|
+
(role) => {
|
|
45090
|
+
if (!user) return role === "anonymous";
|
|
45091
|
+
return user.role === role;
|
|
45092
|
+
},
|
|
45093
|
+
[user]
|
|
45094
|
+
);
|
|
45095
|
+
const hasPermission = useCallback(
|
|
45096
|
+
(permission) => {
|
|
45097
|
+
if (!user) return false;
|
|
45098
|
+
return user.permissions?.includes(permission) ?? false;
|
|
45099
|
+
},
|
|
45100
|
+
[user]
|
|
45101
|
+
);
|
|
45102
|
+
const hasAnyRole = useCallback(
|
|
45103
|
+
(roles) => {
|
|
45104
|
+
if (!user) return roles.includes("anonymous");
|
|
45105
|
+
return user.role ? roles.includes(user.role) : false;
|
|
45106
|
+
},
|
|
45107
|
+
[user]
|
|
45108
|
+
);
|
|
45109
|
+
const hasAllPermissions = useCallback(
|
|
45110
|
+
(permissions) => {
|
|
45111
|
+
if (!user || !user.permissions) return false;
|
|
45112
|
+
return permissions.every((p) => user.permissions?.includes(p));
|
|
45113
|
+
},
|
|
45114
|
+
[user]
|
|
45115
|
+
);
|
|
45116
|
+
const getUserField = useCallback(
|
|
45117
|
+
(path) => {
|
|
45118
|
+
const viewer = user ?? ANONYMOUS_USER;
|
|
45119
|
+
const [first, ...rest] = path.split(".");
|
|
45120
|
+
if (!first) return void 0;
|
|
45121
|
+
let value = viewer[first];
|
|
45122
|
+
for (const segment of rest) {
|
|
45123
|
+
if (value === null || typeof value !== "object" || Array.isArray(value) || value instanceof Date) {
|
|
45124
|
+
return void 0;
|
|
45125
|
+
}
|
|
45126
|
+
value = value[segment];
|
|
45127
|
+
}
|
|
45128
|
+
return value;
|
|
45129
|
+
},
|
|
45130
|
+
[user]
|
|
45131
|
+
);
|
|
45132
|
+
const contextValue = useMemo(
|
|
45133
|
+
() => ({
|
|
45134
|
+
user,
|
|
45135
|
+
isLoggedIn: user !== null,
|
|
45136
|
+
hasRole,
|
|
45137
|
+
hasPermission,
|
|
45138
|
+
hasAnyRole,
|
|
45139
|
+
hasAllPermissions,
|
|
45140
|
+
getUserField
|
|
45141
|
+
}),
|
|
45142
|
+
[user, hasRole, hasPermission, hasAnyRole, hasAllPermissions, getUserField]
|
|
45143
|
+
);
|
|
45144
|
+
return /* @__PURE__ */ jsx(UserContext.Provider, { value: contextValue, children });
|
|
45145
|
+
}
|
|
45146
|
+
function useUser() {
|
|
45147
|
+
const context = useContext(UserContext);
|
|
45148
|
+
if (!context) {
|
|
45149
|
+
return {
|
|
45150
|
+
user: null,
|
|
45151
|
+
isLoggedIn: false,
|
|
45152
|
+
hasRole: (role) => role === "anonymous",
|
|
45153
|
+
hasPermission: () => false,
|
|
45154
|
+
hasAnyRole: (roles) => roles.includes("anonymous"),
|
|
45155
|
+
hasAllPermissions: () => false,
|
|
45156
|
+
getUserField: () => void 0
|
|
45157
|
+
};
|
|
45158
|
+
}
|
|
45159
|
+
return context;
|
|
45160
|
+
}
|
|
45161
|
+
function useHasRole(role) {
|
|
45162
|
+
const { hasRole } = useUser();
|
|
45163
|
+
return hasRole(role);
|
|
45164
|
+
}
|
|
45165
|
+
function useHasPermission(permission) {
|
|
45166
|
+
const { hasPermission } = useUser();
|
|
45167
|
+
return hasPermission(permission);
|
|
45168
|
+
}
|
|
45169
|
+
function useUserForEvaluation() {
|
|
45170
|
+
const { user, isLoggedIn } = useUser();
|
|
45171
|
+
return isLoggedIn && user ? user : void 0;
|
|
45172
|
+
}
|
|
45082
45173
|
function OrbitalProvider({
|
|
45083
45174
|
children,
|
|
45084
45175
|
themes,
|
|
@@ -45090,13 +45181,14 @@ function OrbitalProvider({
|
|
|
45090
45181
|
initialData,
|
|
45091
45182
|
suspense = false,
|
|
45092
45183
|
verification,
|
|
45093
|
-
isolated = false
|
|
45184
|
+
isolated = false,
|
|
45185
|
+
user = null
|
|
45094
45186
|
}) {
|
|
45095
45187
|
const suspenseConfig = useMemo(
|
|
45096
45188
|
() => ({ enabled: suspense }),
|
|
45097
45189
|
[suspense]
|
|
45098
45190
|
);
|
|
45099
|
-
const inner = /* @__PURE__ */ jsx(EventBusProvider, { debug: debug2, isolated, children: /* @__PURE__ */ jsx(VerificationProvider, { enabled: verification, children: /* @__PURE__ */ jsx(SelectionProvider, { debug: debug2, children: /* @__PURE__ */ jsx(SuspenseConfigProvider, { config: suspenseConfig, children }) }) }) });
|
|
45191
|
+
const inner = /* @__PURE__ */ jsx(EventBusProvider, { debug: debug2, isolated, children: /* @__PURE__ */ jsx(VerificationProvider, { enabled: verification, children: /* @__PURE__ */ jsx(UserProvider, { user, children: /* @__PURE__ */ jsx(SelectionProvider, { debug: debug2, children: /* @__PURE__ */ jsx(SuspenseConfigProvider, { config: suspenseConfig, children }) }) }) }) });
|
|
45100
45192
|
if (skipTheme) {
|
|
45101
45193
|
return inner;
|
|
45102
45194
|
}
|
|
@@ -45352,104 +45444,6 @@ var CurrentPagePathProvider = ({
|
|
|
45352
45444
|
}) => /* @__PURE__ */ jsx(CurrentPagePathContext.Provider, { value, children });
|
|
45353
45445
|
CurrentPagePathProvider.displayName = "CurrentPagePathProvider";
|
|
45354
45446
|
var useCurrentPagePath2 = () => useContext(CurrentPagePathContext);
|
|
45355
|
-
var ANONYMOUS_USER = {
|
|
45356
|
-
id: "anonymous",
|
|
45357
|
-
role: "anonymous",
|
|
45358
|
-
permissions: []
|
|
45359
|
-
};
|
|
45360
|
-
var UserContext = createContext(null);
|
|
45361
|
-
function UserProvider({
|
|
45362
|
-
user = null,
|
|
45363
|
-
children
|
|
45364
|
-
}) {
|
|
45365
|
-
const hasRole = useCallback(
|
|
45366
|
-
(role) => {
|
|
45367
|
-
if (!user) return role === "anonymous";
|
|
45368
|
-
return user.role === role;
|
|
45369
|
-
},
|
|
45370
|
-
[user]
|
|
45371
|
-
);
|
|
45372
|
-
const hasPermission = useCallback(
|
|
45373
|
-
(permission) => {
|
|
45374
|
-
if (!user) return false;
|
|
45375
|
-
return user.permissions?.includes(permission) ?? false;
|
|
45376
|
-
},
|
|
45377
|
-
[user]
|
|
45378
|
-
);
|
|
45379
|
-
const hasAnyRole = useCallback(
|
|
45380
|
-
(roles) => {
|
|
45381
|
-
if (!user) return roles.includes("anonymous");
|
|
45382
|
-
return user.role ? roles.includes(user.role) : false;
|
|
45383
|
-
},
|
|
45384
|
-
[user]
|
|
45385
|
-
);
|
|
45386
|
-
const hasAllPermissions = useCallback(
|
|
45387
|
-
(permissions) => {
|
|
45388
|
-
if (!user || !user.permissions) return false;
|
|
45389
|
-
return permissions.every((p) => user.permissions?.includes(p));
|
|
45390
|
-
},
|
|
45391
|
-
[user]
|
|
45392
|
-
);
|
|
45393
|
-
const getUserField = useCallback(
|
|
45394
|
-
(path) => {
|
|
45395
|
-
const userData = user ?? ANONYMOUS_USER;
|
|
45396
|
-
const parts = path.split(".");
|
|
45397
|
-
let value = userData;
|
|
45398
|
-
for (const segment of parts) {
|
|
45399
|
-
if (value === null || value === void 0) {
|
|
45400
|
-
return void 0;
|
|
45401
|
-
}
|
|
45402
|
-
if (typeof value === "object") {
|
|
45403
|
-
value = value[segment];
|
|
45404
|
-
} else {
|
|
45405
|
-
return void 0;
|
|
45406
|
-
}
|
|
45407
|
-
}
|
|
45408
|
-
return value;
|
|
45409
|
-
},
|
|
45410
|
-
[user]
|
|
45411
|
-
);
|
|
45412
|
-
const contextValue = useMemo(
|
|
45413
|
-
() => ({
|
|
45414
|
-
user,
|
|
45415
|
-
isLoggedIn: user !== null,
|
|
45416
|
-
hasRole,
|
|
45417
|
-
hasPermission,
|
|
45418
|
-
hasAnyRole,
|
|
45419
|
-
hasAllPermissions,
|
|
45420
|
-
getUserField
|
|
45421
|
-
}),
|
|
45422
|
-
[user, hasRole, hasPermission, hasAnyRole, hasAllPermissions, getUserField]
|
|
45423
|
-
);
|
|
45424
|
-
return /* @__PURE__ */ jsx(UserContext.Provider, { value: contextValue, children });
|
|
45425
|
-
}
|
|
45426
|
-
function useUser() {
|
|
45427
|
-
const context = useContext(UserContext);
|
|
45428
|
-
if (!context) {
|
|
45429
|
-
return {
|
|
45430
|
-
user: null,
|
|
45431
|
-
isLoggedIn: false,
|
|
45432
|
-
hasRole: (role) => role === "anonymous",
|
|
45433
|
-
hasPermission: () => false,
|
|
45434
|
-
hasAnyRole: (roles) => roles.includes("anonymous"),
|
|
45435
|
-
hasAllPermissions: () => false,
|
|
45436
|
-
getUserField: () => void 0
|
|
45437
|
-
};
|
|
45438
|
-
}
|
|
45439
|
-
return context;
|
|
45440
|
-
}
|
|
45441
|
-
function useHasRole(role) {
|
|
45442
|
-
const { hasRole } = useUser();
|
|
45443
|
-
return hasRole(role);
|
|
45444
|
-
}
|
|
45445
|
-
function useHasPermission(permission) {
|
|
45446
|
-
const { hasPermission } = useUser();
|
|
45447
|
-
return hasPermission(permission);
|
|
45448
|
-
}
|
|
45449
|
-
function useUserForEvaluation() {
|
|
45450
|
-
const { user, isLoggedIn } = useUser();
|
|
45451
|
-
return isLoggedIn && user ? user : void 0;
|
|
45452
|
-
}
|
|
45453
45447
|
var EntitySchemaContext = createContext(null);
|
|
45454
45448
|
function EntitySchemaProvider({
|
|
45455
45449
|
entities,
|
|
@@ -46165,4 +46159,4 @@ function GameAudioProvider2({
|
|
|
46165
46159
|
}
|
|
46166
46160
|
GameAudioProvider2.displayName = "GameAudioProvider";
|
|
46167
46161
|
|
|
46168
|
-
export {
|
|
46162
|
+
export { CurrentPagePathContext, CurrentPagePathProvider, EntitySchemaProvider, EventBusContext2 as EventBusContext, EventBusProvider, GameAudioContext2 as GameAudioContext, GameAudioProvider2 as GameAudioProvider, NavigationProvider2 as NavigationProvider, OfflineModeProvider, OrbitalProvider, OrbitalThemeProvider, SelectionContext, SelectionProvider, ServerBridgeProvider, TraitContext, TraitProvider, TraitScopeProvider3 as TraitScopeProvider, UserContext, UserProvider, VerificationProvider, comparePathSpecificity2 as comparePathSpecificity, extractRouteParams2 as extractRouteParams, findPageByName2 as findPageByName, findPageByPath2 as findPageByPath, getAllPages2 as getAllPages, getDefaultPage2 as getDefaultPage, matchPath2 as matchPath, matchPathAmong2 as matchPathAmong, pathMatches2 as pathMatches, useActivePage2 as useActivePage, useCurrentPagePath2 as useCurrentPagePath, useEntitySchema, useEntitySchemaOptional6 as useEntitySchemaOptional, useGameAudioContext2 as useGameAudioContext, useGameAudioContextOptional2 as useGameAudioContextOptional, useHasPermission, useHasRole, useInitPayload2 as useInitPayload, useNavigateTo2 as useNavigateTo, useNavigation2 as useNavigation, useNavigationId2 as useNavigationId, useNavigationState2 as useNavigationState, useOfflineMode, useOptionalOfflineMode, useSelection, useSelectionOptional, useServerBridge, useTrait, useTraitContext, useTraitScope, useTraitScopeChain2 as useTraitScopeChain, useUser, useUserForEvaluation };
|
package/dist/runtime/index.cjs
CHANGED
|
@@ -21622,7 +21622,7 @@ var init_DashboardLayout = __esm({
|
|
|
21622
21622
|
]
|
|
21623
21623
|
}
|
|
21624
21624
|
),
|
|
21625
|
-
user && /* @__PURE__ */ jsxRuntime.jsxs(Box, { className: "relative", children: [
|
|
21625
|
+
user?.name && /* @__PURE__ */ jsxRuntime.jsxs(Box, { className: "relative", children: [
|
|
21626
21626
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
21627
21627
|
Button,
|
|
21628
21628
|
{
|
package/dist/runtime/index.js
CHANGED
|
@@ -21548,7 +21548,7 @@ var init_DashboardLayout = __esm({
|
|
|
21548
21548
|
]
|
|
21549
21549
|
}
|
|
21550
21550
|
),
|
|
21551
|
-
user && /* @__PURE__ */ jsxs(Box, { className: "relative", children: [
|
|
21551
|
+
user?.name && /* @__PURE__ */ jsxs(Box, { className: "relative", children: [
|
|
21552
21552
|
/* @__PURE__ */ jsxs(
|
|
21553
21553
|
Button,
|
|
21554
21554
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@almadar/ui",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.128.0",
|
|
4
4
|
"description": "React UI components, hooks, and providers for Almadar",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -117,11 +117,11 @@
|
|
|
117
117
|
"access": "public"
|
|
118
118
|
},
|
|
119
119
|
"dependencies": {
|
|
120
|
-
"@almadar/core": "^10.
|
|
121
|
-
"@almadar/evaluator": "^2.
|
|
120
|
+
"@almadar/core": "^10.36.0",
|
|
121
|
+
"@almadar/evaluator": "^2.37.0",
|
|
122
122
|
"@almadar/logger": "^1.10.0",
|
|
123
|
-
"@almadar/runtime": "^6.
|
|
124
|
-
"@almadar/std": "^16.
|
|
123
|
+
"@almadar/runtime": "^6.39.0",
|
|
124
|
+
"@almadar/std": "^16.146.0",
|
|
125
125
|
"@almadar/syntax": "^1.12.0",
|
|
126
126
|
"@dnd-kit/core": "^6.3.1",
|
|
127
127
|
"@dnd-kit/sortable": "^10.0.0",
|