@starasia/admin 8.2.6 → 8.2.8
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { DataGridProps } from './types';
|
|
3
3
|
|
|
4
|
-
export declare const DataGrid: <T>({ columns, data, getRowKey, size, emptyState }: DataGridProps<T>) => React.JSX.Element;
|
|
4
|
+
export declare const DataGrid: <T>({ columns, data, getRowKey, size, resizable, widthStorageKey, columnState, height, emptyState }: DataGridProps<T>) => React.JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { DataGrid } from './DataGrid';
|
|
2
|
-
export type { DataGridProps, DataGridColumn, DataGridAlign } from './types';
|
|
2
|
+
export type { DataGridProps, DataGridColumn, DataGridAlign, DataGridColumnState } from './types';
|
|
@@ -2,6 +2,11 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
|
|
3
3
|
export type DataGridAlign = 'left' | 'center' | 'right';
|
|
4
4
|
export interface DataGridColumn<T> {
|
|
5
|
+
/**
|
|
6
|
+
* Identitas stabil kolom — dipakai untuk hide/show & reorder.
|
|
7
|
+
* Kalau kosong, fallback ke `accessor` (string), lalu ke index.
|
|
8
|
+
*/
|
|
9
|
+
key?: string;
|
|
5
10
|
/** key pada row untuk ambil nilai otomatis; abaikan kalau pakai `render` */
|
|
6
11
|
accessor?: keyof T | (string & {});
|
|
7
12
|
/** judul kolom di header */
|
|
@@ -10,10 +15,22 @@ export interface DataGridColumn<T> {
|
|
|
10
15
|
render?: (row: T, rowIndex: number, data: T[]) => ReactNode;
|
|
11
16
|
/** perataan header + cell (default 'left') */
|
|
12
17
|
align?: DataGridAlign;
|
|
13
|
-
/** lebar kolom, mis. '200px' | 160 */
|
|
18
|
+
/** lebar awal kolom, mis. '200px' | 160 */
|
|
14
19
|
width?: string | number;
|
|
15
|
-
/** lebar minimum
|
|
20
|
+
/** lebar minimum saat di-resize (px) */
|
|
16
21
|
minWidth?: number;
|
|
22
|
+
/** override resize per kolom; default ikut prop `resizable` di DataGrid */
|
|
23
|
+
resizable?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* State visibility + urutan kolom. Bentuknya kompatibel dengan `ColumnPrefState`
|
|
27
|
+
* yang di-emit `FilterBar.onColumnsChange`, jadi bisa langsung disambungkan.
|
|
28
|
+
*/
|
|
29
|
+
export interface DataGridColumnState {
|
|
30
|
+
/** urutan key kolom (boleh subset / lengkap) */
|
|
31
|
+
order?: string[];
|
|
32
|
+
/** key kolom yang disembunyikan */
|
|
33
|
+
hidden?: string[];
|
|
17
34
|
}
|
|
18
35
|
export interface DataGridProps<T> {
|
|
19
36
|
/** definisi kolom (wajib) */
|
|
@@ -24,6 +41,26 @@ export interface DataGridProps<T> {
|
|
|
24
41
|
getRowKey?: (row: T, index: number) => string | number;
|
|
25
42
|
/** padding scale, diteruskan ke primitif Table (default 'md') */
|
|
26
43
|
size?: 'sm' | 'md' | 'lg' | 'xl';
|
|
44
|
+
/** aktifkan drag-resize lebar kolom (default false) */
|
|
45
|
+
resizable?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Kalau diisi, lebar hasil resize dipersist ke localStorage dengan key ini
|
|
48
|
+
* (lewat `useColumnWidths`) dan dipulihkan saat reload.
|
|
49
|
+
*/
|
|
50
|
+
widthStorageKey?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Visibility & urutan kolom (controlled). Sambungkan dari
|
|
53
|
+
* `FilterBar.onColumnsChange`. Kolom dengan key di `hidden` disembunyikan;
|
|
54
|
+
* sisanya diurutkan mengikuti `order`.
|
|
55
|
+
*/
|
|
56
|
+
columnState?: DataGridColumnState;
|
|
57
|
+
/**
|
|
58
|
+
* Tinggi area tabel. Default: mengisi sampai bawah layar
|
|
59
|
+
* (`calc(100vh - posisiAtas)`, ikut menyesuaikan saat window di-resize).
|
|
60
|
+
* Override bebas oleh consumer, mis. '60vh' | 480 | '100%'.
|
|
61
|
+
* Area selalu scrollable (vertikal & horizontal) dan header sticky.
|
|
62
|
+
*/
|
|
63
|
+
height?: string | number;
|
|
27
64
|
/** ditampilkan saat `data` kosong */
|
|
28
65
|
emptyState?: ReactNode;
|
|
29
66
|
}
|