@ishibashi0112/spreadsheet-grid-solid 1.4.0 → 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 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 未指定のため…」)。 |
@@ -1202,7 +1203,7 @@ const columns: GridColumn<Expense>[] = [
1202
1203
  | `'select'` | 候補ドロップダウン(表の外のポータル。`popupContainer`)。↑↓=ハイライト移動 / Enter=確定(下へ)/ Tab=確定(左右へ)/ クリック=確定 / 印字キー=label 前方一致のタイプアヘッド(約 700ms でリセット)/ IME で確定した文字(日本語の名前など)= その文字で始まる候補、無ければ含む候補へ(1.0.2) | `options: readonly GridSelectEditorOption[] \| (row) => readonly GridSelectEditorOption[]`(静的 or 行依存。関数はレンダー中に呼ばれるため純粋であること。readonly / `as const` の配列も可。1.3.0 から)/ `clipboard: 'value' \| 'label'`(既定 `'value'`。`'label'` でコピー・CSV は label、貼り付けた label は value へ。1.1.0) | パススルー(`option.value` は string。型変換したい場合は `parseClipboardValue` を併用)。`clipboard: 'label'` なら、貼り付けた文字が候補の label(前後の空白は外して比べる)ならその value、value ならそのまま、どちらでもなければ生文字列のまま(label を先に見る。エディタで選んだ候補は読み替えずにその value を書く) |
1203
1204
  | `'date'` | ネイティブ `<input type="date">`。ドラフトは `'YYYY-MM-DD' \| ''`。入力欄は中身(年 / 月 / 日)より狭くせず、細い列ではセルからはみ出して開く。セルを選んで文字から打ち始めたときは、その文字を消さないよう文字の入力欄で開き、確定するときに日付として読む(`2026/3/15`・`2026-03-15` など。読み方は既定パーサに、全角の数字・記号と「2026年3月15日」の書き方を足したもの。貼り付けではこれらを読まない)。読めなければ「日付で入力してください」を出して編集を続ける(フォーカスが外れたら取り消し。1.0.2) | `strict`(`true` で日付として読めない値に印。1.2.0。「バリデーション」節) | `''`→`null` / 解釈可能→`'YYYY-MM-DD'` へ正規化(数字の日付は年 / 月 / 日と、年が後ろの月 / 日 / 年 = 「4/11/2026」は 4 月 11 日。日 / 月 / 年としては読まない)/ 解釈不可→生文字列のまま(数字だけの文字列 = Excel の日付のシリアル値「45678」や「5」と、年が 4 桁にならない文字列、年の無い文字列(「11/2」「Nov 1」)、ありえない日付(「2026/2/30」)も解釈不可。翌月へ繰り越さない) |
1204
1205
  | `'checkbox'` | **直接トグル**(編集セッションなし)。チェックボックスそのものを押すか、アクティブセルで Space を押すと即トグル(セルのチェックボックスの外を押したときはアクティブセルになるだけ。ダブルクリックでも切り替わらない)。Enter / F2 / ダブルクリックではエディタが開かない | `checkedValue`(既定 `true`)/ `uncheckedValue`(既定 `false`)。checked 判定は `Object.is(value, checkedValue)` のみ | `''`→unchecked / checked・unchecked の文字列表現→対応値 / `'true'`・`'1'`→checked / その他→unchecked |
1205
- | `'custom'` | `render(ctx)` の返り値を編集オーバーレイ内に描画。**フォーカス管理・キーバインドは利用側の責務**(開いたままグリッドの中の別のセルを押したときに値を残す / エディタを閉じるには、入力欄の `onBlur` で `ctx.commit` か `ctx.cancel` を呼ぶ。呼ばないとエディタが開いたまま残り、グリッドのキー操作が効かない) | `render: (ctx: CellEditorContext<T>) => ReactNode`, `imeDirectInput?: boolean`(グリッドの `imeDirectInput` が有効なとき、IME で確定した文字を `ctx.initialText` に入れて開く。既定 `false`。1.2.0 から) | パススルー |
1206
+ | `'custom'` | `render(ctx)` の返り値を編集オーバーレイ内に描画。**フォーカス管理・キーバインドは利用側の責務**(開いたままグリッドの中の別のセル・行番号・列見出し・見出しの角・行の掴み手・展開トグル・表の余白を押すと、グリッドが編集を終えてエディタを閉じる。編集していたセルの中でエディタが覆っていない所を押したときは閉じない。打った値を残すには入力欄の `onBlur` で `ctx.commit(value)` を呼ぶ。サーバーの検査を待ってから呼んでも、閉じた後に編集していたセルへ書く(その前に同じセルをまた開いて編集しているときとグリッドを外した後は書かない。検査で reject する値は書かず `{ status: 'rejected' }` を返す)。呼ばなければ打ちかけは書かない。1.4.0 まではエディタが開いたまま残り、別のセルをダブルクリックするまでグリッドのキー操作が効かなかった) | `render: (ctx: CellEditorContext<T>) => ReactNode`, `imeDirectInput?: boolean`(グリッドの `imeDirectInput` が有効なとき、IME で確定した文字を `ctx.initialText` に入れて開く。既定 `false`。1.2.0 から) | パススルー |
1206
1207
 
1207
1208
  注意点:
1208
1209
 
@@ -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()` は本体にあるので無くても使える) | +4.8KB |
2291
- | `serverSide` | `serverSideFeature` | サーバーサイド行モデル(SSRM)の読み取りと書き戻し、保存状態の表示(`dataSource` / `serverSideRefreshToken` / `showSaveStatus` ほか) | +4.7KB |
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`) | 約 153KB |
2314
- | `/lite` 機能なし | 約 90KB |
2328
+ | 全部入り(`SpreadsheetGrid`) | 約 155KB |
2329
+ | `/lite` 機能なし | 約 91KB |
2315
2330
  | `/lite` + `standardFeatures` | 約 114KB |
