flexi-datagrid 1.2.9 → 1.2.11
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/README.md +4 -3
- package/dist/DataTable/constants.d.ts +1 -1
- package/dist/DataTable/hooks/useDataTableState.d.ts +2 -0
- package/dist/flexi-datagrid.css +1 -1
- package/dist/index.es.js +267 -254
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -148,7 +148,7 @@ Each entry in `columns` describes one column (or a group of columns, via `childr
|
|
|
148
148
|
| `rowKey` | `keyof T \| (record: T) => string` | Field name or function used to derive a unique React key per row. |
|
|
149
149
|
| `actions` | `(record: T) => ReactNode` | Renders a sticky, right-aligned actions cell per row (e.g. edit/delete buttons). |
|
|
150
150
|
| `isLoading` | `boolean` | Shows a loading state in place of rows. |
|
|
151
|
-
| `groupBy` | `boolean` | Enables drag-and-drop row grouping — drag a column header into the grouping zone above the grid. |
|
|
151
|
+
| `groupBy` | `boolean` | Enables drag-and-drop row grouping — drag a column header into the grouping zone above the grid. It also sets the initial state of the **Group By** checkbox in the settings menu (shown whenever `controlPanel` is on), which lets users turn grouping on or off at runtime. Defaults to `false`. |
|
|
152
152
|
| `defaultGroupBy` | `string[]` | Column keys the grid is grouped by on initial render (requires `groupBy`). |
|
|
153
153
|
| `onPinChange` | `(columnKey, isPinned, side?) => void` | Called whenever a column is pinned/unpinned, with the side (`'left'` \| `'right'`) it was pinned to. |
|
|
154
154
|
| `onGroupChange` | `(groupedKeys: string[]) => void` | Called whenever the set of grouped columns changes. |
|
|
@@ -253,8 +253,9 @@ Notes:
|
|
|
253
253
|
Pass `controlPanel` to render a small toolbar above the grid (and above the grouping drop zone, if `groupBy` is also on) with a single **Settings** menu button. Clicking it opens a dropdown with every display option in one place, instead of a row of separate buttons:
|
|
254
254
|
|
|
255
255
|
- **Show pin/filter icons on hover** — toggles `displayPinnedIcon`. When off, neither the pin button nor the filter button reveals on hovering a column header, regardless of whether the column is `filterable`; when on, hovering a leaf column header's action area reveals its filter icon (if `filterable`) and pin icon.
|
|
256
|
+
- **Group By** — always listed in the dropdown. Its checked state comes from the `groupBy` prop (`groupBy` → checked, otherwise unchecked), and it follows the prop if that value changes. Checking it shows the grouping drop zone and makes leaf column headers draggable into it; unchecking it hides the drop zone and renders the rows ungrouped. Columns the user had grouped by are remembered, so re-checking restores them.
|
|
256
257
|
- **Columns** — a checklist of every leaf column (by `header` label) to show or hide it. Hiding a column removes it from both the header and body, and adjusts any parent group header's `colSpan` automatically.
|
|
257
|
-
- **Reset to defaults** — restores pin/filter icon hover visibility
|
|
258
|
+
- **Reset to defaults** — restores pin/filter icon hover visibility, hidden columns and the Group By checkbox to the values passed via `defaultDisplayPinnedIcon` / `defaultHiddenColumns` / `groupBy` (not to "all columns visible" — it resets to *your configured defaults*, so a column you deliberately hid by default stays hidden after reset).
|
|
258
259
|
|
|
259
260
|
```tsx
|
|
260
261
|
<DataTable
|
|
@@ -289,7 +290,7 @@ Pagination is applied after filtering and sorting, and before row grouping — s
|
|
|
289
290
|
|
|
290
291
|
### Row Grouping
|
|
291
292
|
|
|
292
|
-
Set `groupBy` to enable a drop zone above the table. Dragging a sortable/leaf column header into it groups rows by that column's value, with collapsible group rows and per-group row counts. Multiple columns can be stacked to create nested groups; use `defaultGroupBy` to pre-group on mount.
|
|
293
|
+
Set `groupBy` to enable a drop zone above the table. With `controlPanel` on, the settings menu always shows a **Group By** checkbox whose initial state follows this prop; unchecking it hides the drop zone and ungroups the rows (the chosen group columns are kept for when it's re-checked). Dragging a sortable/leaf column header into it groups rows by that column's value, with collapsible group rows and per-group row counts. Multiple columns can be stacked to create nested groups; use `defaultGroupBy` to pre-group on mount.
|
|
293
294
|
|
|
294
295
|
### Column Reordering
|
|
295
296
|
|
|
@@ -10,6 +10,8 @@ export declare function useDataTableState<T>({ columns, data, rowKey, actions, i
|
|
|
10
10
|
actions: ((record: T) => import("react").ReactNode) | undefined;
|
|
11
11
|
isLoading: boolean;
|
|
12
12
|
groupBy: boolean;
|
|
13
|
+
showGroupBy: boolean;
|
|
14
|
+
toggleShowGroupBy: () => void;
|
|
13
15
|
controlPanel: boolean;
|
|
14
16
|
rowHeight: number;
|
|
15
17
|
rowSpanColumns: string[] | undefined;
|
package/dist/flexi-datagrid.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.flexi-root{width:100%;position:relative}.flexi-root>*+*{margin-top:.75rem}.flexi-settings-menu{z-index:50;background-color:#fff;border:1px solid #e2e8f0;border-radius:.5rem;flex-direction:column;width:13rem;max-height:20rem;padding:.5rem;font-weight:400;display:flex;position:absolute;top:calc(100% + 4px);overflow-y:auto;box-shadow:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a}.flexi-settings-section{flex-direction:column;gap:.125rem;display:flex}.flexi-settings-heading{text-transform:uppercase;letter-spacing:.05em;color:#94a3b8;padding:.25rem .5rem;font-size:11px;font-weight:700}.flexi-settings-divider{background-color:#f1f5f9;height:1px;margin:.375rem 0}.flexi-settings-reset{color:#ef4444;border-radius:.375rem;align-items:center;gap:.375rem;padding:.375rem .5rem;font-size:12px;font-weight:600;display:inline-flex}.flexi-settings-reset:hover{background-color:#fef2f2}.flexi-groupzone{box-sizing:border-box;background-color:#f8fafc80;border:1px dashed #e2e8f0;border-radius:.75rem;align-items:center;gap:.5rem;width:100%;min-height:52px;padding:.5rem 1rem;transition:all .2s;display:flex}.flexi-groupzone--dragover{background-color:#eff6ff80;border:1px solid #3b82f6;transform:scale(.99)}.flexi-groupzone-hint{color:#64748b;-webkit-user-select:none;user-select:none;font-size:12px;font-weight:500}.flexi-groupzone-chips{flex-wrap:wrap;align-items:center;gap:.375rem;display:flex}.flexi-groupzone-label{text-transform:uppercase;letter-spacing:.05em;color:#64748b;margin-right:.25rem;font-size:11px;font-weight:700}.flexi-chip{color:#64748b;background-color:#fff;border:1px solid #e2e8f0;border-radius:.5rem;align-items:center;gap:.375rem;padding:.25rem .25rem .25rem .5rem;font-size:12px;font-weight:600;display:flex;box-shadow:0 1px 2px #0000000d}.flexi-chip-remove{border-radius:5px;width:18px;height:18px}.flexi-table-wrap{box-sizing:border-box;background-color:#fff;border:1px solid #f1f5f9;border-radius:.75rem;width:100%;position:relative;overflow:auto;box-shadow:0 1px 2px #0000000d}.flexi-table{caption-side:bottom;border-collapse:collapse;border-spacing:0;table-layout:fixed;width:100%;font-size:.875rem;position:relative}.flexi-table--bordered th,.flexi-table--bordered td{border:1px solid #e2e8f0}.flexi-thead{-webkit-user-select:none;user-select:none;z-index:40;position:sticky}.flexi-header-row{border-bottom:1px solid #f1f5f9}.flexi-group-spacer-th{border-right:1px solid #f1f5f9;width:48px}.flexi-th{text-align:center;vertical-align:middle;z-index:25;background-color:#f8fafc;border-bottom:1px solid #f1f5f9;border-right:1px solid #f1f5f9;height:48px;padding:0 1rem;font-size:12px;font-weight:700;position:sticky;top:0}.flexi-th--draggable{cursor:grab}.flexi-th--draggable:active{cursor:grabbing}.flexi-th--pinned{background-color:#f8fafc}.flexi-th-inner{justify-content:space-between;align-items:center;gap:.25rem;width:100%;min-width:0;display:flex}.flexi-th-label{white-space:nowrap;text-overflow:ellipsis;flex:auto;align-items:center;gap:.375rem;min-width:0;display:flex;overflow:hidden}.flexi-th-label--sortable{cursor:pointer;-webkit-user-select:none;user-select:none}.flexi-th-label--sortable:hover{color:#2563eb}.flexi-th-text{white-space:nowrap;text-overflow:ellipsis;flex:auto;min-width:0;overflow:hidden}.flexi-sort-icon,.flexi-filter-btn,.flexi-pin-btn{color:#94a3b8;opacity:0;transition:color .15s,opacity .15s}.flexi-sort-icon--active{color:#2563eb;opacity:1}.flexi-th-inner:hover .flexi-sort-icon,.flexi-th-inner:hover .flexi-filter-btn,.flexi-th-inner:hover .flexi-pin-btn{opacity:1}.flexi-th-actions{flex:none;align-items:center;gap:2px;display:flex}.flexi-th-resizer{cursor:col-resize;touch-action:none;-webkit-user-select:none;user-select:none;z-index:5;width:6px;position:absolute;top:0;bottom:0;right:0}.flexi-th-resizer:hover,.flexi-th-resizer:active{background-color:#93c5fd}.flexi-icon-btn{color:#64748b;background-color:#0000;border-radius:6px;justify-content:center;align-items:center;width:22px;height:22px;margin:0;padding:0;transition:background-color .15s,color .15s,transform .1s;display:inline-flex}.flexi-icon-btn:hover{color:#334155;background-color:#e2e8f0}.flexi-icon-btn:active{background-color:#cbd5e1;transform:scale(.92)}.flexi-icon-btn:focus-visible{outline-offset:1px;outline:2px solid #93c5fd}.flexi-filter-btn--active{color:#2563eb;opacity:1}.flexi-filter-btn--active:hover{color:#2563eb;opacity:1;background-color:#dbeafe}.flexi-pin-btn--pinned{color:#3b82f6;opacity:1}.flexi-pin-btn--pinned:hover{color:#2563eb;opacity:1;background-color:#dbeafe}.flexi-
|
|
1
|
+
.flexi-root{width:100%;position:relative}.flexi-root>*+*{margin-top:.75rem}.flexi-settings-menu{z-index:50;background-color:#fff;border:1px solid #e2e8f0;border-radius:.5rem;flex-direction:column;width:13rem;max-height:20rem;padding:.5rem;font-weight:400;display:flex;position:absolute;top:calc(100% + 4px);overflow-y:auto;box-shadow:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a}.flexi-settings-section{flex-direction:column;gap:.125rem;display:flex}.flexi-settings-heading{text-transform:uppercase;letter-spacing:.05em;color:#94a3b8;padding:.25rem .5rem;font-size:11px;font-weight:700}.flexi-settings-divider{background-color:#f1f5f9;height:1px;margin:.375rem 0}.flexi-settings-reset{color:#ef4444;border-radius:.375rem;align-items:center;gap:.375rem;padding:.375rem .5rem;font-size:12px;font-weight:600;display:inline-flex}.flexi-settings-reset:hover{background-color:#fef2f2}.flexi-groupzone{box-sizing:border-box;background-color:#f8fafc80;border:1px dashed #e2e8f0;border-radius:.75rem;align-items:center;gap:.5rem;width:100%;min-height:52px;padding:.5rem 1rem;transition:all .2s;display:flex}.flexi-groupzone--dragover{background-color:#eff6ff80;border:1px solid #3b82f6;transform:scale(.99)}.flexi-groupzone-hint{color:#64748b;-webkit-user-select:none;user-select:none;font-size:12px;font-weight:500}.flexi-groupzone-chips{flex-wrap:wrap;align-items:center;gap:.375rem;display:flex}.flexi-groupzone-label{text-transform:uppercase;letter-spacing:.05em;color:#64748b;margin-right:.25rem;font-size:11px;font-weight:700}.flexi-chip{color:#64748b;background-color:#fff;border:1px solid #e2e8f0;border-radius:.5rem;align-items:center;gap:.375rem;padding:.25rem .25rem .25rem .5rem;font-size:12px;font-weight:600;display:flex;box-shadow:0 1px 2px #0000000d}.flexi-chip-remove{border-radius:5px;width:18px;height:18px}.flexi-table-wrap{box-sizing:border-box;background-color:#fff;border:1px solid #f1f5f9;border-radius:.75rem;width:100%;position:relative;overflow:auto;box-shadow:0 1px 2px #0000000d}.flexi-table{caption-side:bottom;border-collapse:collapse;border-spacing:0;table-layout:fixed;width:100%;font-size:.875rem;position:relative}.flexi-table--bordered th,.flexi-table--bordered td{border:1px solid #e2e8f0}.flexi-thead{-webkit-user-select:none;user-select:none;z-index:40;position:sticky}.flexi-header-row{border-bottom:1px solid #f1f5f9}.flexi-group-spacer-th{border-right:1px solid #f1f5f9;width:48px}.flexi-th{text-align:center;vertical-align:middle;z-index:25;background-color:#f8fafc;border-bottom:1px solid #f1f5f9;border-right:1px solid #f1f5f9;height:48px;padding:0 1rem;font-size:12px;font-weight:700;position:sticky;top:0}.flexi-th--draggable{cursor:grab}.flexi-th--draggable:active{cursor:grabbing}.flexi-th--pinned{background-color:#f8fafc}.flexi-th-inner{justify-content:space-between;align-items:center;gap:.25rem;width:100%;min-width:0;display:flex}.flexi-th-label{white-space:nowrap;text-overflow:ellipsis;flex:auto;align-items:center;gap:.375rem;min-width:0;display:flex;overflow:hidden}.flexi-th-label--sortable{cursor:pointer;-webkit-user-select:none;user-select:none}.flexi-th-label--sortable:hover{color:#2563eb}.flexi-th-text{white-space:nowrap;text-overflow:ellipsis;flex:auto;min-width:0;overflow:hidden}.flexi-sort-icon,.flexi-filter-btn,.flexi-pin-btn{color:#94a3b8;opacity:0;transition:color .15s,opacity .15s}.flexi-sort-icon--active{color:#2563eb;opacity:1}.flexi-th-inner:hover .flexi-sort-icon,.flexi-th-inner:hover .flexi-filter-btn,.flexi-th-inner:hover .flexi-pin-btn{opacity:1}.flexi-th-actions{flex:none;align-items:center;gap:2px;display:flex}.flexi-th-resizer{cursor:col-resize;touch-action:none;-webkit-user-select:none;user-select:none;z-index:5;width:6px;position:absolute;top:0;bottom:0;right:0}.flexi-th-resizer:hover,.flexi-th-resizer:active{background-color:#93c5fd}.flexi-icon-btn{color:#64748b;background-color:#0000;border-radius:6px;justify-content:center;align-items:center;width:22px;height:22px;margin:0;padding:0;transition:background-color .15s,color .15s,transform .1s;display:inline-flex}.flexi-icon-btn:hover{color:#334155;background-color:#e2e8f0}.flexi-icon-btn:active{background-color:#cbd5e1;transform:scale(.92)}.flexi-icon-btn:focus-visible{outline-offset:1px;outline:2px solid #93c5fd}.flexi-filter-btn--active{color:#2563eb;opacity:1}.flexi-filter-btn--active:hover{color:#2563eb;opacity:1;background-color:#dbeafe}.flexi-pin-btn--pinned{color:#3b82f6;opacity:1}.flexi-pin-btn--pinned:hover{color:#2563eb;opacity:1;background-color:#dbeafe}.flexi-settings-corner{z-index:60;width:100%;height:0;position:sticky;top:0;left:0}.flexi-settings-corner-inner{background:#f8fafc;border-bottom:1px solid #e3e4e3;border-left:1px solid #e3e4e3;align-items:center;height:48px;padding:0 .5rem 0 1rem;display:flex;position:absolute;top:0;right:0}.flexi-filter-dropdown{color:#334155;text-align:left;pointer-events:auto;background-color:#fff;border:1px solid #e2e8f0;border-radius:.5rem;flex-direction:column;width:13rem;padding:.5rem 0;font-weight:400;display:flex;position:absolute;box-shadow:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a}.flexi-filter-search{border-bottom:1px solid #f1f5f9;margin-bottom:.25rem;padding:0 .5rem .5rem}.flexi-input{color:#475569;box-sizing:border-box;border:1px solid #e2e8f0;border-radius:.25rem;width:100%;padding:.25rem .5rem;font-size:12px;font-weight:500}.flexi-input:focus{border-color:#3b82f6;outline:none}.flexi-filter-list{flex-direction:column;gap:.25rem;max-height:10rem;padding:0 .5rem;display:flex;overflow-y:auto}.flexi-filter-empty{color:#64748b;text-align:center;padding:.5rem;font-size:11px}.flexi-filter-option{cursor:pointer;-webkit-user-select:none;user-select:none;border-radius:.25rem;align-items:center;gap:.5rem;padding:.375rem .5rem;font-size:12px;display:flex}.flexi-filter-option:hover{background-color:#f8fafc}.flexi-filter-option-text{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.flexi-checkbox{accent-color:#2563eb;border:1px solid #cbd5e1;border-radius:.25rem;width:.875rem;height:.875rem}.flexi-checkbox:focus{outline-offset:1px;outline:2px solid #3b82f6}.flexi-filter-footer{border-top:1px solid #f1f5f9;justify-content:flex-end;margin-top:.5rem;padding:.25rem .5rem 0;display:flex}.flexi-filter-clear{color:#ef4444;padding:.125rem .5rem;font-size:11px;font-weight:500}.flexi-filter-clear:hover{text-decoration:underline}.flexi-tbody{display:table-row-group}.flexi-tbody tr+tr{border-top:1px solid #f1f5f9}.flexi-empty-cell{text-align:center;color:#64748b;padding:2rem;font-size:12px;font-weight:500}.flexi-group-row{-webkit-user-select:none;user-select:none;background-color:#f8fafc99;height:48px;transition:background-color .15s}.flexi-group-row:hover{background-color:#f1f5f9cc}.flexi-group-cell{color:#334155;border-right:1px solid #f1f5f9;padding:.75rem 1rem;font-size:12px;font-weight:600}.flexi-group-toggle{text-align:left;border-radius:6px;align-items:center;gap:.375rem;margin:-4px -8px -4px -4px;padding:4px 8px 4px 4px;transition:background-color .15s;display:flex}.flexi-group-toggle:hover{background-color:#e2e8f099}.flexi-group-toggle:focus-visible{outline-offset:1px;outline:2px solid #93c5fd}.flexi-icon-muted{color:#64748b}.flexi-group-value{color:#1e293b;white-space:nowrap;text-overflow:ellipsis;width:10rem;font-weight:700;overflow:hidden}.flexi-group-count{color:#64748b;background-color:#e2e8f0b3;border-radius:9999px;margin-left:.25rem;padding:.05rem .375rem;font-size:10px;font-weight:500}.flexi-group-filler{background-color:#f8fafc4d}.flexi-row{border-bottom:1px solid #f1f5f9;height:48px;transition:background-color .15s}.flexi-row:hover{background-color:#f8fafccc}.flexi-row--clickable{cursor:pointer}.flexi-row-indent-cell{background-color:#fff;border-right:1px solid #f1f5f9;width:48px}.flexi-cell{vertical-align:middle;padding:.25rem 1rem;transition:background-color .15s}.flexi-row:hover .flexi-cell--pinned{background-color:#f1f5f9}.flexi-cell-text{color:#64748b;white-space:nowrap;text-overflow:ellipsis;font-size:12px;font-weight:500;display:block;overflow:hidden}.flexi-actions-cell{vertical-align:middle;text-align:right;background-color:#fff;padding:.25rem 1rem;box-shadow:-1px 0 #e2e8f0}.flexi-row:hover .flexi-actions-cell{background-color:#f8fafccc}.flexi-tbody--pinned-bottom{box-shadow:0 -2px 5px -2px #0000001a}.flexi-row--pinned-bottom{background-color:#f8fafc;font-weight:600}.flexi-row--pinned-bottom:hover,.flexi-row--pinned-bottom .flexi-cell,.flexi-row--pinned-bottom .flexi-actions-cell{background-color:#f8fafc}.flexi-row--pinned-bottom .flexi-cell-text{color:#334155}.flexi-actions-inner{opacity:0;justify-content:flex-end;gap:.25rem;transition:opacity .15s;display:flex}.flexi-row:hover .flexi-actions-inner{opacity:1}.flexi-icon-xs{width:.75rem;height:.75rem}.flexi-icon-sm{width:.875rem;height:.875rem}.flexi-icon-md{width:1rem;height:1rem}.flexi-pagination{color:#475569;box-sizing:border-box;background-color:#f8fafc80;border:1px solid #e2e8f0;border-radius:.75rem;justify-content:space-between;align-items:center;gap:1rem;width:100%;padding:.5rem .75rem;font-size:12px;font-weight:500;display:flex}.flexi-pagination-size{align-items:center;gap:.5rem;display:flex}.flexi-pagination-select{color:#334155;background-color:#fff;border:1px solid #e2e8f0;border-radius:.375rem;padding:.25rem .5rem;font-size:12px;font-weight:500}.flexi-pagination-info{text-align:center;flex:auto}.flexi-pagination-controls{align-items:center;gap:.25rem;display:flex}.flexi-pagination-controls .flexi-icon-btn:disabled{opacity:.4;cursor:not-allowed}.flexi-pagination-controls .flexi-icon-btn:disabled:hover{background-color:#0000}.flexi-pagination-page{white-space:nowrap;padding:0 .5rem}.flexi-root button{appearance:none;cursor:pointer;font:inherit;color:inherit;background:0 0;border:none;margin:0;padding:0 5px;line-height:normal}.flexi-root input{font:inherit}.flexi-root table{border-collapse:collapse;border-spacing:0}
|
|
2
2
|
/*$vite$:1*/
|
package/dist/index.es.js
CHANGED
|
@@ -4,24 +4,24 @@ import { jsx as x, jsxs as S } from "react/jsx-runtime";
|
|
|
4
4
|
import { createPortal as C } from "react-dom";
|
|
5
5
|
//#region src/DataTable/context/DataTableContext.tsx
|
|
6
6
|
var w = m(null);
|
|
7
|
-
function
|
|
7
|
+
function ee({ value: e, children: t }) {
|
|
8
8
|
return /* @__PURE__ */ x(w.Provider, {
|
|
9
9
|
value: e,
|
|
10
10
|
children: t
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function T() {
|
|
14
14
|
let e = g(w);
|
|
15
15
|
if (!e) throw Error("DataTable components must be rendered inside <DataTable>.");
|
|
16
16
|
return e;
|
|
17
17
|
}
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region src/DataTable/utils/classNames.ts
|
|
20
|
-
var
|
|
20
|
+
var E = (...e) => e.filter(Boolean).join(" ");
|
|
21
21
|
//#endregion
|
|
22
22
|
//#region src/DataTable/components/GroupZone.tsx
|
|
23
|
-
function
|
|
24
|
-
let { groupedColumns: e, columnsByKey: t, addGroup: n, removeGroup: r } =
|
|
23
|
+
function D() {
|
|
24
|
+
let { groupedColumns: e, columnsByKey: t, addGroup: n, removeGroup: r } = T(), [i, a] = b(!1);
|
|
25
25
|
return /* @__PURE__ */ x("div", {
|
|
26
26
|
onDragOver: (e) => {
|
|
27
27
|
e.preventDefault(), a(!0);
|
|
@@ -32,7 +32,7 @@ function O() {
|
|
|
32
32
|
let r = e.dataTransfer.getData("text/plain");
|
|
33
33
|
r && t.has(r) && n(r);
|
|
34
34
|
},
|
|
35
|
-
className:
|
|
35
|
+
className: E("flexi-groupzone", i && "flexi-groupzone--dragover"),
|
|
36
36
|
children: e.length === 0 ? /* @__PURE__ */ x("span", {
|
|
37
37
|
className: "flexi-groupzone-hint",
|
|
38
38
|
children: "Drag a column header here to group your records by that field"
|
|
@@ -55,8 +55,8 @@ function O() {
|
|
|
55
55
|
}
|
|
56
56
|
//#endregion
|
|
57
57
|
//#region src/DataTable/components/Pagination.tsx
|
|
58
|
-
function
|
|
59
|
-
let { currentPage: e, pageSize: t, totalPages: n, totalCount: r, pageSizeOptions: c, goToPage: l, changePageSize: u } =
|
|
58
|
+
function O() {
|
|
59
|
+
let { currentPage: e, pageSize: t, totalPages: n, totalCount: r, pageSizeOptions: c, goToPage: l, changePageSize: u } = T();
|
|
60
60
|
return /* @__PURE__ */ S("div", {
|
|
61
61
|
className: "flexi-pagination",
|
|
62
62
|
children: [
|
|
@@ -127,26 +127,26 @@ function k() {
|
|
|
127
127
|
}
|
|
128
128
|
//#endregion
|
|
129
129
|
//#region src/DataTable/constants.ts
|
|
130
|
-
var
|
|
130
|
+
var te = [
|
|
131
131
|
10,
|
|
132
132
|
25,
|
|
133
133
|
50,
|
|
134
134
|
100
|
|
135
|
-
],
|
|
135
|
+
], k = [], A = [], j = (e) => {
|
|
136
136
|
let t = [];
|
|
137
137
|
return e.forEach((e) => {
|
|
138
|
-
e.children && e.children.length > 0 ? t.push(...
|
|
138
|
+
e.children && e.children.length > 0 ? t.push(...j(e.children)) : t.push(e);
|
|
139
139
|
}), t;
|
|
140
|
-
},
|
|
140
|
+
}, ne = (e) => {
|
|
141
141
|
if (e === !0) return "left";
|
|
142
142
|
if (e === "left" || e === "right") return e;
|
|
143
|
-
},
|
|
143
|
+
}, M = (e) => {
|
|
144
144
|
let t = {};
|
|
145
145
|
return e.forEach((e) => {
|
|
146
|
-
let n =
|
|
146
|
+
let n = ne(e.pinned);
|
|
147
147
|
n && (t[e.key] = n);
|
|
148
148
|
}), t;
|
|
149
|
-
},
|
|
149
|
+
}, N = (e, t, n) => {
|
|
150
150
|
let r = (e) => {
|
|
151
151
|
let n = t[e];
|
|
152
152
|
return n === "left" ? 0 : n === "right" ? 2 : 1;
|
|
@@ -161,22 +161,22 @@ var ee = [
|
|
|
161
161
|
children: i(e.children)
|
|
162
162
|
} : e);
|
|
163
163
|
return i(e);
|
|
164
|
-
},
|
|
164
|
+
}, P = (e, t, n) => {
|
|
165
165
|
let r = e.map((e) => e.key);
|
|
166
166
|
if (r.includes(t) && r.includes(n)) return e;
|
|
167
167
|
for (let r of e) if (r.children && r.children.length > 0) {
|
|
168
|
-
let e =
|
|
168
|
+
let e = P(r.children, t, n);
|
|
169
169
|
if (e) return e;
|
|
170
170
|
}
|
|
171
171
|
return null;
|
|
172
|
-
},
|
|
172
|
+
}, F = (e, t) => {
|
|
173
173
|
let n = t[e.key];
|
|
174
174
|
if (n !== void 0) return n;
|
|
175
175
|
let r = e.style?.width || e.headerStyle?.width || "150px";
|
|
176
176
|
if (typeof r == "number") return r;
|
|
177
177
|
let i = String(r).trim();
|
|
178
178
|
return /^\d+(\.\d+)?(px)?$/i.test(i) && parseInt(i, 10) || 150;
|
|
179
|
-
},
|
|
179
|
+
}, re = (e, t, n) => {
|
|
180
180
|
let r = (e) => {
|
|
181
181
|
let t = 0;
|
|
182
182
|
return e.forEach((e) => {
|
|
@@ -203,13 +203,13 @@ var ee = [
|
|
|
203
203
|
...e,
|
|
204
204
|
rowSpan: Math.min(e.rowSpan, c.length - t)
|
|
205
205
|
})));
|
|
206
|
-
},
|
|
206
|
+
}, ie = ({ visibleLeafColumns: e, pinnedColumns: t, columnWidths: n, hasGroups: r, hasActions: i }) => {
|
|
207
207
|
let a = {}, o = r ? 48 : 0;
|
|
208
208
|
e.forEach((e) => {
|
|
209
209
|
t[e.key] === "left" && (a[e.key] = {
|
|
210
210
|
side: "left",
|
|
211
211
|
offset: o
|
|
212
|
-
}, o +=
|
|
212
|
+
}, o += F(e, n));
|
|
213
213
|
});
|
|
214
214
|
let s = i ? 100 : 0;
|
|
215
215
|
for (let r = e.length - 1; r >= 0; r--) {
|
|
@@ -217,10 +217,10 @@ var ee = [
|
|
|
217
217
|
t[i.key] === "right" && (a[i.key] = {
|
|
218
218
|
side: "right",
|
|
219
219
|
offset: s
|
|
220
|
-
}, s +=
|
|
220
|
+
}, s += F(i, n));
|
|
221
221
|
}
|
|
222
222
|
return a;
|
|
223
|
-
},
|
|
223
|
+
}, I = (e, t, n = !1, r) => {
|
|
224
224
|
let i = e[t];
|
|
225
225
|
if (!i) return r || {};
|
|
226
226
|
let a = i.side === "right";
|
|
@@ -233,7 +233,7 @@ var ee = [
|
|
|
233
233
|
boxShadow: a ? "-2px 0 5px -2px rgba(0,0,0,0.1)" : "2px 0 5px -2px rgba(0,0,0,0.1)",
|
|
234
234
|
...r
|
|
235
235
|
};
|
|
236
|
-
},
|
|
236
|
+
}, ae = () => /* @__PURE__ */ x("td", {
|
|
237
237
|
className: "flexi-row-indent-cell",
|
|
238
238
|
style: {
|
|
239
239
|
position: "sticky",
|
|
@@ -241,7 +241,7 @@ var ee = [
|
|
|
241
241
|
zIndex: 10
|
|
242
242
|
}
|
|
243
243
|
});
|
|
244
|
-
function
|
|
244
|
+
function L({ children: e }) {
|
|
245
245
|
return /* @__PURE__ */ x("td", {
|
|
246
246
|
className: "flexi-actions-cell",
|
|
247
247
|
style: {
|
|
@@ -254,8 +254,8 @@ function R({ children: e }) {
|
|
|
254
254
|
})
|
|
255
255
|
});
|
|
256
256
|
}
|
|
257
|
-
function
|
|
258
|
-
let { rowHeight: t, expandedGroups: n, toggleGroupExpansion: i, totalColumnsCount: o } =
|
|
257
|
+
function oe({ node: e }) {
|
|
258
|
+
let { rowHeight: t, expandedGroups: n, toggleGroupExpansion: i, totalColumnsCount: o } = T(), s = n[e.path] !== !1;
|
|
259
259
|
return /* @__PURE__ */ S("tr", {
|
|
260
260
|
className: "flexi-group-row",
|
|
261
261
|
style: { height: t },
|
|
@@ -290,65 +290,65 @@ function ae({ node: e }) {
|
|
|
290
290
|
})]
|
|
291
291
|
});
|
|
292
292
|
}
|
|
293
|
-
function
|
|
294
|
-
let { rowHeight: r, hasGroups: i, hasActions: a, actions: o, onRowClick: s, visibleLeafColumns: c, pinnedColumns: l, pinOffsets: u, rowSpanColumns: d, rowSpanInfo: f } =
|
|
293
|
+
function se({ record: e, rowIndex: t, className: n }) {
|
|
294
|
+
let { rowHeight: r, hasGroups: i, hasActions: a, actions: o, onRowClick: s, visibleLeafColumns: c, pinnedColumns: l, pinOffsets: u, rowSpanColumns: d, rowSpanInfo: f } = T(), p = f.get(t);
|
|
295
295
|
return /* @__PURE__ */ S("tr", {
|
|
296
|
-
className:
|
|
296
|
+
className: E("flexi-row", s && "flexi-row--clickable", n),
|
|
297
297
|
style: { height: r },
|
|
298
298
|
onClick: s ? (n) => s(e, t, n) : void 0,
|
|
299
299
|
children: [
|
|
300
|
-
i && /* @__PURE__ */ x(
|
|
300
|
+
i && /* @__PURE__ */ x(ae, {}),
|
|
301
301
|
c.map((t) => {
|
|
302
302
|
let n = d?.includes(t.key) ? p?.[t.key] : void 0;
|
|
303
303
|
if (n === "skip") return null;
|
|
304
304
|
let r = e[t.key];
|
|
305
305
|
return /* @__PURE__ */ x("td", {
|
|
306
306
|
rowSpan: typeof n == "number" ? n : void 0,
|
|
307
|
-
className:
|
|
308
|
-
style:
|
|
307
|
+
className: E("flexi-cell", !!l[t.key] && "flexi-cell--pinned", t.className),
|
|
308
|
+
style: I(u, t.key, !1, t.style),
|
|
309
309
|
children: t.render ? t.render(r, e) : /* @__PURE__ */ x("span", {
|
|
310
310
|
className: "flexi-cell-text",
|
|
311
311
|
children: r
|
|
312
312
|
})
|
|
313
313
|
}, t.key);
|
|
314
314
|
}),
|
|
315
|
-
a && o && /* @__PURE__ */ x(
|
|
315
|
+
a && o && /* @__PURE__ */ x(L, { children: o(e) })
|
|
316
316
|
]
|
|
317
317
|
});
|
|
318
318
|
}
|
|
319
|
-
function
|
|
320
|
-
let { hasGroups: r, hasActions: i, actions: a, pinnedBottomRowData: o, visibleLeafColumns: s, pinnedColumns: c, pinOffsets: l } =
|
|
319
|
+
function R({ record: e, index: t, className: n }) {
|
|
320
|
+
let { hasGroups: r, hasActions: i, actions: a, pinnedBottomRowData: o, visibleLeafColumns: s, pinnedColumns: c, pinOffsets: l } = T(), u = {
|
|
321
321
|
position: "sticky",
|
|
322
322
|
bottom: `${(o.length - 1 - t) * 48}px`,
|
|
323
323
|
zIndex: 45
|
|
324
324
|
};
|
|
325
325
|
return /* @__PURE__ */ S("tr", {
|
|
326
|
-
className:
|
|
326
|
+
className: E("flexi-row", "flexi-row--pinned-bottom", n),
|
|
327
327
|
style: u,
|
|
328
328
|
children: [
|
|
329
|
-
r && /* @__PURE__ */ x(
|
|
329
|
+
r && /* @__PURE__ */ x(ae, {}),
|
|
330
330
|
s.map((t) => {
|
|
331
331
|
let n = e[t.key], r = t.pinnedRender ?? t.render;
|
|
332
332
|
return /* @__PURE__ */ x("td", {
|
|
333
|
-
className:
|
|
334
|
-
style:
|
|
333
|
+
className: E("flexi-cell", !!c[t.key] && "flexi-cell--pinned", t.className),
|
|
334
|
+
style: I(l, t.key, !1, t.style),
|
|
335
335
|
children: r ? r(n, e) : /* @__PURE__ */ x("span", {
|
|
336
336
|
className: "flexi-cell-text",
|
|
337
337
|
children: n
|
|
338
338
|
})
|
|
339
339
|
}, t.key);
|
|
340
340
|
}),
|
|
341
|
-
i && a && /* @__PURE__ */ x(
|
|
341
|
+
i && a && /* @__PURE__ */ x(L, { children: a(e) })
|
|
342
342
|
]
|
|
343
343
|
});
|
|
344
344
|
}
|
|
345
345
|
//#endregion
|
|
346
346
|
//#region src/DataTable/components/PinnedBottomBody.tsx
|
|
347
|
-
function
|
|
348
|
-
let { pinnedBottomRowData: e, pinnedRowClassName: t } =
|
|
347
|
+
function ce() {
|
|
348
|
+
let { pinnedBottomRowData: e, pinnedRowClassName: t } = T();
|
|
349
349
|
return e.length === 0 ? null : /* @__PURE__ */ x("tbody", {
|
|
350
350
|
className: "flexi-tbody flexi-tbody--pinned-bottom",
|
|
351
|
-
children: e.map((e, n) => /* @__PURE__ */ x(
|
|
351
|
+
children: e.map((e, n) => /* @__PURE__ */ x(R, {
|
|
352
352
|
record: e,
|
|
353
353
|
index: n,
|
|
354
354
|
className: typeof t == "function" ? t(e, n) : t
|
|
@@ -357,22 +357,22 @@ function z() {
|
|
|
357
357
|
}
|
|
358
358
|
//#endregion
|
|
359
359
|
//#region src/DataTable/components/SettingsMenu.tsx
|
|
360
|
-
function
|
|
361
|
-
let { settingsMenu: e } =
|
|
360
|
+
function le() {
|
|
361
|
+
let { settingsMenu: e } = T();
|
|
362
362
|
return /* @__PURE__ */ x("button", {
|
|
363
363
|
type: "button",
|
|
364
364
|
ref: e.buttonRef,
|
|
365
365
|
onClick: (t) => {
|
|
366
366
|
t.stopPropagation(), e.toggle();
|
|
367
367
|
},
|
|
368
|
-
className:
|
|
368
|
+
className: E("flexi-icon-btn", e.isOpen && "flexi-settings-btn--active"),
|
|
369
369
|
title: "Grid display settings",
|
|
370
370
|
children: /* @__PURE__ */ x(f, { className: "flexi-icon-sm" })
|
|
371
371
|
});
|
|
372
372
|
}
|
|
373
|
-
function
|
|
374
|
-
let { gridRootRef: e, settingsMenu: t, displayPinnedIcon: n, toggleDisplayPinnedIcon: r,
|
|
375
|
-
return !t.isOpen || !t.position || !
|
|
373
|
+
function ue() {
|
|
374
|
+
let { gridRootRef: e, settingsMenu: t, displayPinnedIcon: n, toggleDisplayPinnedIcon: r, showGroupBy: i, toggleShowGroupBy: a, initialLeafColumns: o, hiddenColumns: s, toggleColumnVisibility: c, resetControlPanelDefaults: l } = T(), u = e.current;
|
|
375
|
+
return !t.isOpen || !t.position || !u ? null : C(/* @__PURE__ */ S("div", {
|
|
376
376
|
ref: t.menuRef,
|
|
377
377
|
className: "flexi-settings-menu",
|
|
378
378
|
style: {
|
|
@@ -383,21 +383,36 @@ function V() {
|
|
|
383
383
|
children: [
|
|
384
384
|
/* @__PURE__ */ S("div", {
|
|
385
385
|
className: "flexi-settings-section",
|
|
386
|
-
children: [
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
386
|
+
children: [
|
|
387
|
+
/* @__PURE__ */ x("span", {
|
|
388
|
+
className: "flexi-settings-heading",
|
|
389
|
+
children: "Action Icons"
|
|
390
|
+
}),
|
|
391
|
+
/* @__PURE__ */ S("label", {
|
|
392
|
+
className: "flexi-filter-option",
|
|
393
|
+
children: [/* @__PURE__ */ x("input", {
|
|
394
|
+
type: "checkbox",
|
|
395
|
+
className: "flexi-checkbox",
|
|
396
|
+
checked: n,
|
|
397
|
+
onChange: r
|
|
398
|
+
}), /* @__PURE__ */ x("span", {
|
|
399
|
+
className: "flexi-filter-option-text",
|
|
400
|
+
children: "Show pin icon on hover"
|
|
401
|
+
})]
|
|
402
|
+
}),
|
|
403
|
+
/* @__PURE__ */ S("label", {
|
|
404
|
+
className: "flexi-filter-option",
|
|
405
|
+
children: [/* @__PURE__ */ x("input", {
|
|
406
|
+
type: "checkbox",
|
|
407
|
+
className: "flexi-checkbox",
|
|
408
|
+
checked: i,
|
|
409
|
+
onChange: a
|
|
410
|
+
}), /* @__PURE__ */ x("span", {
|
|
411
|
+
className: "flexi-filter-option-text",
|
|
412
|
+
children: "Group By"
|
|
413
|
+
})]
|
|
414
|
+
})
|
|
415
|
+
]
|
|
401
416
|
}),
|
|
402
417
|
/* @__PURE__ */ x("div", { className: "flexi-settings-divider" }),
|
|
403
418
|
/* @__PURE__ */ S("div", {
|
|
@@ -405,13 +420,13 @@ function V() {
|
|
|
405
420
|
children: [/* @__PURE__ */ x("span", {
|
|
406
421
|
className: "flexi-settings-heading",
|
|
407
422
|
children: "Columns"
|
|
408
|
-
}),
|
|
423
|
+
}), o.map((e) => /* @__PURE__ */ S("label", {
|
|
409
424
|
className: "flexi-filter-option",
|
|
410
425
|
children: [/* @__PURE__ */ x("input", {
|
|
411
426
|
type: "checkbox",
|
|
412
427
|
className: "flexi-checkbox",
|
|
413
|
-
checked: !
|
|
414
|
-
onChange: () =>
|
|
428
|
+
checked: !s.includes(e.key),
|
|
429
|
+
onChange: () => c(e.key)
|
|
415
430
|
}), /* @__PURE__ */ x("span", {
|
|
416
431
|
className: "flexi-filter-option-text",
|
|
417
432
|
children: e.header
|
|
@@ -421,47 +436,47 @@ function V() {
|
|
|
421
436
|
/* @__PURE__ */ x("div", { className: "flexi-settings-divider" }),
|
|
422
437
|
/* @__PURE__ */ S("button", {
|
|
423
438
|
type: "button",
|
|
424
|
-
onClick:
|
|
439
|
+
onClick: l,
|
|
425
440
|
className: "flexi-settings-reset",
|
|
426
441
|
title: "Reset pin icon visibility and hidden columns to their defaults",
|
|
427
442
|
children: [/* @__PURE__ */ x(d, { className: "flexi-icon-sm" }), /* @__PURE__ */ x("span", { children: "Reset to defaults" })]
|
|
428
443
|
})
|
|
429
444
|
]
|
|
430
|
-
}),
|
|
445
|
+
}), u);
|
|
431
446
|
}
|
|
432
447
|
//#endregion
|
|
433
448
|
//#region src/DataTable/utils/records.ts
|
|
434
|
-
var
|
|
449
|
+
var z = (e, t, n) => n?.getValue ? n.getValue(e) : e[t], B = (e, t) => {
|
|
435
450
|
let n = typeof t == "function" ? t(e) : e[t];
|
|
436
451
|
return n == null ? void 0 : String(n);
|
|
437
|
-
},
|
|
452
|
+
}, V = (e, t, n) => {
|
|
438
453
|
if (!n) return;
|
|
439
454
|
let r;
|
|
440
455
|
for (let i in n) n[i](e, t) && (r = r ? `${r} ${i}` : i);
|
|
441
456
|
return r;
|
|
442
|
-
},
|
|
443
|
-
let r = e.map((e) =>
|
|
457
|
+
}, de = (e, t, n) => {
|
|
458
|
+
let r = e.map((e) => z(e, t, n));
|
|
444
459
|
return Array.from(new Set(r)).filter((e) => e != null);
|
|
445
|
-
},
|
|
460
|
+
}, fe = (e, t, n) => {
|
|
446
461
|
let r = Object.entries(t).filter(([, e]) => e && e.length > 0);
|
|
447
|
-
return r.length === 0 ? e : e.filter((e) => r.every(([t, r]) => r.includes(
|
|
448
|
-
},
|
|
462
|
+
return r.length === 0 ? e : e.filter((e) => r.every(([t, r]) => r.includes(z(e, t, n.get(t)))));
|
|
463
|
+
}, H = (e) => e == null || typeof e == "number" && Number.isNaN(e), pe = (e, t) => typeof e == "number" && typeof t == "number" ? e - t : e instanceof Date && t instanceof Date ? e.getTime() - t.getTime() : String(e).localeCompare(String(t), void 0, {
|
|
449
464
|
numeric: !0,
|
|
450
465
|
sensitivity: "base"
|
|
451
|
-
}),
|
|
452
|
-
let a =
|
|
466
|
+
}), me = (e, t, n, r) => [...e].sort((e, i) => {
|
|
467
|
+
let a = z(e, t, r), o = z(i, t, r);
|
|
453
468
|
if (a === o) return 0;
|
|
454
|
-
let s =
|
|
469
|
+
let s = H(a), c = H(o);
|
|
455
470
|
if (s && c) return 0;
|
|
456
471
|
if (s) return 1;
|
|
457
472
|
if (c) return -1;
|
|
458
|
-
let l =
|
|
473
|
+
let l = pe(a, o);
|
|
459
474
|
return n === "asc" ? l : -l;
|
|
460
475
|
});
|
|
461
476
|
//#endregion
|
|
462
477
|
//#region src/DataTable/components/TableBody.tsx
|
|
463
|
-
function
|
|
464
|
-
let { isLoading: e, visibleRows: t, startIndex: n, totalRowCount: r, topSpacerHeight: i, bottomSpacerHeight: a, totalColumnsCount: o, rowKey: s, rowClassRules: c } =
|
|
478
|
+
function U() {
|
|
479
|
+
let { isLoading: e, visibleRows: t, startIndex: n, totalRowCount: r, topSpacerHeight: i, bottomSpacerHeight: a, totalColumnsCount: o, rowKey: s, rowClassRules: c } = T(), l = Math.max(1, o);
|
|
465
480
|
return e || r === 0 ? /* @__PURE__ */ x("tbody", {
|
|
466
481
|
className: "flexi-tbody",
|
|
467
482
|
children: /* @__PURE__ */ x("tr", { children: /* @__PURE__ */ x("td", {
|
|
@@ -486,11 +501,11 @@ function ue() {
|
|
|
486
501
|
}),
|
|
487
502
|
t.map((e, t) => {
|
|
488
503
|
let r = n + t;
|
|
489
|
-
return e.kind === "group" ? /* @__PURE__ */ x(
|
|
504
|
+
return e.kind === "group" ? /* @__PURE__ */ x(oe, { node: e }, `group-header-${e.path}-${r}`) : /* @__PURE__ */ x(se, {
|
|
490
505
|
record: e.record,
|
|
491
506
|
rowIndex: r,
|
|
492
|
-
className:
|
|
493
|
-
},
|
|
507
|
+
className: V(e.record, r, c)
|
|
508
|
+
}, B(e.record, s) ?? `row-${r}`);
|
|
494
509
|
}),
|
|
495
510
|
a > 0 && /* @__PURE__ */ x("tr", {
|
|
496
511
|
"aria-hidden": "true",
|
|
@@ -509,21 +524,21 @@ function ue() {
|
|
|
509
524
|
}
|
|
510
525
|
//#endregion
|
|
511
526
|
//#region src/DataTable/components/TableColGroup.tsx
|
|
512
|
-
function
|
|
513
|
-
let { hasGroups: e, hasActions: t, visibleLeafColumns: n, columnWidths: r } =
|
|
527
|
+
function he() {
|
|
528
|
+
let { hasGroups: e, hasActions: t, visibleLeafColumns: n, columnWidths: r } = T();
|
|
514
529
|
return /* @__PURE__ */ S("colgroup", { children: [
|
|
515
530
|
e && /* @__PURE__ */ x("col", { style: { width: "48px" } }),
|
|
516
531
|
n.map((e) => /* @__PURE__ */ x("col", { style: {
|
|
517
532
|
...e.style,
|
|
518
|
-
width:
|
|
533
|
+
width: F(e, r)
|
|
519
534
|
} }, e.key)),
|
|
520
535
|
t && /* @__PURE__ */ x("col", { style: { width: "100px" } })
|
|
521
536
|
] });
|
|
522
537
|
}
|
|
523
538
|
//#endregion
|
|
524
539
|
//#region src/DataTable/components/FilterDropdown.tsx
|
|
525
|
-
function
|
|
526
|
-
let { gridRootRef: t, filters: n } =
|
|
540
|
+
function ge({ columnKey: e }) {
|
|
541
|
+
let { gridRootRef: t, filters: n } = T(), r = t.current, { filterPosition: i } = n;
|
|
527
542
|
if (!r || !i) return null;
|
|
528
543
|
let a = n.selectedFilters[e], o = (a?.length || 0) > 0, s = n.filteredUniqueValues;
|
|
529
544
|
return C(/* @__PURE__ */ S("div", {
|
|
@@ -578,55 +593,55 @@ function J({ columnKey: e }) {
|
|
|
578
593
|
}
|
|
579
594
|
//#endregion
|
|
580
595
|
//#region src/DataTable/components/HeaderCell.tsx
|
|
581
|
-
function
|
|
582
|
-
let { groupBy: o, pinnedColumns: s, pinOffsets: d, displayPinnedIcon: f, togglePin: p, sortState: m, handleSort: h, filters: g, handleDragStart: _, handleDragEnd: v, handleDrop: y, startResize: b } =
|
|
596
|
+
function _e({ col: r, rowSpan: i, colSpan: a }) {
|
|
597
|
+
let { groupBy: o, pinnedColumns: s, pinOffsets: d, displayPinnedIcon: f, togglePin: p, sortState: m, handleSort: h, filters: g, handleDragStart: _, handleDragEnd: v, handleDrop: y, startResize: b } = T(), C = s[r.key], w = !!C, ee = (g.selectedFilters[r.key]?.length || 0) > 0, D = !r.children || r.children.length === 0, O = m.key === r.key, te = o && D, k = D && r.resizable !== !1, A = !!r.sortable && D;
|
|
583
598
|
return /* @__PURE__ */ S("th", {
|
|
584
599
|
rowSpan: i,
|
|
585
600
|
colSpan: a,
|
|
586
601
|
draggable: !0,
|
|
587
|
-
onDragStart: (e) => _(e, r.key,
|
|
602
|
+
onDragStart: (e) => _(e, r.key, D),
|
|
588
603
|
onDragEnd: v,
|
|
589
604
|
onDragOver: (e) => e.preventDefault(),
|
|
590
605
|
onDrop: (e) => y(e, r.key),
|
|
591
|
-
className:
|
|
592
|
-
style:
|
|
606
|
+
className: E("flexi-th", "flexi-th--draggable", te && "flexi-th--group-draggable", w && "flexi-th--pinned", r.className, r.headerClassName),
|
|
607
|
+
style: I(d, r.key, !0, r.headerStyle),
|
|
593
608
|
children: [/* @__PURE__ */ S("div", {
|
|
594
609
|
className: "flexi-th-inner",
|
|
595
610
|
children: [
|
|
596
611
|
/* @__PURE__ */ S("div", {
|
|
597
|
-
className:
|
|
598
|
-
onClick: () =>
|
|
612
|
+
className: E("flexi-th-label", A && "flexi-th-label--sortable"),
|
|
613
|
+
onClick: () => A && h(r.key),
|
|
599
614
|
children: [/* @__PURE__ */ x("span", {
|
|
600
615
|
className: "flexi-th-text",
|
|
601
616
|
children: r.header
|
|
602
|
-
}),
|
|
603
|
-
className:
|
|
604
|
-
children:
|
|
617
|
+
}), A && /* @__PURE__ */ x("span", {
|
|
618
|
+
className: E("flexi-sort-icon", O && "flexi-sort-icon--active"),
|
|
619
|
+
children: O && m.direction === "asc" ? /* @__PURE__ */ x(t, { className: "flexi-icon-sm" }) : O && m.direction === "desc" ? /* @__PURE__ */ x(e, { className: "flexi-icon-sm" }) : /* @__PURE__ */ x(n, { className: "flexi-icon-sm" })
|
|
605
620
|
})]
|
|
606
621
|
}),
|
|
607
622
|
/* @__PURE__ */ S("div", {
|
|
608
623
|
className: "flexi-th-actions",
|
|
609
|
-
children: [
|
|
624
|
+
children: [D && r.filterable && /* @__PURE__ */ x("button", {
|
|
610
625
|
type: "button",
|
|
611
626
|
ref: (e) => g.registerFilterButton(r.key, e),
|
|
612
627
|
onClick: (e) => {
|
|
613
628
|
e.stopPropagation(), g.toggleFilterDropdown(r.key);
|
|
614
629
|
},
|
|
615
|
-
className:
|
|
630
|
+
className: E("flexi-icon-btn", "flexi-filter-btn", ee && "flexi-filter-btn--active"),
|
|
616
631
|
children: /* @__PURE__ */ x(c, { className: "flexi-icon-sm" })
|
|
617
|
-
}),
|
|
632
|
+
}), D && f && /* @__PURE__ */ x("button", {
|
|
618
633
|
type: "button",
|
|
619
634
|
onClick: (e) => {
|
|
620
635
|
e.stopPropagation(), p(r.key);
|
|
621
636
|
},
|
|
622
|
-
className:
|
|
637
|
+
className: E("flexi-icon-btn", "flexi-pin-btn", w && "flexi-pin-btn--pinned"),
|
|
623
638
|
title: C === "left" ? "Pinned left (click to pin right)" : C === "right" ? "Pinned right (click to unpin)" : "Pin column left",
|
|
624
639
|
children: x(w ? u : l, { className: "flexi-icon-sm" })
|
|
625
640
|
})]
|
|
626
641
|
}),
|
|
627
|
-
|
|
642
|
+
D && g.activeFilterKey === r.key && /* @__PURE__ */ x(ge, { columnKey: r.key })
|
|
628
643
|
]
|
|
629
|
-
}),
|
|
644
|
+
}), k && /* @__PURE__ */ x("div", {
|
|
630
645
|
className: "flexi-th-resizer",
|
|
631
646
|
onMouseDown: (e) => b(e, r),
|
|
632
647
|
onClick: (e) => e.stopPropagation(),
|
|
@@ -636,54 +651,40 @@ function Y({ col: r, rowSpan: i, colSpan: a }) {
|
|
|
636
651
|
}
|
|
637
652
|
//#endregion
|
|
638
653
|
//#region src/DataTable/components/TableHeader.tsx
|
|
639
|
-
function
|
|
640
|
-
let { headerRows: e, hasGroups: t
|
|
654
|
+
function ve() {
|
|
655
|
+
let { headerRows: e, hasGroups: t } = T();
|
|
641
656
|
return /* @__PURE__ */ x("thead", {
|
|
642
657
|
className: "flexi-thead",
|
|
643
|
-
children:
|
|
658
|
+
children: e.map((n, r) => /* @__PURE__ */ S("tr", {
|
|
644
659
|
className: "flexi-header-row",
|
|
645
|
-
children: [
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
}, e.key)),
|
|
662
|
-
n && i === 0 && /* @__PURE__ */ x("th", {
|
|
663
|
-
className: "flexi-actions-th flexi-th ",
|
|
664
|
-
style: {
|
|
665
|
-
right: 0,
|
|
666
|
-
zIndex: 55,
|
|
667
|
-
display: "flex",
|
|
668
|
-
justifyContent: "center",
|
|
669
|
-
alignItems: "center"
|
|
670
|
-
},
|
|
671
|
-
children: /* @__PURE__ */ x(B, {})
|
|
672
|
-
})
|
|
673
|
-
]
|
|
674
|
-
}, `header-row-${i}`))
|
|
660
|
+
children: [r === 0 && t && /* @__PURE__ */ x("th", {
|
|
661
|
+
rowSpan: e.length,
|
|
662
|
+
className: "flexi-group-spacer-th",
|
|
663
|
+
style: {
|
|
664
|
+
position: "sticky",
|
|
665
|
+
top: 0,
|
|
666
|
+
left: 0,
|
|
667
|
+
zIndex: 35,
|
|
668
|
+
backgroundColor: "rgb(248, 250, 252)"
|
|
669
|
+
}
|
|
670
|
+
}), n.map(({ col: e, rowSpan: t, colSpan: n }) => /* @__PURE__ */ x(_e, {
|
|
671
|
+
col: e,
|
|
672
|
+
rowSpan: t,
|
|
673
|
+
colSpan: n
|
|
674
|
+
}, e.key))]
|
|
675
|
+
}, `header-row-${r}`))
|
|
675
676
|
});
|
|
676
677
|
}
|
|
677
678
|
//#endregion
|
|
678
679
|
//#region src/DataTable/utils/grouping.ts
|
|
679
|
-
var
|
|
680
|
+
var ye = (e, t, n, r = 0, i = "") => {
|
|
680
681
|
if (r >= t.length) return e.map((e) => ({
|
|
681
682
|
kind: "record",
|
|
682
683
|
record: e
|
|
683
684
|
}));
|
|
684
685
|
let a = t[r], o = n.get(a), s = /* @__PURE__ */ new Map();
|
|
685
686
|
return e.forEach((e) => {
|
|
686
|
-
let t = String(
|
|
687
|
+
let t = String(z(e, a, o) ?? "N/A"), n = s.get(t);
|
|
687
688
|
n ? n.push(e) : s.set(t, [e]);
|
|
688
689
|
}), Array.from(s.entries()).sort(([e], [t]) => e.localeCompare(t, void 0, {
|
|
689
690
|
numeric: !0,
|
|
@@ -696,18 +697,18 @@ var pe = (e, t, n, r = 0, i = "") => {
|
|
|
696
697
|
groupValue: e,
|
|
697
698
|
path: s,
|
|
698
699
|
depth: r,
|
|
699
|
-
children:
|
|
700
|
+
children: ye(o, t, n, r + 1, s),
|
|
700
701
|
totalItemsCount: o.length
|
|
701
702
|
};
|
|
702
703
|
});
|
|
703
|
-
},
|
|
704
|
+
}, be = (e, t) => {
|
|
704
705
|
let n = [], r = (e) => {
|
|
705
706
|
e.forEach((e) => {
|
|
706
707
|
n.push(e), e.kind === "group" && t[e.path] !== !1 && r(e.children);
|
|
707
708
|
});
|
|
708
709
|
};
|
|
709
710
|
return r(e), n;
|
|
710
|
-
},
|
|
711
|
+
}, xe = (e, t, n, r) => {
|
|
711
712
|
let i = /* @__PURE__ */ new Map();
|
|
712
713
|
if (!t || t.length === 0) return i;
|
|
713
714
|
let a = e.map(() => t.map(() => !0)), o = null;
|
|
@@ -722,7 +723,7 @@ var pe = (e, t, n, r = 0, i = "") => {
|
|
|
722
723
|
let e = !0;
|
|
723
724
|
for (let o = 0; o < t.length; o++) {
|
|
724
725
|
let c = t[o], l = n.get(c);
|
|
725
|
-
e &&
|
|
726
|
+
e && z(i.record, c, l) === z(s.record, c, l) ? a[r][o] = !1 : (e = !1, a[r][o] = !0);
|
|
726
727
|
}
|
|
727
728
|
}
|
|
728
729
|
o = r;
|
|
@@ -750,7 +751,7 @@ var pe = (e, t, n, r = 0, i = "") => {
|
|
|
750
751
|
};
|
|
751
752
|
//#endregion
|
|
752
753
|
//#region src/DataTable/hooks/useAnchoredPosition.ts
|
|
753
|
-
function
|
|
754
|
+
function W({ active: e, resetKey: t, rootRef: n, getAnchor: r, compute: i }) {
|
|
754
755
|
let [a, o] = b(null), s = y(r), c = y(i);
|
|
755
756
|
return s.current = r, c.current = i, _(() => {
|
|
756
757
|
if (!e) {
|
|
@@ -772,7 +773,7 @@ function X({ active: e, resetKey: t, rootRef: n, getAnchor: r, compute: i }) {
|
|
|
772
773
|
}
|
|
773
774
|
//#endregion
|
|
774
775
|
//#region src/DataTable/hooks/useClickOutside.ts
|
|
775
|
-
function
|
|
776
|
+
function G(e, t, n) {
|
|
776
777
|
let r = y(t), i = y(n);
|
|
777
778
|
r.current = t, i.current = n, _(() => {
|
|
778
779
|
if (!e) return;
|
|
@@ -785,7 +786,7 @@ function Z(e, t, n) {
|
|
|
785
786
|
}
|
|
786
787
|
//#endregion
|
|
787
788
|
//#region src/DataTable/hooks/useColumnFilters.ts
|
|
788
|
-
function
|
|
789
|
+
function Se({ data: e, columnsByKey: t, gridRootRef: n }) {
|
|
789
790
|
let [r, i] = b(null), [a, o] = b({}), [s, c] = b(""), l = y(/* @__PURE__ */ new Map()), u = y(null), d = h((e, t) => {
|
|
790
791
|
t ? l.current.set(e, t) : l.current.delete(e);
|
|
791
792
|
}, []), f = h(() => {
|
|
@@ -793,8 +794,8 @@ function ge({ data: e, columnsByKey: t, gridRootRef: n }) {
|
|
|
793
794
|
}, []), p = h((e) => {
|
|
794
795
|
c(""), i((t) => t === e ? null : e);
|
|
795
796
|
}, []);
|
|
796
|
-
|
|
797
|
-
let m =
|
|
797
|
+
G(r !== null, () => [u.current, r ? l.current.get(r) : null], f);
|
|
798
|
+
let m = W({
|
|
798
799
|
active: r !== null,
|
|
799
800
|
resetKey: r,
|
|
800
801
|
rootRef: n,
|
|
@@ -816,7 +817,7 @@ function ge({ data: e, columnsByKey: t, gridRootRef: n }) {
|
|
|
816
817
|
let n = { ...t };
|
|
817
818
|
return delete n[e], n;
|
|
818
819
|
});
|
|
819
|
-
}, []), x = v(() => r ?
|
|
820
|
+
}, []), x = v(() => r ? de(e, r, t.get(r)) : [], [
|
|
820
821
|
e,
|
|
821
822
|
r,
|
|
822
823
|
t
|
|
@@ -841,8 +842,8 @@ function ge({ data: e, columnsByKey: t, gridRootRef: n }) {
|
|
|
841
842
|
}
|
|
842
843
|
//#endregion
|
|
843
844
|
//#region src/DataTable/hooks/useColumnReorder.ts
|
|
844
|
-
function
|
|
845
|
-
let [i, a] = b({}), o = y(null), s = v(() =>
|
|
845
|
+
function Ce({ columns: e, pinnedColumns: t, isResizingRef: n, onColumnReorder: r }) {
|
|
846
|
+
let [i, a] = b({}), o = y(null), s = v(() => N(e, t, i), [
|
|
846
847
|
e,
|
|
847
848
|
t,
|
|
848
849
|
i
|
|
@@ -863,14 +864,14 @@ function _e({ columns: e, pinnedColumns: t, isResizingRef: n, onColumnReorder: r
|
|
|
863
864
|
n.preventDefault(), n.stopPropagation();
|
|
864
865
|
let l = o.current;
|
|
865
866
|
if (o.current = null, !l || l === c) return;
|
|
866
|
-
let u =
|
|
867
|
+
let u = P(s, l, c);
|
|
867
868
|
if (!u) return;
|
|
868
869
|
let d = u.map((e) => e.key), f = d.indexOf(l), p = d.indexOf(c);
|
|
869
870
|
d.splice(p, 0, d.splice(f, 1)[0]);
|
|
870
871
|
let m = { ...i };
|
|
871
872
|
d.forEach((e, t) => {
|
|
872
873
|
m[e] = t;
|
|
873
|
-
}), a(m), r && r(
|
|
874
|
+
}), a(m), r && r(j(N(e, t, m)).map((e) => e.key));
|
|
874
875
|
}, [
|
|
875
876
|
s,
|
|
876
877
|
i,
|
|
@@ -882,14 +883,14 @@ function _e({ columns: e, pinnedColumns: t, isResizingRef: n, onColumnReorder: r
|
|
|
882
883
|
}
|
|
883
884
|
//#endregion
|
|
884
885
|
//#region src/DataTable/hooks/useColumnResize.ts
|
|
885
|
-
function
|
|
886
|
+
function we(e) {
|
|
886
887
|
let [t, n] = b({}), r = y(!1), i = y(null), a = y(e);
|
|
887
888
|
return a.current = e, _(() => () => i.current?.(), []), {
|
|
888
889
|
columnWidths: t,
|
|
889
890
|
isResizingRef: r,
|
|
890
891
|
startResize: h((e, o) => {
|
|
891
892
|
e.preventDefault(), e.stopPropagation(), i.current?.(), r.current = !0;
|
|
892
|
-
let s = e.clientX, c =
|
|
893
|
+
let s = e.clientX, c = F(o, t), l = o.minWidth ?? 60, u = o.maxWidth, d = t[o.key], f = (e) => {
|
|
893
894
|
let t = Math.max(l, c + (e.clientX - s));
|
|
894
895
|
u && (t = Math.min(u, t)), d = t, n((e) => e[o.key] === t ? e : {
|
|
895
896
|
...e,
|
|
@@ -910,7 +911,7 @@ function ve(e) {
|
|
|
910
911
|
}
|
|
911
912
|
//#endregion
|
|
912
913
|
//#region src/DataTable/hooks/useColumnVisibility.ts
|
|
913
|
-
function
|
|
914
|
+
function Te({ defaultHiddenColumns: e, defaultDisplayPinnedIcon: t, onColumnVisibilityChange: n }) {
|
|
914
915
|
let [r, i] = b(e), [a, o] = b(t);
|
|
915
916
|
return {
|
|
916
917
|
hiddenColumns: r,
|
|
@@ -931,7 +932,7 @@ function ye({ defaultHiddenColumns: e, defaultDisplayPinnedIcon: t, onColumnVisi
|
|
|
931
932
|
}
|
|
932
933
|
//#endregion
|
|
933
934
|
//#region src/DataTable/hooks/usePagination.ts
|
|
934
|
-
function
|
|
935
|
+
function Ee({ items: e, enabled: t, defaultPageSize: n, onPageChange: r, resetOn: i }) {
|
|
935
936
|
let [a, o] = b(1), [s, c] = b(Math.max(1, Math.floor(n) || 1)), l = e.length, u = t ? Math.max(1, Math.ceil(l / s)) : 1;
|
|
936
937
|
return _(() => {
|
|
937
938
|
o(1);
|
|
@@ -971,8 +972,8 @@ function be({ items: e, enabled: t, defaultPageSize: n, onPageChange: r, resetOn
|
|
|
971
972
|
}
|
|
972
973
|
//#endregion
|
|
973
974
|
//#region src/DataTable/hooks/usePinnedColumns.ts
|
|
974
|
-
function
|
|
975
|
-
let [n, r] = b(() =>
|
|
975
|
+
function De(e, t) {
|
|
976
|
+
let [n, r] = b(() => M(e));
|
|
976
977
|
return {
|
|
977
978
|
pinnedColumns: n,
|
|
978
979
|
togglePin: h((e) => {
|
|
@@ -983,7 +984,7 @@ function xe(e, t) {
|
|
|
983
984
|
}
|
|
984
985
|
//#endregion
|
|
985
986
|
//#region src/DataTable/hooks/useRowGrouping.ts
|
|
986
|
-
function
|
|
987
|
+
function Oe(e, t) {
|
|
987
988
|
let [n, r] = b(e), [i, a] = b({});
|
|
988
989
|
return {
|
|
989
990
|
groupedColumns: n,
|
|
@@ -1007,11 +1008,11 @@ function Se(e, t) {
|
|
|
1007
1008
|
}
|
|
1008
1009
|
//#endregion
|
|
1009
1010
|
//#region src/DataTable/hooks/useSettingsMenu.ts
|
|
1010
|
-
function
|
|
1011
|
+
function ke(e) {
|
|
1011
1012
|
let [t, n] = b(!1), r = y(null), i = y(null), a = h(() => n((e) => !e), []);
|
|
1012
|
-
return
|
|
1013
|
+
return G(t, () => [r.current, i.current], h(() => n(!1), [])), {
|
|
1013
1014
|
isOpen: t,
|
|
1014
|
-
position:
|
|
1015
|
+
position: W({
|
|
1015
1016
|
active: t,
|
|
1016
1017
|
rootRef: e,
|
|
1017
1018
|
getAnchor: () => i.current,
|
|
@@ -1027,7 +1028,7 @@ function Ce(e) {
|
|
|
1027
1028
|
}
|
|
1028
1029
|
//#endregion
|
|
1029
1030
|
//#region src/DataTable/hooks/useSorting.ts
|
|
1030
|
-
function
|
|
1031
|
+
function Ae() {
|
|
1031
1032
|
let [e, t] = b({
|
|
1032
1033
|
key: null,
|
|
1033
1034
|
direction: null
|
|
@@ -1047,7 +1048,7 @@ function we() {
|
|
|
1047
1048
|
}
|
|
1048
1049
|
//#endregion
|
|
1049
1050
|
//#region src/DataTable/hooks/useVirtualRows.ts
|
|
1050
|
-
function
|
|
1051
|
+
function je({ containerRef: e, totalRowCount: t, rowHeight: n, overscan: r }) {
|
|
1051
1052
|
let [i, a] = b(0), [o, s] = b(0);
|
|
1052
1053
|
return _(() => {
|
|
1053
1054
|
let t = e.current;
|
|
@@ -1082,119 +1083,125 @@ function Te({ containerRef: e, totalRowCount: t, rowHeight: n, overscan: r }) {
|
|
|
1082
1083
|
}
|
|
1083
1084
|
//#endregion
|
|
1084
1085
|
//#region src/DataTable/hooks/useDataTableState.ts
|
|
1085
|
-
function
|
|
1086
|
-
let
|
|
1086
|
+
function K({ columns: e, data: t, rowKey: n, actions: r, isLoading: i, groupBy: a = !1, defaultGroupBy: o = k, onPinChange: s, onGroupChange: c, pinnedBottomRowData: l = A, pinnedRowClassName: u, rowHeight: d = 40, overscan: f = 8, onColumnResize: p, onColumnReorder: m, rowClassRules: g, onRowClick: x, rowSpanColumns: S, controlPanel: C = !1, defaultDisplayPinnedIcon: w = !0, defaultHiddenColumns: ee = k, onColumnVisibilityChange: T, pagination: E = !1, defaultPageSize: D = 10, pageSizeOptions: O = te, onPageChange: ne }) {
|
|
1087
|
+
let M = y(null), N = y(null), P = v(() => j(e), [e]), F = v(() => {
|
|
1087
1088
|
let e = /* @__PURE__ */ new Map();
|
|
1088
|
-
return
|
|
1089
|
-
}, [
|
|
1089
|
+
return P.forEach((t) => e.set(t.key, t)), e;
|
|
1090
|
+
}, [P]), { pinnedColumns: I, togglePin: ae } = De(P, s), { columnWidths: L, isResizingRef: oe, startResize: se } = we(p), { reorderedColumns: R, handleDragStart: ce, handleDragEnd: le, handleDrop: ue } = Ce({
|
|
1090
1091
|
columns: e,
|
|
1091
|
-
pinnedColumns:
|
|
1092
|
-
isResizingRef:
|
|
1092
|
+
pinnedColumns: I,
|
|
1093
|
+
isResizingRef: oe,
|
|
1093
1094
|
onColumnReorder: m
|
|
1094
|
-
}), z =
|
|
1095
|
-
defaultHiddenColumns:
|
|
1096
|
-
defaultDisplayPinnedIcon:
|
|
1097
|
-
onColumnVisibilityChange:
|
|
1098
|
-
}), { hiddenColumns: B } = z, V =
|
|
1095
|
+
}), z = Te({
|
|
1096
|
+
defaultHiddenColumns: ee,
|
|
1097
|
+
defaultDisplayPinnedIcon: w,
|
|
1098
|
+
onColumnVisibilityChange: T
|
|
1099
|
+
}), { hiddenColumns: B } = z, V = Oe(o, c), { groupedColumns: de, expandedGroups: H } = V, [pe, U] = b(a);
|
|
1100
|
+
_(() => U(a), [a]);
|
|
1101
|
+
let he = h(() => U((e) => !e), []), { resetControlPanelDefaults: ge } = z, _e = h(() => {
|
|
1102
|
+
ge(), U(a);
|
|
1103
|
+
}, [ge, a]), ve = pe, W = ve ? de : k, G = W.length > 0, K = !!r, q = v(() => j(R).filter((e) => !W.includes(e.key) && !B.includes(e.key)), [
|
|
1099
1104
|
R,
|
|
1100
1105
|
W,
|
|
1101
1106
|
B
|
|
1102
|
-
]),
|
|
1107
|
+
]), Me = v(() => re(R, W, B), [
|
|
1103
1108
|
R,
|
|
1104
1109
|
W,
|
|
1105
1110
|
B
|
|
1106
|
-
]),
|
|
1111
|
+
]), Ne = v(() => ie({
|
|
1107
1112
|
visibleLeafColumns: q,
|
|
1108
|
-
pinnedColumns:
|
|
1109
|
-
columnWidths:
|
|
1113
|
+
pinnedColumns: I,
|
|
1114
|
+
columnWidths: L,
|
|
1110
1115
|
hasGroups: G,
|
|
1111
1116
|
hasActions: K
|
|
1112
1117
|
}), [
|
|
1113
1118
|
q,
|
|
1114
|
-
F,
|
|
1115
1119
|
I,
|
|
1120
|
+
L,
|
|
1116
1121
|
G,
|
|
1117
1122
|
K
|
|
1118
|
-
]), J =
|
|
1123
|
+
]), J = Se({
|
|
1119
1124
|
data: t,
|
|
1120
|
-
columnsByKey:
|
|
1121
|
-
gridRootRef:
|
|
1122
|
-
}), { sortState: Y, handleSort:
|
|
1125
|
+
columnsByKey: F,
|
|
1126
|
+
gridRootRef: M
|
|
1127
|
+
}), { sortState: Y, handleSort: Pe } = Ae(), X = Ee({
|
|
1123
1128
|
items: v(() => {
|
|
1124
|
-
let e =
|
|
1125
|
-
return !Y.key || !Y.direction ? e :
|
|
1129
|
+
let e = fe(t, J.selectedFilters, F);
|
|
1130
|
+
return !Y.key || !Y.direction ? e : me(e, Y.key, Y.direction, F.get(Y.key));
|
|
1126
1131
|
}, [
|
|
1127
1132
|
t,
|
|
1128
1133
|
J.selectedFilters,
|
|
1129
1134
|
Y,
|
|
1130
|
-
|
|
1135
|
+
F
|
|
1131
1136
|
]),
|
|
1132
|
-
enabled:
|
|
1133
|
-
defaultPageSize:
|
|
1134
|
-
onPageChange:
|
|
1137
|
+
enabled: E,
|
|
1138
|
+
defaultPageSize: D,
|
|
1139
|
+
onPageChange: ne,
|
|
1135
1140
|
resetOn: [J.selectedFilters, Y]
|
|
1136
|
-
}),
|
|
1141
|
+
}), Fe = v(() => ye(X.pagedItems, W, F), [
|
|
1137
1142
|
X.pagedItems,
|
|
1138
1143
|
W,
|
|
1139
|
-
|
|
1140
|
-
]),
|
|
1141
|
-
containerRef:
|
|
1142
|
-
totalRowCount:
|
|
1144
|
+
F
|
|
1145
|
+
]), Z = v(() => be(Fe, H), [Fe, H]), Ie = Z.length, { startIndex: Q, endIndex: Le, topSpacerHeight: Re, bottomSpacerHeight: ze } = je({
|
|
1146
|
+
containerRef: N,
|
|
1147
|
+
totalRowCount: Ie,
|
|
1143
1148
|
rowHeight: d,
|
|
1144
1149
|
overscan: f
|
|
1145
|
-
}),
|
|
1150
|
+
}), $ = v(() => Z.slice(Q, Le), [
|
|
1151
|
+
Z,
|
|
1146
1152
|
Q,
|
|
1153
|
+
Le
|
|
1154
|
+
]), Be = v(() => xe($, S, F, Q), [
|
|
1147
1155
|
$,
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
P,
|
|
1153
|
-
$
|
|
1154
|
-
]), Me = Ce(O), Ne = q.length + +!!K + +!!G;
|
|
1156
|
+
S,
|
|
1157
|
+
F,
|
|
1158
|
+
Q
|
|
1159
|
+
]), Ve = ke(M), He = q.length + +!!K + +!!G;
|
|
1155
1160
|
return {
|
|
1156
|
-
gridRootRef:
|
|
1157
|
-
tableWrapRef:
|
|
1161
|
+
gridRootRef: M,
|
|
1162
|
+
tableWrapRef: N,
|
|
1158
1163
|
rowKey: n,
|
|
1159
1164
|
actions: r,
|
|
1160
1165
|
isLoading: !!i,
|
|
1161
|
-
groupBy:
|
|
1162
|
-
|
|
1166
|
+
groupBy: ve,
|
|
1167
|
+
showGroupBy: pe,
|
|
1168
|
+
toggleShowGroupBy: he,
|
|
1169
|
+
controlPanel: C,
|
|
1163
1170
|
rowHeight: d,
|
|
1164
|
-
rowSpanColumns:
|
|
1165
|
-
rowClassRules:
|
|
1166
|
-
onRowClick:
|
|
1171
|
+
rowSpanColumns: S,
|
|
1172
|
+
rowClassRules: g,
|
|
1173
|
+
onRowClick: x,
|
|
1167
1174
|
pinnedBottomRowData: l,
|
|
1168
1175
|
pinnedRowClassName: u,
|
|
1169
|
-
pageSizeOptions:
|
|
1170
|
-
paginationEnabled:
|
|
1171
|
-
initialLeafColumns:
|
|
1172
|
-
columnsByKey:
|
|
1176
|
+
pageSizeOptions: O,
|
|
1177
|
+
paginationEnabled: E,
|
|
1178
|
+
initialLeafColumns: P,
|
|
1179
|
+
columnsByKey: F,
|
|
1173
1180
|
visibleLeafColumns: q,
|
|
1174
|
-
headerRows:
|
|
1175
|
-
pinnedColumns:
|
|
1176
|
-
pinOffsets:
|
|
1177
|
-
columnWidths:
|
|
1178
|
-
togglePin:
|
|
1179
|
-
startResize:
|
|
1180
|
-
handleDragStart:
|
|
1181
|
-
handleDragEnd:
|
|
1182
|
-
handleDrop:
|
|
1181
|
+
headerRows: Me,
|
|
1182
|
+
pinnedColumns: I,
|
|
1183
|
+
pinOffsets: Ne,
|
|
1184
|
+
columnWidths: L,
|
|
1185
|
+
togglePin: ae,
|
|
1186
|
+
startResize: se,
|
|
1187
|
+
handleDragStart: ce,
|
|
1188
|
+
handleDragEnd: le,
|
|
1189
|
+
handleDrop: ue,
|
|
1183
1190
|
hiddenColumns: B,
|
|
1184
1191
|
displayPinnedIcon: z.displayPinnedIcon,
|
|
1185
1192
|
toggleColumnVisibility: z.toggleColumnVisibility,
|
|
1186
1193
|
toggleDisplayPinnedIcon: z.toggleDisplayPinnedIcon,
|
|
1187
|
-
resetControlPanelDefaults:
|
|
1188
|
-
settingsMenu:
|
|
1189
|
-
groupedColumns:
|
|
1190
|
-
expandedGroups:
|
|
1194
|
+
resetControlPanelDefaults: _e,
|
|
1195
|
+
settingsMenu: Ve,
|
|
1196
|
+
groupedColumns: de,
|
|
1197
|
+
expandedGroups: H,
|
|
1191
1198
|
addGroup: V.addGroup,
|
|
1192
1199
|
removeGroup: V.removeGroup,
|
|
1193
1200
|
toggleGroupExpansion: V.toggleGroupExpansion,
|
|
1194
1201
|
hasGroups: G,
|
|
1195
1202
|
hasActions: K,
|
|
1196
1203
|
sortState: Y,
|
|
1197
|
-
handleSort:
|
|
1204
|
+
handleSort: Pe,
|
|
1198
1205
|
filters: J,
|
|
1199
1206
|
currentPage: X.currentPage,
|
|
1200
1207
|
pageSize: X.pageSize,
|
|
@@ -1202,46 +1209,52 @@ function Q({ columns: e, data: t, rowKey: n, actions: r, isLoading: i, groupBy:
|
|
|
1202
1209
|
totalCount: X.totalCount,
|
|
1203
1210
|
goToPage: X.goToPage,
|
|
1204
1211
|
changePageSize: X.changePageSize,
|
|
1205
|
-
visibleRows:
|
|
1206
|
-
startIndex:
|
|
1207
|
-
totalRowCount:
|
|
1208
|
-
topSpacerHeight:
|
|
1209
|
-
bottomSpacerHeight:
|
|
1210
|
-
rowSpanInfo:
|
|
1211
|
-
totalColumnsCount:
|
|
1212
|
+
visibleRows: $,
|
|
1213
|
+
startIndex: Q,
|
|
1214
|
+
totalRowCount: Ie,
|
|
1215
|
+
topSpacerHeight: Re,
|
|
1216
|
+
bottomSpacerHeight: ze,
|
|
1217
|
+
rowSpanInfo: Be,
|
|
1218
|
+
totalColumnsCount: He
|
|
1212
1219
|
};
|
|
1213
1220
|
}
|
|
1214
1221
|
//#endregion
|
|
1215
1222
|
//#region src/DataTable/DataTable.tsx
|
|
1216
|
-
function
|
|
1217
|
-
let t =
|
|
1218
|
-
return /* @__PURE__ */ x(
|
|
1223
|
+
function q(e) {
|
|
1224
|
+
let t = K(e), { containerStyle: n, tableStyle: r, bordered: i = !1 } = e;
|
|
1225
|
+
return /* @__PURE__ */ x(ee, {
|
|
1219
1226
|
value: t,
|
|
1220
1227
|
children: /* @__PURE__ */ S("div", {
|
|
1221
1228
|
ref: t.gridRootRef,
|
|
1222
1229
|
className: "flexi-root",
|
|
1223
1230
|
children: [
|
|
1224
|
-
t.groupBy && /* @__PURE__ */ x(
|
|
1225
|
-
/* @__PURE__ */
|
|
1231
|
+
t.groupBy && /* @__PURE__ */ x(D, {}),
|
|
1232
|
+
/* @__PURE__ */ S("div", {
|
|
1226
1233
|
ref: t.tableWrapRef,
|
|
1227
1234
|
className: "flexi-table-wrap",
|
|
1228
1235
|
style: n,
|
|
1229
|
-
children: /* @__PURE__ */
|
|
1230
|
-
className:
|
|
1236
|
+
children: [t.controlPanel && /* @__PURE__ */ x("div", {
|
|
1237
|
+
className: "flexi-settings-corner",
|
|
1238
|
+
children: /* @__PURE__ */ x("div", {
|
|
1239
|
+
className: "flexi-settings-corner-inner",
|
|
1240
|
+
children: /* @__PURE__ */ x(le, {})
|
|
1241
|
+
})
|
|
1242
|
+
}), /* @__PURE__ */ S("table", {
|
|
1243
|
+
className: E("flexi-table", i && "flexi-table--bordered"),
|
|
1231
1244
|
style: r,
|
|
1232
1245
|
children: [
|
|
1233
|
-
/* @__PURE__ */ x(
|
|
1234
|
-
/* @__PURE__ */ x(
|
|
1235
|
-
/* @__PURE__ */ x(
|
|
1236
|
-
/* @__PURE__ */ x(
|
|
1246
|
+
/* @__PURE__ */ x(he, {}),
|
|
1247
|
+
/* @__PURE__ */ x(ve, {}),
|
|
1248
|
+
/* @__PURE__ */ x(U, {}),
|
|
1249
|
+
/* @__PURE__ */ x(ce, {})
|
|
1237
1250
|
]
|
|
1238
|
-
})
|
|
1251
|
+
})]
|
|
1239
1252
|
}),
|
|
1240
|
-
/* @__PURE__ */ x(
|
|
1241
|
-
t.paginationEnabled && /* @__PURE__ */ x(
|
|
1253
|
+
/* @__PURE__ */ x(ue, {}),
|
|
1254
|
+
t.paginationEnabled && /* @__PURE__ */ x(O, {})
|
|
1242
1255
|
]
|
|
1243
1256
|
})
|
|
1244
1257
|
});
|
|
1245
1258
|
}
|
|
1246
1259
|
//#endregion
|
|
1247
|
-
export {
|
|
1260
|
+
export { q as DataTable };
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("lucide-react"),require("react"),require("react/jsx-runtime"),require("react-dom")):typeof define==`function`&&define.amd?define([`exports`,`lucide-react`,`react`,`react/jsx-runtime`,`react-dom`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.FlexiDataGrid={},e.LucideReact,e.React,e.JSX,e.ReactDOM))})(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var a=(0,n.createContext)(null);function o({value:e,children:t}){return(0,r.jsx)(a.Provider,{value:e,children:t})}function s(){let e=(0,n.useContext)(a);if(!e)throw Error(`DataTable components must be rendered inside <DataTable>.`);return e}var c=(...e)=>e.filter(Boolean).join(` `);function l(){let{groupedColumns:e,columnsByKey:i,addGroup:a,removeGroup:o}=s(),[l,u]=(0,n.useState)(!1);return(0,r.jsx)(`div`,{onDragOver:e=>{e.preventDefault(),u(!0)},onDragLeave:()=>u(!1),onDrop:e=>{e.preventDefault(),u(!1);let t=e.dataTransfer.getData(`text/plain`);t&&i.has(t)&&a(t)},className:c(`flexi-groupzone`,l&&`flexi-groupzone--dragover`),children:e.length===0?(0,r.jsx)(`span`,{className:`flexi-groupzone-hint`,children:`Drag a column header here to group your records by that field`}):(0,r.jsxs)(`div`,{className:`flexi-groupzone-chips`,children:[(0,r.jsx)(`span`,{className:`flexi-groupzone-label`,children:`Grouped By:`}),e.map(e=>(0,r.jsxs)(`div`,{className:`flexi-chip`,children:[(0,r.jsx)(`span`,{children:i.get(e)?.header||e}),(0,r.jsx)(`button`,{type:`button`,onClick:()=>o(e),className:`flexi-icon-btn flexi-chip-remove`,children:(0,r.jsx)(t.X,{className:`flexi-icon-xs`})})]},e))]})})}function u(){let{currentPage:e,pageSize:n,totalPages:i,totalCount:a,pageSizeOptions:o,goToPage:c,changePageSize:l}=s();return(0,r.jsxs)(`div`,{className:`flexi-pagination`,children:[(0,r.jsxs)(`div`,{className:`flexi-pagination-size`,children:[(0,r.jsx)(`span`,{children:`Rows per page`}),(0,r.jsx)(`select`,{value:n,onChange:e=>l(Number(e.target.value)),className:`flexi-pagination-select`,children:o.map(e=>(0,r.jsx)(`option`,{value:e,children:e},e))})]}),(0,r.jsx)(`div`,{className:`flexi-pagination-info`,children:a===0?`0 of 0`:`${(e-1)*n+1}–${Math.min(e*n,a)} of ${a}`}),(0,r.jsxs)(`div`,{className:`flexi-pagination-controls`,children:[(0,r.jsx)(`button`,{type:`button`,onClick:()=>c(1),disabled:e===1,className:`flexi-icon-btn`,title:`First page`,children:(0,r.jsx)(t.ChevronsLeft,{className:`flexi-icon-sm`})}),(0,r.jsx)(`button`,{type:`button`,onClick:()=>c(e-1),disabled:e===1,className:`flexi-icon-btn`,title:`Previous page`,children:(0,r.jsx)(t.ChevronLeft,{className:`flexi-icon-sm`})}),(0,r.jsxs)(`span`,{className:`flexi-pagination-page`,children:[`Page `,e,` of `,i]}),(0,r.jsx)(`button`,{type:`button`,onClick:()=>c(e+1),disabled:e===i,className:`flexi-icon-btn`,title:`Next page`,children:(0,r.jsx)(t.ChevronRight,{className:`flexi-icon-sm`})}),(0,r.jsx)(`button`,{type:`button`,onClick:()=>c(i),disabled:e===i,className:`flexi-icon-btn`,title:`Last page`,children:(0,r.jsx)(t.ChevronsRight,{className:`flexi-icon-sm`})})]})]})}var d=[10,25,50,100],f=[],p=[],m=e=>{let t=[];return e.forEach(e=>{e.children&&e.children.length>0?t.push(...m(e.children)):t.push(e)}),t},h=e=>{if(e===!0)return`left`;if(e===`left`||e===`right`)return e},g=e=>{let t={};return e.forEach(e=>{let n=h(e.pinned);n&&(t[e.key]=n)}),t},_=(e,t,n)=>{let r=e=>{let n=t[e];return n===`left`?0:n===`right`?2:1},i=e=>e.map((e,t)=>({col:e,idx:t})).sort((e,t)=>{let i=r(e.col.key)-r(t.col.key);return i===0?(n[e.col.key]??e.idx)-(n[t.col.key]??t.idx):i}).map(({col:e})=>e.children&&e.children.length>0?{...e,children:i(e.children)}:e);return i(e)},v=(e,t,n)=>{let r=e.map(e=>e.key);if(r.includes(t)&&r.includes(n))return e;for(let r of e)if(r.children&&r.children.length>0){let e=v(r.children,t,n);if(e)return e}return null},y=(e,t)=>{let n=t[e.key];if(n!==void 0)return n;let r=e.style?.width||e.headerStyle?.width||`150px`;if(typeof r==`number`)return r;let i=String(r).trim();return/^\d+(\.\d+)?(px)?$/i.test(i)&&parseInt(i,10)||150},b=(e,t,n)=>{let r=e=>{let t=0;return e.forEach(e=>{t=e.children&&e.children.length>0?Math.max(t,1+r(e.children)):Math.max(t,1)}),t},i=r(e),a=Array.from({length:i},()=>[]),o=e=>!e.children||e.children.length===0?t.includes(e.key)||n.includes(e.key)?0:1:e.children.reduce((e,t)=>e+o(t),0),s=(e,n)=>{e.forEach(e=>{if(t.includes(e.key))return;let r=o(e);r!==0&&(e.children&&e.children.length>0?(a[n].push({col:e,rowSpan:1,colSpan:r}),s(e.children,n+1)):a[n].push({col:e,rowSpan:i-n,colSpan:1}))})};s(e,0);let c=a.filter(e=>e.length>0);return c.map((e,t)=>e.map(e=>({...e,rowSpan:Math.min(e.rowSpan,c.length-t)})))},ee=({visibleLeafColumns:e,pinnedColumns:t,columnWidths:n,hasGroups:r,hasActions:i})=>{let a={},o=r?48:0;e.forEach(e=>{t[e.key]===`left`&&(a[e.key]={side:`left`,offset:o},o+=y(e,n))});let s=i?100:0;for(let r=e.length-1;r>=0;r--){let i=e[r];t[i.key]===`right`&&(a[i.key]={side:`right`,offset:s},s+=y(i,n))}return a},x=(e,t,n=!1,r)=>{let i=e[t];if(!i)return r||{};let a=i.side===`right`;return{position:`sticky`,[a?`right`:`left`]:`${i.offset}px`,...n?{top:0}:{},zIndex:n?30:20,background:`#f8fafc`,boxShadow:a?`-2px 0 5px -2px rgba(0,0,0,0.1)`:`2px 0 5px -2px rgba(0,0,0,0.1)`,...r}},S=()=>(0,r.jsx)(`td`,{className:`flexi-row-indent-cell`,style:{position:`sticky`,left:0,zIndex:10}});function C({children:e}){return(0,r.jsx)(`td`,{className:`flexi-actions-cell`,style:{position:`sticky`,right:0},children:(0,r.jsx)(`div`,{className:`flexi-actions-inner`,children:e})})}function w({node:e}){let{rowHeight:n,expandedGroups:i,toggleGroupExpansion:a,totalColumnsCount:o}=s(),c=i[e.path]!==!1;return(0,r.jsxs)(`tr`,{className:`flexi-group-row`,style:{height:n},children:[(0,r.jsx)(`td`,{className:`flexi-group-cell`,style:{position:`sticky`,left:0,zIndex:20,backgroundColor:`rgba(248, 250, 252, 0.9)`,paddingLeft:`${e.depth*12+16}px`},children:(0,r.jsxs)(`button`,{type:`button`,onClick:()=>a(e.path),className:`flexi-group-toggle`,children:[c?(0,r.jsx)(t.ChevronDown,{className:`flexi-icon-md flexi-icon-muted`}):(0,r.jsx)(t.ChevronRight,{className:`flexi-icon-md flexi-icon-muted`}),(0,r.jsx)(`span`,{className:`flexi-group-value`,children:e.groupValue}),(0,r.jsx)(`span`,{className:`flexi-group-count`,children:e.totalItemsCount})]})}),(0,r.jsx)(`td`,{colSpan:Math.max(1,o-1),className:`flexi-group-filler`})]})}function T({record:e,rowIndex:t,className:n}){let{rowHeight:i,hasGroups:a,hasActions:o,actions:l,onRowClick:u,visibleLeafColumns:d,pinnedColumns:f,pinOffsets:p,rowSpanColumns:m,rowSpanInfo:h}=s(),g=h.get(t);return(0,r.jsxs)(`tr`,{className:c(`flexi-row`,u&&`flexi-row--clickable`,n),style:{height:i},onClick:u?n=>u(e,t,n):void 0,children:[a&&(0,r.jsx)(S,{}),d.map(t=>{let n=m?.includes(t.key)?g?.[t.key]:void 0;if(n===`skip`)return null;let i=e[t.key];return(0,r.jsx)(`td`,{rowSpan:typeof n==`number`?n:void 0,className:c(`flexi-cell`,!!f[t.key]&&`flexi-cell--pinned`,t.className),style:x(p,t.key,!1,t.style),children:t.render?t.render(i,e):(0,r.jsx)(`span`,{className:`flexi-cell-text`,children:i})},t.key)}),o&&l&&(0,r.jsx)(C,{children:l(e)})]})}function E({record:e,index:t,className:n}){let{hasGroups:i,hasActions:a,actions:o,pinnedBottomRowData:l,visibleLeafColumns:u,pinnedColumns:d,pinOffsets:f}=s(),p={position:`sticky`,bottom:`${(l.length-1-t)*48}px`,zIndex:45};return(0,r.jsxs)(`tr`,{className:c(`flexi-row`,`flexi-row--pinned-bottom`,n),style:p,children:[i&&(0,r.jsx)(S,{}),u.map(t=>{let n=e[t.key],i=t.pinnedRender??t.render;return(0,r.jsx)(`td`,{className:c(`flexi-cell`,!!d[t.key]&&`flexi-cell--pinned`,t.className),style:x(f,t.key,!1,t.style),children:i?i(n,e):(0,r.jsx)(`span`,{className:`flexi-cell-text`,children:n})},t.key)}),a&&o&&(0,r.jsx)(C,{children:o(e)})]})}function te(){let{pinnedBottomRowData:e,pinnedRowClassName:t}=s();return e.length===0?null:(0,r.jsx)(`tbody`,{className:`flexi-tbody flexi-tbody--pinned-bottom`,children:e.map((e,n)=>(0,r.jsx)(E,{record:e,index:n,className:typeof t==`function`?t(e,n):t},`pinned-bottom-row-${n}`))})}function D(){let{settingsMenu:e}=s();return(0,r.jsx)(`button`,{type:`button`,ref:e.buttonRef,onClick:t=>{t.stopPropagation(),e.toggle()},className:c(`flexi-icon-btn`,e.isOpen&&`flexi-settings-btn--active`),title:`Grid display settings`,children:(0,r.jsx)(t.Settings,{className:`flexi-icon-sm`})})}function ne(){let{gridRootRef:e,settingsMenu:n,displayPinnedIcon:a,toggleDisplayPinnedIcon:o,initialLeafColumns:c,hiddenColumns:l,toggleColumnVisibility:u,resetControlPanelDefaults:d}=s(),f=e.current;return!n.isOpen||!n.position||!f?null:(0,i.createPortal)((0,r.jsxs)(`div`,{ref:n.menuRef,className:`flexi-settings-menu`,style:{top:n.position.top,right:n.position.right,zIndex:9999},children:[(0,r.jsxs)(`div`,{className:`flexi-settings-section`,children:[(0,r.jsx)(`span`,{className:`flexi-settings-heading`,children:`Action Icons`}),(0,r.jsxs)(`label`,{className:`flexi-filter-option`,children:[(0,r.jsx)(`input`,{type:`checkbox`,className:`flexi-checkbox`,checked:a,onChange:o}),(0,r.jsx)(`span`,{className:`flexi-filter-option-text`,children:`Show pin icon on hover`})]})]}),(0,r.jsx)(`div`,{className:`flexi-settings-divider`}),(0,r.jsxs)(`div`,{className:`flexi-settings-section`,children:[(0,r.jsx)(`span`,{className:`flexi-settings-heading`,children:`Columns`}),c.map(e=>(0,r.jsxs)(`label`,{className:`flexi-filter-option`,children:[(0,r.jsx)(`input`,{type:`checkbox`,className:`flexi-checkbox`,checked:!l.includes(e.key),onChange:()=>u(e.key)}),(0,r.jsx)(`span`,{className:`flexi-filter-option-text`,children:e.header})]},e.key))]}),(0,r.jsx)(`div`,{className:`flexi-settings-divider`}),(0,r.jsxs)(`button`,{type:`button`,onClick:d,className:`flexi-settings-reset`,title:`Reset pin icon visibility and hidden columns to their defaults`,children:[(0,r.jsx)(t.RotateCcw,{className:`flexi-icon-sm`}),(0,r.jsx)(`span`,{children:`Reset to defaults`})]})]}),f)}var O=(e,t,n)=>n?.getValue?n.getValue(e):e[t],re=(e,t)=>{let n=typeof t==`function`?t(e):e[t];return n==null?void 0:String(n)},k=(e,t,n)=>{if(!n)return;let r;for(let i in n)n[i](e,t)&&(r=r?`${r} ${i}`:i);return r},A=(e,t,n)=>{let r=e.map(e=>O(e,t,n));return Array.from(new Set(r)).filter(e=>e!=null)},ie=(e,t,n)=>{let r=Object.entries(t).filter(([,e])=>e&&e.length>0);return r.length===0?e:e.filter(e=>r.every(([t,r])=>r.includes(O(e,t,n.get(t)))))},j=e=>e==null||typeof e==`number`&&Number.isNaN(e),M=(e,t)=>typeof e==`number`&&typeof t==`number`?e-t:e instanceof Date&&t instanceof Date?e.getTime()-t.getTime():String(e).localeCompare(String(t),void 0,{numeric:!0,sensitivity:`base`}),ae=(e,t,n,r)=>[...e].sort((e,i)=>{let a=O(e,t,r),o=O(i,t,r);if(a===o)return 0;let s=j(a),c=j(o);if(s&&c)return 0;if(s)return 1;if(c)return-1;let l=M(a,o);return n===`asc`?l:-l});function N(){let{isLoading:e,visibleRows:t,startIndex:n,totalRowCount:i,topSpacerHeight:a,bottomSpacerHeight:o,totalColumnsCount:c,rowKey:l,rowClassRules:u}=s(),d=Math.max(1,c);return e||i===0?(0,r.jsx)(`tbody`,{className:`flexi-tbody`,children:(0,r.jsx)(`tr`,{children:(0,r.jsx)(`td`,{colSpan:d,className:`flexi-empty-cell`,children:e?`Loading records...`:`No records found matching criteria.`})})}):(0,r.jsxs)(`tbody`,{className:`flexi-tbody`,children:[a>0&&(0,r.jsx)(`tr`,{"aria-hidden":`true`,style:{height:a},children:(0,r.jsx)(`td`,{colSpan:d,style:{padding:0,border:`none`,height:a}})}),t.map((e,t)=>{let i=n+t;return e.kind===`group`?(0,r.jsx)(w,{node:e},`group-header-${e.path}-${i}`):(0,r.jsx)(T,{record:e.record,rowIndex:i,className:k(e.record,i,u)},re(e.record,l)??`row-${i}`)}),o>0&&(0,r.jsx)(`tr`,{"aria-hidden":`true`,style:{height:o},children:(0,r.jsx)(`td`,{colSpan:d,style:{padding:0,border:`none`,height:o}})})]})}function oe(){let{hasGroups:e,hasActions:t,visibleLeafColumns:n,columnWidths:i}=s();return(0,r.jsxs)(`colgroup`,{children:[e&&(0,r.jsx)(`col`,{style:{width:`48px`}}),n.map(e=>(0,r.jsx)(`col`,{style:{...e.style,width:y(e,i)}},e.key)),t&&(0,r.jsx)(`col`,{style:{width:`100px`}})]})}function P({columnKey:e}){let{gridRootRef:t,filters:n}=s(),a=t.current,{filterPosition:o}=n;if(!a||!o)return null;let c=n.selectedFilters[e],l=(c?.length||0)>0,u=n.filteredUniqueValues;return(0,i.createPortal)((0,r.jsxs)(`div`,{ref:n.dropdownRef,className:`flexi-filter-dropdown`,style:{top:o.top,left:o.left,zIndex:9999},children:[(0,r.jsx)(`div`,{className:`flexi-filter-search`,children:(0,r.jsx)(`input`,{type:`text`,placeholder:`Search values...`,value:n.filterSearchQuery,onChange:e=>n.setFilterSearchQuery(e.target.value),className:`flexi-input`,onClick:e=>e.stopPropagation()})}),(0,r.jsx)(`div`,{className:`flexi-filter-list`,children:u.length===0?(0,r.jsx)(`div`,{className:`flexi-filter-empty`,children:`No results found`}):u.map((t,i)=>(0,r.jsxs)(`label`,{className:`flexi-filter-option`,children:[(0,r.jsx)(`input`,{type:`checkbox`,className:`flexi-checkbox`,checked:c?.includes(t)||!1,onChange:()=>n.handleFilterChange(e,t)}),(0,r.jsx)(`span`,{className:`flexi-filter-option-text`,children:String(t)})]},i))}),l&&(0,r.jsx)(`div`,{className:`flexi-filter-footer`,children:(0,r.jsx)(`button`,{type:`button`,onClick:()=>n.clearFilter(e),className:`flexi-filter-clear`,children:`Clear Filter`})})]}),a)}function se({col:e,rowSpan:n,colSpan:i}){let{groupBy:a,pinnedColumns:o,pinOffsets:l,displayPinnedIcon:u,togglePin:d,sortState:f,handleSort:p,filters:m,handleDragStart:h,handleDragEnd:g,handleDrop:_,startResize:v}=s(),y=o[e.key],b=!!y,ee=(m.selectedFilters[e.key]?.length||0)>0,S=!e.children||e.children.length===0,C=f.key===e.key,w=a&&S,T=S&&e.resizable!==!1,E=!!e.sortable&&S;return(0,r.jsxs)(`th`,{rowSpan:n,colSpan:i,draggable:!0,onDragStart:t=>h(t,e.key,S),onDragEnd:g,onDragOver:e=>e.preventDefault(),onDrop:t=>_(t,e.key),className:c(`flexi-th`,`flexi-th--draggable`,w&&`flexi-th--group-draggable`,b&&`flexi-th--pinned`,e.className,e.headerClassName),style:x(l,e.key,!0,e.headerStyle),children:[(0,r.jsxs)(`div`,{className:`flexi-th-inner`,children:[(0,r.jsxs)(`div`,{className:c(`flexi-th-label`,E&&`flexi-th-label--sortable`),onClick:()=>E&&p(e.key),children:[(0,r.jsx)(`span`,{className:`flexi-th-text`,children:e.header}),E&&(0,r.jsx)(`span`,{className:c(`flexi-sort-icon`,C&&`flexi-sort-icon--active`),children:C&&f.direction===`asc`?(0,r.jsx)(t.ArrowUp,{className:`flexi-icon-sm`}):C&&f.direction===`desc`?(0,r.jsx)(t.ArrowDown,{className:`flexi-icon-sm`}):(0,r.jsx)(t.ArrowUpDown,{className:`flexi-icon-sm`})})]}),(0,r.jsxs)(`div`,{className:`flexi-th-actions`,children:[S&&e.filterable&&(0,r.jsx)(`button`,{type:`button`,ref:t=>m.registerFilterButton(e.key,t),onClick:t=>{t.stopPropagation(),m.toggleFilterDropdown(e.key)},className:c(`flexi-icon-btn`,`flexi-filter-btn`,ee&&`flexi-filter-btn--active`),children:(0,r.jsx)(t.Filter,{className:`flexi-icon-sm`})}),S&&u&&(0,r.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),d(e.key)},className:c(`flexi-icon-btn`,`flexi-pin-btn`,b&&`flexi-pin-btn--pinned`),title:y===`left`?`Pinned left (click to pin right)`:y===`right`?`Pinned right (click to unpin)`:`Pin column left`,children:b?(0,r.jsx)(t.PinOff,{className:`flexi-icon-sm`}):(0,r.jsx)(t.Pin,{className:`flexi-icon-sm`})})]}),S&&m.activeFilterKey===e.key&&(0,r.jsx)(P,{columnKey:e.key})]}),T&&(0,r.jsx)(`div`,{className:`flexi-th-resizer`,onMouseDown:t=>v(t,e),onClick:e=>e.stopPropagation(),onDragStart:e=>e.preventDefault()})]})}function ce(){let{headerRows:e,hasGroups:t,controlPanel:n}=s(),i=e.length===0&&n?[[]]:e;return(0,r.jsx)(`thead`,{className:`flexi-thead`,children:i.map((e,a)=>(0,r.jsxs)(`tr`,{className:`flexi-header-row`,children:[a===0&&t&&(0,r.jsx)(`th`,{rowSpan:i.length,className:`flexi-group-spacer-th`,style:{position:`sticky`,top:0,left:0,zIndex:35,backgroundColor:`rgb(248, 250, 252)`}}),e.map(({col:e,rowSpan:t,colSpan:n})=>(0,r.jsx)(se,{col:e,rowSpan:t,colSpan:n},e.key)),n&&a===0&&(0,r.jsx)(`th`,{className:`flexi-actions-th flexi-th `,style:{right:0,zIndex:55,display:`flex`,justifyContent:`center`,alignItems:`center`},children:(0,r.jsx)(D,{})})]},`header-row-${a}`))})}var F=(e,t,n,r=0,i=``)=>{if(r>=t.length)return e.map(e=>({kind:`record`,record:e}));let a=t[r],o=n.get(a),s=new Map;return e.forEach(e=>{let t=String(O(e,a,o)??`N/A`),n=s.get(t);n?n.push(e):s.set(t,[e])}),Array.from(s.entries()).sort(([e],[t])=>e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})).map(([e,o])=>{let s=i?`${i}➔${e}`:e;return{kind:`group`,groupKey:a,groupValue:e,path:s,depth:r,children:F(o,t,n,r+1,s),totalItemsCount:o.length}})},le=(e,t)=>{let n=[],r=e=>{e.forEach(e=>{n.push(e),e.kind===`group`&&t[e.path]!==!1&&r(e.children)})};return r(e),n},ue=(e,t,n,r)=>{let i=new Map;if(!t||t.length===0)return i;let a=e.map(()=>t.map(()=>!0)),o=null;for(let r=0;r<e.length;r++){let i=e[r];if(i.kind===`group`){o=null;continue}let s=o===null?null:e[o];if(s&&s.kind===`record`){let e=!0;for(let o=0;o<t.length;o++){let c=t[o],l=n.get(c);e&&O(i.record,c,l)===O(s.record,c,l)?a[r][o]=!1:(e=!1,a[r][o]=!0)}}o=r}return t.forEach((t,n)=>{let o=0;for(;o<e.length;){if(e[o].kind===`group`||!a[o][n]){o++;continue}let s=o+1;for(;s<e.length&&e[s].kind!==`group`&&!a[s][n];)s++;if(s-o>1){let e=i.get(r+o)||{};e[t]=s-o,i.set(r+o,e);for(let e=o+1;e<s;e++){let n=i.get(r+e)||{};n[t]=`skip`,i.set(r+e,n)}}o=s}}),i};function I({active:e,resetKey:t,rootRef:r,getAnchor:i,compute:a}){let[o,s]=(0,n.useState)(null),c=(0,n.useRef)(i),l=(0,n.useRef)(a);return c.current=i,l.current=a,(0,n.useEffect)(()=>{if(!e){s(null);return}let t=()=>{let e=c.current(),t=r.current;!e||!t||s(l.current(e.getBoundingClientRect(),t.getBoundingClientRect()))};return t(),window.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t),()=>{window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t)}},[e,t,r]),o}function L(e,t,r){let i=(0,n.useRef)(t),a=(0,n.useRef)(r);i.current=t,a.current=r,(0,n.useEffect)(()=>{if(!e)return;let t=e=>{let t=e.target,[n,...r]=i.current();n&&(n.contains(t)||r.some(e=>e?.contains(t))||a.current())};return document.addEventListener(`mousedown`,t),()=>document.removeEventListener(`mousedown`,t)},[e])}function de({data:e,columnsByKey:t,gridRootRef:r}){let[i,a]=(0,n.useState)(null),[o,s]=(0,n.useState)({}),[c,l]=(0,n.useState)(``),u=(0,n.useRef)(new Map),d=(0,n.useRef)(null),f=(0,n.useCallback)((e,t)=>{t?u.current.set(e,t):u.current.delete(e)},[]),p=(0,n.useCallback)(()=>{a(null),l(``)},[]),m=(0,n.useCallback)(e=>{l(``),a(t=>t===e?null:e)},[]);L(i!==null,()=>[d.current,i?u.current.get(i):null],p);let h=I({active:i!==null,resetKey:i,rootRef:r,getAnchor:()=>i?u.current.get(i):null,compute:(e,t)=>({top:e.bottom-t.top+4,left:e.left-t.left})}),g=(0,n.useCallback)((e,t)=>{s(n=>{let r=n[e]||[],i=r.includes(t)?r.filter(e=>e!==t):[...r,t],a={...n,[e]:i};return i.length===0&&delete a[e],a})},[]),_=(0,n.useCallback)(e=>{s(t=>{let n={...t};return delete n[e],n})},[]),v=(0,n.useMemo)(()=>i?A(e,i,t.get(i)):[],[e,i,t]);return{activeFilterKey:i,selectedFilters:o,filterSearchQuery:c,setFilterSearchQuery:l,filterPosition:h,dropdownRef:d,filteredUniqueValues:(0,n.useMemo)(()=>{if(!c.trim())return v;let e=c.toLowerCase();return v.filter(t=>String(t).toLowerCase().includes(e))},[v,c]),registerFilterButton:f,toggleFilterDropdown:m,handleFilterChange:g,clearFilter:_}}function fe({columns:e,pinnedColumns:t,isResizingRef:r,onColumnReorder:i}){let[a,o]=(0,n.useState)({}),s=(0,n.useRef)(null),c=(0,n.useMemo)(()=>_(e,t,a),[e,t,a]);return{reorderedColumns:c,handleDragStart:(0,n.useCallback)((e,t,n)=>{if(r.current){e.preventDefault();return}s.current=t,n&&e.dataTransfer.setData(`text/plain`,t),e.dataTransfer.effectAllowed=`move`},[r]),handleDragEnd:(0,n.useCallback)(()=>{s.current=null},[]),handleDrop:(0,n.useCallback)((n,r)=>{n.preventDefault(),n.stopPropagation();let l=s.current;if(s.current=null,!l||l===r)return;let u=v(c,l,r);if(!u)return;let d=u.map(e=>e.key),f=d.indexOf(l),p=d.indexOf(r);d.splice(p,0,d.splice(f,1)[0]);let h={...a};d.forEach((e,t)=>{h[e]=t}),o(h),i&&i(m(_(e,t,h)).map(e=>e.key))},[c,a,e,t,i])}}function pe(e){let[t,r]=(0,n.useState)({}),i=(0,n.useRef)(!1),a=(0,n.useRef)(null),o=(0,n.useRef)(e);return o.current=e,(0,n.useEffect)(()=>()=>a.current?.(),[]),{columnWidths:t,isResizingRef:i,startResize:(0,n.useCallback)((e,n)=>{e.preventDefault(),e.stopPropagation(),a.current?.(),i.current=!0;let s=e.clientX,c=y(n,t),l=n.minWidth??60,u=n.maxWidth,d=t[n.key],f=e=>{let t=Math.max(l,c+(e.clientX-s));u&&(t=Math.min(u,t)),d=t,r(e=>e[n.key]===t?e:{...e,[n.key]:t})},p=()=>{window.removeEventListener(`mousemove`,f),window.removeEventListener(`mouseup`,m),a.current=null},m=()=>{p(),requestAnimationFrame(()=>{i.current=!1}),d!==void 0&&o.current?.(n.key,d)};window.addEventListener(`mousemove`,f),window.addEventListener(`mouseup`,m),a.current=()=>{p(),i.current=!1}},[t])}}function me({defaultHiddenColumns:e,defaultDisplayPinnedIcon:t,onColumnVisibilityChange:r}){let[i,a]=(0,n.useState)(e),[o,s]=(0,n.useState)(t);return{hiddenColumns:i,displayPinnedIcon:o,toggleColumnVisibility:(0,n.useCallback)(e=>{let t=i.includes(e)?i.filter(t=>t!==e):[...i,e];a(t),r?.(t)},[i,r]),toggleDisplayPinnedIcon:(0,n.useCallback)(()=>s(e=>!e),[]),resetControlPanelDefaults:(0,n.useCallback)(()=>{s(t),a(e),r?.(e)},[t,e,r])}}function he({items:e,enabled:t,defaultPageSize:r,onPageChange:i,resetOn:a}){let[o,s]=(0,n.useState)(1),[c,l]=(0,n.useState)(Math.max(1,Math.floor(r)||1)),u=e.length,d=t?Math.max(1,Math.ceil(u/c)):1;return(0,n.useEffect)(()=>{s(1)},[...a,c,t]),(0,n.useEffect)(()=>{o>d&&s(d)},[o,d]),{currentPage:o,pageSize:c,totalPages:d,totalCount:u,pagedItems:(0,n.useMemo)(()=>{if(!t)return e;let n=(o-1)*c;return e.slice(n,n+c)},[e,t,o,c]),goToPage:(0,n.useCallback)(e=>{let t=Math.min(Math.max(1,e),d);s(t),i?.(t,c)},[d,c,i]),changePageSize:(0,n.useCallback)(e=>{l(e),s(1),i?.(1,e)},[i])}}function ge(e,t){let[r,i]=(0,n.useState)(()=>g(e));return{pinnedColumns:r,togglePin:(0,n.useCallback)(e=>{let n=r[e],a=n?n===`left`?`right`:void 0:`left`,o={...r};a?o[e]=a:delete o[e],i(o),t?.(e,!!a,a)},[r,t])}}function _e(e,t){let[r,i]=(0,n.useState)(e),[a,o]=(0,n.useState)({});return{groupedColumns:r,expandedGroups:a,addGroup:(0,n.useCallback)(e=>{if(!e||r.includes(e))return;let n=[...r,e];i(n),t?.(n)},[r,t]),removeGroup:(0,n.useCallback)(e=>{let n=r.filter(t=>t!==e);i(n),o({}),t?.(n)},[r,t]),toggleGroupExpansion:(0,n.useCallback)(e=>{o(t=>({...t,[e]:t[e]===!1}))},[])}}function ve(e){let[t,r]=(0,n.useState)(!1),i=(0,n.useRef)(null),a=(0,n.useRef)(null),o=(0,n.useCallback)(()=>r(e=>!e),[]);return L(t,()=>[i.current,a.current],(0,n.useCallback)(()=>r(!1),[])),{isOpen:t,position:I({active:t,rootRef:e,getAnchor:()=>a.current,compute:(e,t)=>({top:e.bottom-t.top+4,right:t.right-e.right})}),menuRef:i,buttonRef:a,toggle:o}}function ye(){let[e,t]=(0,n.useState)({key:null,direction:null});return{sortState:e,handleSort:(0,n.useCallback)(e=>{t(t=>{let n=`asc`;return t.key===e&&(t.direction===`asc`?n=`desc`:t.direction===`desc`&&(n=null)),{key:n?e:null,direction:n}})},[])}}function be({containerRef:e,totalRowCount:t,rowHeight:r,overscan:i}){let[a,o]=(0,n.useState)(0),[s,c]=(0,n.useState)(0);return(0,n.useEffect)(()=>{let t=e.current;if(!t)return;let n=()=>o(t.scrollTop);c(t.clientHeight),o(t.scrollTop),t.addEventListener(`scroll`,n,{passive:!0});let r;return typeof ResizeObserver<`u`&&(r=new ResizeObserver(()=>c(t.clientHeight)),r.observe(t)),()=>{t.removeEventListener(`scroll`,n),r?.disconnect()}},[e]),(0,n.useMemo)(()=>{if(s===0)return{startIndex:0,endIndex:t,topSpacerHeight:0,bottomSpacerHeight:0};let e=r>0?r:1,n=Math.max(0,t-1),o=Math.min(n,Math.floor(a/e)),c=Math.ceil(s/e)+1,l=Math.max(0,o-i),u=Math.min(t,o+c+i);return{startIndex:l,endIndex:u,topSpacerHeight:l*e,bottomSpacerHeight:(t-u)*e}},[a,s,t,r,i])}function R({columns:e,data:t,rowKey:r,actions:i,isLoading:a,groupBy:o=!1,defaultGroupBy:s=f,onPinChange:c,onGroupChange:l,pinnedBottomRowData:u=p,pinnedRowClassName:h,rowHeight:g=48,overscan:_=8,onColumnResize:v,onColumnReorder:y,rowClassRules:x,onRowClick:S,rowSpanColumns:C,controlPanel:w=!1,defaultDisplayPinnedIcon:T=!0,defaultHiddenColumns:E=f,onColumnVisibilityChange:te,pagination:D=!1,defaultPageSize:ne=10,pageSizeOptions:O=d,onPageChange:re}){let k=(0,n.useRef)(null),A=(0,n.useRef)(null),j=(0,n.useMemo)(()=>m(e),[e]),M=(0,n.useMemo)(()=>{let e=new Map;return j.forEach(t=>e.set(t.key,t)),e},[j]),{pinnedColumns:N,togglePin:oe}=ge(j,c),{columnWidths:P,isResizingRef:se,startResize:ce}=pe(v),{reorderedColumns:I,handleDragStart:L,handleDragEnd:R,handleDrop:xe}=fe({columns:e,pinnedColumns:N,isResizingRef:se,onColumnReorder:y}),z=me({defaultHiddenColumns:E,defaultDisplayPinnedIcon:T,onColumnVisibilityChange:te}),{hiddenColumns:B}=z,V=_e(s,l),{groupedColumns:Se,expandedGroups:H}=V,U=o?Se:f,W=U.length>0,G=!!i,K=(0,n.useMemo)(()=>m(I).filter(e=>!U.includes(e.key)&&!B.includes(e.key)),[I,U,B]),Ce=(0,n.useMemo)(()=>b(I,U,B),[I,U,B]),we=(0,n.useMemo)(()=>ee({visibleLeafColumns:K,pinnedColumns:N,columnWidths:P,hasGroups:W,hasActions:G}),[K,N,P,W,G]),q=de({data:t,columnsByKey:M,gridRootRef:k}),{sortState:J,handleSort:Te}=ye(),Y=he({items:(0,n.useMemo)(()=>{let e=ie(t,q.selectedFilters,M);return!J.key||!J.direction?e:ae(e,J.key,J.direction,M.get(J.key))},[t,q.selectedFilters,J,M]),enabled:D,defaultPageSize:ne,onPageChange:re,resetOn:[q.selectedFilters,J]}),Ee=(0,n.useMemo)(()=>F(Y.pagedItems,U,M),[Y.pagedItems,U,M]),X=(0,n.useMemo)(()=>le(Ee,H),[Ee,H]),De=X.length,{startIndex:Z,endIndex:Q,topSpacerHeight:Oe,bottomSpacerHeight:ke}=be({containerRef:A,totalRowCount:De,rowHeight:g,overscan:_}),$=(0,n.useMemo)(()=>X.slice(Z,Q),[X,Z,Q]),Ae=(0,n.useMemo)(()=>ue($,C,M,Z),[$,C,M,Z]),je=ve(k),Me=K.length+ +!!G+ +!!W;return{gridRootRef:k,tableWrapRef:A,rowKey:r,actions:i,isLoading:!!a,groupBy:o,controlPanel:w,rowHeight:g,rowSpanColumns:C,rowClassRules:x,onRowClick:S,pinnedBottomRowData:u,pinnedRowClassName:h,pageSizeOptions:O,paginationEnabled:D,initialLeafColumns:j,columnsByKey:M,visibleLeafColumns:K,headerRows:Ce,pinnedColumns:N,pinOffsets:we,columnWidths:P,togglePin:oe,startResize:ce,handleDragStart:L,handleDragEnd:R,handleDrop:xe,hiddenColumns:B,displayPinnedIcon:z.displayPinnedIcon,toggleColumnVisibility:z.toggleColumnVisibility,toggleDisplayPinnedIcon:z.toggleDisplayPinnedIcon,resetControlPanelDefaults:z.resetControlPanelDefaults,settingsMenu:je,groupedColumns:Se,expandedGroups:H,addGroup:V.addGroup,removeGroup:V.removeGroup,toggleGroupExpansion:V.toggleGroupExpansion,hasGroups:W,hasActions:G,sortState:J,handleSort:Te,filters:q,currentPage:Y.currentPage,pageSize:Y.pageSize,totalPages:Y.totalPages,totalCount:Y.totalCount,goToPage:Y.goToPage,changePageSize:Y.changePageSize,visibleRows:$,startIndex:Z,totalRowCount:De,topSpacerHeight:Oe,bottomSpacerHeight:ke,rowSpanInfo:Ae,totalColumnsCount:Me}}function xe(e){let t=R(e),{containerStyle:n,tableStyle:i,bordered:a=!1}=e;return(0,r.jsx)(o,{value:t,children:(0,r.jsxs)(`div`,{ref:t.gridRootRef,className:`flexi-root`,children:[t.groupBy&&(0,r.jsx)(l,{}),(0,r.jsx)(`div`,{ref:t.tableWrapRef,className:`flexi-table-wrap`,style:n,children:(0,r.jsxs)(`table`,{className:c(`flexi-table`,a&&`flexi-table--bordered`),style:i,children:[(0,r.jsx)(oe,{}),(0,r.jsx)(ce,{}),(0,r.jsx)(N,{}),(0,r.jsx)(te,{})]})}),(0,r.jsx)(ne,{}),t.paginationEnabled&&(0,r.jsx)(u,{})]})})}e.DataTable=xe});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("lucide-react"),require("react"),require("react/jsx-runtime"),require("react-dom")):typeof define==`function`&&define.amd?define([`exports`,`lucide-react`,`react`,`react/jsx-runtime`,`react-dom`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.FlexiDataGrid={},e.LucideReact,e.React,e.JSX,e.ReactDOM))})(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var a=(0,n.createContext)(null);function o({value:e,children:t}){return(0,r.jsx)(a.Provider,{value:e,children:t})}function s(){let e=(0,n.useContext)(a);if(!e)throw Error(`DataTable components must be rendered inside <DataTable>.`);return e}var c=(...e)=>e.filter(Boolean).join(` `);function l(){let{groupedColumns:e,columnsByKey:i,addGroup:a,removeGroup:o}=s(),[l,u]=(0,n.useState)(!1);return(0,r.jsx)(`div`,{onDragOver:e=>{e.preventDefault(),u(!0)},onDragLeave:()=>u(!1),onDrop:e=>{e.preventDefault(),u(!1);let t=e.dataTransfer.getData(`text/plain`);t&&i.has(t)&&a(t)},className:c(`flexi-groupzone`,l&&`flexi-groupzone--dragover`),children:e.length===0?(0,r.jsx)(`span`,{className:`flexi-groupzone-hint`,children:`Drag a column header here to group your records by that field`}):(0,r.jsxs)(`div`,{className:`flexi-groupzone-chips`,children:[(0,r.jsx)(`span`,{className:`flexi-groupzone-label`,children:`Grouped By:`}),e.map(e=>(0,r.jsxs)(`div`,{className:`flexi-chip`,children:[(0,r.jsx)(`span`,{children:i.get(e)?.header||e}),(0,r.jsx)(`button`,{type:`button`,onClick:()=>o(e),className:`flexi-icon-btn flexi-chip-remove`,children:(0,r.jsx)(t.X,{className:`flexi-icon-xs`})})]},e))]})})}function u(){let{currentPage:e,pageSize:n,totalPages:i,totalCount:a,pageSizeOptions:o,goToPage:c,changePageSize:l}=s();return(0,r.jsxs)(`div`,{className:`flexi-pagination`,children:[(0,r.jsxs)(`div`,{className:`flexi-pagination-size`,children:[(0,r.jsx)(`span`,{children:`Rows per page`}),(0,r.jsx)(`select`,{value:n,onChange:e=>l(Number(e.target.value)),className:`flexi-pagination-select`,children:o.map(e=>(0,r.jsx)(`option`,{value:e,children:e},e))})]}),(0,r.jsx)(`div`,{className:`flexi-pagination-info`,children:a===0?`0 of 0`:`${(e-1)*n+1}–${Math.min(e*n,a)} of ${a}`}),(0,r.jsxs)(`div`,{className:`flexi-pagination-controls`,children:[(0,r.jsx)(`button`,{type:`button`,onClick:()=>c(1),disabled:e===1,className:`flexi-icon-btn`,title:`First page`,children:(0,r.jsx)(t.ChevronsLeft,{className:`flexi-icon-sm`})}),(0,r.jsx)(`button`,{type:`button`,onClick:()=>c(e-1),disabled:e===1,className:`flexi-icon-btn`,title:`Previous page`,children:(0,r.jsx)(t.ChevronLeft,{className:`flexi-icon-sm`})}),(0,r.jsxs)(`span`,{className:`flexi-pagination-page`,children:[`Page `,e,` of `,i]}),(0,r.jsx)(`button`,{type:`button`,onClick:()=>c(e+1),disabled:e===i,className:`flexi-icon-btn`,title:`Next page`,children:(0,r.jsx)(t.ChevronRight,{className:`flexi-icon-sm`})}),(0,r.jsx)(`button`,{type:`button`,onClick:()=>c(i),disabled:e===i,className:`flexi-icon-btn`,title:`Last page`,children:(0,r.jsx)(t.ChevronsRight,{className:`flexi-icon-sm`})})]})]})}var d=[10,25,50,100],f=[],p=[],m=e=>{let t=[];return e.forEach(e=>{e.children&&e.children.length>0?t.push(...m(e.children)):t.push(e)}),t},h=e=>{if(e===!0)return`left`;if(e===`left`||e===`right`)return e},g=e=>{let t={};return e.forEach(e=>{let n=h(e.pinned);n&&(t[e.key]=n)}),t},_=(e,t,n)=>{let r=e=>{let n=t[e];return n===`left`?0:n===`right`?2:1},i=e=>e.map((e,t)=>({col:e,idx:t})).sort((e,t)=>{let i=r(e.col.key)-r(t.col.key);return i===0?(n[e.col.key]??e.idx)-(n[t.col.key]??t.idx):i}).map(({col:e})=>e.children&&e.children.length>0?{...e,children:i(e.children)}:e);return i(e)},v=(e,t,n)=>{let r=e.map(e=>e.key);if(r.includes(t)&&r.includes(n))return e;for(let r of e)if(r.children&&r.children.length>0){let e=v(r.children,t,n);if(e)return e}return null},y=(e,t)=>{let n=t[e.key];if(n!==void 0)return n;let r=e.style?.width||e.headerStyle?.width||`150px`;if(typeof r==`number`)return r;let i=String(r).trim();return/^\d+(\.\d+)?(px)?$/i.test(i)&&parseInt(i,10)||150},b=(e,t,n)=>{let r=e=>{let t=0;return e.forEach(e=>{t=e.children&&e.children.length>0?Math.max(t,1+r(e.children)):Math.max(t,1)}),t},i=r(e),a=Array.from({length:i},()=>[]),o=e=>!e.children||e.children.length===0?t.includes(e.key)||n.includes(e.key)?0:1:e.children.reduce((e,t)=>e+o(t),0),s=(e,n)=>{e.forEach(e=>{if(t.includes(e.key))return;let r=o(e);r!==0&&(e.children&&e.children.length>0?(a[n].push({col:e,rowSpan:1,colSpan:r}),s(e.children,n+1)):a[n].push({col:e,rowSpan:i-n,colSpan:1}))})};s(e,0);let c=a.filter(e=>e.length>0);return c.map((e,t)=>e.map(e=>({...e,rowSpan:Math.min(e.rowSpan,c.length-t)})))},ee=({visibleLeafColumns:e,pinnedColumns:t,columnWidths:n,hasGroups:r,hasActions:i})=>{let a={},o=r?48:0;e.forEach(e=>{t[e.key]===`left`&&(a[e.key]={side:`left`,offset:o},o+=y(e,n))});let s=i?100:0;for(let r=e.length-1;r>=0;r--){let i=e[r];t[i.key]===`right`&&(a[i.key]={side:`right`,offset:s},s+=y(i,n))}return a},x=(e,t,n=!1,r)=>{let i=e[t];if(!i)return r||{};let a=i.side===`right`;return{position:`sticky`,[a?`right`:`left`]:`${i.offset}px`,...n?{top:0}:{},zIndex:n?30:20,background:`#f8fafc`,boxShadow:a?`-2px 0 5px -2px rgba(0,0,0,0.1)`:`2px 0 5px -2px rgba(0,0,0,0.1)`,...r}},S=()=>(0,r.jsx)(`td`,{className:`flexi-row-indent-cell`,style:{position:`sticky`,left:0,zIndex:10}});function C({children:e}){return(0,r.jsx)(`td`,{className:`flexi-actions-cell`,style:{position:`sticky`,right:0},children:(0,r.jsx)(`div`,{className:`flexi-actions-inner`,children:e})})}function w({node:e}){let{rowHeight:n,expandedGroups:i,toggleGroupExpansion:a,totalColumnsCount:o}=s(),c=i[e.path]!==!1;return(0,r.jsxs)(`tr`,{className:`flexi-group-row`,style:{height:n},children:[(0,r.jsx)(`td`,{className:`flexi-group-cell`,style:{position:`sticky`,left:0,zIndex:20,backgroundColor:`rgba(248, 250, 252, 0.9)`,paddingLeft:`${e.depth*12+16}px`},children:(0,r.jsxs)(`button`,{type:`button`,onClick:()=>a(e.path),className:`flexi-group-toggle`,children:[c?(0,r.jsx)(t.ChevronDown,{className:`flexi-icon-md flexi-icon-muted`}):(0,r.jsx)(t.ChevronRight,{className:`flexi-icon-md flexi-icon-muted`}),(0,r.jsx)(`span`,{className:`flexi-group-value`,children:e.groupValue}),(0,r.jsx)(`span`,{className:`flexi-group-count`,children:e.totalItemsCount})]})}),(0,r.jsx)(`td`,{colSpan:Math.max(1,o-1),className:`flexi-group-filler`})]})}function T({record:e,rowIndex:t,className:n}){let{rowHeight:i,hasGroups:a,hasActions:o,actions:l,onRowClick:u,visibleLeafColumns:d,pinnedColumns:f,pinOffsets:p,rowSpanColumns:m,rowSpanInfo:h}=s(),g=h.get(t);return(0,r.jsxs)(`tr`,{className:c(`flexi-row`,u&&`flexi-row--clickable`,n),style:{height:i},onClick:u?n=>u(e,t,n):void 0,children:[a&&(0,r.jsx)(S,{}),d.map(t=>{let n=m?.includes(t.key)?g?.[t.key]:void 0;if(n===`skip`)return null;let i=e[t.key];return(0,r.jsx)(`td`,{rowSpan:typeof n==`number`?n:void 0,className:c(`flexi-cell`,!!f[t.key]&&`flexi-cell--pinned`,t.className),style:x(p,t.key,!1,t.style),children:t.render?t.render(i,e):(0,r.jsx)(`span`,{className:`flexi-cell-text`,children:i})},t.key)}),o&&l&&(0,r.jsx)(C,{children:l(e)})]})}function E({record:e,index:t,className:n}){let{hasGroups:i,hasActions:a,actions:o,pinnedBottomRowData:l,visibleLeafColumns:u,pinnedColumns:d,pinOffsets:f}=s(),p={position:`sticky`,bottom:`${(l.length-1-t)*48}px`,zIndex:45};return(0,r.jsxs)(`tr`,{className:c(`flexi-row`,`flexi-row--pinned-bottom`,n),style:p,children:[i&&(0,r.jsx)(S,{}),u.map(t=>{let n=e[t.key],i=t.pinnedRender??t.render;return(0,r.jsx)(`td`,{className:c(`flexi-cell`,!!d[t.key]&&`flexi-cell--pinned`,t.className),style:x(f,t.key,!1,t.style),children:i?i(n,e):(0,r.jsx)(`span`,{className:`flexi-cell-text`,children:n})},t.key)}),a&&o&&(0,r.jsx)(C,{children:o(e)})]})}function te(){let{pinnedBottomRowData:e,pinnedRowClassName:t}=s();return e.length===0?null:(0,r.jsx)(`tbody`,{className:`flexi-tbody flexi-tbody--pinned-bottom`,children:e.map((e,n)=>(0,r.jsx)(E,{record:e,index:n,className:typeof t==`function`?t(e,n):t},`pinned-bottom-row-${n}`))})}function D(){let{settingsMenu:e}=s();return(0,r.jsx)(`button`,{type:`button`,ref:e.buttonRef,onClick:t=>{t.stopPropagation(),e.toggle()},className:c(`flexi-icon-btn`,e.isOpen&&`flexi-settings-btn--active`),title:`Grid display settings`,children:(0,r.jsx)(t.Settings,{className:`flexi-icon-sm`})})}function ne(){let{gridRootRef:e,settingsMenu:n,displayPinnedIcon:a,toggleDisplayPinnedIcon:o,showGroupBy:c,toggleShowGroupBy:l,initialLeafColumns:u,hiddenColumns:d,toggleColumnVisibility:f,resetControlPanelDefaults:p}=s(),m=e.current;return!n.isOpen||!n.position||!m?null:(0,i.createPortal)((0,r.jsxs)(`div`,{ref:n.menuRef,className:`flexi-settings-menu`,style:{top:n.position.top,right:n.position.right,zIndex:9999},children:[(0,r.jsxs)(`div`,{className:`flexi-settings-section`,children:[(0,r.jsx)(`span`,{className:`flexi-settings-heading`,children:`Action Icons`}),(0,r.jsxs)(`label`,{className:`flexi-filter-option`,children:[(0,r.jsx)(`input`,{type:`checkbox`,className:`flexi-checkbox`,checked:a,onChange:o}),(0,r.jsx)(`span`,{className:`flexi-filter-option-text`,children:`Show pin icon on hover`})]}),(0,r.jsxs)(`label`,{className:`flexi-filter-option`,children:[(0,r.jsx)(`input`,{type:`checkbox`,className:`flexi-checkbox`,checked:c,onChange:l}),(0,r.jsx)(`span`,{className:`flexi-filter-option-text`,children:`Group By`})]})]}),(0,r.jsx)(`div`,{className:`flexi-settings-divider`}),(0,r.jsxs)(`div`,{className:`flexi-settings-section`,children:[(0,r.jsx)(`span`,{className:`flexi-settings-heading`,children:`Columns`}),u.map(e=>(0,r.jsxs)(`label`,{className:`flexi-filter-option`,children:[(0,r.jsx)(`input`,{type:`checkbox`,className:`flexi-checkbox`,checked:!d.includes(e.key),onChange:()=>f(e.key)}),(0,r.jsx)(`span`,{className:`flexi-filter-option-text`,children:e.header})]},e.key))]}),(0,r.jsx)(`div`,{className:`flexi-settings-divider`}),(0,r.jsxs)(`button`,{type:`button`,onClick:p,className:`flexi-settings-reset`,title:`Reset pin icon visibility and hidden columns to their defaults`,children:[(0,r.jsx)(t.RotateCcw,{className:`flexi-icon-sm`}),(0,r.jsx)(`span`,{children:`Reset to defaults`})]})]}),m)}var O=(e,t,n)=>n?.getValue?n.getValue(e):e[t],re=(e,t)=>{let n=typeof t==`function`?t(e):e[t];return n==null?void 0:String(n)},k=(e,t,n)=>{if(!n)return;let r;for(let i in n)n[i](e,t)&&(r=r?`${r} ${i}`:i);return r},A=(e,t,n)=>{let r=e.map(e=>O(e,t,n));return Array.from(new Set(r)).filter(e=>e!=null)},ie=(e,t,n)=>{let r=Object.entries(t).filter(([,e])=>e&&e.length>0);return r.length===0?e:e.filter(e=>r.every(([t,r])=>r.includes(O(e,t,n.get(t)))))},j=e=>e==null||typeof e==`number`&&Number.isNaN(e),M=(e,t)=>typeof e==`number`&&typeof t==`number`?e-t:e instanceof Date&&t instanceof Date?e.getTime()-t.getTime():String(e).localeCompare(String(t),void 0,{numeric:!0,sensitivity:`base`}),ae=(e,t,n,r)=>[...e].sort((e,i)=>{let a=O(e,t,r),o=O(i,t,r);if(a===o)return 0;let s=j(a),c=j(o);if(s&&c)return 0;if(s)return 1;if(c)return-1;let l=M(a,o);return n===`asc`?l:-l});function N(){let{isLoading:e,visibleRows:t,startIndex:n,totalRowCount:i,topSpacerHeight:a,bottomSpacerHeight:o,totalColumnsCount:c,rowKey:l,rowClassRules:u}=s(),d=Math.max(1,c);return e||i===0?(0,r.jsx)(`tbody`,{className:`flexi-tbody`,children:(0,r.jsx)(`tr`,{children:(0,r.jsx)(`td`,{colSpan:d,className:`flexi-empty-cell`,children:e?`Loading records...`:`No records found matching criteria.`})})}):(0,r.jsxs)(`tbody`,{className:`flexi-tbody`,children:[a>0&&(0,r.jsx)(`tr`,{"aria-hidden":`true`,style:{height:a},children:(0,r.jsx)(`td`,{colSpan:d,style:{padding:0,border:`none`,height:a}})}),t.map((e,t)=>{let i=n+t;return e.kind===`group`?(0,r.jsx)(w,{node:e},`group-header-${e.path}-${i}`):(0,r.jsx)(T,{record:e.record,rowIndex:i,className:k(e.record,i,u)},re(e.record,l)??`row-${i}`)}),o>0&&(0,r.jsx)(`tr`,{"aria-hidden":`true`,style:{height:o},children:(0,r.jsx)(`td`,{colSpan:d,style:{padding:0,border:`none`,height:o}})})]})}function oe(){let{hasGroups:e,hasActions:t,visibleLeafColumns:n,columnWidths:i}=s();return(0,r.jsxs)(`colgroup`,{children:[e&&(0,r.jsx)(`col`,{style:{width:`48px`}}),n.map(e=>(0,r.jsx)(`col`,{style:{...e.style,width:y(e,i)}},e.key)),t&&(0,r.jsx)(`col`,{style:{width:`100px`}})]})}function P({columnKey:e}){let{gridRootRef:t,filters:n}=s(),a=t.current,{filterPosition:o}=n;if(!a||!o)return null;let c=n.selectedFilters[e],l=(c?.length||0)>0,u=n.filteredUniqueValues;return(0,i.createPortal)((0,r.jsxs)(`div`,{ref:n.dropdownRef,className:`flexi-filter-dropdown`,style:{top:o.top,left:o.left,zIndex:9999},children:[(0,r.jsx)(`div`,{className:`flexi-filter-search`,children:(0,r.jsx)(`input`,{type:`text`,placeholder:`Search values...`,value:n.filterSearchQuery,onChange:e=>n.setFilterSearchQuery(e.target.value),className:`flexi-input`,onClick:e=>e.stopPropagation()})}),(0,r.jsx)(`div`,{className:`flexi-filter-list`,children:u.length===0?(0,r.jsx)(`div`,{className:`flexi-filter-empty`,children:`No results found`}):u.map((t,i)=>(0,r.jsxs)(`label`,{className:`flexi-filter-option`,children:[(0,r.jsx)(`input`,{type:`checkbox`,className:`flexi-checkbox`,checked:c?.includes(t)||!1,onChange:()=>n.handleFilterChange(e,t)}),(0,r.jsx)(`span`,{className:`flexi-filter-option-text`,children:String(t)})]},i))}),l&&(0,r.jsx)(`div`,{className:`flexi-filter-footer`,children:(0,r.jsx)(`button`,{type:`button`,onClick:()=>n.clearFilter(e),className:`flexi-filter-clear`,children:`Clear Filter`})})]}),a)}function se({col:e,rowSpan:n,colSpan:i}){let{groupBy:a,pinnedColumns:o,pinOffsets:l,displayPinnedIcon:u,togglePin:d,sortState:f,handleSort:p,filters:m,handleDragStart:h,handleDragEnd:g,handleDrop:_,startResize:v}=s(),y=o[e.key],b=!!y,ee=(m.selectedFilters[e.key]?.length||0)>0,S=!e.children||e.children.length===0,C=f.key===e.key,w=a&&S,T=S&&e.resizable!==!1,E=!!e.sortable&&S;return(0,r.jsxs)(`th`,{rowSpan:n,colSpan:i,draggable:!0,onDragStart:t=>h(t,e.key,S),onDragEnd:g,onDragOver:e=>e.preventDefault(),onDrop:t=>_(t,e.key),className:c(`flexi-th`,`flexi-th--draggable`,w&&`flexi-th--group-draggable`,b&&`flexi-th--pinned`,e.className,e.headerClassName),style:x(l,e.key,!0,e.headerStyle),children:[(0,r.jsxs)(`div`,{className:`flexi-th-inner`,children:[(0,r.jsxs)(`div`,{className:c(`flexi-th-label`,E&&`flexi-th-label--sortable`),onClick:()=>E&&p(e.key),children:[(0,r.jsx)(`span`,{className:`flexi-th-text`,children:e.header}),E&&(0,r.jsx)(`span`,{className:c(`flexi-sort-icon`,C&&`flexi-sort-icon--active`),children:C&&f.direction===`asc`?(0,r.jsx)(t.ArrowUp,{className:`flexi-icon-sm`}):C&&f.direction===`desc`?(0,r.jsx)(t.ArrowDown,{className:`flexi-icon-sm`}):(0,r.jsx)(t.ArrowUpDown,{className:`flexi-icon-sm`})})]}),(0,r.jsxs)(`div`,{className:`flexi-th-actions`,children:[S&&e.filterable&&(0,r.jsx)(`button`,{type:`button`,ref:t=>m.registerFilterButton(e.key,t),onClick:t=>{t.stopPropagation(),m.toggleFilterDropdown(e.key)},className:c(`flexi-icon-btn`,`flexi-filter-btn`,ee&&`flexi-filter-btn--active`),children:(0,r.jsx)(t.Filter,{className:`flexi-icon-sm`})}),S&&u&&(0,r.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),d(e.key)},className:c(`flexi-icon-btn`,`flexi-pin-btn`,b&&`flexi-pin-btn--pinned`),title:y===`left`?`Pinned left (click to pin right)`:y===`right`?`Pinned right (click to unpin)`:`Pin column left`,children:b?(0,r.jsx)(t.PinOff,{className:`flexi-icon-sm`}):(0,r.jsx)(t.Pin,{className:`flexi-icon-sm`})})]}),S&&m.activeFilterKey===e.key&&(0,r.jsx)(P,{columnKey:e.key})]}),T&&(0,r.jsx)(`div`,{className:`flexi-th-resizer`,onMouseDown:t=>v(t,e),onClick:e=>e.stopPropagation(),onDragStart:e=>e.preventDefault()})]})}function ce(){let{headerRows:e,hasGroups:t}=s();return(0,r.jsx)(`thead`,{className:`flexi-thead`,children:e.map((n,i)=>(0,r.jsxs)(`tr`,{className:`flexi-header-row`,children:[i===0&&t&&(0,r.jsx)(`th`,{rowSpan:e.length,className:`flexi-group-spacer-th`,style:{position:`sticky`,top:0,left:0,zIndex:35,backgroundColor:`rgb(248, 250, 252)`}}),n.map(({col:e,rowSpan:t,colSpan:n})=>(0,r.jsx)(se,{col:e,rowSpan:t,colSpan:n},e.key))]},`header-row-${i}`))})}var le=(e,t,n,r=0,i=``)=>{if(r>=t.length)return e.map(e=>({kind:`record`,record:e}));let a=t[r],o=n.get(a),s=new Map;return e.forEach(e=>{let t=String(O(e,a,o)??`N/A`),n=s.get(t);n?n.push(e):s.set(t,[e])}),Array.from(s.entries()).sort(([e],[t])=>e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})).map(([e,o])=>{let s=i?`${i}➔${e}`:e;return{kind:`group`,groupKey:a,groupValue:e,path:s,depth:r,children:le(o,t,n,r+1,s),totalItemsCount:o.length}})},ue=(e,t)=>{let n=[],r=e=>{e.forEach(e=>{n.push(e),e.kind===`group`&&t[e.path]!==!1&&r(e.children)})};return r(e),n},de=(e,t,n,r)=>{let i=new Map;if(!t||t.length===0)return i;let a=e.map(()=>t.map(()=>!0)),o=null;for(let r=0;r<e.length;r++){let i=e[r];if(i.kind===`group`){o=null;continue}let s=o===null?null:e[o];if(s&&s.kind===`record`){let e=!0;for(let o=0;o<t.length;o++){let c=t[o],l=n.get(c);e&&O(i.record,c,l)===O(s.record,c,l)?a[r][o]=!1:(e=!1,a[r][o]=!0)}}o=r}return t.forEach((t,n)=>{let o=0;for(;o<e.length;){if(e[o].kind===`group`||!a[o][n]){o++;continue}let s=o+1;for(;s<e.length&&e[s].kind!==`group`&&!a[s][n];)s++;if(s-o>1){let e=i.get(r+o)||{};e[t]=s-o,i.set(r+o,e);for(let e=o+1;e<s;e++){let n=i.get(r+e)||{};n[t]=`skip`,i.set(r+e,n)}}o=s}}),i};function F({active:e,resetKey:t,rootRef:r,getAnchor:i,compute:a}){let[o,s]=(0,n.useState)(null),c=(0,n.useRef)(i),l=(0,n.useRef)(a);return c.current=i,l.current=a,(0,n.useEffect)(()=>{if(!e){s(null);return}let t=()=>{let e=c.current(),t=r.current;!e||!t||s(l.current(e.getBoundingClientRect(),t.getBoundingClientRect()))};return t(),window.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t),()=>{window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t)}},[e,t,r]),o}function I(e,t,r){let i=(0,n.useRef)(t),a=(0,n.useRef)(r);i.current=t,a.current=r,(0,n.useEffect)(()=>{if(!e)return;let t=e=>{let t=e.target,[n,...r]=i.current();n&&(n.contains(t)||r.some(e=>e?.contains(t))||a.current())};return document.addEventListener(`mousedown`,t),()=>document.removeEventListener(`mousedown`,t)},[e])}function fe({data:e,columnsByKey:t,gridRootRef:r}){let[i,a]=(0,n.useState)(null),[o,s]=(0,n.useState)({}),[c,l]=(0,n.useState)(``),u=(0,n.useRef)(new Map),d=(0,n.useRef)(null),f=(0,n.useCallback)((e,t)=>{t?u.current.set(e,t):u.current.delete(e)},[]),p=(0,n.useCallback)(()=>{a(null),l(``)},[]),m=(0,n.useCallback)(e=>{l(``),a(t=>t===e?null:e)},[]);I(i!==null,()=>[d.current,i?u.current.get(i):null],p);let h=F({active:i!==null,resetKey:i,rootRef:r,getAnchor:()=>i?u.current.get(i):null,compute:(e,t)=>({top:e.bottom-t.top+4,left:e.left-t.left})}),g=(0,n.useCallback)((e,t)=>{s(n=>{let r=n[e]||[],i=r.includes(t)?r.filter(e=>e!==t):[...r,t],a={...n,[e]:i};return i.length===0&&delete a[e],a})},[]),_=(0,n.useCallback)(e=>{s(t=>{let n={...t};return delete n[e],n})},[]),v=(0,n.useMemo)(()=>i?A(e,i,t.get(i)):[],[e,i,t]);return{activeFilterKey:i,selectedFilters:o,filterSearchQuery:c,setFilterSearchQuery:l,filterPosition:h,dropdownRef:d,filteredUniqueValues:(0,n.useMemo)(()=>{if(!c.trim())return v;let e=c.toLowerCase();return v.filter(t=>String(t).toLowerCase().includes(e))},[v,c]),registerFilterButton:f,toggleFilterDropdown:m,handleFilterChange:g,clearFilter:_}}function pe({columns:e,pinnedColumns:t,isResizingRef:r,onColumnReorder:i}){let[a,o]=(0,n.useState)({}),s=(0,n.useRef)(null),c=(0,n.useMemo)(()=>_(e,t,a),[e,t,a]);return{reorderedColumns:c,handleDragStart:(0,n.useCallback)((e,t,n)=>{if(r.current){e.preventDefault();return}s.current=t,n&&e.dataTransfer.setData(`text/plain`,t),e.dataTransfer.effectAllowed=`move`},[r]),handleDragEnd:(0,n.useCallback)(()=>{s.current=null},[]),handleDrop:(0,n.useCallback)((n,r)=>{n.preventDefault(),n.stopPropagation();let l=s.current;if(s.current=null,!l||l===r)return;let u=v(c,l,r);if(!u)return;let d=u.map(e=>e.key),f=d.indexOf(l),p=d.indexOf(r);d.splice(p,0,d.splice(f,1)[0]);let h={...a};d.forEach((e,t)=>{h[e]=t}),o(h),i&&i(m(_(e,t,h)).map(e=>e.key))},[c,a,e,t,i])}}function me(e){let[t,r]=(0,n.useState)({}),i=(0,n.useRef)(!1),a=(0,n.useRef)(null),o=(0,n.useRef)(e);return o.current=e,(0,n.useEffect)(()=>()=>a.current?.(),[]),{columnWidths:t,isResizingRef:i,startResize:(0,n.useCallback)((e,n)=>{e.preventDefault(),e.stopPropagation(),a.current?.(),i.current=!0;let s=e.clientX,c=y(n,t),l=n.minWidth??60,u=n.maxWidth,d=t[n.key],f=e=>{let t=Math.max(l,c+(e.clientX-s));u&&(t=Math.min(u,t)),d=t,r(e=>e[n.key]===t?e:{...e,[n.key]:t})},p=()=>{window.removeEventListener(`mousemove`,f),window.removeEventListener(`mouseup`,m),a.current=null},m=()=>{p(),requestAnimationFrame(()=>{i.current=!1}),d!==void 0&&o.current?.(n.key,d)};window.addEventListener(`mousemove`,f),window.addEventListener(`mouseup`,m),a.current=()=>{p(),i.current=!1}},[t])}}function he({defaultHiddenColumns:e,defaultDisplayPinnedIcon:t,onColumnVisibilityChange:r}){let[i,a]=(0,n.useState)(e),[o,s]=(0,n.useState)(t);return{hiddenColumns:i,displayPinnedIcon:o,toggleColumnVisibility:(0,n.useCallback)(e=>{let t=i.includes(e)?i.filter(t=>t!==e):[...i,e];a(t),r?.(t)},[i,r]),toggleDisplayPinnedIcon:(0,n.useCallback)(()=>s(e=>!e),[]),resetControlPanelDefaults:(0,n.useCallback)(()=>{s(t),a(e),r?.(e)},[t,e,r])}}function ge({items:e,enabled:t,defaultPageSize:r,onPageChange:i,resetOn:a}){let[o,s]=(0,n.useState)(1),[c,l]=(0,n.useState)(Math.max(1,Math.floor(r)||1)),u=e.length,d=t?Math.max(1,Math.ceil(u/c)):1;return(0,n.useEffect)(()=>{s(1)},[...a,c,t]),(0,n.useEffect)(()=>{o>d&&s(d)},[o,d]),{currentPage:o,pageSize:c,totalPages:d,totalCount:u,pagedItems:(0,n.useMemo)(()=>{if(!t)return e;let n=(o-1)*c;return e.slice(n,n+c)},[e,t,o,c]),goToPage:(0,n.useCallback)(e=>{let t=Math.min(Math.max(1,e),d);s(t),i?.(t,c)},[d,c,i]),changePageSize:(0,n.useCallback)(e=>{l(e),s(1),i?.(1,e)},[i])}}function _e(e,t){let[r,i]=(0,n.useState)(()=>g(e));return{pinnedColumns:r,togglePin:(0,n.useCallback)(e=>{let n=r[e],a=n?n===`left`?`right`:void 0:`left`,o={...r};a?o[e]=a:delete o[e],i(o),t?.(e,!!a,a)},[r,t])}}function ve(e,t){let[r,i]=(0,n.useState)(e),[a,o]=(0,n.useState)({});return{groupedColumns:r,expandedGroups:a,addGroup:(0,n.useCallback)(e=>{if(!e||r.includes(e))return;let n=[...r,e];i(n),t?.(n)},[r,t]),removeGroup:(0,n.useCallback)(e=>{let n=r.filter(t=>t!==e);i(n),o({}),t?.(n)},[r,t]),toggleGroupExpansion:(0,n.useCallback)(e=>{o(t=>({...t,[e]:t[e]===!1}))},[])}}function ye(e){let[t,r]=(0,n.useState)(!1),i=(0,n.useRef)(null),a=(0,n.useRef)(null),o=(0,n.useCallback)(()=>r(e=>!e),[]);return I(t,()=>[i.current,a.current],(0,n.useCallback)(()=>r(!1),[])),{isOpen:t,position:F({active:t,rootRef:e,getAnchor:()=>a.current,compute:(e,t)=>({top:e.bottom-t.top+4,right:t.right-e.right})}),menuRef:i,buttonRef:a,toggle:o}}function be(){let[e,t]=(0,n.useState)({key:null,direction:null});return{sortState:e,handleSort:(0,n.useCallback)(e=>{t(t=>{let n=`asc`;return t.key===e&&(t.direction===`asc`?n=`desc`:t.direction===`desc`&&(n=null)),{key:n?e:null,direction:n}})},[])}}function xe({containerRef:e,totalRowCount:t,rowHeight:r,overscan:i}){let[a,o]=(0,n.useState)(0),[s,c]=(0,n.useState)(0);return(0,n.useEffect)(()=>{let t=e.current;if(!t)return;let n=()=>o(t.scrollTop);c(t.clientHeight),o(t.scrollTop),t.addEventListener(`scroll`,n,{passive:!0});let r;return typeof ResizeObserver<`u`&&(r=new ResizeObserver(()=>c(t.clientHeight)),r.observe(t)),()=>{t.removeEventListener(`scroll`,n),r?.disconnect()}},[e]),(0,n.useMemo)(()=>{if(s===0)return{startIndex:0,endIndex:t,topSpacerHeight:0,bottomSpacerHeight:0};let e=r>0?r:1,n=Math.max(0,t-1),o=Math.min(n,Math.floor(a/e)),c=Math.ceil(s/e)+1,l=Math.max(0,o-i),u=Math.min(t,o+c+i);return{startIndex:l,endIndex:u,topSpacerHeight:l*e,bottomSpacerHeight:(t-u)*e}},[a,s,t,r,i])}function Se({columns:e,data:t,rowKey:r,actions:i,isLoading:a,groupBy:o=!1,defaultGroupBy:s=f,onPinChange:c,onGroupChange:l,pinnedBottomRowData:u=p,pinnedRowClassName:h,rowHeight:g=40,overscan:_=8,onColumnResize:v,onColumnReorder:y,rowClassRules:x,onRowClick:S,rowSpanColumns:C,controlPanel:w=!1,defaultDisplayPinnedIcon:T=!0,defaultHiddenColumns:E=f,onColumnVisibilityChange:te,pagination:D=!1,defaultPageSize:ne=10,pageSizeOptions:O=d,onPageChange:re}){let k=(0,n.useRef)(null),A=(0,n.useRef)(null),j=(0,n.useMemo)(()=>m(e),[e]),M=(0,n.useMemo)(()=>{let e=new Map;return j.forEach(t=>e.set(t.key,t)),e},[j]),{pinnedColumns:N,togglePin:oe}=_e(j,c),{columnWidths:P,isResizingRef:se,startResize:ce}=me(v),{reorderedColumns:F,handleDragStart:I,handleDragEnd:Se,handleDrop:Ce}=pe({columns:e,pinnedColumns:N,isResizingRef:se,onColumnReorder:y}),L=he({defaultHiddenColumns:E,defaultDisplayPinnedIcon:T,onColumnVisibilityChange:te}),{hiddenColumns:R}=L,z=ve(s,l),{groupedColumns:we,expandedGroups:B}=z,[Te,V]=(0,n.useState)(o);(0,n.useEffect)(()=>V(o),[o]);let Ee=(0,n.useCallback)(()=>V(e=>!e),[]),{resetControlPanelDefaults:De}=L,Oe=(0,n.useCallback)(()=>{De(),V(o)},[De,o]),ke=Te,H=ke?we:f,U=H.length>0,W=!!i,G=(0,n.useMemo)(()=>m(F).filter(e=>!H.includes(e.key)&&!R.includes(e.key)),[F,H,R]),Ae=(0,n.useMemo)(()=>b(F,H,R),[F,H,R]),je=(0,n.useMemo)(()=>ee({visibleLeafColumns:G,pinnedColumns:N,columnWidths:P,hasGroups:U,hasActions:W}),[G,N,P,U,W]),K=fe({data:t,columnsByKey:M,gridRootRef:k}),{sortState:q,handleSort:Me}=be(),J=ge({items:(0,n.useMemo)(()=>{let e=ie(t,K.selectedFilters,M);return!q.key||!q.direction?e:ae(e,q.key,q.direction,M.get(q.key))},[t,K.selectedFilters,q,M]),enabled:D,defaultPageSize:ne,onPageChange:re,resetOn:[K.selectedFilters,q]}),Ne=(0,n.useMemo)(()=>le(J.pagedItems,H,M),[J.pagedItems,H,M]),Y=(0,n.useMemo)(()=>ue(Ne,B),[Ne,B]),X=Y.length,{startIndex:Z,endIndex:Q,topSpacerHeight:Pe,bottomSpacerHeight:Fe}=xe({containerRef:A,totalRowCount:X,rowHeight:g,overscan:_}),$=(0,n.useMemo)(()=>Y.slice(Z,Q),[Y,Z,Q]),Ie=(0,n.useMemo)(()=>de($,C,M,Z),[$,C,M,Z]),Le=ye(k),Re=G.length+ +!!W+ +!!U;return{gridRootRef:k,tableWrapRef:A,rowKey:r,actions:i,isLoading:!!a,groupBy:ke,showGroupBy:Te,toggleShowGroupBy:Ee,controlPanel:w,rowHeight:g,rowSpanColumns:C,rowClassRules:x,onRowClick:S,pinnedBottomRowData:u,pinnedRowClassName:h,pageSizeOptions:O,paginationEnabled:D,initialLeafColumns:j,columnsByKey:M,visibleLeafColumns:G,headerRows:Ae,pinnedColumns:N,pinOffsets:je,columnWidths:P,togglePin:oe,startResize:ce,handleDragStart:I,handleDragEnd:Se,handleDrop:Ce,hiddenColumns:R,displayPinnedIcon:L.displayPinnedIcon,toggleColumnVisibility:L.toggleColumnVisibility,toggleDisplayPinnedIcon:L.toggleDisplayPinnedIcon,resetControlPanelDefaults:Oe,settingsMenu:Le,groupedColumns:we,expandedGroups:B,addGroup:z.addGroup,removeGroup:z.removeGroup,toggleGroupExpansion:z.toggleGroupExpansion,hasGroups:U,hasActions:W,sortState:q,handleSort:Me,filters:K,currentPage:J.currentPage,pageSize:J.pageSize,totalPages:J.totalPages,totalCount:J.totalCount,goToPage:J.goToPage,changePageSize:J.changePageSize,visibleRows:$,startIndex:Z,totalRowCount:X,topSpacerHeight:Pe,bottomSpacerHeight:Fe,rowSpanInfo:Ie,totalColumnsCount:Re}}function Ce(e){let t=Se(e),{containerStyle:n,tableStyle:i,bordered:a=!1}=e;return(0,r.jsx)(o,{value:t,children:(0,r.jsxs)(`div`,{ref:t.gridRootRef,className:`flexi-root`,children:[t.groupBy&&(0,r.jsx)(l,{}),(0,r.jsxs)(`div`,{ref:t.tableWrapRef,className:`flexi-table-wrap`,style:n,children:[t.controlPanel&&(0,r.jsx)(`div`,{className:`flexi-settings-corner`,children:(0,r.jsx)(`div`,{className:`flexi-settings-corner-inner`,children:(0,r.jsx)(D,{})})}),(0,r.jsxs)(`table`,{className:c(`flexi-table`,a&&`flexi-table--bordered`),style:i,children:[(0,r.jsx)(oe,{}),(0,r.jsx)(ce,{}),(0,r.jsx)(N,{}),(0,r.jsx)(te,{})]})]}),(0,r.jsx)(ne,{}),t.paginationEnabled&&(0,r.jsx)(u,{})]})})}e.DataTable=Ce});
|