@ishibashi0112/spreadsheet-grid 0.5.0 → 0.7.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.
@@ -0,0 +1,11 @@
1
+ import type { GridColumn } from '../model/gridTypes';
2
+ export type SerializeRowsToCsvParams<T> = {
3
+ getRow: (viewIndex: number) => T;
4
+ startRow: number;
5
+ endRow: number;
6
+ columns: GridColumn<T>[];
7
+ delimiter?: string;
8
+ includeHeaders?: boolean;
9
+ bom?: boolean;
10
+ };
11
+ export declare const serializeRowsToCsv: <T>({ getRow, startRow, endRow, columns, delimiter, includeHeaders, bom, }: SerializeRowsToCsvParams<T>) => string;
@@ -0,0 +1,8 @@
1
+ import type { GridColumn, GridExportData } from '../model/gridTypes';
2
+ export type BuildGridExportDataParams<T> = {
3
+ getRow: (viewIndex: number) => T;
4
+ startRow: number;
5
+ endRow: number;
6
+ columns: GridColumn<T>[];
7
+ };
8
+ export declare const buildGridExportData: <T>({ getRow, startRow, endRow, columns, }: BuildGridExportDataParams<T>) => GridExportData;
@@ -0,0 +1,13 @@
1
+ import type { ColumnFilterValue, GridColumn, GridColumnState, GridFilterState, GridSortState, GridState } from '../model/gridTypes';
2
+ export declare const GRID_STATE_VERSION = 2;
3
+ export declare const cloneColumnFilterValue: (value: ColumnFilterValue) => ColumnFilterValue;
4
+ export declare const extractColumnState: <T>(columns: GridColumn<T>[]) => GridColumnState[];
5
+ export declare const buildGridState: (columnWidths: Record<string, number>, filters: GridFilterState, sort: GridSortState, columns?: GridColumnState[], version?: number) => GridState;
6
+ export declare const migrateGridState: (input: unknown) => GridState;
7
+ export declare const applyColumnState: <T>(currentColumns: GridColumn<T>[], savedColumnState: GridColumnState[], savedWidths: Record<string, number>) => GridColumn<T>[];
8
+ export declare const isSameGridState: (a: GridState, b: GridState) => boolean;
9
+ export type StateChangeDecision = {
10
+ emit: boolean;
11
+ nextLast: GridState | null;
12
+ };
13
+ export declare const decideStateChangeEmit: (prevLast: GridState | null, current: GridState, isDragging: boolean) => StateChangeDecision;
@@ -0,0 +1,22 @@
1
+ import type { ScrollAlign } from '../model/gridTypes';
2
+ export type VerticalScrollTargetParams = {
3
+ rowTop: number;
4
+ rowHeight: number;
5
+ headerHeight: number;
6
+ viewportHeight: number;
7
+ currentScrollTop: number;
8
+ align: ScrollAlign;
9
+ maxScrollTop?: number;
10
+ };
11
+ export declare const computeVerticalScrollTarget: ({ rowTop, rowHeight, headerHeight, viewportHeight, currentScrollTop, align, maxScrollTop, }: VerticalScrollTargetParams) => number;
12
+ export type HorizontalScrollTargetParams = {
13
+ cellLeft: number;
14
+ cellWidth: number;
15
+ leftPaneWidth: number;
16
+ rightPaneWidth: number;
17
+ viewportWidth: number;
18
+ currentScrollLeft: number;
19
+ align: ScrollAlign;
20
+ maxScrollLeft?: number;
21
+ };
22
+ export declare const computeHorizontalScrollTarget: ({ cellLeft, cellWidth, leftPaneWidth, rightPaneWidth, viewportWidth, currentScrollLeft, align, maxScrollLeft, }: HorizontalScrollTargetParams) => number;
@@ -1,4 +1,4 @@
1
- import type { CellCoord, ColumnFilterValue, GridSortEntry } from './gridTypes';
1
+ import type { CellCoord, ColumnFilterValue, GridFilterState, GridSortEntry } from './gridTypes';
2
2
  export type GridUiAction = {
3
3
  type: 'cell/activate';
4
4
  cell: CellCoord | null;
@@ -59,6 +59,9 @@ export type GridUiAction = {
59
59
  columnKey: string;
60
60
  } | {
61
61
  type: 'filter/resetAll';
62
+ } | {
63
+ type: 'filter/setAll';
64
+ filters: GridFilterState;
62
65
  } | {
63
66
  type: 'sort/set';
64
67
  entries: GridSortEntry[];
@@ -86,6 +89,7 @@ export declare const gridActions: {
86
89
  setColumnFilter: (columnKey: string, value: ColumnFilterValue) => GridUiAction;
87
90
  clearColumnFilter: (columnKey: string) => GridUiAction;
88
91
  resetAllFilters: () => GridUiAction;
92
+ setAllFilters: (filters: GridFilterState) => GridUiAction;
89
93
  setSort: (entries: GridSortEntry[]) => GridUiAction;
90
94
  clearSort: () => GridUiAction;
91
95
  };
@@ -1,4 +1,4 @@
1
- import type { ReactNode } from 'react';
1
+ import type { ReactNode, Ref } from 'react';
2
2
  export type GridRowKey = string | number;
3
3
  export type RowModel<T> = {
4
4
  getRowCount: () => number;
@@ -245,7 +245,75 @@ export type GridClassNames = {
245
245
  rowHeaderCell?: string;
246
246
  iconButton?: string;
247
247
  };
248
+ export type ScrollAlign = 'auto' | 'start' | 'center' | 'end';
249
+ export type CsvExportScope = 'all' | 'selection' | 'visible';
250
+ export type CsvExportOptions = {
251
+ scope?: CsvExportScope;
252
+ includeHeaders?: boolean;
253
+ delimiter?: string;
254
+ bom?: boolean;
255
+ };
256
+ export type GridExportOptions = {
257
+ scope?: CsvExportScope;
258
+ };
259
+ export type GridExportCell = {
260
+ value: unknown;
261
+ text: string;
262
+ };
263
+ export type GridExportData = {
264
+ columns: {
265
+ key: string;
266
+ title: string;
267
+ }[];
268
+ rows: GridExportCell[][];
269
+ };
270
+ export type GridColumnState = {
271
+ key: string;
272
+ visible?: boolean;
273
+ pinned?: GridColumnPinned;
274
+ };
275
+ export type GridState = {
276
+ version: number;
277
+ columnWidths: Record<string, number>;
278
+ filters: GridFilterState;
279
+ sort: GridSortState;
280
+ columns?: GridColumnState[];
281
+ };
282
+ export type SpreadsheetGridHandle<T> = {
283
+ scrollToRow: (viewRowIndex: number, options?: {
284
+ align?: ScrollAlign;
285
+ }) => void;
286
+ scrollToCell: (viewRowIndex: number, colIndex: number, options?: {
287
+ align?: ScrollAlign;
288
+ }) => void;
289
+ scrollToTop: () => void;
290
+ scrollToBottom: () => void;
291
+ getVisibleRowRange: () => {
292
+ startIndex: number;
293
+ endIndex: number;
294
+ } | null;
295
+ getActiveCell: () => CellCoord | null;
296
+ setActiveCell: (cell: CellCoord | null, options?: {
297
+ scrollIntoView?: boolean;
298
+ }) => void;
299
+ getSelection: () => GridSelection;
300
+ selectCell: (viewRowIndex: number, colIndex: number, options?: {
301
+ scrollIntoView?: boolean;
302
+ }) => void;
303
+ selectRange: (range: CellRange, options?: {
304
+ scrollIntoView?: boolean;
305
+ }) => void;
306
+ clearSelection: () => void;
307
+ getSelectedRows: () => T[];
308
+ exportCsv: (options?: CsvExportOptions) => string;
309
+ downloadCsv: (filename?: string, options?: CsvExportOptions) => void;
310
+ getExportData: (options?: GridExportOptions) => GridExportData;
311
+ getState: () => GridState;
312
+ applyState: (state: GridState) => void;
313
+ };
248
314
  export type SpreadsheetGridProps<T> = {
315
+ ref?: Ref<SpreadsheetGridHandle<T>>;
316
+ onStateChange?: (state: GridState) => void;
249
317
  rows?: T[];
250
318
  dataSource?: ServerSideDataSource<T>;
251
319
  serverSideRefreshToken?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ishibashi0112/spreadsheet-grid",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "React 19 製のカスタム仮想化データグリッド。100 万行対応の仮想化・3 ペイン固定列・ソート/フィルター・クライアント/サーバーサイド行モデル対応。",
5
5
  "keywords": [
6
6
  "react",