@ishibashi0112/spreadsheet-grid-core 0.47.1 → 0.49.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.
Files changed (106) hide show
  1. package/dist/controllers/autoHeightMeasurer.cjs +1 -1
  2. package/dist/controllers/autoHeightMeasurer.js +4 -2
  3. package/dist/controllers/clipboardController.cjs +1 -1
  4. package/dist/controllers/clipboardController.d.ts +2 -1
  5. package/dist/controllers/clipboardController.js +67 -61
  6. package/dist/controllers/columnAutosizeRunner.cjs +1 -1
  7. package/dist/controllers/columnAutosizeRunner.d.ts +3 -0
  8. package/dist/controllers/columnAutosizeRunner.js +40 -24
  9. package/dist/controllers/columnHeaderDragController.cjs +1 -1
  10. package/dist/controllers/columnHeaderDragController.js +285 -107
  11. package/dist/controllers/editController.cjs +1 -1
  12. package/dist/controllers/editController.js +2 -2
  13. package/dist/controllers/fillHandleController.cjs +1 -0
  14. package/dist/controllers/fillHandleController.d.ts +87 -0
  15. package/dist/controllers/fillHandleController.js +346 -0
  16. package/dist/controllers/filterPopoverController.cjs +1 -1
  17. package/dist/controllers/filterPopoverController.js +55 -46
  18. package/dist/controllers/globalFilteredOrder.cjs +1 -1
  19. package/dist/controllers/globalFilteredOrder.js +5 -5
  20. package/dist/controllers/historyController.cjs +1 -1
  21. package/dist/controllers/historyController.d.ts +1 -0
  22. package/dist/controllers/historyController.js +8 -5
  23. package/dist/controllers/keyboardController.cjs +1 -1
  24. package/dist/controllers/keyboardController.js +2 -2
  25. package/dist/controllers/pointerInteractionsController.cjs +1 -1
  26. package/dist/controllers/pointerInteractionsController.d.ts +2 -0
  27. package/dist/controllers/pointerInteractionsController.js +136 -132
  28. package/dist/controllers/rowDragController.cjs +1 -1
  29. package/dist/controllers/rowDragController.d.ts +1 -0
  30. package/dist/controllers/rowDragController.js +104 -97
  31. package/dist/controllers/scrollSyncController.cjs +1 -1
  32. package/dist/controllers/scrollSyncController.d.ts +1 -0
  33. package/dist/controllers/scrollSyncController.js +32 -21
  34. package/dist/controllers/selectOptionsCollector.cjs +1 -1
  35. package/dist/controllers/selectOptionsCollector.js +5 -5
  36. package/dist/controllers/selectionAggregatesRunner.cjs +1 -0
  37. package/dist/controllers/selectionAggregatesRunner.d.ts +27 -0
  38. package/dist/controllers/selectionAggregatesRunner.js +65 -0
  39. package/dist/controllers/serverSideRowModel.cjs +1 -1
  40. package/dist/controllers/serverSideRowModel.js +75 -69
  41. package/dist/controllers/tooltipController.cjs +1 -1
  42. package/dist/controllers/tooltipController.js +44 -43
  43. package/dist/controllers/viewportSyncController.cjs +1 -1
  44. package/dist/controllers/viewportSyncController.d.ts +3 -2
  45. package/dist/controllers/viewportSyncController.js +6 -4
  46. package/dist/engine/columnCommands.cjs +1 -1
  47. package/dist/engine/columnCommands.js +1 -1
  48. package/dist/engine/columnLayout.cjs +1 -1
  49. package/dist/engine/columnLayout.js +1 -1
  50. package/dist/engine/createGridEngine.cjs +1 -1
  51. package/dist/engine/createGridEngine.d.ts +2 -0
  52. package/dist/engine/createGridEngine.js +43 -41
  53. package/dist/engine/gridApi.cjs +1 -1
  54. package/dist/engine/gridApi.d.ts +6 -0
  55. package/dist/engine/gridApi.js +134 -123
  56. package/dist/logic/aggregation.cjs +1 -1
  57. package/dist/logic/aggregation.d.ts +1 -0
  58. package/dist/logic/aggregation.js +16 -7
  59. package/dist/logic/autoScrollGeometry.cjs +1 -1
  60. package/dist/logic/autoScrollGeometry.d.ts +1 -0
  61. package/dist/logic/autoScrollGeometry.js +3 -3
  62. package/dist/logic/clearCells.cjs +1 -1
  63. package/dist/logic/clearCells.d.ts +1 -1
  64. package/dist/logic/clearCells.js +7 -7
  65. package/dist/logic/columnAutosize.cjs +1 -1
  66. package/dist/logic/columnAutosize.d.ts +6 -0
  67. package/dist/logic/columnAutosize.js +60 -39
  68. package/dist/logic/exportCsv.cjs +2 -2
  69. package/dist/logic/exportCsv.d.ts +5 -1
  70. package/dist/logic/exportCsv.js +16 -15
  71. package/dist/logic/exportData.cjs +1 -1
  72. package/dist/logic/exportData.d.ts +2 -1
  73. package/dist/logic/exportData.js +27 -21
  74. package/dist/logic/fillHandle.cjs +1 -0
  75. package/dist/logic/fillHandle.d.ts +69 -0
  76. package/dist/logic/fillHandle.js +254 -0
  77. package/dist/logic/fillSeries.cjs +1 -0
  78. package/dist/logic/fillSeries.d.ts +11 -0
  79. package/dist/logic/fillSeries.js +239 -0
  80. package/dist/logic/filtering.cjs +1 -1
  81. package/dist/logic/filtering.js +37 -37
  82. package/dist/logic/gridState.cjs +1 -1
  83. package/dist/logic/gridState.js +1 -1
  84. package/dist/logic/imeInput.cjs +1 -1
  85. package/dist/logic/imeInput.js +2 -2
  86. package/dist/logic/labelRows.cjs +1 -1
  87. package/dist/logic/labelRows.js +1 -1
  88. package/dist/logic/selectOptions.cjs +1 -1
  89. package/dist/logic/selectOptions.js +1 -1
  90. package/dist/logic/selectionAggregates.cjs +1 -0
  91. package/dist/logic/selectionAggregates.d.ts +25 -0
  92. package/dist/logic/selectionAggregates.js +74 -0
  93. package/dist/logic/totalRow.cjs +1 -0
  94. package/dist/logic/totalRow.d.ts +25 -0
  95. package/dist/logic/totalRow.js +90 -0
  96. package/dist/model/gridReducer.cjs +1 -1
  97. package/dist/model/gridReducer.js +1 -1
  98. package/dist/model/gridTypes.core.d.ts +205 -16
  99. package/dist/model/gridTypes.unbound.d.ts +4 -0
  100. package/dist/utils/clipboard.cjs +1 -1
  101. package/dist/utils/clipboard.d.ts +1 -1
  102. package/dist/utils/clipboard.js +9 -9
  103. package/dist/utils/permissions.cjs +1 -1
  104. package/dist/utils/permissions.d.ts +6 -2
  105. package/dist/utils/permissions.js +8 -2
  106. package/package.json +1 -1
