@starasia/admin 8.26.0 → 8.27.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.
@@ -20,3 +20,4 @@ export declare const App: React.MemoExoticComponent<({ router, menus, menuBottom
20
20
  export * from './hooks';
21
21
  export * from './context';
22
22
  export * from './sidebarBadges';
23
+ export * from './sidebar';
@@ -0,0 +1,47 @@
1
+ import { default as React, PropsWithChildren } from 'react';
2
+
3
+ export interface SidebarContextValue {
4
+ /** Desktop sidebar collapsed (narrow rail) state. */
5
+ collapsed: boolean;
6
+ /** Set the desktop collapsed state directly (boolean or updater fn). */
7
+ setCollapsed: (value: boolean | ((prev: boolean) => boolean)) => void;
8
+ /** Toggle the desktop collapsed state. */
9
+ toggle: () => void;
10
+ /** Force-collapse the desktop sidebar to its narrow rail. */
11
+ collapse: () => void;
12
+ /** Force-expand the desktop sidebar to full width. */
13
+ expand: () => void;
14
+ /** Mobile drawer open state (sidebar slides over the content). */
15
+ mobileOpen: boolean;
16
+ /** Set the mobile drawer open state directly (boolean or updater fn). */
17
+ setMobileOpen: (value: boolean | ((prev: boolean) => boolean)) => void;
18
+ /** Open the mobile drawer. */
19
+ openMobile: () => void;
20
+ /** Close the mobile drawer. */
21
+ closeMobile: () => void;
22
+ /** Toggle the mobile drawer. */
23
+ toggleMobile: () => void;
24
+ }
25
+ export interface SidebarProviderProps extends PropsWithChildren {
26
+ /** Initial desktop collapsed state. @default false */
27
+ defaultCollapsed?: boolean;
28
+ }
29
+ /**
30
+ * Holds the AppLayout sidebar's collapse/expand (desktop) and drawer (mobile)
31
+ * state, so any component in the tree can read or control it via `useSidebar()`
32
+ * instead of prop-drilling. Mounted automatically by `<App>`, alongside
33
+ * `SidebarBadgesProvider` — consumers don't need to render it themselves.
34
+ */
35
+ export declare const SidebarProvider: ({ children, defaultCollapsed, }: SidebarProviderProps) => React.JSX.Element;
36
+ /**
37
+ * Read & control the AppLayout sidebar.
38
+ *
39
+ * ```tsx
40
+ * const { collapsed, toggle, expand, collapse, mobileOpen, openMobile } = useSidebar();
41
+ * <Button onClick={toggle}>{collapsed ? "Expand" : "Collapse"}</Button>
42
+ * ```
43
+ *
44
+ * Must be used inside `<App>` (which mounts `SidebarProvider`). Outside it the
45
+ * hook returns a no-op default (`collapsed: false`).
46
+ */
47
+ export declare const useSidebar: () => SidebarContextValue;