@starasia/admin 1.3.4 → 1.4.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.
@@ -6,7 +6,7 @@ export interface Option {
6
6
  label: string;
7
7
  value: string;
8
8
  }
9
- export type InputType = "dropdown" | "text" | "date" | "select-button" | "date-range";
9
+ export type InputType = "dropdown" | "text" | "date" | "select-button" | "date-range" | "checkbox";
10
10
  export type ChangeHandler = (params: {
11
11
  value: any;
12
12
  name?: string;
@@ -1,5 +1,16 @@
1
1
  import { default as React, ReactNode } from 'react';
2
+ import { IconName } from '@starasia/icon';
3
+ import { SidebarHeaderSlotChildren } from '../SidebarHeaderSlot';
2
4
 
5
+ /**
6
+ * Item tombol di profile menu body. Multiple item bisa di-pass via
7
+ * `profileMenuButtons` di AppLayout.
8
+ */
9
+ export interface ProfileMenuButton {
10
+ icon: IconName;
11
+ label: string;
12
+ onClick: () => void;
13
+ }
3
14
  interface AppLayoutProps {
4
15
  children?: ReactNode;
5
16
  profile?: {
@@ -12,14 +23,39 @@ interface AppLayoutProps {
12
23
  isLoggingOut?: boolean;
13
24
  loadingComponent?: ReactNode;
14
25
  /**
15
- * Content untuk sidebar header slot (dibawah logo)
16
- * Dapat berupa: Organization Menu, User Switcher, Custom Component, atau kombinasinya
26
+ * Content untuk sidebar header slot (dibawah logo).
27
+ * Boleh ReactNode (auto-hide saat sidebar collapse), atau render function
28
+ * `({ collapsed }) => ReactNode` agar caller bisa render alternatif saat
29
+ * collapse (mis. tampilkan hanya logo).
30
+ */
31
+ sidebarHeaderContent?: SidebarHeaderSlotChildren;
32
+ /**
33
+ * Slot untuk komponen aksi di sisi kanan header (sebelum profile/user info).
34
+ * Caller compose sendiri — mis. `<><NotificationBell /><ModuleSwitcher /></>`.
35
+ */
36
+ headerActions?: ReactNode;
37
+ /**
38
+ * Optional: role/jabatan yang ditampilkan di profile menu heading.
39
+ */
40
+ profileRole?: string;
41
+ /**
42
+ * Optional: array tombol di profile menu body. Caller bisa tambah
43
+ * berapapun item terstruktur (Settings, Bahasa, Tema, dll). Tiap item
44
+ * dirender sebagai `<MenuButton>` dengan style konsisten.
45
+ */
46
+ profileMenuButtons?: ProfileMenuButton[];
47
+ /**
48
+ * Optional: slot kustom tambahan di profile menu body (setelah
49
+ * `profileMenuButtons`). Pakai untuk konten non-button atau item dengan
50
+ * style/struktur custom. Caller compose `<MenuButton>` sendiri.
17
51
  */
18
- sidebarHeaderContent?: ReactNode;
52
+ profileMenuItems?: ReactNode;
19
53
  /**
20
- * Show/hide module switcher control in header (and its modal)
54
+ * Optional: override total item Logout di footer. Kalau di-set, footer
55
+ * default (Logout button + dialog konfirmasi) tidak dirender — caller
56
+ * bertanggung jawab penuh atas footer & handler logout.
21
57
  */
22
- showModuleSwitcher?: boolean;
58
+ logoutButton?: ReactNode;
23
59
  }
24
60
  /**
25
61
  * AppLayout - Main application layout component based on workspace pattern
@@ -27,12 +63,12 @@ interface AppLayoutProps {
27
63
  * - Responsive sidebar with collapse/expand (mobile: full-width + overlay)
28
64
  * - Accordion menu items with auto-expansion
29
65
  * - Sidebar scroll position persistence
30
- * - Module switcher modal with localStorage
31
- * - Settings shortcuts dropdown
66
+ * - Filter sidebar by selected module (via shared useModuleSelection)
32
67
  * - User profile & logout dialog
33
68
  * - Mobile hamburger menu
34
69
  * - Loading overlay support
35
70
  * - Embed mode for iframes
71
+ * - Header actions slot for caller-composed controls (e.g. ModuleSwitcher)
36
72
  */
37
- export declare function AppLayout({ children, headerRight, profile, isLoadingProfile, onLogout, isLoggingOut, loadingComponent, sidebarHeaderContent, showModuleSwitcher, }: AppLayoutProps): React.JSX.Element;
73
+ export declare function AppLayout({ children, headerRight, profile, isLoadingProfile, onLogout, isLoggingOut, loadingComponent, sidebarHeaderContent, headerActions, profileRole, profileMenuButtons, profileMenuItems, logoutButton, }: AppLayoutProps): React.JSX.Element;
38
74
  export {};
@@ -0,0 +1,18 @@
1
+ import { default as React } from 'react';
2
+
3
+ export interface ModuleSwitcherProps {
4
+ /**
5
+ * Optional callback fired after the selection changes. Useful for
6
+ * analytics or side-effects beyond default navigation.
7
+ */
8
+ onSelect?: (id: number | null) => void;
9
+ "aria-label"?: string;
10
+ }
11
+ /**
12
+ * ModuleSwitcher - Header action that opens the ModuleSwitcherModal.
13
+ *
14
+ * Self-contained: reads `app.menus` via `useApp()`, persists the active
15
+ * group id via `useModuleSelection()` (localStorage + cross-component sync).
16
+ * Selecting a group navigates to its first menu item.
17
+ */
18
+ export declare function ModuleSwitcher({ onSelect, "aria-label": ariaLabel, }?: ModuleSwitcherProps): React.JSX.Element;
@@ -1,31 +1,35 @@
1
1
  import { default as React, ReactNode } from 'react';
2
2
 
3
+ export interface SidebarHeaderSlotRenderProps {
4
+ collapsed: boolean;
5
+ }
6
+ export type SidebarHeaderSlotChildren = ReactNode | ((state: SidebarHeaderSlotRenderProps) => ReactNode);
3
7
  export interface SidebarHeaderSlotProps {
4
8
  /**
5
9
  * Collapsed state from sidebar
6
10
  */
7
11
  collapsed?: boolean;
8
12
  /**
9
- * Content to display below logo - dapat berupa:
10
- * - Organization menu
11
- * - User switcher
12
- * - Custom component
13
- * - Atau kombinasi dari beberapa komponen
13
+ * Content to display below logo. Boleh berupa:
14
+ * - ReactNode biasa — slot akan auto-hide (visibility: hidden) saat collapsed.
15
+ * - Render function `(state) => ReactNode` — caller punya kontrol penuh
16
+ * atas tampilan tiap state (mis. tampilkan hanya logo saat collapsed).
14
17
  */
15
- children?: ReactNode;
18
+ children?: SidebarHeaderSlotChildren;
16
19
  }
17
20
  /**
18
21
  * SidebarHeaderSlot - Flexible slot area dibawah logo sidebar
19
- * Digunakan untuk menempatkan komponen apapun yang relevan dengan sidebar header
20
22
  *
21
- * Contoh penggunaan:
22
- * <SidebarHeaderSlot collapsed={sidebarCollapsed}>
23
- * <OrganizationMenu />
24
- * </SidebarHeaderSlot>
23
+ * Render-prop usage (recommended saat butuh tampilan beda saat collapse):
24
+ *
25
+ * <SidebarHeaderSlot collapsed={collapsed}>
26
+ * {({ collapsed }) => (collapsed ? <LogoOnly /> : <FullHeader />)}
27
+ * </SidebarHeaderSlot>
28
+ *
29
+ * ReactNode usage (auto-hide saat collapsed, ruang tetap dipertahankan):
25
30
  *
26
- * atau:
27
- * <SidebarHeaderSlot collapsed={sidebarCollapsed}>
28
- * <UserSwitcher />
29
- * </SidebarHeaderSlot>
31
+ * <SidebarHeaderSlot collapsed={collapsed}>
32
+ * <OrganizationMenu />
33
+ * </SidebarHeaderSlot>
30
34
  */
31
35
  export declare function SidebarHeaderSlot({ collapsed, children, }: SidebarHeaderSlotProps): React.JSX.Element | null;
@@ -1,6 +1,7 @@
1
1
  export * from './AppLayout';
2
2
  export * from './SidebarHeaderSlot';
3
3
  export * from './ModuleSwitcherModal';
4
+ export * from './ModuleSwitcher';
4
5
  export * from './AuthLayout';
5
6
  export * from './HorizontalField';
6
7
  export * from './ModalDialog';
@@ -3,3 +3,4 @@ export * from './useDynamicTitle';
3
3
  export * from './useRouteParams';
4
4
  export * from './useRouteInfo';
5
5
  export * from './useAuthRole';
6
+ export * from './useModuleSelection';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Shared state for the active module/group selected via ModuleSwitcher.
3
+ * Backed by localStorage; synced across components in the same tab via
4
+ * a custom event, and across tabs via the native `storage` event.
5
+ */
6
+ export declare function useModuleSelection(): {
7
+ selectedGroupId: number | null;
8
+ setSelectedGroupId: (id: number | null) => void;
9
+ };