react-gridix 0.2.0 → 0.2.2

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/dist/index.d.ts CHANGED
@@ -117,7 +117,7 @@ export declare interface ColumnDef<T = Record<string, any>> {
117
117
  * Key of the row object this column reads and writes. Use dot notation for nested objects:
118
118
  * `"contact.phone"`. Edits to a nested field copy the objects on the way and never change your data in place.
119
119
  */
120
- field: FieldPath<T> & string;
120
+ field: (FieldPath<T> & string) | SequenceField;
121
121
  /**
122
122
  * Text shown in the header. Defaults to the field name, except for `type: "boolean"` columns,
123
123
  * which default to an empty string.
@@ -130,7 +130,15 @@ export declare interface ColumnDef<T = Record<string, any>> {
130
130
  * Values can be ISO strings (`"2026-11-05"`), `Date` objects or timestamps. A date is saved in the same
131
131
  * kind the cell already had (a `Date` stays a `Date`, a string stays an ISO string).
132
132
  */
133
- type?: "text" | "number" | "boolean" | "date";
133
+ type?: "text" | "number" | "boolean" | "date" | "sequence";
134
+ /**
135
+ * Only for `type: "sequence"`: the number of the first row. Default 1.
136
+ * A sequence column shows row numbers that are counted again after every search, filter or sort, and it
137
+ * needs no data. Give it any `field` that starts with `#`, for example `{ field: "#", type: "sequence" }`.
138
+ */
139
+ sequenceStart?: number;
140
+ /** Only for `type: "sequence"`: start again at `sequenceStart` on every page. Default false (the count continues: 11, 12, ...). */
141
+ sequenceRestartEachPage?: boolean;
134
142
  width?: number | string;
135
143
  minWidth?: number | string;
136
144
  /** Largest width in pixels when the user resizes the column. */
@@ -154,6 +162,13 @@ export declare interface ColumnDef<T = Record<string, any>> {
154
162
  filterOptions?: (string | FilterOption)[];
155
163
  /** Placeholder of the default filter text box. */
156
164
  filterPlaceholder?: string;
165
+ /**
166
+ * Milliseconds to wait after the user stops typing in this column's filter before the filter is
167
+ * applied (and, in server-side mode, before `onQueryChange` is called). Applies to the text, exact
168
+ * and number boxes. Checkboxes (select) and date pickers apply at once.
169
+ * Overrides the grid's `filterDebounce`. Use 0 to apply on every keystroke.
170
+ */
171
+ filterDebounce?: number;
157
172
  /** A React component drawn instead of the default dot. Receives `{ column, active, open }`. */
158
173
  filterIndicator?: ComponentType<FilterIndicatorProps<T>>;
159
174
  /** Classes for this column's filter indicator button (Tailwind works). */
@@ -214,7 +229,7 @@ export declare interface ColumnDef<T = Record<string, any>> {
214
229
  headerCheckbox?: boolean;
215
230
  }
216
231
 
217
- export declare function DataGrid<T extends AnyRow = AnyRow>({ columns, rows, getRowId, editable, enterMovesDown, onCellEdit, onRowsChange, rowSelection, selectedRowIds, defaultSelectedRowIds, onSelectionChange, isRowSelectable, sort: sortProp, defaultSort, onSortChange, multiSort, searchable, searchPlaceholder, search: searchProp, onSearchChange, filters: filtersProp, onFiltersChange, pagination, paginationPosition, pageSize: initialPageSize, pageSizeOptions, page: pageProp, onPageChange, onPageSizeChange, serverSide, rowCount, onQueryChange, queryDebounce, loading: loadingProp, loadingRows, skeletonRow, errorMessage, columnMenu, onColumnVisibilityChange, keyboardNavigation, virtualize, rowHeight, overscan, exportable, apiRef, onRowClick, toolbar, emptyMessage, striped, stripeColors, checkboxVariant, animateRows, theme, maxHeight, className, style, classNames, styles, rowClassName, rowStyle, }: DataGridProps<T>): JSX_2.Element;
232
+ export declare function DataGrid<T extends AnyRow = AnyRow>({ columns, rows, getRowId, editable, enterMovesDown, onCellEdit, onRowsChange, rowSelection, selectedRowIds, defaultSelectedRowIds, onSelectionChange, isRowSelectable, sort: sortProp, defaultSort, onSortChange, multiSort, searchable, searchPlaceholder, search: searchProp, onSearchChange, filters: filtersProp, onFiltersChange, pagination, paginationPosition, pageSize: initialPageSize, pageSizeOptions, page: pageProp, onPageChange, onPageSizeChange, serverSide, rowCount, onQueryChange, queryDebounce, filterDebounce, loading: loadingProp, loadingRows, skeletonRow, errorMessage, columnMenu, onColumnVisibilityChange, keyboardNavigation, virtualize, rowHeight, overscan, exportable, apiRef, onRowClick, toolbar, emptyMessage, striped, stripeColors, checkboxVariant, animateRows, rowAnimationClassName, theme, maxHeight, className, style, classNames, styles, rowClassName, rowStyle, }: DataGridProps<T>): JSX_2.Element;
218
233
 
219
234
  /** Methods you can call from outside by passing a ref as `apiRef`. */
220
235
  export declare interface DataGridApi<T = Record<string, any>> {
@@ -304,6 +319,11 @@ export declare interface DataGridProps<T = Record<string, any>> {
304
319
  onQueryChange?: (query: GridQuery) => void | Promise<unknown>;
305
320
  /** Wait this long (ms) after the last keystroke in the search box before querying. Default 250. */
306
321
  queryDebounce?: number;
322
+ /**
323
+ * Default for every column's filter: milliseconds to wait after the last keystroke before a typed
324
+ * filter is applied. A column can override it with its own `filterDebounce`. Default 300.
325
+ */
326
+ filterDebounce?: number;
307
327
  /**
308
328
  * Force the loading state on or off. When you leave it out, the loading state follows the promise
309
329
  * returned by `onQueryChange`.
@@ -346,9 +366,17 @@ export declare interface DataGridProps<T = Record<string, any>> {
346
366
  checkboxVariant?: CheckboxVariant;
347
367
  /** Rows slide in smoothly when they render (new page, sort, search). Default true. Respects "reduce motion". */
348
368
  animateRows?: boolean;
369
+ /**
370
+ * Your own CSS class (or a function returning one) for the entrance animation of every row. It
371
+ * replaces the built-in slide-up. The class should set `animation`. Each row also has the CSS
372
+ * variable `--rg-i` (its position, 0 to 24) so you can stagger rows:
373
+ * `.fade-in { animation: fade 0.4s both; animation-delay: calc(var(--rg-i) * 40ms); }`.
374
+ * Does nothing when `animateRows` is false or `virtualize` is on.
375
+ */
376
+ rowAnimationClassName?: string | ((row: T, rowIndex: number) => string);
349
377
  /**
350
378
  * Name of a theme. Nothing changes unless you pass one: "ocean", "midnight", "sunset", "forest",
351
- * "lavender", "coffee", "graphite" or "aurora", or the name of your own `[data-rk-theme="..."]` CSS.
379
+ * "lavender", "coffee", "graphite" or "aurora", or the name of your own `[data-rg-theme="..."]` CSS.
352
380
  */
353
381
  theme?: GridTheme | (string & {});
354
382
  /** Makes the body scroll with a sticky header, e.g. 400 or "60vh". */
@@ -455,7 +483,7 @@ export declare type GridSlot = "root" | "toolbar" | "search" | "scroll" | "table
455
483
 
456
484
  /**
457
485
  * Built-in themes. A theme only applies when you pass its name to `<DataGrid theme="..." />`.
458
- * Any other string works too if you define `[data-rk-theme="name"]` CSS variables yourself.
486
+ * Any other string works too if you define `[data-rg-theme="name"]` CSS variables yourself.
459
487
  */
460
488
  export declare type GridTheme = "ocean" | "midnight" | "sunset" | "forest" | "lavender" | "coffee" | "graphite" | "aurora";
461
489
 
@@ -486,6 +514,9 @@ export declare interface RowSelection<T> {
486
514
  rows: T[];
487
515
  }
488
516
 
517
+ /** The field of a `type: "sequence"` column. It holds no data, so it can be any name that starts with `#`. */
518
+ export declare type SequenceField = `#${string}`;
519
+
489
520
  /** Props received by the `skeletonRow` component, which draws one placeholder row while loading. */
490
521
  export declare interface SkeletonRowProps<T = Record<string, any>> {
491
522
  /** Position of this placeholder row (0, 1, 2 ...). */
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),h=require("react"),yn=require("react-dom"),ye=(...r)=>r.filter(Boolean).join(" ");function vn(){return o.jsx("svg",{viewBox:"0 0 16 16",width:"100%",height:"100%","aria-hidden":"true",focusable:"false",children:o.jsx("path",{d:"M3.5 8.5l3 3 6-7",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function jn(){return o.jsx("svg",{viewBox:"0 0 16 16",width:"100%",height:"100%","aria-hidden":"true",focusable:"false",children:o.jsx("path",{d:"M4 8h8",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round"})})}function ee({checked:r,onChange:a,indeterminate:c=!1,variant:d="native",disabled:g=!1,label:f,"aria-label":x,id:_,name:w,indicator:L,className:F,style:b,classNames:C={},styles:E={}}){const M=c?"indeterminate":r?"checked":"unchecked";return o.jsxs("label",{className:ye("rk-checkbox",`rk-checkbox--${d}`,M==="checked"&&"rk-checkbox--checked",c&&"rk-checkbox--indeterminate",g&&"rk-checkbox--disabled",C.root,F),style:{...E.root,...b},"data-state":M,children:[d==="native"?o.jsx("input",{type:"checkbox",id:_,name:w,ref:I=>{I&&(I.indeterminate=c)},className:ye("rk-checkbox__control",C.control),style:E.control,checked:r,disabled:g,"aria-label":x,"data-state":M,onChange:I=>a(I.target.checked)}):o.jsx("button",{type:"button",role:"checkbox",id:_,className:ye("rk-checkbox__control",C.control),style:E.control,"aria-checked":c?"mixed":r,"aria-label":x,disabled:g,"data-state":M,onClick:()=>a(!r),children:o.jsx("span",{className:ye("rk-checkbox__indicator",L!==void 0&&!c&&"rk-checkbox__indicator--custom",C.indicator),style:E.indicator,"data-state":M,"aria-hidden":"true",children:c?d==="tick"?o.jsx(jn,{}):null:L!==void 0?L:d==="tick"?o.jsx(vn,{}):null})}),f!=null&&f!==!1&&f!==""&&o.jsx("span",{className:ye("rk-checkbox__label",C.label),style:E.label,children:f})]})}const wn=/^(\d{4})-(\d{2})-(\d{2})$/,fr=r=>String(r).padStart(2,"0");function we(r){const a=wn.exec(r);if(!a)return null;const[c,d,g]=[Number(a[1]),Number(a[2]),Number(a[3])],f=new Date(c,d-1,g);return f.getFullYear()===c&&f.getMonth()===d-1&&f.getDate()===g?f:null}function U(r){var a;if(r instanceof Date)return Number.isNaN(r.getTime())?null:`${r.getFullYear()}-${fr(r.getMonth()+1)}-${fr(r.getDate())}`;if(typeof r=="number")return Number.isFinite(r)?U(new Date(r)):null;if(typeof r=="string"){const c=r.trim();if(c==="")return null;const d=(a=/^\d{4}-\d{2}-\d{2}/.exec(c))==null?void 0:a[0];if(d)return we(d)?d:null;const g=Date.parse(c);return Number.isNaN(g)?null:U(new Date(g))}return null}function Nn(r,a,c){const d=U(r);return d?we(d).toLocaleDateString(a,c??{year:"numeric",month:"short",day:"numeric"}):r==null?"":String(r)}function En(r,a){var c;return r===""?null:a instanceof Date?we(r):typeof a=="number"?((c=we(r))==null?void 0:c.getTime())??null:r}function ur(r){return r.filterType?r.filterType:r.type==="number"?"number":r.type==="date"?"date":r.type==="boolean"?"select":"text"}const Sn=r=>typeof r=="object"&&r!==null&&!Array.isArray(r);function mr(r){if(r==null)return!1;if(typeof r=="string")return r.trim()!=="";if(Array.isArray(r))return r.length>0;if(Sn(r)){const a=r;return typeof a.min=="number"||typeof a.max=="number"||!!a.from||!!a.to}return!1}function Cn(r,a,c,d){switch(r){case"text":return c.toLowerCase().includes(String(a).trim().toLowerCase());case"exact":return c.toLowerCase()===String(a).trim().toLowerCase();case"number":{const{min:g,max:f}=a,x=typeof d=="number"?d:d==null||d===""?NaN:Number(d);return Number.isNaN(x)?!1:(typeof g!="number"||x>=g)&&(typeof f!="number"||x<=f)}case"date":{const{from:g,to:f}=a,x=U(d);return x?(!g||x>=g)&&(!f||x<=f):!1}case"select":return a.includes(String(d??""))}}function Dn(r,a,c,d){if(r.filterOptions)return r.filterOptions.map(f=>typeof f=="string"?{value:f,label:f}:f);if(r.type==="boolean")return[{value:"true",label:"Yes"},{value:"false",label:"No"}];const g=new Map;for(const f of a){const x=c(f);if(x==null||x==="")continue;const _=String(x);g.has(_)||g.set(_,d(f))}return[...g].map(([f,x])=>({value:f,label:x})).sort((f,x)=>f.label.localeCompare(x.label,void 0,{numeric:!0}))}const Et=typeof window<"u"?h.useLayoutEffect:h.useEffect;function ve(r,a,c){const[d,g]=h.useState(a),f=r!==void 0,x=f?r:d,_=h.useCallback(w=>{f||g(w),c==null||c(w)},[f,c]);return[x,_]}const S=(...r)=>r.filter(Boolean).join(" "),Ze=r=>r.headerName??(r.type==="boolean"?"":r.field),fe=r=>Ze(r)||r.field;function xr({anchorRef:r,open:a,onClose:c,label:d,theme:g,className:f,style:x,children:_}){const w=h.useRef(null),[L,F]=h.useState({top:0,left:0}),b=h.useCallback(()=>{var O;const C=r.current;if(!C)return;const E=C.getBoundingClientRect(),M=((O=w.current)==null?void 0:O.offsetWidth)??260,I=Math.max(8,Math.min(E.left,window.innerWidth-M-8));F({top:E.bottom+6,left:I})},[r]);return Et(()=>{a&&b()},[a,b]),h.useEffect(()=>{if(!a)return;const C=M=>{var O,te;const I=M.target;(O=w.current)!=null&&O.contains(I)||(te=r.current)!=null&&te.contains(I)||c()},E=M=>{var I;M.key==="Escape"&&(c(),(I=r.current)==null||I.focus())};return document.addEventListener("mousedown",C),document.addEventListener("keydown",E),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0),()=>{document.removeEventListener("mousedown",C),document.removeEventListener("keydown",E),window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0)}},[a,c,b,r]),!a||typeof document>"u"?null:yn.createPortal(o.jsx("div",{ref:w,role:"dialog","aria-label":d,"data-rk-theme":g||void 0,className:S("rk-grid-popup",f),style:{position:"fixed",top:L.top,left:L.left,...x},children:_}),document.body)}const Qe=r=>{if(r.trim()==="")return;const a=Number(r);return Number.isFinite(a)?a:void 0},br=r=>typeof r=="object"&&r!==null&&!Array.isArray(r);function Mn({value:r,onChange:a,label:c,inputClassName:d,inputStyle:g}){const f=br(r)?r:{},[x,_]=h.useState(f.min===void 0?"":String(f.min)),[w,L]=h.useState(f.max===void 0?"":String(f.max));h.useEffect(()=>{Qe(x)!==f.min&&_(f.min===void 0?"":String(f.min)),Qe(w)!==f.max&&L(f.max===void 0?"":String(f.max))},[f.min,f.max]);const F=(b,C)=>{const E=Qe(b),M=Qe(C);a(E===void 0&&M===void 0?void 0:{min:E,max:M})};return o.jsxs("div",{className:"rk-grid__filter-fields",children:[o.jsxs("label",{className:"rk-grid__filter-field",children:[o.jsx("span",{children:"Min"}),o.jsx("input",{autoFocus:!0,type:"number",className:S("rk-grid__filter-input",d),style:g,value:x,"aria-label":`Minimum ${c}`,onChange:b=>{_(b.target.value),F(b.target.value,w)}})]}),o.jsxs("label",{className:"rk-grid__filter-field",children:[o.jsx("span",{children:"Max"}),o.jsx("input",{type:"number",className:S("rk-grid__filter-input",d),style:g,value:w,"aria-label":`Maximum ${c}`,onChange:b=>{L(b.target.value),F(x,b.target.value)}})]})]})}function Tn({value:r,onChange:a,label:c,inputClassName:d,inputStyle:g}){const f=br(r)?r:{},x=(_,w)=>a(!_&&!w?void 0:{from:_||void 0,to:w||void 0});return o.jsxs("div",{className:"rk-grid__filter-fields",children:[o.jsxs("label",{className:"rk-grid__filter-field",children:[o.jsx("span",{children:"From"}),o.jsx("input",{autoFocus:!0,type:"date",className:S("rk-grid__filter-input",d),style:g,value:f.from??"","aria-label":`${c} from`,onChange:_=>x(_.target.value,f.to)})]}),o.jsxs("label",{className:"rk-grid__filter-field",children:[o.jsx("span",{children:"To"}),o.jsx("input",{type:"date",className:S("rk-grid__filter-input",d),style:g,value:f.to??"","aria-label":`${c} to`,onChange:_=>x(f.from,_.target.value)})]})]})}function In({value:r,onChange:a,options:c}){const d=Array.isArray(r)?r:[],g=(f,x)=>{const _=x?[...d,f]:d.filter(w=>w!==f);a(_.length?_:void 0)};return o.jsxs("div",{className:"rk-grid__filter-fields rk-grid__filter-options",role:"group",children:[c.length===0&&o.jsx("span",{className:"rk-grid__filter-empty",children:"No values"}),c.map(f=>o.jsx(ee,{checked:d.includes(f.value),onChange:x=>g(f.value,x),label:f.label??f.value},f.value))]})}function Ln({column:r,label:a,kind:c,value:d,onChange:g,options:f,theme:x,indicatorClassName:_,indicatorStyle:w,popupClassName:L,popupStyle:F,inputClassName:b,inputStyle:C}){const[E,M]=h.useState(!1),I=h.useRef(null),O=mr(d),te=h.useCallback(()=>M(!1),[]),Ne=typeof d=="string"?d:"",et=()=>{if(r.filterRenderer)return h.createElement(r.filterRenderer,{column:r,value:Ne,onChange:W=>g(W||void 0)});switch(c){case"number":return o.jsx(Mn,{value:d,onChange:g,label:a,inputClassName:b,inputStyle:C});case"date":return o.jsx(Tn,{value:d,onChange:g,label:a,inputClassName:b,inputStyle:C});case"select":return o.jsx(In,{value:d,onChange:g,options:f});default:return o.jsx("input",{autoFocus:!0,type:"text",className:S("rk-grid__filter-input",b),style:C,value:Ne,placeholder:r.filterPlaceholder??(c==="exact"?"Exactly…":`Filter ${a}…`),"aria-label":`Filter text for ${a}`,onChange:W=>g(W.target.value||void 0),onKeyDown:W=>{var re;W.key==="Enter"&&(M(!1),(re=I.current)==null||re.focus())}})}};return o.jsxs(o.Fragment,{children:[o.jsx("button",{ref:I,type:"button",className:S("rk-grid__filter-btn",O&&"rk-grid__filter-btn--active",E&&"rk-grid__filter-btn--open",_),style:w,"aria-label":`Filter ${a}`,"aria-haspopup":"dialog","aria-expanded":E,"data-active":O||void 0,onClick:W=>{W.stopPropagation(),M(re=>!re)},onKeyDown:W=>W.stopPropagation(),children:r.filterIndicator?h.createElement(r.filterIndicator,{column:r,active:O,open:E}):o.jsx("span",{className:"rk-grid__filter-dot","aria-hidden":"true"})}),o.jsxs(xr,{anchorRef:I,open:E,onClose:te,label:`Filter ${a}`,theme:x,className:L,style:F,children:[et(),O&&o.jsx("button",{type:"button",className:"rk-grid__filter-clear",onClick:()=>g(void 0),children:"Clear"})]})]})}function Fn({columns:r,hidden:a,onToggle:c,theme:d,className:g,style:f}){const[x,_]=h.useState(!1),w=h.useRef(null),L=h.useCallback(()=>_(!1),[]),F=r.filter(b=>!a.has(b.field)).length;return o.jsxs(o.Fragment,{children:[o.jsx("button",{ref:w,type:"button",className:S("rk-grid__tool-btn",g),style:f,"aria-haspopup":"dialog","aria-expanded":x,onClick:()=>_(b=>!b),children:"Columns"}),o.jsx(xr,{anchorRef:w,open:x,onClose:L,label:"Show or hide columns",theme:d,children:o.jsx("div",{className:"rk-grid__filter-fields rk-grid__filter-options",role:"group","aria-label":"Columns",children:r.filter(b=>b.hideable!==!1).map(b=>{const C=!a.has(b.field);return o.jsx(ee,{checked:C,disabled:C&&F<=1,onChange:E=>c(b.field,!E),label:fe(b)},b.field)})})})]})}const Rn=/^[=+\-@\t\r]/;function $n(r,a,c){if(r==null)return"";let d=String(r);return c&&typeof r=="string"&&Rn.test(d)&&!Number.isFinite(Number(d))&&(d=`'${d}`),d.includes(a)||/["\r\n]/.test(d)?`"${d.replace(/"/g,'""')}"`:d}function On(r,a,c={}){const{delimiter:d=",",sanitize:g=!0}=c,f=x=>x.map(_=>$n(_,d,g)).join(d);return[f(r),...a.map(f)].join(`\r
2
- `)}function Pn(r,a){if(typeof document>"u")return;const c=new Blob(["\uFEFF",r],{type:"text/csv;charset=utf-8"}),d=URL.createObjectURL(c),g=document.createElement("a");g.href=d,g.download=a,g.style.display="none",document.body.appendChild(g),g.click(),g.remove(),setTimeout(()=>URL.revokeObjectURL(d),1e3)}const St=new Set(["__proto__","prototype","constructor"]),kr=(r,a)=>Object.prototype.hasOwnProperty.call(r,a);function B(r,a){if(r===null||typeof r!="object")return;if(kr(r,a))return r[a];let c=r;for(const d of a.split(".")){if(c==null||typeof c!="object"||St.has(d))return;c=c[d]}return c}function hr(r,a,c){if(Array.isArray(r)){const d=[...r];return d[a]=c,d}return{...r,[a]:c}}function Ct(r,a,c){const d=r??{};if(kr(d,a)||!a.includes("."))return St.has(a)?r:hr(d,a,c);const[g,...f]=a.split(".");if(St.has(g))return r;const x=d[g];return hr(d,g,Ct(x!==null&&typeof x=="object"?x:{},f.join("."),c))}const G=44,An=150,pr=10,Nt=(r,a)=>`${typeof r}:${r}\0${a}`;function je(r,a){const c=B(a,r.field);return r.valueFormatter?r.valueFormatter(c,a):r.type==="boolean"&&typeof c=="boolean"?c?"Yes":"No":r.type==="date"?Nn(c,r.dateLocale,r.dateFormat):c==null?"":c instanceof Date?c.toLocaleDateString():String(c)}function Kn(r,a,c){if(c.type==="date"){const d=U(r)??"",g=U(a)??"";return d<g?-1:d>g?1:0}return typeof r=="number"&&typeof a=="number"?r-a:r instanceof Date&&a instanceof Date?r.getTime()-a.getTime():typeof r=="boolean"&&typeof a=="boolean"?Number(r)-Number(a):String(r).localeCompare(String(a),void 0,{numeric:!0,sensitivity:"base"})}const Bn=r=>r?Array.isArray(r)?r:[r]:[],gr=r=>r.type==="date"&&r.validity.badInput;function Wn({columns:r,rows:a,getRowId:c,editable:d=!1,enterMovesDown:g=!0,onCellEdit:f,onRowsChange:x,rowSelection:_=!1,selectedRowIds:w,defaultSelectedRowIds:L,onSelectionChange:F,isRowSelectable:b,sort:C,defaultSort:E=null,onSortChange:M,multiSort:I=!1,searchable:O=!1,searchPlaceholder:te="Search…",search:Ne,onSearchChange:et,filters:W,onFiltersChange:re,pagination:z=!1,paginationPosition:Ee="bottom",pageSize:_r=10,pageSizeOptions:tt=[5,10,25,50],page:yr,onPageChange:vr,onPageSizeChange:rt,serverSide:K=!1,rowCount:jr,onQueryChange:Dt,queryDebounce:Mt=250,loading:wr,loadingRows:Nr,skeletonRow:Tt,errorMessage:Er="Could not load the data.",columnMenu:It=!1,onColumnVisibilityChange:nt,keyboardNavigation:it=!1,virtualize:V=!1,rowHeight:H=40,overscan:Lt=6,exportable:Se=!1,apiRef:ue,onRowClick:ot,toolbar:Ft,emptyMessage:Sr="No rows to show",striped:Cr=!1,stripeColors:Ce,checkboxVariant:st="native",animateRows:Rt=!0,theme:lt,maxHeight:De,className:Dr,style:Mr,classNames:D={},styles:v={},rowClassName:at,rowStyle:ct}){const T=(e,t)=>({className:S(t,D[e]),style:v[e]}),[Me,$t]=h.useState(a),ne=h.useRef(a);h.useEffect(()=>{ne.current=a,$t(a)},[a]);const Ot=e=>{ne.current=e,$t(e)},[he,Tr]=ve(Ne,"",et),[ie,Ir]=ve(W,{},re),[P,Lr]=ve(C,Bn(E),M),[dt,oe]=ve(yr,0,vr),[R,Fr]=h.useState(_r),Rr=e=>{Fr(e),rt==null||rt(e)},[Te,$r]=h.useState(()=>new Set(r.filter(e=>e.hidden).map(e=>e.field))),Or=(e,t)=>{const n=new Set(Te);t?n.add(e):n.delete(e),$r(n),nt==null||nt([...n])},[ft,Pt]=h.useState({}),[Ie,Pr]=h.useState({}),[Vn,Ar]=h.useState(0),pe=h.useRef(new Map),[ge,se]=h.useState(null),le=h.useRef(0),Le=h.useRef(null),Fe=h.useRef(new Map),[ut,At]=h.useState(null),ht=h.useRef(null),me=h.useRef(null),[pt,Kt]=h.useState({top:0,height:0}),y=h.useMemo(()=>{const e=r.filter(t=>!Te.has(t.field));return[...e.filter(t=>t.pinned==="left"),...e.filter(t=>t.pinned!=="left"&&t.pinned!=="right"),...e.filter(t=>t.pinned==="right")]},[r,Te]),gt=e=>e.sortable===!0,A=_==="single"?"single":_?"multiple":null,xe=y.length+(A?1:0),ae=h.useMemo(()=>Me.map((e,t)=>({row:e,index:t,id:c?c(e,t):t})),[Me,c]),Bt=h.useRef(new Map);ae.forEach(e=>Bt.current.set(e.id,e.row));const Re=h.useMemo(()=>Object.entries(ie).filter(([e,t])=>{const n=y.find(l=>l.field===e);return!!n&&!!n.filterable&&mr(t)}),[ie,y]),[Kr,Br]=h.useState(he);h.useEffect(()=>{if(!K)return;const e=setTimeout(()=>Br(he),Mt);return()=>clearTimeout(e)},[he,K,Mt]);const ce=K?Kr:he,Wt=e=>e.filterRenderer?"text":ur(e),J=h.useMemo(()=>{if(K)return ae;const e=ce.trim().toLowerCase();let t=ae.filter(({row:l})=>e&&!y.some(i=>je(i,l).toLowerCase().includes(e))?!1:Re.every(([i,s])=>{const m=y.find(p=>p.field===i);return Cn(Wt(m),s,je(m,l),B(l,i))}));const n=P.map(l=>({col:y.find(i=>i.field===l.field),dir:l.direction==="asc"?1:-1})).filter(l=>!!l.col);return n.length&&(t=[...t].sort((l,i)=>{for(const{col:s,dir:m}of n){const p=B(l.row,s.field),u=B(i.row,s.field),k=p==null||p==="",N=u==null||u==="";if(k||N){if(k!==N)return k?1:-1;continue}const Xe=s.comparator?s.comparator(p,u,l.row,i.row):Kn(p,u,s);if(Xe!==0)return Xe*m}return 0})),t},[ae,y,ce,Re,P,K]),$e=JSON.stringify([ce,ie,P,R]),Vt=h.useRef($e);h.useEffect(()=>{Vt.current!==$e&&(Vt.current=$e,oe(0))},[$e]);const de=K?jr??ae.length:J.length,Y=z?Math.max(1,Math.ceil(de/R)):1,$=Math.min(dt,Y-1),j=z&&!K?J.slice($*R,$*R+R):J,Wr=de===0?0:z?$*R+1:1,Vr=z?Math.min(de,($+1)*R):de,mt=h.useMemo(()=>({sort:P.filter(e=>{const t=r.find(n=>n.field===e.field);return!!t&&gt(t)}),filters:Object.fromEntries(Re),search:ce.trim(),page:$,pageSize:R}),[P,r,Re,ce,$,R]),Ur=JSON.stringify(mt),Oe=h.useRef(mt);Oe.current=mt;const Pe=h.useRef(Dt);Pe.current=Dt;const[qr,Ae]=h.useState(!1),[zr,xt]=h.useState(!1),bt=h.useRef(0),Ke=h.useCallback(e=>{var l;const t=++bt.current,n=(l=Pe.current)==null?void 0:l.call(Pe,e);n&&typeof n.then=="function"?(Ae(!0),xt(!1),n.then(()=>{t===bt.current&&Ae(!1)},()=>{t===bt.current&&(Ae(!1),xt(!0))})):(Ae(!1),xt(!1))},[]);h.useEffect(()=>{K&&Ke(Oe.current)},[K,Ur,Ke]),h.useEffect(()=>{K&&z&&dt>Y-1&&oe(Y-1)},[K,z,dt,Y]);const kt=wr??qr,Ut=e=>e.map(t=>Bt.current.get(t)).filter(t=>t!==void 0),[q,Be]=ve(w,L??[],e=>F==null?void 0:F({ids:e,rows:Ut(e)})),_t=h.useMemo(()=>new Set(q),[q]),We=e=>b?b(e):!0,Ve=h.useRef(null),qt=h.useRef(!1),Hr=(e,t)=>{if(!A||!We(e.row))return;if(A==="single"){Be(t?[e.id]:[]),Ve.current=e.id;return}const n=new Set(q),l=qt.current&&Ve.current!==null?j.findIndex(s=>s.id===Ve.current):-1,i=j.findIndex(s=>s.id===e.id);if(l>=0&&i>=0)for(let s=Math.min(l,i);s<=Math.max(l,i);s++)We(j[s].row)&&(t?n.add(j[s].id):n.delete(j[s].id));else t?n.add(e.id):n.delete(e.id);Ve.current=e.id,Be([...n])},be=h.useMemo(()=>J.filter(e=>We(e.row)),[J,b]),zt=be.filter(e=>_t.has(e.id)).length,Ht=be.length>0&&zt===be.length,Jt=e=>{const t=new Set(q);be.forEach(n=>e?t.add(n.id):t.delete(n.id)),Be([...t])},Ue=(e,t,n)=>({value:B(t,e.field),formattedValue:je(e,t),row:t,rowIndex:n,field:e.field,column:e}),yt=(e,t)=>{const n=e.editable??d;return typeof n=="function"?n(t):!!n},qe=(e,t)=>yt(e,t)&&!(e.type==="boolean"&&!e.cellEditor),Jr=(e,t)=>{const n=Ue(e,t.row,t.index),l=yt(e,n);return{...n,editable:l,updateValue:i=>l&&Gt(t,e,{value:i})}},Yt=(e,t)=>{if(!gt(e))return;const n=P.find(s=>s.field===e.field),l=n?n.direction==="asc"?"desc":null:"asc";let i;t&&I?l?n?i=P.map(s=>s.field===e.field?{...s,direction:l}:s):i=[...P,{field:e.field,direction:l}]:i=P.filter(s=>s.field!==e.field):i=l?[{field:e.field,direction:l}]:[],Lr(i)},ze=(e,t)=>{var n;return(n=Fe.current.get(Nt(e,t)))==null?void 0:n.focus()},X=()=>{le.current+=1,se(null)},Yr=e=>{for(const t of ne.current){const n=B(t,e.field);if(n!=null&&n!=="")return n}},He=(e,t,n={})=>{if(!qe(t,Ue(t,e.row,e.index)))return!1;const l=B(e.row,t.field);let i;return t.cellEditor?i=l:t.type==="date"?i=U(l)??"":i=n.text??(l==null?"":String(l)),Le.current=i,le.current+=1,se({id:e.id,field:t.field,draft:i,session:le.current,select:n.select??"end",invalid:!1}),!0},Gt=(e,t,n)=>{const l=ne.current[e.index]??e.row,i=B(l,t.field);let s;if("value"in n)s=n.value;else if(t.valueParser)s=t.valueParser(n.text,l);else if(t.type==="date"){if(n.text!==""&&!we(n.text))return!1;s=En(n.text,i??Yr(t))}else if(t.type==="number")if(n.text.trim()==="")s=null;else{const u=Number(n.text);if(!Number.isFinite(u))return!1;s=u}else s=n.text;if(t.type==="date"){if(U(s)===U(i))return!0;const u=U(s);if(u&&(t.dateMin&&u<t.dateMin||t.dateMax&&u>t.dateMax))return!1}else if(Object.is(s,i))return!0;if(t.validate&&!t.validate(s,l))return!1;const m=Ct(l,t.field,s),p=ne.current.map((u,k)=>k===e.index?m:u);return Ot(p),f==null||f({rowId:e.id,rowIndex:e.index,field:t.field,oldValue:i,newValue:s,row:m}),x==null||x(p),!0},Xt=(e,t,n)=>{const l=j.findIndex(k=>k.id===e.id),i=y.findIndex(k=>k.field===t);if(l<0||i<0)return null;const s=(k,N)=>qe(N,Ue(N,k.row,k.index));if(n==="down"||n==="up"){const k=n==="down"?1:-1;for(let N=l+k;N>=0&&N<j.length;N+=k)if(s(j[N],y[i]))return{entry:j[N],col:y[i]};return null}const m=n==="right"?1:-1;let p=l,u=i+m;for(;p>=0&&p<j.length;){for(;u>=0&&u<y.length;){if(s(j[p],y[u]))return{entry:j[p],col:y[u]};u+=m}p+=m,u=m>0?0:y.length-1}return null},ke=(e,t,n,l={})=>{const{move:i="none",focus:s=!0}=l;if(!Gt(e,t,n))return se(p=>p&&{...p,invalid:!0}),!1;const m=i==="none"?null:Xt(e,t.field,i);return m?He(m.entry,m.col,{select:"all"}):(X(),s&&ze(e.id,t.field)),!0},Gr=(e,t,n)=>{if(e.nativeEvent.isComposing)return;const l=e.currentTarget.value,i=gr(e.currentTarget);if(e.key==="Enter"){if(e.preventDefault(),i)return se(m=>m&&{...m,invalid:!0});const s=g?e.shiftKey?"up":"down":"none";ke(t,n,{text:l},{move:s})}else if(e.key==="Escape")e.preventDefault(),X(),ze(t.id,n.field);else if(e.key==="Tab"&&!i){const s=e.shiftKey?"left":"right";Xt(t,n.field,s)&&(e.preventDefault(),ke(t,n,{text:l},{move:s}))}},Xr=(e,t)=>{var s;const n=j[e],l=y[t];if(!n||!l)return;At({id:n.id,field:l.field}),ht.current=Nt(n.id,l.field);const i=me.current;if(V&&i){const m=((s=i.querySelector("thead"))==null?void 0:s.clientHeight)??0,p=e*H;p<i.scrollTop?i.scrollTo({top:p,behavior:"auto"}):p+H>i.scrollTop+i.clientHeight-m&&i.scrollTo({top:p+H-i.clientHeight+m,behavior:"auto"})}};h.useEffect(()=>{const e=ht.current;if(!e)return;const t=Fe.current.get(e);t&&(ht.current=null,t.focus())});const Qr=(e,t,n)=>{if(!it)return!1;let l=j.findIndex(s=>s.id===t.id),i=y.findIndex(s=>s.field===n.field);if(l<0||i<0)return!1;switch(e.key){case"ArrowDown":l+=1;break;case"ArrowUp":l-=1;break;case"ArrowRight":i+=1;break;case"ArrowLeft":i-=1;break;case"PageDown":l+=pr;break;case"PageUp":l-=pr;break;case"Home":i=0,(e.ctrlKey||e.metaKey)&&(l=0);break;case"End":i=y.length-1,(e.ctrlKey||e.metaKey)&&(l=j.length-1);break;default:return!1}return e.preventDefault(),Xr(Math.max(0,Math.min(j.length-1,l)),Math.max(0,Math.min(y.length-1,i))),!0},Zr=(e,t,n,l)=>{e.target===e.currentTarget&&(Qr(e,t,n)||qe(n,l)&&(e.key==="Enter"||e.key==="F2"?(e.preventDefault(),He(t,n)):!n.cellEditor&&n.type!=="date"&&e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.preventDefault(),He(t,n,{text:e.key}))))};Et(()=>{if(!V||!me.current)return;const e=me.current,t=()=>Kt(l=>l.height===e.clientHeight?l:{...l,height:e.clientHeight});if(t(),typeof ResizeObserver>"u")return;const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[V]);const _e=V&&!kt&&j.length>0,en=pt.height||(typeof De=="number"?De:400),Je=_e?Math.max(0,Math.floor(pt.top/H)-Lt):0,vt=_e?Math.min(j.length,Math.ceil((pt.top+en)/H)+Lt):j.length,tn=_e?j.slice(Je,vt):j,Qt=`${$}|${R}|${JSON.stringify(P)}|${ce}|${JSON.stringify(ie)}`,Zt=h.useRef(!0);h.useEffect(()=>{if(Zt.current){Zt.current=!1;return}const e=me.current;e&&typeof e.scrollTo=="function"&&e.scrollTop>0&&e.scrollTo({top:0,behavior:"smooth"})},[Qt]);const jt=Object.keys(ft).length>0,Ye=e=>ft[e.field]??(typeof e.width=="number"?e.width:An),rn=e=>Math.max(40,typeof e.minWidth=="number"?e.minWidth:60),nn=(e,t)=>{e.preventDefault(),e.stopPropagation();const n={...ft};jt||y.forEach(k=>{var N;return n[k.field]=((N=pe.current.get(k.field))==null?void 0:N.offsetWidth)??Ye(k)});const l=e.clientX,i=n[t.field]??Ye(t),s=e.currentTarget;s.setPointerCapture(e.pointerId),Pt(n);const m=k=>Math.min(t.maxWidth??1/0,Math.max(rn(t),Math.round(k))),p=k=>Pt(N=>({...N,[t.field]:m(i+k.clientX-l)})),u=()=>{s.removeEventListener("pointermove",p),s.removeEventListener("pointerup",u),s.removeEventListener("pointercancel",u)};s.addEventListener("pointermove",p),s.addEventListener("pointerup",u),s.addEventListener("pointercancel",u)};Et(()=>{var i,s;const e={};let t=A&&y.some(m=>m.pinned==="left")?G:0;for(const m of y)m.pinned==="left"&&(e[m.field]=t,t+=((i=pe.current.get(m.field))==null?void 0:i.offsetWidth)??0);let n=0;for(const m of[...y].reverse())m.pinned==="right"&&(e[m.field]=n,n+=((s=pe.current.get(m.field))==null?void 0:s.offsetWidth)??0);const l=Object.keys(e);(l.length!==Object.keys(Ie).length||l.some(m=>e[m]!==Ie[m]))&&Pr(e)}),h.useEffect(()=>{const e=()=>Ar(t=>t+1);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const er=y.map(e=>e.pinned).lastIndexOf("left"),on=y.findIndex(e=>e.pinned==="right"),Ge=er>=0,tr=(e,t)=>({className:e.pinned?S("rk-grid__pinned",`rk-grid__pinned--${e.pinned}`,t===er&&"rk-grid__pinned--edge",t===on&&"rk-grid__pinned--edge"):void 0,style:e.pinned==="left"?{left:Ie[e.field]??0}:e.pinned==="right"?{right:Ie[e.field]??0}:void 0}),rr=typeof Se=="object"?Se:{},nr=(e={})=>{const t={...rr,...e},n=t.scope??"filtered",l=n==="page"?j:n==="selected"?ae.filter(p=>_t.has(p.id)):J,i=t.includeHidden?r:y,s=i.map(p=>Ze(p)||p.field),m=l.map(({row:p})=>i.map(u=>{const k=B(p,u.field);return u.exportValue?u.exportValue(k,p):u.type==="date"?U(k)??"":je(u,p)}));return On(s,m,{sanitize:t.sanitize})},ir=(e={})=>{const t={...rr,...e};Pn(nr(e),`${t.filename??"export"}.csv`)};h.useEffect(()=>{ue&&(ue.current={getCsv:nr,exportCsv:ir,getSelectedRows:()=>Ut(q),getSelectedRowIds:()=>q,selectAll:()=>Jt(!0),clearSelection:()=>Be([]),refresh:()=>{K&&Ke(Oe.current)}})}),h.useEffect(()=>()=>{ue&&(ue.current=null)},[ue]);const or=e=>{var n,l,i,s,m,p,u,k;const t=e.checkbox??{};return{variant:t.variant??st,indicator:t.indicator,className:t.className,style:t.style,classNames:{root:S(D.checkbox,(n=t.classNames)==null?void 0:n.root),control:S(D.checkboxControl,(l=t.classNames)==null?void 0:l.control),indicator:S(D.checkboxIndicator,(i=t.classNames)==null?void 0:i.indicator),label:(s=t.classNames)==null?void 0:s.label},styles:{root:{...v.checkbox,...(m=t.styles)==null?void 0:m.root},control:{...v.checkboxControl,...(p=t.styles)==null?void 0:p.control},indicator:{...v.checkboxIndicator,...(u=t.styles)==null?void 0:u.indicator},label:(k=t.styles)==null?void 0:k.label}}},Q=e=>e.stopPropagation(),sn=(e,t)=>o.jsx("span",{className:"rk-grid__checkbox-cell",onClick:Q,onDoubleClick:Q,children:o.jsx(ee,{...or(e),checked:!!t.value,disabled:!t.editable,"aria-label":`Toggle ${fe(e)}`,onChange:n=>t.updateValue(n)})}),sr=e=>J.filter(t=>yt(e,Ue(e,t.row,t.index))),ln=(e,t)=>{const n=new Map(sr(e).map(s=>[s.index,s])),l=[],i=ne.current.map((s,m)=>{const p=n.get(m);if(!p)return s;const u=B(s,e.field);if(!!u===t||e.validate&&!e.validate(t,s))return s;const k=Ct(s,e.field,t);return l.push({rowId:p.id,rowIndex:m,field:e.field,oldValue:u,newValue:t,row:k}),k});l.length!==0&&(Ot(i),l.forEach(s=>f==null?void 0:f(s)),x==null||x(i))},an=e=>{const t=sr(e),n=t.length>0?t:J,l=n.filter(s=>!!B(s.row,e.field)).length,i=n.length>0&&l===n.length;return o.jsx("span",{className:"rk-grid__header-checkbox",onClick:Q,onDoubleClick:Q,children:o.jsx(ee,{...or(e),checked:i,indeterminate:l>0&&!i,disabled:t.length===0,label:Ze(e)||void 0,"aria-label":`Select all ${fe(e)}`,onChange:s=>ln(e,s)})})},cn=(e,t,n)=>{if(t.cellEditor)return o.jsx("div",{className:"rk-grid__custom-editor",onBlur:i=>{i.currentTarget.contains(i.relatedTarget)||n.session===le.current&&(ke(e,t,{value:Le.current},{focus:!1})||X())},onKeyDown:i=>{i.key==="Escape"&&(i.preventDefault(),i.stopPropagation(),X(),ze(e.id,t.field))},children:h.createElement(t.cellEditor,{value:n.draft,row:e.row,rowIndex:e.index,field:t.field,column:t,onChange:i=>{Le.current=i,se(s=>s&&s.session===n.session?{...s,draft:i,invalid:!1}:s)},onCommit:(i,s="none")=>{n.session===le.current&&ke(e,t,{value:i===void 0?Le.current:i},{move:s})},onCancel:()=>{X(),ze(e.id,t.field)}})});const l=t.type==="date";return o.jsx("input",{autoFocus:!0,type:l?"date":"text",min:l?t.dateMin:void 0,max:l?t.dateMax:void 0,className:S("rk-grid__editor",n.invalid&&"rk-grid__editor--invalid",D.editor),style:{textAlign:t.align,...v.editor},value:n.draft===null||n.draft===void 0?"":String(n.draft),inputMode:t.type==="number"?"decimal":void 0,"aria-label":`Edit ${fe(t)}`,"aria-invalid":n.invalid||void 0,onChange:i=>{const s=i.target.value;se(m=>m&&{...m,draft:s,invalid:!1})},onFocus:i=>{const s=i.currentTarget;l||(n.select==="all"?s.select():s.setSelectionRange(s.value.length,s.value.length))},onBlur:i=>{if(n.session===le.current){if(gr(i.currentTarget))return X();ke(e,t,{text:i.currentTarget.value},{focus:!1})||X()}},onKeyDown:i=>Gr(i,e,t)})},dn=h.useMemo(()=>{const e=new Map;for(const t of y)t.filterable&&!t.filterRenderer&&ur(t)==="select"&&e.set(t.field,Dn(t,Me,n=>B(n,t.field),n=>je(t,n)));return e},[y,Me]),fn=Cr||!!Ce,un=Ce?{"--rk-stripe-a":Ce[0],"--rk-stripe-b":Ce[1]}:void 0,hn=z&&(Ee==="top"||Ee==="both"),pn=z&&(Ee==="bottom"||Ee==="both"),gn=O||!!Ft||It||!!Se,lr=e=>o.jsxs("div",{className:S("rk-grid__footer",e==="top"&&"rk-grid__footer--top",D.footer),style:v.footer,"data-position":e,children:[o.jsxs("span",{...T("rowCount","rk-grid__count"),children:[de===0?"0 rows":`${Wr}–${Vr} of ${de}`,A&&q.length>0?` · ${q.length} selected`:""]}),o.jsxs("div",{...T("pagination","rk-grid__pagination"),children:[o.jsxs("label",{className:"rk-grid__page-size-label",children:["Rows per page",o.jsx("select",{value:R,onChange:t=>Rr(Number(t.target.value)),...T("pageSize","rk-grid__page-size"),children:(tt.includes(R)?tt:[...tt,R].sort((t,n)=>t-n)).map(t=>o.jsx("option",{value:t,children:t},t))})]}),o.jsx("button",{type:"button","aria-label":"First page",disabled:$===0,onClick:()=>oe(0),...T("pageButton","rk-grid__page-btn"),children:"«"}),o.jsx("button",{type:"button","aria-label":"Previous page",disabled:$===0,onClick:()=>oe($-1),...T("pageButton","rk-grid__page-btn"),children:"‹"}),o.jsxs("span",{...T("pageInfo","rk-grid__page-info"),children:["Page ",$+1," of ",Y]}),o.jsx("button",{type:"button","aria-label":"Next page",disabled:$>=Y-1,onClick:()=>oe($+1),...T("pageButton","rk-grid__page-btn"),children:"›"}),o.jsx("button",{type:"button","aria-label":"Last page",disabled:$>=Y-1,onClick:()=>oe(Y-1),...T("pageButton","rk-grid__page-btn"),children:"»"})]})]}),mn=e=>o.jsx("tr",{className:"rk-grid__tr rk-grid__skeleton-row","aria-hidden":"true",style:V?{height:H}:void 0,children:Tt?o.jsx("td",{colSpan:xe,className:"rk-grid__td rk-grid__skeleton-cell",children:h.createElement(Tt,{rowIndex:e,columns:y})}):o.jsxs(o.Fragment,{children:[A&&o.jsx("td",{className:"rk-grid__td",children:o.jsx("span",{...T("skeleton","rk-grid__skeleton"),style:{...v.skeleton,width:18}})}),y.map((t,n)=>o.jsx("td",{className:"rk-grid__td",style:{textAlign:t.align},children:o.jsx("span",{...T("skeleton","rk-grid__skeleton"),style:{...v.skeleton,width:`${55+(e*7+n*13)%35}%`}})},t.field))]})},`sk${e}`),xn=(e,t)=>{const{row:n,id:l,index:i}=e,s=typeof at=="function"?at(n,i):at,m=typeof ct=="function"?ct(n,i):ct,p=_t.has(l);return o.jsxs("tr",{onClick:ot?()=>ot(n,i):void 0,"aria-selected":A?p:void 0,className:S("rk-grid__tr","rk-grid__row",fn&&(t%2===0?"rk-grid__row--stripe-a":"rk-grid__row--stripe-b"),Rt&&!V&&"rk-grid__row--enter",p&&"rk-grid__row--selected",ot&&"rk-grid__row--clickable",D.row,s),style:{...Rt&&!V?{"--rk-i":Math.min(t,24)}:null,...V?{height:H}:null,...v.row,...m},children:[A&&o.jsx("td",{className:S("rk-grid__td rk-grid__select-cell",Ge&&"rk-grid__pinned rk-grid__pinned--left"),style:{width:G,minWidth:G,maxWidth:G,...Ge?{left:0}:null},onClick:Q,children:o.jsx("span",{className:"rk-grid__checkbox-cell",onClickCapture:u=>qt.current=u.shiftKey,children:o.jsx(ee,{variant:st,checked:p,disabled:!We(n),"aria-label":A==="single"?"Select row":`Select row ${i+1}`,onChange:u=>Hr(e,u),classNames:{root:D.checkbox,control:D.checkboxControl,indicator:D.checkboxIndicator},styles:{root:v.checkbox,control:v.checkboxControl,indicator:v.checkboxIndicator}})})}),y.map((u,k)=>{const N=Jr(u,e),Xe=typeof u.cellClassName=="function"?u.cellClassName(N):u.cellClassName,kn=typeof u.cellStyle=="function"?u.cellStyle(N):u.cellStyle,ar=ge!==null&&ge.id===l&&ge.field===u.field,wt=qe(u,N),cr=tr(u,k),_n=ut?ut.id===l&&ut.field===u.field:t===0&&k===0;return o.jsx("td",{ref:Z=>{const dr=Nt(l,u.field);Z?Fe.current.set(dr,Z):Fe.current.delete(dr)},tabIndex:it?_n?0:-1:wt?0:void 0,onFocus:it?Z=>Z.target===Z.currentTarget&&At({id:l,field:u.field}):void 0,onDoubleClick:wt?()=>He(e,u):void 0,onKeyDown:Z=>Zr(Z,e,u,N),className:S("rk-grid__td",wt&&"rk-grid__td--editable",ar&&"rk-grid__td--editing",cr.className,D.cell,u.className,Xe),style:{textAlign:u.align,...v.cell,...u.style,...kn,...cr.style},children:ar&&ge?cn(e,u,ge):u.cellRenderer?h.createElement(u.cellRenderer,N):u.type==="boolean"&&!u.cellEditor?sn(u,N):N.formattedValue},u.field)})]},l)},bn=Nr??(z?Math.min(R,20):5);return o.jsxs("div",{className:S("rk-grid",V&&"rk-grid--virtual",D.root,Dr),style:{...un,...v.root,...Mr},"data-rk-theme":lt||void 0,"aria-busy":kt||void 0,children:[gn&&o.jsxs("div",{...T("toolbar","rk-grid__toolbar"),children:[o.jsxs("div",{className:"rk-grid__toolbar-left",children:[O&&o.jsx("input",{type:"search",value:he,onChange:e=>Tr(e.target.value),placeholder:te,"aria-label":"Search all columns",...T("search","rk-grid__search")}),A&&q.length>0&&o.jsxs("span",{className:"rk-grid__selected-count",role:"status",children:[q.length," selected"]})]}),o.jsxs("div",{className:"rk-grid__toolbar-actions",children:[Ft,It&&o.jsx(Fn,{columns:r,hidden:Te,onToggle:Or,theme:lt,className:D.toolButton,style:v.toolButton}),Se&&o.jsx("button",{type:"button",onClick:()=>ir(),...T("toolButton","rk-grid__tool-btn"),children:"Export CSV"})]})]}),hn&&lr("top"),o.jsx("div",{ref:me,...T("scroll","rk-grid__scroll"),onScroll:V?e=>Kt({top:e.currentTarget.scrollTop,height:e.currentTarget.clientHeight}):void 0,style:{...v.scroll,...De!==void 0?{maxHeight:De}:V?{maxHeight:400}:null},children:o.jsxs("table",{...T("table","rk-grid__table"),role:"grid",style:jt?{...v.table,tableLayout:"fixed",width:y.reduce((e,t)=>e+Ye(t),A?G:0),minWidth:"100%"}:v.table,children:[o.jsx("thead",{...T("thead","rk-grid__thead"),children:o.jsxs("tr",{...T("headerRow","rk-grid__tr"),children:[A&&o.jsx("th",{scope:"col",className:S("rk-grid__th rk-grid__select-cell",Ge&&"rk-grid__pinned rk-grid__pinned--left",D.headerCell),style:{width:G,minWidth:G,maxWidth:G,...Ge?{left:0}:null,...v.headerCell},children:A==="multiple"&&o.jsx("span",{className:"rk-grid__checkbox-cell",children:o.jsx(ee,{variant:st,checked:Ht,indeterminate:zt>0&&!Ht,disabled:be.length===0,"aria-label":"Select all rows",onChange:Jt,classNames:{root:D.checkbox,control:D.checkboxControl,indicator:D.checkboxIndicator},styles:{root:v.checkbox,control:v.checkboxControl,indicator:v.checkboxIndicator}})})}),y.map((e,t)=>{const n=P.findIndex(p=>p.field===e.field),l=n>=0?P[n].direction:null,i=gt(e),s=Wt(e),m=tr(e,t);return o.jsxs("th",{ref:p=>{p?pe.current.set(e.field,p):pe.current.delete(e.field)},scope:"col","aria-sort":l?l==="asc"?"ascending":"descending":i?"none":void 0,tabIndex:i?0:void 0,onClick:p=>Yt(e,p.shiftKey),onKeyDown:p=>{i&&p.target===p.currentTarget&&(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),Yt(e,p.shiftKey))},className:S("rk-grid__th",i&&"rk-grid__th--sortable",m.className,D.headerCell,e.className,e.headerClassName),style:{width:jt?Ye(e):e.width,minWidth:e.minWidth,textAlign:e.align,...v.headerCell,...e.style,...e.headerStyle,...m.style},children:[o.jsxs("span",{className:"rk-grid__th-content",children:[e.headerRenderer?h.createElement(e.headerRenderer,{column:e,sortDirection:l}):e.headerCheckbox&&e.type==="boolean"?an(e):Ze(e),e.filterable&&o.jsx(Ln,{column:e,label:fe(e),kind:s,value:ie[e.field],onChange:p=>{const u={...ie};p===void 0?delete u[e.field]:u[e.field]=p,Ir(u)},options:dn.get(e.field)??[],theme:lt,indicatorClassName:S(D.filterIndicator,e.filterIndicatorClassName),indicatorStyle:{...v.filterIndicator,...e.filterIndicatorStyle},popupClassName:S(D.filterPopup,e.filterPopupClassName),popupStyle:{...v.filterPopup,...e.filterPopupStyle},inputClassName:D.filterInput,inputStyle:v.filterInput}),i&&o.jsxs("span",{className:"rk-grid__sort","aria-hidden":"true",children:[l==="asc"?"▲":l==="desc"?"▼":"↕",l&&P.length>1&&o.jsx("sup",{className:"rk-grid__sort-order",children:n+1})]})]}),e.resizable&&o.jsx("span",{className:"rk-grid__resizer",role:"separator","aria-orientation":"vertical","aria-label":`Resize ${fe(e)}`,onPointerDown:p=>nn(p,e),onClick:Q,onDoubleClick:Q})]},e.field)})]})}),o.jsx("tbody",{...T("tbody","rk-grid__tbody"),children:kt?Array.from({length:bn},(e,t)=>mn(t)):zr?o.jsx("tr",{children:o.jsxs("td",{colSpan:xe,...T("empty","rk-grid__empty rk-grid__error"),role:"alert",children:[Er," ",o.jsx("button",{type:"button",className:"rk-grid__tool-btn",onClick:()=>Ke(Oe.current),children:"Retry"})]})}):j.length===0?o.jsx("tr",{children:o.jsx("td",{colSpan:xe,...T("empty","rk-grid__empty"),children:Sr})}):o.jsxs(o.Fragment,{children:[_e&&Je>0&&o.jsx("tr",{"aria-hidden":"true",className:"rk-grid__spacer",children:o.jsx("td",{colSpan:xe,style:{height:Je*H}})}),tn.map((e,t)=>xn(e,Je+t)),_e&&vt<j.length&&o.jsx("tr",{"aria-hidden":"true",className:"rk-grid__spacer",children:o.jsx("td",{colSpan:xe,style:{height:(j.length-vt)*H}})})]})},Qt)]})}),pn&&lr("bottom")]})}exports.Checkbox=ee;exports.DataGrid=Wn;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),u=require("react"),Cn=require("react-dom"),Ie=(...r)=>r.filter(Boolean).join(" ");function Fn(){return i.jsx("svg",{viewBox:"0 0 16 16",width:"100%",height:"100%","aria-hidden":"true",focusable:"false",children:i.jsx("path",{d:"M3.5 8.5l3 3 6-7",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Tn(){return i.jsx("svg",{viewBox:"0 0 16 16",width:"100%",height:"100%","aria-hidden":"true",focusable:"false",children:i.jsx("path",{d:"M4 8h8",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round"})})}function xe({checked:r,onChange:n,indeterminate:d=!1,variant:c="native",disabled:h=!1,label:g,"aria-label":f,id:j,name:y,indicator:S,className:M,style:w,classNames:v={},styles:_={}}){const E=d?"indeterminate":r?"checked":"unchecked";return i.jsxs("label",{className:Ie("rg-checkbox",`rg-checkbox--${c}`,E==="checked"&&"rg-checkbox--checked",d&&"rg-checkbox--indeterminate",h&&"rg-checkbox--disabled",v.root,M),style:{..._.root,...w},"data-state":E,children:[c==="native"?i.jsx("input",{type:"checkbox",id:j,name:y,ref:I=>{I&&(I.indeterminate=d)},className:Ie("rg-checkbox__control",v.control),style:_.control,checked:r,disabled:h,"aria-label":f,"data-state":E,onChange:I=>n(I.target.checked)}):i.jsx("button",{type:"button",role:"checkbox",id:j,className:Ie("rg-checkbox__control",v.control),style:_.control,"aria-checked":d?"mixed":r,"aria-label":f,disabled:h,"data-state":E,onClick:()=>n(!r),children:i.jsx("span",{className:Ie("rg-checkbox__indicator",S!==void 0&&!d&&"rg-checkbox__indicator--custom",v.indicator),style:_.indicator,"data-state":E,"aria-hidden":"true",children:d?c==="tick"?i.jsx(Tn,{}):null:S!==void 0?S:c==="tick"?i.jsx(Fn,{}):null})}),g!=null&&g!==!1&&g!==""&&i.jsx("span",{className:Ie("rg-checkbox__label",v.label),style:_.label,children:g})]})}const Rn=/^(\d{4})-(\d{2})-(\d{2})$/,jr=r=>String(r).padStart(2,"0");function U(r){const n=Rn.exec(r);if(!n)return null;const[d,c,h]=[Number(n[1]),Number(n[2]),Number(n[3])],g=new Date(d,c-1,h);return g.getFullYear()===d&&g.getMonth()===c-1&&g.getDate()===h?g:null}function G(r){var n;if(r instanceof Date)return Number.isNaN(r.getTime())?null:`${r.getFullYear()}-${jr(r.getMonth()+1)}-${jr(r.getDate())}`;if(typeof r=="number")return Number.isFinite(r)?G(new Date(r)):null;if(typeof r=="string"){const d=r.trim();if(d==="")return null;const c=(n=/^\d{4}-\d{2}-\d{2}/.exec(d))==null?void 0:n[0];if(c)return U(c)?c:null;const h=Date.parse(d);return Number.isNaN(h)?null:G(new Date(h))}return null}function In(r,n,d){const c=G(r);return c?U(c).toLocaleDateString(n,d??{year:"numeric",month:"short",day:"numeric"}):r==null?"":String(r)}function Ln(r,n){var d;return r===""?null:n instanceof Date?U(r):typeof n=="number"?((d=U(r))==null?void 0:d.getTime())??null:r}const $=(...r)=>r.filter(Boolean).join(" "),ut=r=>r.headerName??(r.type==="boolean"?"":r.type==="sequence"?"#":r.field),be=r=>ut(r)||r.field,wr=r=>String(r).padStart(2,"0"),Pt=(r,n,d)=>`${r}-${wr(n+1)}-${wr(d)}`;function Dr(r,n,d,c){const h=[r,n==null?void 0:n.from,n==null?void 0:n.to].map(y=>y?U(y):null).find(Boolean);if(h)return new Date(h.getFullYear(),h.getMonth(),1);const g=new Date;let f=G(g);d&&f<d&&(f=d),c&&f>c&&(f=c);const j=U(f)??g;return new Date(j.getFullYear(),j.getMonth(),1)}function Fr({value:r,range:n,min:d,max:c,onPick:h,locale:g,weekStart:f=0,hideFooter:j,keepFocus:y,className:S}){var Ae;const[M,w]=u.useState(()=>Dr(r,n,d,c)),[v,_]=u.useState(null),E=u.useRef(null),I=u.useRef({value:r,from:n==null?void 0:n.from,to:n==null?void 0:n.to});u.useEffect(()=>{const x=I.current;I.current={value:r,from:n==null?void 0:n.from,to:n==null?void 0:n.to};const B=r!==x.value?r:(n==null?void 0:n.from)!==x.from?n==null?void 0:n.from:(n==null?void 0:n.to)!==x.to?n==null?void 0:n.to:void 0,T=B?U(B):null;T&&w(P=>P.getFullYear()===T.getFullYear()&&P.getMonth()===T.getMonth()?P:new Date(T.getFullYear(),T.getMonth(),1))},[r,n==null?void 0:n.from,n==null?void 0:n.to]);const C=G(new Date),D=M.getFullYear(),F=M.getMonth(),Z=u.useMemo(()=>{const x=new Intl.DateTimeFormat(g,{weekday:"short"});return Array.from({length:7},(B,T)=>x.format(new Date(2023,0,1+(T+f)%7)))},[g,f]),le=new Intl.DateTimeFormat(g,{month:"long",year:"numeric"}).format(M),z=u.useMemo(()=>{const x=(new Date(D,F,1).getDay()-f+7)%7;return Array.from({length:42},(B,T)=>{const P=new Date(D,F,1-x+T);return{iso:Pt(P.getFullYear(),P.getMonth(),P.getDate()),day:P.getDate(),outside:P.getMonth()!==F}})},[D,F,f]),W=x=>!!d&&x<d||!!c&&x>c,ie=x=>w(new Date(D,F+x,1)),Pe=x=>{const B=U(x);B&&((B.getFullYear()!==D||B.getMonth()!==F)&&w(new Date(B.getFullYear(),B.getMonth(),1)),_(x),requestAnimationFrame(()=>{var T,P;return(P=(T=E.current)==null?void 0:T.querySelector(`[data-iso="${x}"]`))==null?void 0:P.focus()}))},De=(x,B)=>{const T=U(B),P=ne=>{x.preventDefault(),Pe(Pt(T.getFullYear(),T.getMonth(),T.getDate()+ne))};switch(x.key){case"ArrowLeft":return P(-1);case"ArrowRight":return P(1);case"ArrowUp":return P(-7);case"ArrowDown":return P(7);case"Home":return P(-((T.getDay()-f+7)%7));case"End":return P(6-(T.getDay()-f+7)%7);case"PageUp":case"PageDown":{x.preventDefault();const ne=x.key==="PageUp"?-1:1,ae=new Date(T.getFullYear(),T.getMonth()+ne+1,0).getDate();Pe(Pt(T.getFullYear(),T.getMonth()+ne,Math.min(T.getDate(),ae)));return}}},ft=x=>!!x&&z.some(B=>B.iso===x&&!B.outside),gt=[v,r,C].find(x=>ft(x)&&!W(x))??((Ae=z.find(x=>!x.outside&&!W(x.iso)))==null?void 0:Ae.iso),ee=n==null?void 0:n.from,K=n==null?void 0:n.to;return i.jsxs("div",{className:$("rg-cal",S),onMouseDown:y?x=>x.preventDefault():void 0,role:"group","aria-label":`Calendar, ${le}`,children:[i.jsxs("div",{className:"rg-cal__head",children:[i.jsx("button",{type:"button",className:"rg-cal__nav","aria-label":"Previous year",onClick:()=>ie(-12),children:"«"}),i.jsx("button",{type:"button",className:"rg-cal__nav","aria-label":"Previous month",onClick:()=>ie(-1),children:"‹"}),i.jsx("span",{className:"rg-cal__title","aria-live":"polite",children:le}),i.jsx("button",{type:"button",className:"rg-cal__nav","aria-label":"Next month",onClick:()=>ie(1),children:"›"}),i.jsx("button",{type:"button",className:"rg-cal__nav","aria-label":"Next year",onClick:()=>ie(12),children:"»"})]}),i.jsxs("div",{className:"rg-cal__grid",ref:E,children:[Z.map(x=>i.jsx("span",{className:"rg-cal__dow","aria-hidden":"true",children:x.slice(0,2)},x)),z.map(({iso:x,day:B,outside:T})=>{const P=x===r,ne=x===ee,ae=x===K,ht=!!ee&&!!K&&x>ee&&x<K;return i.jsx("button",{type:"button","data-iso":x,tabIndex:x===gt?0:-1,disabled:W(x),"aria-pressed":P||ne||ae,"aria-label":new Intl.DateTimeFormat(g,{dateStyle:"full"}).format(U(x)),className:$("rg-cal__day",T&&"rg-cal__day--outside",x===C&&"rg-cal__day--today",(P||ne||ae)&&"rg-cal__day--selected",ht&&"rg-cal__day--in-range",ee&&K&&ne&&ee!==K&&"rg-cal__day--range-start",ee&&K&&ae&&ee!==K&&"rg-cal__day--range-end"),onClick:()=>h(x),onKeyDown:Oe=>De(Oe,x),onFocus:()=>_(x),children:B},x)})]}),!j&&i.jsxs("div",{className:"rg-cal__foot",children:[i.jsx("button",{type:"button",className:"rg-cal__link",disabled:W(C),onClick:()=>{w(Dr(C)),h(C)},children:"Today"}),i.jsx("button",{type:"button",className:"rg-cal__link",onClick:()=>h(""),children:"Clear"})]})]})}const Ot=typeof window<"u"?u.useLayoutEffect:u.useEffect;function Le(r,n,d){const[c,h]=u.useState(n),g=r!==void 0,f=g?r:c,j=u.useCallback(y=>{g||h(y),d==null||d(y)},[g,d]);return[f,j]}function Tr(r,n){const d=u.useRef(r);d.current=r;const c=u.useRef(void 0),h=u.useRef(null),g=u.useCallback(()=>{c.current!==void 0&&clearTimeout(c.current),c.current=void 0,h.current=null},[]),f=u.useCallback(()=>{c.current!==void 0&&clearTimeout(c.current),c.current=void 0;const y=h.current;h.current=null,y&&d.current(...y)},[]),j=u.useCallback((...y)=>{if(n<=0){g(),d.current(...y);return}h.current=y,c.current!==void 0&&clearTimeout(c.current),c.current=setTimeout(f,n)},[n,g,f]);return u.useEffect(()=>f,[f]),{call:j,flush:f,cancel:g}}function Yt({anchorRef:r,open:n,onClose:d,label:c,theme:h,className:g,style:f,keepFocus:j,children:y}){const S=u.useRef(null),[M,w]=u.useState({top:0,left:0}),v=u.useCallback(()=>{var D;const _=r.current;if(!_)return;const E=_.getBoundingClientRect(),I=((D=S.current)==null?void 0:D.offsetWidth)??260,C=Math.max(8,Math.min(E.left,window.innerWidth-I-8));w({top:E.bottom+6,left:C})},[r]);return Ot(()=>{n&&v()},[n,v]),u.useEffect(()=>{if(!n)return;const _=I=>{var D,F;const C=I.target;(D=S.current)!=null&&D.contains(C)||(F=r.current)!=null&&F.contains(C)||d()},E=I=>{var C;I.key==="Escape"&&(d(),(C=r.current)==null||C.focus())};return document.addEventListener("mousedown",_),document.addEventListener("keydown",E),window.addEventListener("resize",v),window.addEventListener("scroll",v,!0),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",E),window.removeEventListener("resize",v),window.removeEventListener("scroll",v,!0)}},[n,d,v,r]),!n||typeof document>"u"?null:Cn.createPortal(i.jsx("div",{ref:S,role:"dialog",onMouseDown:j?_=>_.preventDefault():void 0,"aria-label":c,"data-rg-theme":h||void 0,className:$("rg-grid-popup",g),style:{position:"fixed",top:M.top,left:M.left,...f},children:y}),document.body)}function $n({value:r,onChange:n,onPick:d,onBlur:c,onKeyDown:h,min:g,max:f,locale:j,invalid:y,label:S,theme:M,className:w,style:v}){const _=u.useRef(null);return i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:_,autoFocus:!0,type:"text",inputMode:"numeric",placeholder:"YYYY-MM-DD",autoComplete:"off",className:w,style:v,value:r,"aria-label":S,"aria-invalid":y||void 0,"aria-haspopup":"dialog","aria-expanded":!0,onChange:E=>n(E.target.value.trim()),onBlur:c,onKeyDown:h,onFocus:E=>E.currentTarget.setSelectionRange(E.currentTarget.value.length,E.currentTarget.value.length)}),i.jsx(Yt,{anchorRef:_,open:!0,onClose:()=>{},label:S,theme:M,className:"rg-date-popup",keepFocus:!0,children:i.jsx(Fr,{value:r,min:g,max:f,locale:j,onPick:d,keepFocus:!0})})]})}function Nr(r){return r.filterType?r.filterType:r.type==="number"?"number":r.type==="date"?"date":r.type==="boolean"?"select":"text"}const Pn=r=>typeof r=="object"&&r!==null&&!Array.isArray(r);function Rr(r){if(r==null)return!1;if(typeof r=="string")return r.trim()!=="";if(Array.isArray(r))return r.length>0;if(Pn(r)){const n=r;return typeof n.min=="number"||typeof n.max=="number"||!!n.from||!!n.to}return!1}function An(r,n,d,c){switch(r){case"text":return d.toLowerCase().includes(String(n).trim().toLowerCase());case"exact":return d.toLowerCase()===String(n).trim().toLowerCase();case"number":{const{min:h,max:g}=n,f=typeof c=="number"?c:c==null||c===""?NaN:Number(c);return Number.isNaN(f)?!1:(typeof h!="number"||f>=h)&&(typeof g!="number"||f<=g)}case"date":{const{from:h,to:g}=n,f=G(c);return f?(!h||f>=h)&&(!g||f<=g):!1}case"select":return n.includes(String(c??""))}}function On(r,n,d,c){if(r.filterOptions)return r.filterOptions.map(g=>typeof g=="string"?{value:g,label:g}:g);if(r.type==="boolean")return[{value:"true",label:"Yes"},{value:"false",label:"No"}];const h=new Map;for(const g of n){const f=d(g);if(f==null||f==="")continue;const j=String(f);h.has(j)||h.set(j,c(g))}return[...h].map(([g,f])=>({value:g,label:f})).sort((g,f)=>g.label.localeCompare(f.label,void 0,{numeric:!0}))}const Er=r=>{if(r.trim()==="")return;const n=Number(r);return Number.isFinite(n)?n:void 0},Ir=r=>typeof r=="object"&&r!==null&&!Array.isArray(r);function Kn({value:r,onChange:n,label:d,debounce:c,inputClassName:h,inputStyle:g}){const f=Ir(r)?r:{},[j,y]=u.useState(f.min===void 0?"":String(f.min)),[S,M]=u.useState(f.max===void 0?"":String(f.max)),w=u.useRef(f),v=Tr((_,E)=>{const I=Er(_),C=Er(E);w.current={min:I,max:C},n(I===void 0&&C===void 0?void 0:{min:I,max:C})},c);return u.useEffect(()=>{f.min===w.current.min&&f.max===w.current.max||(w.current=f,v.cancel(),y(f.min===void 0?"":String(f.min)),M(f.max===void 0?"":String(f.max)))},[f.min,f.max]),i.jsxs("div",{className:"rg-grid__filter-fields",children:[i.jsxs("label",{className:"rg-grid__filter-field",children:[i.jsx("span",{children:"Min"}),i.jsx("input",{autoFocus:!0,type:"number",className:$("rg-grid__filter-input",h),style:g,value:j,"aria-label":`Minimum ${d}`,onChange:_=>{y(_.target.value),v.call(_.target.value,S)},onKeyDown:_=>_.key==="Enter"&&v.flush()})]}),i.jsxs("label",{className:"rg-grid__filter-field",children:[i.jsx("span",{children:"Max"}),i.jsx("input",{type:"number",className:$("rg-grid__filter-input",h),style:g,value:S,"aria-label":`Maximum ${d}`,onChange:_=>{M(_.target.value),v.call(j,_.target.value)},onKeyDown:_=>_.key==="Enter"&&v.flush()})]})]})}function Bn({value:r,onChange:n,onEnter:d,label:c,kind:h,placeholder:g,debounce:f,inputClassName:j,inputStyle:y}){const[S,M]=u.useState(r),w=u.useRef(r),v=Tr(_=>{w.current=_,n(_||void 0)},f);return u.useEffect(()=>{r!==w.current&&(w.current=r,v.cancel(),M(r))},[r]),i.jsx("input",{autoFocus:!0,type:"text",className:$("rg-grid__filter-input",j),style:y,value:S,placeholder:g??(h==="exact"?"Exactly…":`Filter ${c}…`),"aria-label":`Filter text for ${c}`,onChange:_=>{M(_.target.value),v.call(_.target.value)},onKeyDown:_=>{_.key==="Enter"&&(_.preventDefault(),v.flush(),d())}})}function Yn({value:r,onChange:n,label:d,inputClassName:c,inputStyle:h,min:g,max:f,locale:j}){const y=Ir(r)?r:{},S=(D,F)=>n(!D&&!F?void 0:{from:D||void 0,to:F||void 0}),[M,w]=u.useState(y.from??""),[v,_]=u.useState(y.to??"");u.useEffect(()=>{(U(M)?M:"")!==(y.from??"")&&w(y.from??""),(U(v)?v:"")!==(y.to??"")&&_(y.to??"")},[y.from,y.to]);const E=(D,F)=>{if((D==="from"?w:_)(F),F!==""&&!U(F))return;const Z=F||void 0;D==="from"?S(Z,y.to):S(y.from,Z)},I=D=>{D&&(!y.from||y.to?S(D,void 0):D<y.from?S(D,y.from):S(y.from,D))},C=(D,F,Z)=>i.jsxs("label",{className:"rg-grid__filter-field",children:[i.jsx("span",{children:D==="from"?"From":"To"}),i.jsx("input",{autoFocus:Z,type:"text",inputMode:"numeric",placeholder:"YYYY-MM-DD",className:$("rg-grid__filter-input",F!==""&&!U(F)&&"rg-grid__filter-input--invalid",c),style:h,value:F,"aria-label":`${d} ${D}`,"aria-invalid":F!==""&&!U(F)||void 0,onChange:le=>E(D,le.target.value.trim())})]});return i.jsxs("div",{className:"rg-grid__filter-fields rg-grid__filter-fields--stack",children:[i.jsxs("div",{className:"rg-grid__filter-date-row",children:[C("from",M,!0),C("to",v,!1)]}),i.jsx(Fr,{range:y,min:g,max:f,locale:j,onPick:I,hideFooter:!0})]})}function Wn({value:r,onChange:n,options:d}){const c=Array.isArray(r)?r:[],h=(g,f)=>{const j=f?[...c,g]:c.filter(y=>y!==g);n(j.length?j:void 0)};return i.jsxs("div",{className:"rg-grid__filter-fields rg-grid__filter-options",role:"group",children:[d.length===0&&i.jsx("span",{className:"rg-grid__filter-empty",children:"No values"}),d.map(g=>i.jsx(xe,{checked:c.includes(g.value),onChange:f=>h(g.value,f),label:g.label??g.value},g.value))]})}function qn({column:r,label:n,kind:d,value:c,onChange:h,options:g,debounce:f=300,theme:j,indicatorClassName:y,indicatorStyle:S,popupClassName:M,popupStyle:w,inputClassName:v,inputStyle:_}){const[E,I]=u.useState(!1),C=u.useRef(null),D=Rr(c),F=u.useCallback(()=>I(!1),[]),Z=typeof c=="string"?c:"",le=()=>{if(r.filterRenderer)return u.createElement(r.filterRenderer,{column:r,value:Z,onChange:z=>h(z||void 0)});switch(d){case"number":return i.jsx(Kn,{value:c,onChange:h,label:n,debounce:f,inputClassName:v,inputStyle:_});case"date":return i.jsx(Yn,{value:c,onChange:h,label:n,min:r.dateMin,max:r.dateMax,locale:r.dateLocale,inputClassName:v,inputStyle:_});case"select":return i.jsx(Wn,{value:c,onChange:h,options:g});default:return i.jsx(Bn,{value:Z,onChange:h,onEnter:()=>{var z;I(!1),(z=C.current)==null||z.focus()},label:n,kind:d,placeholder:r.filterPlaceholder,debounce:f,inputClassName:v,inputStyle:_})}};return i.jsxs(i.Fragment,{children:[i.jsx("button",{ref:C,type:"button",className:$("rg-grid__filter-btn",D&&"rg-grid__filter-btn--active",E&&"rg-grid__filter-btn--open",y),style:S,"aria-label":`Filter ${n}`,"aria-haspopup":"dialog","aria-expanded":E,"data-active":D||void 0,onClick:z=>{z.stopPropagation(),I(W=>!W)},onKeyDown:z=>z.stopPropagation(),children:r.filterIndicator?u.createElement(r.filterIndicator,{column:r,active:D,open:E}):i.jsx("span",{className:"rg-grid__filter-dot","aria-hidden":"true"})}),i.jsxs(Yt,{anchorRef:C,open:E,onClose:F,label:`Filter ${n}`,theme:j,className:M,style:w,children:[le(),D&&i.jsx("button",{type:"button",className:"rg-grid__filter-clear",onClick:()=>h(void 0),children:"Clear"})]})]})}function Vn({columns:r,hidden:n,onToggle:d,theme:c,className:h,style:g}){const[f,j]=u.useState(!1),y=u.useRef(null),S=u.useCallback(()=>j(!1),[]),M=r.filter(w=>!n.has(w.field)).length;return i.jsxs(i.Fragment,{children:[i.jsx("button",{ref:y,type:"button",className:$("rg-grid__tool-btn",h),style:g,"aria-haspopup":"dialog","aria-expanded":f,onClick:()=>j(w=>!w),children:"Columns"}),i.jsx(Yt,{anchorRef:y,open:f,onClose:S,label:"Show or hide columns",theme:c,children:i.jsx("div",{className:"rg-grid__filter-fields rg-grid__filter-options",role:"group","aria-label":"Columns",children:r.filter(w=>w.hideable!==!1).map(w=>{const v=!n.has(w.field);return i.jsx(xe,{checked:v,disabled:v&&M<=1,onChange:_=>d(w.field,!_),label:be(w)},w.field)})})})]})}const Un=/^[=+\-@\t\r]/;function zn(r,n,d){if(r==null)return"";let c=String(r);return d&&typeof r=="string"&&Un.test(c)&&!Number.isFinite(Number(c))&&(c=`'${c}`),c.includes(n)||/["\r\n]/.test(c)?`"${c.replace(/"/g,'""')}"`:c}function Hn(r,n,d={}){const{delimiter:c=",",sanitize:h=!0}=d,g=f=>f.map(j=>zn(j,c,h)).join(c);return[g(r),...n.map(g)].join(`\r
2
+ `)}function Jn(r,n){if(typeof document>"u")return;const d=new Blob(["\uFEFF",r],{type:"text/csv;charset=utf-8"}),c=URL.createObjectURL(d),h=document.createElement("a");h.href=c,h.download=n,h.style.display="none",document.body.appendChild(h),h.click(),h.remove(),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const Kt=new Set(["__proto__","prototype","constructor"]),Lr=(r,n)=>Object.prototype.hasOwnProperty.call(r,n);function Q(r,n){if(r===null||typeof r!="object")return;if(Lr(r,n))return r[n];let d=r;for(const c of n.split(".")){if(d==null||typeof d!="object"||Kt.has(c))return;d=d[c]}return d}function Sr(r,n,d){if(Array.isArray(r)){const c=[...r];return c[n]=d,c}return{...r,[n]:d}}function Bt(r,n,d){const c=r??{};if(Lr(c,n)||!n.includes("."))return Kt.has(n)?r:Sr(c,n,d);const[h,...g]=n.split(".");if(Kt.has(h))return r;const f=c[h];return Sr(c,h,Bt(f!==null&&typeof f=="object"?f:{},g.join("."),d))}const ge=38,Gn=150,Mr=10,At=(r,n)=>`${typeof r}:${r}\0${n}`;function $e(r,n){const d=Q(n,r.field);return r.valueFormatter?r.valueFormatter(d,n):r.type==="boolean"&&typeof d=="boolean"?d?"Yes":"No":r.type==="date"?In(d,r.dateLocale,r.dateFormat):d==null?"":d instanceof Date?d.toLocaleDateString():String(d)}function Xn(r,n,d){if(d.type==="date"){const c=G(r)??"",h=G(n)??"";return c<h?-1:c>h?1:0}return typeof r=="number"&&typeof n=="number"?r-n:r instanceof Date&&n instanceof Date?r.getTime()-n.getTime():typeof r=="boolean"&&typeof n=="boolean"?Number(r)-Number(n):String(r).localeCompare(String(n),void 0,{numeric:!0,sensitivity:"base"})}const Qn=r=>r?Array.isArray(r)?r:[r]:[],Cr=r=>r.type==="date"&&r.validity.badInput;function Zn({columns:r,rows:n,getRowId:d,editable:c=!1,enterMovesDown:h=!0,onCellEdit:g,onRowsChange:f,rowSelection:j=!1,selectedRowIds:y,defaultSelectedRowIds:S,onSelectionChange:M,isRowSelectable:w,sort:v,defaultSort:_=null,onSortChange:E,multiSort:I=!1,searchable:C=!1,searchPlaceholder:D="Search…",search:F,onSearchChange:Z,filters:le,onFiltersChange:z,pagination:W=!1,paginationPosition:ie="bottom",pageSize:Pe=10,pageSizeOptions:De=[5,10,25,50],page:ft,onPageChange:gt,onPageSizeChange:ee,serverSide:K=!1,rowCount:Ae,onQueryChange:x,queryDebounce:B=250,filterDebounce:T=300,loading:P,loadingRows:ne,skeletonRow:ae,errorMessage:ht="Could not load the data.",columnMenu:Oe=!1,onColumnVisibilityChange:pt,keyboardNavigation:mt=!1,virtualize:te=!1,rowHeight:se=40,overscan:Wt=6,exportable:Ke=!1,apiRef:Ne,onRowClick:bt,toolbar:qt,emptyMessage:$r="No rows to show",striped:Pr=!1,stripeColors:Be,checkboxVariant:xt="native",animateRows:Vt=!0,rowAnimationClassName:_t,theme:Ye,maxHeight:We,className:Ar,style:Or,classNames:A={},styles:R={},rowClassName:yt,rowStyle:vt}){const Y=(e,t)=>({className:$(t,A[e]),style:R[e]}),[qe,Ut]=u.useState(n),_e=u.useRef(n);u.useEffect(()=>{_e.current=n,Ut(n)},[n]);const zt=e=>{_e.current=e,Ut(e)},[Ee,Kr]=Le(F,"",Z),[ye,Br]=Le(le,{},z),[H,Yr]=Le(v,Qn(_),E),[kt,ve]=Le(ft,0,gt),[q,Wr]=u.useState(Pe),qr=e=>{Wr(e),ee==null||ee(e)},[Ve,Vr]=u.useState(()=>new Set(r.filter(e=>e.hidden).map(e=>e.field))),Ur=(e,t)=>{const o=new Set(Ve);t?o.add(e):o.delete(e),Vr(o),pt==null||pt([...o])},[jt,Ht]=u.useState({}),[Ue,zr]=u.useState({}),[eo,Hr]=u.useState(0),Se=u.useRef(new Map),[Me,he]=u.useState(null),ce=u.useRef(0),ze=u.useRef(null),He=u.useRef(new Map),[wt,Jt]=u.useState(null),Dt=u.useRef(null),Ce=u.useRef(null),[Nt,Gt]=u.useState({top:0,height:0}),N=u.useMemo(()=>{const e=r.filter(t=>!Ve.has(t.field)).map(t=>t.type==="sequence"?{...t,sortable:!1,filterable:!1,editable:!1,filterRenderer:void 0}:t);return[...e.filter(t=>t.pinned==="left"),...e.filter(t=>t.pinned!=="left"&&t.pinned!=="right"),...e.filter(t=>t.pinned==="right")]},[r,Ve]),Et=e=>e.sortable===!0,J=j==="single"?"single":j?"multiple":null,Fe=N.length+(J?1:0),ke=u.useMemo(()=>qe.map((e,t)=>({row:e,index:t,id:d?d(e,t):t})),[qe,d]),Xt=u.useRef(new Map);ke.forEach(e=>Xt.current.set(e.id,e.row));const Je=u.useMemo(()=>Object.entries(ye).filter(([e,t])=>{const o=N.find(a=>a.field===e);return!!o&&!!o.filterable&&Rr(t)}),[ye,N]),[Jr,Gr]=u.useState(Ee);u.useEffect(()=>{if(!K)return;const e=setTimeout(()=>Gr(Ee),B);return()=>clearTimeout(e)},[Ee,K,B]);const je=K?Jr:Ee,Qt=e=>e.filterRenderer?"text":Nr(e),de=u.useMemo(()=>{if(K)return ke;const e=je.trim().toLowerCase();let t=ke.filter(({row:a})=>e&&!N.some(s=>$e(s,a).toLowerCase().includes(e))?!1:Je.every(([s,l])=>{const b=N.find(m=>m.field===s);return An(Qt(b),l,$e(b,a),Q(a,s))}));const o=H.map(a=>({col:N.find(s=>s.field===a.field),dir:a.direction==="asc"?1:-1})).filter(a=>!!a.col);return o.length&&(t=[...t].sort((a,s)=>{for(const{col:l,dir:b}of o){const m=Q(a.row,l.field),k=Q(s.row,l.field),p=m==null||m==="",O=k==null||k==="";if(p||O){if(p!==O)return p?1:-1;continue}const X=l.comparator?l.comparator(m,k,a.row,s.row):Xn(m,k,l);if(X!==0)return X*b}return 0})),t},[ke,N,je,Je,H,K]),Ge=JSON.stringify([je,ye,H,q]),Zt=u.useRef(Ge);u.useEffect(()=>{Zt.current!==Ge&&(Zt.current=Ge,ve(0))},[Ge]);const we=K?Ae??ke.length:de.length,ue=W?Math.max(1,Math.ceil(we/q)):1,V=Math.min(kt,ue-1),L=W&&!K?de.slice(V*q,V*q+q):de,Xr=we===0?0:W?V*q+1:1,Qr=W?Math.min(we,(V+1)*q):we,St=u.useMemo(()=>({sort:H.filter(e=>{const t=r.find(o=>o.field===e.field);return!!t&&Et(t)}),filters:Object.fromEntries(Je),search:je.trim(),page:V,pageSize:q}),[H,r,Je,je,V,q]),Zr=JSON.stringify(St),Xe=u.useRef(St);Xe.current=St;const Qe=u.useRef(x);Qe.current=x;const[en,Ze]=u.useState(!1),[tn,Mt]=u.useState(!1),Ct=u.useRef(0),et=u.useCallback(e=>{var a;const t=++Ct.current,o=(a=Qe.current)==null?void 0:a.call(Qe,e);o&&typeof o.then=="function"?(Ze(!0),Mt(!1),o.then(()=>{t===Ct.current&&Ze(!1)},()=>{t===Ct.current&&(Ze(!1),Mt(!0))})):(Ze(!1),Mt(!1))},[]);u.useEffect(()=>{K&&et(Xe.current)},[K,Zr,et]),u.useEffect(()=>{K&&W&&kt>ue-1&&ve(ue-1)},[K,W,kt,ue]);const Ft=P??en,er=e=>e.map(t=>Xt.current.get(t)).filter(t=>t!==void 0),[oe,tt]=Le(y,S??[],e=>M==null?void 0:M({ids:e,rows:er(e)})),Tt=u.useMemo(()=>new Set(oe),[oe]),rt=e=>w?w(e):!0,nt=u.useRef(null),tr=u.useRef(!1),rn=(e,t)=>{if(!J||!rt(e.row))return;if(J==="single"){tt(t?[e.id]:[]),nt.current=e.id;return}const o=new Set(oe),a=tr.current&&nt.current!==null?L.findIndex(l=>l.id===nt.current):-1,s=L.findIndex(l=>l.id===e.id);if(a>=0&&s>=0)for(let l=Math.min(a,s);l<=Math.max(a,s);l++)rt(L[l].row)&&(t?o.add(L[l].id):o.delete(L[l].id));else t?o.add(e.id):o.delete(e.id);nt.current=e.id,tt([...o])},Te=u.useMemo(()=>de.filter(e=>rt(e.row)),[de,w]),rr=Te.filter(e=>Tt.has(e.id)).length,nr=Te.length>0&&rr===Te.length,or=e=>{const t=new Set(oe);Te.forEach(o=>e?t.add(o.id):t.delete(o.id)),tt([...t])},ot=(e,t,o)=>({value:Q(t,e.field),formattedValue:$e(e,t),row:t,rowIndex:o,field:e.field,column:e}),Rt=(e,t)=>{const o=e.editable??c;return typeof o=="function"?o(t):!!o},it=(e,t)=>Rt(e,t)&&!(e.type==="boolean"&&!e.cellEditor),nn=(e,t)=>{const o=ot(e,t.row,t.index),a=Rt(e,o);return{...o,editable:a,updateValue:s=>a&&sr(t,e,{value:s})}},ir=(e,t)=>{if(!Et(e))return;const o=H.find(l=>l.field===e.field),a=o?o.direction==="asc"?"desc":null:"asc";let s;t&&I?a?o?s=H.map(l=>l.field===e.field?{...l,direction:a}:l):s=[...H,{field:e.field,direction:a}]:s=H.filter(l=>l.field!==e.field):s=a?[{field:e.field,direction:a}]:[],Yr(s)},st=(e,t)=>{var o;return(o=He.current.get(At(e,t)))==null?void 0:o.focus()},fe=()=>{ce.current+=1,he(null)},on=e=>{for(const t of _e.current){const o=Q(t,e.field);if(o!=null&&o!=="")return o}},lt=(e,t,o={})=>{if(!it(t,ot(t,e.row,e.index)))return!1;const a=Q(e.row,t.field);let s;return t.cellEditor?s=a:t.type==="date"?s=G(a)??"":s=o.text??(a==null?"":String(a)),ze.current=s,ce.current+=1,he({id:e.id,field:t.field,draft:s,session:ce.current,select:o.select??"end",invalid:!1}),!0},sr=(e,t,o)=>{const a=_e.current[e.index]??e.row,s=Q(a,t.field);let l;if("value"in o)l=o.value;else if(t.valueParser)l=t.valueParser(o.text,a);else if(t.type==="date"){if(o.text!==""&&!U(o.text))return!1;l=Ln(o.text,s??on(t))}else if(t.type==="number")if(o.text.trim()==="")l=null;else{const k=Number(o.text);if(!Number.isFinite(k))return!1;l=k}else l=o.text;if(t.type==="date"){if(G(l)===G(s))return!0;const k=G(l);if(k&&(t.dateMin&&k<t.dateMin||t.dateMax&&k>t.dateMax))return!1}else if(Object.is(l,s))return!0;if(t.validate&&!t.validate(l,a))return!1;const b=Bt(a,t.field,l),m=_e.current.map((k,p)=>p===e.index?b:k);return zt(m),g==null||g({rowId:e.id,rowIndex:e.index,field:t.field,oldValue:s,newValue:l,row:b}),f==null||f(m),!0},lr=(e,t,o)=>{const a=L.findIndex(p=>p.id===e.id),s=N.findIndex(p=>p.field===t);if(a<0||s<0)return null;const l=(p,O)=>it(O,ot(O,p.row,p.index));if(o==="down"||o==="up"){const p=o==="down"?1:-1;for(let O=a+p;O>=0&&O<L.length;O+=p)if(l(L[O],N[s]))return{entry:L[O],col:N[s]};return null}const b=o==="right"?1:-1;let m=a,k=s+b;for(;m>=0&&m<L.length;){for(;k>=0&&k<N.length;){if(l(L[m],N[k]))return{entry:L[m],col:N[k]};k+=b}m+=b,k=b>0?0:N.length-1}return null},pe=(e,t,o,a={})=>{const{move:s="none",focus:l=!0}=a;if(!sr(e,t,o))return he(m=>m&&{...m,invalid:!0}),!1;const b=s==="none"?null:lr(e,t.field,s);return b?lt(b.entry,b.col,{select:"all"}):(fe(),l&&st(e.id,t.field)),!0},ar=(e,t,o)=>{if(e.nativeEvent.isComposing)return;const a=e.currentTarget.value,s=Cr(e.currentTarget);if(e.key==="Enter"){if(e.preventDefault(),s)return he(b=>b&&{...b,invalid:!0});const l=h?e.shiftKey?"up":"down":"none";pe(t,o,{text:a},{move:l})}else if(e.key==="Escape")e.preventDefault(),fe(),st(t.id,o.field);else if(e.key==="Tab"&&!s){const l=e.shiftKey?"left":"right";lr(t,o.field,l)&&(e.preventDefault(),pe(t,o,{text:a},{move:l}))}},sn=(e,t)=>{var l;const o=L[e],a=N[t];if(!o||!a)return;Jt({id:o.id,field:a.field}),Dt.current=At(o.id,a.field);const s=Ce.current;if(te&&s){const b=((l=s.querySelector("thead"))==null?void 0:l.clientHeight)??0,m=e*se;m<s.scrollTop?s.scrollTo({top:m,behavior:"auto"}):m+se>s.scrollTop+s.clientHeight-b&&s.scrollTo({top:m+se-s.clientHeight+b,behavior:"auto"})}};u.useEffect(()=>{const e=Dt.current;if(!e)return;const t=He.current.get(e);t&&(Dt.current=null,t.focus())});const ln=(e,t,o)=>{if(!mt)return!1;let a=L.findIndex(l=>l.id===t.id),s=N.findIndex(l=>l.field===o.field);if(a<0||s<0)return!1;switch(e.key){case"ArrowDown":a+=1;break;case"ArrowUp":a-=1;break;case"ArrowRight":s+=1;break;case"ArrowLeft":s-=1;break;case"PageDown":a+=Mr;break;case"PageUp":a-=Mr;break;case"Home":s=0,(e.ctrlKey||e.metaKey)&&(a=0);break;case"End":s=N.length-1,(e.ctrlKey||e.metaKey)&&(a=L.length-1);break;default:return!1}return e.preventDefault(),sn(Math.max(0,Math.min(L.length-1,a)),Math.max(0,Math.min(N.length-1,s))),!0},an=(e,t,o,a)=>{e.target===e.currentTarget&&(ln(e,t,o)||it(o,a)&&(e.key==="Enter"||e.key==="F2"?(e.preventDefault(),lt(t,o)):!o.cellEditor&&o.type!=="date"&&e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.preventDefault(),lt(t,o,{text:e.key}))))};Ot(()=>{if(!te||!Ce.current)return;const e=Ce.current,t=()=>Gt(a=>a.height===e.clientHeight?a:{...a,height:e.clientHeight});if(t(),typeof ResizeObserver>"u")return;const o=new ResizeObserver(t);return o.observe(e),()=>o.disconnect()},[te]);const Re=te&&!Ft&&L.length>0,cn=Nt.height||(typeof We=="number"?We:400),at=Re?Math.max(0,Math.floor(Nt.top/se)-Wt):0,It=Re?Math.min(L.length,Math.ceil((Nt.top+cn)/se)+Wt):L.length,dn=Re?L.slice(at,It):L,cr=`${V}|${q}|${JSON.stringify(H)}|${je}|${JSON.stringify(ye)}`,dr=u.useRef(!0);u.useEffect(()=>{if(dr.current){dr.current=!1;return}const e=Ce.current;e&&typeof e.scrollTo=="function"&&e.scrollTop>0&&e.scrollTo({top:0,behavior:"smooth"})},[cr]);const Lt=Object.keys(jt).length>0,ct=e=>jt[e.field]??(typeof e.width=="number"?e.width:Gn),un=e=>Math.max(40,typeof e.minWidth=="number"?e.minWidth:60),fn=(e,t)=>{e.preventDefault(),e.stopPropagation();const o={...jt};Lt||N.forEach(p=>{var O;return o[p.field]=((O=Se.current.get(p.field))==null?void 0:O.offsetWidth)??ct(p)});const a=e.clientX,s=o[t.field]??ct(t),l=e.currentTarget;l.setPointerCapture(e.pointerId),Ht(o);const b=p=>Math.min(t.maxWidth??1/0,Math.max(un(t),Math.round(p))),m=p=>Ht(O=>({...O,[t.field]:b(s+p.clientX-a)})),k=()=>{l.removeEventListener("pointermove",m),l.removeEventListener("pointerup",k),l.removeEventListener("pointercancel",k)};l.addEventListener("pointermove",m),l.addEventListener("pointerup",k),l.addEventListener("pointercancel",k)};Ot(()=>{var s,l;const e={};let t=J&&N.some(b=>b.pinned==="left")?ge:0;for(const b of N)b.pinned==="left"&&(e[b.field]=t,t+=((s=Se.current.get(b.field))==null?void 0:s.offsetWidth)??0);let o=0;for(const b of[...N].reverse())b.pinned==="right"&&(e[b.field]=o,o+=((l=Se.current.get(b.field))==null?void 0:l.offsetWidth)??0);const a=Object.keys(e);(a.length!==Object.keys(Ue).length||a.some(b=>e[b]!==Ue[b]))&&zr(e)}),u.useEffect(()=>{const e=()=>Hr(t=>t+1);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const ur=N.map(e=>e.pinned).lastIndexOf("left"),gn=N.findIndex(e=>e.pinned==="right"),dt=ur>=0,fr=(e,t)=>({className:e.pinned?$("rg-grid__pinned",`rg-grid__pinned--${e.pinned}`,t===ur&&"rg-grid__pinned--edge",t===gn&&"rg-grid__pinned--edge"):void 0,style:e.pinned==="left"?{left:Ue[e.field]??0}:e.pinned==="right"?{right:Ue[e.field]??0}:void 0}),gr=typeof Ke=="object"?Ke:{},hr=(e={})=>{const t={...gr,...e},o=t.scope??"filtered",a=o==="page"?L:o==="selected"?ke.filter(m=>Tt.has(m.id)):de,s=t.includeHidden?r:N,l=s.map(m=>ut(m)||m.field),b=a.map(({row:m},k)=>s.map(p=>{if(p.type==="sequence")return _r(p,k,o==="page"&&W&&!p.sequenceRestartEachPage?V*q:0);const O=Q(m,p.field);return p.exportValue?p.exportValue(O,m):p.type==="date"?G(O)??"":$e(p,m)}));return Hn(l,b,{sanitize:t.sanitize})},pr=(e={})=>{const t={...gr,...e};Jn(hr(e),`${t.filename??"export"}.csv`)};u.useEffect(()=>{Ne&&(Ne.current={getCsv:hr,exportCsv:pr,getSelectedRows:()=>er(oe),getSelectedRowIds:()=>oe,selectAll:()=>or(!0),clearSelection:()=>tt([]),refresh:()=>{K&&et(Xe.current)}})}),u.useEffect(()=>()=>{Ne&&(Ne.current=null)},[Ne]);const mr=e=>{var o,a,s,l,b,m,k,p;const t=e.checkbox??{};return{variant:t.variant??xt,indicator:t.indicator,className:t.className,style:t.style,classNames:{root:$(A.checkbox,(o=t.classNames)==null?void 0:o.root),control:$(A.checkboxControl,(a=t.classNames)==null?void 0:a.control),indicator:$(A.checkboxIndicator,(s=t.classNames)==null?void 0:s.indicator),label:(l=t.classNames)==null?void 0:l.label},styles:{root:{...R.checkbox,...(b=t.styles)==null?void 0:b.root},control:{...R.checkboxControl,...(m=t.styles)==null?void 0:m.control},indicator:{...R.checkboxIndicator,...(k=t.styles)==null?void 0:k.indicator},label:(p=t.styles)==null?void 0:p.label}}},me=e=>e.stopPropagation(),hn=(e,t)=>i.jsx("span",{className:"rg-grid__checkbox-cell",onClick:me,onDoubleClick:me,children:i.jsx(xe,{...mr(e),checked:!!t.value,disabled:!t.editable,"aria-label":`Toggle ${be(e)}`,onChange:o=>t.updateValue(o)})}),br=e=>de.filter(t=>Rt(e,ot(e,t.row,t.index))),pn=(e,t)=>{const o=new Map(br(e).map(l=>[l.index,l])),a=[],s=_e.current.map((l,b)=>{const m=o.get(b);if(!m)return l;const k=Q(l,e.field);if(!!k===t||e.validate&&!e.validate(t,l))return l;const p=Bt(l,e.field,t);return a.push({rowId:m.id,rowIndex:b,field:e.field,oldValue:k,newValue:t,row:p}),p});a.length!==0&&(zt(s),a.forEach(l=>g==null?void 0:g(l)),f==null||f(s))},mn=e=>{const t=br(e),o=t.length>0?t:de,a=o.filter(l=>!!Q(l.row,e.field)).length,s=o.length>0&&a===o.length;return i.jsx("span",{className:"rg-grid__header-checkbox",onClick:me,onDoubleClick:me,children:i.jsx(xe,{...mr(e),checked:s,indeterminate:a>0&&!s,disabled:t.length===0,label:ut(e)||void 0,"aria-label":`Select all ${be(e)}`,onChange:l=>pn(e,l)})})},bn=(e,t,o)=>{if(t.cellEditor)return i.jsx("div",{className:"rg-grid__custom-editor",onBlur:s=>{s.currentTarget.contains(s.relatedTarget)||o.session===ce.current&&(pe(e,t,{value:ze.current},{focus:!1})||fe())},onKeyDown:s=>{s.key==="Escape"&&(s.preventDefault(),s.stopPropagation(),fe(),st(e.id,t.field))},children:u.createElement(t.cellEditor,{value:o.draft,row:e.row,rowIndex:e.index,field:t.field,column:t,onChange:s=>{ze.current=s,he(l=>l&&l.session===o.session?{...l,draft:s,invalid:!1}:l)},onCommit:(s,l="none")=>{o.session===ce.current&&pe(e,t,{value:s===void 0?ze.current:s},{move:l})},onCancel:()=>{fe(),st(e.id,t.field)}})});const a=t.type==="date";return a?i.jsx($n,{value:o.draft===null||o.draft===void 0?"":String(o.draft),label:`Edit ${be(t)}`,invalid:o.invalid,min:t.dateMin,max:t.dateMax,locale:t.dateLocale,theme:Ye,className:$("rg-grid__editor",o.invalid&&"rg-grid__editor--invalid",A.editor),style:{textAlign:t.align,...R.editor},onChange:s=>he(l=>l&&{...l,draft:s,invalid:!1}),onPick:s=>{o.session===ce.current&&pe(e,t,{text:s},{focus:!0})},onBlur:s=>{o.session===ce.current&&(pe(e,t,{text:s.currentTarget.value},{focus:!1})||fe())},onKeyDown:s=>ar(s,e,t)}):i.jsx("input",{autoFocus:!0,type:a?"date":"text",min:a?t.dateMin:void 0,max:a?t.dateMax:void 0,className:$("rg-grid__editor",o.invalid&&"rg-grid__editor--invalid",A.editor),style:{textAlign:t.align,...R.editor},value:o.draft===null||o.draft===void 0?"":String(o.draft),inputMode:t.type==="number"?"decimal":void 0,"aria-label":`Edit ${be(t)}`,"aria-invalid":o.invalid||void 0,onChange:s=>{const l=s.target.value;he(b=>b&&{...b,draft:l,invalid:!1})},onFocus:s=>{const l=s.currentTarget;a||(o.select==="all"?l.select():l.setSelectionRange(l.value.length,l.value.length))},onBlur:s=>{if(o.session===ce.current){if(Cr(s.currentTarget))return fe();pe(e,t,{text:s.currentTarget.value},{focus:!1})||fe()}},onKeyDown:s=>ar(s,e,t)})},xn=u.useMemo(()=>{const e=new Map;for(const t of N)t.filterable&&!t.filterRenderer&&Nr(t)==="select"&&e.set(t.field,On(t,qe,o=>Q(o,t.field),o=>$e(t,o)));return e},[N,qe]),_n=Pr||!!Be,yn=Be?{"--rg-stripe-a":Be[0],"--rg-stripe-b":Be[1]}:void 0,vn=W&&(ie==="top"||ie==="both"),kn=W&&(ie==="bottom"||ie==="both"),jn=C||!!qt||Oe||!!Ke,xr=e=>i.jsxs("div",{className:$("rg-grid__footer",e==="top"&&"rg-grid__footer--top",A.footer),style:R.footer,"data-position":e,children:[i.jsxs("span",{...Y("rowCount","rg-grid__count"),children:[we===0?"0 rows":`${Xr}–${Qr} of ${we}`,J&&oe.length>0?` · ${oe.length} selected`:""]}),i.jsxs("div",{...Y("pagination","rg-grid__pagination"),children:[i.jsxs("label",{className:"rg-grid__page-size-label",children:["Rows per page",i.jsx("select",{value:q,onChange:t=>qr(Number(t.target.value)),...Y("pageSize","rg-grid__page-size"),children:(De.includes(q)?De:[...De,q].sort((t,o)=>t-o)).map(t=>i.jsx("option",{value:t,children:t},t))})]}),i.jsx("button",{type:"button","aria-label":"First page",disabled:V===0,onClick:()=>ve(0),...Y("pageButton","rg-grid__page-btn"),children:"«"}),i.jsx("button",{type:"button","aria-label":"Previous page",disabled:V===0,onClick:()=>ve(V-1),...Y("pageButton","rg-grid__page-btn"),children:"‹"}),i.jsxs("span",{...Y("pageInfo","rg-grid__page-info"),children:["Page ",V+1," of ",ue]}),i.jsx("button",{type:"button","aria-label":"Next page",disabled:V>=ue-1,onClick:()=>ve(V+1),...Y("pageButton","rg-grid__page-btn"),children:"›"}),i.jsx("button",{type:"button","aria-label":"Last page",disabled:V>=ue-1,onClick:()=>ve(ue-1),...Y("pageButton","rg-grid__page-btn"),children:"»"})]})]}),wn=e=>i.jsx("tr",{className:"rg-grid__tr rg-grid__skeleton-row","aria-hidden":"true",style:te?{height:se}:void 0,children:ae?i.jsx("td",{colSpan:Fe,className:"rg-grid__td rg-grid__skeleton-cell",children:u.createElement(ae,{rowIndex:e,columns:N})}):i.jsxs(i.Fragment,{children:[J&&i.jsx("td",{className:"rg-grid__td",children:i.jsx("span",{...Y("skeleton","rg-grid__skeleton"),style:{...R.skeleton,width:18}})}),N.map((t,o)=>i.jsx("td",{className:"rg-grid__td",style:{textAlign:t.align},children:i.jsx("span",{...Y("skeleton","rg-grid__skeleton"),style:{...R.skeleton,width:`${55+(e*7+o*13)%35}%`}})},t.field))]})},`sk${e}`),_r=(e,t,o=W&&!e.sequenceRestartEachPage?V*q:0)=>(e.sequenceStart??1)+o+t,Dn=(e,t)=>{const{row:o,id:a,index:s}=e,l=typeof yt=="function"?yt(o,s):yt,b=typeof vt=="function"?vt(o,s):vt,m=Tt.has(a),k=typeof _t=="function"?_t(o,s):_t;return i.jsxs("tr",{onClick:bt?()=>bt(o,s):void 0,"aria-selected":J?m:void 0,className:$("rg-grid__tr","rg-grid__row",_n&&(t%2===0?"rg-grid__row--stripe-a":"rg-grid__row--stripe-b"),Vt&&!te&&(k||"rg-grid__row--enter"),m&&"rg-grid__row--selected",bt&&"rg-grid__row--clickable",A.row,l),style:{...Vt&&!te?{"--rg-i":Math.min(t,24)}:null,...te?{height:se}:null,...R.row,...b},children:[J&&i.jsx("td",{className:$("rg-grid__td rg-grid__select-cell",dt&&"rg-grid__pinned rg-grid__pinned--left"),style:{width:ge,minWidth:ge,maxWidth:ge,...dt?{left:0}:null},onClick:me,children:i.jsx("span",{className:"rg-grid__checkbox-cell",onClickCapture:p=>tr.current=p.shiftKey,children:i.jsx(xe,{variant:xt,checked:m,disabled:!rt(o),"aria-label":J==="single"?"Select row":`Select row ${s+1}`,onChange:p=>rn(e,p),classNames:{root:A.checkbox,control:A.checkboxControl,indicator:A.checkboxIndicator},styles:{root:R.checkbox,control:R.checkboxControl,indicator:R.checkboxIndicator}})})}),N.map((p,O)=>{let X=nn(p,e);if(p.type==="sequence"){const re=_r(p,t);X={...X,value:re,formattedValue:p.valueFormatter?p.valueFormatter(re,o):String(re),editable:!1}}const En=typeof p.cellClassName=="function"?p.cellClassName(X):p.cellClassName,Sn=typeof p.cellStyle=="function"?p.cellStyle(X):p.cellStyle,yr=Me!==null&&Me.id===a&&Me.field===p.field,$t=it(p,X),vr=fr(p,O),Mn=wt?wt.id===a&&wt.field===p.field:t===0&&O===0;return i.jsx("td",{ref:re=>{const kr=At(a,p.field);re?He.current.set(kr,re):He.current.delete(kr)},tabIndex:mt?Mn?0:-1:$t?0:void 0,onFocus:mt?re=>re.target===re.currentTarget&&Jt({id:a,field:p.field}):void 0,onDoubleClick:$t?()=>lt(e,p):void 0,onKeyDown:re=>an(re,e,p,X),className:$("rg-grid__td",$t&&"rg-grid__td--editable",yr&&"rg-grid__td--editing",vr.className,A.cell,p.className,En),style:{textAlign:p.align,...R.cell,...p.style,...Sn,...vr.style},children:yr&&Me?bn(e,p,Me):p.cellRenderer?u.createElement(p.cellRenderer,X):p.type==="boolean"&&!p.cellEditor?hn(p,X):X.formattedValue},p.field)})]},a)},Nn=ne??(W?Math.min(q,20):5);return i.jsxs("div",{className:$("rg-grid",te&&"rg-grid--virtual",A.root,Ar),style:{...yn,...R.root,...Or},"data-rg-theme":Ye||void 0,"aria-busy":Ft||void 0,children:[jn&&i.jsxs("div",{...Y("toolbar","rg-grid__toolbar"),children:[i.jsxs("div",{className:"rg-grid__toolbar-left",children:[C&&i.jsx("input",{type:"search",value:Ee,onChange:e=>Kr(e.target.value),placeholder:D,"aria-label":"Search all columns",...Y("search","rg-grid__search")}),J&&oe.length>0&&i.jsxs("span",{className:"rg-grid__selected-count",role:"status",children:[oe.length," selected"]})]}),i.jsxs("div",{className:"rg-grid__toolbar-actions",children:[qt,Oe&&i.jsx(Vn,{columns:r,hidden:Ve,onToggle:Ur,theme:Ye,className:A.toolButton,style:R.toolButton}),Ke&&i.jsx("button",{type:"button",onClick:()=>pr(),...Y("toolButton","rg-grid__tool-btn"),children:"Export CSV"})]})]}),vn&&xr("top"),i.jsx("div",{ref:Ce,...Y("scroll","rg-grid__scroll"),onScroll:te?e=>Gt({top:e.currentTarget.scrollTop,height:e.currentTarget.clientHeight}):void 0,style:{...R.scroll,...We!==void 0?{maxHeight:We}:te?{maxHeight:400}:null},children:i.jsxs("table",{...Y("table","rg-grid__table"),role:"grid",style:Lt?{...R.table,tableLayout:"fixed",width:N.reduce((e,t)=>e+ct(t),J?ge:0),minWidth:"100%"}:R.table,children:[i.jsx("thead",{...Y("thead","rg-grid__thead"),children:i.jsxs("tr",{...Y("headerRow","rg-grid__tr"),children:[J&&i.jsx("th",{scope:"col",className:$("rg-grid__th rg-grid__select-cell",dt&&"rg-grid__pinned rg-grid__pinned--left",A.headerCell),style:{width:ge,minWidth:ge,maxWidth:ge,...dt?{left:0}:null,...R.headerCell},children:J==="multiple"&&i.jsx("span",{className:"rg-grid__checkbox-cell",children:i.jsx(xe,{variant:xt,checked:nr,indeterminate:rr>0&&!nr,disabled:Te.length===0,"aria-label":"Select all rows",onChange:or,classNames:{root:A.checkbox,control:A.checkboxControl,indicator:A.checkboxIndicator},styles:{root:R.checkbox,control:R.checkboxControl,indicator:R.checkboxIndicator}})})}),N.map((e,t)=>{const o=H.findIndex(m=>m.field===e.field),a=o>=0?H[o].direction:null,s=Et(e),l=Qt(e),b=fr(e,t);return i.jsxs("th",{ref:m=>{m?Se.current.set(e.field,m):Se.current.delete(e.field)},scope:"col","aria-sort":a?a==="asc"?"ascending":"descending":s?"none":void 0,tabIndex:s?0:void 0,onClick:m=>ir(e,m.shiftKey),onKeyDown:m=>{s&&m.target===m.currentTarget&&(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),ir(e,m.shiftKey))},className:$("rg-grid__th",s&&"rg-grid__th--sortable",b.className,A.headerCell,e.className,e.headerClassName),style:{width:Lt?ct(e):e.width,minWidth:e.minWidth,textAlign:e.align,...R.headerCell,...e.style,...e.headerStyle,...b.style},children:[i.jsxs("span",{className:"rg-grid__th-content",children:[e.headerRenderer?u.createElement(e.headerRenderer,{column:e,sortDirection:a}):e.headerCheckbox&&e.type==="boolean"?mn(e):ut(e),e.filterable&&i.jsx(qn,{column:e,label:be(e),kind:l,value:ye[e.field],onChange:m=>{const k={...ye};m===void 0?delete k[e.field]:k[e.field]=m,Br(k)},options:xn.get(e.field)??[],debounce:e.filterDebounce??T,theme:Ye,indicatorClassName:$(A.filterIndicator,e.filterIndicatorClassName),indicatorStyle:{...R.filterIndicator,...e.filterIndicatorStyle},popupClassName:$(A.filterPopup,e.filterPopupClassName),popupStyle:{...R.filterPopup,...e.filterPopupStyle},inputClassName:A.filterInput,inputStyle:R.filterInput}),s&&i.jsxs("span",{className:"rg-grid__sort","aria-hidden":"true",children:[a==="asc"?"▲":a==="desc"?"▼":"↕",a&&H.length>1&&i.jsx("sup",{className:"rg-grid__sort-order",children:o+1})]})]}),e.resizable&&i.jsx("span",{className:"rg-grid__resizer",role:"separator","aria-orientation":"vertical","aria-label":`Resize ${be(e)}`,onPointerDown:m=>fn(m,e),onClick:me,onDoubleClick:me})]},e.field)})]})}),i.jsx("tbody",{...Y("tbody","rg-grid__tbody"),children:Ft?Array.from({length:Nn},(e,t)=>wn(t)):tn?i.jsx("tr",{children:i.jsxs("td",{colSpan:Fe,...Y("empty","rg-grid__empty rg-grid__error"),role:"alert",children:[ht," ",i.jsx("button",{type:"button",className:"rg-grid__tool-btn",onClick:()=>et(Xe.current),children:"Retry"})]})}):L.length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:Fe,...Y("empty","rg-grid__empty"),children:$r})}):i.jsxs(i.Fragment,{children:[Re&&at>0&&i.jsx("tr",{"aria-hidden":"true",className:"rg-grid__spacer",children:i.jsx("td",{colSpan:Fe,style:{height:at*se}})}),dn.map((e,t)=>Dn(e,at+t)),Re&&It<L.length&&i.jsx("tr",{"aria-hidden":"true",className:"rg-grid__spacer",children:i.jsx("td",{colSpan:Fe,style:{height:(L.length-It)*se}})})]})},cr)]})}),kn&&xr("bottom")]})}exports.Checkbox=xe;exports.DataGrid=Zn;