@ishibashi0112/spreadsheet-grid 1.0.0 → 1.0.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 +99 -82
- package/README.md +4 -4
- package/dist/ColumnFilterPopover-VHTWLyQ7.cjs +1 -0
- package/dist/ColumnFilterPopover-xCX4O5Pb.js +1036 -0
- package/dist/editors/DateCellEditor.d.ts +2 -1
- package/dist/editors/NumberCellEditor.d.ts +2 -1
- package/dist/editors/SelectCellEditor.d.ts +2 -1
- package/dist/editors/TextCellEditor.d.ts +2 -1
- package/dist/hooks/useColumnSelectOptionsCollector.d.ts +2 -1
- package/dist/hooks/useGridViewportSync.d.ts +2 -1
- package/dist/index.cjs +7 -7
- package/dist/index.js +2875 -2771
- package/dist/lite/ColumnFilterPopover-BNzAJgCT.js +1036 -0
- package/dist/lite/ColumnFilterPopover-Dusx2AfV.cjs +1 -0
- package/dist/lite/columnMenu-C8LMgSDh.cjs +1 -0
- package/dist/lite/{columnMenu-tZSAVFch.js → columnMenu-DImtqeXz.js} +27 -12
- package/dist/lite/createSpreadsheetGrid-BsuvhGwN.cjs +7 -0
- package/dist/lite/createSpreadsheetGrid-CcUZV9Nl.js +4383 -0
- package/dist/lite/createSpreadsheetGrid.cjs +1 -1
- package/dist/lite/createSpreadsheetGrid.js +1 -1
- package/dist/lite/features/columnMenu.cjs +1 -1
- package/dist/lite/features/columnMenu.js +1 -1
- package/dist/lite/features/filtering.cjs +1 -1
- package/dist/lite/features/filtering.js +1 -1
- package/dist/lite/features/selectionAggregates.cjs +1 -1
- package/dist/lite/features/selectionAggregates.js +1 -1
- package/dist/lite/features/standard.cjs +1 -1
- package/dist/lite/features/standard.js +3 -3
- package/dist/lite/features/toolPanel.cjs +1 -1
- package/dist/lite/features/toolPanel.js +1 -1
- package/dist/lite/{filtering-DWiGawv7.js → filtering-BJD9TbJf.js} +14 -10
- package/dist/lite/filtering-CTgteY8F.cjs +1 -0
- package/dist/lite/{lazyPopups-BJXlFn1p.cjs → lazyPopups-BQZ_tQmx.cjs} +1 -1
- package/dist/lite/{lazyPopups-DVqRlLJf.js → lazyPopups-DbZ9rUbb.js} +1 -1
- package/dist/lite/{selectionAggregates-D5TcCyB5.cjs → selectionAggregates-CP0_LaAu.cjs} +1 -1
- package/dist/lite/{selectionAggregates-3u3kJh4W.js → selectionAggregates-CS_VR9ev.js} +14 -7
- package/dist/lite/{toolPanel-DZFTU5l3.js → toolPanel-DZ6JUS79.js} +1 -1
- package/dist/lite/{toolPanel-E0gQydUn.cjs → toolPanel-RciyWlun.cjs} +1 -1
- package/dist/lite/{toolPanelViews-CbMCZSFx.js → toolPanelViews-DYrngzT1.js} +2 -1
- package/dist/lite/toolPanelViews-DgY7fFl7.cjs +1 -0
- package/dist/lite.cjs +1 -1
- package/dist/lite.js +6 -6
- package/dist/style.css +1 -1
- package/dist/style.layer.css +1 -1
- package/dist/themes/heroui.css +2 -1
- package/dist/themes/shadcn.css +2 -1
- package/dist/toolPanelViews-BdtqSCJ6.cjs +1 -0
- package/dist/{toolPanelViews-BywJx-1p.js → toolPanelViews-C7C1j-ss.js} +2 -1
- package/package.json +2 -2
- package/skills/spreadsheet-grid/SKILL.md +7 -7
- package/dist/ColumnFilterPopover-BPUTyi1X.js +0 -1023
- package/dist/ColumnFilterPopover-C0BaV7ne.cjs +0 -1
- package/dist/lite/ColumnFilterPopover-CRrelKCm.cjs +0 -1
- package/dist/lite/ColumnFilterPopover-DZj1S5tC.js +0 -1023
- package/dist/lite/columnMenu-Dp1_-G7T.cjs +0 -1
- package/dist/lite/createSpreadsheetGrid--0D_J_WV.js +0 -4305
- package/dist/lite/createSpreadsheetGrid-BVm9M39W.cjs +0 -7
- package/dist/lite/filtering-SjDjhxZN.cjs +0 -1
- package/dist/lite/toolPanelViews-CRRJt6BV.cjs +0 -1
- package/dist/toolPanelViews-lSrwZauC.cjs +0 -1
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ More runnable examples (server-side row model, Astryx) are in [`examples/`](http
|
|
|
52
52
|
|
|
53
53
|
## Smaller bundles: `/lite` (0.54.0+)
|
|
54
54
|
|
|
55
|
-
`SpreadsheetGrid` includes every feature (about
|
|
55
|
+
`SpreadsheetGrid` includes every feature (about 136KB gzip of initial JS). The `/lite` entry builds a grid with only the features you pass; the rest is left out of your bundle (about 77KB with no features, about 99KB with the `standardFeatures` preset).
|
|
56
56
|
|
|
57
57
|
```tsx
|
|
58
58
|
import { createSpreadsheetGrid, standardFeatures, serverSideFeature } from '@ishibashi0112/spreadsheet-grid/lite'
|
|
@@ -100,7 +100,7 @@ This library is new, so AI coding assistants rarely know its API and tend to gue
|
|
|
100
100
|
- **Row keys.** Return a stable key from `rowKeyGetter` (the default is the row index).
|
|
101
101
|
- **`rows` or `dataSource`.** `rows` is the client-side row model; `dataSource` switches to the server-side row model. They are mutually exclusive.
|
|
102
102
|
- **Height.** Use the `height` prop, not `style.height` on the root. A value containing `%` (`'100%'`) sizes the **whole grid including its bars** and needs a parent with a definite height; a number sizes the **scroll area only**. Without `height`, the scroll area is capped at `480px` (`maxHeight`).
|
|
103
|
-
- **Imperative API.** Pass `ref` to get a `SpreadsheetGridHandle<T>` (no `forwardRef` needed on your side; works the same on React 18.3 and 19).
|
|
103
|
+
- **Imperative API.** Pass `ref` to get a `SpreadsheetGridHandle<T>` (no `forwardRef` needed on your side; works the same on React 18.3 and 19). If you wrap the grid in your own component and pass `ref` to the wrapper, make the wrapper a `forwardRef` on React 18: the types accept `ref` either way, but React 18 does not pass it as a prop, so the handle stays `null`.
|
|
104
104
|
- **Positions are view positions.** `viewRowIndex` / `colIndex` (in `selectCell` and the like) are positions after sorting and filtering, and `colIndex` also counts the columns the grid adds (row drag handle, detail toggle, auto group column). Look them up with `getViewRowIndex(rowKey)` / `getColIndex(columnKey)` instead of `rows.findIndex`.
|
|
105
105
|
- **Next.js App Router.** Render the grid from a Client Component (a file with `'use client'`); the package does not add the directive.
|
|
106
106
|
- **UI language.** The grid's own texts are Japanese by default. For English pass `localeText={localeTextEn}` from `@ishibashi0112/spreadsheet-grid/locales/en` (and `gridAskLocaleTextEn` to `GridAskBar`).
|
|
@@ -133,7 +133,7 @@ Astryx / Mantine / HeroUI v3 / shadcn/ui の中で使うときは、`style.css`
|
|
|
133
133
|
|
|
134
134
|
### バンドルを小さくする: `/lite`(0.54.0 から)
|
|
135
135
|
|
|
136
|
-
`SpreadsheetGrid` は全機能入りです(初期読み込みの JS が約
|
|
136
|
+
`SpreadsheetGrid` は全機能入りです(初期読み込みの JS が約 136KB gzip)。`/lite` の入口では、渡した機能だけを入れたグリッドを作れます。渡さなかった機能はバンドルに入りません(機能なしで約 77KB、プリセット `standardFeatures` で約 99KB)。
|
|
137
137
|
|
|
138
138
|
```tsx
|
|
139
139
|
import { createSpreadsheetGrid, standardFeatures, serverSideFeature } from '@ishibashi0112/spreadsheet-grid/lite'
|
|
@@ -181,7 +181,7 @@ npm パッケージに同梱されているため、オフライン(`node_module
|
|
|
181
181
|
- **行キー。** `rowKeyGetter` で安定したキーを返してください(既定は行 index)。
|
|
182
182
|
- **`rows` か `dataSource`。** `rows` はクライアントサイド行モデル、`dataSource` を渡すとサーバーサイド行モデルです。両者は排他です。
|
|
183
183
|
- **高さ。** ルートの `style.height` ではなく `height` prop で指定します。`%` を含む値(`'100%'`)は**バーを含むグリッド全体**の高さで、親要素に確定高さが必要です。数値は**スクロール領域だけ**の高さです。`height` 未指定時のスクロール領域は `480px`(`maxHeight`)が上限です。
|
|
184
|
-
- **命令的 API。** `ref` を渡すと `SpreadsheetGridHandle<T>` を受け取れます(利用側で `forwardRef` は不要。React 18.3 / 19 のどちらでも同じ)。
|
|
184
|
+
- **命令的 API。** `ref` を渡すと `SpreadsheetGridHandle<T>` を受け取れます(利用側で `forwardRef` は不要。React 18.3 / 19 のどちらでも同じ)。グリッドを自分のコンポーネントで包んでその部品へ `ref` を渡すときは、React 18 では包む部品を `forwardRef` にします(型はどちらでも通りますが、React 18 は `ref` を props として渡さないので、ハンドルが `null` のままになります)。
|
|
185
185
|
- **位置は表示の位置。** `selectCell` などの `viewRowIndex` / `colIndex` は並べ替え・絞り込みの後の表示の位置で、`colIndex` は行ドラッグのハンドル列・展開トグル列・自動グループ列(ライブラリが足す列)も数えます。`rows.findIndex` ではなく `getViewRowIndex(rowKey)` / `getColIndex(columnKey)` で引いてください。
|
|
186
186
|
- **Next.js App Router。** クライアントコンポーネント(`'use client'` のファイル)から描画してください。パッケージ側はディレクティブを付けていません。
|
|
187
187
|
- **UI の言語。** グリッドが出す文言の既定は日本語です。英語は `@ishibashi0112/spreadsheet-grid/locales/en` の `localeTextEn` を `localeText` に渡します(`GridAskBar` には `gridAskLocaleTextEn`)。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./useGridLocaleText-D74sCoAT.cjs"),t=require("./useVirtualizerCore-DTzCVMhF.cjs"),n=require("./usePopupLocaleText-BAn7AGEy.cjs");let r=require("react"),i=require("@ishibashi0112/spreadsheet-grid-core/internal/logic/cx"),a=require("react-dom"),o=require("@ishibashi0112/spreadsheet-grid-core/internal/controllers/escapeClaimController"),s=require("@ishibashi0112/spreadsheet-grid-core/internal/logic/domGuards"),c=require("@ishibashi0112/spreadsheet-grid-core/internal/logic/localeText"),l=require("react/jsx-runtime"),u=require("@ishibashi0112/spreadsheet-grid-core/internal/logic/filtering"),d=require("@ishibashi0112/spreadsheet-grid-core/internal/logic/dateFilterPresets"),f=require("@ishibashi0112/spreadsheet-grid-core/internal/logic/localeTextFilters"),p=require("@ishibashi0112/spreadsheet-grid-core/internal/logic/focusCycle"),m=require("@ishibashi0112/spreadsheet-grid-core/internal/logic/setFilterSearch"),h=require("@ishibashi0112/spreadsheet-grid-core/internal/logic/setFilterSelection"),g=require("@ishibashi0112/spreadsheet-grid-core/internal/logic/numberFilterCondition"),_=require("@ishibashi0112/spreadsheet-grid-core/internal/logic/textFilterCondition"),v=require("@ishibashi0112/spreadsheet-grid-core/internal/logic/dateFilterCondition"),y=require("@ishibashi0112/spreadsheet-grid-core/internal/logic/datePickerCalendar"),b=require("@ishibashi0112/spreadsheet-grid-core/internal/logic/dateFilterTree");function x({value:e,onCommit:t,ariaLabel:a,inputRef:o,onRequestClose:d,align:f=`left`}){let p=n.t(),[m,h]=(0,r.useState)(null),[g,_]=(0,r.useState)(!1),[v,b]=(0,r.useState)(!1),[x,S]=(0,r.useState)(`days`),[C,w]=(0,r.useState)(()=>new Date().getFullYear()),[T,E]=(0,r.useState)(()=>new Date().getMonth()),D=(0,r.useRef)(null),O=m??(0,y.formatFilterDateDisplay)(e),k=(0,u.toDateKey)(new Date)??``,A=()=>{if(m===null)return;let e=m.trim();if(e===``){t(``),h(null),_(!1);return}let n=(0,u.toDateKey)(e);if(n===null){_(!0);return}t(n),h(null),_(!1)},j=()=>{let[t,n]=(e===``?k:e).split(`-`);w(Number(t)),E(Number(n)-1),S(`days`),b(!0)},M=()=>{b(!1)},N=e=>{t(e),h(null),_(!1),M()};(0,r.useEffect)(()=>{if(!v)return;let e=e=>{let t=e.target;t&&D.current?.contains(t)||b(!1)};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[v]);let P=e=>{if(e.stopPropagation(),e.key===`Enter`){if((0,s.isImeComposingKeyEvent)(e.nativeEvent))return;e.preventDefault(),A(),M();return}if(e.key===`Escape`){if(e.preventDefault(),v){M();return}d()}},F=e=>({onPointerDown:t=>{t.preventDefault(),t.stopPropagation(),e()},onKeyDown:t=>{if(t.stopPropagation(),t.key===`Enter`||t.key===` `){t.preventDefault(),e();return}if(t.key===`Escape`){if(t.preventDefault(),v){M(),t.currentTarget.closest(`.ssg-dp-root`)?.querySelector(`.ssg-dp-input`)?.focus();return}d()}}}),I=e=>{if(x===`days`){let t=new Date(C,T+e,1);w(t.getFullYear()),E(t.getMonth());return}if(x===`months`){w(t=>t+e);return}w(t=>t+e*12)},L=()=>{S(e=>e===`days`?`months`:`years`)},R=()=>{S(e=>e===`years`?`months`:`days`)},z=x===`days`?(0,c.formatLocaleText)(p.calendarTitle,{year:C,month:T+1}):x===`months`?(0,c.formatLocaleText)(p.calendarYear,{year:C}):`${(0,y.yearGridStart)(C)} – ${(0,y.yearGridStart)(C)+11}`;return(0,l.jsxs)(`div`,{ref:D,className:`ssg-dp-root`,children:[(0,l.jsxs)(`div`,{className:(0,i.cx)(`ssg-dp-field`,v&&`ssg-dp-field--open`,g&&`ssg-dp-field--invalid`),children:[(0,l.jsx)(`input`,{ref:o,type:`text`,inputMode:`numeric`,value:O,placeholder:`yyyy/mm/dd`,"aria-label":a,"aria-invalid":g||void 0,className:`ssg-dp-input`,onChange:e=>{h(e.target.value),_(!1)},onKeyDown:P,onBlur:A}),(0,l.jsx)(`button`,{type:`button`,className:`ssg-dp-cal-btn`,"aria-label":v?p.calendarClose:p.calendarOpen,...F(()=>{v?M():j()}),children:(0,l.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,l.jsx)(`rect`,{x:`1.5`,y:`2.5`,width:`13`,height:`12`,rx:`1.5`,fill:`none`,stroke:`currentColor`}),(0,l.jsx)(`line`,{x1:`1.5`,y1:`6`,x2:`14.5`,y2:`6`,stroke:`currentColor`}),(0,l.jsx)(`line`,{x1:`5`,y1:`1`,x2:`5`,y2:`4`,stroke:`currentColor`}),(0,l.jsx)(`line`,{x1:`11`,y1:`1`,x2:`11`,y2:`4`,stroke:`currentColor`})]})})]}),v&&(0,l.jsxs)(`div`,{className:(0,i.cx)(`ssg-dp-panel`,f===`right`&&`ssg-dp-panel--right`),children:[(0,l.jsxs)(`div`,{className:`ssg-dp-nav`,children:[(0,l.jsx)(`button`,{type:`button`,className:`ssg-dp-nav-btn`,"aria-label":p.calendarPrevious,...F(()=>I(-1)),children:`‹`}),(0,l.jsx)(`button`,{type:`button`,className:`ssg-dp-nav-title`,disabled:x===`years`,"aria-label":p.calendarChangeView,...F(L),children:z}),(0,l.jsx)(`button`,{type:`button`,className:`ssg-dp-nav-btn`,"aria-label":p.calendarNext,...F(()=>I(1)),children:`›`})]}),x===`days`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`ssg-dp-dow`,children:p.calendarWeekdays.map((e,t)=>(0,l.jsx)(`span`,{className:(0,i.cx)(t===0&&`ssg-dp-dow--sun`,t===6&&`ssg-dp-dow--sat`),children:e},t))}),(0,l.jsx)(`div`,{className:`ssg-dp-days`,children:(0,y.buildCalendarDayCells)(C,T).map(t=>(0,l.jsx)(`button`,{type:`button`,className:(0,i.cx)(`ssg-dp-day`,!t.inCurrentMonth&&`ssg-dp-day--out`,t.key===k&&`ssg-dp-day--today`,t.key===e&&`ssg-dp-day--selected`),"aria-label":t.key,...F(()=>N(t.key)),children:t.day},t.key))})]}),x===`months`&&(0,l.jsx)(`div`,{className:`ssg-dp-grid`,children:p.calendarMonths.map((e,t)=>(0,l.jsx)(`button`,{type:`button`,className:(0,i.cx)(`ssg-dp-cell`,t===T&&`ssg-dp-cell--selected`),...F(()=>{E(t),S(`days`)}),children:e},t))}),x===`years`&&(0,l.jsx)(`div`,{className:`ssg-dp-grid`,children:(0,y.buildYearGrid)(C).map(e=>(0,l.jsx)(`button`,{type:`button`,className:(0,i.cx)(`ssg-dp-cell`,e===C&&`ssg-dp-cell--selected`),...F(()=>{w(e),S(`months`)}),children:e},e))}),(0,l.jsxs)(`div`,{className:`ssg-dp-foot`,children:[x!==`days`&&(0,l.jsx)(`button`,{type:`button`,className:`ssg-dp-foot-btn`,...F(R),children:p.calendarBack}),(0,l.jsx)(`button`,{type:`button`,className:`ssg-dp-foot-btn`,...F(()=>N(k)),children:p.calendarToday}),(0,l.jsx)(`button`,{type:`button`,className:`ssg-dp-foot-btn ssg-dp-foot-btn--muted`,...F(()=>N(``)),children:p.clear})]})]})]})}var S=24,C=(e,t,n)=>e===``&&t===f.DEFAULT_FILTER_LOCALE_TEXT.blank?n:t,w=(e,t)=>t===f.DEFAULT_FILTER_LOCALE_TEXT.blank?e:e.map(e=>e.value===``&&e.label===f.DEFAULT_FILTER_LOCALE_TEXT.blank?{...e,label:t}:e);function T({options:e,setSelection:i,searchInputRef:a,onValueToggle:o,onSelectAllChange:u,onReplaceSelection:d,onRequestClose:f,isServerSide:p,selectAllUsesExplicitScope:g=!1,truncated:_=!1}){let v=n.t(),[y,b]=(0,r.useState)(``),x=(0,r.useDeferredValue)(y),T=(0,r.useMemo)(()=>w(e,v.blank),[e,v.blank]),E=(0,r.useMemo)(()=>(0,m.filterSetOptionsBySearch)(T,x),[T,x]),D=x.trim().length>0,O=(0,r.useRef)(null),k=t.t({count:E.length,getScrollElement:()=>O.current,estimateSize:()=>S,overscan:10}),A=(0,r.useMemo)(()=>{if(i===null)return E.length;let e=0;for(let t of E)(0,h.isSetValueSelected)(i,t.value)&&(e+=1);return e},[i,E]),j=E.length>0&&A===E.length,M=A>0&&!j,N=(0,r.useMemo)(()=>new Set(e.map(e=>e.value)),[e]),F=(0,r.useMemo)(()=>{if(i===null)return e.length;let t=0;for(let e of i.values)N.has(e)&&(t+=1);return i.mode===`include`?t:e.length-t},[i,N,e.length]);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`input`,{ref:a,type:`text`,value:y,onChange:e=>b(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`&&(e.preventDefault(),f()),e.key===`Enter`){if((0,s.isImeComposingKeyEvent)(e.nativeEvent))return;e.preventDefault();let t=(0,m.resolveSetFilterEnterAction)(T,y);if(t.kind===`none`)return;t.kind===`replace`&&d(t.values),f()}},placeholder:v.filterSearchPlaceholder,"aria-label":v.filterSearchPlaceholder,className:`ssg-filter-input`}),(0,l.jsxs)(`label`,{className:`ssg-filter-selectall`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:j,ref:e=>{e&&(e.indeterminate=M)},onChange:()=>{u(D||g?E.map(e=>e.value):`all`,!j)}}),(0,l.jsx)(`span`,{className:`ssg-filter-selectall-label`,children:D?v.filterSelectAllResults:v.filterSelectAll})]}),(0,l.jsx)(`div`,{ref:O,className:`ssg-filter-list`,children:E.length===0?(0,l.jsx)(`div`,{className:`ssg-filter-empty`,children:e.length===0?p?v.filterNoOptionsSource:v.noOptions:v.filterNoMatches}):(0,l.jsx)(`div`,{className:`ssg-filter-virt`,style:{height:k.getTotalSize()},children:k.getVirtualItems().map(e=>{let t=E[e.index];if(!t)return null;let n=(0,h.isSetValueSelected)(i,t.value);return(0,l.jsxs)(`label`,{className:`ssg-filter-option`,style:{transform:`translateY(${e.start}px)`,height:e.size},children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>o(t.value)}),(0,l.jsx)(`span`,{className:`ssg-filter-option-label`,children:C(t.value,t.label,v.blank)})]},t.value)})})}),(0,l.jsxs)(`div`,{className:`ssg-filter-meta`,children:[(0,c.formatLocaleText)(v.filterSelectedCount,{selected:F,total:e.length}),D?(0,c.formatLocaleText)(v.filterShownCount,{count:E.length}):``,_&&(0,l.jsx)(P,{})]})]})}var E=e=>{e.key!==`Escape`&&e.stopPropagation()},D=e=>e.nativeEvent.isComposing===!0,O=(e,t,n)=>{if(D(n)){e(t,{commit:!1});return}e(t)};function k({draft:e,valueInputRef:t,onDraftChange:r,onKeyDown:i}){let a=n.t(),o=(0,g.numberFilterOperandCount)(e.operator);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`select`,{value:e.operator,onChange:t=>r({...e,operator:t.target.value}),onKeyDown:i,className:`ssg-filter-select`,"aria-label":a.filterOperator,children:g.NUMBER_FILTER_OPERATOR_OPTIONS.map(e=>(0,l.jsx)(`option`,{value:e.value,children:a[e.labelKey]},e.value))}),o>0?(0,l.jsxs)(`div`,{className:`ssg-filter-cond-values`,children:[(0,l.jsx)(`input`,{ref:t,type:`text`,inputMode:`decimal`,value:e.value1,onChange:t=>O(r,{...e,value1:t.target.value},t),onCompositionEnd:t=>r({...e,value1:t.currentTarget.value}),onKeyDown:i,placeholder:o===2?a.filterMin:a.filterValuePlaceholder,className:`ssg-filter-input`,"aria-label":o===2?a.filterMin:a.filterValue}),o===2&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`span`,{className:`ssg-filter-cond-tilde`,children:a.filterRangeSeparator}),(0,l.jsx)(`input`,{type:`text`,inputMode:`decimal`,value:e.value2,onChange:t=>O(r,{...e,value2:t.target.value},t),onCompositionEnd:t=>r({...e,value2:t.currentTarget.value}),onKeyDown:i,placeholder:a.filterMax,className:`ssg-filter-input`,"aria-label":a.filterMax})]})]}):(0,l.jsx)(`div`,{className:`ssg-filter-meta`,children:a.filterNoValue})]})}function A({draft:e,valueInputRef:t,onDraftChange:r,onKeyDown:i}){let a=n.t(),o=(0,_.textFilterOperandCount)(e.operator);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`select`,{value:e.operator,onChange:t=>r({...e,operator:t.target.value}),onKeyDown:i,className:`ssg-filter-select`,"aria-label":a.filterOperator,children:_.TEXT_FILTER_OPERATOR_OPTIONS.map(e=>(0,l.jsx)(`option`,{value:e.value,children:a[e.labelKey]},e.value))}),o>0?(0,l.jsx)(`div`,{className:`ssg-filter-cond-values`,children:(0,l.jsx)(`input`,{ref:t,type:`text`,value:e.value,onChange:t=>O(r,{...e,value:t.target.value},t),onCompositionEnd:t=>r({...e,value:t.currentTarget.value}),onKeyDown:i,placeholder:a.filterValuePlaceholder,className:`ssg-filter-input`,"aria-label":a.filterValue})}):(0,l.jsx)(`div`,{className:`ssg-filter-meta`,children:a.filterNoValue})]})}function j({draft:e,valueInputRef:t,onDraftChange:r,onKeyDown:a,presets:o,renderDateInput:s,onRequestClose:c}){let u=n.t(),d=e.preset===null?(0,v.dateFilterOperandCount)(e.operator):0,f=(t,n)=>{r({...e,[t]:(0,v.normalizeFilterDateInputValue)(n),preset:null})};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`select`,{value:e.operator,onChange:t=>r({...e,operator:t.target.value,preset:null}),onKeyDown:a,className:`ssg-filter-select`,"aria-label":u.filterOperator,children:v.DATE_FILTER_OPERATOR_OPTIONS.map(e=>(0,l.jsx)(`option`,{value:e.value,children:u[e.labelKey]},e.value))}),d>0?(0,l.jsxs)(`div`,{className:`ssg-filter-cond-values`,children:[s?s({value:e.value1,onChange:e=>f(`value1`,e),ariaLabel:d===2?u.filterStartDate:u.filterDate,slot:d===2?`from`:`single`}):(0,l.jsx)(x,{value:e.value1,onCommit:t=>r({...e,value1:t,preset:null}),ariaLabel:d===2?u.filterStartDate:u.filterDate,inputRef:t,onRequestClose:c}),d===2&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`span`,{className:`ssg-filter-cond-tilde`,children:u.filterRangeSeparator}),s?s({value:e.value2,onChange:e=>f(`value2`,e),ariaLabel:u.filterEndDate,slot:`to`}):(0,l.jsx)(x,{value:e.value2,onCommit:t=>r({...e,value2:t,preset:null}),ariaLabel:u.filterEndDate,onRequestClose:c,align:`right`})]})]}):e.preset===null?(0,l.jsx)(`div`,{className:`ssg-filter-meta`,children:u.filterNoValue}):null,o.length>0&&(0,l.jsx)(`div`,{className:`ssg-filter-presets`,children:o.map(t=>(0,l.jsx)(`button`,{type:`button`,onPointerDown:n=>{n.preventDefault(),n.stopPropagation(),r({...e,preset:e.preset===t.id?null:t.id})},onKeyDown:n=>{E(n),(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),r({...e,preset:e.preset===t.id?null:t.id}))},className:(0,i.cx)(`ssg-filter-preset-chip`,e.preset===t.id&&`ssg-filter-preset-chip--active`),children:t.label},t.id))})]})}function M({options:e,setSelection:i,searchInputRef:a,onValueToggle:o,onSelectAllChange:u,onReplaceSelection:d,onRequestClose:f,isServerSide:p,truncated:g=!1}){let _=n.t(),[v,y]=(0,r.useState)(``),x=(0,r.useDeferredValue)(v),[T,D]=(0,r.useState)(()=>new Set),O=x.trim().length>0,k=(0,r.useMemo)(()=>w(e,_.blank),[e,_.blank]),A=(0,r.useMemo)(()=>(0,m.filterSetOptionsBySearch)(k,x),[k,x]),j=(0,r.useMemo)(()=>(0,b.buildDateTreeRows)(e,T,_),[e,T,_]),M=(0,r.useRef)(null),N=O?A.length:j.length,F=t.t({count:N,getScrollElement:()=>M.current,estimateSize:()=>S,overscan:10}),I=(0,r.useMemo)(()=>(O?A:e).map(e=>e.value),[O,A,e]),L=(0,r.useMemo)(()=>{let e=0;for(let t of I)(0,h.isSetValueSelected)(i,t)&&(e+=1);return e},[I,i]),R=I.length>0&&L===I.length,z=L>0&&!R,B=(0,r.useMemo)(()=>new Set(e.map(e=>e.value)),[e]),ee=(0,r.useMemo)(()=>{if(i===null)return e.length;let t=0;for(let e of i.values)B.has(e)&&(t+=1);return i.mode===`include`?t:e.length-t},[i,B,e.length]),V=e=>{D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},H=e=>{let t=0;for(let n of e)(0,h.isSetValueSelected)(i,n)&&(t+=1);return t},U=e=>{let t=H(e.leafKeys),n=e.leafKeys.length>0&&t===e.leafKeys.length,r=t>0&&!n;return(0,l.jsxs)(l.Fragment,{children:[e.type===`group`?(0,l.jsx)(`button`,{type:`button`,onPointerDown:t=>{t.preventDefault(),t.stopPropagation(),V(e.key)},onKeyDown:t=>{E(t),(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),V(e.key))},className:`ssg-filter-tree-toggle`,"aria-label":e.expanded?_.treeCollapse:_.treeExpand,children:e.expanded?`▾`:`▸`}):(0,l.jsx)(`span`,{className:`ssg-filter-tree-toggle ssg-filter-tree-toggle--placeholder`}),(0,l.jsx)(`input`,{type:`checkbox`,checked:n,ref:e=>{e&&(e.indeterminate=r)},"aria-label":C(e.key,e.label,_.blank),onChange:()=>{if(e.type===`leaf`){o(e.key);return}u(e.leafKeys,!n)}}),(0,l.jsx)(`span`,{className:`ssg-filter-option-label`,children:C(e.key,e.label,_.blank)})]})};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`input`,{ref:a,type:`text`,value:v,onChange:e=>y(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`&&(e.preventDefault(),f()),e.key===`Enter`){if((0,s.isImeComposingKeyEvent)(e.nativeEvent))return;e.preventDefault();let t=(0,m.resolveSetFilterEnterAction)(k,v);if(t.kind===`none`)return;t.kind===`replace`&&d(t.values),f()}},placeholder:_.filterSearchPlaceholder,"aria-label":_.filterSearchPlaceholder,className:`ssg-filter-input`}),(0,l.jsxs)(`label`,{className:`ssg-filter-selectall`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:R,ref:e=>{e&&(e.indeterminate=z)},onChange:()=>u(I,!R)}),(0,l.jsx)(`span`,{className:`ssg-filter-selectall-label`,children:O?_.filterSelectAllResults:_.filterSelectAll})]}),(0,l.jsx)(`div`,{ref:M,className:`ssg-filter-list`,children:N===0?(0,l.jsx)(`div`,{className:`ssg-filter-empty`,children:e.length===0?p?_.filterNoOptionsSource:_.noOptions:_.filterNoMatches}):(0,l.jsx)(`div`,{className:`ssg-filter-virt`,style:{height:F.getTotalSize()},children:F.getVirtualItems().map(e=>{if(O){let t=A[e.index];return t?(0,l.jsxs)(`label`,{className:`ssg-filter-option`,style:{transform:`translateY(${e.start}px)`,height:e.size},children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:(0,h.isSetValueSelected)(i,t.value),onChange:()=>o(t.value)}),(0,l.jsx)(`span`,{className:`ssg-filter-option-label`,children:C(t.value,t.label,_.blank)})]},t.value):null}let t=j[e.index];return t?(0,l.jsx)(`div`,{className:`ssg-filter-option`,style:{transform:`translateY(${e.start}px)`,height:e.size,paddingLeft:8+t.depth*16},children:U(t)},t.key):null})})}),(0,l.jsxs)(`div`,{className:`ssg-filter-meta`,children:[(0,c.formatLocaleText)(_.filterSelectedCount,{selected:ee,total:e.length}),O?(0,c.formatLocaleText)(_.filterShownCount,{count:A.length}):``,g&&(0,l.jsx)(P,{})]})]})}function N({status:e,errorMessage:t,onRetry:r}){let i=n.t();return e===`loading`?(0,l.jsx)(`div`,{className:`ssg-filter-collecting`,children:i.filterOptionsLoading}):(0,l.jsxs)(`div`,{className:`ssg-filter-error`,role:`alert`,children:[(0,l.jsx)(`div`,{children:i.filterOptionsFailed}),t?(0,l.jsx)(`div`,{className:`ssg-filter-error-detail`,title:t,children:t}):null,r?(0,l.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),r()},onKeyDown:e=>{E(e),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r())},className:`ssg-filter-btn-secondary`,children:i.retry}):null]})}function P(){return(0,l.jsx)(`span`,{className:`ssg-filter-truncated`,children:n.t().filterOptionsTruncated})}function F({conditionEditor:e,conditionActive:t,onConditionClear:r,options:i,setSelection:a,onSelectionClear:o,summaryText:s,children:u,optionsMeta:d}){let f=n.t();return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`ssg-filter-sec-head`,children:[(0,l.jsx)(`span`,{className:`ssg-filter-sec-label`,children:f.filterConditionSection}),(0,l.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),r()},onKeyDown:e=>{E(e),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r())},className:`ssg-filter-sec-clear`,disabled:!t,children:f.clear})]}),e,(0,l.jsx)(`div`,{className:`ssg-filter-sep`}),(0,l.jsxs)(`div`,{className:`ssg-filter-sec-head`,children:[(0,l.jsx)(`span`,{className:`ssg-filter-sec-label`,children:f.filterValuesSection}),(0,l.jsx)(`span`,{className:`ssg-filter-sec-meta`,children:d??(0,c.formatLocaleText)(t?f.filterMatchCount:f.filterTotalCount,{count:i.length})}),(0,l.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),o()},onKeyDown:e=>{E(e),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),o())},className:`ssg-filter-sec-clear`,disabled:a===null,children:f.clear})]}),u,(0,l.jsxs)(`div`,{className:`ssg-filter-summary`,children:[`🔽 `,s]})]})}function I({isOpen:t,themeClassName:u,popoverSlot:f,title:m,filterType:h,draftValue:y,numberConditionDraft:b,onNumberConditionDraftChange:x,textConditionDraft:S,onTextConditionDraftChange:w,dateConditionDraft:D,onDateConditionDraftChange:O,datePresets:I,renderDateInput:L,onComboConditionClear:R,onComboSelectionClear:z,comboSummaryText:B,currentValueText:ee,layout:V,selectOptions:H,optionsStatus:U,optionsProgress:te,optionsTruncated:ne=!1,optionsErrorMessage:re,onOptionsRetry:ie,setSelection:W,popoverRef:ae,textInputRef:G,selectRef:oe,onRequestClose:K,onDraftChange:se,onApply:q,onClear:ce,onSetValueToggle:le,onSetSelectAllChange:ue,onSetClear:de,onSetReplaceSelection:fe,isServerSide:pe=!1}){let J=n.t(),me=(0,r.useRef)(null),[he]=(0,r.useState)(()=>new Date);if(e.o(ae,t&&V!==null,u),typeof document>`u`||!t||!V)return null;let ge={top:V.top,left:V.left,width:V.width,maxHeight:V.maxHeight},_e=e=>{e.stopPropagation(),e.key===`Escape`&&!(0,o.isEscapePreventedInside)(e.nativeEvent)&&!(0,s.isImeComposingKeyEvent)(e.nativeEvent)&&(e.preventDefault(),K())},ve=e=>{if(e.key!==`Tab`||e.altKey||e.ctrlKey||e.metaKey||(0,s.isImeComposingKeyEvent)(e.nativeEvent))return;let t=(0,p.resolveFocusWrapTarget)(e.currentTarget,e.target instanceof Element?e.target:null,e.shiftKey);t!==null&&(e.preventDefault(),t.focus())},ye=e=>{e.stopPropagation()},be=h===`set`,Y=h===`numberSet`,X=h===`textSet`,Z=h===`dateSet`,xe=Y||X||Z,Q=be||xe,Se=U===`loading`||U===`error`,Ce=b??g.DEFAULT_NUMBER_FILTER_DRAFT,we=S??_.DEFAULT_TEXT_FILTER_DRAFT,Te=D??v.DEFAULT_DATE_FILTER_DRAFT,Ee=I??(0,d.normalizeDateFilterPresets)(void 0,J),De=Y?(0,g.buildParsedNumberFilterFromDraft)(Ce):null,Oe=X?(0,_.buildParsedTextFilterFromDraft)(we):null,ke=Z?(0,v.buildParsedDateFilterFromDraft)(Te):null,Ae=De!==null||Oe!==null||ke!==null,je=Y?(0,g.filterOptionsByNumberCondition)(H,De):X?(0,_.filterOptionsByTextCondition)(H,Oe):Z?(0,v.filterOptionsByDateCondition)(H,ke,he,Ee):H,$=e=>{if(e.stopPropagation(),!(0,s.isImeComposingKeyEvent)(e.nativeEvent)){if(e.key===`Enter`){e.preventDefault(),q();return}e.key===`Escape`&&(e.preventDefault(),K())}},Me=Y?(0,l.jsx)(k,{draft:Ce,valueInputRef:G,onDraftChange:x,onKeyDown:$}):X?(0,l.jsx)(A,{draft:we,valueInputRef:G,onDraftChange:w,onKeyDown:$}):(0,l.jsx)(j,{draft:Te,valueInputRef:G,onDraftChange:O,onKeyDown:$,presets:Ee,renderDateInput:L,onRequestClose:K});return(0,a.createPortal)((0,l.jsxs)(`div`,{ref:ae,onPointerDown:ye,onKeyDown:_e,onKeyDownCapture:ve,onPasteCapture:e=>{e.stopPropagation()},className:(0,i.cx)(`ssg-filter-popover`,u,f?.className),style:{...f?.style,...ge},role:`dialog`,"aria-label":(0,c.formatLocaleText)(J.filterTitle,{column:m}),children:[(0,l.jsx)(`div`,{className:`ssg-filter-title`,children:(0,c.formatLocaleText)(J.filterTitle,{column:m})}),(Q||h===`select`)&&U===`collecting`?(0,l.jsx)(`div`,{className:`ssg-filter-collecting`,children:(0,c.formatLocaleText)(J.filterCollecting,{percent:Math.round(te*100)})}):(Q||h===`select`)&&Se?xe?(0,l.jsx)(F,{conditionEditor:Me,conditionActive:Ae,onConditionClear:R,options:je,setSelection:W,onSelectionClear:z,summaryText:B,optionsMeta:U===`loading`?J.filterOptionsLoadingShort:J.filterOptionsFailedShort,children:(0,l.jsx)(N,{status:U===`loading`?`loading`:`error`,errorMessage:re,onRetry:ie})}):(0,l.jsx)(N,{status:U===`loading`?`loading`:`error`,errorMessage:re,onRetry:ie}):xe?(0,l.jsx)(F,{conditionEditor:Me,conditionActive:Ae,onConditionClear:R,options:je,setSelection:W,onSelectionClear:z,summaryText:B,children:Z?(0,l.jsx)(M,{options:je,setSelection:W,searchInputRef:me,onValueToggle:le,onSelectAllChange:ue,onReplaceSelection:fe,onRequestClose:K,isServerSide:pe,truncated:ne}):(0,l.jsx)(T,{options:je,setSelection:W,searchInputRef:me,onValueToggle:le,onSelectAllChange:ue,onReplaceSelection:fe,onRequestClose:K,isServerSide:pe,selectAllUsesExplicitScope:!0,truncated:ne})}):be?(0,l.jsx)(T,{options:H,setSelection:W,searchInputRef:G,onValueToggle:le,onSelectAllChange:ue,onReplaceSelection:fe,onRequestClose:K,isServerSide:pe,truncated:ne}):h===`number`?(0,l.jsx)(l.Fragment,{children:(0,l.jsx)(k,{draft:Ce,valueInputRef:G,onDraftChange:x,onKeyDown:$})}):h===`select`?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`select`,{ref:oe,value:y,onChange:e=>se(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Enter`){e.preventDefault(),q();return}e.key===`Escape`&&(e.preventDefault(),K())},className:`ssg-filter-select`,children:[(0,l.jsx)(`option`,{value:``,children:J.filterAll}),H.map(e=>(0,l.jsx)(`option`,{value:e.value,children:C(e.value,e.label,J.blank)},`${m}-${e.value}`))]}),(0,l.jsxs)(`div`,{className:`ssg-filter-meta`,children:[(0,c.formatLocaleText)(J.filterOptionCount,{count:H.length}),ne&&(0,l.jsx)(P,{})]})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`input`,{ref:G,type:`text`,value:y,onChange:e=>se(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),!(0,s.isImeComposingKeyEvent)(e.nativeEvent)){if(e.key===`Enter`){e.preventDefault(),q();return}e.key===`Escape`&&(e.preventDefault(),K())}},placeholder:J.filterTextPlaceholder,"aria-label":J.filterTextPlaceholder,className:`ssg-filter-input`}),(0,l.jsx)(`div`,{className:`ssg-filter-meta ssg-filter-meta--ellipsis`,children:J.filterTextHint})]}),!Q&&(0,l.jsx)(`div`,{className:`ssg-filter-meta ssg-filter-meta--ellipsis`,children:(0,c.formatLocaleText)(J.filterCurrentValue,{value:ee})}),(0,l.jsx)(`div`,{className:`ssg-filter-footer`,children:Q?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),de()},onKeyDown:e=>{E(e),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),de())},className:`ssg-filter-btn-secondary`,children:J.clear}),(0,l.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),K()},onKeyDown:e=>{E(e),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),K())},className:`ssg-filter-btn-primary`,children:J.close})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),ce()},onKeyDown:e=>{E(e),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),ce())},className:`ssg-filter-btn-secondary`,children:J.clear}),(0,l.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),q()},onKeyDown:e=>{E(e),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),q())},className:`ssg-filter-btn-primary`,children:J.apply})]})})]}),document.body)}exports.ColumnFilterPopover=I,exports.default=I;
|