@@ -368,6 +368,86 @@ export type LabelRowOptions<T, F extends GridFrameworkTypes = GridFrameworkTypes
368
368
  */
369
369
  exportText?: (row: T) => string | ReadonlyArray<string | number | null | undefined>;
370
370
  };
371
+ export type TotalRowCellKind = GridAggFuncName | 'custom' | 'value';
372
+ export type TotalRowCellContext<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
373
+ column: GridColumn<T, F>;
374
+ value: unknown;
375
+ kind: TotalRowCellKind;
376
+ text: string;
377
+ caption: string | undefined;
378
+ };
379
+ /**
380
+ * 合計行の設定です(`totalRow` prop)。`true` を渡すと既定値だけで有効になります。
381
+ *
382
+ * 各フィールドの説明は React 版パッケージ `@ishibashi0112/spreadsheet-grid` に同梱の `API_REFERENCE.md`
383
+ * の「合計行」節と同じ内容です。
384
+ */
385
+ export type TotalRowOptions<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
386
+ /**
387
+ * 見出し。行ドラッグ /
388
+ * 展開トグルの合成列を除いた先頭列に出す(その列に値があるときは行番号の欄へ)。
389
+ *
390
+ * @defaultValue `'合計'`
391
+ */
392
+ label?: string;
393
+ /**
394
+ * 列 key → 表示する値。指定した列は計算せずこの値を出す(`aggFunc` より優先。serverSide
395
+ * はこれだけ)。
396
+ */
397
+ values?: Readonly<Record<string, unknown>>;
398
+ /**
399
+ * 値のあるセルの中身を差し替える。`ctx = { column, value, kind, text, caption }`(`kind` は
400
+ * `'sum' | 'avg' | 'min' | 'max' | 'count' | 'custom' | 'value'`、`text` は既定の表示文字列、
401
+ * `caption` は種類の見出し)。
402
+ */
403
+ renderCell?: (ctx: TotalRowCellContext<T, F>) => F['node'];
404
+ /**
405
+ * 合計行の高さ(px)。
406
+ *
407
+ * @defaultValue `rowHeight`
408
+ */
409
+ height?: number;
410
+ /** 行要素へ追加する class(または `{ className, style }`)。`classNames.totalRow` に加えて付与。 */
411
+ className?: GridSlotProps<F>;
412
+ };
413
+ export type GridFillDirection = 'down' | 'up' | 'right' | 'left';
414
+ export type GridFillKind = 'series' | 'copy';
415
+ export type GridFillValueParams<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
416
+ /** 埋めるセルの列。 */
417
+ column: GridColumn<T, F>;
418
+ /** 埋めるセルの行(書き込み前)。 */
419
+ row: T;
420
+ /** 埋めるセルのビュー行 index。 */
421
+ rowIndex: number;
422
+ /**
423
+ * 元の値。埋める向きの順で、最後の要素が埋めるセルに一番近い(上 / 左へ埋めるときは下 /
424
+ * 右から並ぶ)。
425
+ */
426
+ sourceValues: readonly unknown[];
427
+ /** 元の範囲の直後を 0 とする位置(ラベル行 / グループ行は数えない)。 */
428
+ index: number;
429
+ /** 埋める向き(`'down' | 'up' | 'right' | 'left'`)。 */
430
+ direction: GridFillDirection;
431
+ /** この列(上下へ埋めるとき)/ 行(左右へ埋めるとき)の埋め方(`'series' | 'copy'`)。 */
432
+ kind: GridFillKind;
433
+ /** 既定で書く値。 */
434
+ defaultValue: unknown;
435
+ };
436
+ /**
437
+ * フィルハンドルの設定です(`fillHandle` prop)。`true` を渡すと既定値だけで有効になります。
438
+ *
439
+ * 各フィールドの説明は React 版パッケージ `@ishibashi0112/spreadsheet-grid` に同梱の `API_REFERENCE.md`
440
+ * の「フィルハンドル」節と同じ内容です。
441
+ */
442
+ export type FillHandleOptions<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
443
+ /**
444
+ * 埋めるセルごとに書く値を決める。返した値をそのまま書く(既定のままにするなら
445
+ * `params.defaultValue` を返す)。編集できないセルでは呼ばれない。
446
+ * ドラッグ中のツールチップ(いちばん遠いセルの値)でも呼ぶため、副作用の無い関数にする。返した値も
447
+ * `validate` を通り、reject なら書かない。
448
+ */
449
+ getFillValue?: (params: GridFillValueParams<T, F>) => unknown;
450
+ };
371
451
  export type RowDragContext = {
372
452
  rowKey: GridRowKey;
373
453
  sourceRowIndex: number;
@@ -391,6 +471,14 @@ export type CellStyleContext<T, F extends GridFrameworkTypes = GridFrameworkType
391
471
  isEditing: boolean;
392
472
  readOnly: boolean;
393
473
  };
