gm-datagrid 0.1.26 → 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 +10 -0
- package/dist/components/GMGridLoadingSkeleton.d.ts +13 -0
- package/dist/components/GridConfirmDialog.d.ts +10 -0
- package/dist/context/ConfirmContext.d.ts +7 -0
- package/dist/features/measureColumnContentWidth.d.ts +15 -0
- package/dist/features/useColumnResize.d.ts +7 -1
- package/dist/features/useGridContentWidth.d.ts +17 -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 +9060 -8497
- package/dist/gm-datagrid.umd.cjs +49 -49
- package/dist/lib/i18n.d.ts +8 -0
- package/dist/types/index.d.ts +36 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -92,6 +92,16 @@ export default function ProductsPage() {
|
|
|
92
92
|
| `slotProps` | `GridToolbarSlotProps` | — | Props merged into each slot component |
|
|
93
93
|
| `statusSwitch` | `StatusSwitchConfig` | — | Grid defaults for inline STATUS toggles (see `docs/STATUS_SWITCH.md`) |
|
|
94
94
|
| `autoCheckboxSelection` | `boolean` | `true` | Enable checkboxes when `slot.bulkAction` is set |
|
|
95
|
+
| `minHeight` | `number \| string` | `360` | Minimum height of the grid root |
|
|
96
|
+
| `bodyMinHeight` | `number \| string` | — | Minimum height of the scrollable body |
|
|
97
|
+
| `showRowNumber` | `boolean` | `true` | Leading/trailing row index column (`Nº`) |
|
|
98
|
+
| `rowNumberPosition` | `'first' \| 'last'` | `'first'` | Row number column position |
|
|
99
|
+
| `loadingRowCount` | `number` | `8` | Skeleton placeholder rows while loading |
|
|
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 |
|
|
95
105
|
| `locale` | `'es' \| 'en'` | `'es'` | Built-in UI language. See [Internationalisation](#internationalisation-locale) |
|
|
96
106
|
|
|
97
107
|
### Pagination props
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ColumnDef } from '../types';
|
|
3
|
+
interface GMGridLoadingSkeletonProps {
|
|
4
|
+
columns: ColumnDef[];
|
|
5
|
+
widths: Record<string, number>;
|
|
6
|
+
rowCount?: number;
|
|
7
|
+
rowHeight: number;
|
|
8
|
+
contentMinWidth: number;
|
|
9
|
+
checkboxSelection?: boolean;
|
|
10
|
+
showRowNumber?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const GMGridLoadingSkeleton: React.NamedExoticComponent<GMGridLoadingSkeletonProps>;
|
|
13
|
+
export default GMGridLoadingSkeleton;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GridLocale } from '../lib/i18n';
|
|
2
|
+
interface GridConfirmDialogProps {
|
|
3
|
+
open: boolean;
|
|
4
|
+
message: string;
|
|
5
|
+
locale?: GridLocale;
|
|
6
|
+
title?: string;
|
|
7
|
+
onClose: (accepted: boolean) => void;
|
|
8
|
+
}
|
|
9
|
+
export default function GridConfirmDialog({ open, message, locale, title, onClose, }: GridConfirmDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export declare function ConfirmProvider({ children, locale, confirmPrompt, }: {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
locale?: 'es' | 'en';
|
|
5
|
+
confirmPrompt?: (message: string) => Promise<boolean>;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function useGridConfirm(): (message: string) => Promise<boolean>;
|
|
@@ -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.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ColumnDef } from '../types';
|
|
2
|
+
export declare const GM_GRID_CB_WIDTH = 40;
|
|
3
|
+
export declare const GM_GRID_ROW_NUMBER_WIDTH = 52;
|
|
4
|
+
export interface GridContentWidthOptions {
|
|
5
|
+
columns: ColumnDef[];
|
|
6
|
+
widths: Record<string, number>;
|
|
7
|
+
checkboxSelection?: boolean;
|
|
8
|
+
showRowNumber?: boolean;
|
|
9
|
+
}
|
|
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;
|
|
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 {};
|