2316
- | `/lite` + `standardFeatures` + `serverSideFeature` | 約 118KB |
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 guides show a Solid tab wherever the code differs, and the API reference is written for the React version with the same props. Solid notes, in Japanese: [Solid で使う](https://datasheet-grid.vercel.app/docs/solid)) · [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)
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 ([installation](https://datasheet-grid.vercel.app/docs/installation), [design systems](https://datasheet-grid.vercel.app/docs/guides/design-systems)).
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 168KB 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 95KB with no features, about 123KB with the `standardFeatures` preset). Unlike the React version, the parts come from the main entry (there is no `/lite`).
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 in usual tables. Jumping far in very large or very wide tables takes more JavaScript time than the React version: in our measurement on 1.4.0, `Ctrl+End` in 1,000,000 rows took about 1.2 times as long, and large vertical jumps in a table of about 200 columns about 2 times the script time, with a few MB more memory (each visible cell is a small set of Solid computations; 1.4.0 roughly halved the earlier gap).
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
@@ -79,7 +79,7 @@ The feature names and what they enable are listed in the bundled `API_REFERENCE.
79
79
  - **Async rows.** Rows from an async `createMemo` / `createSignal(async)` work inside `<Loading>`: the fallback shows until the first rows arrive. While they are fetched again, the grid keeps the previous rows and stays usable; show the wait with `isPending(() => rows())`. With `<Loading on={...}>` the fallback replaces the grid during the refetch (the grid keeps its state and comes back when the rows arrive); an edit in progress is committed when the grid is replaced, so `onRowsChange` gets the previous rows. A failed refetch reaches your `<Errored>`. Rows read through `createDeferred` show the old values while a save's `refresh()` fetches them again (that is how `createDeferred` works); an async `createMemo` keeps the saved values.
80
80
  - **Callbacks after drawing.** The callbacks the React version calls from an effect after rendering (`onActiveCellChange`, `onStateChange`, `onFiltersChange`, `onSortChange`, `onExpandedDetailRowKeysChange`, and `onRowSelectionChange` when removing selected rows drops them from the selection) run right after the flush that drew the change, in a microtask, and not after the grid is removed. In tests, `await Promise.resolve()` after `flush()` before checking them.
81
81
  - **Tests (Vitest + jsdom).** Add `@solidjs/vite-plugin` to the Vitest config. Without the plugin, put `browser` in `resolve.conditions`, `ssr.resolve.conditions` and `ssr.resolve.externalConditions` (all three). Use the Solid 2 version of `@solidjs/testing-library` (1.0 release candidates) and `installJsdomLayoutStubs` from `@ishibashi0112/spreadsheet-grid-solid/testing` (jsdom has no layout).
82
- - **SSR.** SolidStart supports only Solid 1 at the time of writing. With Solid 2, use Vite's SSR with `@solidjs/vite-plugin` (`ssr: true`), `renderToString` or `renderToStream` with `generateHydrationScript` on the server, and `hydrate` on the client (`@solidjs/router` 2 also needs `createRequestEvent` from `@solidjs/web` and `provideRequestEvent` from `@solidjs/web/storage`). The server renders what the React version renders: the frame, the row numbers and pinned cells of the first rows, counts and totals (columns that are not pinned need the grid's width and are drawn in the browser, as in the React version). The server's rows are a display-only copy: after hydration the grid swaps it for the rows computed in the browser within the same task, so a different time zone or date in the browser (date conditions, `Date` values) cannot leave the server's rows on the page. Solid's hydration does not fix server text that differs on the client, so the server HTML holds two `.ssg-root` elements: a hidden frame without rows that hydration picks up, followed by the copy, which is removed after hydration (the React version re-renders the mismatch on the client). Run the production server with `NODE_ENV=production` (or set `define: { 'process.env.NODE_ENV': JSON.stringify('production') }` in the SSR build): otherwise the server renders the development build's extra parts and hydration does not pick up the grid.
82
+ - **SSR.** SolidStart supports only Solid 1 at the time of writing. With Solid 2, use Vite's SSR with `@solidjs/vite-plugin` (`ssr: true`), `renderToString` or `renderToStream` with `generateHydrationScript` on the server, and `hydrate` on the client (`@solidjs/router` 2 also needs `createRequestEvent` from `@solidjs/web` and `provideRequestEvent` from `@solidjs/web/storage`). The server renders what the React version renders: the frame, the row numbers and pinned cells of the first rows, counts and totals (columns that are not pinned need the grid's width and are drawn in the browser, as in the React version). The server's rows are a display-only copy: after hydration the grid swaps it for the rows computed in the browser within the same task, so a different time zone or date in the browser (date conditions, `Date` values) cannot leave the server's rows on the page. Solid's hydration does not fix server text that differs on the client, so the server HTML holds a hidden frame without rows that hydration picks up, followed by the copy, which is removed after hydration (the React version re-renders the mismatch on the client). Only the copy has the `.ssg-root` class, so the server HTML has one `.ssg-root`, as in the React version (the frame gets the class after hydration; 1.4.0 put it on both). Run the production server with `NODE_ENV=production` (or set `define: { 'process.env.NODE_ENV': JSON.stringify('production') }` in the SSR build): otherwise the server renders the development build's extra parts and hydration does not pick up the grid.
83
83
  - **Saving the state in the URL.** Pass the saved state as `initialState` on the first render, save it from `onStateChange`, and apply later changes (back / forward) with `grid.applyState(...)`. Reading signals inside the grid's callbacks is fine; they run outside tracking, like event handlers.
84
84
  - **Detail rows.** `detailRow.render` runs when a row opens, and `ctx.row` returns the current row when read. Read `ctx.row` inside JSX (passing it to a component, as in `order={ctx.row}`, counts too) and only that expression follows edits and undo. Reading it in the body of `render` (including destructuring `({ row }) => …`) calls `render` again whenever the row changes and rebuilds the card (focus and unsaved text in its inputs, and the state of a nested grid, are lost). A field initialized with `createSignal(() => ctx.row.x)` is reset whenever the row changes, so keep unsaved input in a plain signal: `createSignal(untrack(() => ctx.row.x))`. The same goes for custom editors: `ctx.value` and `ctx.row` are reactive, so read them inside JSX, or take the starting value with `untrack(() => ctx.value)` (or `ctx.initialText`); reading them in the component body makes Solid report `STRICT_READ_UNTRACKED` in development.
85
85
  - **Values from outside the rows.** `getValue` and `valueFormatter` should depend only on the row and the value. If they read a signal from outside, the cells follow it but totals (`aggFunc`) do not; re-create the columns when that signal changes (for example `const columns = createMemo(() => makeColumns(totals()))`).
@@ -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)**(ガイドはコードが違う所に Solid のタブがあります。API リファレンスは React 版向けですが、props は同じです。Solid 版だけのことは [Solid で使う](https://datasheet-grid.vercel.app/docs/solid))· [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)
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 が約 168KB gzip。列フィルターのポップオーバーとツールパネルの約 16KB は後から読みます)。`createSpreadsheetGrid` では渡した機能だけを入れたグリッドを作れ、渡さなかった機能はバンドルに入りません(機能なしで約 95KB、プリセット `standardFeatures` で約 123KB)。React 版と違い、機能の部品も同じ入口から import します(`/lite` はありません)。機能の名前と中身は同梱の `API_REFERENCE.md` の「機能を選んで組み込む」のとおりです(部品の名前も React 版と同じ)。グリッドはコンポーネントの中ではなく、モジュールの先頭で 1 回だけ作ってください。
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
- - **速さ。** ふつうの表のスクロールと編集は React 版と変わりません。とても行の多い表や列の多い表で遠くへ飛ぶときは、JS の時間が React 版より長くなります。1.4.0 で測ると、100 万行の `Ctrl+End` は約 1.2 倍、約 200 列の表で縦に大きく飛ぶときの JS は約 2 倍で、メモリは数 MB 多くなりました(見えているセルごとに Solid の計算をいくつか持つため。1.4.0 で差をおよそ半分に縮めました)。
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 で気をつけること
@@ -146,7 +146,7 @@ Solid 2.0 向けの仮想化スプレッドシート / データグリッドで
146
146
  - **非同期の行。** 非同期の `createMemo` / `createSignal(async)` の行は `<Loading>` の中で使えます(最初の行が届くまでは fallback)。取り直しの間は前の行のまま操作できるので、待っていることは `isPending(() => rows())` で出してください。`<Loading on={...}>` では取り直しの間 fallback がグリッドに替わります(グリッドの状態は残り、行が届くと戻ります)。替わるときに編集中の値は確定し、`onRowsChange` には前の行が渡ります。取り直しの失敗は利用側の `<Errored>` が受けます。`createDeferred` で読んだ行は、保存の `refresh()` の取り直しの間は元の値を出します(`createDeferred` の意味どおり)。非同期の `createMemo` なら保存した値のままです。
147
147
  - **描いた後の通知。** React 版が描いた後の effect で呼ぶ通知(`onActiveCellChange` / `onStateChange` / `onFiltersChange` / `onSortChange` / `onExpandedDetailRowKeysChange`、選んだ行を消して選択から外したときの `onRowSelectionChange`)は、その変化を反映し終えた直後(次のマイクロタスク)に呼び、グリッドを外した後には呼びません。テストでは `flush()` の後に `await Promise.resolve()` で 1 回待ってから確かめてください。
148
148
  - **テスト(Vitest + jsdom)。** Vitest の設定に `@solidjs/vite-plugin` を入れてください。プラグイン無しなら `browser` を `resolve.conditions` / `ssr.resolve.conditions` / `ssr.resolve.externalConditions` の 3 か所すべてに書きます。`@solidjs/testing-library` は Solid 2 向けの版(1.0 の候補版)を使い、jsdom にはレイアウトが無いので `@ishibashi0112/spreadsheet-grid-solid/testing` の `installJsdomLayoutStubs` を呼びます。
149
- - **SSR。** 今の SolidStart は Solid 1 だけに対応しています。Solid 2 では Vite の SSR と `@solidjs/vite-plugin`(`ssr: true`)で、サーバーは `renderToString` か `renderToStream` と `generateHydrationScript`、クライアントは `hydrate` を使います(`@solidjs/router` 2 は `@solidjs/web` の `createRequestEvent` と `@solidjs/web/storage` の `provideRequestEvent` も要ります)。サーバーは React 版と同じものを描きます(骨組み・最初の行の行番号と固定した列のセル・件数・合計。固定していない列はグリッドの幅が要るので、React 版と同じくブラウザで描きます)。サーバーの行は表示だけの写しで、ハイドレーションの後、同じタスクの中でブラウザで計算した行へ入れ替えます。サーバーとブラウザでタイムゾーンや今日が違っても(日付の条件・Date の値)、サーバーの行がページに残りません。Solid のハイドレーションはクライアントで違う値になった文字を直さないので、サーバーの HTML には `.ssg-root` が 2 つ並びます(ハイドレーションで使う、行を空にして隠した骨組みと、その後ろの写し。写しはハイドレーションの後に外れます。React 版は食い違いをクライアントで描き直します)。本番のサーバーは `NODE_ENV=production` で起動してください(または SSR のビルドに `define: { 'process.env.NODE_ENV': JSON.stringify('production') }`)。無いとサーバーが開発用の部品も描き、ハイドレーションがグリッドを引き継げません。
149
+ - **SSR。** 今の SolidStart は Solid 1 だけに対応しています。Solid 2 では Vite の SSR と `@solidjs/vite-plugin`(`ssr: true`)で、サーバーは `renderToString` か `renderToStream` と `generateHydrationScript`、クライアントは `hydrate` を使います(`@solidjs/router` 2 は `@solidjs/web` の `createRequestEvent` と `@solidjs/web/storage` の `provideRequestEvent` も要ります)。サーバーは React 版と同じものを描きます(骨組み・最初の行の行番号と固定した列のセル・件数・合計。固定していない列はグリッドの幅が要るので、React 版と同じくブラウザで描きます)。サーバーの行は表示だけの写しで、ハイドレーションの後、同じタスクの中でブラウザで計算した行へ入れ替えます。サーバーとブラウザでタイムゾーンや今日が違っても(日付の条件・Date の値)、サーバーの行がページに残りません。Solid のハイドレーションはクライアントで違う値になった文字を直さないので、サーバーの HTML には、ハイドレーションで使う行を空にして隠した骨組みと、その後ろの写しが並びます(写しはハイドレーションの後に外れます。React 版は食い違いをクライアントで描き直します)。`.ssg-root` が付くのは写しだけで、サーバーの HTML の `.ssg-root` は React 版と同じく 1 つです(骨組みにはハイドレーションの後に付きます。1.4.0 は両方に付いていました)。本番のサーバーは `NODE_ENV=production` で起動してください(または SSR のビルドに `define: { 'process.env.NODE_ENV': JSON.stringify('production') }`)。無いとサーバーが開発用の部品も描き、ハイドレーションがグリッドを引き継げません。
150
150
  - **状態を URL に残す。** 保存した状態は最初の描画で `initialState` に渡し、`onStateChange` で保存し、後からの変化(戻る / 進む)は `grid.applyState(...)` で入れます。グリッドの通知の中で signal を読んでかまいません(イベントのハンドラと同じく追跡の外で呼びます)。
151
151
  - **展開行。** `detailRow.render` は行を開いたときに呼び、`ctx.row` は読んだときに今の行を引きます。JSX の中で `ctx.row` を読めば(`order={ctx.row}` のように部品へ渡すのも同じ)、編集や元に戻すにその式だけが追従します。`render` の本体で読むと(引数の分割代入 `({ row }) => …` も)、その行が変わるたびに `render` を呼び直してカードを作り直します(カードの中の入力欄のフォーカスや打ちかけの文字、入れ子のグリッドの状態が消えます)。`createSignal(() => ctx.row.x)` で持った入力欄の値は行が変わるたびに戻るので、保存前の入力はふつうの signal で持ちます(`createSignal(untrack(() => ctx.row.x))`)。custom エディタも同じで、`ctx.value` / `ctx.row` は読んだときに引くので JSX の中で読むか、始めの値は `untrack(() => ctx.value)`(または `ctx.initialText`)で取ってください(部品の本体で読むと開発時に Solid が `STRICT_READ_UNTRACKED` を出します)。
152
152
  - **行の外の値。** `getValue` / `valueFormatter` は行と値だけから決めてください。外の signal を読むと、セルはそれに追従しますが合計(`aggFunc`)は追従しません。その signal が変わったら列を作り直してください(`const columns = createMemo(() => makeColumns(totals()))` など)。
@@ -1,5 +1,6 @@
1
1
  import type { JSX } from '@solidjs/web';
2
2
  import type { EditorCommitDirection, EditorCommitResult, EditorEnterMove, GridRowKey } from '@ishibashi0112/spreadsheet-grid-core';
3
+ import type { LateEditCommitReceiver } from '@ishibashi0112/spreadsheet-grid-core/internal/controllers/editController';
3
4
  import type { GridColumn, GridResolvedSlots } from '../model/gridTypes.js';
4
5
  export type CellEditorRect = {
5
6
  left: number;
@@ -30,6 +31,7 @@ type CellEditorLayerProps<T> = {
30
31
  onCommit: (value: unknown, direction?: EditorCommitDirection) => EditorCommitResult | void;
31
32
  onCancel: () => void;
32
33
  onRegisterFlush?: ((flush: (() => void) | null) => void) | undefined;
34
+ onRegisterLateCommit?: ((receiver: LateEditCommitReceiver) => () => void) | undefined;
33
35
  align?: 'left' | 'center' | 'right' | undefined;
34
36
  enterMove?: EditorEnterMove | undefined;
35
37
  domId?: string | undefined;
@@ -1,9 +1,11 @@
1
1
  import type { JSX } from '@solidjs/web';
2
2
  import type { CellEditorContext } from '@ishibashi0112/spreadsheet-grid-core';
3
+ import type { LateEditCommitReceiver } from '@ishibashi0112/spreadsheet-grid-core/internal/controllers/editController';
3
4
  import type { SolidGridTypes } from '../model/gridTypes.js';
4
5
  type CustomCellEditorProps<T> = {
5
6
  render: (ctx: CellEditorContext<T, SolidGridTypes>) => JSX.Element;
6
7
  context: CellEditorContext<T, SolidGridTypes>;
8
+ onRegisterLateCommit?: ((receiver: LateEditCommitReceiver) => () => void) | undefined;
7
9
  };
8
10
  export declare function CustomCellEditor<T>(props: CustomCellEditorProps<T>): JSX.Element;
9
11
  export {};