474
+ /**
475
+ * `canEditCell` の第 5 引数。`sourceRowIndex` は元 `rows` の index(serverSide では view index と同値)、
476
+ * `rowKey` は `rowKeyGetter` の値(未指定なら元 `rows` の index)。
477
+ */
478
+ export type CanEditCellContext = {
479
+ sourceRowIndex: number;
480
+ rowKey: GridRowKey;
481
+ };
394
482
  export type RowStyleContext<T> = {
395
483
  row: T;
396
484
  rowIndex: number;
@@ -514,7 +602,10 @@ export type GridColumn<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
514
602
  title?: string;
515
603
  /** 列幅(px)。 */
516
604
  width: number;
517
- /** リサイズ時の下限幅。flex 配分時の下限クランプにも使用(flex 列で未指定なら内部既定 50px)。 */
605
+ /**
606
+ * リサイズ時の下限幅(未指定時の手動リサイズの下限は 60px。`0` を指定すると 0 まで縮められる)。
607
+ * flex 配分時の下限クランプにも使用(flex 列で未指定なら内部既定 50px)。
608
+ */
518
609
  minWidth?: number;
519
610
  /**
520
611
  * 上限幅。**未指定なら上限なし**(autoSize は内容にぴったり合わせ、
@@ -597,9 +688,11 @@ export type GridColumn<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
597
688
  */
598
689
  rowGroup?: boolean;
599
690
  /**
600
- * グルーピング時のこの列の集計。組み込みは値駆動の数値集計(`Number()`
601
- * で有限になる値のみ対象・空値除外、`count` は配下 leaf 行数)。
602
- * 関数でカスタム集計可(返り値がグループ行に表示)。`rowGroup` 列がないときは無視。
691
+ * グルーピング時と合計行(`totalRow`)のこの列の集計。
692
+ * 組み込みは数値と数値の文字列だけを数える集計(空値・空白だけの文字列・`true` /
693
+ * `false`・`Date`・配列などは対象外、`count` は配下 leaf 行数 / 合計行では対象の行数)。
694
+ * 関数でカスタム集計可(返り値がグループ行 / 合計行に表示)。`rowGroup` 列も `totalRow`
695
+ * もないときは無視。
603
696
  */
604
697
  aggFunc?: GridAggFuncName | GridAggFunc<T, F>;
605
698
  /**
@@ -659,7 +752,12 @@ export type GridColumn<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
659
752
  * `numberFormatter` 等を渡せる。元の値/編集/コピー/ソート/フィルターには影響しない。
660
753
  */
661
754
  valueFormatter?: CellValueFormatter<T, F>;
662
- /** カスタムヘッダー描画。 */
755
+ /**
756
+ * カスタムヘッダー描画。中に置いたボタン / 入力欄 / リンク等(`button` / `input` / `select` /
757
+ * `textarea` / `a[href]` / `label` / `contenteditable` / `role="button"` 等)
758
+ * を押したときは列の範囲選択を始めない(既定動作も止めないため入力欄にフォーカスが入る)。
759
+ * それ以外の部分を押すと従来どおり列を選択する。
760
+ */
663
761
  renderHeader?: (ctx: HeaderRenderContext<T, F>) => F['node'];
664
762
  /**
665
763
  * フィルター UI の種別。`'auto'` は列の値から `numberSet` / `textSet` / `dateSet` を自動判定する
@@ -779,6 +877,18 @@ export type SpreadsheetGridDerivedSummary = {
779
877
  sortedColumnLabel: string | null;
780
878
  };
781
879
  export type GlobalFilterStatus = 'idle' | 'filtering' | 'ready';
880
+ export type GridSelectionAggregates = {
881
+ status: 'computing' | 'ready';
882
+ progress: number;
883
+ cellCount: number;
884
+ count: number;
885
+ numericCount: number;
886
+ sum: number | undefined;
887
+ average: number | undefined;
888
+ min: number | undefined;
889
+ max: number | undefined;
890
+ partial: boolean;
891
+ };
782
892
  export type SpreadsheetGridSlotContext<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
783
893
  rows: T[];
784
894
  filteredRows: T[];
@@ -793,6 +903,7 @@ export type SpreadsheetGridSlotContext<T, F extends GridFrameworkTypes = GridFra
793
903
  derivedSummary: SpreadsheetGridDerivedSummary;
794
904
  globalFilterStatus: GlobalFilterStatus;
795
905
  globalFilterProgress: number;
906
+ selectionAggregates?: GridSelectionAggregates | null;
796
907
  };
797
908
  export type GridContextMenuTarget<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
798
909
  type: 'cell';
@@ -982,6 +1093,16 @@ export type GridClassNames<F extends GridFrameworkTypes = GridFrameworkTypes> =
982
1093
  * 縦固定の複製にも付く)/ 中身の器 `.ssg-label-row-content`
983
1094
  */
984
1095
  labelRowContent?: GridSlotProps<F>;
1096
+ /**
1097
+ * `totalRow` / `totalCell`: 付与先: 合計行の行要素 `.ssg-total-row`(3 ペイン分。
1098
+ * `totalRow.className` に加えて付与)/ 合計行のセル `.ssg-total-cell`(`bodyCell` に加えて付与)
1099
+ */
1100
+ totalRow?: GridSlotProps<F>;
1101
+ /**
1102
+ * `totalRow` / `totalCell`: 付与先: 合計行の行要素 `.ssg-total-row`(3 ペイン分。
1103
+ * `totalRow.className` に加えて付与)/ 合計行のセル `.ssg-total-cell`(`bodyCell` に加えて付与)
1104
+ */
1105
+ totalCell?: GridSlotProps<F>;
985
1106
  /**
986
1107
  * 付与先: ポータル系パネルの root(列メニュー / フィルター / コンテキストメニュー / select
987
1108
  * エディタ候補 / ツールパネル。`document.body` 直下)
@@ -1047,11 +1168,14 @@ export type CsvExportOptions = {
1047
1168
  includeHeaders?: boolean;
1048
1169
  delimiter?: string;
1049
1170
  bom?: boolean;
1171
+ escapeFormulas?: boolean;
1050
1172
  includeLabelRows?: boolean;
1173
+ includeTotalRow?: boolean;
1051
1174
  };
1052
1175
  export type GridExportOptions = {
1053
1176
  scope?: CsvExportScope;
1054
1177
  includeLabelRows?: boolean;
1178
+ includeTotalRow?: boolean;
1055
1179
  };
1056
1180
  export type GridExportCell = {
1057
1181
  value: unknown;
@@ -1063,7 +1187,7 @@ export type GridExportData = {
1063
1187
  title: string;
1064
1188
  }[];
1065
1189
  rows: GridExportCell[][];
1066
- rowKinds?: Array<'data' | 'label'>;
1190
+ rowKinds?: Array<'data' | 'label' | 'total'>;
1067
1191
  };
1068
1192
  export type GridColumnState = {
1069
1193
  key: string;
@@ -1134,13 +1258,18 @@ export type SpreadsheetGridHandle<T> = {
1134
1258
  }) => void;
1135
1259
  /** 現在のアクティブセル `{ row, col }`(なければ `null`)。 */
1136
1260
  getActiveCell: () => CellCoord | null;
1137
- /** アクティブセル設定(`null` で解除)。`scrollIntoView` で可視化も行う。 */
1261
+ /**
1262
+ * アクティブセル設定(`null` で解除)。`scrollIntoView: true`
1263
+ * で可視化も行う(固定列のセルでも縦方向へスクロールする)。中央ペイン(固定でない列)のセルは、
1264
+ * 指定が無くてもアクティブセルの位置が変わると見える位置までスクロールされる(クリック /
1265
+ * キー操作と同じ動き)。
1266
+ */
1138
1267
  setActiveCell: (cell: CellCoord | null, options?: {
1139
1268
  scrollIntoView?: boolean;
1140
1269
  }) => void;
1141
1270
  /** 現在の選択状態(`GridSelection`)。 */
1142
1271
  getSelection: () => GridSelection;
1143
- /** 単一セル選択(クリック相当)。 */
1272
+ /** 単一セル選択(クリック相当)。スクロールの扱いは `setActiveCell` と同じ。 */
1144
1273
  selectCell: (viewRowIndex: number, colIndex: number, options?: {
1145
1274
  scrollIntoView?: boolean;
1146
1275
  }) => void;
@@ -1633,7 +1762,8 @@ export type SpreadsheetGridProps<T, F extends GridFrameworkTypes = GridFramework
1633
1762
  * 行ドラッグ並べ替え(`enableRowDrag`)の表示方式。`'ghost'` は従来(ゴースト + ガイド線、
1634
1763
  * ドロップ後に新しい位置へスライド)。`'live'` は掴んだ行がポインタに追従し、
1635
1764
  * 通る先の行がその場で上下へ退避する(ドロップ先が「隙間」として見える。
1636
- * 枠外で離しても直前の位置へ確定、`Esc` で元へ戻る)。`motion` が `'off'` のときは `'ghost'`
1765
+ * 枠外で離しても直前の位置へ確定、`Esc` で元へ戻る。
1766
+ * ウィンドウからフォーカスが外れたときも元へ戻る)。`motion` が `'off'` のときは `'ghost'`
1637
1767
  * と同じ。
