react-gridix 0.1.1 → 0.2.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/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { ComponentType } from 'react';
2
2
  import { CSSProperties } from 'react';
3
3
  import { JSX as JSX_2 } from 'react';
4
+ import { MutableRefObject } from 'react';
4
5
  import { ReactNode } from 'react';
5
6
 
6
7
  declare type AnyRow = Record<string, any>;
@@ -116,26 +117,58 @@ export declare interface ColumnDef<T = Record<string, any>> {
116
117
  * Key of the row object this column reads and writes. Use dot notation for nested objects:
117
118
  * `"contact.phone"`. Edits to a nested field copy the objects on the way and never change your data in place.
118
119
  */
119
- field: FieldPath<T> & string;
120
+ field: (FieldPath<T> & string) | SequenceField;
120
121
  /**
121
122
  * Text shown in the header. Defaults to the field name, except for `type: "boolean"` columns,
122
123
  * which default to an empty string.
123
124
  */
124
125
  headerName?: string;
125
126
  /**
126
- * "number" columns sort numerically and parse edits as numbers.
127
- * "boolean" columns show a checkbox that toggles with one click (see `checkbox`).
127
+ * - `"number"` : sorts numerically, edits parse as numbers, filters with a min / max range.
128
+ * - `"boolean"` : shows a checkbox that toggles with one click (see `checkbox`).
129
+ * - `"date"` : shows a formatted date, edits with a date picker, sorts by day, filters with a from / to range.
130
+ * Values can be ISO strings (`"2026-11-05"`), `Date` objects or timestamps. A date is saved in the same
131
+ * kind the cell already had (a `Date` stays a `Date`, a string stays an ISO string).
128
132
  */
129
- type?: "text" | "number" | "boolean";
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;
130
142
  width?: number | string;
131
143
  minWidth?: number | string;
144
+ /** Largest width in pixels when the user resizes the column. */
145
+ maxWidth?: number;
132
146
  align?: "left" | "center" | "right";
133
- /** Overrides the grid-level `sortable`. */
147
+ /** Click the header to sort by this column. Default false: sorting is opt-in, column by column. */
134
148
  sortable?: boolean;
149
+ /** Let the user drag the right edge of the header to change the column's width. Default false. */
150
+ resizable?: boolean;
151
+ /** Keep this column stuck to the left or right edge while the grid scrolls sideways. Pinned columns move to that edge. */
152
+ pinned?: "left" | "right";
153
+ /** Start with this column hidden. Needs `columnMenu` on the grid if users should be able to show it again. */
154
+ hidden?: boolean;
155
+ /** Set to false to keep this column out of the column menu (it can then never be hidden by the user). */
156
+ hideable?: boolean;
135
157
  /** Show a filter indicator in this column's header. Default false. Clicking it opens the filter popup. */
136
158
  filterable?: boolean;
159
+ /** Which filter this column gets. Defaults from `type`, see {@link FilterType}. */
160
+ filterType?: FilterType;
161
+ /** Choices for a `"select"` filter. When missing they are taken from the values in the loaded rows. */
162
+ filterOptions?: (string | FilterOption)[];
137
163
  /** Placeholder of the default filter text box. */
138
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;
139
172
  /** A React component drawn instead of the default dot. Receives `{ column, active, open }`. */
140
173
  filterIndicator?: ComponentType<FilterIndicatorProps<T>>;
141
174
  /** Classes for this column's filter indicator button (Tailwind works). */
@@ -146,7 +179,7 @@ export declare interface ColumnDef<T = Record<string, any>> {
146
179
  filterPopupClassName?: string;
147
180
  /** Inline styles for this column's filter popup. */
148
181
  filterPopupStyle?: CSSProperties;
149
- /** A React component that replaces the filter text box inside the popup. */
182
+ /** A React component that replaces the filter controls inside the popup (text matching only). */
150
183
  filterRenderer?: ComponentType<FilterRendererProps<T>>;
151
184
  /**
152
185
  * `true` / `false`, or a function that decides per cell. Overrides the grid-level `editable`.
@@ -161,9 +194,19 @@ export declare interface ColumnDef<T = Record<string, any>> {
161
194
  validate?: (value: unknown, row: T) => boolean;
162
195
  /** Custom sort. Return a negative, zero or positive number. */
163
196
  comparator?: (a: any, b: any, rowA: T, rowB: T) => number;
197
+ /** `type: "date"`: how the date is shown, as `Intl.DateTimeFormat` options. Default `{ year: "numeric", month: "short", day: "numeric" }`. */
198
+ dateFormat?: Intl.DateTimeFormatOptions;
199
+ /** `type: "date"`: locale for the displayed date, for example `"en-GB"`. Default is the browser's. */
200
+ dateLocale?: string;
201
+ /** `type: "date"`: earliest day the date picker accepts, as `"YYYY-MM-DD"`. */
202
+ dateMin?: string;
203
+ /** `type: "date"`: latest day the date picker accepts, as `"YYYY-MM-DD"`. */
204
+ dateMax?: string;
205
+ /** What goes into the CSV export for this column. Defaults to the displayed text (dates as `YYYY-MM-DD`). */
206
+ exportValue?: (value: any, row: T) => string | number | boolean | null | undefined;
164
207
  /** A React component that renders the cell content. Define it outside render so it keeps its identity. */
165
208
  cellRenderer?: ComponentType<CellParams<T>>;
166
- /** A React component used instead of the text box when editing this column. */
209
+ /** A React component used instead of the default editor when editing this column. */
167
210
  cellEditor?: ComponentType<CellEditorProps<T>>;
168
211
  /** A React component that renders the header label (the filter indicator and sort arrow are still added). */
169
212
  headerRenderer?: ComponentType<HeaderRendererProps<T>>;
@@ -186,12 +229,27 @@ export declare interface ColumnDef<T = Record<string, any>> {
186
229
  headerCheckbox?: boolean;
187
230
  }
188
231
 
189
- export declare function DataGrid<T extends AnyRow = AnyRow>({ columns, rows, getRowId, editable, enterMovesDown, onCellEdit, onRowsChange, sortable, defaultSort, onSortChange, searchable, searchPlaceholder, pagination, paginationPosition, pageSize: initialPageSize, pageSizeOptions, 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;
233
+
234
+ /** Methods you can call from outside by passing a ref as `apiRef`. */
235
+ export declare interface DataGridApi<T = Record<string, any>> {
236
+ /** Builds the CSV text without downloading it. */
237
+ getCsv: (options?: ExportOptions) => string;
238
+ /** Downloads a CSV file (opens the browser's save dialog). */
239
+ exportCsv: (options?: ExportOptions) => void;
240
+ getSelectedRows: () => T[];
241
+ getSelectedRowIds: () => (string | number)[];
242
+ /** Selects every selectable row that matches the search and filters. */
243
+ selectAll: () => void;
244
+ clearSelection: () => void;
245
+ /** Runs the last query again (`serverSide` only). Use it after your data changed on the server. */
246
+ refresh: () => void;
247
+ }
190
248
 
191
249
  export declare interface DataGridProps<T = Record<string, any>> {
192
250
  columns: ColumnDef<T>[];
193
251
  rows: T[];
194
- /** Stable id for each row. Defaults to the row's index in `rows`. */
252
+ /** Stable id for each row. Defaults to the row's index in `rows`. Row selection needs ids that do not change. */
195
253
  getRowId?: (row: T, index: number) => string | number;
196
254
  /** Allow editing cells (double-click, Enter/F2, or just start typing). Default false. */
197
255
  editable?: boolean;
@@ -204,20 +262,98 @@ export declare interface DataGridProps<T = Record<string, any>> {
204
262
  onCellEdit?: (event: CellEditEvent<T>) => void;
205
263
  /** Fires with the full updated array after a cell edit. Handy for `setRows`. */
206
264
  onRowsChange?: (rows: T[]) => void;
207
- /** Header click sorting. Default true. */
208
- sortable?: boolean;
209
- /** Uncontrolled initial sort. */
210
- defaultSort?: SortModel | null;
211
- onSortChange?: (sort: SortModel | null) => void;
212
- /** Global search box above the grid. Default true. */
265
+ /**
266
+ * Adds a checkbox column for selecting rows. `true` or `"multiple"` allows many rows (with a
267
+ * select-all header and Shift+click ranges), `"single"` allows one. Default false.
268
+ */
269
+ rowSelection?: boolean | "single" | "multiple";
270
+ /** Controlled selection: the ids of the selected rows. Pair it with `onSelectionChange`. */
271
+ selectedRowIds?: (string | number)[];
272
+ /** Initial selection when you do not control it. */
273
+ defaultSelectedRowIds?: (string | number)[];
274
+ /** Fires whenever the selection changes. */
275
+ onSelectionChange?: (selection: RowSelection<T>) => void;
276
+ /** Return false for rows that must not be selected (their checkbox is disabled). */
277
+ isRowSelectable?: (row: T) => boolean;
278
+ /** Controlled sort. Pair it with `onSortChange`. */
279
+ sort?: SortModel[];
280
+ /** Initial sort when you do not control it. */
281
+ defaultSort?: SortModel | SortModel[] | null;
282
+ /** Fires with the new sort list (empty when no column is sorted). */
283
+ onSortChange?: (sort: SortModel[]) => void;
284
+ /** Hold Shift while clicking headers to sort by several columns. Default false. */
285
+ multiSort?: boolean;
286
+ /** Show the global search box. Default false. */
213
287
  searchable?: boolean;
214
288
  searchPlaceholder?: string;
215
- /** Default true. */
289
+ /** Controlled search text. Pair it with `onSearchChange`. */
290
+ search?: string;
291
+ onSearchChange?: (search: string) => void;
292
+ /** Controlled filters, by field. Pair it with `onFiltersChange`. */
293
+ filters?: Record<string, FilterValue>;
294
+ onFiltersChange?: (filters: Record<string, FilterValue>) => void;
295
+ /** Split rows into pages and show the row count and page controls. Default false. */
216
296
  pagination?: boolean;
217
297
  /** Where the row count and page controls go: "bottom" (default), "top" or "both". */
218
298
  paginationPosition?: PaginationPosition;
299
+ /** Initial rows per page. */
219
300
  pageSize?: number;
220
301
  pageSizeOptions?: number[];
302
+ /** Controlled page (zero-based). Pair it with `onPageChange`. */
303
+ page?: number;
304
+ onPageChange?: (page: number) => void;
305
+ /** Fires when the user picks another page size. */
306
+ onPageSizeChange?: (pageSize: number) => void;
307
+ /**
308
+ * Let your server sort, filter, search and page. The grid then shows `rows` as they are (the
309
+ * current page) and calls `onQueryChange` whenever the query changes. Default false.
310
+ */
311
+ serverSide?: boolean;
312
+ /** Total number of rows on the server, for the page count. Needed with `serverSide` and `pagination`. */
313
+ rowCount?: number;
314
+ /**
315
+ * Called on mount and whenever the query changes (`serverSide` only). If it returns a promise,
316
+ * the grid shows the loading state until the promise settles and shows an error with a Retry
317
+ * button if it rejects. Update your `rows` (and `rowCount`) before the promise resolves.
318
+ */
319
+ onQueryChange?: (query: GridQuery) => void | Promise<unknown>;
320
+ /** Wait this long (ms) after the last keystroke in the search box before querying. Default 250. */
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;
327
+ /**
328
+ * Force the loading state on or off. When you leave it out, the loading state follows the promise
329
+ * returned by `onQueryChange`.
330
+ */
331
+ loading?: boolean;
332
+ /** How many placeholder rows to draw while loading. Default: the page size (at most 20), or 5 without pagination. */
333
+ loadingRows?: number;
334
+ /** A component that draws one placeholder row's content. Without it each cell gets a shimmering bar. */
335
+ skeletonRow?: ComponentType<SkeletonRowProps<T>>;
336
+ /** Shown (with a Retry button) when the promise from `onQueryChange` rejects. */
337
+ errorMessage?: ReactNode;
338
+ /** Show a "Columns" button that lets users show and hide columns. Default false. */
339
+ columnMenu?: boolean;
340
+ /** Fires with the fields that are hidden now. */
341
+ onColumnVisibilityChange?: (hiddenFields: string[]) => void;
342
+ /** Arrow keys, Home/End and Page Up/Down move between cells. Default false. */
343
+ keyboardNavigation?: boolean;
344
+ /**
345
+ * Render only the rows that are on screen, so tens of thousands of rows stay smooth. Needs a fixed
346
+ * `rowHeight`, and the grid scrolls inside `maxHeight` (400 when you set none). Default false.
347
+ */
348
+ virtualize?: boolean;
349
+ /** Row height in pixels when `virtualize` is on. Rows must fit it. Default 40. */
350
+ rowHeight?: number;
351
+ /** Extra rows rendered above and below the visible ones when `virtualize` is on. Default 6. */
352
+ overscan?: number;
353
+ /** Show an "Export CSV" button. Pass an object to set the file name, scope and so on. Default false. */
354
+ exportable?: boolean | ExportOptions;
355
+ /** Pass a ref to call methods such as `exportCsv()` or `getSelectedRows()` from outside. */
356
+ apiRef?: MutableRefObject<DataGridApi<T> | null>;
221
357
  onRowClick?: (row: T, rowIndex: number) => void;
222
358
  /** Extra content on the right side of the toolbar. */
223
359
  toolbar?: ReactNode;
@@ -226,13 +362,21 @@ export declare interface DataGridProps<T = Record<string, any>> {
226
362
  striped?: boolean;
227
363
  /** Two colours for the alternating rows, for example `["#ffffff", "#f1f5f9"]`. Implies `striped`. */
228
364
  stripeColors?: [string, string];
229
- /** Checkbox style for `type: "boolean"` columns: "button", "tick" or "native" (default). */
365
+ /** Checkbox style for `type: "boolean"` columns and the selection column: "button", "tick" or "native" (default). */
230
366
  checkboxVariant?: CheckboxVariant;
231
367
  /** Rows slide in smoothly when they render (new page, sort, search). Default true. Respects "reduce motion". */
232
368
  animateRows?: boolean;
233
369
  /**
234
- * Name of a theme. Nothing changes unless you pass one: "ocean", "midnight", "sunset" or "forest",
235
- * or the name of your own `[data-rk-theme="..."]` CSS.
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);
377
+ /**
378
+ * Name of a theme. Nothing changes unless you pass one: "ocean", "midnight", "sunset", "forest",
379
+ * "lavender", "coffee", "graphite" or "aurora", or the name of your own `[data-rg-theme="..."]` CSS.
236
380
  */
237
381
  theme?: GridTheme | (string & {});
238
382
  /** Makes the body scroll with a sticky header, e.g. 400 or "60vh". */
@@ -249,6 +393,29 @@ export declare interface DataGridProps<T = Record<string, any>> {
249
393
  rowStyle?: CSSProperties | ((row: T, rowIndex: number) => CSSProperties);
250
394
  }
251
395
 
396
+ /** Value of a `"date"` filter: ISO days (`"2026-11-05"`), both ends included. */
397
+ export declare interface DateRangeFilter {
398
+ from?: string;
399
+ to?: string;
400
+ }
401
+
402
+ export declare interface ExportOptions {
403
+ /** File name without the extension. Default `"export"`. */
404
+ filename?: string;
405
+ /**
406
+ * Which rows to export.
407
+ * - `"filtered"` (default): every row matching the search and filters, across all pages
408
+ * - `"page"` : only the rows on the current page
409
+ * - `"selected"`: only the selected rows
410
+ * With `serverSide`, "filtered" means the rows currently loaded.
411
+ */
412
+ scope?: "filtered" | "page" | "selected";
413
+ /** Also export columns the user has hidden. Default false. */
414
+ includeHidden?: boolean;
415
+ /** Add an apostrophe in front of text that starts with `= + - @`, so spreadsheets do not run it as a formula. Default true. */
416
+ sanitize?: boolean;
417
+ }
418
+
252
419
  /**
253
420
  * Every field a column can point at: top-level keys, plus dot paths into nested objects
254
421
  * (`"contact.phone"`). Goes up to 5 levels deep. Arrays are treated as plain values.
@@ -260,43 +427,107 @@ export declare type FieldPath<T, D extends number = 5> = [D] extends [never] ? n
260
427
  /** Props received by a column's `filterIndicator` component. */
261
428
  export declare interface FilterIndicatorProps<T = Record<string, any>> {
262
429
  column: ColumnDef<T>;
263
- /** True while a filter text is set for this column. */
430
+ /** True while a filter is set for this column. */
264
431
  active: boolean;
265
432
  /** True while the filter popup is open. */
266
433
  open: boolean;
267
434
  }
268
435
 
269
- /** Props received by a column's `filterRenderer` component (it is shown inside the filter popup). */
436
+ /** An entry in a `"select"` filter's list. A plain string is shorthand for `{ value }`. */
437
+ export declare interface FilterOption {
438
+ value: string;
439
+ /** Text shown in the list. Defaults to `value`. */
440
+ label?: string;
441
+ }
442
+
443
+ /**
444
+ * Props received by a column's `filterRenderer` component (shown inside the filter popup).
445
+ * A column with a `filterRenderer` always filters with a text "contains" match.
446
+ */
270
447
  export declare interface FilterRendererProps<T = Record<string, any>> {
271
448
  column: ColumnDef<T>;
272
449
  value: string;
273
450
  onChange: (value: string) => void;
274
451
  }
275
452
 
276
- export declare type GridSlot = "root" | "toolbar" | "search" | "scroll" | "table" | "thead" | "headerRow" | "headerCell" | "filterIndicator" | "filterPopup" | "filterInput" | "tbody" | "row" | "cell" | "editor" | "empty" | "footer" | "rowCount" | "pageInfo" | "pageSize" | "pagination" | "pageButton" | "checkbox" | "checkboxControl" | "checkboxIndicator";
453
+ /**
454
+ * Which kind of filter a column gets in its popup.
455
+ * - `"text"` : "contains" match on the displayed text (default for text columns)
456
+ * - `"exact"` : the displayed text must equal what was typed (ignoring case)
457
+ * - `"number"` : a min / max range (default for `type: "number"` columns)
458
+ * - `"date"` : a from / to range (default for `type: "date"` columns)
459
+ * - `"select"` : pick one or more values from a list (default for `type: "boolean"` columns)
460
+ */
461
+ export declare type FilterType = "text" | "exact" | "number" | "date" | "select";
462
+
463
+ /** What a column's filter currently holds. The shape depends on the column's `FilterType`. */
464
+ export declare type FilterValue = string | NumberRangeFilter | DateRangeFilter | string[];
465
+
466
+ /**
467
+ * Everything the grid wants from your server in `serverSide` mode. It is sent to `onQueryChange`
468
+ * on mount and whenever the sort, search, a filter, the page or the page size changes.
469
+ */
470
+ export declare interface GridQuery {
471
+ /** Sorted columns, in priority order. Only sortable columns are included. */
472
+ sort: SortModel[];
473
+ /** Active filters by field. A filter that is empty is left out. Values depend on each column's `filterType`. */
474
+ filters: Record<string, FilterValue>;
475
+ /** The global search text (trimmed). */
476
+ search: string;
477
+ /** Zero-based page index. */
478
+ page: number;
479
+ pageSize: number;
480
+ }
481
+
482
+ export declare type GridSlot = "root" | "toolbar" | "search" | "scroll" | "table" | "thead" | "headerRow" | "headerCell" | "filterIndicator" | "filterPopup" | "filterInput" | "tbody" | "row" | "cell" | "editor" | "empty" | "footer" | "rowCount" | "pageInfo" | "pageSize" | "pagination" | "pageButton" | "checkbox" | "checkboxControl" | "checkboxIndicator" | "toolButton" | "skeleton";
277
483
 
278
484
  /**
279
485
  * Built-in themes. A theme only applies when you pass its name to `<DataGrid theme="..." />`.
280
- * 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.
281
487
  */
282
- export declare type GridTheme = "ocean" | "midnight" | "sunset" | "forest";
488
+ export declare type GridTheme = "ocean" | "midnight" | "sunset" | "forest" | "lavender" | "coffee" | "graphite" | "aurora";
283
489
 
284
490
  /** Props received by a column's `headerRenderer` component. */
285
491
  export declare interface HeaderRendererProps<T = Record<string, any>> {
286
492
  column: ColumnDef<T>;
493
+ /** Direction this column is sorted in, or null when it is not sorted. */
287
494
  sortDirection: SortDirection | null;
288
495
  }
289
496
 
290
497
  export declare type MoveDirection = "down" | "up" | "left" | "right" | "none";
291
498
 
499
+ /** Value of a `"number"` filter. Either bound may be missing. */
500
+ export declare interface NumberRangeFilter {
501
+ min?: number;
502
+ max?: number;
503
+ }
504
+
292
505
  export declare type PaginationPosition = "bottom" | "top" | "both";
293
506
 
294
507
  declare type Prev = [never, 0, 1, 2, 3, 4, 5];
295
508
 
296
509
  declare type Primitive = string | number | boolean | bigint | symbol | null | undefined | Date | ((...args: any[]) => any);
297
510
 
511
+ /** The selected rows. `rows` only holds rows that are loaded in the grid right now (matters with `serverSide`). */
512
+ export declare interface RowSelection<T> {
513
+ ids: (string | number)[];
514
+ rows: T[];
515
+ }
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
+
520
+ /** Props received by the `skeletonRow` component, which draws one placeholder row while loading. */
521
+ export declare interface SkeletonRowProps<T = Record<string, any>> {
522
+ /** Position of this placeholder row (0, 1, 2 ...). */
523
+ rowIndex: number;
524
+ /** The columns that are currently visible. */
525
+ columns: ColumnDef<T>[];
526
+ }
527
+
298
528
  export declare type SortDirection = "asc" | "desc";
299
529
 
530
+ /** One sorted column. The grid keeps a list of these (more than one only with `multiSort`). */
300
531
  export declare interface SortModel {
301
532
  field: string;
302
533
  direction: SortDirection;
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),f=require("react"),ct=require("react-dom"),oe=(...o)=>o.filter(Boolean).join(" ");function ut(){return l.jsx("svg",{viewBox:"0 0 16 16",width:"100%",height:"100%","aria-hidden":"true",focusable:"false",children:l.jsx("path",{d:"M3.5 8.5l3 3 6-7",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function ft(){return l.jsx("svg",{viewBox:"0 0 16 16",width:"100%",height:"100%","aria-hidden":"true",focusable:"false",children:l.jsx("path",{d:"M4 8h8",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round"})})}function je({checked:o,onChange:d,indeterminate:c=!1,variant:g="native",disabled:P=!1,label:x,"aria-label":m,id:A,name:U,indicator:T,className:W,style:w,classNames:k={},styles:E={}}){const B=c?"indeterminate":o?"checked":"unchecked";return l.jsxs("label",{className:oe("rk-checkbox",`rk-checkbox--${g}`,B==="checked"&&"rk-checkbox--checked",c&&"rk-checkbox--indeterminate",P&&"rk-checkbox--disabled",k.root,W),style:{...E.root,...w},"data-state":B,children:[g==="native"?l.jsx("input",{type:"checkbox",id:A,name:U,ref:y=>{y&&(y.indeterminate=c)},className:oe("rk-checkbox__control",k.control),style:E.control,checked:o,disabled:P,"aria-label":m,"data-state":B,onChange:y=>d(y.target.checked)}):l.jsx("button",{type:"button",role:"checkbox",id:A,className:oe("rk-checkbox__control",k.control),style:E.control,"aria-checked":c?"mixed":o,"aria-label":m,disabled:P,"data-state":B,onClick:()=>d(!o),children:l.jsx("span",{className:oe("rk-checkbox__indicator",T!==void 0&&!c&&"rk-checkbox__indicator--custom",k.indicator),style:E.indicator,"data-state":B,"aria-hidden":"true",children:c?g==="tick"?l.jsx(ft,{}):null:T!==void 0?T:g==="tick"?l.jsx(ut,{}):null})}),x!=null&&x!==!1&&x!==""&&l.jsx("span",{className:oe("rk-checkbox__label",k.label),style:E.label,children:x})]})}const ve=(...o)=>o.filter(Boolean).join(" "),ht=typeof window<"u"?f.useLayoutEffect:f.useEffect;function pt({column:o,label:d,value:c,onChange:g,theme:P,indicatorClassName:x,indicatorStyle:m,popupClassName:A,popupStyle:U,inputClassName:T,inputStyle:W}){const[w,k]=f.useState(!1),[E,B]=f.useState({top:0,left:0}),y=f.useRef(null),z=f.useRef(null),O=c.trim()!=="",$=f.useCallback(()=>{var R;const b=y.current;if(!b)return;const F=b.getBoundingClientRect(),K=((R=z.current)==null?void 0:R.offsetWidth)??260,L=Math.max(8,Math.min(F.left,window.innerWidth-K-8));B({top:F.bottom+6,left:L})},[]);ht(()=>{w&&$()},[w,$]),f.useEffect(()=>{if(!w)return;const b=K=>{var R,ie;const L=K.target;(R=z.current)!=null&&R.contains(L)||(ie=y.current)!=null&&ie.contains(L)||k(!1)},F=K=>{var L;K.key==="Escape"&&(k(!1),(L=y.current)==null||L.focus())};return document.addEventListener("mousedown",b),document.addEventListener("keydown",F),window.addEventListener("resize",$),window.addEventListener("scroll",$,!0),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",F),window.removeEventListener("resize",$),window.removeEventListener("scroll",$,!0)}},[w,$]);const pe=()=>{var b;k(!1),(b=y.current)==null||b.focus()};return l.jsxs(l.Fragment,{children:[l.jsx("button",{ref:y,type:"button",className:ve("rk-grid__filter-btn",O&&"rk-grid__filter-btn--active",w&&"rk-grid__filter-btn--open",x),style:m,"aria-label":`Filter ${d}`,"aria-haspopup":"dialog","aria-expanded":w,"data-active":O||void 0,onClick:b=>{b.stopPropagation(),w||$(),k(F=>!F)},children:o.filterIndicator?f.createElement(o.filterIndicator,{column:o,active:O,open:w}):l.jsx("span",{className:"rk-grid__filter-dot","aria-hidden":"true"})}),w&&typeof document<"u"&&ct.createPortal(l.jsxs("div",{ref:z,role:"dialog","aria-label":`Filter ${d}`,"data-rk-theme":P||void 0,className:ve("rk-grid-popup",A),style:{position:"fixed",top:E.top,left:E.left,...U},children:[o.filterRenderer?f.createElement(o.filterRenderer,{column:o,value:c,onChange:g}):l.jsx("input",{autoFocus:!0,type:"text",className:ve("rk-grid__filter-input",T),style:W,value:c,placeholder:o.filterPlaceholder??`Filter ${d}…`,"aria-label":`Filter text for ${d}`,onChange:b=>g(b.target.value),onKeyDown:b=>{b.key==="Enter"&&pe()}}),O&&l.jsx("button",{type:"button",className:"rk-grid__filter-clear",onClick:()=>g(""),children:"Clear"})]}),document.body)]})}const we=new Set(["__proto__","prototype","constructor"]),We=(o,d)=>Object.prototype.hasOwnProperty.call(o,d);function V(o,d){if(o===null||typeof o!="object")return;if(We(o,d))return o[d];let c=o;for(const g of d.split(".")){if(c==null||typeof c!="object"||we.has(g))return;c=c[g]}return c}function ze(o,d,c){if(Array.isArray(o)){const g=[...o];return g[d]=c,g}return{...o,[d]:c}}function Ee(o,d,c){const g=o??{};if(We(g,d)||!d.includes("."))return we.has(d)?o:ze(g,d,c);const[P,...x]=d.split(".");if(we.has(P))return o;const m=g[P];return ze(g,P,Ee(m!==null&&typeof m=="object"?m:{},x.join("."),c))}const D=(...o)=>o.filter(Boolean).join(" "),Oe=(o,d)=>`${typeof o}:${o}\0${d}`,Se=o=>o.headerName??(o.type==="boolean"?"":o.field),he=o=>Se(o)||o.field;function ye(o,d){const c=V(d,o.field);return o.valueFormatter?o.valueFormatter(c,d):o.type==="boolean"&&typeof c=="boolean"?c?"Yes":"No":c==null?"":c instanceof Date?c.toLocaleDateString():String(c)}function gt(o,d){return typeof o=="number"&&typeof d=="number"?o-d:o instanceof Date&&d instanceof Date?o.getTime()-d.getTime():typeof o=="boolean"&&typeof d=="boolean"?Number(o)-Number(d):String(o).localeCompare(String(d),void 0,{numeric:!0,sensitivity:"base"})}function bt({columns:o,rows:d,getRowId:c,editable:g=!1,enterMovesDown:P=!0,onCellEdit:x,onRowsChange:m,sortable:A=!0,defaultSort:U=null,onSortChange:T,searchable:W=!0,searchPlaceholder:w="Search…",pagination:k=!0,paginationPosition:E="bottom",pageSize:B=10,pageSizeOptions:y=[5,10,25,50],onRowClick:z,toolbar:O,emptyMessage:$="No rows to show",striped:pe=!1,stripeColors:b,checkboxVariant:F="native",animateRows:K=!0,theme:L,maxHeight:R,className:ie,style:qe,classNames:S={},styles:j={},rowClassName:ge,rowStyle:be}){const _=(e,t)=>({className:D(t,S[e]),style:j[e]}),[Ne,Ce]=f.useState(d),Y=f.useRef(d);f.useEffect(()=>{Y.current=d,Ce(d)},[d]);const De=e=>{Y.current=e,Ce(e)},[H,Ge]=f.useState(""),[Q,Je]=f.useState({}),[v,Ue]=f.useState(U),[Ye,X]=f.useState(0),[I,He]=f.useState(B),[Z,ee]=f.useState(null),q=f.useRef(0),le=f.useRef(null),ke=f.useRef(new Map),Pe=f.useMemo(()=>Ne.map((e,t)=>({row:e,index:t,id:c?c(e,t):t})),[Ne,c]),te=f.useMemo(()=>{const e=H.trim().toLowerCase(),t=Object.entries(Q).filter(([n,i])=>i.trim()!==""&&o.some(s=>s.field===n&&s.filterable));let r=Pe.filter(({row:n})=>e&&!o.some(s=>ye(s,n).toLowerCase().includes(e))?!1:t.every(([i,s])=>{const h=o.find(a=>a.field===i);return h?ye(h,n).toLowerCase().includes(s.trim().toLowerCase()):!0}));if(v){const n=o.find(i=>i.field===v.field);if(n){const i=v.direction==="asc"?1:-1;r=[...r].sort((s,h)=>{const a=V(s.row,n.field),u=V(h.row,n.field),p=a==null||a==="",N=u==null||u==="";return p||N?p===N?0:p?1:-1:(n.comparator?n.comparator(a,u,s.row,h.row):gt(a,u))*i})}}return r},[Pe,o,H,Q,v]);f.useEffect(()=>X(0),[H,Q,v,I]);const Ie=f.useRef(null),G=te.length,re=k?Math.max(1,Math.ceil(G/I)):1,C=Math.min(Ye,re-1),M=k?te.slice(C*I,C*I+I):te,Qe=G===0?0:k?C*I+1:1,Xe=k?Math.min(G,(C+1)*I):G,$e=e=>e.sortable??A,Le=`${C}|${I}|${v?`${v.field}:${v.direction}`:""}|${H}|${JSON.stringify(Q)}`,Te=f.useRef(!0);f.useEffect(()=>{if(Te.current){Te.current=!1;return}const e=Ie.current;e&&typeof e.scrollTo=="function"&&e.scrollTop>0&&e.scrollTo({top:0,behavior:"smooth"})},[Le]);const se=(e,t,r)=>({value:V(t,e.field),formattedValue:ye(e,t),row:t,rowIndex:r,field:e.field,column:e}),xe=(e,t)=>{const r=e.editable??g;return typeof r=="function"?r(t):!!r},ae=(e,t)=>xe(e,t)&&!(e.type==="boolean"&&!e.cellEditor),Ze=(e,t)=>{const r=se(e,t.row,t.index),n=xe(e,r);return{...r,editable:n,updateValue:i=>n&&Fe(t,e,{value:i})}},Be=e=>{if(!$e(e))return;let t;!v||v.field!==e.field?t={field:e.field,direction:"asc"}:v.direction==="asc"?t={field:e.field,direction:"desc"}:t=null,Ue(t),T==null||T(t)},de=(e,t)=>{var r;return(r=ke.current.get(Oe(e,t)))==null?void 0:r.focus()},J=()=>{q.current+=1,ee(null)},ce=(e,t,r={})=>{if(!ae(t,se(t,e.row,e.index)))return!1;const n=V(e.row,t.field),i=t.cellEditor?n:r.text??(n==null?"":String(n));return le.current=i,q.current+=1,ee({id:e.id,field:t.field,draft:i,session:q.current,select:r.select??"end",invalid:!1}),!0},Fe=(e,t,r)=>{const n=Y.current[e.index]??e.row,i=V(n,t.field);let s;if("value"in r)s=r.value;else if(t.valueParser)s=t.valueParser(r.text,n);else if(t.type==="number")if(r.text.trim()==="")s=null;else{const u=Number(r.text);if(!Number.isFinite(u))return!1;s=u}else s=r.text;if(Object.is(s,i))return!0;if(t.validate&&!t.validate(s,n))return!1;const h=Ee(n,t.field,s),a=Y.current.map((u,p)=>p===e.index?h:u);return De(a),x==null||x({rowId:e.id,rowIndex:e.index,field:t.field,oldValue:i,newValue:s,row:h}),m==null||m(a),!0},Me=(e,t,r)=>{const n=M.findIndex(p=>p.id===e.id),i=o.findIndex(p=>p.field===t);if(n<0||i<0)return null;const s=(p,N)=>ae(N,se(N,p.row,p.index));if(r==="down"||r==="up"){const p=r==="down"?1:-1;for(let N=n+p;N>=0&&N<M.length;N+=p)if(s(M[N],o[i]))return{entry:M[N],col:o[i]};return null}const h=r==="right"?1:-1;let a=n,u=i+h;for(;a>=0&&a<M.length;){for(;u>=0&&u<o.length;){if(s(M[a],o[u]))return{entry:M[a],col:o[u]};u+=h}a+=h,u=h>0?0:o.length-1}return null},ne=(e,t,r,n={})=>{const{move:i="none",focus:s=!0}=n;if(!Fe(e,t,r))return ee(a=>a&&{...a,invalid:!0}),!1;const h=i==="none"?null:Me(e,t.field,i);return h?ce(h.entry,h.col,{select:"all"}):(J(),s&&de(e.id,t.field)),!0},et=(e,t,r)=>{if(e.nativeEvent.isComposing)return;const n=e.currentTarget.value;if(e.key==="Enter"){e.preventDefault();const i=P?e.shiftKey?"up":"down":"none";ne(t,r,{text:n},{move:i})}else if(e.key==="Escape")e.preventDefault(),J(),de(t.id,r.field);else if(e.key==="Tab"){const i=e.shiftKey?"left":"right";Me(t,r.field,i)&&(e.preventDefault(),ne(t,r,{text:n},{move:i}))}},tt=(e,t,r,n)=>{e.target!==e.currentTarget||!ae(r,n)||(e.key==="Enter"||e.key==="F2"?(e.preventDefault(),ce(t,r)):!r.cellEditor&&e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.preventDefault(),ce(t,r,{text:e.key})))},rt=(e,t,r)=>t.cellEditor?l.jsx("div",{className:"rk-grid__custom-editor",onBlur:n=>{n.currentTarget.contains(n.relatedTarget)||r.session===q.current&&(ne(e,t,{value:le.current},{focus:!1})||J())},onKeyDown:n=>{n.key==="Escape"&&(n.preventDefault(),n.stopPropagation(),J(),de(e.id,t.field))},children:f.createElement(t.cellEditor,{value:r.draft,row:e.row,rowIndex:e.index,field:t.field,column:t,onChange:n=>{le.current=n,ee(i=>i&&i.session===r.session?{...i,draft:n,invalid:!1}:i)},onCommit:(n,i="none")=>{r.session===q.current&&ne(e,t,{value:n===void 0?le.current:n},{move:i})},onCancel:()=>{J(),de(e.id,t.field)}})}):l.jsx("input",{autoFocus:!0,className:D("rk-grid__editor",r.invalid&&"rk-grid__editor--invalid",S.editor),style:{textAlign:t.align,...j.editor},value:r.draft===null||r.draft===void 0?"":String(r.draft),inputMode:t.type==="number"?"decimal":void 0,"aria-label":`Edit ${he(t)}`,"aria-invalid":r.invalid||void 0,onChange:n=>{const i=n.target.value;ee(s=>s&&{...s,draft:i,invalid:!1})},onFocus:n=>{const i=n.currentTarget;r.select==="all"?i.select():i.setSelectionRange(i.value.length,i.value.length)},onBlur:n=>{r.session===q.current&&(ne(e,t,{text:n.currentTarget.value},{focus:!1})||J())},onKeyDown:n=>et(n,e,t)}),Ke=e=>{var r,n,i,s,h,a,u,p;const t=e.checkbox??{};return{variant:t.variant??F,indicator:t.indicator,className:t.className,style:t.style,classNames:{root:D(S.checkbox,(r=t.classNames)==null?void 0:r.root),control:D(S.checkboxControl,(n=t.classNames)==null?void 0:n.control),indicator:D(S.checkboxIndicator,(i=t.classNames)==null?void 0:i.indicator),label:(s=t.classNames)==null?void 0:s.label},styles:{root:{...j.checkbox,...(h=t.styles)==null?void 0:h.root},control:{...j.checkboxControl,...(a=t.styles)==null?void 0:a.control},indicator:{...j.checkboxIndicator,...(u=t.styles)==null?void 0:u.indicator},label:(p=t.styles)==null?void 0:p.label}}},ue=e=>e.stopPropagation(),nt=(e,t)=>l.jsx("span",{className:"rk-grid__checkbox-cell",onClick:ue,onDoubleClick:ue,children:l.jsx(je,{...Ke(e),checked:!!t.value,disabled:!t.editable,"aria-label":`Toggle ${he(e)}`,onChange:r=>t.updateValue(r)})}),Re=e=>te.filter(t=>xe(e,se(e,t.row,t.index))),ot=(e,t)=>{const r=new Map(Re(e).map(s=>[s.index,s])),n=[],i=Y.current.map((s,h)=>{const a=r.get(h);if(!a)return s;const u=V(s,e.field);if(!!u===t||e.validate&&!e.validate(t,s))return s;const p=Ee(s,e.field,t);return n.push({rowId:a.id,rowIndex:h,field:e.field,oldValue:u,newValue:t,row:p}),p});n.length!==0&&(De(i),n.forEach(s=>x==null?void 0:x(s)),m==null||m(i))},it=e=>{const t=Re(e),r=t.length>0?t:te,n=r.filter(s=>!!V(s.row,e.field)).length,i=r.length>0&&n===r.length;return l.jsx("span",{className:"rk-grid__header-checkbox",onClick:ue,onDoubleClick:ue,children:l.jsx(je,{...Ke(e),checked:i,indeterminate:n>0&&!i,disabled:t.length===0,label:Se(e)||void 0,"aria-label":`Select all ${he(e)}`,onChange:s=>ot(e,s)})})},lt=pe||!!b,st=b?{"--rk-stripe-a":b[0],"--rk-stripe-b":b[1]}:void 0,at=k&&(E==="top"||E==="both"),dt=!k||E==="bottom"||E==="both",Ve=e=>l.jsxs("div",{className:D("rk-grid__footer",e==="top"&&"rk-grid__footer--top",S.footer),style:j.footer,"data-position":e,children:[l.jsx("span",{..._("rowCount","rk-grid__count"),children:G===0?"0 rows":`${Qe}–${Xe} of ${G}`}),k&&l.jsxs("div",{..._("pagination","rk-grid__pagination"),children:[l.jsxs("label",{className:"rk-grid__page-size-label",children:["Rows per page",l.jsx("select",{value:I,onChange:t=>He(Number(t.target.value)),..._("pageSize","rk-grid__page-size"),children:(y.includes(I)?y:[...y,I].sort((t,r)=>t-r)).map(t=>l.jsx("option",{value:t,children:t},t))})]}),l.jsx("button",{type:"button","aria-label":"First page",disabled:C===0,onClick:()=>X(0),..._("pageButton","rk-grid__page-btn"),children:"«"}),l.jsx("button",{type:"button","aria-label":"Previous page",disabled:C===0,onClick:()=>X(C-1),..._("pageButton","rk-grid__page-btn"),children:"‹"}),l.jsxs("span",{..._("pageInfo","rk-grid__page-info"),children:["Page ",C+1," of ",re]}),l.jsx("button",{type:"button","aria-label":"Next page",disabled:C>=re-1,onClick:()=>X(C+1),..._("pageButton","rk-grid__page-btn"),children:"›"}),l.jsx("button",{type:"button","aria-label":"Last page",disabled:C>=re-1,onClick:()=>X(re-1),..._("pageButton","rk-grid__page-btn"),children:"»"})]})]});return l.jsxs("div",{className:D("rk-grid",S.root,ie),style:{...st,...j.root,...qe},"data-rk-theme":L||void 0,children:[(W||O)&&l.jsxs("div",{..._("toolbar","rk-grid__toolbar"),children:[W?l.jsx("input",{type:"search",value:H,onChange:e=>Ge(e.target.value),placeholder:w,"aria-label":"Search all columns",..._("search","rk-grid__search")}):l.jsx("span",{}),O]}),at&&Ve("top"),l.jsx("div",{ref:Ie,..._("scroll","rk-grid__scroll"),style:{...j.scroll,...R!==void 0?{maxHeight:R}:null},children:l.jsxs("table",{..._("table","rk-grid__table"),role:"grid",children:[l.jsx("thead",{..._("thead","rk-grid__thead"),children:l.jsx("tr",{..._("headerRow","rk-grid__tr"),children:o.map(e=>{const t=(v==null?void 0:v.field)===e.field?v.direction:null,r=$e(e);return l.jsx("th",{scope:"col","aria-sort":t?t==="asc"?"ascending":"descending":r?"none":void 0,tabIndex:r?0:void 0,onClick:()=>Be(e),onKeyDown:n=>{r&&n.target===n.currentTarget&&(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),Be(e))},className:D("rk-grid__th",r&&"rk-grid__th--sortable",S.headerCell,e.className,e.headerClassName),style:{width:e.width,minWidth:e.minWidth,textAlign:e.align,...j.headerCell,...e.style,...e.headerStyle},children:l.jsxs("span",{className:"rk-grid__th-content",children:[e.headerRenderer?f.createElement(e.headerRenderer,{column:e,sortDirection:t}):e.headerCheckbox&&e.type==="boolean"?it(e):Se(e),e.filterable&&l.jsx(pt,{column:e,label:he(e),value:Q[e.field]??"",onChange:n=>Je(i=>({...i,[e.field]:n})),theme:L,indicatorClassName:D(S.filterIndicator,e.filterIndicatorClassName),indicatorStyle:{...j.filterIndicator,...e.filterIndicatorStyle},popupClassName:D(S.filterPopup,e.filterPopupClassName),popupStyle:{...j.filterPopup,...e.filterPopupStyle},inputClassName:S.filterInput,inputStyle:j.filterInput}),r&&l.jsx("span",{className:"rk-grid__sort","aria-hidden":"true",children:t==="asc"?"▲":t==="desc"?"▼":"↕"})]})},e.field)})})}),l.jsx("tbody",{..._("tbody","rk-grid__tbody"),children:M.length===0?l.jsx("tr",{children:l.jsx("td",{colSpan:o.length,..._("empty","rk-grid__empty"),children:$})}):M.map((e,t)=>{const{row:r,id:n,index:i}=e,s=typeof ge=="function"?ge(r,i):ge,h=typeof be=="function"?be(r,i):be;return l.jsx("tr",{onClick:z?()=>z(r,i):void 0,className:D("rk-grid__tr","rk-grid__row",lt&&(t%2===0?"rk-grid__row--stripe-a":"rk-grid__row--stripe-b"),K&&"rk-grid__row--enter",z&&"rk-grid__row--clickable",S.row,s),style:{...K?{"--rk-i":Math.min(t,24)}:null,...j.row,...h},children:o.map(a=>{const u=Ze(a,e),p=typeof a.cellClassName=="function"?a.cellClassName(u):a.cellClassName,N=typeof a.cellStyle=="function"?a.cellStyle(u):a.cellStyle,_e=Z!==null&&Z.id===n&&Z.field===a.field,me=ae(a,u);return l.jsx("td",{ref:fe=>{const Ae=Oe(n,a.field);fe?ke.current.set(Ae,fe):ke.current.delete(Ae)},tabIndex:me?0:void 0,onDoubleClick:me?()=>ce(e,a):void 0,onKeyDown:fe=>tt(fe,e,a,u),className:D("rk-grid__td",me&&"rk-grid__td--editable",_e&&"rk-grid__td--editing",S.cell,a.className,p),style:{textAlign:a.align,...j.cell,...a.style,...N},children:_e&&Z?rt(e,a,Z):a.cellRenderer?f.createElement(a.cellRenderer,u):a.type==="boolean"&&!a.cellEditor?nt(a,u):u.formattedValue},a.field)})},n)})},Le)]})}),dt&&Ve("bottom")]})}exports.Checkbox=je;exports.DataGrid=bt;
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;