@ishibashi0112/spreadsheet-grid 0.41.0 → 0.41.1
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/API_REFERENCE.md +1349 -0
- package/README.md +92 -0
- package/dist/SpreadsheetGrid.d.ts +39 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +2017 -2019
- package/dist/model/gridTypes.d.ts +13 -0
- package/dist/style.css +1 -1
- package/package.json +4 -3
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# @ishibashi0112/spreadsheet-grid
|
|
2
|
+
|
|
3
|
+
A virtualized spreadsheet / data grid for React 19 (~1M rows, pinned columns, Excel-like editing / selection / clipboard, filters & sorting, client-side and server-side row models). 日本語は下にあります。
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @ishibashi0112/spreadsheet-grid
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peer dependencies: `react` / `react-dom` `>= 19`. Import the CSS once:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import '@ishibashi0112/spreadsheet-grid/style.css'
|
|
15
|
+
// or, if you use CSS cascade layers (e.g. Tailwind v4): '@ishibashi0112/spreadsheet-grid/style.layer.css'
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quick start
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { useState } from 'react'
|
|
22
|
+
import { SpreadsheetGrid, type GridColumn } from '@ishibashi0112/spreadsheet-grid'
|
|
23
|
+
import '@ishibashi0112/spreadsheet-grid/style.css'
|
|
24
|
+
|
|
25
|
+
type Row = { id: number; name: string }
|
|
26
|
+
const columns: GridColumn<Row>[] = [{ key: 'name', title: 'Name', width: 200, editable: true }]
|
|
27
|
+
|
|
28
|
+
export function App() {
|
|
29
|
+
const [rows, setRows] = useState<Row[]>([{ id: 1, name: 'alpha' }])
|
|
30
|
+
return (
|
|
31
|
+
<div style={{ height: 600 }}>
|
|
32
|
+
<SpreadsheetGrid
|
|
33
|
+
rows={rows}
|
|
34
|
+
columns={columns}
|
|
35
|
+
onRowsChange={setRows}
|
|
36
|
+
rowKeyGetter={(row) => row.id}
|
|
37
|
+
height="100%"
|
|
38
|
+
/>
|
|
39
|
+
</div>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Documentation in this package
|
|
45
|
+
|
|
46
|
+
Everything below ships inside the npm package, so it is available offline (for example to coding agents reading `node_modules`).
|
|
47
|
+
|
|
48
|
+
| What | Where |
|
|
49
|
+
| --- | --- |
|
|
50
|
+
| Full API reference — props, column options, imperative handle (`ref`), recipes (Japanese) | `API_REFERENCE.md` in this package |
|
|
51
|
+
| Per-field docs (shown on hover) | JSDoc in the type definitions. Field docs live in `@ishibashi0112/spreadsheet-grid-core/dist/model/gridTypes.core.d.ts` and match the tables in `API_REFERENCE.md` |
|
|
52
|
+
| Guides, demos, design notes | [GitHub README](https://github.com/ishibashi0112/datasheet-grid#readme) and the `website/` docs in the repository |
|
|
53
|
+
|
|
54
|
+
## Rules that are easy to get wrong
|
|
55
|
+
|
|
56
|
+
- **Import the CSS.** Without `style.css` the grid is unstyled and its scroll area does not work.
|
|
57
|
+
- **State is controlled.** Edits come back through `onRowsChange` as a new array; pass that array back to `rows` as-is (re-creating it, e.g. with `map`, clears the undo history).
|
|
58
|
+
- **Row keys.** Return a stable key from `rowKeyGetter` (the default is the row index).
|
|
59
|
+
- **`rows` or `dataSource`.** `rows` is the client-side row model; `dataSource` switches to the server-side row model. They are mutually exclusive.
|
|
60
|
+
- **Height.** Use the `height` prop, not `style.height` on the root. A value containing `%` (`'100%'`) sizes the **whole grid including its bars** and needs a parent with a definite height; a number sizes the **scroll area only**. Without `height`, the scroll area is capped at `480px` (`maxHeight`).
|
|
61
|
+
- **Imperative API.** Pass `ref` (React 19 ref-as-prop, no `forwardRef`) to get a `SpreadsheetGridHandle<T>`.
|
|
62
|
+
- **Next.js App Router.** Render the grid from a Client Component (a file with `'use client'`); the package does not add the directive.
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
MIT
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## 日本語
|
|
71
|
+
|
|
72
|
+
React 19 向けの仮想化スプレッドシート / データグリッドです(約 100 万行・列固定・Excel ライクな編集 / 選択 / クリップボード・フィルター / ソート・クライアントサイド / サーバーサイド行モデル)。
|
|
73
|
+
|
|
74
|
+
### このパッケージに同梱のドキュメント
|
|
75
|
+
|
|
76
|
+
npm パッケージに同梱されているため、オフライン(`node_modules` を読むコーディングエージェント等)でも参照できます。
|
|
77
|
+
|
|
78
|
+
| 内容 | 場所 |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
| API リファレンス全体(props / 列定義 / 命令的 API(`ref`)/ レシピ) | 本パッケージ直下の `API_REFERENCE.md` |
|
|
81
|
+
| フィールドごとの説明(ホバーで表示) | 型定義の JSDoc。各フィールドの説明は `@ishibashi0112/spreadsheet-grid-core/dist/model/gridTypes.core.d.ts` にあり、`API_REFERENCE.md` の表と同じ内容 |
|
|
82
|
+
| ガイド / デモ / 設計メモ | [GitHub の README](https://github.com/ishibashi0112/datasheet-grid#readme) とリポジトリの `website/` |
|
|
83
|
+
|
|
84
|
+
### 間違えやすいルール
|
|
85
|
+
|
|
86
|
+
- **CSS を読み込む。** `style.css` が無いとスタイルが当たらず、スクロール領域も機能しません。
|
|
87
|
+
- **状態は controlled。** 編集結果は `onRowsChange` が新しい配列で返します。受け取った配列をそのまま `rows` へ戻してください(`map` 等で作り直すと undo 履歴が消えます)。
|
|
88
|
+
- **行キー。** `rowKeyGetter` で安定したキーを返してください(既定は行 index)。
|
|
89
|
+
- **`rows` か `dataSource`。** `rows` はクライアントサイド行モデル、`dataSource` を渡すとサーバーサイド行モデルです。両者は排他です。
|
|
90
|
+
- **高さ。** ルートの `style.height` ではなく `height` prop で指定します。`%` を含む値(`'100%'`)は**バーを含むグリッド全体**の高さで、親要素に確定高さが必要です。数値は**スクロール領域だけ**の高さです。`height` 未指定時のスクロール領域は `480px`(`maxHeight`)が上限です。
|
|
91
|
+
- **命令的 API。** `ref`(React 19 の ref-as-prop。`forwardRef` は不要)で `SpreadsheetGridHandle<T>` を受け取ります。
|
|
92
|
+
- **Next.js App Router。** クライアントコンポーネント(`'use client'` のファイル)から描画してください。パッケージ側はディレクティブを付けていません。
|
|
@@ -1,2 +1,41 @@
|
|
|
1
1
|
import type { SpreadsheetGridProps } from './model/gridTypes';
|
|
2
|
+
/**
|
|
3
|
+
* 仮想化スプレッドシート / データグリッドです。データは clientSide なら `rows`、serverSide(SSRM)なら
|
|
4
|
+
* `dataSource` で渡します(両者は排他)。
|
|
5
|
+
*
|
|
6
|
+
* - CSS の読み込みが必要です: `import '@ishibashi0112/spreadsheet-grid/style.css'`
|
|
7
|
+
* (カスケードレイヤー運用なら `style.layer.css`)。
|
|
8
|
+
* - 状態は controlled です。編集結果は `onRowsChange` が新しい配列で返すので、受け取った配列をそのまま
|
|
9
|
+
* `rows` へ戻してください(作り直すと undo 履歴が消えます)。
|
|
10
|
+
* - 行キーは `rowKeyGetter` で安定した値を返してください(既定は index)。
|
|
11
|
+
* - 高さは `height` prop で指定します。`'100%'` でバー込みのグリッド全体が親に収まります(親は確定高さが
|
|
12
|
+
* 必要)。数値はスクロール領域の高さです。
|
|
13
|
+
* - 命令的 API は `ref`(`SpreadsheetGridHandle<T>`)で受け取ります。
|
|
14
|
+
* - props / 列定義 / 命令的 API の全説明は同梱の `API_REFERENCE.md` と各 props の JSDoc にあります。
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* import { useState } from 'react';
|
|
19
|
+
* import { SpreadsheetGrid, type GridColumn } from '@ishibashi0112/spreadsheet-grid';
|
|
20
|
+
* import '@ishibashi0112/spreadsheet-grid/style.css';
|
|
21
|
+
*
|
|
22
|
+
* type Row = { id: number; name: string };
|
|
23
|
+
* const columns: GridColumn<Row>[] = [{ key: 'name', title: '名前', width: 200, editable: true }];
|
|
24
|
+
*
|
|
25
|
+
* export function App() {
|
|
26
|
+
* const [rows, setRows] = useState<Row[]>([{ id: 1, name: 'alpha' }]);
|
|
27
|
+
* return (
|
|
28
|
+
* <div style={{ height: 600 }}>
|
|
29
|
+
* <SpreadsheetGrid
|
|
30
|
+
* rows={rows}
|
|
31
|
+
* columns={columns}
|
|
32
|
+
* onRowsChange={setRows}
|
|
33
|
+
* rowKeyGetter={(row) => row.id}
|
|
34
|
+
* height="100%"
|
|
35
|
+
* />
|
|
36
|
+
* </div>
|
|
37
|
+
* );
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
2
41
|
export declare function SpreadsheetGrid<T extends object>({ rows: rowsProp, dataSource, serverSideRefreshToken, onServerSideLoadError, onServerSideWriteError, columns: columnsProp, onRowsChange, onColumnsChange, rowKeyGetter, isRowExportable, createRow, createOverflowColumn, rowHeight: rowHeightProp, autoHeight, estimateRowHeight, headerHeight: headerHeightProp, density, theme, rowHeaderWidth, height, maxHeight, readOnly, dimReadOnlyCells, canEditCell: canEditCellProp, enableUndoRedo, enableClearOnDelete, editorEnterMove, undoHistoryLimit, onUndoRedoStateChange, enableRangeSelection, enableRowSelection, rowSelectionMode, enableSelectAllRows: enableSelectAllRowsProp, rowSelection: rowSelectionProp, selectedRowKeys: selectedRowKeysProp, onRowSelectionChange, enableGlobalFilter, enableColumnFilter, renderFilterDateInput, getFilterOptions, enableSorting, manualFiltering, manualSorting, enableColumnResize, autoSizeColumns, showCellOverflowTooltip, showValidationMarks, enableRowHover, enableColumnHeaderHover, hoveredRowIndex: hoveredRowIndexProp, onHoveredRowChange, enableColumnMenu, noMatchingRowsText, noRowsText, showTopBar, showBottomBar, showTopBarSummary, showTopBarFilter, globalFilterPlaceholder, globalFilterIcon, showTopBarCounts, showBottomBarCounts, showFilterChipBar, renderTopBar, renderBottomBar, className, style, classNames, getRowClassName, detailRow, onExpandedDetailRowKeysChange, labelRow, enableRowDrag, isRowDraggable, onRowMove, enableContextMenu, getContextMenuItems, onContextMenuOpen, scrollHint, ref, onStateChange, onFiltersChange, onSortChange, onScroll, }: SpreadsheetGridProps<T>): import("react").JSX.Element;
|