1638
1768
  *
1639
1769
  * @defaultValue `'ghost'`
@@ -1643,9 +1773,12 @@ export type SpreadsheetGridProps<T, F extends GridFrameworkTypes = GridFramework
1643
1773
  * 列ヘッダーのドラッグ並べ替え(`onColumnsChange` 指定時)の表示方式。`'ghost'` は従来(ゴースト +
1644
1774
  * 縦線、ドロップ後に新しい位置へスライド)。`'live'` は同じペイン内では掴んだ列(ヘッダー +
1645
1775
  * 描画中のセル)がポインタに追従し、通る先の列がその場で左右へ退避する(ドロップ先が「隙間」
1646
- * として見える。枠外で離しても直前の位置へ確定、`Esc` で元へ戻る)。
1647
- * 固定列のペインをまたいで移す(固定の変更)ときは `'ghost'` と同じ縦線 + ゴーストに切り替わる。
1648
- * `motion` が `'off'` のときは `'ghost'` と同じ。
1776
+ * として見える。枠外で離しても直前の位置へ確定、`Esc` で元へ戻る。
1777
+ * ウィンドウからフォーカスが外れたときも元へ戻る)。固定列のペインをまたいで移す(固定の変更)
1778
+ * ときは、掴んだ列の複製(浮かぶ列)がポインタに付いてきて元のペインは列が抜けた分だけ詰まり、
1779
+ * 移動先は縦線で示す(浮かぶ列の見出しに、固定ペインへはピン / 中央へは移動の矢印のアイコン。
1780
+ * 浮かぶ列は表の枠の内側に収まり、離すと新しい位置へ滑り込む)。`motion` が `'off'` のときは
1781
+ * `'ghost'` と同じ。
1649
1782
  *
1650
1783
  * @defaultValue `'ghost'`
1651
1784
  */
@@ -1712,8 +1845,16 @@ export type SpreadsheetGridProps<T, F extends GridFrameworkTypes = GridFramework
1712
1845
  * @defaultValue `false`
1713
1846
  */
1714
1847
  dimReadOnlyCells?: boolean;
