@nubitio/admin 0.5.20 → 0.5.22
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/index.cjs +44 -0
- package/dist/index.d.cts +21 -1
- package/dist/index.d.mts +21 -1
- package/dist/index.mjs +42 -2
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -440,6 +440,46 @@ function useSession() {
|
|
|
440
440
|
if (!context) throw new Error("useSession must be used within a <SessionProvider>.");
|
|
441
441
|
return context;
|
|
442
442
|
}
|
|
443
|
+
/** Seeds session state from a known profile (e.g. after a custom /api/me fetch). */
|
|
444
|
+
function StaticSessionProvider({ profile, children }) {
|
|
445
|
+
const value = (0, react.useMemo)(() => ({
|
|
446
|
+
session: {
|
|
447
|
+
status: "authenticated",
|
|
448
|
+
profile
|
|
449
|
+
},
|
|
450
|
+
refresh: async () => void 0,
|
|
451
|
+
logout: async () => void 0,
|
|
452
|
+
roles: profile.roles,
|
|
453
|
+
username: profile.username
|
|
454
|
+
}), [profile]);
|
|
455
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SessionContext.Provider, {
|
|
456
|
+
value,
|
|
457
|
+
children
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
//#endregion
|
|
461
|
+
//#region packages/admin/hooks/useFeature.ts
|
|
462
|
+
function useFeature(featureKey) {
|
|
463
|
+
const { session } = useSession();
|
|
464
|
+
if (session.status !== "authenticated") return false;
|
|
465
|
+
return session.profile.features?.[featureKey]?.enabled ?? false;
|
|
466
|
+
}
|
|
467
|
+
function useFeatureConfig(featureKey) {
|
|
468
|
+
const { session } = useSession();
|
|
469
|
+
if (session.status !== "authenticated") return {};
|
|
470
|
+
const entry = session.profile.features?.[featureKey];
|
|
471
|
+
if (!entry?.enabled) return {};
|
|
472
|
+
return entry.config ?? {};
|
|
473
|
+
}
|
|
474
|
+
//#endregion
|
|
475
|
+
//#region packages/admin/features/FeatureGate.tsx
|
|
476
|
+
function FeatureGate({ featureKey, ...props }) {
|
|
477
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_nubitio_ui.FeatureGate, {
|
|
478
|
+
featureKey,
|
|
479
|
+
enabled: useFeature(featureKey),
|
|
480
|
+
...props
|
|
481
|
+
});
|
|
482
|
+
}
|
|
443
483
|
//#endregion
|
|
444
484
|
//#region packages/admin/auth/LoginPage.tsx
|
|
445
485
|
function joinApiPath$1(apiBaseUrl, path) {
|
|
@@ -800,13 +840,17 @@ function createNubitApp(config) {
|
|
|
800
840
|
exports.AdminHeader = AdminHeader;
|
|
801
841
|
exports.AdminShell = AdminShell;
|
|
802
842
|
exports.AdminSidebarMenu = AdminSidebarMenu;
|
|
843
|
+
exports.FeatureGate = FeatureGate;
|
|
803
844
|
exports.LoginPage = LoginPage;
|
|
804
845
|
exports.SessionProvider = SessionProvider;
|
|
846
|
+
exports.StaticSessionProvider = StaticSessionProvider;
|
|
805
847
|
exports.ToastHost = ToastHost;
|
|
806
848
|
exports.createNubitApp = createNubitApp;
|
|
807
849
|
exports.filterMenuByRoles = filterMenuByRoles;
|
|
808
850
|
exports.hasAnyRole = hasAnyRole;
|
|
809
851
|
exports.useAppRuntime = useAppRuntime;
|
|
852
|
+
exports.useFeature = useFeature;
|
|
853
|
+
exports.useFeatureConfig = useFeatureConfig;
|
|
810
854
|
exports.useRuntimeConfig = useRuntimeConfig;
|
|
811
855
|
exports.useScreenSize = useScreenSize;
|
|
812
856
|
exports.useScreenSizeClass = useScreenSizeClass;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React$1, { ReactNode } from "react";
|
|
2
|
+
import { FeatureGateProps as FeatureGateProps$1 } from "@nubitio/ui";
|
|
2
3
|
import { CoreRuntime } from "@nubitio/core";
|
|
3
4
|
import { QueryClient } from "@tanstack/react-query";
|
|
4
5
|
|
|
@@ -147,6 +148,25 @@ declare function SessionProvider({
|
|
|
147
148
|
children: React$1.ReactNode;
|
|
148
149
|
}): React$1.JSX.Element;
|
|
149
150
|
declare function useSession(): SessionContextValue;
|
|
151
|
+
/** Seeds session state from a known profile (e.g. after a custom /api/me fetch). */
|
|
152
|
+
declare function StaticSessionProvider({
|
|
153
|
+
profile,
|
|
154
|
+
children
|
|
155
|
+
}: {
|
|
156
|
+
profile: SessionProfile;
|
|
157
|
+
children: React$1.ReactNode;
|
|
158
|
+
}): React$1.JSX.Element;
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region packages/admin/hooks/useFeature.d.ts
|
|
161
|
+
declare function useFeature(featureKey: string): boolean;
|
|
162
|
+
declare function useFeatureConfig(featureKey: string): Record<string, unknown>;
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region packages/admin/features/FeatureGate.d.ts
|
|
165
|
+
type FeatureGateProps = Omit<FeatureGateProps$1, 'enabled'>;
|
|
166
|
+
declare function FeatureGate({
|
|
167
|
+
featureKey,
|
|
168
|
+
...props
|
|
169
|
+
}: FeatureGateProps): React$1.JSX.Element;
|
|
150
170
|
//#endregion
|
|
151
171
|
//#region packages/admin/auth/LoginPage.d.ts
|
|
152
172
|
interface LoginPageProps {
|
|
@@ -287,4 +307,4 @@ declare function hasAnyRole(required: string | string[] | undefined, roles: stri
|
|
|
287
307
|
*/
|
|
288
308
|
declare function filterMenuByRoles(items: NubitAppMenuItem[], roles: string[]): AdminMenuItem[];
|
|
289
309
|
//#endregion
|
|
290
|
-
export { AdminHeader, type AdminHeaderAction, type AdminHeaderProps, type AdminMenuItem, type AdminMenuSubItem, AdminShell, type AdminShellProps, AdminSidebarMenu, type AdminSidebarMenuProps, type AdminSidebarMenuSelectEvent, type AppProfile, type CreateNubitAppConfig, LoginPage, type LoginPageProps, type NotificationType, type NubitApp, type NubitAppMenuContext, type NubitAppMenuItem, type NubitAppMenuSubItem, type NubitAppRoute, type NubitAppUserMenuContext, type RuntimeConfig, type RuntimeConfigState, type SessionContextValue, type SessionFeatureEntitlement, type SessionProfile, SessionProvider, type SessionProviderConfig, type SessionState, type SessionTenant, ToastHost, type ToastHostProps, type ToastItem, type UseRuntimeConfigOptions, createNubitApp, filterMenuByRoles, hasAnyRole, useAppRuntime, useRuntimeConfig, useScreenSize, useScreenSizeClass, useSession };
|
|
310
|
+
export { AdminHeader, type AdminHeaderAction, type AdminHeaderProps, type AdminMenuItem, type AdminMenuSubItem, AdminShell, type AdminShellProps, AdminSidebarMenu, type AdminSidebarMenuProps, type AdminSidebarMenuSelectEvent, type AppProfile, type CreateNubitAppConfig, FeatureGate, type FeatureGateProps, LoginPage, type LoginPageProps, type NotificationType, type NubitApp, type NubitAppMenuContext, type NubitAppMenuItem, type NubitAppMenuSubItem, type NubitAppRoute, type NubitAppUserMenuContext, type RuntimeConfig, type RuntimeConfigState, type SessionContextValue, type SessionFeatureEntitlement, type SessionProfile, SessionProvider, type SessionProviderConfig, type SessionState, type SessionTenant, StaticSessionProvider, ToastHost, type ToastHostProps, type ToastItem, type UseRuntimeConfigOptions, createNubitApp, filterMenuByRoles, hasAnyRole, useAppRuntime, useFeature, useFeatureConfig, useRuntimeConfig, useScreenSize, useScreenSizeClass, useSession };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React$1, { ReactNode } from "react";
|
|
2
|
+
import { FeatureGateProps as FeatureGateProps$1 } from "@nubitio/ui";
|
|
2
3
|
import { QueryClient } from "@tanstack/react-query";
|
|
3
4
|
import { CoreRuntime } from "@nubitio/core";
|
|
4
5
|
|
|
@@ -147,6 +148,25 @@ declare function SessionProvider({
|
|
|
147
148
|
children: React$1.ReactNode;
|
|
148
149
|
}): React$1.JSX.Element;
|
|
149
150
|
declare function useSession(): SessionContextValue;
|
|
151
|
+
/** Seeds session state from a known profile (e.g. after a custom /api/me fetch). */
|
|
152
|
+
declare function StaticSessionProvider({
|
|
153
|
+
profile,
|
|
154
|
+
children
|
|
155
|
+
}: {
|
|
156
|
+
profile: SessionProfile;
|
|
157
|
+
children: React$1.ReactNode;
|
|
158
|
+
}): React$1.JSX.Element;
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region packages/admin/hooks/useFeature.d.ts
|
|
161
|
+
declare function useFeature(featureKey: string): boolean;
|
|
162
|
+
declare function useFeatureConfig(featureKey: string): Record<string, unknown>;
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region packages/admin/features/FeatureGate.d.ts
|
|
165
|
+
type FeatureGateProps = Omit<FeatureGateProps$1, 'enabled'>;
|
|
166
|
+
declare function FeatureGate({
|
|
167
|
+
featureKey,
|
|
168
|
+
...props
|
|
169
|
+
}: FeatureGateProps): React$1.JSX.Element;
|
|
150
170
|
//#endregion
|
|
151
171
|
//#region packages/admin/auth/LoginPage.d.ts
|
|
152
172
|
interface LoginPageProps {
|
|
@@ -287,4 +307,4 @@ declare function hasAnyRole(required: string | string[] | undefined, roles: stri
|
|
|
287
307
|
*/
|
|
288
308
|
declare function filterMenuByRoles(items: NubitAppMenuItem[], roles: string[]): AdminMenuItem[];
|
|
289
309
|
//#endregion
|
|
290
|
-
export { AdminHeader, type AdminHeaderAction, type AdminHeaderProps, type AdminMenuItem, type AdminMenuSubItem, AdminShell, type AdminShellProps, AdminSidebarMenu, type AdminSidebarMenuProps, type AdminSidebarMenuSelectEvent, type AppProfile, type CreateNubitAppConfig, LoginPage, type LoginPageProps, type NotificationType, type NubitApp, type NubitAppMenuContext, type NubitAppMenuItem, type NubitAppMenuSubItem, type NubitAppRoute, type NubitAppUserMenuContext, type RuntimeConfig, type RuntimeConfigState, type SessionContextValue, type SessionFeatureEntitlement, type SessionProfile, SessionProvider, type SessionProviderConfig, type SessionState, type SessionTenant, ToastHost, type ToastHostProps, type ToastItem, type UseRuntimeConfigOptions, createNubitApp, filterMenuByRoles, hasAnyRole, useAppRuntime, useRuntimeConfig, useScreenSize, useScreenSizeClass, useSession };
|
|
310
|
+
export { AdminHeader, type AdminHeaderAction, type AdminHeaderProps, type AdminMenuItem, type AdminMenuSubItem, AdminShell, type AdminShellProps, AdminSidebarMenu, type AdminSidebarMenuProps, type AdminSidebarMenuSelectEvent, type AppProfile, type CreateNubitAppConfig, FeatureGate, type FeatureGateProps, LoginPage, type LoginPageProps, type NotificationType, type NubitApp, type NubitAppMenuContext, type NubitAppMenuItem, type NubitAppMenuSubItem, type NubitAppRoute, type NubitAppUserMenuContext, type RuntimeConfig, type RuntimeConfigState, type SessionContextValue, type SessionFeatureEntitlement, type SessionProfile, SessionProvider, type SessionProviderConfig, type SessionState, type SessionTenant, StaticSessionProvider, ToastHost, type ToastHostProps, type ToastItem, type UseRuntimeConfigOptions, createNubitApp, filterMenuByRoles, hasAnyRole, useAppRuntime, useFeature, useFeatureConfig, useRuntimeConfig, useScreenSize, useScreenSizeClass, useSession };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
2
2
|
import { BrowserRouter, Navigate, Route, Routes, useLocation, useNavigate } from "react-router-dom";
|
|
3
|
-
import { Badge, Button, Card, IconButton, TextField, ThemeProvider, ThemeSwitcher, useFloatingPanel } from "@nubitio/ui";
|
|
3
|
+
import { Badge, Button, Card, FeatureGate as FeatureGate$1, IconButton, TextField, ThemeProvider, ThemeSwitcher, useFloatingPanel } from "@nubitio/ui";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
6
6
|
import { CoreConfigProvider, CoreProvider, MercureProvider } from "@nubitio/core";
|
|
@@ -416,6 +416,46 @@ function useSession() {
|
|
|
416
416
|
if (!context) throw new Error("useSession must be used within a <SessionProvider>.");
|
|
417
417
|
return context;
|
|
418
418
|
}
|
|
419
|
+
/** Seeds session state from a known profile (e.g. after a custom /api/me fetch). */
|
|
420
|
+
function StaticSessionProvider({ profile, children }) {
|
|
421
|
+
const value = useMemo(() => ({
|
|
422
|
+
session: {
|
|
423
|
+
status: "authenticated",
|
|
424
|
+
profile
|
|
425
|
+
},
|
|
426
|
+
refresh: async () => void 0,
|
|
427
|
+
logout: async () => void 0,
|
|
428
|
+
roles: profile.roles,
|
|
429
|
+
username: profile.username
|
|
430
|
+
}), [profile]);
|
|
431
|
+
return /* @__PURE__ */ jsx(SessionContext.Provider, {
|
|
432
|
+
value,
|
|
433
|
+
children
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
//#endregion
|
|
437
|
+
//#region packages/admin/hooks/useFeature.ts
|
|
438
|
+
function useFeature(featureKey) {
|
|
439
|
+
const { session } = useSession();
|
|
440
|
+
if (session.status !== "authenticated") return false;
|
|
441
|
+
return session.profile.features?.[featureKey]?.enabled ?? false;
|
|
442
|
+
}
|
|
443
|
+
function useFeatureConfig(featureKey) {
|
|
444
|
+
const { session } = useSession();
|
|
445
|
+
if (session.status !== "authenticated") return {};
|
|
446
|
+
const entry = session.profile.features?.[featureKey];
|
|
447
|
+
if (!entry?.enabled) return {};
|
|
448
|
+
return entry.config ?? {};
|
|
449
|
+
}
|
|
450
|
+
//#endregion
|
|
451
|
+
//#region packages/admin/features/FeatureGate.tsx
|
|
452
|
+
function FeatureGate({ featureKey, ...props }) {
|
|
453
|
+
return /* @__PURE__ */ jsx(FeatureGate$1, {
|
|
454
|
+
featureKey,
|
|
455
|
+
enabled: useFeature(featureKey),
|
|
456
|
+
...props
|
|
457
|
+
});
|
|
458
|
+
}
|
|
419
459
|
//#endregion
|
|
420
460
|
//#region packages/admin/auth/LoginPage.tsx
|
|
421
461
|
function joinApiPath$1(apiBaseUrl, path) {
|
|
@@ -773,4 +813,4 @@ function createNubitApp(config) {
|
|
|
773
813
|
return { App };
|
|
774
814
|
}
|
|
775
815
|
//#endregion
|
|
776
|
-
export { AdminHeader, AdminShell, AdminSidebarMenu, LoginPage, SessionProvider, ToastHost, createNubitApp, filterMenuByRoles, hasAnyRole, useAppRuntime, useRuntimeConfig, useScreenSize, useScreenSizeClass, useSession };
|
|
816
|
+
export { AdminHeader, AdminShell, AdminSidebarMenu, FeatureGate, LoginPage, SessionProvider, StaticSessionProvider, ToastHost, createNubitApp, filterMenuByRoles, hasAnyRole, useAppRuntime, useFeature, useFeatureConfig, useRuntimeConfig, useScreenSize, useScreenSizeClass, useSession };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nubitio/admin",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.22",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Admin shell layout components: responsive sidebar, header, and screen size utilities for Nubit apps.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"react": "^19.0.0",
|
|
54
54
|
"react-dom": "^19.0.0",
|
|
55
55
|
"react-router-dom": "^6.0.0",
|
|
56
|
-
"@nubitio/core": "^0.5.
|
|
57
|
-
"@nubitio/
|
|
58
|
-
"@nubitio/
|
|
59
|
-
"@nubitio/
|
|
56
|
+
"@nubitio/core": "^0.5.22",
|
|
57
|
+
"@nubitio/crud": "^0.5.22",
|
|
58
|
+
"@nubitio/hydra": "^0.5.22",
|
|
59
|
+
"@nubitio/ui": "^0.5.22"
|
|
60
60
|
}
|
|
61
61
|
}
|