gm-datagrid 0.1.27 → 0.1.30
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/README.md +4 -0
- package/dist/features/measureColumnContentWidth.d.ts +15 -0
- package/dist/features/useColumnResize.d.ts +7 -1
- package/dist/features/useGridContentWidth.d.ts +6 -0
- package/dist/features/useGridViewportWidth.d.ts +4 -0
- package/dist/features/useResolvedColumnWidths.d.ts +17 -0
- package/dist/features/useVirtualization.d.ts +3 -1
- package/dist/gm-datagrid.js +6487 -6338
- package/dist/gm-datagrid.umd.cjs +35 -35
- package/dist/lib/i18n.d.ts +2 -0
- package/dist/types/index.d.ts +22 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -98,6 +98,10 @@ export default function ProductsPage() {
|
|
|
98
98
|
| `rowNumberPosition` | `'first' \| 'last'` | `'first'` | Row number column position |
|
|
99
99
|
| `loadingRowCount` | `number` | `8` | Skeleton placeholder rows while loading |
|
|
100
100
|
| `confirmPrompt` | `(message) => Promise<boolean>` | — | Override built-in confirm dialog |
|
|
101
|
+
| `fillAvailableWidth` | `boolean` | `true` | Grow columns to fill the viewport when the column sum is narrower |
|
|
102
|
+
| `disableColumnAutoFit` | `boolean` | `false` | Set `true` to turn off double-click auto-fit on resize handles |
|
|
103
|
+
| `autoFitMaxWidth` | `number` | `480` | Max width (px) for double-click column auto-fit |
|
|
104
|
+
| `stickyHeader` | `boolean` | `true` | Sticky column header and filter row inside the scroll area |
|
|
101
105
|
| `locale` | `'es' \| 'en'` | `'es'` | Built-in UI language. See [Internationalisation](#internationalisation-locale) |
|
|
102
106
|
|
|
103
107
|
### Pagination props
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ColumnDef, Row } from '../types';
|
|
2
|
+
export declare const COLUMN_AUTO_FIT_PADDING = 24;
|
|
3
|
+
export declare const COLUMN_AUTO_FIT_DEFAULT_MAX = 480;
|
|
4
|
+
export interface MeasureColumnContentWidthOptions {
|
|
5
|
+
column: ColumnDef;
|
|
6
|
+
rows: Row[];
|
|
7
|
+
maxWidth?: number;
|
|
8
|
+
headerFont?: string;
|
|
9
|
+
cellFont?: string;
|
|
10
|
+
maxSampleRows?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Estimates column width from header label and a sample of row display strings.
|
|
14
|
+
*/
|
|
15
|
+
export declare function measureColumnContentWidth({ column, rows, maxWidth, headerFont, cellFont, maxSampleRows, }: MeasureColumnContentWidthOptions): number;
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import { ColumnDef } from '../types';
|
|
1
|
+
import { ColumnDef, Row } from '../types';
|
|
2
2
|
interface UseColumnResizeProps {
|
|
3
3
|
columns: ColumnDef[];
|
|
4
4
|
gridTitle: string;
|
|
5
5
|
}
|
|
6
6
|
type WidthMap = Record<string, number>;
|
|
7
|
+
export interface ColumnAutoFitContext {
|
|
8
|
+
column: ColumnDef;
|
|
9
|
+
rows: Row[];
|
|
10
|
+
maxWidth?: number;
|
|
11
|
+
}
|
|
7
12
|
interface ColumnResizeState {
|
|
8
13
|
widths: WidthMap;
|
|
9
14
|
onResizeStart: (field: string, startX: number, startWidth: number) => void;
|
|
15
|
+
autoFitColumn: (field: string, ctx: ColumnAutoFitContext) => void;
|
|
10
16
|
}
|
|
11
17
|
/**
|
|
12
18
|
* Interactive column resize with localStorage persistence.
|
|
@@ -8,4 +8,10 @@ export interface GridContentWidthOptions {
|
|
|
8
8
|
showRowNumber?: boolean;
|
|
9
9
|
}
|
|
10
10
|
export declare function computeGridContentWidth({ columns, widths, checkboxSelection, showRowNumber, }: GridContentWidthOptions): number;
|
|
11
|
+
export interface GridTrackWidthOptions extends GridContentWidthOptions {
|
|
12
|
+
viewportWidth?: number;
|
|
13
|
+
fillAvailableWidth?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** Track width for header/body: at least viewport when filling, otherwise content sum. */
|
|
16
|
+
export declare function computeGridTrackWidth(options: GridTrackWidthOptions): number;
|
|
11
17
|
export declare function useGridContentWidth(options: GridContentWidthOptions): number;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ColumnDef } from '../types';
|
|
2
|
+
export type ColumnWidthMap = Record<string, number>;
|
|
3
|
+
export declare function getBaseColumnWidth(col: ColumnDef, widths: ColumnWidthMap): number;
|
|
4
|
+
export interface ResolveColumnWidthsOptions {
|
|
5
|
+
columns: ColumnDef[];
|
|
6
|
+
widths: ColumnWidthMap;
|
|
7
|
+
viewportWidth: number;
|
|
8
|
+
fillAvailableWidth?: boolean;
|
|
9
|
+
checkboxSelection?: boolean;
|
|
10
|
+
showRowNumber?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Merges user-resized widths with optional growth to fill the grid viewport.
|
|
14
|
+
* Honors `ColumnDef.flex` when distributing extra space.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveColumnWidths({ columns, widths, viewportWidth, fillAvailableWidth, checkboxSelection, showRowNumber, }: ResolveColumnWidthsOptions): ColumnWidthMap;
|
|
17
|
+
export declare function useResolvedColumnWidths(options: ResolveColumnWidthsOptions): ColumnWidthMap;
|
|
@@ -4,6 +4,8 @@ interface UseVirtualizationProps {
|
|
|
4
4
|
containerRef: React.RefObject<HTMLDivElement>;
|
|
5
5
|
density: GridDensity;
|
|
6
6
|
overscan?: number;
|
|
7
|
+
/** Sticky header/filter height inside the same scrollport (px). */
|
|
8
|
+
scrollMarginTop?: number;
|
|
7
9
|
}
|
|
8
10
|
interface VirtualizationState {
|
|
9
11
|
visibleStart: number;
|
|
@@ -15,5 +17,5 @@ interface VirtualizationState {
|
|
|
15
17
|
* Computes which rows are visible in the viewport.
|
|
16
18
|
* Updates on scroll/resize — no perpetual rAF setState loop.
|
|
17
19
|
*/
|
|
18
|
-
export declare function useVirtualization({ rows, containerRef, density, overscan, }: UseVirtualizationProps): VirtualizationState;
|
|
20
|
+
export declare function useVirtualization({ rows, containerRef, density, overscan, scrollMarginTop, }: UseVirtualizationProps): VirtualizationState;
|
|
19
21
|
export {};
|