@ishibashi0112/spreadsheet-grid 0.50.0 → 0.52.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 +22 -3
- package/dist/ColumnFilterPopover-B7RIBAz5.cjs +1 -0
- package/dist/ColumnFilterPopover-Bca4dkRt.js +1021 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2608 -4246
- package/dist/toolPanelViews-B6D8xn1e.js +657 -0
- package/dist/toolPanelViews-DQ4E0PbH.cjs +1 -0
- package/dist/useVirtualizerCore-CzoP0AUm.cjs +1 -0
- package/dist/useVirtualizerCore-q794NurB.js +21 -0
- package/dist/view/lazyPopups.d.ts +17 -0
- package/dist/view/toolPanelViews.d.ts +4 -0
- package/package.json +2 -2
package/API_REFERENCE.md
CHANGED
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
| `undoHistoryLimit` | `number` | `100` | 保持する undo ステップ数の上限。超過分は古い順に破棄。 |
|
|
54
54
|
| `enableClearOnDelete` | `boolean` | `true` | `Delete` / `Backspace` キーによる選択セル(なければアクティブセル)の値クリア。`false` でキーは何もしない(素通し)。ペースト・エディタでの上書き・undo/redo には影響しない(クリアのキーボード操作だけの opt-out)。 |
|
|
55
55
|
| `editorEnterMove` | `EditorEnterMove` | `'down'` | 組み込みエディタ(text / number / select / date)の `Enter` 確定後にアクティブセルをどこへ移すか(`'down'` \| `'up'` \| `'right'` \| `'left'` \| `'none'`。Excel の「Enter キーを押したら、セルを移動する(方向)」相当)。`'none'` は移動せずその場に留まる。`Tab` / `Shift+Tab`(右 / 左)と `Escape` には影響しない。custom エディタはキーバインドが consumer 責務のため対象外(`ctx.commit(value, direction)` の direction で指定)。 |
|
|
56
|
-
| `imeDirectInput` | `boolean` | `false` | **IME オンのままの直接入力**(Excel / SPREAD と同じ)。`true` で、編集していないあいだグリッドのフォーカスをアクティブセル上の透明な入力欄(入力受け)に置き、IME の変換をそこで始める。text エディタ(`editor` 未指定 / `type: 'text'`)の編集可能セルでは変換中の文字をセルの上に表示し、変換を確定すると確定した文字列を初期値に編集を始める(もう一度 `Enter` でセルを確定して移動)
|
|
56
|
+
| `imeDirectInput` | `boolean` | `false` | **IME オンのままの直接入力**(Excel / SPREAD と同じ)。`true` で、編集していないあいだグリッドのフォーカスをアクティブセル上の透明な入力欄(入力受け)に置き、IME の変換をそこで始める。text エディタ(`editor` 未指定 / `type: 'text'`)の編集可能セルでは変換中の文字をセルの上に表示し、変換を確定すると確定した文字列を初期値に編集を始める(もう一度 `Enter` でセルを確定して移動)。number エディタの列では確定した全角の数字・符号・小数点・3 桁区切りを半角に直して編集を始め(「12.5」→ `12.5`)、数値として読めない変換は捨てる。それ以外の列(select / date / checkbox / custom)と読み取り専用セルでは変換を捨てる(従来どおり何も入らない)。キー操作 / コピー・貼り付け / `Tab` は従来どおり。既定 OFF の理由: 有効中はグリッドにフォーカスがあるあいだ `document.activeElement` が入力欄になり、入力欄では反応しないアプリのショートカット(例: Mantine の `useHotkeys` の既定)が効かなくなるため。詳細は「IME オンのままの直接入力」節。 |
|
|
57
57
|
| `onUndoRedoStateChange` | `(state: UndoRedoState) => void` | — | undo / redo 可能状態が**変化したとき**に呼ばれる(ツールバーの undo/redo ボタンの disabled 表示などリアクティブな UI 用)。初回マウントでは発火せず、同値では再発火しない。毎レンダーのインライン関数でも問題ない。引数の型 `UndoRedoState`(`{ canUndo, canRedo }`)はパッケージから import できる。 |
|
|
58
58
|
| `enableRangeSelection` | `boolean` | `true` | 複数セル範囲選択。 |
|
|
59
59
|
| `enableRowSelection` | `boolean` | `false` | チェックボックス行選択の有効化(マスタースイッチ)。`true` で行ヘッダ(行NO)ガターが行選択のヒット領域になり、Excel 風のガター起点セル範囲選択は off(ボディ側セルのドラッグ範囲選択は不変)。判定は O(1)・全選択は除外集合でキーを列挙しない(1M 行でも一定コスト)。 |
|
|
@@ -413,7 +413,8 @@ const gridRef = useRef<SpreadsheetGridHandle<Row>>(null);
|
|
|
413
413
|
```
|
|
414
414
|
|
|
415
415
|
- **動き**: 編集していないあいだ、グリッドのフォーカスはアクティブセルの上の透明な入力欄(入力受け)にあります。日本語を打ち始めると変換中の文字がセルの上にエディタと同じ見た目で表示され、変換を確定(`Enter` / 候補の確定)すると確定した文字列を初期値に編集が始まります。そのまま続けて入力でき、もう一度 `Enter` でセルを確定して移動します(移動先は `editorEnterMove`)。変換を取り消した(`Escape` で空にした)ときは編集を始めません。
|
|
416
|
-
- **対象**: text エディタ(`editor` 未指定 / `type: 'text'`)
|
|
416
|
+
- **対象**: text エディタ(`editor` 未指定 / `type: 'text'`)と number エディタの編集可能なデータセル。select / date / checkbox / custom の列、読み取り専用セル、グループ行 / ラベル行、SSRM の未ロード行では変換を捨てます(従来どおり何も入りません)。
|
|
417
|
+
- **number 列**: 変換を確定すると、全角の数字・符号・小数点・3 桁区切りを半角に直した値で編集が始まります(「12.5」→ `12.5`、「ー5」→ `-5`、「1,234」→ `1234`。句読点の設定が「、。」の IME で入る「12。5」も `12.5`)。かなや漢字など数値として読めない変換は捨てます。IME そのものはオフにしません(ブラウザからは IME をオンへ戻せないため。Chrome / Edge は CSS の `ime-mode` にも対応していません)。
|
|
417
418
|
- **変わらないもの**: 矢印 / `Tab` / `Enter` / `F2` / `Delete` / `Ctrl+C` / 貼り付け / undo などのキー操作、IME を使わない文字キーでの編集開始(その 1 文字が初期値)、端の列の `Tab` でグリッド外へ出る動き。変換中のキー(候補の選択など)はグリッドでは扱いません。
|
|
418
419
|
- **変換中にクリックしたとき**: 変換中に別のセルやグリッド外をクリックすると、変換中の文字は入力されません(確定してから移動してください)。クリックした先のフォーカスは奪いません。
|
|
419
420
|
- **フォーカス**: 有効中は `document.activeElement` が入力受け(`input[data-ssg-ime-input]`)になります。グリッドにフォーカスがあるかを `gridElement.contains(document.activeElement)` で判定している場合は従来どおり動きますが、「入力欄にフォーカスがあるときは無効」になるショートカット(Mantine の `useHotkeys` の既定など)はグリッド上で効かなくなります。これが既定 OFF の理由です。
|
|
@@ -708,7 +709,7 @@ const columns = [
|
|
|
708
709
|
| type | UI / 操作 | オプション | 既定パーサ(`parseClipboardValue` 未指定時) |
|
|
709
710
|
| --- | --- | --- | --- |
|
|
710
711
|
| `'text'` | 従来のテキスト input(既定) | — | パススルー(生文字列のまま) |
|
|
711
|
-
| `'number'` | `<input type="number">`(スピナー / ↑↓ステップ / 不正文字抑止) | `min` / `max` / `step` | `''
|
|
712
|
+
| `'number'` | `<input type="number">`(スピナー / ↑↓ステップ / 不正文字抑止) | `min` / `max` / `step` | `''`・空白だけ→`null` / 有限数値文字列→`number`(全角の数字・符号・小数点と 3 桁区切りも読む: `'1,234'`→`1234`、`'ー5'`→`-5`)/ 非数値→生文字列のまま(mark が拾う) |
|
|
712
713
|
| `'select'` | 候補ドロップダウン(body 直下ポータル)。↑↓=ハイライト移動 / Enter=確定(下へ)/ Tab=確定(左右へ)/ クリック=確定 / 印字キー=label 前方一致のタイプアヘッド(約 700ms でリセット) | `options: GridSelectEditorOption[] \| (row) => GridSelectEditorOption[]`(静的 or 行依存。関数はレンダー中に呼ばれるため純粋であること) | パススルー(`option.value` は string。型変換したい場合は `parseClipboardValue` を併用) |
|
|
713
714
|
| `'date'` | ネイティブ `<input type="date">`。ドラフトは `'YYYY-MM-DD' \| ''` | — | `''`→`null` / 解釈可能→`'YYYY-MM-DD'` へ正規化 / 解釈不可→生文字列のまま |
|
|
714
715
|
| `'checkbox'` | **直接トグル**(編集セッションなし)。クリック / Space で即トグル。Enter / F2 / ダブルクリックではエディタが開かない | `checkedValue`(既定 `true`)/ `uncheckedValue`(既定 `false`)。checked 判定は `Object.is(value, checkedValue)` のみ | `''`→unchecked / checked・unchecked の文字列表現→対応値 / `'true'`・`'1'`→checked / その他→unchecked |
|
|
@@ -1560,6 +1561,23 @@ const dataSource: ServerSideDataSource<Row> = {
|
|
|
1560
1561
|
|
|
1561
1562
|
`initialRowCount` と内部の行数 state は mount 時に確定する。そのため **実行時にモードを切り替える場合は `key` を変えてグリッドを再マウントすること**(clientSide で mount 後に `dataSource` を後付けしても件数が初期化されない)。serverSide で直接 mount する通常利用ではこの限りではない。
|
|
1562
1563
|
|
|
1564
|
+
## ポップオーバー部品の遅延読み込み(`preloadGridPopups`)
|
|
1565
|
+
|
|
1566
|
+
列フィルターのポップオーバーと、ツールパネル(フィルター管理 / 列の表示 / 並び替え)の部品は本体と別のチャンクに分かれていて、初期の読み込みに含まれない(lazy-popups。初期の JS が約 1 割小さくなる。props / ハンドルは不変)。
|
|
1567
|
+
|
|
1568
|
+
- グリッドはマウント後、ブラウザが暇なとき(`requestIdleCallback`。無い環境では約 200ms 後)に、その機能が使えるときだけ部品を先読みする(列フィルター = `enableColumnFilter` かつ `filterType` を持つ列がある / ツールパネル = フィルター・列メニュー・ソートのどれかが使える)。
|
|
1569
|
+
- 先読みの前に開かれたときはその場で読み込み、読み込みが終わるまで部品は出ない(出たあと入力欄へフォーカスが入る。読み込み中も Escape で閉じられる)。先読みが終わっただけではグリッドは再描画しない。
|
|
1570
|
+
- 読み込みに失敗したときは `console.error` に出して閉じる(次に開いたときに読み直しを試みるが、ブラウザによっては失敗した動的 import をページの再読み込みまで覚えている)。
|
|
1571
|
+
- 動的 import(`import()`)に対応したバンドラー(Vite / webpack / Next.js / Rollup / esbuild など)が前提。CJS ビルドは `require` で読み込む。
|
|
1572
|
+
|
|
1573
|
+
```ts
|
|
1574
|
+
import { preloadGridPopups } from '@ishibashi0112/spreadsheet-grid';
|
|
1575
|
+
```
|
|
1576
|
+
|
|
1577
|
+
| 関数 | 説明 |
|
|
1578
|
+
| --- | --- |
|
|
1579
|
+
| `preloadGridPopups(): Promise<void>` | 部品を先に読み込む。通常は不要(グリッドが自動で先読みする)。テストでポップオーバーを開いた直後に同期で中身を確かめるとき(`beforeAll` で `await`)や、画面遷移の前に読み込んでおきたいときに使う。 |
|
|
1580
|
+
|
|
1563
1581
|
## テスト支援(`/testing` サブパス)
|
|
1564
1582
|
|
|
1565
1583
|
jsdom はレイアウトを計算しないため、素の jsdom では実グリッドの行・列が 1 本も描画されない(縦: スクロール要素の `clientHeight` / `clientWidth` が 0。横: 列仮想化(`@tanstack/virtual-core`)が **ResizeObserver の通知**から矩形を得るため、no-op スタブでは幅 0 のまま)。`@ishibashi0112/spreadsheet-grid/testing` の `installJsdomLayoutStubs()` がこれをまとめて解決する(proposals ③)。
|
|
@@ -1577,6 +1595,7 @@ beforeAll(() => {
|
|
|
1577
1595
|
- 返り値はインストール前へ戻す restore 関数(`afterAll(restore)` 用・任意)。
|
|
1578
1596
|
- React 非依存の小さなモジュールで、本体バンドルとは独立(`dist/testing.js`)。
|
|
1579
1597
|
- これで `.ssg-body-row` / `.ssg-body-cell` の描画・付与クラス・セル文字列を DOM で検証できる(本体の `SpreadsheetGrid.jsdomLayoutStubs.integration.test.tsx` が動作保証)。
|
|
1598
|
+
- 列フィルターのポップオーバー / ツールパネルを開いた直後に**同期で**中身を確かめるテストでは、部品の遅延読み込みが終わっていないと出ていない。`beforeAll(() => preloadGridPopups())`(本体から import)で先に読み込むか、`findBy*` / `waitFor` で待つ([ポップオーバー部品の遅延読み込み](#ポップオーバー部品の遅延読み込みpreloadgridpopups))。
|
|
1580
1599
|
|
|
1581
1600
|
## パーツ別スロット(`classNames` / `GridSlotProps`)
|
|
1582
1601
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./useVirtualizerCore-CzoP0AUm.cjs");let t=require("react"),n=require("@ishibashi0112/spreadsheet-grid-core/logic/cx"),r=require("react-dom"),i=require("react/jsx-runtime"),a=require("@ishibashi0112/spreadsheet-grid-core/logic/filtering"),o=require("@ishibashi0112/spreadsheet-grid-core/logic/dateFilterPresets"),s=require("@ishibashi0112/spreadsheet-grid-core/logic/setFilterSearch"),c=require("@ishibashi0112/spreadsheet-grid-core/logic/setFilterSelection"),l=require("@ishibashi0112/spreadsheet-grid-core/logic/numberFilterCondition"),u=require("@ishibashi0112/spreadsheet-grid-core/logic/textFilterCondition"),d=require("@ishibashi0112/spreadsheet-grid-core/logic/dateFilterCondition"),f=require("@ishibashi0112/spreadsheet-grid-core/logic/datePickerCalendar"),p=require("@ishibashi0112/spreadsheet-grid-core/logic/dateFilterTree");function m({value:e,onCommit:r,ariaLabel:o,inputRef:s,onRequestClose:c,align:l=`left`}){let[u,d]=(0,t.useState)(null),[p,m]=(0,t.useState)(!1),[h,g]=(0,t.useState)(!1),[_,v]=(0,t.useState)(`days`),[y,b]=(0,t.useState)(()=>new Date().getFullYear()),[x,S]=(0,t.useState)(()=>new Date().getMonth()),C=(0,t.useRef)(null),w=u??(0,f.formatFilterDateDisplay)(e),T=(0,a.toDateKey)(new Date)??``,E=()=>{if(u===null)return;let e=u.trim();if(e===``){r(``),d(null),m(!1);return}let t=(0,a.toDateKey)(e);if(t===null){m(!0);return}r(t),d(null),m(!1)},D=()=>{let[t,n]=(e===``?T:e).split(`-`);b(Number(t)),S(Number(n)-1),v(`days`),g(!0)},O=()=>{g(!1)},k=e=>{r(e),d(null),m(!1),O()};(0,t.useEffect)(()=>{if(!h)return;let e=e=>{let t=e.target;t&&C.current?.contains(t)||g(!1)};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[h]);let A=e=>{if(e.stopPropagation(),e.key===`Enter`){if(e.nativeEvent.isComposing)return;e.preventDefault(),E(),O();return}if(e.key===`Escape`){if(e.preventDefault(),h){O();return}c()}},j=e=>({onPointerDown:t=>{t.preventDefault(),t.stopPropagation(),e()},onKeyDown:t=>{t.stopPropagation(),(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())}}),M=e=>{if(_===`days`){let t=new Date(y,x+e,1);b(t.getFullYear()),S(t.getMonth());return}if(_===`months`){b(t=>t+e);return}b(t=>t+e*12)},N=()=>{v(e=>e===`days`?`months`:`years`)},P=()=>{v(e=>e===`years`?`months`:`days`)},F=_===`days`?(0,f.formatCalendarTitle)(y,x):_===`months`?`${y}年`:`${(0,f.yearGridStart)(y)} – ${(0,f.yearGridStart)(y)+11}`;return(0,i.jsxs)(`div`,{ref:C,className:`ssg-dp-root`,children:[(0,i.jsxs)(`div`,{className:(0,n.cx)(`ssg-dp-field`,h&&`ssg-dp-field--open`,p&&`ssg-dp-field--invalid`),children:[(0,i.jsx)(`input`,{ref:s,type:`text`,inputMode:`numeric`,value:w,placeholder:`yyyy/mm/dd`,"aria-label":o,"aria-invalid":p||void 0,className:`ssg-dp-input`,onChange:e=>{d(e.target.value),m(!1)},onKeyDown:A,onBlur:E}),(0,i.jsx)(`button`,{type:`button`,className:`ssg-dp-cal-btn`,"aria-label":h?`カレンダーを閉じる`:`カレンダーを開く`,...j(()=>{h?O():D()}),children:(0,i.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,i.jsx)(`rect`,{x:`1.5`,y:`2.5`,width:`13`,height:`12`,rx:`1.5`,fill:`none`,stroke:`currentColor`}),(0,i.jsx)(`line`,{x1:`1.5`,y1:`6`,x2:`14.5`,y2:`6`,stroke:`currentColor`}),(0,i.jsx)(`line`,{x1:`5`,y1:`1`,x2:`5`,y2:`4`,stroke:`currentColor`}),(0,i.jsx)(`line`,{x1:`11`,y1:`1`,x2:`11`,y2:`4`,stroke:`currentColor`})]})})]}),h&&(0,i.jsxs)(`div`,{className:(0,n.cx)(`ssg-dp-panel`,l===`right`&&`ssg-dp-panel--right`),children:[(0,i.jsxs)(`div`,{className:`ssg-dp-nav`,children:[(0,i.jsx)(`button`,{type:`button`,className:`ssg-dp-nav-btn`,"aria-label":`前へ`,...j(()=>M(-1)),children:`‹`}),(0,i.jsx)(`button`,{type:`button`,className:`ssg-dp-nav-title`,disabled:_===`years`,"aria-label":`表示単位を切り替える`,...j(N),children:F}),(0,i.jsx)(`button`,{type:`button`,className:`ssg-dp-nav-btn`,"aria-label":`次へ`,...j(()=>M(1)),children:`›`})]}),_===`days`&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`div`,{className:`ssg-dp-dow`,children:f.CALENDAR_DOW_LABELS.map((e,t)=>(0,i.jsx)(`span`,{className:(0,n.cx)(t===0&&`ssg-dp-dow--sun`,t===6&&`ssg-dp-dow--sat`),children:e},e))}),(0,i.jsx)(`div`,{className:`ssg-dp-days`,children:(0,f.buildCalendarDayCells)(y,x).map(t=>(0,i.jsx)(`button`,{type:`button`,className:(0,n.cx)(`ssg-dp-day`,!t.inCurrentMonth&&`ssg-dp-day--out`,t.key===T&&`ssg-dp-day--today`,t.key===e&&`ssg-dp-day--selected`),"aria-label":t.key,...j(()=>k(t.key)),children:t.day},t.key))})]}),_===`months`&&(0,i.jsx)(`div`,{className:`ssg-dp-grid`,children:f.CALENDAR_MONTH_LABELS.map((e,t)=>(0,i.jsx)(`button`,{type:`button`,className:(0,n.cx)(`ssg-dp-cell`,t===x&&`ssg-dp-cell--selected`),...j(()=>{S(t),v(`days`)}),children:e},e))}),_===`years`&&(0,i.jsx)(`div`,{className:`ssg-dp-grid`,children:(0,f.buildYearGrid)(y).map(e=>(0,i.jsx)(`button`,{type:`button`,className:(0,n.cx)(`ssg-dp-cell`,e===y&&`ssg-dp-cell--selected`),...j(()=>{b(e),v(`months`)}),children:e},e))}),(0,i.jsxs)(`div`,{className:`ssg-dp-foot`,children:[_!==`days`&&(0,i.jsx)(`button`,{type:`button`,className:`ssg-dp-foot-btn`,...j(P),children:`← 戻る`}),(0,i.jsx)(`button`,{type:`button`,className:`ssg-dp-foot-btn`,...j(()=>k(T)),children:`今日`}),(0,i.jsx)(`button`,{type:`button`,className:`ssg-dp-foot-btn ssg-dp-foot-btn--muted`,...j(()=>k(``)),children:`クリア`})]})]})]})}var h=24;function g({options:n,setSelection:r,searchInputRef:a,onValueToggle:o,onSelectAllChange:l,onReplaceSelection:u,onRequestClose:d,isServerSide:f,selectAllUsesExplicitScope:p=!1,truncated:m=!1}){let[g,_]=(0,t.useState)(``),v=(0,t.useDeferredValue)(g),y=(0,t.useMemo)(()=>(0,s.filterSetOptionsBySearch)(n,v),[n,v]),b=v.trim().length>0,x=(0,t.useRef)(null),S=e.t({count:y.length,getScrollElement:()=>x.current,estimateSize:()=>h,overscan:10}),C=(0,t.useMemo)(()=>{if(r===null)return y.length;let e=0;for(let t of y)(0,c.isSetValueSelected)(r,t.value)&&(e+=1);return e},[r,y]),T=y.length>0&&C===y.length,E=C>0&&!T,D=(0,t.useMemo)(()=>new Set(n.map(e=>e.value)),[n]),O=(0,t.useMemo)(()=>{if(r===null)return n.length;let e=0;for(let t of r.values)D.has(t)&&(e+=1);return r.mode===`include`?e:n.length-e},[r,D,n.length]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`input`,{ref:a,type:`text`,value:g,onChange:e=>_(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`&&(e.preventDefault(),d()),e.key===`Enter`){if(e.nativeEvent.isComposing)return;e.preventDefault();let t=(0,s.resolveSetFilterEnterAction)(n,g);if(t.kind===`none`)return;t.kind===`replace`&&u(t.values),d()}},placeholder:`検索(Enter で確定)`,className:`ssg-filter-input`}),(0,i.jsxs)(`label`,{className:`ssg-filter-selectall`,children:[(0,i.jsx)(`input`,{type:`checkbox`,checked:T,ref:e=>{e&&(e.indeterminate=E)},onChange:()=>{l(b||p?y.map(e=>e.value):`all`,!T)}}),(0,i.jsx)(`span`,{className:`ssg-filter-selectall-label`,children:b?`(検索結果をすべて選択)`:`(すべて選択)`})]}),(0,i.jsx)(`div`,{ref:x,className:`ssg-filter-list`,children:y.length===0?(0,i.jsx)(`div`,{className:`ssg-filter-empty`,children:n.length===0?f?`候補が未指定です(serverSide では列に filterOptions などの候補供給が必要)`:`候補がありません`:`一致する候補がありません`}):(0,i.jsx)(`div`,{className:`ssg-filter-virt`,style:{height:S.getTotalSize()},children:S.getVirtualItems().map(e=>{let t=y[e.index];if(!t)return null;let n=(0,c.isSetValueSelected)(r,t.value);return(0,i.jsxs)(`label`,{className:`ssg-filter-option`,style:{transform:`translateY(${e.start}px)`,height:e.size},children:[(0,i.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>o(t.value)}),(0,i.jsx)(`span`,{className:`ssg-filter-option-label`,children:t.label})]},t.value)})})}),(0,i.jsxs)(`div`,{className:`ssg-filter-meta`,children:[`選択中: `,O,` / `,n.length,` 件`,b?`(表示中 ${y.length} 件)`:``,m&&(0,i.jsx)(w,{})]})]})}var _=e=>e.nativeEvent.isComposing===!0,v=(e,t,n)=>{if(_(n)){e(t,{commit:!1});return}e(t)};function y({draft:e,valueInputRef:t,onDraftChange:n,onKeyDown:r}){let a=(0,l.numberFilterOperandCount)(e.operator);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`select`,{value:e.operator,onChange:t=>n({...e,operator:t.target.value}),onKeyDown:r,className:`ssg-filter-select`,"aria-label":`条件の演算子`,children:l.NUMBER_FILTER_OPERATOR_OPTIONS.map(e=>(0,i.jsx)(`option`,{value:e.value,children:e.label},e.value))}),a>0?(0,i.jsxs)(`div`,{className:`ssg-filter-cond-values`,children:[(0,i.jsx)(`input`,{ref:t,type:`text`,inputMode:`decimal`,value:e.value1,onChange:t=>v(n,{...e,value1:t.target.value},t),onCompositionEnd:t=>n({...e,value1:t.currentTarget.value}),onKeyDown:r,placeholder:a===2?`下限`:`値`,className:`ssg-filter-input`,"aria-label":a===2?`下限`:`条件の値`}),a===2&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`span`,{className:`ssg-filter-cond-tilde`,children:`〜`}),(0,i.jsx)(`input`,{type:`text`,inputMode:`decimal`,value:e.value2,onChange:t=>v(n,{...e,value2:t.target.value},t),onCompositionEnd:t=>n({...e,value2:t.currentTarget.value}),onKeyDown:r,placeholder:`上限`,className:`ssg-filter-input`,"aria-label":`上限`})]})]}):(0,i.jsx)(`div`,{className:`ssg-filter-meta`,children:`この演算子は値入力を使いません`})]})}function b({draft:e,valueInputRef:t,onDraftChange:n,onKeyDown:r}){let a=(0,u.textFilterOperandCount)(e.operator);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`select`,{value:e.operator,onChange:t=>n({...e,operator:t.target.value}),onKeyDown:r,className:`ssg-filter-select`,"aria-label":`条件の演算子`,children:u.TEXT_FILTER_OPERATOR_OPTIONS.map(e=>(0,i.jsx)(`option`,{value:e.value,children:e.label},e.value))}),a>0?(0,i.jsx)(`div`,{className:`ssg-filter-cond-values`,children:(0,i.jsx)(`input`,{ref:t,type:`text`,value:e.value,onChange:t=>v(n,{...e,value:t.target.value},t),onCompositionEnd:t=>n({...e,value:t.currentTarget.value}),onKeyDown:r,placeholder:`値`,className:`ssg-filter-input`,"aria-label":`条件の値`})}):(0,i.jsx)(`div`,{className:`ssg-filter-meta`,children:`この演算子は値入力を使いません`})]})}function x({draft:e,valueInputRef:t,onDraftChange:r,onKeyDown:a,presets:o,renderDateInput:s,onRequestClose:c}){let l=e.preset===null?(0,d.dateFilterOperandCount)(e.operator):0,u=(t,n)=>{r({...e,[t]:(0,d.normalizeFilterDateInputValue)(n),preset:null})};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`select`,{value:e.operator,onChange:t=>r({...e,operator:t.target.value,preset:null}),onKeyDown:a,className:`ssg-filter-select`,"aria-label":`条件の演算子`,children:d.DATE_FILTER_OPERATOR_OPTIONS.map(e=>(0,i.jsx)(`option`,{value:e.value,children:e.label},e.value))}),l>0?(0,i.jsxs)(`div`,{className:`ssg-filter-cond-values`,children:[s?s({value:e.value1,onChange:e=>u(`value1`,e),ariaLabel:l===2?`開始日`:`条件の日付`,slot:l===2?`from`:`single`}):(0,i.jsx)(m,{value:e.value1,onCommit:t=>r({...e,value1:t,preset:null}),ariaLabel:l===2?`開始日`:`条件の日付`,inputRef:t,onRequestClose:c}),l===2&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`span`,{className:`ssg-filter-cond-tilde`,children:`〜`}),s?s({value:e.value2,onChange:e=>u(`value2`,e),ariaLabel:`終了日`,slot:`to`}):(0,i.jsx)(m,{value:e.value2,onCommit:t=>r({...e,value2:t,preset:null}),ariaLabel:`終了日`,onRequestClose:c,align:`right`})]})]}):e.preset===null?(0,i.jsx)(`div`,{className:`ssg-filter-meta`,children:`この演算子は値入力を使いません`}):null,o.length>0&&(0,i.jsx)(`div`,{className:`ssg-filter-presets`,children:o.map(t=>(0,i.jsx)(`button`,{type:`button`,onPointerDown:n=>{n.preventDefault(),n.stopPropagation(),r({...e,preset:e.preset===t.id?null:t.id})},onKeyDown:n=>{n.stopPropagation(),(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),r({...e,preset:e.preset===t.id?null:t.id}))},className:(0,n.cx)(`ssg-filter-preset-chip`,e.preset===t.id&&`ssg-filter-preset-chip--active`),children:t.label},t.id))})]})}function S({options:n,setSelection:r,searchInputRef:a,onValueToggle:o,onSelectAllChange:l,onReplaceSelection:u,onRequestClose:d,isServerSide:f,truncated:m=!1}){let[g,_]=(0,t.useState)(``),v=(0,t.useDeferredValue)(g),[y,b]=(0,t.useState)(()=>new Set),x=v.trim().length>0,S=(0,t.useMemo)(()=>(0,s.filterSetOptionsBySearch)(n,v),[n,v]),C=(0,t.useMemo)(()=>(0,p.buildDateTreeRows)(n,y),[n,y]),T=(0,t.useRef)(null),E=x?S.length:C.length,D=e.t({count:E,getScrollElement:()=>T.current,estimateSize:()=>h,overscan:10}),O=(0,t.useMemo)(()=>(x?S:n).map(e=>e.value),[x,S,n]),k=(0,t.useMemo)(()=>{let e=0;for(let t of O)(0,c.isSetValueSelected)(r,t)&&(e+=1);return e},[O,r]),A=O.length>0&&k===O.length,j=k>0&&!A,M=(0,t.useMemo)(()=>new Set(n.map(e=>e.value)),[n]),N=(0,t.useMemo)(()=>{if(r===null)return n.length;let e=0;for(let t of r.values)M.has(t)&&(e+=1);return r.mode===`include`?e:n.length-e},[r,M,n.length]),P=e=>{b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},F=e=>{let t=0;for(let n of e)(0,c.isSetValueSelected)(r,n)&&(t+=1);return t},I=e=>{let t=F(e.leafKeys),n=e.leafKeys.length>0&&t===e.leafKeys.length,r=t>0&&!n;return(0,i.jsxs)(i.Fragment,{children:[e.type===`group`?(0,i.jsx)(`button`,{type:`button`,onPointerDown:t=>{t.preventDefault(),t.stopPropagation(),P(e.key)},onKeyDown:t=>{t.stopPropagation(),(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),P(e.key))},className:`ssg-filter-tree-toggle`,"aria-label":e.expanded?`折りたたむ`:`展開する`,children:e.expanded?`▾`:`▸`}):(0,i.jsx)(`span`,{className:`ssg-filter-tree-toggle ssg-filter-tree-toggle--placeholder`}),(0,i.jsx)(`input`,{type:`checkbox`,checked:n,ref:e=>{e&&(e.indeterminate=r)},onChange:()=>{if(e.type===`leaf`){o(e.key);return}l(e.leafKeys,!n)}}),(0,i.jsx)(`span`,{className:`ssg-filter-option-label`,children:e.label})]})};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`input`,{ref:a,type:`text`,value:g,onChange:e=>_(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`&&(e.preventDefault(),d()),e.key===`Enter`){if(e.nativeEvent.isComposing)return;e.preventDefault();let t=(0,s.resolveSetFilterEnterAction)(n,g);if(t.kind===`none`)return;t.kind===`replace`&&u(t.values),d()}},placeholder:`検索(Enter で確定)`,className:`ssg-filter-input`}),(0,i.jsxs)(`label`,{className:`ssg-filter-selectall`,children:[(0,i.jsx)(`input`,{type:`checkbox`,checked:A,ref:e=>{e&&(e.indeterminate=j)},onChange:()=>l(O,!A)}),(0,i.jsx)(`span`,{className:`ssg-filter-selectall-label`,children:x?`(検索結果をすべて選択)`:`(すべて選択)`})]}),(0,i.jsx)(`div`,{ref:T,className:`ssg-filter-list`,children:E===0?(0,i.jsx)(`div`,{className:`ssg-filter-empty`,children:n.length===0?f?`候補が未指定です(serverSide では列に filterOptions などの候補供給が必要)`:`候補がありません`:`一致する候補がありません`}):(0,i.jsx)(`div`,{className:`ssg-filter-virt`,style:{height:D.getTotalSize()},children:D.getVirtualItems().map(e=>{if(x){let t=S[e.index];return t?(0,i.jsxs)(`label`,{className:`ssg-filter-option`,style:{transform:`translateY(${e.start}px)`,height:e.size},children:[(0,i.jsx)(`input`,{type:`checkbox`,checked:(0,c.isSetValueSelected)(r,t.value),onChange:()=>o(t.value)}),(0,i.jsx)(`span`,{className:`ssg-filter-option-label`,children:t.label})]},t.value):null}let t=C[e.index];return t?(0,i.jsx)(`div`,{className:`ssg-filter-option`,style:{transform:`translateY(${e.start}px)`,height:e.size,paddingLeft:8+t.depth*16},children:I(t)},t.key):null})})}),(0,i.jsxs)(`div`,{className:`ssg-filter-meta`,children:[`選択中: `,N,` / `,n.length,` 件`,x?`(表示中 ${S.length} 件)`:``,m&&(0,i.jsx)(w,{})]})]})}function C({status:e,errorMessage:t,onRetry:n}){return e===`loading`?(0,i.jsx)(`div`,{className:`ssg-filter-collecting`,children:`候補を取得中…`}):(0,i.jsxs)(`div`,{className:`ssg-filter-error`,role:`alert`,children:[(0,i.jsx)(`div`,{children:`候補の取得に失敗しました`}),t?(0,i.jsx)(`div`,{className:`ssg-filter-error-detail`,title:t,children:t}):null,n?(0,i.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),n()},onKeyDown:e=>{e.stopPropagation(),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())},className:`ssg-filter-btn-secondary`,children:`再試行`}):null]})}function w(){return(0,i.jsx)(`span`,{className:`ssg-filter-truncated`,children:`(先頭のみ・打ち切り)`})}function T({conditionEditor:e,conditionActive:t,onConditionClear:n,options:r,setSelection:a,onSelectionClear:o,summaryText:s,children:c,optionsMeta:l}){return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(`div`,{className:`ssg-filter-sec-head`,children:[(0,i.jsx)(`span`,{className:`ssg-filter-sec-label`,children:`条件`}),(0,i.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),n()},onKeyDown:e=>{e.stopPropagation(),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())},className:`ssg-filter-sec-clear`,disabled:!t,children:`クリア`})]}),e,(0,i.jsx)(`div`,{className:`ssg-filter-sep`}),(0,i.jsxs)(`div`,{className:`ssg-filter-sec-head`,children:[(0,i.jsx)(`span`,{className:`ssg-filter-sec-label`,children:`値`}),(0,i.jsx)(`span`,{className:`ssg-filter-sec-meta`,children:l??(t?`一致 ${r.length} 件`:`全 ${r.length} 件`)}),(0,i.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),o()},onKeyDown:e=>{e.stopPropagation(),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),o())},className:`ssg-filter-sec-clear`,disabled:a===null,children:`クリア`})]}),c,(0,i.jsxs)(`div`,{className:`ssg-filter-summary`,children:[`🔽 `,s]})]})}function E({isOpen:e,themeClassName:a,popoverSlot:s,title:c,filterType:f,draftValue:p,numberConditionDraft:m,onNumberConditionDraftChange:h,textConditionDraft:_,onTextConditionDraftChange:v,dateConditionDraft:E,onDateConditionDraftChange:D,datePresets:O,renderDateInput:k,onComboConditionClear:A,onComboSelectionClear:j,comboSummaryText:M,currentValueText:N,layout:P,selectOptions:F,optionsStatus:I,optionsProgress:ee,optionsTruncated:L=!1,optionsErrorMessage:te,onOptionsRetry:ne,setSelection:R,popoverRef:re,textInputRef:z,selectRef:ie,onRequestClose:B,onDraftChange:ae,onApply:V,onClear:oe,onSetValueToggle:H,onSetSelectAllChange:U,onSetClear:se,onSetReplaceSelection:W,isServerSide:G=!1}){let ce=(0,t.useRef)(null),[le]=(0,t.useState)(()=>new Date);if(typeof document>`u`||!e||!P)return null;let ue={top:P.top,left:P.left,width:P.width,maxHeight:P.maxHeight},de=e=>{e.stopPropagation()},fe=e=>{e.stopPropagation()},pe=f===`set`,K=f===`numberSet`,q=f===`textSet`,J=f===`dateSet`,Y=K||q||J,X=pe||Y,me=I===`loading`||I===`error`,Z=m??l.DEFAULT_NUMBER_FILTER_DRAFT,he=_??u.DEFAULT_TEXT_FILTER_DRAFT,ge=E??d.DEFAULT_DATE_FILTER_DRAFT,_e=O??(0,o.normalizeDateFilterPresets)(void 0),ve=K?(0,l.buildParsedNumberFilterFromDraft)(Z):null,ye=q?(0,u.buildParsedTextFilterFromDraft)(he):null,be=J?(0,d.buildParsedDateFilterFromDraft)(ge):null,xe=ve!==null||ye!==null||be!==null,Q=K?(0,l.filterOptionsByNumberCondition)(F,ve):q?(0,u.filterOptionsByTextCondition)(F,ye):J?(0,d.filterOptionsByDateCondition)(F,be,le,_e):F,$=e=>{if(e.stopPropagation(),!e.nativeEvent.isComposing){if(e.key===`Enter`){e.preventDefault(),V();return}e.key===`Escape`&&(e.preventDefault(),B())}},Se=K?(0,i.jsx)(y,{draft:Z,valueInputRef:z,onDraftChange:h,onKeyDown:$}):q?(0,i.jsx)(b,{draft:he,valueInputRef:z,onDraftChange:v,onKeyDown:$}):(0,i.jsx)(x,{draft:ge,valueInputRef:z,onDraftChange:D,onKeyDown:$,presets:_e,renderDateInput:k,onRequestClose:B});return(0,r.createPortal)((0,i.jsxs)(`div`,{ref:re,onPointerDown:fe,onKeyDown:de,onPasteCapture:e=>{e.stopPropagation()},className:(0,n.cx)(`ssg-filter-popover`,a,s?.className),style:{...s?.style,...ue},children:[(0,i.jsxs)(`div`,{className:`ssg-filter-title`,children:[`列フィルター: `,c]}),(X||f===`select`)&&I===`collecting`?(0,i.jsxs)(`div`,{className:`ssg-filter-collecting`,children:[`候補を収集中… `,Math.round(ee*100),`%`]}):(X||f===`select`)&&me?Y?(0,i.jsx)(T,{conditionEditor:Se,conditionActive:xe,onConditionClear:A,options:Q,setSelection:R,onSelectionClear:j,summaryText:M,optionsMeta:I===`loading`?`取得中…`:`取得失敗`,children:(0,i.jsx)(C,{status:I===`loading`?`loading`:`error`,errorMessage:te,onRetry:ne})}):(0,i.jsx)(C,{status:I===`loading`?`loading`:`error`,errorMessage:te,onRetry:ne}):Y?(0,i.jsx)(T,{conditionEditor:Se,conditionActive:xe,onConditionClear:A,options:Q,setSelection:R,onSelectionClear:j,summaryText:M,children:J?(0,i.jsx)(S,{options:Q,setSelection:R,searchInputRef:ce,onValueToggle:H,onSelectAllChange:U,onReplaceSelection:W,onRequestClose:B,isServerSide:G,truncated:L}):(0,i.jsx)(g,{options:Q,setSelection:R,searchInputRef:ce,onValueToggle:H,onSelectAllChange:U,onReplaceSelection:W,onRequestClose:B,isServerSide:G,selectAllUsesExplicitScope:!0,truncated:L})}):pe?(0,i.jsx)(g,{options:F,setSelection:R,searchInputRef:z,onValueToggle:H,onSelectAllChange:U,onReplaceSelection:W,onRequestClose:B,isServerSide:G,truncated:L}):f===`number`?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`div`,{className:`ssg-filter-hint`,children:`フィルター種別: number`}),(0,i.jsx)(y,{draft:Z,valueInputRef:z,onDraftChange:h,onKeyDown:$})]}):f===`select`?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`div`,{className:`ssg-filter-hint`,children:`フィルター種別: select`}),(0,i.jsxs)(`select`,{ref:ie,value:p,onChange:e=>ae(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Enter`){e.preventDefault(),V();return}e.key===`Escape`&&(e.preventDefault(),B())},className:`ssg-filter-select`,children:[(0,i.jsx)(`option`,{value:``,children:`(すべて)`}),F.map(e=>(0,i.jsx)(`option`,{value:e.value,children:e.label},`${c}-${e.value}`))]}),(0,i.jsxs)(`div`,{className:`ssg-filter-meta`,children:[`候補数: `,F.length,L&&(0,i.jsx)(w,{})]})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(`div`,{className:`ssg-filter-hint`,children:[`フィルター種別: `,f]}),(0,i.jsx)(`input`,{ref:z,type:`text`,value:p,onChange:e=>ae(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),!e.nativeEvent.isComposing){if(e.key===`Enter`){e.preventDefault(),V();return}e.key===`Escape`&&(e.preventDefault(),B())}},placeholder:`部分一致で絞り込み`,className:`ssg-filter-input`}),(0,i.jsx)(`div`,{className:`ssg-filter-meta ssg-filter-meta--ellipsis`,children:`部分一致検索です`})]}),!X&&(0,i.jsxs)(`div`,{className:`ssg-filter-meta ssg-filter-meta--ellipsis`,children:[`現在値: `,N]}),(0,i.jsx)(`div`,{className:`ssg-filter-footer`,children:X?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),se()},onKeyDown:e=>{e.stopPropagation(),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),se())},className:`ssg-filter-btn-secondary`,children:`クリア`}),(0,i.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),B()},onKeyDown:e=>{e.stopPropagation(),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),B())},className:`ssg-filter-btn-primary`,children:`閉じる`})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),oe()},onKeyDown:e=>{e.stopPropagation(),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),oe())},className:`ssg-filter-btn-secondary`,children:`クリア`}),(0,i.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),V()},onKeyDown:e=>{e.stopPropagation(),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),V())},className:`ssg-filter-btn-primary`,children:`適用`})]})})]}),document.body)}exports.ColumnFilterPopover=E,exports.default=E;
|