@starasia/admin 8.26.0 → 8.28.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/components/FilterBar/hooks/useLastFilterState.d.ts +11 -1
- package/dist/components/FilterBar/types.d.ts +7 -0
- package/dist/entries/App/index.d.ts +1 -0
- package/dist/entries/App/sidebar.d.ts +47 -0
- package/dist/index.cjs.js +18 -18
- package/dist/index.es.js +1890 -1789
- package/dist/index.umd.js +16 -16
- package/package.json +1 -1
|
@@ -7,6 +7,16 @@ interface UseLastFilterStateOptions {
|
|
|
7
7
|
snapshotKeys: string[];
|
|
8
8
|
/** Opt-out toggle (default true when scopeId is provided). */
|
|
9
9
|
enabled?: boolean;
|
|
10
|
+
/** URL param holding the JSON-blob of filter values (default `'filter'`). */
|
|
11
|
+
filterKey?: string;
|
|
12
|
+
/** Field name for search inside the `filterKey` blob (default `'q'`). */
|
|
13
|
+
searchKey?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the search term is kept in the snapshot. Default `true`. When
|
|
16
|
+
* `false`, `searchKey` is stripped from the `filterKey` blob on both write
|
|
17
|
+
* and read, so filters + page still persist/restore but search does not.
|
|
18
|
+
*/
|
|
19
|
+
persistSearch?: boolean;
|
|
10
20
|
}
|
|
11
21
|
/**
|
|
12
22
|
* Persists the latest filter URL params per scope, so link-based back
|
|
@@ -25,7 +35,7 @@ interface UseLastFilterStateOptions {
|
|
|
25
35
|
* supaya state "sudah di-clear" tidak ter-restore lagi saat balik ke halaman.
|
|
26
36
|
* - **`clear()`**: removes the snapshot (dipanggil dari Reset).
|
|
27
37
|
*/
|
|
28
|
-
export declare function useLastFilterState({ scopeId, storage, snapshotKeys, enabled }: UseLastFilterStateOptions): {
|
|
38
|
+
export declare function useLastFilterState({ scopeId, storage, snapshotKeys, enabled, filterKey, searchKey, persistSearch }: UseLastFilterStateOptions): {
|
|
29
39
|
enabled: boolean;
|
|
30
40
|
read: () => Record<string, string> | null;
|
|
31
41
|
clear: () => void;
|
|
@@ -201,6 +201,13 @@ export interface FilterBarProps {
|
|
|
201
201
|
* params (e.g. link-based back navigation). Requires `scopeId`. Default `true`.
|
|
202
202
|
*/
|
|
203
203
|
persistLastState?: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* Whether the search term is included in the auto last-state snapshot.
|
|
206
|
+
* Default `true`. Set `false` to keep filters + page persisted/restored on
|
|
207
|
+
* back-navigation while the search box always starts empty. Only affects the
|
|
208
|
+
* automatic snapshot — Saved Views still capture search.
|
|
209
|
+
*/
|
|
210
|
+
persistSearch?: boolean;
|
|
204
211
|
/** Persistence adapter (default: localStorage via @starasia/storage). */
|
|
205
212
|
storage?: FilterStorageAdapter;
|
|
206
213
|
/** Called after a full reset (clears filters + search). */
|
|
@@ -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;
|