1715
- /** セル単位の編集可否ゲート。 */
1716
- canEditCell?: (rowIndex: number, colIndex: number, row: T, column: GridColumn<T, F>) => boolean;
1848
+ /**
1849
+ * セル単位の編集可否ゲート。`rowIndex` は**ビュー行 index**(フィルター / ソート後の表示位置)で、
1850
+ * 表示(読み取り専用の見た目)・編集開始・確定・貼り付け・Delete クリア・IME
1851
+ * 入力のどの経路でも同じ値が渡る。`ctx`(`CanEditCellContext`)は `{ sourceRowIndex, rowKey }` = 元
1852
+ * `rows` の index と行キー(`cellClassName` の ctx と同基準。serverSide では `sourceRowIndex` は
1853
+ * view index と同値)。ソート / フィルターで動かない判定は `row` か `ctx.rowKey` で行う。
1854
+ * 貼り付けで末尾に追加される行は、追加後の位置と元 `rows` の index で呼ばれる。※ v0.48 以前は
1855
+ * clientSide の貼り付けと Delete クリアだけ元 `rows` の index が渡っていた。
1856
+ */
1857
+ canEditCell?: (rowIndex: number, colIndex: number, row: T, column: GridColumn<T, F>, ctx: CanEditCellContext) => boolean;
1717
1858
  /**
1718
1859
  * グリッド編集(セル編集 / ペースト / `renderCell` の `setValue`)の取り消し/やり直し。`Ctrl/Cmd+Z`
1719
1860
  * = undo、`Ctrl/Cmd+Shift+Z` / `Ctrl/Cmd+Y` = redo(ハンドルの `undo()` / `redo()` でも可)。
@@ -1770,7 +1911,8 @@ export type SpreadsheetGridProps<T, F extends GridFrameworkTypes = GridFramework
1770
1911
  /**
1771
1912
  * undo / redo 可能状態が**変化したとき**に呼ばれる(ツールバーの undo/redo ボタンの disabled
1772
1913
  * 表示などリアクティブな UI 用)。初回マウントでは発火せず、同値では再発火しない。
1773
- * 毎レンダーのインライン関数でも問題ない。
1914
+ * 毎レンダーのインライン関数でも問題ない。引数の型 `UndoRedoState`(`{ canUndo, canRedo }`)
1915
+ * はパッケージから import できる。
1774
1916
  */
1775
1917
  onUndoRedoStateChange?: (state: UndoRedoState) => void;
1776
1918
  /**
@@ -1971,7 +2113,9 @@ export type SpreadsheetGridProps<T, F extends GridFrameworkTypes = GridFramework
1971
2113
  */
1972
2114
  enableColumnMenu?: boolean;
1973
2115
  /**
1974
- * フィルター結果 0 行時のオーバーレイ文言。
2116
+ * フィルター結果 0 行時のオーバーレイ文言。serverSide(`dataSource`)では列 /
2117
+ * グローバルフィルターが掛かった状態で 0 件のときにこちら、掛かっていなければ `noRowsText`
2118
+ * を出す。
1975
2119
  *
1976
2120
  * @defaultValue `'一致する行がありません'`
1977
2121
  */
@@ -1982,6 +2126,11 @@ export type SpreadsheetGridProps<T, F extends GridFrameworkTypes = GridFramework
1982
2126
  * @defaultValue `'表示する行がありません'`
1983
2127
  */
1984
2128
  noRowsText?: string;
2129
+ /**
2130
+ * 表(`role="grid"` の要素)のアクセシブル名。スクリーンリーダーが表を読み上げるときの名前で、1
2131
+ * 画面に複数のグリッドを置くときは付けておくと区別できる(「アクセシビリティ」節)。
2132
+ */
2133
+ ariaLabel?: string;
1985
2134
  /**
1986
2135
  * 上部バー(ツールバー)の表示有無。`false` で `renderTopBar` / `enableGlobalFilter`
1987
2136
  * に関わらず一切描画しない(表示のマスタースイッチ。矛盾指定時は `renderTopBar` より優先)。
@@ -2039,6 +2188,18 @@ export type SpreadsheetGridProps<T, F extends GridFrameworkTypes = GridFramework
2039
2188
  * @defaultValue `true`
2040
2189
  */
2041
2190
  showBottomBarCounts?: boolean;
2191
+ /**
2192
+ * 2 セル以上を選んだとき、選択範囲の集計(平均 / データの個数 / 合計)を既定ボトムバーの右側(Active
2193
+ * / Selection の隣の空き)に出す。数えるのは表示中のデータ行 ×
2194
+ * データ列のセルで(フィルターで隠れた行・グループ行・ラベル行・合成列は対象外)、合計 /
2195
+ * 平均は数値と数値の文字列だけ(グループ集計と同じ判定)、データの個数は空でないセル。
2196
+ * 大きな選択は時間分割で計算し、その間は「集計中…」。SSRM
2197
+ * では読み込み済みの行だけで計算し「読み込み済みの行のみ」と添える。`false` では計算もせず
2198
+ * `slotContext.selectionAggregates` は `null`(「選択範囲の集計」節)。
2199
+ *
2200
+ * @defaultValue `true`
2201
+ */
2202
+ showSelectionAggregates?: boolean;
2042
2203
  /**
2043
2204
  * フィルターチップバー(適用中の列フィルターをトップバー直下にチップで常時表示)
2044
2205
  * の表示有無(opt-in)。有効フィルター 0 件時はバーごと非表示(空バーは出さない)。`showTopBar`
@@ -2115,6 +2276,34 @@ export type SpreadsheetGridProps<T, F extends GridFrameworkTypes = GridFramework
2115
2276
  * @defaultValue —(無効)
2116
2277
  */
2117
2278
  labelRow?: LabelRowOptions<T, F>;
