@ishibashi0112/spreadsheet-grid-solid 1.4.1 → 1.5.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/API_REFERENCE.md +25 -8
- package/README.md +7 -7
- package/dist/index.js +2052 -1951
- package/dist/primitives/reusedRow.d.ts +2 -0
- package/dist/primitives/rowSlots.d.ts +12 -0
- package/dist/primitives/serverSide.d.ts +1 -0
- package/dist/source/index.jsx +179 -35
- package/dist/style.css +1 -1
- package/dist/style.layer.css +1 -1
- package/package.json +3 -3
- package/skills/spreadsheet-grid-solid/SKILL.md +1 -1
package/API_REFERENCE.md
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
| `onRowsChange` | `(nextRows: T[]) => void` | — | 行が変化したとき呼ばれる(rows を controlled にする)。 |
|
|
26
26
|
| `dataSource` | `ServerSideDataSource<T>` | — | serverSide(SSRM)モードのデータ供給口。指定すると可視窓近傍のブロックだけを `getRows` で都度取得し、`rows` 系の clientSide パイプラインをバイパスする。`updateRows`(任意)を持たせるとセル編集の書き戻し(楽観更新つき)が有効になる(「セル編集の書き戻し」節)。 |
|
|
27
27
|
| `serverSideRefreshToken` | `number` | — | serverSide のソフトリフレッシュ用トークン。値を増やすと、クエリ(フィルター/ソート/グローバル)を変えずにキャッシュを破棄して現在の可視レンジをサーバから取り直す。スクロール位置は保持し、件数は到着ブロックの `totalRowCount` で追従する(clientSide では無視)。命令的に呼びたい場合は同挙動のハンドル `refreshServerSide()` を使う。 |
|
|
28
|
+
| `serverSideRefetch` | `'skeleton' \| 'keep'` | `'skeleton'` | serverSide で条件(ソート / 列フィルター / グローバルフィルター)が変わったときと、取り直し(`refreshServerSide()` / `serverSideRefreshToken`)のときの見せ方(1.5.0 から)。`'skeleton'` は読み込み中の行(1.4 までと同じ)。`'keep'` は新しい行が届くまで前の行を薄くして見せ続け(ルートに `.ssg-root--refetching`)、列見出しの下に動く線(`.ssg-refetch-bar`)を出し、表(`role="grid"`)に `aria-busy="true"` を付ける。見えている範囲の新しい行がそろったら(そのブロックの取得に失敗したら)一度に差し替える(一部だけ新しい行が混ざらない)。前の行を見せている間は編集・貼り付け・削除・フィルハンドルをしない(行の位置が新しい結果と合わないため)。初めての取得と、前の行が無いときは読み込み中の行。保存中の書き込みがあるときは、決着してから取り直す(1.4 までと同じ)。色はトークン `--ssg-refetch-row-opacity` / `--ssg-refetch-bar` / `--ssg-refetch-bar-track`。`motion` が `'off'` なら線は動かない。clientSide では無視。詳細は「取り直しの間の見せ方」節。 |
|
|
28
29
|
| `onServerSideLoadError` | `(error, params) => void` | — | serverSide の `getRows` が reject したときの通知(abort は正常キャンセルのため通知しない)。`params` は失敗した要求の view 空間レンジ `{ startIndex, endIndex }`。グリッド内蔵のエラーバー(再試行 UI)とは独立に呼ばれる(利用側トースト / ログ用)。インライン関数可(latest-ref 経由で読む)。 |
|
|
29
30
|
| `onServerSideWriteError` | `(error, params) => void` | — | serverSide の `dataSource.updateRows` が reject したときの通知。グリッド側は楽観更新をロールバック済みで、`params.updates` に失敗して元に戻した行更新(`rowKey` / `changes` / `previousRow`)が入る(利用側トースト / リトライ導線用。`changes` は元に戻したセルだけで、後から同じセルを変えた編集で上書き済みの変更は入らない。`row` は今の表示の行に元に戻した変更を当てた行で、同じ行の新しい編集の値を含む)。グリッド内蔵の保存失敗バーとは独立に呼ばれる。インライン関数可(latest-ref 経由で読む)。詳細は「セル編集の書き戻し」節。 |
|
|
30
31
|
| `onColumnsChange` | `(nextColumns: GridColumn<T>[]) => void` | — | 列が変化したとき呼ばれる。列メニューの固定切替はこれが指定されている場合のみ反映。列の並べ替え(ヘッダーのドラッグ / 列パネル)と `applyState` で渡る `nextColumns` は、配列順が固定列ごと(左固定 → 中央 → 右固定)に並べ直される(画面上の列順は変わらない。例: 右固定列の後ろに宣言した列があると、右固定列が配列の末尾へ移る)。列メニューの固定切替は配列順を変えず `pinned` だけを更新する。指定が無いと、列メニューの固定 / リセットと、ツールパネルの「列」タブの表示 / 非表示・並べ替え・リセットは押せない(今の状態は見える)。押せない理由のツールチップは利用者向けの文(「この表では列の固定を変えられません」など。1.0.2 から。1.0.1 までは「onColumnsChange 未指定のため…」)。 |
|
|
@@ -2206,9 +2207,23 @@ set / select / 複合(numberSet / textSet / dateSet)の候補集合はクライ
|
|
|
2206
2207
|
|
|
2207
2208
|
- **`queryKey` 変化との違い**: フィルター/ソート/グローバルフィルターの変更は結果セットの総入れ替えなので**先頭へスクロールリセット**してキャッシュを全破棄し block 0 から取り直す。一方ソフトリフレッシュは**スクロール位置を保持**したままキャッシュを破棄し、**現在の可視レンジ**を即時(debounce なし)取り直す。
|
|
2208
2209
|
- **件数**: リフレッシュ時に件数はリセットせず、到着ブロックの `totalRowCount` で更新する。外部更新で件数が増減していれば縦スクロール空間が追従する。可視レンジ未確立や件数 0(空結果)からのリフレッシュでは block 0 をブートストラップとして取り直す(空になったテーブルがサーバ側でデータを得た後も復帰できる)。
|
|
2209
|
-
- **挙動メモ**: 取り直し中は対象行が一瞬スケルトン表示になる(purge → 再取得)。`refreshToken` は単調増加で運用する(値が変わったときだけ取り直す)。初回 mount では発火しない。
|
|
2210
|
+
- **挙動メモ**: 取り直し中は対象行が一瞬スケルトン表示になる(purge → 再取得)。前の行を見せたまま取り直すには `serverSideRefetch="keep"`(下の「取り直しの間の見せ方」節)。`refreshToken` は単調増加で運用する(値が変わったときだけ取り直す)。初回 mount では発火しない。
|
|
2210
2211
|
- **用途**: 外部での編集/追加削除(mutation)後の反映トリガーとして使う想定。グリッド上の**セル編集**は `dataSource.updateRows`(下の「セル編集の書き戻し」節)で直接書き戻せるため本機能は不要。**行の追加削除**は書き戻し API を持たないため、「サーバへ反映 → `refreshServerSide()`」の運用に寄せる(AG Grid も実質この形)。
|
|
2211
2212
|
|
|
2213
|
+
### 取り直しの間の見せ方(`serverSideRefetch`)
|
|
2214
|
+
|
|
2215
|
+
条件(ソート / 列フィルター / グローバルフィルター)を変えたときと、取り直し(`refreshServerSide()` / `serverSideRefreshToken`)のとき、既定(`'skeleton'`)では行が読み込み中の行(スケルトン)になる。`serverSideRefetch="keep"` にすると、新しい行が届くまで前の行を薄くして見せ続ける(1.5.0 から)。
|
|
2216
|
+
|
|
2217
|
+
```tsx
|
|
2218
|
+
<SpreadsheetGrid dataSource={dataSource} columns={columns} rowKeyGetter={(row) => row.id} serverSideRefetch="keep" />
|
|
2219
|
+
```
|
|
2220
|
+
|
|
2221
|
+
- **見せ方**: 前の行は `--ssg-refetch-row-opacity`(既定 `0.45`)の濃さに見え(本体の見えている所に、セルの背景色の面を重ねて薄くする。行の要素の `opacity` は変えないので、固定列の下に中央の列が透けない)、列見出しの下に左から右へ流れる線(`.ssg-refetch-bar`。色は `--ssg-refetch-bar`、下地は `--ssg-refetch-bar-track`)が出る。ルートには `.ssg-root--refetching`、表(`role="grid"`)には `aria-busy="true"` が付く。`motion` が `'off'` なら線は動かない(全幅の止まった線)。
|
|
2222
|
+
- **差し替えるとき**: 見えている範囲(描いている行)のブロックがすべて新しい条件で届いたら、一度に差し替える(件数も新しい `totalRowCount` に)。届いたブロックから順に混ぜることはしない(上が新しい並び、下が古い並び、のような表を見せないため)。見えている範囲のブロックの取得に失敗したときは、前の行をやめて失敗の表示(読み込み中の行 + エラーバー)にする。範囲の外のブロックは待たない。
|
|
2223
|
+
- **スクロール**: 条件が変わったときは 1.4 までと同じく先頭へ戻る(前の行の先頭を薄く見せる)。取り直しはスクロール位置を保つ。前の行を見せている間にスクロールした先が前の行の読み込み済みのブロックの外なら、そこは読み込み中の行になる。
|
|
2224
|
+
- **編集**: 前の行を見せている間は、編集の開始・貼り付け・削除・フィルハンドルをしない(前の行の位置が新しい結果と合わないため。編集中に取り直しが始まったときは、その編集を確定しても書かない)。セルの読み取り専用の印・`aria-readonly`・`renderCell` の `readOnly` は変えない。前の行を見せ始める前の保存中の書き込みは、決着してから取り直す(1.4 までと同じ)。その値は保存できるまで前の行に出し続ける。
|
|
2225
|
+
- **前の行が無いとき**: 初めての取得と、まだ 1 つもブロックが届いていないときは、`'keep'` でも読み込み中の行になる。前の行を見せている間にまた条件を変えたときは、最初の前の行を見せたまま、新しい条件で取り直す(途中まで届いた行は捨てる)。
|
|
2226
|
+
|
|
2212
2227
|
### getRows 失敗時のエラー表示とリトライ
|
|
2213
2228
|
|
|
2214
2229
|
`getRows` が reject する(abort 以外。Promise を返す前に同期で throw したときも同じ)と、失敗ブロックの行はスケルトンのまま残り、グリッド下部中央に**エラーバー**(「行の取得に失敗しました(N ブロック)」+ 再試行 / 閉じる)が表示される。
|
|
@@ -2287,8 +2302,8 @@ export const OrdersTable = () => <Grid columns={columns} dataSource={dataSource}
|
|
|
2287
2302
|
| `filtering` | `filteringFeature` | グローバル / 列フィルター、フィルターのポップオーバー(遅延読み込み)、チップバー、非同期の候補(`enableGlobalFilter` / `enableColumnFilter` / `columns[].filterType` / `getFilterOptions` / `showFilterChipBar` / `onFiltersChange` / `manualFiltering` ほか) | +13.8KB(+ 遅延 8.2KB) |
|
|
2288
2303
|
| `fillHandle` | `fillHandleFeature` | フィルハンドル(`fillHandle`) | +9.3KB |
|
|
2289
2304
|
| `columnReorder` | `columnReorderFeature` | 列ヘッダーのドラッグ並べ替え(`onColumnsChange` 指定時 / `columnDragMotion`) | +6.0KB |
|
|
2290
|
-
| `rowDrag` | `rowDragFeature` | 行のドラッグ並べ替え(`enableRowDrag` / `isRowDraggable` / `onRowMove` / `canDropRow` / `rowDragMotion`。ハンドルの `moveRow()` は本体にあるので無くても使える) | +
|
|
2291
|
-
| `serverSide` | `serverSideFeature` | サーバーサイド行モデル(SSRM)の読み取りと書き戻し、保存状態の表示(`dataSource` / `serverSideRefreshToken` / `showSaveStatus` ほか) | +
|
|
2305
|
+
| `rowDrag` | `rowDragFeature` | 行のドラッグ並べ替え(`enableRowDrag` / `isRowDraggable` / `onRowMove` / `canDropRow` / `rowDragMotion`。ハンドルの `moveRow()` は本体にあるので無くても使える) | +5.3KB |
|
|
2306
|
+
| `serverSide` | `serverSideFeature` | サーバーサイド行モデル(SSRM)の読み取りと書き戻し、保存状態の表示(`dataSource` / `serverSideRefreshToken` / `showSaveStatus` ほか) | +5.1KB |
|
|
2292
2307
|
| `columnMenu` | `columnMenuFeature` | 列メニュー(ソート・固定。幅の自動調整は `columnAutosize`、フィルターの入口は `filtering`、パネルの入口は `toolPanel` があるとき。`enableColumnMenu`) | +3.5KB |
|
|
2293
2308
|
| `find` | `findFeature` | セル内検索(`find` / `onFindChange`) | +2.9KB |
|
|
2294
2309
|
| `grouping` | `groupingFeature` | 行グルーピングと集計(`columns[].rowGroup` / `aggFunc`) | +2.7KB |
|
|
@@ -2300,20 +2315,20 @@ export const OrdersTable = () => <Grid columns={columns} dataSource={dataSource}
|
|
|
2300
2315
|
| `toolPanel` | `toolPanelFeature` | ツールパネル(フィルター管理 / 列の表示 / 並び替え。部品は遅延読み込み) | +2.0KB(+ 遅延 7.1KB) |
|
|
2301
2316
|
| `labelRow` | `labelRowFeature` | ラベル行(`labelRow`) | +1.8KB |
|
|
2302
2317
|
| `totalRow` | `totalRowFeature` | 合計行(`totalRow`) | +1.7KB |
|
|
2318
|
+
| `motionExtras` | `motionExtrasFeature` | 変更のハイライト、コピー範囲の点線、十字ホバー(`highlightChanges` / `showCopyRange` / `hoverHighlight`) | +1.5KB |
|
|
2303
2319
|
| `conditionalFormat` | `conditionalFormatFeature` | 条件付き書式とチップ(`columns[].conditionalFormat`) | +1.3KB |
|
|
2304
2320
|
| `pinnedRows` | `pinnedRowsFeature` | 固定行(`pinnedTopRows` / `pinnedBottomRows`) | +1.3KB |
|
|
2305
2321
|
| `imeDirectInput` | `imeDirectInputFeature` | IME オンのままの直接入力(`imeDirectInput`) | +1.2KB |
|
|
2306
|
-
| `motionExtras` | `motionExtrasFeature` | 変更のハイライト、コピー範囲の点線、十字ホバー(`highlightChanges` / `showCopyRange` / `hoverHighlight`) | +1.2KB |
|
|
2307
2322
|
| `autoHeight` | `autoHeightFeature` | 行の高さの実測(`autoHeight` / `columns[].autoHeight`) | +1.2KB |
|
|
2308
2323
|
|
|
2309
2324
|
サイズ(初期読み込みの JS の gzip。esbuild で minify・React は外部化・`@tanstack/virtual-core` 込み。2026-11-23 の dist で計測):
|
|
2310
2325
|
|
|
2311
2326
|
| 構成 | 初期 JS(gzip) |
|
|
2312
2327
|
| --- | --- |
|
|
2313
|
-
| 全部入り(`SpreadsheetGrid`) | 約
|
|
2314
|
-
| `/lite` 機能なし | 約
|
|
2328
|
+
| 全部入り(`SpreadsheetGrid`) | 約 155KB |
|
|
2329
|
+
| `/lite` 機能なし | 約 91KB |
|
|
2315
2330
|
| `/lite` + `standardFeatures` | 約 114KB |
|
|
2316
|
-
| `/lite` + `standardFeatures` + `serverSideFeature` | 約
|
|
2331
|
+
| `/lite` + `standardFeatures` + `serverSideFeature` | 約 119KB |
|
|
2317
2332
|
|
|
2318
2333
|
- 各機能の目安は「機能なし」に 1 つだけ足したときの増え方で、組み合わせると共通部分のぶん合計より少し小さくなる。バンドラーによって数 KB 前後する(0.61.0 の全部入りの実測で、Vite 8(Rolldown)は esbuild より約 1.5KB 小さく、Vite 7(Rollup)はほぼ同じ。Next.js 16 では webpack が Turbopack より約 4KB 大きい)。
|
|
2319
2334
|
- 使わない機能がバンドルから落ちることは、Vite 8・webpack 5・Next.js 16(既定の Turbopack)・esbuild で確かめている(バンドラーが `package.json` の `sideEffects` と `/* @__PURE__ */` を解釈する必要がある)。
|
|
@@ -2733,6 +2748,7 @@ function Grid(props: SpreadsheetGridProps<Row>) {
|
|
|
2733
2748
|
| --- | --- |
|
|
2734
2749
|
| `.ssg-root` | グリッドのルート要素(`className` prop の付与先)。 |
|
|
2735
2750
|
| `.ssg-root--fill-height` | `height` に `%` を含む値を渡したときのルート(flex column)。 |
|
|
2751
|
+
| `.ssg-root--refetching` | `serverSideRefetch="keep"` で、取り直しの間に前の行を見せているときのルート(このとき本体の見えている所を `--ssg-refetch-row-opacity` の濃さに薄く見せる)。 |
|
|
2736
2752
|
| `.ssg-root--filling` | フィルハンドル(`fillHandle`)のドラッグ中のルート(カーソルを十字に固定)。 |
|
|
2737
2753
|
| `.ssg-theme-dark` | `theme="dark"`(または `'auto'` のダーク解決)時に root と各ポータル(popover / menu / panel / ツールチップ)へ。 |
|
|
2738
2754
|
| `.ssg-theme-class` | `theme="class"` のとき root と各ポータル(popover / menu / panel / ツールチップ / ドラッグのゴースト)と `GridAskBar` へ。祖先に `.dark` か `[data-theme="dark"]` があるとダークのプリセットになる(`:where` で定義)。 |
|
|
@@ -2743,6 +2759,7 @@ function Grid(props: SpreadsheetGridProps<Row>) {
|
|
|
2743
2759
|
| `.ssg-filter-chip-bar` | フィルターチップバー。 |
|
|
2744
2760
|
| `.ssg-empty-state` | 0 行時の空状態。 |
|
|
2745
2761
|
| `.ssg-ssrm-error-bar` | SSRM の読み込みエラーバー。 |
|
|
2762
|
+
| `.ssg-refetch-bar` | `serverSideRefetch="keep"` で前の行を見せている間、列見出しの下に出る動く線(色は `--ssg-refetch-bar` / `--ssg-refetch-bar-track`)。 |
|
|
2746
2763
|
| `.ssg-scroll-hint` | スクロール位置インジケーター(`scrollHint`)。 |
|
|
2747
2764
|
| `.ssg-find-bar` | セル内検索(`find`)の検索バー。 |
|
|
2748
2765
|
| `.ssg-find-mark` / `.ssg-find-mark--current` | セル内検索のヒット / 今のヒット(`<mark>`)。 |
|
|
@@ -2830,7 +2847,7 @@ function Grid(props: SpreadsheetGridProps<Row>) {
|
|
|
2830
2847
|
| 保存の印(SSRM の書き戻し) | `--ssg-save-pending` / `--ssg-save-ok` / `--ssg-save-ok-contrast` / `--ssg-save-failed` |
|
|
2831
2848
|
| 検索とフィルハンドル | `--ssg-find-mark-bg` / `--ssg-find-mark-current-bg`、`--ssg-fill-line` / `--ssg-fill-handle-ring` |
|
|
2832
2849
|
| 条件付き書式 | `--ssg-cf-bar` / `--ssg-cf-bar-negative`(データバー)、`--ssg-cf-seq-min` / `--ssg-cf-seq-max` / `--ssg-cf-div-negative` / `--ssg-cf-div-mid` / `--ssg-cf-div-positive`(カラースケール)、`--ssg-cf-neutral` / `--ssg-cf-neutral-bg` / `--ssg-cf-info` / `--ssg-cf-info-bg` / `--ssg-cf-good` / `--ssg-cf-good-bg` / `--ssg-cf-warning` / `--ssg-cf-warning-bg` / `--ssg-cf-critical` / `--ssg-cf-critical-bg`(チップ) |
|
|
2833
|
-
| 読み込み中とスクロール位置 | `--ssg-skeleton-bar` / `--ssg-skeleton-bar-hi`(SSRM のスケルトン)、`--ssg-scrollhint-track-bg` / `--ssg-scrollhint-thumb` / `--ssg-scrollhint-thumb-active`(`scrollHint`) |
|
|
2850
|
+
| 読み込み中とスクロール位置 | `--ssg-skeleton-bar` / `--ssg-skeleton-bar-hi`(SSRM のスケルトン)、`--ssg-refetch-row-opacity` / `--ssg-refetch-bar` / `--ssg-refetch-bar-track`(`serverSideRefetch="keep"` の前の行の濃さ / 動く線 / 線の下地)、`--ssg-scrollhint-track-bg` / `--ssg-scrollhint-thumb` / `--ssg-scrollhint-thumb-active`(`scrollHint`) |
|
|
2834
2851
|
| モーション | `--ssg-motion-fast` / `--ssg-motion-base` / `--ssg-motion-slow` / `--ssg-motion-ease` |
|
|
2835
2852
|
|
|
2836
2853
|
## 補助型(props で参照される shape)
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A virtualized spreadsheet / data grid for Solid 2.0 (~1M rows, pinned columns, Excel-like editing / selection / clipboard, filters & sorting, client-side and server-side row models). It is the Solid version of [`@ishibashi0112/spreadsheet-grid`](https://www.npmjs.com/package/@ishibashi0112/spreadsheet-grid) (React): the same props, column options, imperative handle, CSS and look, built on the same framework-independent core. 日本語は下にあります。
|
|
4
4
|
|
|
5
|
-
**[Docs & live demo](https://datasheet-grid.vercel.app)** (the
|
|
5
|
+
**[Docs & live demo](https://datasheet-grid.vercel.app)** (pick Solid at the top of the sidebar and the getting-started pages, the code in the guides and the notes on the API reference switch to Solid. In Japanese: [installation](https://datasheet-grid.vercel.app/docs/solid/installation) · [Solid で気をつけること](https://datasheet-grid.vercel.app/docs/solid/notes)) · [Try on StackBlitz](https://stackblitz.com/fork/github/ishibashi0112/datasheet-grid/tree/main/examples/solid?file=src/App.tsx&terminal=dev) · [GitHub](https://github.com/ishibashi0112/datasheet-grid) · [Changelog](https://github.com/ishibashi0112/datasheet-grid/blob/main/packages/solid/CHANGELOG.md)
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -18,7 +18,7 @@ import '@ishibashi0112/spreadsheet-grid-solid/style.css'
|
|
|
18
18
|
|
|
19
19
|
The package follows the Solid convention for libraries: the `solid` export condition points at JSX source (`dist/source/`), which your bundler compiles with your own Solid settings (DOM or SSR, dev or prod). With Vite, use `@solidjs/vite-plugin` 3 (Vite 8 or later). SSR needs this form. Tools without the `solid` condition get the DOM build (`dist/index.js`, ESM only). In Node (for example tests with Vitest and jsdom), resolve with the `solid` or `browser` condition, which `@solidjs/vite-plugin` sets: with Node's default conditions `@solidjs/web` resolves to its server build and the DOM build fails with "Client-only API called on the server side".
|
|
20
20
|
|
|
21
|
-
`style.layer.css` and the design-system themes (`themes/astryx.css` / `themes/mantine.css` / `themes/heroui.css` / `themes/shadcn.css`) are the same files as in the React version ([
|
|
21
|
+
`style.layer.css` and the design-system themes (`themes/astryx.css` / `themes/mantine.css` / `themes/heroui.css` / `themes/shadcn.css`) are the same files as in the React version ([CSS](https://datasheet-grid.vercel.app/docs/css), [design systems](https://datasheet-grid.vercel.app/docs/guides/design-systems)).
|
|
22
22
|
|
|
23
23
|
## Quick start
|
|
24
24
|
|
|
@@ -52,7 +52,7 @@ A runnable example (an editable inventory table with 10,000 rows) is in [`exampl
|
|
|
52
52
|
|
|
53
53
|
## Picking features
|
|
54
54
|
|
|
55
|
-
`SpreadsheetGrid` includes every feature (about
|
|
55
|
+
`SpreadsheetGrid` includes every feature (about 170KB gzip of initial JS; the column filter popover and the tool panel, about 16KB, load later). `createSpreadsheetGrid` builds a grid with only the features you pass, and the rest is left out of your bundle (about 97KB with no features, about 124KB with the `standardFeatures` preset). Unlike the React version, the parts come from the main entry (there is no `/lite`).
|
|
56
56
|
|
|
57
57
|
```tsx
|
|
58
58
|
import { createSpreadsheetGrid, standardFeatures, serverSideFeature } from '@ishibashi0112/spreadsheet-grid-solid'
|
|
@@ -68,7 +68,7 @@ The feature names and what they enable are listed in the bundled `API_REFERENCE.
|
|
|
68
68
|
- **`ref` works like Solid's DOM refs.** `let grid!: SpreadsheetGridHandle<Row>` with `ref={grid}`, or `ref={(handle) => (grid = handle)}`, gives you the handle with the same methods (there are no React ref objects). The handle is set before your component's first `createEffect` and `onSettled` run, so you can call it there (for example to restore a saved state or scroll to the bottom). Inside `<Loading>`, the grid is not drawn until the first rows arrive, and methods that change its state do nothing before that (the grid warns once in development): pass the first state as `initialState`, or call the handle from an effect that reads the rows (`createEffect(() => rows().length, …)`). After the grid is removed (hidden with `<Show>` and so on), a handle left in your variable does nothing for methods that change the state (the grid warns once in development), and methods that read return the values from when it was removed (save `grid.getState()` in `onCleanup`; `getScrollPosition()` returns `null` and `isAtBottom()` `false`).
|
|
69
69
|
- **Render functions run only when needed.** `renderCell` and `renderHeader` run again when their column changes, and the bar renderers when the function changes; not on every update as in React. Everything in the context (`row`, `value`, `rowIndex`, `isActive`, the bar context and each field of its `derivedSummary`, and so on) is read when you access it: read it inside JSX and only that expression follows, so an input inside a cell can call `ctx.setValue` on every keystroke and keep its focus (1.4.0+; earlier versions re-created the cell content whenever its row changed). Reading a value in the function body (destructuring the arguments included) re-creates the content when that value changes. Reading it at the top of your own component's body (`renderCell={(ctx) => <MyCell ctx={ctx} />}` with `const v = props.ctx.value` in `MyCell`) does not follow later changes (Solid reports `STRICT_READ_UNTRACKED` in development), so read it inside JSX there. Signals from outside the grid read in the `renderCell` body re-create the content of every visible cell when they change, so read them inside JSX (or through a memo per row key).
|
|
70
70
|
- **Natural-language filter (`/ai`).** `GridAskBar` and `createGridAsk` (the React version's `useGridAsk`; Solid names it `create…`) come from `@ishibashi0112/spreadsheet-grid-solid/ai` (about 15KB gzip, separate from the grid's bundle). Pass the grid as a function that returns the handle, `grid={() => grid}` (with `let grid!` and `ref={grid}`), or as a signal (`ref={setGrid}` with `grid={grid}`); there are no ref objects. Everything else (your `ask` function, the answer format, `gridAskLocaleTextEn` from `/locales/en`) is the same as the React version ([AI filter guide](https://datasheet-grid.vercel.app/docs/guides/ai-filter)).
|
|
71
|
-
- **Speed.** Scrolling and editing feel the same as the React version
|
|
71
|
+
- **Speed.** Scrolling and editing feel about the same as the React version. In our measurement on 1.5.0, `Ctrl+End` in 1,000,000 rows and large vertical jumps in a table of about 200 columns take about the same JavaScript time as the React version (about 1.1 times). Short scrolls and large horizontal jumps take about 1.5 to 2 times the script time, and a table of about 200 columns uses about 9 MB more memory (each visible cell is a small set of Solid computations; when only the drawn range changes, row and cell elements are reused and only their contents are rewritten).
|
|
72
72
|
- Everything else (props, column options, handle methods, callbacks, CSS classes and tokens) is the same as in the React version. The package ships `API_REFERENCE.md` (0.1.2+; the same document as the React version's, with a note at the top on reading it for Solid; also [on GitHub](https://github.com/ishibashi0112/datasheet-grid/blob/main/packages/react/API_REFERENCE.md)).
|
|
73
73
|
|
|
74
74
|
## Solid-specific notes
|
|
@@ -116,7 +116,7 @@ MIT
|
|
|
116
116
|
|
|
117
117
|
Solid 2.0 向けの仮想化スプレッドシート / データグリッドです(約 100 万行・列固定・Excel ライクな編集 / 選択 / クリップボード・フィルター / ソート・クライアントサイド / サーバーサイド行モデル)。React 版の [`@ishibashi0112/spreadsheet-grid`](https://www.npmjs.com/package/@ishibashi0112/spreadsheet-grid) と同じ props・列の定義・命令的なハンドル・CSS・見た目で、同じフレームワークに依らないコアの上に作っています。
|
|
118
118
|
|
|
119
|
-
**[ドキュメントとライブデモ](https://datasheet-grid.vercel.app)**(
|
|
119
|
+
**[ドキュメントとライブデモ](https://datasheet-grid.vercel.app)**(サイドバーの一番上で Solid を選ぶと、はじめるのページ・ガイドのコード・API リファレンスの読み替えが Solid になります。Solid 版だけのことは [Solid で気をつけること](https://datasheet-grid.vercel.app/docs/solid/notes))· [StackBlitz で試す](https://stackblitz.com/fork/github/ishibashi0112/datasheet-grid/tree/main/examples/solid?file=src/App.tsx&terminal=dev) · [GitHub](https://github.com/ishibashi0112/datasheet-grid) · [変更履歴](https://github.com/ishibashi0112/datasheet-grid/blob/main/packages/solid/CHANGELOG.md)
|
|
120
120
|
|
|
121
121
|
`npm install @ishibashi0112/spreadsheet-grid-solid` で入れます(peer は `solid-js` / `@solidjs/web` の `^2.0.0`)。CSS は `import '@ishibashi0112/spreadsheet-grid-solid/style.css'` を 1 回読み込みます。`style.layer.css` とデザインシステムのテーマ(`themes/*.css`)は React 版と同じファイルです。
|
|
122
122
|
|
|
@@ -128,14 +128,14 @@ Solid 2.0 向けの仮想化スプレッドシート / データグリッドで
|
|
|
128
128
|
|
|
129
129
|
### 機能を選んで組み込む
|
|
130
130
|
|
|
131
|
-
`SpreadsheetGrid` は全機能入りです(初期読み込みの JS が約
|
|
131
|
+
`SpreadsheetGrid` は全機能入りです(初期読み込みの JS が約 170KB gzip。列フィルターのポップオーバーとツールパネルの約 16KB は後から読みます)。`createSpreadsheetGrid` では渡した機能だけを入れたグリッドを作れ、渡さなかった機能はバンドルに入りません(機能なしで約 97KB、プリセット `standardFeatures` で約 124KB)。React 版と違い、機能の部品も同じ入口から import します(`/lite` はありません)。機能の名前と中身は同梱の `API_REFERENCE.md` の「機能を選んで組み込む」のとおりです(部品の名前も React 版と同じ)。グリッドはコンポーネントの中ではなく、モジュールの先頭で 1 回だけ作ってください。
|
|
132
132
|
|
|
133
133
|
### React 版との違い
|
|
134
134
|
|
|
135
135
|
- **`ref` は Solid の DOM の ref と同じです。** `let grid!: SpreadsheetGridHandle<Row>` と `ref={grid}`、または `ref={(handle) => (grid = handle)}` で、同じメソッドを持つハンドルを受け取れます(React の ref オブジェクトはありません)。ハンドルは利用側の部品の最初の `createEffect` と `onSettled` より前に入るので、そこで呼べます(保存した状態を戻す、末尾へスクロールする など)。`<Loading>` の中では最初の行が届くまでグリッドを描かず、それまでに呼んだ状態を変えるメソッドは何もしません(開発時に 1 回知らせます)。最初の状態は `initialState` で渡すか、行を読む effect(`createEffect(() => rows().length, …)`)から呼んでください。グリッドを外した後(`<Show>` で隠したときなど)も変数に残ったハンドルは、状態を変えるメソッドは何もせず(開発時に 1 回知らせます)、読むメソッドは外したときの値を返します(`onCleanup` で `grid.getState()` を保存できます。`getScrollPosition()` は `null`、`isAtBottom()` は `false`)。
|
|
136
136
|
- **描く関数は必要なときだけ呼びます。** `renderCell` と `renderHeader` は列が変わったとき、バーの関数は関数が変わったときに呼び直します(React 版のように更新のたびには呼びません)。文脈の値(`row` / `value` / `rowIndex` / `isActive`、バーの文脈と、その `derivedSummary` の各項目など)は読んだときに引くので、JSX の中で読めばその式だけが追従します。セルの中の入力欄で打つたびに `ctx.setValue` しても、入力欄はそのままでフォーカスも外れません(1.4.0 から。それまでは行が変わるたびにセルの中身を作り直していました)。関数の本体で読むと(引数の分割代入も)、その値が変わったときに中身を作り直します(バーの入力欄なら、フォーカスと打ちかけの文字が消えます)。自分の部品の本体の一番上で読むと(`renderCell={(ctx) => <MyCell ctx={ctx} />}` で `MyCell` の中の `const v = props.ctx.value`)、その後の変化に追従しません(開発時に Solid が `STRICT_READ_UNTRACKED` を出します)。そこでも JSX の中で読んでください。グリッドの外の signal を `renderCell` の本体で読むと、変わるたびに見えているすべてのセルの中身を作り直します。JSX の中で読むか、行のキーごとの memo を通してください。
|
|
137
137
|
- **ことばで絞り込み(`/ai`)。** `GridAskBar` と `createGridAsk`(React 版の `useGridAsk`。Solid の慣例で `create…` の名前)は `@ishibashi0112/spreadsheet-grid-solid/ai` から import します(約 15KB gzip。グリッドのバンドルとは別)。グリッドはハンドルを返す関数 `grid={() => grid}`(`let grid!` と `ref={grid}`)か signal(`ref={setGrid}` と `grid={grid}`)で渡します(ref オブジェクトはありません)。そのほか(利用側の `ask`・答えの形・`/locales/en` の `gridAskLocaleTextEn`)は React 版と同じです([ことばで絞り込み](https://datasheet-grid.vercel.app/docs/guides/ai-filter))。
|
|
138
|
-
- **速さ。**
|
|
138
|
+
- **速さ。** スクロールと編集は React 版とほぼ同じです。1.5.0 で測ると、100 万行の `Ctrl+End` と、約 200 列の表で縦に大きく飛ぶときの JS の時間は React 版と同じくらい(約 1.1 倍)です。少しずつのスクロールと横に大きく飛ぶときは JS の時間が React 版の約 1.5〜2 倍で、約 200 列の表ではメモリが約 9MB 多くなります(見えているセルごとに Solid の計算をいくつか持つため。描く範囲だけが変わったときは、行の要素とセルの部品を使い回して中身だけを書き換えます)。
|
|
139
139
|
- そのほか(props・列の定義・ハンドルのメソッド・通知・CSS のクラスとトークン)は React 版と同じです。パッケージに `API_REFERENCE.md` を同梱しています(0.1.2 から。React 版と同じ文書で、先頭に Solid 版での読み替えがあります。[GitHub](https://github.com/ishibashi0112/datasheet-grid/blob/main/packages/react/API_REFERENCE.md) でも読めます)。
|
|
140
140
|
|
|
141
141
|
### Solid で気をつけること
|