@ishibashi0112/spreadsheet-grid-solid 1.4.0 → 1.4.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 +1 -1
- package/README.md +2 -2
- package/dist/editors/CellEditorLayer.d.ts +2 -0
- package/dist/editors/CustomCellEditor.d.ts +2 -0
- package/dist/index.js +662 -643
- package/dist/source/index.jsx +37 -5
- package/dist/view/DetailToggleButton.d.ts +1 -0
- package/package.json +3 -3
- package/skills/spreadsheet-grid-solid/SKILL.md +1 -1
package/API_REFERENCE.md
CHANGED
|
@@ -1202,7 +1202,7 @@ const columns: GridColumn<Expense>[] = [
|
|
|
1202
1202
|
| `'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
1203
|
| `'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
1204
|
| `'checkbox'` | **直接トグル**(編集セッションなし)。チェックボックスそのものを押すか、アクティブセルで Space を押すと即トグル(セルのチェックボックスの外を押したときはアクティブセルになるだけ。ダブルクリックでも切り替わらない)。Enter / F2 / ダブルクリックではエディタが開かない | `checkedValue`(既定 `true`)/ `uncheckedValue`(既定 `false`)。checked 判定は `Object.is(value, checkedValue)` のみ | `''`→unchecked / checked・unchecked の文字列表現→対応値 / `'true'`・`'1'`→checked / その他→unchecked |
|
|
1205
|
-
| `'custom'` | `render(ctx)` の返り値を編集オーバーレイ内に描画。**フォーカス管理・キーバインドは利用側の責務**(
|
|
1205
|
+
| `'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
1206
|
|
|
1207
1207
|
注意点:
|
|
1208
1208
|
|
package/README.md
CHANGED
|
@@ -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
|
|
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()))`).
|
|
@@ -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
|
|
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 {};
|