@ishibashi0112/spreadsheet-grid 0.34.0 → 0.35.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,796 @@
1
+ export type GridFrameworkTypes = {
2
+ node: unknown;
3
+ style: object;
4
+ };
5
+ export type GridRowKey = string | number;
6
+ export type RowModel<T> = {
7
+ getRowCount: () => number;
8
+ getRow: (viewIndex: number) => T;
9
+ getSourceIndex: (viewIndex: number) => number;
10
+ getRowKey: (viewIndex: number) => GridRowKey;
11
+ getGroupRow?: (viewIndex: number) => GridGroupRow | undefined;
12
+ };
13
+ export type ServerSideQuery = {
14
+ globalText?: string;
15
+ columnFilters?: Record<string, ColumnFilterValue>;
16
+ sort?: GridSortState;
17
+ };
18
+ export type ServerSideGetRowsParams = {
19
+ startIndex: number;
20
+ endIndex: number;
21
+ query: ServerSideQuery;
22
+ signal: AbortSignal;
23
+ };
24
+ export type ServerSideGetRowsResult<T> = {
25
+ rows: T[];
26
+ totalRowCount: number;
27
+ };
28
+ export type ServerSideDataSource<T> = {
29
+ getRows: (params: ServerSideGetRowsParams) => Promise<ServerSideGetRowsResult<T>>;
30
+ updateRows?: (params: ServerSideUpdateRowsParams<T>) => Promise<ServerSideUpdateRowsResult<T> | void>;
31
+ initialRowCount?: number;
32
+ blockSize?: number;
33
+ maxCachedBlocks?: number;
34
+ };
35
+ export type ServerSideCellChange = {
36
+ columnKey: string;
37
+ previousValue: unknown;
38
+ newValue: unknown;
39
+ };
40
+ export type ServerSideRowUpdate<T> = {
41
+ rowKey: GridRowKey;
42
+ rowIndex: number;
43
+ row: T;
44
+ previousRow: T;
45
+ changes: ServerSideCellChange[];
46
+ };
47
+ export type ServerSideUpdateRowsParams<T> = {
48
+ updates: ServerSideRowUpdate<T>[];
49
+ };
50
+ export type ServerSideUpdateRowsResult<T> = {
51
+ rows?: T[];
52
+ };
53
+ export type ServerSideLoadErrorParams = {
54
+ startIndex: number;
55
+ endIndex: number;
56
+ };
57
+ export type ServerSideWriteErrorParams<T> = {
58
+ updates: ServerSideRowUpdate<T>[];
59
+ };
60
+ export type CellCoord = {
61
+ row: number;
62
+ col: number;
63
+ };
64
+ export type CellRange = {
65
+ start: CellCoord;
66
+ end: CellCoord;
67
+ };
68
+ export type UndoRedoState = {
69
+ canUndo: boolean;
70
+ canRedo: boolean;
71
+ };
72
+ export type GridSelection = {
73
+ type: 'cell';
74
+ range: CellRange;
75
+ } | {
76
+ type: 'row';
77
+ startRow: number;
78
+ endRow: number;
79
+ } | {
80
+ type: 'col';
81
+ startCol: number;
82
+ endCol: number;
83
+ } | null;
84
+ export type RowSelectionState = {
85
+ mode: 'include' | 'exclude';
86
+ keys: ReadonlySet<GridRowKey>;
87
+ };
88
+ export type RowSelectionModel = {
89
+ type: 'include';
90
+ rowKeys: GridRowKey[];
91
+ } | {
92
+ type: 'exclude';
93
+ rowKeys: GridRowKey[];
94
+ };
95
+ export type RowSelectionMode = 'single' | 'multiple';
96
+ export type SelectAllState = 'none' | 'some' | 'all';
97
+ export type GridFilterState = {
98
+ globalText: string;
99
+ columnFilters: Record<string, ColumnFilterValue>;
100
+ };
101
+ export type GridSortDirection = 'asc' | 'desc' | null;
102
+ export type GridSortEntry = {
103
+ columnKey: string;
104
+ direction: 'asc' | 'desc';
105
+ };
106
+ export type GridSortState = GridSortEntry[];
107
+ export type GridSelectFilterOption = {
108
+ label: string;
109
+ value: string;
110
+ };
111
+ export type ColumnFilterUiType = 'text' | 'textSet' | 'number' | 'numberSet' | 'date' | 'dateSet' | 'select' | 'set' | 'custom';
112
+ export type ColumnFilterTypeOption = ColumnFilterUiType | 'auto';
113
+ export type SetColumnFilterValue = {
114
+ kind: 'set';
115
+ mode?: 'include' | 'exclude';
116
+ values: string[];
117
+ };
118
+ export type ParsedNumberFilter = {
119
+ mode: 'comparison';
120
+ operator: '>' | '>=' | '<' | '<=' | '=' | '!=';
121
+ value: number;
122
+ } | {
123
+ mode: 'range';
124
+ min: number;
125
+ max: number;
126
+ } | {
127
+ mode: 'blank';
128
+ } | {
129
+ mode: 'notBlank';
130
+ };
131
+ export type NumberColumnFilterValue = {
132
+ kind: 'number';
133
+ raw: string;
134
+ parsed: ParsedNumberFilter | null;
135
+ };
136
+ export type TextColumnFilterValue = {
137
+ kind: 'text';
138
+ value: string;
139
+ };
140
+ export type DateColumnFilterValue = {
141
+ kind: 'date';
142
+ value: string;
143
+ };
144
+ export type NumberSetColumnFilterValue = {
145
+ kind: 'numberSet';
146
+ condition: ParsedNumberFilter | null;
147
+ set: {
148
+ mode?: 'include' | 'exclude';
149
+ values: string[];
150
+ } | null;
151
+ };
152
+ export type ParsedTextFilter = {
153
+ mode: 'contains' | 'equals' | 'startsWith' | 'endsWith';
154
+ value: string;
155
+ } | {
156
+ mode: 'blank';
157
+ } | {
158
+ mode: 'notBlank';
159
+ };
160
+ export type TextSetColumnFilterValue = {
161
+ kind: 'textSet';
162
+ condition: ParsedTextFilter | null;
163
+ set: {
164
+ mode?: 'include' | 'exclude';
165
+ values: string[];
166
+ } | null;
167
+ };
168
+ export type DateFilterPreset = 'today' | 'thisMonth' | 'last30days';
169
+ export type DateFilterPresetRange = {
170
+ from?: string | Date;
171
+ to?: string | Date;
172
+ };
173
+ export type CustomDateFilterPreset = {
174
+ id: string;
175
+ label: string;
176
+ resolve: (now: Date) => DateFilterPresetRange;
177
+ };
178
+ export type DateFilterPresetOption = DateFilterPreset | CustomDateFilterPreset;
179
+ export type FilterDateInputContext = {
180
+ value: string;
181
+ onChange: (value: string | Date | null) => void;
182
+ ariaLabel: string;
183
+ slot: 'single' | 'from' | 'to';
184
+ columnKey: string;
185
+ };
186
+ export type ParsedDateFilter = {
187
+ mode: 'range';
188
+ from: string;
189
+ to: string;
190
+ } | {
191
+ mode: 'onOrAfter' | 'onOrBefore' | 'equals' | 'notEquals';
192
+ value: string;
193
+ } | {
194
+ mode: 'blank';
195
+ } | {
196
+ mode: 'notBlank';
197
+ } | {
198
+ mode: 'preset';
199
+ preset: string;
200
+ };
201
+ export type DateSetColumnFilterValue = {
202
+ kind: 'dateSet';
203
+ condition: ParsedDateFilter | null;
204
+ set: {
205
+ mode?: 'include' | 'exclude';
206
+ values: string[];
207
+ } | null;
208
+ };
209
+ export type SelectColumnFilterValue = {
210
+ kind: 'select';
211
+ value: string;
212
+ };
213
+ export type CustomColumnFilterValue = {
214
+ kind: 'custom';
215
+ value: unknown;
216
+ };
217
+ export type ColumnFilterValue = SetColumnFilterValue | NumberColumnFilterValue | NumberSetColumnFilterValue | TextColumnFilterValue | TextSetColumnFilterValue | DateColumnFilterValue | DateSetColumnFilterValue | SelectColumnFilterValue | CustomColumnFilterValue;
218
+ export type CellRenderContext<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
219
+ row: T;
220
+ rowIndex: number;
221
+ sourceRowIndex: number;
222
+ rowKey: GridRowKey;
223
+ colIndex: number;
224
+ value: unknown;
225
+ column: GridColumn<T, F>;
226
+ isActive: boolean;
227
+ isSelected: boolean;
228
+ isEditing: boolean;
229
+ readOnly: boolean;
230
+ setValue: (value: unknown) => void;
231
+ detail?: CellDetailContext;
232
+ };
233
+ export type CellDetailContext = {
234
+ expanded: boolean;
235
+ expandable: boolean;
236
+ toggle: () => void;
237
+ setExpanded: (expanded: boolean) => void;
238
+ };
239
+ export type DetailRowRenderContext<T> = {
240
+ row: T;
241
+ rowKey: GridRowKey;
242
+ rowIndex: number;
243
+ sourceRowIndex: number;
244
+ collapse: () => void;
245
+ };
246
+ export type DetailRowOptions<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
247
+ render: (ctx: DetailRowRenderContext<T>) => F['node'];
248
+ height?: number;
249
+ isExpandable?: (row: T, ctx: {
250
+ rowKey: GridRowKey;
251
+ sourceRowIndex: number;
252
+ }) => boolean;
253
+ showToggleColumn?: boolean;
254
+ className?: GridSlotProps<F>;
255
+ };
256
+ export type RowDragContext = {
257
+ rowKey: GridRowKey;
258
+ sourceRowIndex: number;
259
+ };
260
+ export type RowMoveParams<T> = {
261
+ rowKey: GridRowKey;
262
+ fromIndex: number;
263
+ toIndex: number;
264
+ rows: T[];
265
+ };
266
+ export type CellStyleContext<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
267
+ row: T;
268
+ rowIndex: number;
269
+ sourceRowIndex: number;
270
+ rowKey: GridRowKey;
271
+ colIndex: number;
272
+ value: unknown;
273
+ column: GridColumn<T, F>;
274
+ isActive: boolean;
275
+ isSelected: boolean;
276
+ isEditing: boolean;
277
+ readOnly: boolean;
278
+ };
279
+ export type RowStyleContext<T> = {
280
+ row: T;
281
+ rowIndex: number;
282
+ sourceRowIndex: number;
283
+ rowKey: GridRowKey;
284
+ isSelected: boolean;
285
+ };
286
+ export type CellRenderState = {
287
+ isActive: boolean;
288
+ isSelected: boolean;
289
+ isEditing: boolean;
290
+ readOnly: boolean;
291
+ };
292
+ export type HeaderRenderContext<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
293
+ colIndex: number;
294
+ width: number;
295
+ column: GridColumn<T, F>;
296
+ filterValue?: unknown;
297
+ isFiltered?: boolean;
298
+ };
299
+ export type GridColumnPinned = 'left' | 'right';
300
+ export type CellValueFormatterParams<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
301
+ value: unknown;
302
+ row: T;
303
+ column: GridColumn<T, F>;
304
+ };
305
+ export type CellValueFormatter<T, F extends GridFrameworkTypes = GridFrameworkTypes> = (params: CellValueFormatterParams<T, F>) => string;
306
+ export type EditorCommitDirection = 'down' | 'up' | 'right' | 'left';
307
+ export type EditorEnterMove = 'down' | 'up' | 'right' | 'left' | 'none';
308
+ export type GridSelectEditorOption = GridSelectFilterOption;
309
+ export type GridColumnEditor<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
310
+ type: 'text';
311
+ } | {
312
+ type: 'number';
313
+ min?: number;
314
+ max?: number;
315
+ step?: number;
316
+ } | {
317
+ type: 'select';
318
+ options: GridSelectEditorOption[] | ((row: T) => GridSelectEditorOption[]);
319
+ } | {
320
+ type: 'date';
321
+ } | {
322
+ type: 'checkbox';
323
+ checkedValue?: unknown;
324
+ uncheckedValue?: unknown;
325
+ } | {
326
+ type: 'custom';
327
+ render: (ctx: CellEditorContext<T, F>) => F['node'];
328
+ };
329
+ export type CellEditorContext<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
330
+ row: T;
331
+ rowIndex: number;
332
+ sourceRowIndex: number;
333
+ rowKey: GridRowKey;
334
+ colIndex: number;
335
+ column: GridColumn<T, F>;
336
+ value: unknown;
337
+ initialText: string;
338
+ align?: 'left' | 'center' | 'right';
339
+ commit: (value: unknown, direction?: EditorCommitDirection) => EditorCommitResult;
340
+ cancel: () => void;
341
+ };
342
+ export type GridValidationMode = 'mark' | 'reject';
343
+ export type CellValidationContext<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
344
+ value: unknown;
345
+ row: T;
346
+ column: GridColumn<T, F>;
347
+ };
348
+ export type CellValidationResult = boolean | string | {
349
+ message: string;
350
+ };
351
+ export type GridInvalidCell = {
352
+ rowKey: GridRowKey;
353
+ sourceRowIndex: number;
354
+ columnKey: string;
355
+ message: string;
356
+ };
357
+ export type EditorCommitResult = {
358
+ status: 'committed';
359
+ } | {
360
+ status: 'rejected';
361
+ message: string;
362
+ } | {
363
+ status: 'noop';
364
+ };
365
+ export type GridAggFuncName = 'sum' | 'min' | 'max' | 'avg' | 'count';
366
+ export type GridAggFuncParams<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
367
+ values: unknown[];
368
+ rows: T[];
369
+ column: GridColumn<T, F>;
370
+ };
371
+ export type GridAggFunc<T, F extends GridFrameworkTypes = GridFrameworkTypes> = (params: GridAggFuncParams<T, F>) => unknown;
372
+ export type GridGroupRow = {
373
+ kind: 'group';
374
+ groupKey: string;
375
+ columnKey: string;
376
+ value: unknown;
377
+ label: string;
378
+ level: number;
379
+ leafCount: number;
380
+ aggregates: Record<string, unknown>;
381
+ };
382
+ export type GridColumn<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
383
+ key: string;
384
+ title?: string;
385
+ width: number;
386
+ minWidth?: number;
387
+ maxWidth?: number;
388
+ wordBreak?: 'normal' | 'break-all' | 'keep-all' | 'break-word' | 'auto-phrase';
389
+ lineBreak?: 'auto' | 'loose' | 'normal' | 'strict' | 'anywhere';
390
+ flex?: number;
391
+ resizable?: boolean;
392
+ suppressAutoSize?: boolean;
393
+ estimateCellWidth?: (row: T, column: GridColumn<T, F>) => number;
394
+ autoHeight?: boolean;
395
+ visible?: boolean;
396
+ editable?: boolean;
397
+ readOnly?: boolean;
398
+ pinned?: GridColumnPinned;
399
+ rowGroup?: boolean;
400
+ aggFunc?: GridAggFuncName | GridAggFunc<T, F>;
401
+ getValue?: (row: T) => unknown;
402
+ setValue?: (row: T, value: unknown) => T;
403
+ renderCell?: (ctx: CellRenderContext<T, F>) => F['node'];
404
+ cellClassName?: GridSlotProps<F> | ((ctx: CellStyleContext<T, F>) => GridSlotProps<F> | undefined);
405
+ align?: 'left' | 'center' | 'right';
406
+ valueFormatter?: CellValueFormatter<T, F>;
407
+ renderHeader?: (ctx: HeaderRenderContext<T, F>) => F['node'];
408
+ filterType?: ColumnFilterTypeOption;
409
+ filterOptions?: readonly GridSelectFilterOption[];
410
+ dateFilterPresets?: false | readonly DateFilterPresetOption[];
411
+ filterFn?: (row: T, filterValue: unknown) => boolean;
412
+ editor?: GridColumnEditor<T, F>;
413
+ validate?: (ctx: CellValidationContext<T, F>) => CellValidationResult;
414
+ validationMode?: GridValidationMode;
415
+ parseClipboardValue?: (raw: string, row: T) => unknown;
416
+ formatClipboardValue?: (value: unknown, row: T) => string;
417
+ };
418
+ export type ColumnResizeDragState = {
419
+ type: 'columnResize';
420
+ columnKey: string;
421
+ startX: number;
422
+ startWidth: number;
423
+ minWidth: number;
424
+ maxWidth: number;
425
+ };
426
+ export type CellSelectionDragState = {
427
+ type: 'selection';
428
+ selectionKind: 'cell';
429
+ anchor: CellCoord;
430
+ };
431
+ export type RowSelectionDragState = {
432
+ type: 'selection';
433
+ selectionKind: 'row';
434
+ anchorRow: number;
435
+ };
436
+ export type ColumnSelectionDragState = {
437
+ type: 'selection';
438
+ selectionKind: 'col';
439
+ anchorCol: number;
440
+ };
441
+ export type GridUiState = {
442
+ activeCell: CellCoord | null;
443
+ selection: GridSelection;
444
+ rowSelection: RowSelectionState;
445
+ editingCell: CellCoord | null;
446
+ dragState: CellSelectionDragState | RowSelectionDragState | ColumnSelectionDragState | ColumnResizeDragState | null;
447
+ columnWidths: Record<string, number>;
448
+ filters: GridFilterState;
449
+ sort: GridSortState;
450
+ collapsedGroupKeys: ReadonlySet<string>;
451
+ expandedDetailRowKeys: ReadonlySet<GridRowKey>;
452
+ };
453
+ export type SpreadsheetGridSelectionStats = {
454
+ selectedCellCount: number;
455
+ selectedRowCount: number;
456
+ selectedColumnCount: number;
457
+ };
458
+ export type SpreadsheetGridDerivedSummary = {
459
+ rowSummaryText: string;
460
+ columnSummaryText: string;
461
+ filterSummaryText: string;
462
+ sortSummaryText: string;
463
+ activeCellLabel: string;
464
+ selectionLabel: string;
465
+ selectionStatsText: string;
466
+ selectionStats: SpreadsheetGridSelectionStats;
467
+ hasGlobalFilter: boolean;
468
+ globalFilterPreview: string | null;
469
+ activeColumnFilterCount: number;
470
+ hasAnyFilter: boolean;
471
+ hasSorting: boolean;
472
+ sortedColumnLabel: string | null;
473
+ };
474
+ export type GlobalFilterStatus = 'idle' | 'filtering' | 'ready';
475
+ export type SpreadsheetGridSlotContext<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
476
+ rows: T[];
477
+ filteredRows: T[];
478
+ columns: GridColumn<T, F>[];
479
+ visibleColumns: GridColumn<T, F>[];
480
+ globalFilterText: string;
481
+ columnFilterValues: Record<string, ColumnFilterValue>;
482
+ sortState: GridSortState;
483
+ setGlobalFilterText: (value: string) => void;
484
+ activeCell: CellCoord | null;
485
+ selection: GridSelection;
486
+ derivedSummary: SpreadsheetGridDerivedSummary;
487
+ globalFilterStatus: GlobalFilterStatus;
488
+ globalFilterProgress: number;
489
+ };
490
+ export type GridContextMenuTarget<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
491
+ type: 'cell';
492
+ rowIndex: number;
493
+ colIndex: number;
494
+ rowKey: GridRowKey;
495
+ row: T;
496
+ column: GridColumn<T, F>;
497
+ value: unknown;
498
+ } | {
499
+ type: 'rowHeader';
500
+ rowIndex: number;
501
+ rowKey: GridRowKey;
502
+ row: T;
503
+ };
504
+ export type GridContextMenuParams<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
505
+ target: GridContextMenuTarget<T, F>;
506
+ clientX: number;
507
+ clientY: number;
508
+ selection: GridSelection;
509
+ activeCell: CellCoord | null;
510
+ isTargetSelected: boolean;
511
+ };
512
+ export type GridContextMenuActionItem<F extends GridFrameworkTypes = GridFrameworkTypes> = {
513
+ kind?: 'action';
514
+ id?: string;
515
+ label: F['node'];
516
+ icon?: F['node'];
517
+ disabled?: boolean;
518
+ danger?: boolean;
519
+ onSelect: () => void;
520
+ };
521
+ export type GridContextMenuLabelItem<F extends GridFrameworkTypes = GridFrameworkTypes> = {
522
+ kind: 'label';
523
+ id?: string;
524
+ label: F['node'];
525
+ };
526
+ export type GridContextMenuSeparatorItem = {
527
+ kind: 'separator';
528
+ id?: string;
529
+ };
530
+ export type GridContextMenuCustomItem<F extends GridFrameworkTypes = GridFrameworkTypes> = {
531
+ kind: 'custom';
532
+ id?: string;
533
+ render: (ctx: {
534
+ close: () => void;
535
+ }) => F['node'];
536
+ };
537
+ export type GridContextMenuItem<F extends GridFrameworkTypes = GridFrameworkTypes> = GridContextMenuActionItem<F> | GridContextMenuLabelItem<F> | GridContextMenuSeparatorItem | GridContextMenuCustomItem<F>;
538
+ export type GridSlotProps<F extends GridFrameworkTypes = GridFrameworkTypes> = string | {
539
+ className?: string;
540
+ style?: F['style'];
541
+ };
542
+ export type GridResolvedSlot<F extends GridFrameworkTypes = GridFrameworkTypes> = {
543
+ className?: string;
544
+ style?: F['style'];
545
+ };
546
+ export type GridResolvedSlots<F extends GridFrameworkTypes = GridFrameworkTypes> = Partial<Record<keyof GridClassNames<F>, GridResolvedSlot<F>>>;
547
+ export type GridClassNames<F extends GridFrameworkTypes = GridFrameworkTypes> = {
548
+ root?: GridSlotProps<F>;
549
+ toolbar?: GridSlotProps<F>;
550
+ statusBar?: GridSlotProps<F>;
551
+ headerRow?: GridSlotProps<F>;
552
+ headerCell?: GridSlotProps<F>;
553
+ bodyRow?: GridSlotProps<F>;
554
+ bodyCell?: GridSlotProps<F>;
555
+ rowHeaderCell?: GridSlotProps<F>;
556
+ iconButton?: GridSlotProps<F>;
557
+ cornerCell?: GridSlotProps<F>;
558
+ groupRow?: GridSlotProps<F>;
559
+ groupCell?: GridSlotProps<F>;
560
+ detailBand?: GridSlotProps<F>;
561
+ detailCard?: GridSlotProps<F>;
562
+ popover?: GridSlotProps<F>;
563
+ menuItem?: GridSlotProps<F>;
564
+ tooltip?: GridSlotProps<F>;
565
+ dragGhost?: GridSlotProps<F>;
566
+ checkbox?: GridSlotProps<F>;
567
+ cellEditor?: GridSlotProps<F>;
568
+ emptyState?: GridSlotProps<F>;
569
+ filterChipBar?: GridSlotProps<F>;
570
+ errorBar?: GridSlotProps<F>;
571
+ scrollHint?: GridSlotProps<F>;
572
+ activeCellOverlay?: GridSlotProps<F>;
573
+ selectionOverlay?: GridSlotProps<F>;
574
+ };
575
+ export type ScrollAlign = 'auto' | 'start' | 'center' | 'end';
576
+ export type GridScrollPosition = {
577
+ top: number;
578
+ left: number;
579
+ };
580
+ export type GridScrollEventParams = {
581
+ top: number;
582
+ left: number;
583
+ source: 'user' | 'api';
584
+ };
585
+ /**
586
+ * エクスポートの対象範囲です(exportCsv / downloadCsv / getExportData で共通)。
587
+ * - `'view'` : ビュー行全体(フィルター/ソート/列可視・固定順を反映)。**既定値**。スクロール位置に依存しません。
588
+ * - `'raw'` : 全ソース行(`rows` 配列順)。フィルターもソートも無視します(列は可視列・固定順に従います)。
589
+ * serverSide はソース行配列を持たないため `'view'` 相当へフォールバックします(console.warn を出力)。
590
+ * - `'rendered'` : 仮想化ウィンドウ(いま描画中の行のみ・オーバースキャン込み)。結果はスクロール位置に依存します。
591
+ * - `'selection'`: 現在の選択範囲(セル/行/列)。選択なしのときは空(CSV は空文字 / データは空配列)を返します。
592
+ */
593
+ export type CsvExportScope = 'view' | 'raw' | 'rendered' | 'selection' | DeprecatedCsvExportScope;
594
+ /**
595
+ * 後方互換エイリアスです(実行時挙動は新名称と完全同一): `'all'` → `'view'` / `'visible'` → `'rendered'`。
596
+ * @deprecated `'visible'` は「フィルターで見えている行」ではなく「描画中の行(仮想化ウィンドウ)」を
597
+ * 指すため誤読のもとになります。新規コードでは `'view'` / `'rendered'` を使用してください。
598
+ */
599
+ export type DeprecatedCsvExportScope = 'all' | 'visible';
600
+ export type CsvExportOptions = {
601
+ scope?: CsvExportScope;
602
+ includeHeaders?: boolean;
603
+ delimiter?: string;
604
+ bom?: boolean;
605
+ };
606
+ export type GridExportOptions = {
607
+ scope?: CsvExportScope;
608
+ };
609
+ export type GridExportCell = {
610
+ value: unknown;
611
+ text: string;
612
+ };
613
+ export type GridExportData = {
614
+ columns: {
615
+ key: string;
616
+ title: string;
617
+ }[];
618
+ rows: GridExportCell[][];
619
+ };
620
+ export type GridColumnState = {
621
+ key: string;
622
+ visible?: boolean;
623
+ pinned?: GridColumnPinned;
624
+ };
625
+ export type GridState = {
626
+ version: number;
627
+ columnWidths: Record<string, number>;
628
+ filters: GridFilterState;
629
+ sort: GridSortState;
630
+ columns?: GridColumnState[];
631
+ };
632
+ export type SpreadsheetGridHandle<T> = {
633
+ scrollToRow: (viewRowIndex: number, options?: {
634
+ align?: ScrollAlign;
635
+ }) => void;
636
+ scrollToCell: (viewRowIndex: number, colIndex: number, options?: {
637
+ align?: ScrollAlign;
638
+ }) => void;
639
+ scrollToTop: () => void;
640
+ scrollToBottom: () => void;
641
+ getVisibleRowRange: () => {
642
+ startIndex: number;
643
+ endIndex: number;
644
+ } | null;
645
+ getScrollPosition: () => GridScrollPosition | null;
646
+ setScrollPosition: (position: {
647
+ top?: number;
648
+ left?: number;
649
+ }, options?: {
650
+ behavior?: 'auto' | 'smooth';
651
+ }) => void;
652
+ getActiveCell: () => CellCoord | null;
653
+ setActiveCell: (cell: CellCoord | null, options?: {
654
+ scrollIntoView?: boolean;
655
+ }) => void;
656
+ getSelection: () => GridSelection;
657
+ selectCell: (viewRowIndex: number, colIndex: number, options?: {
658
+ scrollIntoView?: boolean;
659
+ }) => void;
660
+ selectRange: (range: CellRange, options?: {
661
+ scrollIntoView?: boolean;
662
+ }) => void;
663
+ clearSelection: () => void;
664
+ getSelectedRows: () => T[];
665
+ exportCsv: (options?: CsvExportOptions) => string;
666
+ downloadCsv: (filename?: string, options?: CsvExportOptions) => void;
667
+ getExportData: (options?: GridExportOptions) => GridExportData;
668
+ getState: () => GridState;
669
+ applyState: (state: GridState) => void;
670
+ getRowSelection: () => RowSelectionModel;
671
+ setRowSelection: (model: RowSelectionModel) => void;
672
+ getSelectedRowKeys: () => GridRowKey[];
673
+ getSelectedRowData: () => T[];
674
+ getSelectedRowCount: () => number;
675
+ isRowSelected: (rowKey: GridRowKey) => boolean;
676
+ selectAllRows: () => void;
677
+ clearRowSelection: () => void;
678
+ undo: () => void;
679
+ redo: () => void;
680
+ canUndo: () => boolean;
681
+ canRedo: () => boolean;
682
+ clearUndoHistory: () => void;
683
+ setGroupCollapsed: (groupKey: string, collapsed: boolean) => void;
684
+ expandAllGroups: () => void;
685
+ collapseAllGroups: () => void;
686
+ getGroupRows: () => GridGroupRow[];
687
+ setDetailRowExpanded: (rowKey: GridRowKey, expanded: boolean) => void;
688
+ getExpandedDetailRowKeys: () => GridRowKey[];
689
+ collapseAllDetailRows: () => void;
690
+ moveRow: (rowKey: GridRowKey, toIndex: number) => void;
691
+ getInvalidCells: () => GridInvalidCell[];
692
+ refreshServerSide: () => void;
693
+ openFilterManager: () => void;
694
+ closeFilterManager: () => void;
695
+ };
696
+ export type GridDensity = 'compact' | 'standard' | 'comfortable';
697
+ export type GridTheme = 'light' | 'dark' | 'auto';
698
+ export type AutoSizeColumnsMode = 'onMount' | 'onDataChange' | false;
699
+ export type ScrollHintTrigger = 'scroll' | 'hover' | 'always';
700
+ export type ScrollHintRenderArgs<T> = {
701
+ rowIndex: number;
702
+ rowData: T | undefined;
703
+ };
704
+ export type ScrollHintOptions<T = unknown, F extends GridFrameworkTypes = GridFrameworkTypes> = {
705
+ bubble?: boolean;
706
+ ruler?: boolean;
707
+ scrollbar?: boolean;
708
+ trigger?: ScrollHintTrigger;
709
+ minRows?: number;
710
+ hintColumn?: string;
711
+ renderHint?: (args: ScrollHintRenderArgs<T>) => F['node'];
712
+ };
713
+ export type SpreadsheetGridProps<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
714
+ onStateChange?: (state: GridState) => void;
715
+ onScroll?: (params: GridScrollEventParams) => void;
716
+ rows?: readonly T[];
717
+ dataSource?: ServerSideDataSource<T>;
718
+ serverSideRefreshToken?: number;
719
+ onServerSideLoadError?: (error: unknown, params: ServerSideLoadErrorParams) => void;
720
+ onServerSideWriteError?: (error: unknown, params: ServerSideWriteErrorParams<T>) => void;
721
+ columns: readonly GridColumn<T, F>[];
722
+ onRowsChange?: (nextRows: T[]) => void;
723
+ onColumnsChange?: (nextColumns: GridColumn<T, F>[]) => void;
724
+ rowKeyGetter?: (row: T, index: number) => GridRowKey;
725
+ isRowExportable?: (row: T, ctx: {
726
+ viewRowIndex: number;
727
+ rowKey: GridRowKey;
728
+ }) => boolean;
729
+ createRow?: () => T;
730
+ createOverflowColumn?: (columnIndex: number) => GridColumn<T, F>;
731
+ rowHeight?: number;
732
+ autoHeight?: boolean;
733
+ estimateRowHeight?: number;
734
+ headerHeight?: number;
735
+ density?: GridDensity;
736
+ theme?: GridTheme;
737
+ rowHeaderWidth?: number;
738
+ height?: number | string;
739
+ maxHeight?: number | string;
740
+ readOnly?: boolean;
741
+ dimReadOnlyCells?: boolean;
742
+ canEditCell?: (rowIndex: number, colIndex: number, row: T, column: GridColumn<T, F>) => boolean;
743
+ enableUndoRedo?: boolean;
744
+ enableClearOnDelete?: boolean;
745
+ editorEnterMove?: EditorEnterMove;
746
+ undoHistoryLimit?: number;
747
+ onUndoRedoStateChange?: (state: UndoRedoState) => void;
748
+ enableRangeSelection?: boolean;
749
+ enableRowSelection?: boolean;
750
+ rowSelectionMode?: RowSelectionMode;
751
+ enableSelectAllRows?: boolean;
752
+ rowSelection?: RowSelectionModel;
753
+ selectedRowKeys?: GridRowKey[];
754
+ onRowSelectionChange?: (model: RowSelectionModel) => void;
755
+ enableGlobalFilter?: boolean;
756
+ enableColumnFilter?: boolean;
757
+ renderFilterDateInput?: (ctx: FilterDateInputContext) => F['node'];
758
+ enableSorting?: boolean;
759
+ enableColumnResize?: boolean;
760
+ autoSizeColumns?: AutoSizeColumnsMode;
761
+ showCellOverflowTooltip?: boolean;
762
+ showValidationMarks?: boolean;
763
+ enableRowHover?: boolean;
764
+ hoveredRowIndex?: number | null;
765
+ onHoveredRowChange?: (viewRowIndex: number | null, ctx: {
766
+ source: 'pointer';
767
+ }) => void;
768
+ enableColumnHeaderHover?: boolean;
769
+ enableColumnMenu?: boolean;
770
+ noMatchingRowsText?: string;
771
+ noRowsText?: string;
772
+ showTopBar?: boolean;
773
+ showTopBarSummary?: boolean;
774
+ showTopBarCounts?: boolean;
775
+ showTopBarFilter?: boolean;
776
+ globalFilterPlaceholder?: string;
777
+ globalFilterIcon?: F['node'];
778
+ showBottomBar?: boolean;
779
+ showBottomBarCounts?: boolean;
780
+ showFilterChipBar?: boolean;
781
+ renderTopBar?: (context: SpreadsheetGridSlotContext<T, F>) => F['node'];
782
+ renderBottomBar?: (context: SpreadsheetGridSlotContext<T, F>) => F['node'];
783
+ className?: string;
784
+ style?: F['style'];
785
+ classNames?: GridClassNames<F>;
786
+ getRowClassName?: (row: T, rowIndex: number, ctx: RowStyleContext<T>) => GridSlotProps<F> | undefined;
787
+ detailRow?: DetailRowOptions<T, F>;
788
+ onExpandedDetailRowKeysChange?: (keys: GridRowKey[]) => void;
789
+ enableRowDrag?: boolean;
790
+ isRowDraggable?: (row: T, ctx: RowDragContext) => boolean;
791
+ onRowMove?: (params: RowMoveParams<T>) => void;
792
+ enableContextMenu?: boolean;
793
+ getContextMenuItems?: (params: GridContextMenuParams<T, F>) => GridContextMenuItem<F>[];
794
+ onContextMenuOpen?: (params: GridContextMenuParams<T, F>) => void;
795
+ scrollHint?: boolean | ScrollHintOptions<T, F>;
796
+ };