@ishibashi0112/spreadsheet-grid 0.11.0 → 0.12.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 +24 -0
- package/dist/SpreadsheetGrid.d.ts +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1070 -1038
- package/dist/logic/autoSizeOnData.d.ts +10 -0
- package/dist/model/gridTypes.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,6 +18,7 @@ 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`.
|
|
21
22
|
- External height control via `height` / `maxHeight` (e.g. `height="100%"` to follow the parent's height).
|
|
22
23
|
- Both **client-side** (`rows`) and **server-side** (`dataSource`, SSRM) row models.
|
|
23
24
|
- 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 +123,17 @@ By default the grid caps its height at `480px` (`max-height`) and scrolls when t
|
|
|
122
123
|
|
|
123
124
|
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
125
|
|
|
126
|
+
### Auto-sizing columns
|
|
127
|
+
|
|
128
|
+
Set `autoSizeColumns` to fit column widths to their content when data arrives — no imperative calls or effects needed on your side:
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
// Refit every time a new result set replaces `rows` (e.g. after a form submit).
|
|
132
|
+
<SpreadsheetGrid rows={rows} columns={columns} autoSizeColumns="onDataChange" />
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
`'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.
|
|
136
|
+
|
|
125
137
|
### Density
|
|
126
138
|
|
|
127
139
|
Set `density` to switch the overall sizing with one prop — `'compact' | 'standard' | 'comfortable'` (default `'standard'`, identical to previous versions):
|
|
@@ -224,6 +236,7 @@ The full prop and type reference lives in [`src/components/spreadsheet-grid/API_
|
|
|
224
236
|
- ソート、列ごとのフィルター(`text` / `number` / `date` / `select` / `set` / `custom`)、グローバルフィルター。
|
|
225
237
|
- セル内編集とクリップボードのコピー/貼り付け、範囲選択、キーボード操作。
|
|
226
238
|
- 折り返し・可変行高に対応する auto-height 行(任意)。
|
|
239
|
+
- データ投入時に列幅を内容へ自動フィット — `autoSizeColumns="onMount"`(初回にデータが載った一度きり)/ `"onDataChange"`(`rows` が変わるたび。フォーム送信結果の差し替え等)。列メニュー「すべての列の幅を自動調整」と同一エンジンで、列個別の除外は `suppressAutoSize`。
|
|
227
240
|
- `height` / `maxHeight` によるスクロールコンテナ高さの外部制御(`height="100%"` で親要素の高さに追従)。
|
|
228
241
|
- **クライアントサイド**(`rows`)と**サーバーサイド**(`dataSource`、SSRM)の両行モデル。
|
|
229
242
|
- CSS カスタムプロパティ(`--ssg-*`。特異度 0 で定義され、利用側の上書きが常に勝ちます)によるテーマ設定。基底スタイルは未レイヤーの単一クラス特異度で、Tailwind Preflight などの CSS リセットに壊されません。カスケードレイヤー版(`style.layer.css`)も同梱。`className` / `classNames` スロットも用意。
|
|
@@ -328,6 +341,17 @@ export function Example() {
|
|
|
328
341
|
|
|
329
342
|
`height="100%"` を効かせるには、**親要素が確定高さを持つ**必要があります(祖先まで高さが確定している/flex 子なら `min-height: 0` が必要)。これは CSS の一般則のため本ライブラリ側では解決できません。`maxHeight` は高さの上限で、`height` と併用できます(明示高さ+上限)。
|
|
330
343
|
|
|
344
|
+
#### 列幅の自動調整(autoSizeColumns)
|
|
345
|
+
|
|
346
|
+
`autoSizeColumns` を渡すと、データ投入時に列幅を内容へ自動フィットします(利用側でトークンや effect は不要):
|
|
347
|
+
|
|
348
|
+
```tsx
|
|
349
|
+
// フォーム送信結果などで rows を丸ごと差し替えるたびに合わせ直す。
|
|
350
|
+
<SpreadsheetGrid rows={rows} columns={columns} autoSizeColumns="onDataChange" />
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
`'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)。
|
|
354
|
+
|
|
331
355
|
#### 密度(density)
|
|
332
356
|
|
|
333
357
|
`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, 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;
|