@ishibashi0112/spreadsheet-grid 0.11.0 → 0.13.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.
- package/README.md +52 -0
- package/dist/SpreadsheetGrid.d.ts +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1380 -1333
- package/dist/logic/autoSizeOnData.d.ts +10 -0
- package/dist/logic/cellOverflowTooltip.d.ts +5 -0
- package/dist/model/gridTypes.d.ts +5 -0
- package/dist/view/GridBodyLayer.d.ts +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,6 +18,9 @@ A high-performance, virtualized spreadsheet / data grid for **React 19**, writte
|
|
|
18
18
|
- Sorting, per-column filters (`text` / `number` / `date` / `select` / `set` / `custom`), and a global filter.
|
|
19
19
|
- In-cell editing and clipboard copy / paste, with range selection and keyboard navigation.
|
|
20
20
|
- Optional auto-height rows for wrapped, variable-height content.
|
|
21
|
+
- Auto-fit column widths to content on data load — `autoSizeColumns="onMount"` (once, on first data) or `"onDataChange"` (every time `rows` changes, e.g. after a form submit). Same engine as the column menu's "Autosize All Columns"; opt individual columns out with `suppressAutoSize`.
|
|
22
|
+
- Full-text tooltip on truncated cells — `showCellOverflowTooltip` shows the full value on hover, but only when the cell is actually clipped (…).
|
|
23
|
+
- Japanese-aware line wrapping — per-column `wordBreak` / `lineBreak`, including `wordBreak: 'auto-phrase'` for phrase-based breaks on Chromium (BudouX). Cross-browser BudouX recipe in the API reference.
|
|
21
24
|
- External height control via `height` / `maxHeight` (e.g. `height="100%"` to follow the parent's height).
|
|
22
25
|
- Both **client-side** (`rows`) and **server-side** (`dataSource`, SSRM) row models.
|
|
23
26
|
- Themeable with CSS custom properties (`--ssg-*`, defined at zero specificity so your overrides always win). Base styles are plain unlayered CSS with single-class specificity, so they survive CSS resets such as Tailwind Preflight; a cascade-layers variant (`style.layer.css`) is also shipped. `className` / `classNames` slots are provided.
|
|
@@ -122,6 +125,29 @@ By default the grid caps its height at `480px` (`max-height`) and scrolls when t
|
|
|
122
125
|
|
|
123
126
|
For `height="100%"` to work, the parent must have a resolved height (its ancestors are sized, and a flex child needs `min-height: 0`). This is standard CSS the library can't resolve for you. `maxHeight` sets an upper bound and can be combined with `height` (explicit height, capped at `maxHeight`).
|
|
124
127
|
|
|
128
|
+
### Auto-height rows
|
|
129
|
+
|
|
130
|
+
Variable row height needs **two switches, both required**: the grid prop `autoHeight` (the master switch, default `false`) **and** at least one column with `autoHeight: true` (that column wraps and drives the row height). A cell grows only when `grid autoHeight && column.autoHeight` are both true. Auto-height is active only up to **50,000 rows**; beyond that it falls back to uniform `rowHeight`. `estimateRowHeight` is the placeholder for off-screen (not-yet-measured) rows — not a cap. See [`API_REFERENCE.md`](./src/components/spreadsheet-grid/API_REFERENCE.md) for details.
|
|
131
|
+
|
|
132
|
+
```tsx
|
|
133
|
+
<SpreadsheetGrid
|
|
134
|
+
rows={rows}
|
|
135
|
+
columns={[{ key: 'note', title: 'Note', width: 320, autoHeight: true }]}
|
|
136
|
+
autoHeight // master switch — without it, the column's autoHeight is ignored
|
|
137
|
+
/>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Auto-sizing columns
|
|
141
|
+
|
|
142
|
+
Set `autoSizeColumns` to fit column widths to their content when data arrives — no imperative calls or effects needed on your side:
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
// Refit every time a new result set replaces `rows` (e.g. after a form submit).
|
|
146
|
+
<SpreadsheetGrid rows={rows} columns={columns} autoSizeColumns="onDataChange" />
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
`'onMount'` fits once on first data; `'onDataChange'` refits whenever the `rows` reference changes; `false` (default) does nothing. It reuses the same measurement as the column menu's "Autosize All Columns", so per-column opt-outs apply: columns with `suppressAutoSize: true` (and `autoHeight: true` columns) keep their `width`. The trigger only reacts to `rows` — filtering, sorting and column reordering do **not** refit — and it writes to internal widths without calling `onColumnsChange`, so it coexists with controlled `columns`. Server-side (`dataSource`) is not supported. See [`API_REFERENCE.md`](./src/components/spreadsheet-grid/API_REFERENCE.md) for details.
|
|
150
|
+
|
|
125
151
|
### Density
|
|
126
152
|
|
|
127
153
|
Set `density` to switch the overall sizing with one prop — `'compact' | 'standard' | 'comfortable'` (default `'standard'`, identical to previous versions):
|
|
@@ -224,6 +250,9 @@ The full prop and type reference lives in [`src/components/spreadsheet-grid/API_
|
|
|
224
250
|
- ソート、列ごとのフィルター(`text` / `number` / `date` / `select` / `set` / `custom`)、グローバルフィルター。
|
|
225
251
|
- セル内編集とクリップボードのコピー/貼り付け、範囲選択、キーボード操作。
|
|
226
252
|
- 折り返し・可変行高に対応する auto-height 行(任意)。
|
|
253
|
+
- データ投入時に列幅を内容へ自動フィット — `autoSizeColumns="onMount"`(初回にデータが載った一度きり)/ `"onDataChange"`(`rows` が変わるたび。フォーム送信結果の差し替え等)。列メニュー「すべての列の幅を自動調整」と同一エンジンで、列個別の除外は `suppressAutoSize`。
|
|
254
|
+
- 省略(…)セルの全文ツールチップ — `showCellOverflowTooltip` でホバー時に全文表示(実際にクリップされているセルのみ)。
|
|
255
|
+
- 日本語対応の折り返し — 列ごとの `wordBreak` / `lineBreak`。`wordBreak: 'auto-phrase'` で Chromium(Chrome / Edge)の文節折り返し(BudouX)。クロスブラウザの BudouX レシピは API リファレンス参照。
|
|
227
256
|
- `height` / `maxHeight` によるスクロールコンテナ高さの外部制御(`height="100%"` で親要素の高さに追従)。
|
|
228
257
|
- **クライアントサイド**(`rows`)と**サーバーサイド**(`dataSource`、SSRM)の両行モデル。
|
|
229
258
|
- CSS カスタムプロパティ(`--ssg-*`。特異度 0 で定義され、利用側の上書きが常に勝ちます)によるテーマ設定。基底スタイルは未レイヤーの単一クラス特異度で、Tailwind Preflight などの CSS リセットに壊されません。カスケードレイヤー版(`style.layer.css`)も同梱。`className` / `classNames` スロットも用意。
|
|
@@ -328,6 +357,29 @@ export function Example() {
|
|
|
328
357
|
|
|
329
358
|
`height="100%"` を効かせるには、**親要素が確定高さを持つ**必要があります(祖先まで高さが確定している/flex 子なら `min-height: 0` が必要)。これは CSS の一般則のため本ライブラリ側では解決できません。`maxHeight` は高さの上限で、`height` と併用できます(明示高さ+上限)。
|
|
330
359
|
|
|
360
|
+
#### 可変行高(auto-height)
|
|
361
|
+
|
|
362
|
+
行高を可変にするには**2つのスイッチが両方必要**です。グリッド props の `autoHeight`(大本のスイッチ・既定 `false`)と、**少なくとも1列に `column.autoHeight: true`**(その列が折り返して行高を駆動)。セルが可変になるのは「グリッド `autoHeight` && 列 `autoHeight`」が両方 true のときだけです。有効なのは **50,000 行以内**で、超えると uniform 行高(`rowHeight`)へフォールバックします。`estimateRowHeight` は画面外(未測定)行の推定値で、上限ではありません。詳細は [`API_REFERENCE.md`](./src/components/spreadsheet-grid/API_REFERENCE.md)。
|
|
363
|
+
|
|
364
|
+
```tsx
|
|
365
|
+
<SpreadsheetGrid
|
|
366
|
+
rows={rows}
|
|
367
|
+
columns={[{ key: 'note', title: '備考', width: 320, autoHeight: true }]}
|
|
368
|
+
autoHeight // 大本のスイッチ(これが無いと列側 autoHeight は無視される)
|
|
369
|
+
/>
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
#### 列幅の自動調整(autoSizeColumns)
|
|
373
|
+
|
|
374
|
+
`autoSizeColumns` を渡すと、データ投入時に列幅を内容へ自動フィットします(利用側でトークンや effect は不要):
|
|
375
|
+
|
|
376
|
+
```tsx
|
|
377
|
+
// フォーム送信結果などで rows を丸ごと差し替えるたびに合わせ直す。
|
|
378
|
+
<SpreadsheetGrid rows={rows} columns={columns} autoSizeColumns="onDataChange" />
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
`'onMount'` は初回にデータが載った一度きり、`'onDataChange'` は `rows`(参照)が変わるたび、`false`(既定)は無効です。計測は列メニュー「すべての列の幅を自動調整」と同一エンジンのため、列個別の除外がそのまま効きます — `suppressAutoSize: true` の列(および `autoHeight: true` の列)は `width` を維持します。発火 signal は `rows` のみで、フィルター / ソート / 列並べ替えでは**再フィットしません**。フィット幅は内部の列幅 state に反映され `onColumnsChange` を呼ばないため、controlled な `columns` とも競合しません。serverSide(`dataSource`)では無効です。詳細は [`API_REFERENCE.md`](./src/components/spreadsheet-grid/API_REFERENCE.md)。
|
|
382
|
+
|
|
331
383
|
#### 密度(density)
|
|
332
384
|
|
|
333
385
|
`density` プロップ 1 つで全体のサイズ感を切り替えられます — `'compact' | 'standard' | 'comfortable'`(既定 `'standard'` = 従来と同値):
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import './styles.css';
|
|
2
2
|
import type { SpreadsheetGridProps } from './model/gridTypes';
|
|
3
|
-
export declare function SpreadsheetGrid<T extends object>({ rows, dataSource, serverSideRefreshToken, columns, onRowsChange, onColumnsChange, rowKeyGetter, createRow, createOverflowColumn, rowHeight: rowHeightProp, autoHeight, estimateRowHeight, headerHeight: headerHeightProp, density, theme, rowHeaderWidth, height, maxHeight, readOnly, dimReadOnlyCells, canEditCell, enableRangeSelection, enableRowSelection, rowSelectionMode, enableSelectAllRows: enableSelectAllRowsProp, rowSelection: rowSelectionProp, selectedRowKeys: selectedRowKeysProp, onRowSelectionChange, enableGlobalFilter, enableColumnFilter, enableSorting, enableColumnResize, enableRowHover, enableColumnHeaderHover, enableColumnMenu, noMatchingRowsText, noRowsText, showTopBar, showBottomBar, showTopBarSummary, showTopBarFilter, globalFilterPlaceholder, globalFilterIcon, showTopBarCounts, showBottomBarCounts, showFilterChipBar, renderTopBar, renderBottomBar, className, classNames, getRowClassName, enableContextMenu, getContextMenuItems, onContextMenuOpen, ref, onStateChange, }: SpreadsheetGridProps<T>): import("react").JSX.Element;
|
|
3
|
+
export declare function SpreadsheetGrid<T extends object>({ rows, dataSource, serverSideRefreshToken, columns, onRowsChange, onColumnsChange, rowKeyGetter, createRow, createOverflowColumn, rowHeight: rowHeightProp, autoHeight, estimateRowHeight, headerHeight: headerHeightProp, density, theme, rowHeaderWidth, height, maxHeight, readOnly, dimReadOnlyCells, canEditCell, enableRangeSelection, enableRowSelection, rowSelectionMode, enableSelectAllRows: enableSelectAllRowsProp, rowSelection: rowSelectionProp, selectedRowKeys: selectedRowKeysProp, onRowSelectionChange, enableGlobalFilter, enableColumnFilter, enableSorting, enableColumnResize, autoSizeColumns, showCellOverflowTooltip, enableRowHover, enableColumnHeaderHover, enableColumnMenu, noMatchingRowsText, noRowsText, showTopBar, showBottomBar, showTopBarSummary, showTopBarFilter, globalFilterPlaceholder, globalFilterIcon, showTopBarCounts, showBottomBarCounts, showFilterChipBar, renderTopBar, renderBottomBar, className, classNames, getRowClassName, enableContextMenu, getContextMenuItems, onContextMenuOpen, ref, onStateChange, }: SpreadsheetGridProps<T>): import("react").JSX.Element;
|