@starasia/admin 8.1.3 → 8.2.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/components/pills/DatePill.d.ts +3 -11
- package/dist/components/FilterBar/hooks/useLastFilterState.d.ts +27 -0
- package/dist/components/FilterBar/index.d.ts +1 -1
- package/dist/components/FilterBar/types.d.ts +28 -4
- package/dist/components/FilterBar/utils/storage-adapter.d.ts +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +2613 -2253
- package/dist/index.umd.js +1 -1
- package/package.json +2 -2
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { DateCompactFilterField, DateCompactValue, DateFilterField } from '../../types';
|
|
3
3
|
|
|
4
4
|
interface DatePillProps {
|
|
5
|
-
field: DateFilterField |
|
|
6
|
-
value: Date |
|
|
7
|
-
from: Date;
|
|
8
|
-
to: Date;
|
|
9
|
-
} | undefined;
|
|
5
|
+
field: DateFilterField | DateCompactFilterField;
|
|
6
|
+
value: Date | DateCompactValue | undefined;
|
|
10
7
|
onChange: (v: unknown) => void;
|
|
11
8
|
onClear: () => void;
|
|
12
9
|
/** Removes the whole pill (the popover's "Remove Filter" action). */
|
|
13
10
|
onRemove: () => void;
|
|
14
11
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Date / date-range pill. Outer `Menu` for positioning + Remove Filter; the
|
|
17
|
-
* popover hosts a `StarasiaDate` calendar (no `input` mode — the Menu trigger
|
|
18
|
-
* is our pill button).
|
|
19
|
-
*/
|
|
20
12
|
export declare const DatePill: React.FC<DatePillProps>;
|
|
21
13
|
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { FilterStorageAdapter } from '../types';
|
|
2
|
+
|
|
3
|
+
interface UseLastFilterStateOptions {
|
|
4
|
+
scopeId?: string;
|
|
5
|
+
storage: FilterStorageAdapter;
|
|
6
|
+
/** URL params to snapshot (e.g. [activeFilterKey, filterKey, perPageKey]). */
|
|
7
|
+
snapshotKeys: string[];
|
|
8
|
+
/** Opt-out toggle (default true when scopeId is provided). */
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Persists the latest filter URL params per scope, so link-based back
|
|
13
|
+
* navigation (which drops the query string) still restores the previous
|
|
14
|
+
* filters on remount. URL always wins — restoration only kicks in when the
|
|
15
|
+
* URL has none of the snapshot keys.
|
|
16
|
+
*
|
|
17
|
+
* - **Autosave**: writes to `localStorage[filterbar:last:{scopeId}]` on every
|
|
18
|
+
* `searchParams` change.
|
|
19
|
+
* - **Autorestore**: on mount, hydrates the URL from storage if empty.
|
|
20
|
+
* - **`clear()`**: removes the snapshot; call this from Reset so the user's
|
|
21
|
+
* explicit reset isn't undone on the next navigation back.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useLastFilterState({ scopeId, storage, snapshotKeys, enabled }: UseLastFilterStateOptions): {
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
clear: () => void;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { FilterBar } from './FilterBar';
|
|
2
2
|
export { localStorageAdapter, storageKeys } from './utils/storage-adapter';
|
|
3
|
-
export type { FilterBarProps, FilterFieldConfig, FilterFieldType, SelectFilterField, CheckboxMultipleFilterField, DateFilterField,
|
|
3
|
+
export type { FilterBarProps, FilterFieldConfig, FilterFieldType, SelectFilterField, CheckboxMultipleFilterField, DateFilterField, DateCompactFilterField, DateCompactOp, DateCompactValue, RelativeDirection, RelativePeriod, ColumnConfig, ColumnPrefState, SavedView, FilterStorageAdapter } from './types';
|
|
@@ -8,7 +8,7 @@ import { Pagination } from '../TableSection/types';
|
|
|
8
8
|
* (`handleChangeFilter`, `getValuesFilter`, …) so the JSON-blob URL encoding
|
|
9
9
|
* (`?filter={...}`) is reused as-is. `key` is the param name inside that blob.
|
|
10
10
|
*/
|
|
11
|
-
export type FilterFieldType = 'date' | 'date-
|
|
11
|
+
export type FilterFieldType = 'date' | 'date-compact' | 'dropdown' | 'dropdown-multiple' | 'checkbox-multiple' | 'radio';
|
|
12
12
|
interface BaseFilterField {
|
|
13
13
|
/** Stable key — used as the field name inside the `?filter` blob. */
|
|
14
14
|
key: string;
|
|
@@ -49,10 +49,28 @@ export interface DateFilterField extends BaseFilterField {
|
|
|
49
49
|
type: 'date';
|
|
50
50
|
mode?: 'days' | 'months' | 'years';
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
/** Compact date filter — operator + payload (date / range / relative / empty). */
|
|
53
|
+
export type DateCompactOp = 'is' | 'is-before' | 'is-after' | 'is-on-or-before' | 'is-on-or-after' | 'is-between' | 'is-relative-to-today' | 'is-empty' | 'is-not-empty';
|
|
54
|
+
export type RelativeDirection = 'past' | 'next' | 'this';
|
|
55
|
+
export type RelativePeriod = 'day' | 'week' | 'month' | 'year';
|
|
56
|
+
export interface DateCompactValue {
|
|
57
|
+
op: DateCompactOp;
|
|
58
|
+
/** ISO date — set for is / before / after / on-or-before / on-or-after. */
|
|
59
|
+
date?: string;
|
|
60
|
+
/** ISO date — set together with `to` when `op === 'is-between'`. */
|
|
61
|
+
from?: string;
|
|
62
|
+
to?: string;
|
|
63
|
+
/** Set when `op === 'is-relative-to-today'`. `count` is required for past/next. */
|
|
64
|
+
relative?: {
|
|
65
|
+
direction: RelativeDirection;
|
|
66
|
+
count?: number;
|
|
67
|
+
period: RelativePeriod;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export interface DateCompactFilterField extends BaseFilterField {
|
|
71
|
+
type: 'date-compact';
|
|
54
72
|
}
|
|
55
|
-
export type FilterFieldConfig = SelectFilterField | CheckboxMultipleFilterField | DateFilterField |
|
|
73
|
+
export type FilterFieldConfig = SelectFilterField | CheckboxMultipleFilterField | DateFilterField | DateCompactFilterField;
|
|
56
74
|
/** A single column entry fed to the Customize Column panel. */
|
|
57
75
|
export interface ColumnConfig {
|
|
58
76
|
key: string;
|
|
@@ -127,6 +145,12 @@ export interface FilterBarProps {
|
|
|
127
145
|
enabled?: boolean;
|
|
128
146
|
scopeId: string;
|
|
129
147
|
};
|
|
148
|
+
/**
|
|
149
|
+
* Auto-restore the last applied filter state when the URL has no filter
|
|
150
|
+
* params (e.g. link-based back navigation). Requires `savedViews.scopeId`.
|
|
151
|
+
* Default `true`.
|
|
152
|
+
*/
|
|
153
|
+
persistLastState?: boolean;
|
|
130
154
|
/** Persistence adapter (default: localStorage via @starasia/storage). */
|
|
131
155
|
storage?: FilterStorageAdapter;
|
|
132
156
|
/** Called after a full reset (clears filters + search). */
|