xladmin 0.6.0 → 0.9.1

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 CHANGED
@@ -71,6 +71,7 @@ For framework routing, use one of the adapter packages instead of the default br
71
71
  ## Current User And Logout
72
72
 
73
73
  `Shell` shows a compact current-user panel pinned to the bottom of the sidebar when a user is available.
74
+ Long login values wrap inside the panel instead of overflowing the sidebar.
74
75
  By default it calls:
75
76
 
76
77
  - `client.getCurrentUser()` -> `GET /xladmin/me/`
@@ -1,7 +1,9 @@
1
1
  import type { ReactNode } from 'react';
2
2
  type ShellContextValue = {
3
- isMobile: boolean;
4
- openMobileSidebar: () => void;
3
+ hasSidebar: boolean;
4
+ sidebarId: string;
5
+ isSidebarOpen: boolean;
6
+ toggleSidebar: () => void;
5
7
  pendingPath: string | null;
6
8
  pendingView: 'overview' | 'model' | 'generic' | null;
7
9
  startPendingNavigation: (path: string, view?: 'overview' | 'model' | 'generic') => void;
package/dist/index.js CHANGED
@@ -1716,8 +1716,10 @@ function useAdminData() {
1716
1716
  import { createContext as createContext5, useContext as useContext5 } from "react";
1717
1717
  import { jsx as jsx7 } from "react/jsx-runtime";
1718
1718
  var defaultShellContextValue = {
1719
- isMobile: false,
1720
- openMobileSidebar: () => {
1719
+ hasSidebar: false,
1720
+ sidebarId: "",
1721
+ isSidebarOpen: false,
1722
+ toggleSidebar: () => {
1721
1723
  },
1722
1724
  pendingPath: null,
1723
1725
  pendingView: null,
@@ -2156,7 +2158,6 @@ var MAIN_HEADER_TITLE_HEIGHT = 34;
2156
2158
  var MAIN_HEADER_SUBTITLE_HEIGHT = 16;
2157
2159
  function MainHeader({ title, subtitle, details, error, beforeTitle, beforeSubtitle, actions }) {
2158
2160
  const t = useAdminTranslation();
2159
- const { isMobile, openMobileSidebar } = useShellContext();
2160
2161
  const [isDetailsOpen, setIsDetailsOpen] = useState6(false);
2161
2162
  return /* @__PURE__ */ jsxs7(
2162
2163
  Paper3,
@@ -2175,16 +2176,7 @@ function MainHeader({ title, subtitle, details, error, beforeTitle, beforeSubtit
2175
2176
  /* @__PURE__ */ jsxs7(Stack5, { spacing: 0.5, children: [
2176
2177
  /* @__PURE__ */ jsxs7(Stack5, { direction: "row", spacing: 1.5, sx: { minWidth: 0, alignItems: "center", justifyContent: "space-between" }, children: [
2177
2178
  /* @__PURE__ */ jsxs7(Stack5, { direction: "row", spacing: 1, sx: { minWidth: 0, flex: 1, alignItems: "center" }, children: [
2178
- isMobile ? /* @__PURE__ */ jsx13(Box5, { sx: { display: "flex", alignItems: "center", flexShrink: 0 }, children: /* @__PURE__ */ jsx13(
2179
- IconButton,
2180
- {
2181
- "aria-label": t("menu"),
2182
- onClick: openMobileSidebar,
2183
- size: "small",
2184
- sx: { ml: -0.5 },
2185
- children: /* @__PURE__ */ jsx13(MenuIcon, { fontSize: "small" })
2186
- }
2187
- ) }) : null,
2179
+ /* @__PURE__ */ jsx13(SidebarMenuButton, {}),
2188
2180
  beforeTitle ? /* @__PURE__ */ jsx13(Box5, { sx: { display: "flex", alignItems: "center", flexShrink: 0 }, children: beforeTitle }) : null,
2189
2181
  /* @__PURE__ */ jsx13(
2190
2182
  Typography3,
@@ -2257,15 +2249,18 @@ function MainHeaderSkeleton({
2257
2249
  zIndex: 3
2258
2250
  },
2259
2251
  children: /* @__PURE__ */ jsxs7(Stack5, { spacing: 1, children: [
2260
- /* @__PURE__ */ jsx13(
2261
- Skeleton,
2262
- {
2263
- variant: "rounded",
2264
- width: titleWidth,
2265
- height: MAIN_HEADER_TITLE_HEIGHT,
2266
- sx: { transform: "none" }
2267
- }
2268
- ),
2252
+ /* @__PURE__ */ jsxs7(Stack5, { direction: "row", spacing: 1, sx: { alignItems: "center" }, children: [
2253
+ /* @__PURE__ */ jsx13(SidebarMenuButton, {}),
2254
+ /* @__PURE__ */ jsx13(
2255
+ Skeleton,
2256
+ {
2257
+ variant: "rounded",
2258
+ width: titleWidth,
2259
+ height: MAIN_HEADER_TITLE_HEIGHT,
2260
+ sx: { transform: "none" }
2261
+ }
2262
+ )
2263
+ ] }),
2269
2264
  /* @__PURE__ */ jsx13(
2270
2265
  Skeleton,
2271
2266
  {
@@ -2279,6 +2274,25 @@ function MainHeaderSkeleton({
2279
2274
  }
2280
2275
  );
2281
2276
  }
2277
+ function SidebarMenuButton() {
2278
+ const t = useAdminTranslation();
2279
+ const { hasSidebar, sidebarId, isSidebarOpen, toggleSidebar } = useShellContext();
2280
+ if (!hasSidebar) {
2281
+ return null;
2282
+ }
2283
+ return /* @__PURE__ */ jsx13(Box5, { sx: { display: "flex", alignItems: "center", flexShrink: 0 }, children: /* @__PURE__ */ jsx13(
2284
+ IconButton,
2285
+ {
2286
+ "aria-label": t("menu"),
2287
+ "aria-controls": sidebarId,
2288
+ "aria-expanded": isSidebarOpen,
2289
+ onClick: toggleSidebar,
2290
+ size: "small",
2291
+ sx: { ml: -0.5 },
2292
+ children: /* @__PURE__ */ jsx13(MenuIcon, { fontSize: "small" })
2293
+ }
2294
+ ) });
2295
+ }
2282
2296
 
2283
2297
  // src/components/OverviewPage.tsx
2284
2298
  import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
@@ -5434,11 +5448,12 @@ function SidebarCurrentUser({ currentUser, isLoggingOut, onLogout }) {
5434
5448
  sx: {
5435
5449
  flex: 1,
5436
5450
  minWidth: 0,
5437
- overflow: "hidden",
5438
- textOverflow: "ellipsis",
5439
- whiteSpace: "nowrap",
5451
+ overflowWrap: "anywhere",
5452
+ whiteSpace: "normal",
5453
+ wordBreak: "break-word",
5440
5454
  fontSize: 13,
5441
- fontWeight: 650
5455
+ fontWeight: 650,
5456
+ lineHeight: 1.25
5442
5457
  },
5443
5458
  children: currentUser.login
5444
5459
  }
@@ -5491,6 +5506,7 @@ function Shell({
5491
5506
  const location = useAdminLocation(resolvedRouter);
5492
5507
  const pathname = location.pathname;
5493
5508
  const isDesktopSidebar = useMediaQuery4(activeTheme.breakpoints.up("lg"));
5509
+ const [isDesktopSidebarOpen, setIsDesktopSidebarOpen] = useState13(true);
5494
5510
  const [isMobileSidebarOpen, setIsMobileSidebarOpen] = useState13(false);
5495
5511
  const [pendingPath, setPendingPath] = useState13(null);
5496
5512
  const [pendingView, setPendingView] = useState13(null);
@@ -5543,8 +5559,16 @@ function Shell({
5543
5559
  }
5544
5560
  }, [client, isLoggingOut, loginPath, onLogout, resolvedRouter]);
5545
5561
  const shellContextValue = useMemo11(() => ({
5546
- isMobile: !isDesktopSidebar,
5547
- openMobileSidebar: () => setIsMobileSidebarOpen(true),
5562
+ hasSidebar: true,
5563
+ sidebarId: isDesktopSidebar ? "xladmin-desktop-sidebar" : "xladmin-mobile-sidebar",
5564
+ isSidebarOpen: isDesktopSidebar ? isDesktopSidebarOpen : isMobileSidebarOpen,
5565
+ toggleSidebar: () => {
5566
+ if (isDesktopSidebar) {
5567
+ setIsDesktopSidebarOpen((current) => !current);
5568
+ return;
5569
+ }
5570
+ setIsMobileSidebarOpen((current) => !current);
5571
+ },
5548
5572
  pendingPath,
5549
5573
  pendingView,
5550
5574
  startPendingNavigation: (path, view = "generic") => {
@@ -5564,7 +5588,14 @@ function Shell({
5564
5588
  setPendingPath(null);
5565
5589
  setPendingView(null);
5566
5590
  }
5567
- }), [isDesktopSidebar, pathname, pendingPath, pendingView]);
5591
+ }), [
5592
+ isDesktopSidebar,
5593
+ isDesktopSidebarOpen,
5594
+ isMobileSidebarOpen,
5595
+ pathname,
5596
+ pendingPath,
5597
+ pendingView
5598
+ ]);
5568
5599
  return /* @__PURE__ */ jsx28(AdminRouterProvider, { router: resolvedRouter, children: /* @__PURE__ */ jsx28(ThemeProvider, { theme: activeTheme, children: /* @__PURE__ */ jsx28(AdminLocaleProvider, { locale, children: /* @__PURE__ */ jsx28(AdminDataProvider, { value: { locale: locale === "en" ? "en" : "ru", models, blocks }, children: /* @__PURE__ */ jsx28(ShellContextProvider, { value: shellContextValue, children: /* @__PURE__ */ jsxs20(AdminMessageProvider, { children: [
5569
5600
  /* @__PURE__ */ jsx28(CssBaseline, {}),
5570
5601
  /* @__PURE__ */ jsx28(
@@ -5624,9 +5655,10 @@ function Shell({
5624
5655
  spacing: 0,
5625
5656
  sx: { height: "100%", minHeight: 0, alignItems: "stretch" },
5626
5657
  children: [
5627
- /* @__PURE__ */ jsx28(
5658
+ isDesktopSidebarOpen ? /* @__PURE__ */ jsx28(
5628
5659
  Box17,
5629
5660
  {
5661
+ id: "xladmin-desktop-sidebar",
5630
5662
  sx: {
5631
5663
  display: { xs: "none", lg: "block" },
5632
5664
  width: 320,
@@ -5648,7 +5680,7 @@ function Shell({
5648
5680
  }
5649
5681
  )
5650
5682
  }
5651
- ),
5683
+ ) : null,
5652
5684
  /* @__PURE__ */ jsx28(
5653
5685
  Box17,
5654
5686
  {
@@ -5674,6 +5706,7 @@ function Shell({
5674
5706
  /* @__PURE__ */ jsx28(
5675
5707
  Drawer,
5676
5708
  {
5709
+ id: "xladmin-mobile-sidebar",
5677
5710
  anchor: "left",
5678
5711
  open: isMobileSidebarOpen,
5679
5712
  onClose: () => setIsMobileSidebarOpen(false),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xladmin",
3
- "version": "0.6.0",
3
+ "version": "0.9.1",
4
4
  "description": "Framework-agnostic React + MUI admin frontend for xladmin.",
5
5
  "license": "MIT",
6
6
  "type": "module",