2279
+ /**
2280
+ * **合計行**。表の下端に合計行を固定表示する(縦スクロールしても動かず、
2281
+ * 横スクロールと左右の固定列には付いていく)。列ごとの集計は
2282
+ * `GridColumn.aggFunc`(行グルーピングと共通)で決め、
2283
+ * フィルター後のデータ行で計算し直す(ラベル行は数えず、グルーピング中は折りたたんだ行も数える)。
2284
+ * 合計以外の組み込み集計は値の前に種類(平均 / 最小 / 最大 / 個数)を出す。表示専用(選択 / 編集 /
2285
+ * 貼り付け / コピーの対象外)。`true` で既定値、オブジェクトで
2286
+ * `{ label?, values?, renderCell?, height?, className? }`。serverSide は計算せず `values`
2287
+ * の値だけを出す。エクスポートは `includeTotalRow: true` のときだけ末尾に含める。詳細は「合計行」
2288
+ * 節。
2289
+ *
2290
+ * @defaultValue —(無効)
2291
+ */
2292
+ totalRow?: boolean | TotalRowOptions<T, F>;
2293
+ /**
2294
+ * **フィルハンドル**。選択範囲(無ければアクティブセル)の右下に小さな四角を出し、
2295
+ * 引いた先のセルを**連続データ**(1, 2, 3 … / 日付 / 曜日・月の名前 / `P-001` のような末尾の数)
2296
+ * か**セルのコピー**で埋める(Excel のオートフィル)。ドラッグ中は埋める範囲を点線で、
2297
+ * いちばん遠いセルへ入る値をポインタの近くに出し、`Ctrl`(Mac は `⌘`)で埋め方を入れ替え、`Escape`
2298
+ * でやめる。離したあとは右下のボタンで「連続データ / セルのコピー」を選び直せる(元に戻す 1
2299
+ * 回で埋める前へ)。ハンドルのダブルクリックで隣の列に値が続くところまで下へ埋める。
2300
+ * 書き込みは貼り付けと同じ規則(編集できないセル・`validate` の reject は飛ばす / undo の対象)。
2301
+ * `readOnly` や書き込み先が無い(`onRowsChange` も `dataSource.updateRows` も無い)ときは出さない。
2302
+ * `true` で既定、オブジェクトで `{ getFillValue? }`。詳細は「フィルハンドル」節。
2303
+ *
2304
+ * @defaultValue —(無効)
2305
+ */
2306
+ fillHandle?: boolean | FillHandleOptions<T, F>;
2118
2307
  /**
2119
2308
  * **行ドラッグ並び替え**。先頭にドラッグハンドル列(幅 28px・タイトル無しの合成列。
2120
2309
  * 左固定列があれば左固定側)を挿入し、ハンドル(⋮⋮)を掴んで行を上下へ動かせる。確定時は
@@ -7,6 +7,10 @@ export type UnboundGridTypes = {
7
7
  export type CellRenderContext<T> = Core.CellRenderContext<T, UnboundGridTypes>;
8
8
  export type DetailRowOptions<T> = Core.DetailRowOptions<T, UnboundGridTypes>;
9
9
  export type LabelRowOptions<T> = Core.LabelRowOptions<T, UnboundGridTypes>;
10
+ export type TotalRowOptions<T> = Core.TotalRowOptions<T, UnboundGridTypes>;
11
+ export type TotalRowCellContext<T> = Core.TotalRowCellContext<T, UnboundGridTypes>;
12
+ export type FillHandleOptions<T> = Core.FillHandleOptions<T, UnboundGridTypes>;
13
+ export type GridFillValueParams<T> = Core.GridFillValueParams<T, UnboundGridTypes>;
10
14
  export type CellStyleContext<T> = Core.CellStyleContext<T, UnboundGridTypes>;
11
15
  export type GridConditionalFormat<T> = Core.GridConditionalFormat<T, UnboundGridTypes>;
12
16
  export type HeaderRenderContext<T> = Core.HeaderRenderContext<T, UnboundGridTypes>;
@@ -5,4 +5,4 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
5
5
  `)||(r.push(i),n.push(r)),n},a=e=>/[\t\n\r"]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e,o=e=>e.map(a).join(` `),s=(n,r,i,a,s)=>{if(!a)return``;let c=[];if(a.type===`cell`){let r=t.normalizeCellRange(a.range);for(let t=r.start.row;t<=r.end.row;t+=1){let a=n(t);if(!a||s&&!s(a,t))continue;let l=[];for(let t=r.start.col;t<=r.end.col;t+=1){let n=i[t];if(!n)continue;let r=e.getCellValue(a,n),o=n.formatClipboardValue?n.formatClipboardValue(r,a):String(r??``);l.push(o)}c.push(o(l))}return c.join(`
6
6
  `)}if(a.type===`row`){let r=t.normalizeRowRange(a.startRow,a.endRow);for(let t=r.startRow;t<=r.endRow;t+=1){let r=n(t);if(!r||s&&!s(r,t))continue;let a=i.map(t=>{let n=e.getCellValue(r,t);return t.formatClipboardValue?t.formatClipboardValue(n,r):String(n??``)});c.push(o(a))}return c.join(`
7
7
  `)}let l=t.normalizeColumnRange(a.startCol,a.endCol);for(let t=0;t<r;t+=1){let r=n(t);if(!r||s&&!s(r,t))continue;let a=[];for(let t=l.startCol;t<=l.endCol;t+=1){let n=i[t];if(!n)continue;let o=e.getCellValue(r,n),s=n.formatClipboardValue?n.formatClipboardValue(o,r):String(o??``);a.push(s)}c.push(o(a))}return c.join(`
8
- `)},c=(t,i,a,o,s,c,l)=>{if(o.length===0)return t;let u=[...t];for(let t=0;t<o.length;t+=1){let d=i(s+t);if(d===void 0)continue;let f=u[d];if(!f)continue;let p=f,m=!1;for(let i=0;i<o[t].length;i+=1){let s=c+i,u=a[s];if(!u||!l(d,s,f,u))continue;let h=o[t][i],g=n.resolveCellParser(u)(h,f);r.decideCellWrite(u,f,g).action!==`reject`&&(p=e.setCellValue(p,u,g),m=!0)}m&&(u[d]=p)}return u},l=(e,t,i,a,o,s)=>{let c=[];for(let l=0;l<i.length;l+=1){let u=a+l,d=e(u);if(d)for(let e=0;e<i[l].length;e+=1){let a=o+e,f=t[a];if(!f||!s(u,a,d,f))continue;let p=n.resolveCellParser(f)(i[l][e],d);r.decideCellWrite(f,d,p).action!==`reject`&&c.push({viewIndex:u,column:f,value:p})}}return c},u=e=>{let{body:t,activeElement:n}=document;if(!t)return!1;let r=document.createElement(`textarea`);r.value=e,r.setAttribute(`readonly`,``),r.style.position=`fixed`,r.style.top=`0`,r.style.left=`-9999px`,r.style.opacity=`0`,t.appendChild(r);let i;try{r.select(),i=document.execCommand(`copy`)}catch{i=!1}finally{t.removeChild(r),n instanceof HTMLElement&&n.focus()}return i},d=async e=>{if(navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),!0}catch{}return u(e)?!0:(console.warn(`[SpreadsheetGrid] クリップボードへのコピーに失敗しました(navigator.clipboard が利用できず、execCommand フォールバックも失敗)。`),!1)};exports.applyClipboardMatrixToRows=c,exports.buildClipboardCellEdits=l,exports.copyTextViaExecCommand=u,exports.escapeTsvField=a,exports.joinTsvRow=o,exports.parseClipboardText=i,exports.serializeSelectionToTsv=s,exports.writeTextToClipboard=d;
8
+ `)},c=(t,i,a,o,s,c,l)=>{if(o.length===0)return t;let u=[...t];for(let t=0;t<o.length;t+=1){let d=s+t,f=i(d);if(f===void 0)continue;let p=u[f];if(!p)continue;let m=p,h=!1;for(let i=0;i<o[t].length;i+=1){let s=c+i,u=a[s];if(!u||!l(f,s,p,u,d))continue;let g=o[t][i],_=n.resolveCellParser(u)(g,p);r.decideCellWrite(u,p,_).action!==`reject`&&(m=e.setCellValue(m,u,_),h=!0)}h&&(u[f]=m)}return u},l=(e,t,i,a,o,s)=>{let c=[];for(let l=0;l<i.length;l+=1){let u=a+l,d=e(u);if(d)for(let e=0;e<i[l].length;e+=1){let a=o+e,f=t[a];if(!f||!s(u,a,d,f))continue;let p=n.resolveCellParser(f)(i[l][e],d);r.decideCellWrite(f,d,p).action!==`reject`&&c.push({viewIndex:u,column:f,value:p})}}return c},u=e=>{let{body:t,activeElement:n}=document;if(!t)return!1;let r=document.createElement(`textarea`);r.value=e,r.setAttribute(`readonly`,``),r.style.position=`fixed`,r.style.top=`0`,r.style.left=`-9999px`,r.style.opacity=`0`,t.appendChild(r);let i;try{r.select(),i=document.execCommand(`copy`)}catch{i=!1}finally{t.removeChild(r),n instanceof HTMLElement&&n.focus()}return i},d=async e=>{if(navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),!0}catch{}return u(e)?!0:(console.warn(`[SpreadsheetGrid] クリップボードへのコピーに失敗しました(navigator.clipboard が利用できず、execCommand フォールバックも失敗)。`),!1)};exports.applyClipboardMatrixToRows=c,exports.buildClipboardCellEdits=l,exports.copyTextViaExecCommand=u,exports.escapeTsvField=a,exports.joinTsvRow=o,exports.parseClipboardText=i,exports.serializeSelectionToTsv=s,exports.writeTextToClipboard=d;
@@ -25,7 +25,7 @@ export declare const serializeSelectionToTsv: <T>(getRow: (viewIndex: number) =>
25
25
  startCol: number;
26
26
  endCol: number;
27
27
  } | null, isRowIncluded?: (row: T, viewRowIndex: number) => boolean) => string;
28
- export declare const applyClipboardMatrixToRows: <T extends object>(rows: T[], resolveSourceIndex: (viewIndex: number) => number | undefined, columns: GridColumn<T>[], matrix: ClipboardMatrix, startRowIndex: number, startColIndex: number, canWriteCell: (originalRowIndex: number, colIndex: number, row: T, column: GridColumn<T>) => boolean) => T[];
28
+ export declare const applyClipboardMatrixToRows: <T extends object>(rows: T[], resolveSourceIndex: (viewIndex: number) => number | undefined, columns: GridColumn<T>[], matrix: ClipboardMatrix, startRowIndex: number, startColIndex: number, canWriteCell: (originalRowIndex: number, colIndex: number, row: T, column: GridColumn<T>, filteredRowIndex: number) => boolean) => T[];
29
29
  export declare const buildClipboardCellEdits: <T extends object>(getRow: (viewIndex: number) => T | undefined, columns: GridColumn<T>[], matrix: ClipboardMatrix, startRowIndex: number, startColIndex: number, canWriteCell: (viewIndex: number, colIndex: number, row: T, column: GridColumn<T>) => boolean) => ServerSideCellEditInput<T>[];
30
30
  export declare const copyTextViaExecCommand: (text: string) => boolean;
31
31
  export declare const writeTextToClipboard: (text: string) => Promise<boolean>;
@@ -91,18 +91,18 @@ var s = (e) => {
91
91
  if (i.length === 0) return e;
92
92
  let u = [...e];
93
93
  for (let e = 0; e < i.length; e += 1) {
94
- let d = n(s + e);
95
- if (d === void 0) continue;
96
- let f = u[d];
97
- if (!f) continue;
98
- let p = f, m = !1;
94
+ let d = s + e, f = n(d);
95
+ if (f === void 0) continue;
96
+ let p = u[f];
97
+ if (!p) continue;
98
+ let m = p, h = !1;
99
99
  for (let n = 0; n < i[e].length; n += 1) {
100
100
  let s = c + n, u = r[s];
101
- if (!u || !l(d, s, f, u)) continue;
102
- let h = i[e][n], g = a(u)(h, f);
103
- o(u, f, g).action !== "reject" && (p = t(p, u, g), m = !0);
101
+ if (!u || !l(f, s, p, u, d)) continue;
102
+ let g = i[e][n], _ = a(u)(g, p);
103
+ o(u, p, _).action !== "reject" && (m = t(m, u, _), h = !0);
104
104
  }
105
- m && (u[d] = p);
105
+ h && (u[f] = m);
106
106
  }
107
107
  return u;
108
108
  }, f = (e, t, n, r, i, s) => {
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=(e,t,n,r,i)=>e.readOnly||i.readOnly||i.editable===!1?!1:e.canEditCell?e.canEditCell(t,n,r,i):!0,t=(e,t)=>t.getValue?t.getValue(e):e[t.key],n=(e,t,n)=>t.setValue?t.setValue(e,n):{...e,[t.key]:n};exports.getCellValue=t,exports.isCellEditable=e,exports.setCellValue=n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=(e,t)=>!e.readOnly&&!t.readOnly&&t.editable!==!1,t=(t,n,r,i,a,o)=>e(t,a)?t.canEditCell?t.canEditCell(n,r,i,a,o??{sourceRowIndex:n,rowKey:n}):!0:!1,n=(e,t)=>({sourceRowIndex:e.getSourceIndex(t)??t,rowKey:e.getRowKey(t)??t}),r=(t,r,i,a,o,s)=>e(t,s)?t.canEditCell?t.canEditCell(i,a,o,s,n(r,i)):!0:!1,i=(e,t)=>t.getValue?t.getValue(e):e[t.key],a=(e,t,n)=>t.setValue?t.setValue(e,n):{...e,[t.key]:n};exports.getCellValue=i,exports.isCellEditable=t,exports.isViewCellEditable=r,exports.resolveCanEditCellContext=n,exports.setCellValue=a;
@@ -1,4 +1,8 @@
1
- import type { GridColumn, SpreadsheetGridProps } from '../model/gridTypes.unbound.js';
2
- export declare const isCellEditable: <T>(props: Pick<SpreadsheetGridProps<T>, "readOnly" | "canEditCell">, rowIndex: number, colIndex: number, row: T, column: GridColumn<T>) => boolean;
1
+ import type { CanEditCellContext, GridColumn, RowModel, SpreadsheetGridProps } from '../model/gridTypes.unbound.js';
2
+ type EditPermissionProps<T> = Pick<SpreadsheetGridProps<T>, 'readOnly' | 'canEditCell'>;
3
+ export declare const isCellEditable: <T>(props: EditPermissionProps<T>, rowIndex: number, colIndex: number, row: T, column: GridColumn<T>, context?: CanEditCellContext) => boolean;
4
+ export declare const resolveCanEditCellContext: <T>(rowModel: Pick<RowModel<T>, "getSourceIndex" | "getRowKey">, viewIndex: number) => CanEditCellContext;
5
+ export declare const isViewCellEditable: <T>(props: EditPermissionProps<T>, rowModel: Pick<RowModel<T>, "getSourceIndex" | "getRowKey">, viewIndex: number, colIndex: number, row: T, column: GridColumn<T>) => boolean;
3
6
  export declare const getCellValue: <T>(row: T, column: GridColumn<T>) => unknown;
4
7
  export declare const setCellValue: <T>(row: T, column: GridColumn<T>, value: unknown) => T;
8
+ export {};
@@ -1,7 +1,13 @@
1
1
  //#region src/utils/permissions.ts
2
- var e = (e, t, n, r, i) => e.readOnly || i.readOnly || i.editable === !1 ? !1 : e.canEditCell ? e.canEditCell(t, n, r, i) : !0, t = (e, t) => t.getValue ? t.getValue(e) : e[t.key], n = (e, t, n) => t.setValue ? t.setValue(e, n) : {
2
+ var e = (e, t) => !e.readOnly && !t.readOnly && t.editable !== !1, t = (t, n, r, i, a, o) => e(t, a) ? t.canEditCell ? t.canEditCell(n, r, i, a, o ?? {
3
+ sourceRowIndex: n,
4
+ rowKey: n
5
+ }) : !0 : !1, n = (e, t) => ({
6
+ sourceRowIndex: e.getSourceIndex(t) ?? t,
7
+ rowKey: e.getRowKey(t) ?? t
8
+ }), r = (t, r, i, a, o, s) => e(t, s) ? t.canEditCell ? t.canEditCell(i, a, o, s, n(r, i)) : !0 : !1, i = (e, t) => t.getValue ? t.getValue(e) : e[t.key], a = (e, t, n) => t.setValue ? t.setValue(e, n) : {
3
9
  ...e,
4
10
  [t.key]: n
5
11
  };
6
12
  //#endregion
7
- export { t as getCellValue, e as isCellEditable, n as setCellValue };
13
+ export { i as getCellValue, t as isCellEditable, r as isViewCellEditable, n as resolveCanEditCellContext, a as setCellValue };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ishibashi0112/spreadsheet-grid-core",
3
- "version": "0.47.1",
3
+ "version": "0.49.0",
4
4
  "description": "SpreadsheetGrid のフレームワーク非依存コア(状態 / 派生値計算 / コマンド / DOM コントローラ)。React 版 @ishibashi0112/spreadsheet-grid と将来の Solid 版が共有します。",
5
5
  "keywords": [
6
6
  "grid",